diff --git a/app/src/libs/combat/process.ts b/app/src/libs/combat/process.ts index 5d9c5e89..59347752 100644 --- a/app/src/libs/combat/process.ts +++ b/app/src/libs/combat/process.ts @@ -477,12 +477,18 @@ export const applyEffects = (battle: CompleteBattle, actorId: string) => { if (damage > 0) { target.curHealth -= damage; target.curHealth = Math.max(0, target.curHealth); - // If residual damage reduces health to 0, mark player as having left battle + // If residual damage reduces health to 0, mark player as having left battle and died if (target.curHealth <= 0) { target.leftBattle = true; + // Also mark them as having died (not fled) to properly end combat + target.fledBattle = false; + // If this is a Kage challenge and the defender dies from residual damage, they should lose Kage status + if (battle.battleType === "KAGE_CHALLENGE" && target.isAggressor === false) { + target.isKage = false; + } } actionEffects.push({ - txt: `${target.username} takes ${damage.toFixed(2)} residual damage`, + txt: `${target.username} takes ${damage.toFixed(2)} residual damage${target.curHealth <= 0 ? " and dies" : ""}`, color: "red", types: c.types, });