[bug] fix sturdy and endure causing an extra stat boost to boss Pokemon

This commit is contained in:
MokaStitcher 2024-09-20 20:05:59 +02:00
parent 0eea2031fb
commit 99a086a0af
2 changed files with 24 additions and 2 deletions

View File

@ -4750,7 +4750,7 @@ export class EnemyPokemon extends Pokemon {
}
handleBossSegmentCleared(segmentIndex: integer): void {
while (segmentIndex - 1 < this.bossSegmentIndex) {
while (this.bossSegmentIndex > 0 && segmentIndex - 1 < this.bossSegmentIndex) {
// Filter out already maxed out stat stages and weigh the rest based on existing stats
const leftoverStats = EFFECTIVE_STATS.filter((s: EffectiveStat) => this.getStatStage(s) < 6);
const statWeights = leftoverStats.map((s: EffectiveStat) => this.getStat(s, false));

View File

@ -35,7 +35,7 @@ describe("Boss Pokemon / Shields", () => {
.enemyMoveset(Moves.SPLASH)
.enemyHeldItems([])
.startingLevel(1000)
.moveset([Moves.FALSE_SWIPE, Moves.SUPER_FANG, Moves.SPLASH])
.moveset([Moves.FALSE_SWIPE, Moves.SUPER_FANG, Moves.SPLASH, Moves.PSYCHIC])
.ability(Abilities.NO_GUARD);
});
@ -198,6 +198,28 @@ describe("Boss Pokemon / Shields", () => {
}, TIMEOUT);
it("the boss enduring does not proc an extra stat boost", async () => {
game.override
.enemyHealthSegments(2)
.enemyAbility(Abilities.STURDY);
await game.classicMode.startBattle([ Species.MEWTWO ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon.isBoss()).toBe(true);
expect(enemyPokemon.bossSegments).toBe(2);
expect(getTotalStatStageBoosts(enemyPokemon)).toBe(0);
game.move.select(Moves.PSYCHIC);
await game.toNextTurn();
// Enemy survived with Sturdy
expect(enemyPokemon.bossSegmentIndex).toBe(0);
expect(enemyPokemon.hp).toBe(1);
expect(getTotalStatStageBoosts(enemyPokemon)).toBe(1);
}, TIMEOUT);
/**
* Gets the sum of the effective stat stage boosts for the given Pokemon
* @param enemyPokemon the pokemon to get stats from