hm
This commit is contained in:
parent
cefa2ace5a
commit
0e432c62ae
87 changed files with 4282 additions and 3066 deletions
|
|
@ -72,76 +72,10 @@
|
|||
},
|
||||
|
||||
evaluateColonyMood(force = false) {
|
||||
const now = this.time || 0;
|
||||
if (!force && this.colonyMood && now < (this.nextColonyMoodEvalAt || 0)) return this.colonyMood;
|
||||
const alive = (this.tarinai || []).filter(t => t && !t.dead);
|
||||
const n = alive.length;
|
||||
const avg = (fn) => n ? alive.reduce((sum, t) => sum + (Number(fn(t)) || 0), 0) / n : 0;
|
||||
const count = (fn) => alive.reduce((sum, t) => sum + (fn(t) ? 1 : 0), 0);
|
||||
const ratio = (value) => n ? value / n : 0;
|
||||
const avgEnergy = avg(t => t.energy || 0);
|
||||
const avgStress = avg(t => t.stress || 0);
|
||||
const avgHunger = avg(t => t.hunger || 0);
|
||||
const avgSafety = avg(t => t.needs?.safety || 0);
|
||||
const panicCount = count(t => t.state === "panic" || (t.fearTimer || 0) > 0.2 || (t.panicTargetUntil || 0) > now);
|
||||
const safetyHighCount = count(t => (t.needs?.safety || 0) >= 52 || (t.fearTimer || 0) > 0.35);
|
||||
const weakCount = count(t => (t.energy || 0) < 45 || (t.hunger || 0) > 88 || (t.needs?.health || 0) > 58);
|
||||
const diseasedCount = count(t => t.zunchiDisease || t.sleepDisease || t.explosionDisease || t.fightDisease);
|
||||
const breedingCount = count(t => (t.loveMochiTimer || 0) > 0.1 || t.state === "birth_ritual" || (t.birthRitualTimer || 0) > 0.1);
|
||||
const recentDeaths = (Array.isArray(this.recentDeathTimes) ? this.recentDeathTimes : []).filter(t => now - (Number(t) || -999) <= 30).length;
|
||||
let nearestAvg = Infinity;
|
||||
if (n >= 2) {
|
||||
let totalNearest = 0;
|
||||
for (const a of alive) {
|
||||
let best = Infinity;
|
||||
for (const b of alive) {
|
||||
if (a === b) continue;
|
||||
const dx = (a.x || 0) - (b.x || 0);
|
||||
const dy = (a.y || 0) - (b.y || 0);
|
||||
const d2 = dx * dx + dy * dy;
|
||||
if (d2 < best) best = d2;
|
||||
}
|
||||
if (Number.isFinite(best)) totalNearest += Math.sqrt(best);
|
||||
}
|
||||
nearestAvg = totalNearest / n;
|
||||
}
|
||||
const recentShock = (now - (this.lastShootAt || -999) <= 8) || (now - (this.lastGenkotsuAt || -999) <= 8);
|
||||
const panicRatio = ratio(panicCount);
|
||||
const safetyRatio = ratio(safetyHighCount);
|
||||
const weakRatio = ratio(weakCount);
|
||||
const diseaseRatio = ratio(diseasedCount);
|
||||
const breedingRatio = ratio(breedingCount);
|
||||
const fieldId = String(this.fieldType || "garden");
|
||||
const overcrowdLimit = fieldId === "cage" ? 20 : (fieldId === "park" ? 100 : 50);
|
||||
const denseCrowd = Number.isFinite(nearestAvg) && nearestAvg < 84 && n >= Math.max(8, Math.floor(overcrowdLimit * 0.55));
|
||||
const candidates = [];
|
||||
const add = (id, priority, ok) => { if (ok) candidates.push({ id, priority }); };
|
||||
|
||||
// Severe or multi-signal situations are evaluated first. Simple population
|
||||
// and comfort labels are deliberately fallback states so they do not mask
|
||||
// richer current events.
|
||||
add("devastation", 120, n <= 0 || recentDeaths >= 3 || (n <= 2 && this.deadCount > 0 && (recentDeaths > 0 || weakRatio >= 0.35 || panicRatio >= 0.20)));
|
||||
add("crisis", 110, recentDeaths >= 2 || (avgEnergy < 38 && weakRatio >= 0.34) || (avgHunger > 88 && weakRatio >= 0.40));
|
||||
add("confusion", 100, (recentShock && (panicRatio >= 0.10 || safetyRatio >= 0.18)) || panicRatio >= 0.25);
|
||||
add("fearful", 90, (avgSafety >= 50 && safetyRatio >= 0.28) || (recentShock && safetyRatio >= 0.18));
|
||||
add("disease_spread", 82, diseaseRatio >= 0.25 || (diseasedCount >= 3 && diseaseRatio >= 0.16));
|
||||
add("weakened", 74, (avgEnergy < 54 && weakRatio >= 0.18) || avgHunger > 82 || weakRatio >= 0.34);
|
||||
add("breeding", 66, breedingRatio >= 0.10 || breedingCount >= 2 || now - (this.lastBirthAt || -999) <= 45);
|
||||
add("happy", 46, avgStress < 28 && panicRatio < 0.08 && diseaseRatio < 0.12 && weakRatio < 0.18);
|
||||
add("overcrowded", 34, n >= overcrowdLimit || denseCrowd);
|
||||
add("isolated", 28, n <= 1 || (n <= 3 && nearestAvg > Math.max(180, Math.min(this.w || 900, this.h || 600) * 0.32)));
|
||||
|
||||
let id = "relaxed";
|
||||
if (candidates.length) {
|
||||
candidates.sort((a, b) => b.priority - a.priority);
|
||||
id = candidates[0].id;
|
||||
}
|
||||
const next = this.colonyMoodDefinition(id);
|
||||
this.colonyMood = next;
|
||||
this.nextColonyMoodEvalAt = now + 1.25;
|
||||
return next;
|
||||
return global.TarinaiColonySituationSystem?.evaluate?.(this, force) || this.colonyMood || this.colonyMoodDefinition?.("relaxed");
|
||||
},
|
||||
|
||||
|
||||
observeHighlightKind(t) {
|
||||
const s = this.selected;
|
||||
if (!s || !t || t === s || t.dead || this.tool !== "observe") return "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue