import { LootTables } from "./loot-tables.js"; import { getIncomeMultiplier } from "./mutation-rules.js"; import { getSellValue } from "./economy.js"; import { isOriginCell } from "./grid-utils.js"; /** * Total sell value of all animals in the zoo (used for visitor attraction). Counts each animal block once (origin cell only). * @param {import("./types.js").GameState} state * @returns {number} */ export function getTotalAnimalValue(state) { let total = 0; for (const [key, cell] of Object.entries(state.grid.cells)) { if (cell.kind !== "animal" || !isOriginCell(key, cell)) { // skip } else { const animalDef = LootTables.Animals[cell.id]; if (animalDef !== null && animalDef !== undefined) { const mutationMult = getIncomeMultiplier(cell.mutation); total += getSellValue( animalDef.baseIncomePerSecond, cell.level, mutationMult, animalDef.sellFactor ); } } } return total; }