refacto: Changing display of revenues per planet by default + fixing WS for revenues
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user