tarinai/js/disease_registry.js
2026-06-22 02:03:19 +09:00

63 lines
2.3 KiB
JavaScript

"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 extends global.TarinaiRegistryBase {
byFlag(flag = "") { return [...this.defs.values()].find(def => def.flag === flag) || null; }
label(id = "") { return super.label(id, id || ""); }
color(id = "") { return super.color(id, "rgba(255,242,160,0.85)"); }
infectionChance(id = "", fallback = 0) {
const value = this.get(id)?.baseInfectionChance;
return Number.isFinite(value) ? value : fallback;
}
mysteryPool() { return [...this.defs.values()].filter(def => def.mysteryEligible).map(def => def.id); }
debugSnapshot() { return super.debugSnapshot((id, def) => ({ id: def.id || 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);