// Status effects a unit or city can carry. They are data-driven so new ones can // be added without touching the simulation or the renderer: the server derives // the active ids, applies their fields, and ships the ids in snapshots; the // browser draws one icon per id. // // A status may define `hpLossPerDay` (a fraction of maximum hit points taken // each day), a `cityHpLossPerDay` override for when the unit stands in a city, // and an `upkeepMultiplier` applied to the unit's upkeep while it is active. import { formatPercent } from "../text_format.js"; export const STATUS_ENCIRCLED = "encircled"; export const STATUS_BESIEGED = "besieged"; export const STATUS_BATTLE = "battle"; export const STATUSES = [ { id: STATUS_ENCIRCLED, label: "Encircled", icon: "encirclement.svg", get description() { return `Cut off: every adjacent land tile is held by a hostile unit and no friendly port supplies it by sea. Loses ${formatPercent(this.hpLossPerDay)} of its maximum hit points each day, or ${formatPercent(this.cityHpLossPerDay)} inside a city.`; }, hpLossPerDay: 0.10, cityHpLossPerDay: 0.02, }, { id: STATUS_BESIEGED, label: "Besieged", icon: "encirclement.svg", description: "Cut off: every adjacent land tile is held by a hostile unit and no friendly port supplies it by sea.", }, { id: STATUS_BATTLE, label: "In battle", icon: "icon_battle.svg", get description() { return `Fighting an enemy unit on the same tile. Upkeep is multiplied by ${this.upkeepMultiplier} and the unit cannot pillage while the battle rages.`; }, upkeepMultiplier: 3, }, ]; export function statusById(id) { return STATUSES.find((status) => status.id === id) || null; }