This commit is contained in:
33333-33333 2026-06-28 13:40:41 +09:00
commit f500279abd
93 changed files with 1893 additions and 1198 deletions

View file

@ -48,18 +48,100 @@
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: {} } },
calm: { id: "calm", label: "\u7a4f\u3084\u304b", description: "\u793e\u4ea4\u6027\u304c\u4e0a\u304c\u308b", effects: { personality: { sociability: 0.42 } } },
prickly: { id: "prickly", label: "\u7dca\u5f35", description: "\u653b\u6483\u6027\u304c\u4e0a\u304c\u308b", effects: { personality: { aggression: 0.46 } } },
stinky: { id: "stinky", label: "\u4e0d\u885b\u751f", description: "\u958b\u653e\u6027\u304c\u4e0b\u304c\u308b", effects: { personality: { openness: -0.44 } } },
weaklings: { id: "weaklings", label: "\u5f31\u4f53\u5316", description: "\u305a\u3093\u3061\u3069\u308c\u3044\u4ee5\u5916\u306e\u30b9\u30c8\u30ec\u30b9\u304c\u4e0b\u304c\u308b", effects: { personality: {} } },
zunda_party: { id: "zunda_party", label: "\u305a\u3093\u3060\u96c6\u4e2d", description: "\u793e\u4ea4\u6027\u3068\u958b\u653e\u6027\u304c\u4e0a\u304c\u308a\u3001\u30b9\u30c8\u30ec\u30b9\u304c\u4e0b\u304c\u308b", effects: { personality: { sociability: 0.38, openness: 0.38 } } },
ball_party: { id: "ball_party", label: "\u30dc\u30fc\u30eb\u96c6\u4e2d", description: "\u793e\u4ea4\u6027\u3068\u958b\u653e\u6027\u304c\u4e0a\u304c\u308a\u3001\u30b9\u30c8\u30ec\u30b9\u304c\u4e0b\u304c\u308b", effects: { personality: { sociability: 0.38, openness: 0.38 } } },
sun_party: { id: "sun_party", label: "\u65e5\u5149\u6d74\u50be\u5411", description: "\u65e5\u5149\u6d74\u306e\u983b\u5ea6\u304c\u4e0a\u304c\u308b", effects: { personality: {} } },
ant_overrun: { id: "ant_overrun", label: "\u30a2\u30ea\u5897\u52a0", description: "\u30a2\u30ea\u3092\u898b\u308b\u3068\u30d1\u30cb\u30c3\u30af\u306b\u306a\u308a\u3084\u3059\u3044", effects: { personality: {} } },
devastation: { id: "devastation", label: "\u58ca\u6ec5\u5bf8\u524d", description: "\u30b3\u30ed\u30cb\u30fc\u306e\u5b58\u7d9a\u304c\u304b\u306a\u308a\u5371\u3046\u3044\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
crisis: { id: "crisis", label: "\u5371\u6a5f", description: "\u3051\u304c\u3084\u6d88\u8017\u304c\u76ee\u7acb\u3061\u3001\u7acb\u3066\u76f4\u3057\u304c\u5fc5\u8981\u306a\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
confusion: { id: "confusion", label: "\u6df7\u4e71", description: "\u9a5a\u304d\u3084\u30d1\u30cb\u30c3\u30af\u3067\u843d\u3061\u7740\u304d\u304c\u5931\u308f\u308c\u3066\u3044\u307e\u3059\u3002", effects: { personality: {} } },
fearful: { id: "fearful", label: "\u6050\u6016", description: "\u5b89\u5168\u3092\u6c42\u3081\u308b\u500b\u4f53\u304c\u591a\u304f\u3001\u5371\u967a\u3092\u907f\u3051\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059\u3002", effects: { personality: {} } },
weakened: { id: "weakened", label: "\u8870\u5f31", description: "\u4f53\u529b\u3084\u5143\u6c17\u304c\u843d\u3061\u3001\u52d5\u304d\u304c\u5f31\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002", effects: { personality: {} } },
disease_spread: { id: "disease_spread", label: "\u75c5\u6c17\u8513\u5ef6", description: "\u75c5\u6c17\u306e\u500b\u4f53\u304c\u76ee\u7acb\u3061\u3001\u8abf\u5b50\u3092\u5d29\u3057\u3084\u3059\u3044\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
overcrowded: { id: "overcrowded", label: "\u904e\u5bc6", description: "\u500b\u4f53\u540c\u58eb\u306e\u8ddd\u96e2\u304c\u8fd1\u304f\u3001\u3076\u3064\u304b\u308a\u3084\u3059\u3044\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
isolated: { id: "isolated", label: "\u5b64\u7acb", description: "\u4ef2\u9593\u304c\u5c11\u306a\u3044\u3001\u307e\u305f\u306f\u8ddd\u96e2\u304c\u96e2\u308c\u3066\u5bc2\u3057\u3044\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
breeding: { id: "breeding", label: "\u7e41\u6b96", description: "\u7e41\u6b96\u3084\u89aa\u5bc6\u306a\u884c\u52d5\u304c\u8d77\u3053\u308a\u3084\u3059\u3044\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
happy: { id: "happy", label: "\u5e78\u798f", description: "\u30b9\u30c8\u30ec\u30b9\u304c\u5c11\u306a\u304f\u3001\u4f59\u88d5\u306e\u3042\u308b\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
relaxed: { id: "relaxed", label: "\u5b89\u5b9a", description: "\u5927\u304d\u306a\u554f\u984c\u304c\u5c11\u306a\u304f\u3001\u843d\u3061\u7740\u3044\u305f\u72b6\u614b\u3067\u3059\u3002", effects: { personality: {} } },
};
return defs[id] || defs.relaxed;
},
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;
},
observeHighlightKind(t) {
const s = this.selected;
if (!s || !t || t === s || t.dead || this.tool !== "observe") return "";
@ -107,9 +189,12 @@
return conflicts;
},
blastZunchiFrom(x, y, radius, strength = 1) {
blastZunchiFrom(x, y, radius, strength = 1, options = {}) {
let moved = 0;
const limit = Math.max(1, Number(options.limit || 180) || 180);
const effectLimit = Math.max(0, Number(options.effectLimit || 12) || 12);
for (const it of this.nearbyItems(x, y, radius + 60)) {
if (moved >= limit) break;
if (!it || it.dead || it.type !== "zunchi") continue;
let dx = it.x - x;
let dy = it.y - y;
@ -125,7 +210,7 @@
it.amount = Math.max(10, (it.amount || 80) - p * 8);
it.stage = "fresh";
moved += 1;
if (moved < 12) this.effects.push(new Effect("zunchi_miasma", it.x, it.y - 4, { vx: (it.vx || 0) * 0.15, vy: (it.vy || 0) * 0.15 - 18, size: rand(9, 18), life: rand(0.36, 0.62), color: "rgba(58,102,38,0.48)" }));
if (moved < effectLimit) this.effects.push(new Effect("zunchi_miasma", it.x, it.y - 4, { vx: (it.vx || 0) * 0.15, vy: (it.vy || 0) * 0.15 - 18, size: rand(9, 18), life: rand(0.36, 0.62), color: "rgba(58,102,38,0.48)" }));
}
if (moved) this.drawListDirty = true;
return moved;