refactor
This commit is contained in:
parent
0a6148c73f
commit
e8f1d1db1e
60 changed files with 2417 additions and 612 deletions
|
|
@ -37,6 +37,49 @@
|
|||
this.foodSpoilageEvents = (this.foodSpoilageEvents || 0) + 1;
|
||||
},
|
||||
|
||||
hourOfDay(timeValue = this.time || 0) {
|
||||
return ((((timeValue || 0) / Math.max(1, CONFIG.dayLength || 120)) * 24) % 24 + 24) % 24;
|
||||
},
|
||||
|
||||
colonyMoodDefinition(id = "relaxed") {
|
||||
const defs = {
|
||||
calm: { id: "calm", label: "おだやか", description: "社交性プラス", effects: { personality: { sociability: 0.42 } } },
|
||||
prickly: { id: "prickly", label: "ピリピリ", description: "攻撃性プラス", effects: { personality: { aggression: 0.46 } } },
|
||||
stinky: { id: "stinky", label: "くさい", description: "開放性マイナス", effects: { personality: { openness: -0.44 } } },
|
||||
weaklings: { id: "weaklings", label: "ざこだらけ", description: "ずんちどれい以外のストレス減少", effects: { personality: {} } },
|
||||
zunda_party: { id: "zunda_party", label: "ずんだぱーてぃー", description: "社交性と開放性プラス。ストレス減少", effects: { personality: { sociability: 0.38, openness: 0.38 } } },
|
||||
ball_party: { id: "ball_party", label: "ぼーるぱーてぃー", description: "社交性と開放性プラス。ストレス減少", effects: { personality: { sociability: 0.38, openness: 0.38 } } },
|
||||
sun_party: { id: "sun_party", label: "おひさまぱーてぃー", description: "日光浴頻度増加", effects: { personality: {} } },
|
||||
ant_overrun: { id: "ant_overrun", label: "ありだらけ", description: "アリを見るとパニック", effects: { personality: {} } },
|
||||
relaxed: { id: "relaxed", label: "のんびり", description: "何も無し", effects: { personality: {} } },
|
||||
};
|
||||
return defs[id] || defs.relaxed;
|
||||
},
|
||||
|
||||
evaluateColonyMood() {
|
||||
const alive = (this.tarinai || []).filter(t => t && !t.dead);
|
||||
const avgStress = alive.length ? alive.reduce((s, t) => s + (t.stress || 0), 0) / alive.length : 0;
|
||||
const avgHunger = alive.length ? alive.reduce((s, t) => s + (t.hunger || 0), 0) / alive.length : 0;
|
||||
const environment = this.environmentScores ? this.environmentScores() : { hygiene: 100 };
|
||||
const fights = alive.filter(t => t.state === "fight" || (t.fightTimer || 0) > 0.04 || t.state === "intimidate" || (t.intimidateTimer || 0) > 0.04).length;
|
||||
const corpseCount = (this.itemCounts?.ant_corpse || 0) + Math.max(0, Math.round((this.deadCount || 0) * 0.5));
|
||||
const slaveRatio = alive.length ? alive.filter(t => t.isZunchiSlave).length / alive.length : 0;
|
||||
const candidates = [];
|
||||
if (alive.length && avgStress <= 28 && avgHunger <= 34) candidates.push("calm");
|
||||
if (fights >= 2 || corpseCount >= 4) candidates.push("prickly");
|
||||
if ((environment.hygiene || 0) <= 42) candidates.push("stinky");
|
||||
if (alive.length && slaveRatio >= 0.45) candidates.push("weaklings");
|
||||
if ((this.itemCounts?.sweet || 0) >= 30) candidates.push("zunda_party");
|
||||
if ((this.itemCounts?.ball || 0) >= 10) candidates.push("ball_party");
|
||||
if (alive.some(t => t.state === "sunbath" || (t.sunbathTimer || 0) > 0.1)) candidates.push("sun_party");
|
||||
if ((this.itemCounts?.ant_nest || 0) >= 1) candidates.push("ant_overrun");
|
||||
const nextId = candidates.length ? candidates[Math.floor(Math.random() * candidates.length)] : "relaxed";
|
||||
this.colonyMood = this.colonyMoodDefinition(nextId);
|
||||
this.lastColonyMoodDay = this.day || 1;
|
||||
this.log?.(`今日のコロニーの雰囲気は「${this.colonyMood.label}」。`, "event");
|
||||
return this.colonyMood;
|
||||
},
|
||||
|
||||
observeHighlightKind(t) {
|
||||
const s = this.selected;
|
||||
if (!s || !t || t === s || t.dead || this.tool !== "observe") return "";
|
||||
|
|
@ -112,9 +155,14 @@
|
|||
dt *= this.speed;
|
||||
dt = Math.min(dt, 0.12 * this.speed);
|
||||
|
||||
const prevTime = this.time;
|
||||
this.time += dt;
|
||||
const previousDay = this.day || 1;
|
||||
this.day = Math.floor(this.time / CONFIG.dayLength) + 1;
|
||||
const prevHour = this.hourOfDay ? this.hourOfDay(prevTime) : 0;
|
||||
const nowHour = this.hourOfDay ? this.hourOfDay(this.time) : 0;
|
||||
const crossedColonyEvalHour = (this.day !== previousDay) ? (nowHour >= 6) : (prevHour < 6 && nowHour >= 6);
|
||||
const pendingColonyMoodEvaluation = crossedColonyEvalHour && this.lastColonyMoodDay !== this.day;
|
||||
if (this.day !== previousDay) {
|
||||
for (const t of this.tarinai || []) if (t) t.personalityDaily = { day: this.day, total: 0, byKey: {}, byCause: {} };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue