**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
80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
/**
|
|
* Season cycle: 4 seasons from game day. Used for temperature, visitors, reproduction, billeterie.
|
|
* Refs: docs/specs/inventaire_saisons.md, temperature.md, visiteur.md, reproduction.md, billeterie.md.
|
|
*/
|
|
|
|
import { GameConfig } from "./config.js";
|
|
|
|
/** @typedef {"spring"|"summer"|"autumn"|"winter"} SeasonId */
|
|
|
|
const SEASON_ORDER = /** @type {SeasonId[]} */ (["spring", "summer", "autumn", "winter"]);
|
|
|
|
/**
|
|
* Current season from state game day.
|
|
* @param {import("./types.js").GameState} state
|
|
* @returns {SeasonId}
|
|
*/
|
|
export function getCurrentSeason(state) {
|
|
const cfg = GameConfig.Season;
|
|
if (!cfg || !cfg.DaysPerSeason) return "spring";
|
|
const gameDay = state.gameDayTotal ?? 0;
|
|
const seasonIndex = Math.floor(gameDay / cfg.DaysPerSeason) % 4;
|
|
return SEASON_ORDER[seasonIndex] ?? "spring";
|
|
}
|
|
|
|
/**
|
|
* Day index within current season (0..DaysPerSeason-1).
|
|
* @param {import("./types.js").GameState} state
|
|
* @returns {number}
|
|
*/
|
|
export function getSeasonDay(state) {
|
|
const cfg = GameConfig.Season;
|
|
if (!cfg || !cfg.DaysPerSeason) return 0;
|
|
const gameDay = state.gameDayTotal ?? 0;
|
|
return gameDay % cfg.DaysPerSeason;
|
|
}
|
|
|
|
/**
|
|
* Temperature modifier for display/calculations (°C). From temperature.md.
|
|
* @param {SeasonId} season
|
|
* @returns {number}
|
|
*/
|
|
export function getSeasonTemperatureModifier(season) {
|
|
const cfg = GameConfig.Season?.TemperatureModifier;
|
|
if (!cfg) return 0;
|
|
return cfg[season] ?? 0;
|
|
}
|
|
|
|
/**
|
|
* Visitor demand multiplier. From visiteur.md (Impact Saisons).
|
|
* @param {SeasonId} season
|
|
* @returns {number}
|
|
*/
|
|
export function getSeasonVisitorMultiplier(season) {
|
|
const cfg = GameConfig.Season?.VisitorMultiplier;
|
|
if (!cfg) return 1;
|
|
return cfg[season] ?? 1;
|
|
}
|
|
|
|
/**
|
|
* Reproduction chance bonus (e.g. spring +0.2, winter -0.5). From reproduction.md.
|
|
* @param {SeasonId} season
|
|
* @returns {number}
|
|
*/
|
|
export function getSeasonReproductionBonus(season) {
|
|
const cfg = GameConfig.Season?.ReproductionBonus;
|
|
if (!cfg) return 0;
|
|
return cfg[season] ?? 0;
|
|
}
|
|
|
|
/**
|
|
* Billeterie ticket price multiplier (summer +20%, winter -10%). From billeterie.md.
|
|
* @param {SeasonId} season
|
|
* @returns {number}
|
|
*/
|
|
export function getSeasonTicketPriceMultiplier(season) {
|
|
const cfg = GameConfig.Season?.TicketPriceMultiplier;
|
|
if (!cfg) return 1;
|
|
return cfg[season] ?? 1;
|
|
}
|