[Bug]]Beta] Boss segments not fully clearing (#6609)

fix: boss segments with 1 hp remaining
This commit is contained in:
Sirz Benjie 2025-09-29 14:43:23 -05:00 committed by GitHub
parent 5745213257
commit 4a719e48c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -6835,6 +6835,7 @@ export class EnemyPokemon extends Pokemon {
this.hp,
segmentSize,
this.getMinimumSegmentIndex(),
this.bossSegmentIndex,
);
}

View File

@ -16,6 +16,7 @@ import { toDmgValue } from "#utils/common";
* @param currentHp - The target's current HP
* @param segmentHp - The HP in each segment (total HP / number of segments)
* @param minSegmentIndex - The minimum segment index that can be cleared; default `0` (all segments). Used for the final boss
* @param currentSegmentIndex - The current segment index of the target; if not provided, it will be calculated from `currentHp` and `segmentHp`.
* @returns A tuple consisting of the adjusted damage and index of the boss segment the target is in after damage is applied.
*/
export function calculateBossSegmentDamage(
@ -23,8 +24,9 @@ export function calculateBossSegmentDamage(
currentHp: number,
segmentHp: number,
minSegmentIndex = 0,
currentSegmentIndex?: number,
): [adjustedDamage: number, clearedBossSegmentIndex: number] {
const segmentIndex = Math.ceil(currentHp / segmentHp) - 1;
const segmentIndex = currentSegmentIndex ?? Math.ceil(currentHp / segmentHp) - 1;
if (segmentIndex <= 0) {
return [damage, 1];
}