fix(combat): _find_ally_needing_heal uses hp*2 < hp_max (strictly below half) - the floored hp < hp_max//2 was off by one for odd hp_max (5 -> threshold 2, so 2/5 hp counted healthy); + threshold regression test
This commit is contained in:
@@ -8311,9 +8311,14 @@ def _find_heal_spell(engine: CombatEngine, spells_known: list[str]) -> str | Non
|
||||
|
||||
|
||||
def _find_ally_needing_heal(engine: CombatEngine, caster: CombatantState) -> CombatantState | None:
|
||||
"""Find an ally below 50% HP."""
|
||||
"""Find an ally below half HP.
|
||||
|
||||
``hp * 2 < hp_max`` is strictly-below-half for every hp_max; the old
|
||||
``hp < hp_max // 2`` floored the threshold (hp_max 5 -> 2), so a level-1
|
||||
character at 2/5 hp counted as healthy.
|
||||
"""
|
||||
for ally_state in engine.states:
|
||||
below_half = ally_state.hp < ally_state.combatant.hp_max // 2
|
||||
below_half = ally_state.hp * 2 < ally_state.combatant.hp_max
|
||||
if ally_state.side == caster.side and ally_state.active and below_half:
|
||||
return ally_state
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user