[Bug] Stat Stages are now changed individually instead of all at once (#4457)

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com>
This commit is contained in:
PrabbyDD 2024-10-12 15:29:36 -07:00 committed by GitHub
parent 2ac688de4b
commit ebb7612999
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 152 additions and 0 deletions

View File

@ -36,6 +36,16 @@ export class StatStageChangePhase extends PokemonPhase {
}
start() {
// Check if multiple stats are being changed at the same time, then run SSCPhase for each of them
if (this.stats.length > 1) {
for (let i = 0; i < this.stats.length; i++) {
const stat = [ this.stats[i] ];
this.scene.unshiftPhase(new StatStageChangePhase(this.scene, this.battlerIndex, this.selfTarget, stat, this.stages, this.showMessage, this.ignoreAbilities, this.canBeCopied, this.onChange));
}
return this.end();
}
const pokemon = this.getPokemon();
if (!pokemon.isActive(true)) {

View File

@ -0,0 +1,72 @@
import { Stat } from "#enums/stat";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Competitive", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single")
.enemySpecies(Species.BEEDRILL)
.enemyMoveset(Moves.TICKLE)
.startingLevel(1)
.moveset([ Moves.SPLASH, Moves.CLOSE_COMBAT ])
.ability(Abilities.COMPETITIVE);
});
it("lower atk and def by 1 via tickle, then increase spatk by 4 via competitive", async () => {
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(4);
});
it("lowering your own stats should not trigger competitive", async () => {
game.override.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0);
});
it("white herb should remove only the negative effects", async () => {
game.override.startingHeldItems([{ name: "WHITE_HERB" }]);
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(4);
});
});

View File

@ -0,0 +1,70 @@
import { Stat } from "#enums/stat";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Defiant", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single")
.enemySpecies(Species.BEEDRILL)
.enemyMoveset(Moves.TICKLE)
.startingLevel(1)
.moveset([ Moves.SPLASH, Moves.CLOSE_COMBAT ])
.ability(Abilities.DEFIANT);
});
it("lower atk and def by 1 via tickle, then increase atk by 4 via defiant", async () => {
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(3);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1);
});
it("lowering your own stats should not trigger defiant", async () => {
game.override.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0);
});
it("white herb should remove only the negative effects", async () => {
game.override.startingHeldItems([{ name: "WHITE_HERB" }]);
await game.classicMode.startBattle([ Species.FLYGON ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnInitPhase);
expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(3);
});
});