world-simulator / frontend /src /eventDecor.ts
kikikita's picture
Refactor action handling and update UI elements
81070c7
Raw
History Blame Contribute Delete
1.24 kB
import type { GameLogEventSnapshot } from "./types";
const EVENT_ICONS: Record<string, string> = {
beast_spawned: "B",
beast_attack: "B",
beast_killed: "A",
beast_retreat: "B",
npc_attack: "A",
npc_died: "X",
npc_born: "+",
build_started: "H",
build_completed: "H",
house_damaged: "H",
house_destroyed: "H",
gather: "G",
transfer: "T",
steal: "S",
heal: "H",
consume: "F",
help_request: "!",
directive_issued: "D",
directive_completed: "D",
election_started: "E",
vote_cast: "V",
election_completed: "E",
policy_updated: "P",
treasury_deposit: "T",
treasury_stolen: "T",
cannon_crafted: "C",
cannon_operator_assigned: "C",
cannon_fired: "C",
game_over: "END",
};
export function eventIcon(type: string): string {
return EVENT_ICONS[type] ?? "-";
}
export function severityClass(severity: string): string {
switch (severity) {
case "good":
return "severityGood";
case "warning":
return "severityWarning";
case "danger":
return "severityDanger";
default:
return "severityNeutral";
}
}
export function isMajorEvent(event: GameLogEventSnapshot): boolean {
return event.severity !== "neutral" || event.type === "build_started";
}