Lint: fix errors and remove unused variables

**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
This commit is contained in:
ncantu
2026-03-04 15:32:27 +01:00
parent d8a55daf3f
commit c7d389ecbb
57 changed files with 4664 additions and 3049 deletions

View File

@@ -14,6 +14,24 @@ import { tickFeeding, checkDeathCauses, getFeedingRate } from "./food.js";
import { tickReproduction, getReproductionScore } from "./reproduction.js";
import { tickVisitorIncidents } from "./visitor-incidents.js";
import { tickSaleListings } from "./trade.js";
import { getCurrentSeason } from "./seasons.js";
/**
* @param {import("./types.js").GameState} state
* @param {number} pointsPerLevelPerSecond
* @param {number} dt
* @returns {number}
*/
function sumResearchPointsFromCells(state, pointsPerLevelPerSecond, dt) {
let total = 0;
for (const [, cell] of Object.entries(state.grid.cells)) {
if (cell !== null && cell !== undefined && cell.kind === "research") {
const level = cell.level ?? 1;
total += pointsPerLevelPerSecond * level * dt;
}
}
return total;
}
/**
* Add research points from all research cells. PointsPerTickPerLevel * level per second.
@@ -24,17 +42,8 @@ import { tickSaleListings } from "./trade.js";
function tickResearch(state, dt) {
const cfg = GameConfig.Research;
if (!cfg || cfg.PointsPerTickPerLevel === null || cfg.PointsPerTickPerLevel === undefined) return;
const pointsPerLevelPerSecond = cfg.PointsPerTickPerLevel;
let total = 0;
for (const [, cell] of Object.entries(state.grid.cells)) {
if (cell !== null && cell !== undefined && cell.kind === "research") {
const level = cell.level ?? 1;
total += pointsPerLevelPerSecond * level * dt;
}
}
if (total > 0) {
state.researchPoints = (state.researchPoints ?? 0) + total;
}
const total = sumResearchPointsFromCells(state, cfg.PointsPerTickPerLevel, dt);
if (total > 0) state.researchPoints = (state.researchPoints ?? 0) + total;
}
/**
@@ -94,8 +103,13 @@ export function startGameLoop(getState, onUpdate, saveStateFn) {
lastNpcTruckAt = nowMs;
}
tickLaboratory(state, nowUnix);
const { hatched, questEarned } = doOneTick(state, nowUnix, nowMs, dt);
if (questEarned > 0) playSound("quest");
const { hatched, questEarned } = doOneTick(state, nowUnix, nowMs, dt);
const newSeason = getCurrentSeason(state);
if (state.lastSeason !== undefined && state.lastSeason !== newSeason) {
state.seasonChangeMessage = newSeason;
}
state.lastSeason = newSeason;
if (questEarned > 0) playSound("quest");
onUpdate(state, { lastHatched: hatched });
saveAccum += dt;