feat(combat): Standardize wound stacking logic to respect skill value limits

- Apply consistent wound stacking calculation across all targets (including commander)
- Enforce skill.value as upper bound for wounds applied, accounting for existing wound stacks
- Prevent negative or zero wound applications by early-returning when toApply <= 0
This commit is contained in:
Brian Fertig 2026-04-03 10:18:27 -06:00
parent d5a30da9aa
commit fd78f75c83
1 changed files with 6 additions and 6 deletions

View File

@ -84,9 +84,7 @@ export class SkillProcessor {
if (targets.length === 0) return;
const allTargets = [];
for (const t of targets) {
const toApply = t.type === 'commander'
? Math.min(canApply, Math.max(0, skill.value - (t.woundStacks || 0)))
: canApply;
const toApply = Math.min(canApply, Math.max(0, skill.value - (t.woundStacks || 0)));
if (toApply <= 0) continue;
t.woundStacks = (t.woundStacks || 0) + toApply;
allTargets.push({ target: t, stacks: toApply });
@ -106,9 +104,11 @@ export class SkillProcessor {
if (context) { context.woundTarget = defender; context.woundStacks = toApply; }
return;
}
defender.woundStacks = (defender.woundStacks || 0) + canApply;
if (tracker) tracker.applied += canApply;
if (context) { context.woundTarget = defender; context.woundStacks = canApply; }
const toApply = Math.min(canApply, Math.max(0, skill.value - (defender.woundStacks || 0)));
if (toApply <= 0) return;
defender.woundStacks = (defender.woundStacks || 0) + toApply;
if (tracker) tracker.applied += toApply;
if (context) { context.woundTarget = defender; context.woundStacks = toApply; }
}
berserk(skill, attacker, defender, allies, enemies, context) {