mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
[Bug] Fix Guard Swap and Power Swap swapping all stats (#4213)
* [Bug] Fix `SwapStatStagesAttr` Oversight * Remove SPLASH_ONLY Leftover
This commit is contained in:
parent
dd61950cb1
commit
1cf075adc9
@ -2836,7 +2836,7 @@ export class SwapStatStagesAttr extends MoveEffectAttr {
|
|||||||
*/
|
*/
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any []): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any []): boolean {
|
||||||
if (super.apply(user, target, move, args)) {
|
if (super.apply(user, target, move, args)) {
|
||||||
for (const s of BATTLE_STATS) {
|
for (const s of this.stats) {
|
||||||
const temp = user.getStatStage(s);
|
const temp = user.getStatStage(s);
|
||||||
user.setStatStage(s, target.getStatStage(s));
|
user.setStatStage(s, target.getStatStage(s));
|
||||||
target.setStatStage(s, temp);
|
target.setStatStage(s, temp);
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import GameManager from "#app/test/utils/gameManager";
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat, BATTLE_STATS } from "#enums/stat";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
||||||
|
|
||||||
describe("Moves - Guard Swap", () => {
|
describe("Moves - Guard Swap", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
const TIMEOUT = 20 * 1000;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
@ -27,37 +28,42 @@ describe("Moves - Guard Swap", () => {
|
|||||||
game.override
|
game.override
|
||||||
.battleType("single")
|
.battleType("single")
|
||||||
.enemyAbility(Abilities.BALL_FETCH)
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
.enemyMoveset([Moves.SHELL_SMASH])
|
.enemyMoveset(Moves.SPLASH)
|
||||||
.enemySpecies(Species.MEW)
|
.enemySpecies(Species.INDEEDEE)
|
||||||
.enemyLevel(200)
|
.enemyLevel(200)
|
||||||
.moveset([ Moves.GUARD_SWAP ])
|
.moveset([ Moves.GUARD_SWAP ])
|
||||||
.ability(Abilities.NONE);
|
.ability(Abilities.NONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should swap the user's DEF AND SPDEF stat stages with the target's", async () => {
|
it("should swap the user's DEF and SPDEF stat stages with the target's", async () => {
|
||||||
await game.startBattle([
|
await game.classicMode.startBattle([
|
||||||
Species.INDEEDEE
|
Species.INDEEDEE
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Should start with no stat stages
|
|
||||||
const player = game.scene.getPlayerPokemon()!;
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
// After Shell Smash, should have +2 in ATK and SPATK, -1 in DEF and SPDEF
|
|
||||||
const enemy = game.scene.getEnemyPokemon()!;
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
vi.spyOn(enemy.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(1));
|
||||||
|
|
||||||
game.move.select(Moves.GUARD_SWAP);
|
game.move.select(Moves.GUARD_SWAP);
|
||||||
|
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
await game.phaseInterceptor.to(MoveEndPhase);
|
||||||
|
|
||||||
expect(player.getStatStage(Stat.DEF)).toBe(0);
|
for (const s of BATTLE_STATS) {
|
||||||
expect(player.getStatStage(Stat.SPDEF)).toBe(0);
|
expect(player.getStatStage(s)).toBe(0);
|
||||||
expect(enemy.getStatStage(Stat.DEF)).toBe(-1);
|
expect(enemy.getStatStage(s)).toBe(1);
|
||||||
expect(enemy.getStatStage(Stat.SPDEF)).toBe(-1);
|
}
|
||||||
|
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
expect(player.getStatStage(Stat.DEF)).toBe(-1);
|
for (const s of BATTLE_STATS) {
|
||||||
expect(player.getStatStage(Stat.SPDEF)).toBe(-1);
|
if (s === Stat.DEF || s === Stat.SPDEF) {
|
||||||
expect(enemy.getStatStage(Stat.DEF)).toBe(0);
|
expect(player.getStatStage(s)).toBe(1);
|
||||||
expect(enemy.getStatStage(Stat.SPDEF)).toBe(0);
|
expect(enemy.getStatStage(s)).toBe(0);
|
||||||
}, 20000);
|
} else {
|
||||||
|
expect(player.getStatStage(s)).toBe(0);
|
||||||
|
expect(enemy.getStatStage(s)).toBe(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, TIMEOUT);
|
||||||
});
|
});
|
||||||
|
64
src/test/moves/heart_swap.test.ts
Normal file
64
src/test/moves/heart_swap.test.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { BATTLE_STATS } from "#enums/stat";
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
||||||
|
|
||||||
|
describe("Moves - Heart Swap", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
const TIMEOUT = 20 * 1000;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
|
.battleType("single")
|
||||||
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
|
.enemyMoveset(Moves.SPLASH)
|
||||||
|
.enemySpecies(Species.INDEEDEE)
|
||||||
|
.enemyLevel(200)
|
||||||
|
.moveset([ Moves.HEART_SWAP ])
|
||||||
|
.ability(Abilities.NONE);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should swap all of the user's stat stages with the target's", async () => {
|
||||||
|
await game.classicMode.startBattle([
|
||||||
|
Species.MANAPHY
|
||||||
|
]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
vi.spyOn(enemy.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(1));
|
||||||
|
|
||||||
|
game.move.select(Moves.HEART_SWAP);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(MoveEndPhase);
|
||||||
|
|
||||||
|
for (const s of BATTLE_STATS) {
|
||||||
|
expect(player.getStatStage(s)).toBe(0);
|
||||||
|
expect(enemy.getStatStage(s)).toBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
|
for (const s of BATTLE_STATS) {
|
||||||
|
expect(enemy.getStatStage(s)).toBe(0);
|
||||||
|
expect(player.getStatStage(s)).toBe(1);
|
||||||
|
}
|
||||||
|
}, TIMEOUT);
|
||||||
|
});
|
@ -1,16 +1,17 @@
|
|||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import GameManager from "#app/test/utils/gameManager";
|
import GameManager from "#app/test/utils/gameManager";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat, BATTLE_STATS } from "#enums/stat";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
||||||
|
|
||||||
describe("Moves - Power Swap", () => {
|
describe("Moves - Power Swap", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
const TIMEOUT = 20 * 1000;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
phaserGame = new Phaser.Game({
|
phaserGame = new Phaser.Game({
|
||||||
@ -27,36 +28,42 @@ describe("Moves - Power Swap", () => {
|
|||||||
game.override
|
game.override
|
||||||
.battleType("single")
|
.battleType("single")
|
||||||
.enemyAbility(Abilities.BALL_FETCH)
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
.enemyMoveset([Moves.SHELL_SMASH])
|
.enemyMoveset(Moves.SPLASH)
|
||||||
.enemySpecies(Species.MEW)
|
.enemySpecies(Species.INDEEDEE)
|
||||||
.enemyLevel(200)
|
.enemyLevel(200)
|
||||||
.moveset([ Moves.POWER_SWAP ])
|
.moveset([ Moves.POWER_SWAP ])
|
||||||
.ability(Abilities.NONE);
|
.ability(Abilities.NONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should swap the user's ATK AND SPATK stat stages with the target's", async () => {
|
it("should swap the user's ATK and SPATK stat stages with the target's", async () => {
|
||||||
await game.startBattle([
|
await game.classicMode.startBattle([
|
||||||
Species.INDEEDEE
|
Species.INDEEDEE
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Should start with no stat stages
|
|
||||||
const player = game.scene.getPlayerPokemon()!;
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
// After Shell Smash, should have +2 in ATK and SPATK, -1 in DEF and SPDEF
|
|
||||||
const enemy = game.scene.getEnemyPokemon()!;
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
|
vi.spyOn(enemy.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(1));
|
||||||
|
|
||||||
game.move.select(Moves.POWER_SWAP);
|
game.move.select(Moves.POWER_SWAP);
|
||||||
|
|
||||||
await game.phaseInterceptor.to(MoveEndPhase);
|
await game.phaseInterceptor.to(MoveEndPhase);
|
||||||
|
|
||||||
expect(player.getStatStage(Stat.ATK)).toBe(0);
|
for (const s of BATTLE_STATS) {
|
||||||
expect(player.getStatStage(Stat.SPATK)).toBe(0);
|
expect(player.getStatStage(s)).toBe(0);
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(2);
|
expect(enemy.getStatStage(s)).toBe(1);
|
||||||
expect(enemy.getStatStage(Stat.SPATK)).toBe(2);
|
}
|
||||||
|
|
||||||
await game.phaseInterceptor.to(TurnEndPhase);
|
await game.phaseInterceptor.to(TurnEndPhase);
|
||||||
|
|
||||||
expect(player.getStatStage(Stat.ATK)).toBe(2);
|
for (const s of BATTLE_STATS) {
|
||||||
expect(player.getStatStage(Stat.SPATK)).toBe(2);
|
if (s === Stat.ATK || s === Stat.SPATK) {
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(0);
|
expect(player.getStatStage(s)).toBe(1);
|
||||||
expect(enemy.getStatStage(Stat.SPATK)).toBe(0);
|
expect(enemy.getStatStage(s)).toBe(0);
|
||||||
}, 20000);
|
} else {
|
||||||
|
expect(player.getStatStage(s)).toBe(0);
|
||||||
|
expect(enemy.getStatStage(s)).toBe(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, TIMEOUT);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user