Fixed Rounding Error For TargetHalfHpDamageAttr

Moves that deal half of a target's HP were not able to deal damage if the target had 1 HP. Used Math.max to ensure 1 is the lowest this value ever evaluates to.
pull/393/head
Benjamin Odom 2024-05-01 18:05:34 -05:00 committed by Samuel H
parent 6ac224ab8a
commit ad59c0a7c4
1 changed files with 1 additions and 1 deletions

View File

@ -557,7 +557,7 @@ export class TargetHalfHpDamageAttr extends FixedDamageAttr {
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
(args[0] as Utils.IntegerHolder).value = Math.floor(target.hp / 2);
(args[0] as Utils.IntegerHolder).value = Math.max(Math.floor(target.hp / 2), 1);
return true;
}