Skip to content

Commit

Permalink
Fix pr #402: Fix issue #376: Death by Residual Damage leaving you stu…
Browse files Browse the repository at this point in the history
…ck in combat
  • Loading branch information
openhands-agent committed Feb 24, 2025
1 parent b084ba4 commit 9b7df4d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/src/libs/combat/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 9b7df4d

Please sign in to comment.