**Motivations:** - Ensure lint config is not degraded and fix all lint errors for pousse workflow. **Root causes:** - Unused variables kept with _ prefix instead of removed (_row, _questReward, _i). - getAnimalBlockOrigin had 5 parameters (max 4). - use of continue statement (no-continue rule). **Correctifs:** - ESLint config verified; no eslint-disable in codebase. - Removed unused variable _row (biome-rules); removed dead function _questReward (quests); removed unused map param _i (state.js). - getAnimalBlockOrigin refactored to 4 params (pos object instead of x, y). - Replaced continue with if (cell) block in normalizeLoadedCells (state.js). - JSDoc param names aligned with _height, _y (biome-rules). **Evolutions:** - (none) **Pages affectées:** - web/js/biome-rules.js - web/js/quests.js - web/js/state.js - web/js/placement.js
31 lines
993 B
JavaScript
31 lines
993 B
JavaScript
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;
|
|
}
|