mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
refactor: lint
This commit is contained in:
parent
2c8f3a16f0
commit
e05f6fc166
1 changed files with 37 additions and 21 deletions
|
|
@ -208,7 +208,12 @@ class StatesModule {
|
||||||
const riverCost = this.getRiverCost(cells.r[e], e, type!);
|
const riverCost = this.getRiverCost(cells.r[e], e, type!);
|
||||||
const typeCost = this.getTypeCost(cells.t[e], type!);
|
const typeCost = this.getTypeCost(cells.t[e], type!);
|
||||||
const cellCost = Math.max(
|
const cellCost = Math.max(
|
||||||
cultureCost + populationCost + biomeCost + heightCost + riverCost + typeCost,
|
cultureCost +
|
||||||
|
populationCost +
|
||||||
|
biomeCost +
|
||||||
|
heightCost +
|
||||||
|
riverCost +
|
||||||
|
typeCost,
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
const totalCost = p + 10 + cellCost / states[s].expansionism!;
|
const totalCost = p + 10 + cellCost / states[s].expansionism!;
|
||||||
|
|
@ -517,13 +522,15 @@ class StatesModule {
|
||||||
.join("")
|
.join("")
|
||||||
.includes(String(t));
|
.includes(String(t));
|
||||||
|
|
||||||
let status = (naval
|
let status = (
|
||||||
? rw(navals)
|
naval
|
||||||
: neib
|
? rw(navals)
|
||||||
? rw(neibs)
|
: neib
|
||||||
: neibOfNeib
|
? rw(neibs)
|
||||||
? rw(neibsOfNeibs)
|
: neibOfNeib
|
||||||
: rw(far)) as DiplomacyStatus;
|
? rw(neibsOfNeibs)
|
||||||
|
: rw(far)
|
||||||
|
) as DiplomacyStatus;
|
||||||
|
|
||||||
// add Vassal
|
// add Vassal
|
||||||
if (
|
if (
|
||||||
|
|
@ -593,12 +600,8 @@ class StatesModule {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ap = sum(
|
ap = sum(attackers.map((a) => states[a].area! * states[a].expansionism!)); // attackers joined power
|
||||||
attackers.map((a) => states[a].area! * states[a].expansionism!),
|
dp = sum(defenders.map((d) => states[d].area! * states[d].expansionism!)); // defender joined power
|
||||||
); // attackers joined power
|
|
||||||
dp = sum(
|
|
||||||
defenders.map((d) => states[d].area! * states[d].expansionism!),
|
|
||||||
); // defender joined power
|
|
||||||
|
|
||||||
// defender allies join
|
// defender allies join
|
||||||
dd.forEach((r, d) => {
|
dd.forEach((r, d) => {
|
||||||
|
|
@ -709,16 +712,22 @@ class StatesModule {
|
||||||
};
|
};
|
||||||
|
|
||||||
const median = (window as any).d3.median(pack.states.map((s) => s.area));
|
const median = (window as any).d3.median(pack.states.map((s) => s.area));
|
||||||
const empireMin = states
|
const empireMin = states.map((s) => s.area!).sort((a, b) => b - a)[
|
||||||
.map((s) => s.area!)
|
Math.max(Math.ceil(states.length ** 0.4) - 2, 0)
|
||||||
.sort((a, b) => b - a)[Math.max(Math.ceil(states.length ** 0.4) - 2, 0)];
|
];
|
||||||
const expTiers = pack.states.map((s) => {
|
const expTiers = pack.states.map((s) => {
|
||||||
let tier = Math.min(Math.floor((s.area! / median) * 2.6), 4);
|
let tier = Math.min(Math.floor((s.area! / median) * 2.6), 4);
|
||||||
if (tier === 4 && s.area! < empireMin) tier = 3;
|
if (tier === 4 && s.area! < empireMin) tier = 3;
|
||||||
return tier;
|
return tier;
|
||||||
});
|
});
|
||||||
|
|
||||||
const monarchy = ["Duchy", "Grand Duchy", "Principality", "Kingdom", "Empire"]; // per expansionism tier
|
const monarchy = [
|
||||||
|
"Duchy",
|
||||||
|
"Grand Duchy",
|
||||||
|
"Principality",
|
||||||
|
"Kingdom",
|
||||||
|
"Empire",
|
||||||
|
]; // per expansionism tier
|
||||||
const republic: Record<string, number> = {
|
const republic: Record<string, number> = {
|
||||||
Republic: 75,
|
Republic: 75,
|
||||||
Federation: 4,
|
Federation: 4,
|
||||||
|
|
@ -768,7 +777,15 @@ class StatesModule {
|
||||||
if (isTheocracy) s.form = "Theocracy";
|
if (isTheocracy) s.form = "Theocracy";
|
||||||
else if (isAnarchy) s.form = "Anarchy";
|
else if (isAnarchy) s.form = "Anarchy";
|
||||||
else s.form = s.type === "Naval" ? rw(naval) : rw(generic);
|
else s.form = s.type === "Naval" ? rw(naval) : rw(generic);
|
||||||
s.formName = this.selectForm(s, tier, monarchy, republic, union, theocracy, anarchy);
|
s.formName = this.selectForm(
|
||||||
|
s,
|
||||||
|
tier,
|
||||||
|
monarchy,
|
||||||
|
republic,
|
||||||
|
union,
|
||||||
|
theocracy,
|
||||||
|
anarchy,
|
||||||
|
);
|
||||||
s.fullName = this.getFullName(s);
|
s.fullName = this.getFullName(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -854,8 +871,7 @@ class StatesModule {
|
||||||
if (tier > 2) return "Patriarchate";
|
if (tier > 2) return "Patriarchate";
|
||||||
}
|
}
|
||||||
if (P(0.9) && [21, 16].includes(base)) return "Imamah"; // Nigerian, Turkish
|
if (P(0.9) && [21, 16].includes(base)) return "Imamah"; // Nigerian, Turkish
|
||||||
if (tier > 2 && P(0.8) && [18, 17, 28].includes(base))
|
if (tier > 2 && P(0.8) && [18, 17, 28].includes(base)) return "Caliphate"; // Arabic, Berber, Swahili
|
||||||
return "Caliphate"; // Arabic, Berber, Swahili
|
|
||||||
return rw(theocracy);
|
return rw(theocracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue