refacto: Changing display of revenues per planet by default + fixing WS for revenues

This commit is contained in:
gauvainboiche
2026-04-02 15:10:51 +02:00
parent a746662db4
commit 5ce2ae6c98
7 changed files with 417 additions and 97 deletions
+24 -1
View File
@@ -3,24 +3,47 @@ import {
getElementBonus,
getMilitaryDeductions,
getActivePlayerCounts,
getActivePlayerNames,
getVictoryPoints,
getGridCells,
} from "./db/gameDb.js";
import { getConfig } from "./configLoader.js";
import { computeTeamIncome, computeTeamMilitaryPower } from "./helpers/economy.js";
export async function buildRealtimeSnapshot(worldSeed) {
const [scores, elementBonus, militaryDeductions, activePlayers, victoryPoints] = await Promise.all([
const [scores, elementBonus, militaryDeductions, activePlayers, playerNames, victoryPoints, rows] = await Promise.all([
getEconScores(worldSeed),
getElementBonus(worldSeed),
getMilitaryDeductions(worldSeed),
getActivePlayerCounts(worldSeed),
getActivePlayerNames(worldSeed),
getVictoryPoints(),
getGridCells(worldSeed),
]);
const cfg = getConfig();
const resourceWorth = cfg.resourceWorth ?? { common: {}, rare: {} };
const militaryPowerCfg = cfg.militaryPower ?? {};
const incomePerSecond = {
blue: computeTeamIncome("blue", rows, resourceWorth),
red: computeTeamIncome("red", rows, resourceWorth),
};
const militaryPowerGross = {
blue: computeTeamMilitaryPower("blue", rows, militaryPowerCfg),
red: computeTeamMilitaryPower("red", rows, militaryPowerCfg),
};
return {
worldSeed,
scores,
elementBonus,
militaryDeductions,
activePlayers,
playerNames,
victoryPoints,
incomePerSecond,
militaryPowerGross,
};
}