[P2 Bug] Fix sturdy and endure causing an extra stat boost to boss Pokemon (#4347)

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

* [doc] add doc for handleBossSegmentCleared
This commit is contained in:
MokaStitcher 2024-09-20 23:19:33 +02:00 committed by GitHub
parent 4cc3b0daae
commit 5f5b439e42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View File

@ -4749,8 +4749,15 @@ export class EnemyPokemon extends Pokemon {
return true;
}
/**
* Go through a boss' health segments and give stats boosts for each newly cleared segment
* The base boost is 1 to a random stat that's not already maxed out per broken shield
* For Pokemon with 3 health segments or more, breaking the last shield gives +2 instead
* For Pokemon with 5 health segments or more, breaking the last two shields give +2 each
* @param segmentIndex index of the segment to get down to (0 = no shield left, 1 = 1 shield left, etc.)
*/
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

@ -33,7 +33,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);
});
@ -196,6 +196,28 @@ describe("Boss Pokemon / Shields", () => {
});
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