[Bug] Breaking a boss bar will no longer crash at max stat stages (#6440)

Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com>
This commit is contained in:
NightKev 2025-08-28 22:36:43 -07:00 committed by GitHub
parent 98e65b9b8b
commit dadc7b9598
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6916,7 +6916,7 @@ export class EnemyPokemon extends Pokemon {
const leftoverStats = EFFECTIVE_STATS.filter((s: EffectiveStat) => this.getStatStage(s) < 6); const leftoverStats = EFFECTIVE_STATS.filter((s: EffectiveStat) => this.getStatStage(s) < 6);
const statWeights = leftoverStats.map((s: EffectiveStat) => this.getStat(s, false)); const statWeights = leftoverStats.map((s: EffectiveStat) => this.getStat(s, false));
let boostedStat: EffectiveStat; let boostedStat: EffectiveStat | undefined;
const statThresholds: number[] = []; const statThresholds: number[] = [];
let totalWeight = 0; let totalWeight = 0;
@ -6934,6 +6934,11 @@ export class EnemyPokemon extends Pokemon {
} }
} }
if (boostedStat === undefined) {
this.bossSegmentIndex--;
return;
}
let stages = 1; let stages = 1;
// increase the boost if the boss has at least 3 segments and we passed last shield // increase the boost if the boss has at least 3 segments and we passed last shield
@ -6949,7 +6954,7 @@ export class EnemyPokemon extends Pokemon {
"StatStageChangePhase", "StatStageChangePhase",
this.getBattlerIndex(), this.getBattlerIndex(),
true, true,
[boostedStat!], [boostedStat],
stages, stages,
true, true,
true, true,