many
This commit is contained in:
parent
0b9ff1363b
commit
0a6148c73f
67 changed files with 2653 additions and 1519 deletions
|
|
@ -24,6 +24,29 @@
|
|||
return this.generation > 1 && this.growth < 1;
|
||||
},
|
||||
|
||||
syncGrowthScale() {
|
||||
if (!Number.isFinite(this.adultScale)) this.adultScale = adultScaleFromGenetics(this.familyKey || this.id, this.genetics);
|
||||
const nextScale = this.generation > 1 ? scaleForGrowth(this.adultScale, this.growth) : this.adultScale;
|
||||
this.scale = clamp(nextScale, 0.10, 0.42);
|
||||
if (this.refreshEffectiveSize) this.refreshEffectiveSize();
|
||||
else this.radius = 56 * this.scale;
|
||||
const growthBucket = Math.floor(clamp(this.growth || 0, 0, 1) * 20);
|
||||
if (this.generation > 1 && this.world?.recordFamily && this.familyJoined?.() && this.familyGrowthBucket !== growthBucket) {
|
||||
this.familyGrowthBucket = growthBucket;
|
||||
this.world.recordFamily(this);
|
||||
}
|
||||
return this.scale;
|
||||
},
|
||||
|
||||
geneticStatRatio(key = "") {
|
||||
this.genetics = normalizeGenetics(this.genetics, this.familyKey || this.id);
|
||||
if (key === "life") return this.genetics.lifeSpanMul || 1;
|
||||
if (key === "attack") return this.genetics.attackMul || 1;
|
||||
if (key === "speed") return this.genetics.speedMul || 1;
|
||||
if (key === "size") return this.genetics.sizeMul || 1;
|
||||
return 1;
|
||||
},
|
||||
|
||||
parentToFollow() {
|
||||
if (!this.juvenile || !this.parents?.length) return null;
|
||||
let best = null, bestD = Infinity;
|
||||
|
|
@ -52,6 +75,32 @@
|
|||
if (this.records.length > 42) this.records.length = 42;
|
||||
},
|
||||
|
||||
recordChangeCause(reason = "", target = "", options = {}) {
|
||||
const text = String(reason || "").trim();
|
||||
const affected = String(target || "").trim();
|
||||
if (!text && !affected) return false;
|
||||
if (!Array.isArray(this.recentChangeCauses)) this.recentChangeCauses = [];
|
||||
const now = this.world?.time || 0;
|
||||
const entry = {
|
||||
time: now,
|
||||
reason: text || "\u5909\u5316",
|
||||
target: affected || "\u72b6\u614b",
|
||||
value: options.value ?? "",
|
||||
};
|
||||
const head = this.recentChangeCauses[0];
|
||||
if (head && head.reason === entry.reason && head.target === entry.target) {
|
||||
const oldValue = Number(head.value);
|
||||
const addValue = Number(entry.value);
|
||||
if (Number.isFinite(oldValue) || Number.isFinite(addValue)) head.value = (Number.isFinite(oldValue) ? oldValue : 0) + (Number.isFinite(addValue) ? addValue : 0);
|
||||
else head.value = entry.value || head.value || "";
|
||||
head.time = now;
|
||||
return true;
|
||||
}
|
||||
this.recentChangeCauses.unshift(entry);
|
||||
if (this.recentChangeCauses.length > 8) this.recentChangeCauses.length = 8;
|
||||
return true;
|
||||
},
|
||||
|
||||
personalityProfile() {
|
||||
const base = { label: "\u4e2d\u7acb", fear: 1, fight: 1, social: 1, relation: 1, sleep: 1, zunda: 1, play: 1 };
|
||||
const p = ensurePersonality(this).currentPersonality;
|
||||
|
|
@ -205,7 +254,8 @@
|
|||
},
|
||||
|
||||
addStress(amount, opts = {}) {
|
||||
const delta = Math.max(0, amount || 0);
|
||||
const tolerance = Number.isFinite(opts.tolerance) ? opts.tolerance : 0.88;
|
||||
const delta = Math.max(0, (amount || 0) * tolerance);
|
||||
if (delta <= 0) return 0;
|
||||
const before = this.stress || 0;
|
||||
this.stress = clamp(before + delta, 0, 130);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue