From dadc7b95988bc845529719adc783c3f77db11cb4 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 28 Aug 2025 22:36:43 -0700 Subject: [PATCH] [Bug] Breaking a boss bar will no longer crash at max stat stages (#6440) Co-authored-by: Wlowscha <54003515+Wlowscha@users.noreply.github.com> --- src/field/pokemon.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index dab96e4090a..db973ef2d78 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -6916,7 +6916,7 @@ export class EnemyPokemon extends Pokemon { const leftoverStats = EFFECTIVE_STATS.filter((s: EffectiveStat) => this.getStatStage(s) < 6); const statWeights = leftoverStats.map((s: EffectiveStat) => this.getStat(s, false)); - let boostedStat: EffectiveStat; + let boostedStat: EffectiveStat | undefined; const statThresholds: number[] = []; let totalWeight = 0; @@ -6934,6 +6934,11 @@ export class EnemyPokemon extends Pokemon { } } + if (boostedStat === undefined) { + this.bossSegmentIndex--; + return; + } + let stages = 1; // 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", this.getBattlerIndex(), true, - [boostedStat!], + [boostedStat], stages, true, true,