This commit is contained in:
33333-33333 2026-06-26 12:46:32 +09:00
commit 86226ccc94
97 changed files with 5790 additions and 2307 deletions

View file

@ -126,9 +126,11 @@ const HEALTH = (() => {
}
function applyDamage(t, amount, reason = "") {
const before = t.energy;
const maxEnergy = typeof tarinaiMaxEnergy === "function" ? tarinaiMaxEnergy(t) : (Number(t.maxEnergy) || 100);
t.maxEnergy = maxEnergy;
const before = clamp(Number(t.energy) || 0, 0, maxEnergy);
const loss = Math.max(0, amount || 0);
t.energy = clamp(t.energy - loss, 0, 100);
t.energy = clamp(before - loss, 0, maxEnergy);
const actualLoss = Math.max(0, before - t.energy);
let cause = "";
if (actualLoss > 0.01) {