|
@@ -79,11 +79,11 @@ async function _render(planetName: string, pop: Pop) {
|
|
|
'education': calcTotalNeeds(lastPOPR, 'education'),
|
|
'education': calcTotalNeeds(lastPOPR, 'education'),
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const currentPOPIFilled: Map<POPIBuilding, number> = new Map();
|
|
|
|
|
|
|
+ const currentPOPIFilled: POPIFill = new Map();
|
|
|
for (const infra of infras) {
|
|
for (const infra of infras) {
|
|
|
const filled = calcPOPIFilled(infra);
|
|
const filled = calcPOPIFilled(infra);
|
|
|
if (filled !== null)
|
|
if (filled !== null)
|
|
|
- currentPOPIFilled.set(infra.Type, filled);
|
|
|
|
|
|
|
+ currentPOPIFilled.set(infra.Type, {tier: infra.CurrentLevel, numMats: filled});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// gen
|
|
// gen
|
|
@@ -153,10 +153,10 @@ async function _render(planetName: string, pop: Pop) {
|
|
|
${infras.map((infra) => {
|
|
${infras.map((infra) => {
|
|
|
if (infra.CurrentLevel === 0)
|
|
if (infra.CurrentLevel === 0)
|
|
|
return '';
|
|
return '';
|
|
|
- const filled = currentPOPIFilled.get(infra.Type)!;
|
|
|
|
|
|
|
+ const fill = currentPOPIFilled.get(infra.Type)!;
|
|
|
return `<tr>
|
|
return `<tr>
|
|
|
<td>${infra.Type} T${infra.CurrentLevel}</td>
|
|
<td>${infra.Type} T${infra.CurrentLevel}</td>
|
|
|
- <td>${filled}/${infra.Upkeeps.length}</td>
|
|
|
|
|
|
|
+ <td>${fill.numMats}/${infra.Upkeeps.length}</td>
|
|
|
</tr>`;
|
|
</tr>`;
|
|
|
}).join('')}
|
|
}).join('')}
|
|
|
</tr>
|
|
</tr>
|
|
@@ -168,7 +168,7 @@ async function _render(planetName: string, pop: Pop) {
|
|
|
${[...popiFillCombinations(currentPOPIFilled)].map((combination) => {
|
|
${[...popiFillCombinations(currentPOPIFilled)].map((combination) => {
|
|
|
const happiness = projectedHappiness(pop, totalNeeds, siteCount, combination);
|
|
const happiness = projectedHappiness(pop, totalNeeds, siteCount, combination);
|
|
|
return `<tr>
|
|
return `<tr>
|
|
|
- <td>${[...combination.entries()].map(([building, filled]) => `${building}: ${filled}`).join(', ')}</td>
|
|
|
|
|
|
|
+ <td>${[...combination.entries()].map(([building, fill]) => `${building}: ${fill.numMats}`).join(', ')}</td>
|
|
|
<td>${formatPct(happiness)}</td>
|
|
<td>${formatPct(happiness)}</td>
|
|
|
</tr>`;
|
|
</tr>`;
|
|
|
}).join('')}
|
|
}).join('')}
|
|
@@ -225,30 +225,30 @@ function calcPOPIFilled(infra: Infrastructure): number | null {
|
|
|
return filled;
|
|
return filled;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function* popiFillCombinations(currentPOPIFilled: Map<POPIBuilding, number>): Generator<Map<POPIBuilding, number>> {
|
|
|
|
|
|
|
+function* popiFillCombinations(currentPOPIFilled: POPIFill): Generator<POPIFill> {
|
|
|
const entries = [...currentPOPIFilled.keys()];
|
|
const entries = [...currentPOPIFilled.keys()];
|
|
|
- function* helper(index: number, current: Map<POPIBuilding, number>): Generator<Map<POPIBuilding, number>> {
|
|
|
|
|
|
|
+ function* helper(index: number, current: POPIFill): Generator<POPIFill> {
|
|
|
if (index === entries.length) {
|
|
if (index === entries.length) {
|
|
|
yield new Map(current);
|
|
yield new Map(current);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const building = entries[index];
|
|
const building = entries[index];
|
|
|
|
|
+ const tier = currentPOPIFilled.get(building)!.tier;
|
|
|
for (let i = 0; i <= POPI[building].max; i++) {
|
|
for (let i = 0; i <= POPI[building].max; i++) {
|
|
|
- current.set(building, i);
|
|
|
|
|
|
|
+ current.set(building, {tier, numMats: i});
|
|
|
yield* helper(index + 1, current);
|
|
yield* helper(index + 1, current);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
yield* helper(0, new Map());
|
|
yield* helper(0, new Map());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function projectedHappiness(pop: Pop, totalNeeds: Record<Need, number>, siteCount: number,
|
|
|
|
|
- popiFilled: Map<POPIBuilding, number>): number {
|
|
|
|
|
|
|
+function projectedHappiness(pop: Pop, totalNeeds: Record<Need, number>, siteCount: number, popiFilled: POPIFill): number {
|
|
|
let totalProvided: Record<Need, number> = {'safety': 50 * siteCount, 'health': 50 * siteCount,
|
|
let totalProvided: Record<Need, number> = {'safety': 50 * siteCount, 'health': 50 * siteCount,
|
|
|
'comfort': 0, 'culture': 0, 'education': 0};
|
|
'comfort': 0, 'culture': 0, 'education': 0};
|
|
|
- for (const [building, filled] of popiFilled.entries()) {
|
|
|
|
|
|
|
+ for (const [building, fill] of popiFilled.entries()) {
|
|
|
const {max, needs} = POPI[building];
|
|
const {max, needs} = POPI[building];
|
|
|
for (const {need, satisfaction} of needs) {
|
|
for (const {need, satisfaction} of needs) {
|
|
|
- const provided = filled / max * satisfaction;
|
|
|
|
|
|
|
+ const provided = fill.numMats / max * fill.tier * satisfaction;
|
|
|
totalProvided[need] += provided;
|
|
totalProvided[need] += provided;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -297,6 +297,7 @@ type Need = 'safety' | 'health' | 'comfort' | 'culture' | 'education';
|
|
|
type POPIBuilding = 'SAFETY_STATION' | 'SECURITY_DRONE_POST' | 'EMERGENCY_CENTER' | 'INFIRMARY' | 'HOSPITAL' |
|
|
type POPIBuilding = 'SAFETY_STATION' | 'SECURITY_DRONE_POST' | 'EMERGENCY_CENTER' | 'INFIRMARY' | 'HOSPITAL' |
|
|
|
'WELLNESS_CENTER' | 'WILDLIFE_PARK' | 'ARCADES' | 'ART_CAFE' | 'ART_GALLERY' | 'THEATER' |
|
|
'WELLNESS_CENTER' | 'WILDLIFE_PARK' | 'ARCADES' | 'ART_CAFE' | 'ART_GALLERY' | 'THEATER' |
|
|
|
'PLANETARY_BROADCASTING_HUB' | 'LIBRARY' | 'UNIVERSITY';
|
|
'PLANETARY_BROADCASTING_HUB' | 'LIBRARY' | 'UNIVERSITY';
|
|
|
|
|
+type POPIFill = Map<POPIBuilding, {tier: number, numMats: number}>;
|
|
|
|
|
|
|
|
interface Planet {
|
|
interface Planet {
|
|
|
PopulationReports: POPR[]
|
|
PopulationReports: POPR[]
|