tarinai/js/disease_registry.js

61 lines
2.3 KiB
JavaScript
Raw Normal View History

2026-06-21 22:29:00 +09:00
"use strict";
(function (global) {
const rawDefinitions = {
disease_zunchi: {
id: "disease_zunchi",
flag: "zunchiDisease",
label: "\u305a\u3093\u3061\u75c5",
symptoms: ["stress", "energy_loss", "infection"],
displayText: "\u305a\u3093\u3061\u75c5",
color: "rgba(113,93,59,0.74)",
mysteryEligible: true,
cureRules: ["water", "natural_recovery"]
},
disease_sleep: {
id: "disease_sleep",
flag: "sleepDisease",
label: "\u306d\u3080\u308a\u75c5",
symptoms: ["sleep_lock", "no_counterattack"],
displayText: "\u306d\u3080\u308a\u75c5",
color: "rgba(104,84,168,0.78)",
mysteryEligible: true,
cureRules: ["damage"]
},
disease_explosion: {
id: "disease_explosion",
flag: "explosionDisease",
label: "\u7206\u767a\u75c5",
symptoms: ["explodes_after_timer", "water_seeking"],
displayText: "\u7206\u767a\u75c5",
color: "rgba(210,90,44,0.78)",
baseInfectionChance: 0.15,
mysteryEligible: true,
cureRules: ["water", "zunda_mochi"]
},
disease_fight: {
id: "disease_fight",
flag: "fightDisease",
label: "\u304d\u305a\u3064\u304d\u75c5",
symptoms: ["fight_lash_out", "zunda_seeking"],
displayText: "\u304d\u305a\u3064\u304d\u75c5",
color: "rgba(180,86,52,0.80)",
mysteryEligible: true,
cureRules: ["zunda_mochi", "natural_recovery"]
}
};
class DiseaseRegistry {
constructor(defs) { this.defs = new Map(Object.entries(defs || {})); }
get(id = "") { return this.defs.get(String(id || "")) || null; }
byFlag(flag = "") { return [...this.defs.values()].find(def => def.flag === flag) || null; }
label(id = "") { return this.get(id)?.label || id || ""; }
color(id = "") { return this.get(id)?.color || "rgba(255,242,160,0.85)"; }
mysteryPool() { return [...this.defs.values()].filter(def => def.mysteryEligible).map(def => def.id); }
debugSnapshot() { return [...this.defs.values()].map(def => ({ id: def.id, label: def.label, flag: def.flag, cures: def.cureRules || [] })); }
}
const registry = new DiseaseRegistry(rawDefinitions);
global.TarinaiDiseaseRegistry = registry;
global.TARINAI_DISEASE_DEFINITIONS = Object.freeze(rawDefinitions);
})(typeof window !== "undefined" ? window : globalThis);