This commit is contained in:
33333-33333 2026-06-25 14:51:58 +09:00
commit 434f07cc4e
103 changed files with 8387 additions and 8152 deletions

View file

@ -16,18 +16,17 @@ function tarinaiRoundRectPath(ctx, x, y, w, h, r) {
class Tarinai { constructor(world, opts = {}) {
this.world = world;
this.familyKey = opts.familyKey || opts.archiveKey || opts.id || (crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random()}`);
this.familyKey = opts.familyKey || opts.id || (crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random()}`);
this.id = opts.id || "";
this.liveToken = opts.liveToken || 0;
this.name = opts.name || makeName(world);
// Legacy string personality is intentionally ignored. The game now uses only the four-axis personality model.
this.personality = "";
this.type = opts.type || baseSpriteId();
const typeMeta = SPRITES.find(s => s.id === this.type);
if (typeMeta?.actionOnly || typeMeta?.displayOnly) this.type = baseSpriteId();
this.birthPersonality = normalizePersonality(opts.birthPersonality || opts.personalityBirth);
if (!opts.birthPersonality && !opts.personalityBirth) this.birthPersonality = randomBirthPersonality(this.familyKey);
this.currentPersonality = normalizePersonality(opts.currentPersonality || opts.personalityCurrent || this.birthPersonality);
this.birthPersonality = normalizePersonality(opts.birthPersonality);
if (!opts.birthPersonality) this.birthPersonality = randomBirthPersonality(this.familyKey);
this.currentPersonality = normalizePersonality(opts.currentPersonality || this.birthPersonality);
this.personalityDaily = opts.personalityDaily && typeof opts.personalityDaily === "object" ? JSON.parse(JSON.stringify(opts.personalityDaily)) : null;
ensurePersonality(this);
this.genetics = normalizeGenetics(opts.genetics, this.familyKey);
@ -77,7 +76,7 @@ class Tarinai { constructor(world, opts = {}) {
this.behaviorSerial = opts.behaviorSerial ?? 0;
this.behavior = typeof globalThis.normalizeTarinaiBehaviorState === "function"
? globalThis.normalizeTarinaiBehaviorState(opts, this)
: (opts.behavior && typeof opts.behavior === "object" ? { ...opts.behavior } : (opts.activeBehavior && typeof opts.activeBehavior === "object" ? { ...opts.activeBehavior } : null));
: (opts.behavior && typeof opts.behavior === "object" ? { ...opts.behavior } : null);
this.forcedBehaviorQueue = Array.isArray(opts.forcedBehaviorQueue) ? opts.forcedBehaviorQueue.map(v => ({ ...(v || {}) })).slice(-8) : [];
this.actionCooldowns = opts.actionCooldowns && typeof opts.actionCooldowns === "object" ? { ...opts.actionCooldowns } : {};
this.needShock = opts.needShock && typeof opts.needShock === "object" ? { ...opts.needShock } : {};
@ -87,6 +86,7 @@ class Tarinai { constructor(world, opts = {}) {
this.stressBarTimer = opts.stressBarTimer ?? 0;
this.affection = opts.affection ?? rand(0, 30);
this.dead = !!opts.dead;
this.lifeStatus = opts.lifeStatus || (this.dead ? "dead" : "alive");
this.deathReason = opts.deathReason || "";
this.lastDamageCause = opts.lastDamageCause || "";
this.lastDamageAmount = opts.lastDamageAmount ?? 0;