From 0dc53bfeb83e14db2b2c160d0ad3345da1fc0609 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Fri, 1 Mar 2024 11:26:40 -0500 Subject: [PATCH] Fix boss stat boosts not being applied on revive --- src/field/pokemon.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 158614f32..b2c09ee7b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2343,6 +2343,8 @@ export class EnemyPokemon extends Pokemon { if (this.isFainted()) return 0; + let bossSegmentIndex = this.bossSegmentIndex; + if (this.isBoss()) { if (!ignoreSegments) { const segmentSize = this.getMaxHp() / this.bossSegments; @@ -2353,13 +2355,13 @@ export class EnemyPokemon extends Pokemon { if (this.hp - damage <= roundedHpThreshold) { const hpRemainder = this.hp - roundedHpThreshold; let segmentsBypassed = 0; - while (this.canBypassBossSegments(segmentsBypassed + 1) && (damage - hpRemainder) >= Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))) { + while (segmentsBypassed < this.bossSegmentIndex && this.canBypassBossSegments(segmentsBypassed + 1) && (damage - hpRemainder) >= Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))) { segmentsBypassed++; //console.log('damage', damage, 'segment', segmentsBypassed + 1, 'segment size', segmentSize, 'damage needed', Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))); } damage = hpRemainder + Math.round(segmentSize * segmentsBypassed); - this.handleBossSegmentCleared(s - segmentsBypassed); + bossSegmentIndex = s - segmentsBypassed; } break; } @@ -2368,7 +2370,12 @@ export class EnemyPokemon extends Pokemon { this.battleInfo.updateBossSegments(this); } - return super.damage(damage, ignoreSegments, preventEndure); + const ret = super.damage(damage, ignoreSegments, preventEndure); + + if (this.isBoss() && bossSegmentIndex < this.bossSegmentIndex) + this.handleBossSegmentCleared(bossSegmentIndex); + + return ret; } canBypassBossSegments(segmentCount: integer = 1): boolean {