Updates Toxic Spikes tests
This commit is contained in:
parent
c76642798d
commit
e14f9c7113
|
@ -1,18 +1,17 @@
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
|
||||||
import GameManager from "#test/utils/gameManager";
|
import { StatusEffect } from "#app/data/status-effect";
|
||||||
|
import { decrypt, encrypt, GameData, SessionSaveData } from "#app/system/game-data";
|
||||||
import { Abilities } from "#enums/abilities";
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { Species } from "#enums/species";
|
import { Species } from "#enums/species";
|
||||||
|
import GameManager from "#test/utils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import {StatusEffect} from "#app/data/status-effect";
|
import { SPLASH_ONLY } from "../utils/testUtils";
|
||||||
import {ArenaTagType} from "#enums/arena-tag-type";
|
|
||||||
import {ArenaTrapTag} from "#app/data/arena-tag";
|
|
||||||
import {decrypt, encrypt, GameData, SessionSaveData} from "#app/system/game-data";
|
|
||||||
|
|
||||||
|
const TIMEOUT = 20 * 1000;
|
||||||
|
|
||||||
|
|
||||||
// I am frankly, not that comfortable with the testing system, these could prob be more precise
|
|
||||||
describe("Moves - Toxic Spikes", () => {
|
describe("Moves - Toxic Spikes", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
@ -29,266 +28,110 @@ describe("Moves - Toxic Spikes", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.scene.battleStyle = 1;
|
game.override
|
||||||
game.override.battleType("single");
|
.battleType("single")
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
.startingWave(5)
|
||||||
game.override.enemyAbility(Abilities.HYDRATION);
|
.enemySpecies(Species.RATTATA)
|
||||||
game.override.enemyPassiveAbility(Abilities.HYDRATION);
|
.enemyAbility(Abilities.BALL_FETCH)
|
||||||
game.override.ability(Abilities.NO_GUARD);
|
.ability(Abilities.BALL_FETCH)
|
||||||
game.override.passiveAbility(Abilities.HUGE_POWER);
|
.enemyMoveset(SPLASH_ONLY)
|
||||||
game.override.startingWave(3);
|
.moveset([Moves.TOXIC_SPIKES, Moves.SPLASH, Moves.ROAR]);
|
||||||
game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]);
|
|
||||||
game.override.moveset([Moves.TOXIC_SPIKES,Moves.SPLASH, Moves.ROAR, Moves.GLACIAL_LANCE]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("no switches, no effect", async() => {
|
it("should not affect the opponent if they do not switch", async() => {
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
|
||||||
// player set toxic spikes on the field and do splash for 3 turns
|
|
||||||
// opponent do splash for 4 turns
|
|
||||||
// nobody should take damage
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
const initialHp = game.scene.getEnemyParty()[0].hp;
|
|
||||||
expect(game.scene.getEnemyParty()[0].hp).toBe(initialHp);
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
// Opponent should be full health and not statused
|
|
||||||
expect(game.scene.getEnemyParty()[0].hp).toBe(initialHp);
|
|
||||||
expect(!(game.scene.getEnemyParty()[0].status?.effect));
|
|
||||||
console.log(game.textInterceptor.logs);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("user switch, no effect", async() => {
|
const enemy = game.scene.getEnemyField()[0];
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
|
||||||
// player set toxic spikes on the field and switch back to back
|
|
||||||
// opponent do splash for 2 turns
|
|
||||||
// nobody should be poisoned or damaged
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, false);
|
|
||||||
|
|
||||||
const initialHp = game.scene.getParty()[0].hp;
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
game.doSwitchPokemon(1);
|
game.doSwitchPokemon(1);
|
||||||
await game.phaseInterceptor.run(CommandPhase);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
await game.phaseInterceptor.to(CommandPhase, false);
|
|
||||||
|
|
||||||
game.doSwitchPokemon(1);
|
expect(enemy.hp).toBe(enemy.getMaxHp());
|
||||||
await game.phaseInterceptor.run(CommandPhase);
|
expect(enemy.status?.effect).toBeUndefined();
|
||||||
await game.phaseInterceptor.to(CommandPhase, false);
|
}, TIMEOUT);
|
||||||
|
|
||||||
expect(game.scene.getParty()[0].hp).toBe(initialHp);
|
it("should poison the opponent if they switch into 1 layer", async() => {
|
||||||
expect(!(game.scene.getEnemyParty()[0].status?.effect));
|
await game.classicMode.runToSummon([Species.MIGHTYENA]);
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("force enemy switch - poisoned", async() => {
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
game.override.startingWave(5);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
game.move.select(Moves.ROAR);
|
||||||
// player sets 1 layer of toxic spikes
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
// then forces a switch with roar
|
|
||||||
// opponent should be damaged and poisoned at end of next turn
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(2);
|
|
||||||
await game.toNextTurn();
|
|
||||||
const opponent = game.scene.currentBattle.enemyParty[0];
|
|
||||||
expect(opponent.hp).toBeLessThan(opponent.getMaxHp());
|
|
||||||
expect(game.scene.currentBattle.enemyParty[0].status?.effect).toBe(StatusEffect.POISON);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("force enemy switch - toxic", async() => {
|
const enemy = game.scene.getEnemyField()[0];
|
||||||
game.override.startingWave(5);
|
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
|
||||||
// player sets 1 layer of toxic spikes
|
|
||||||
// then forces a switch with roar
|
|
||||||
// opponent should be damaged and poisoned at end of next turn
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
game.doAttack(2);
|
|
||||||
await game.toNextTurn();
|
|
||||||
const opponent = game.scene.currentBattle.enemyParty[0];
|
|
||||||
expect(opponent.hp).toBeLessThan(opponent.getMaxHp());
|
|
||||||
expect(game.scene.currentBattle.enemyParty[0].status?.effect).toBe(StatusEffect.TOXIC);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("enemy switch - poison", async() => {
|
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
||||||
game.override.startingWave(5);
|
expect(enemy.status?.effect).toBe(StatusEffect.POISON);
|
||||||
game.override.startingLevel(5000);
|
}, TIMEOUT);
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
|
||||||
// turn 1: player set toxic spikes, opponent do splash
|
|
||||||
// turn 2: player do splash, opponent switch pokemon
|
|
||||||
// opponent pokemon should trigger spikes and get poisoned
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
|
|
||||||
game.doAttack(0);
|
it("should badly poison the opponent if they switch into 2 layers", async() => {
|
||||||
await game.toNextTurn();
|
await game.classicMode.runToSummon([Species.MIGHTYENA]);
|
||||||
|
|
||||||
game.forceOpponentToSwitch();
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
game.doAttack(1);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
await game.toNextTurn();
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
const opponent = game.scene.currentBattle.enemyParty[0];
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
expect(opponent.hp).toBeLessThan(opponent.getMaxHp());
|
game.move.select(Moves.ROAR);
|
||||||
expect(opponent.status?.effect).toBe(StatusEffect.POISON);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("enemy switch - toxic", async() => {
|
const enemy = game.scene.getEnemyField()[0];
|
||||||
game.override.startingWave(5);
|
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
||||||
game.override.startingLevel(5000);
|
expect(enemy.status?.effect).toBe(StatusEffect.TOXIC);
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
}, TIMEOUT);
|
||||||
// turn 1: player set toxic spikes, opponent do splash
|
|
||||||
// turn 2: player do splash, opponent switch pokemon
|
|
||||||
// opponent pokemon should trigger spikes and get poisoned
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
|
|
||||||
game.doAttack(0);
|
it("should be removed if a grounded poison pokemon switches in", async() => {
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
game.forceOpponentToSwitch();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
const opponent = game.scene.currentBattle.enemyParty[0];
|
|
||||||
expect(opponent.hp).toBeLessThan(opponent.getMaxHp());
|
|
||||||
expect(opponent.status?.effect).toBe(StatusEffect.TOXIC);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("grounded poison switch - absorb ", async() => {
|
|
||||||
game.override.startingWave(5);
|
|
||||||
game.override.startingLevel(5000);
|
|
||||||
game.override.enemySpecies(Species.GRIMER);
|
game.override.enemySpecies(Species.GRIMER);
|
||||||
// turn 1: player set toxic spikes, opponent do splash
|
await game.classicMode.runToSummon([Species.MIGHTYENA]);
|
||||||
// turn 2: player do splash, opponent switch pokemon
|
|
||||||
// opponent pokemon should trigger spikes and get poisoned
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
|
|
||||||
game.doAttack(0);
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
await game.toNextTurn();
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
game.move.select(Moves.ROAR);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
game.doAttack(0);
|
const enemy = game.scene.getEnemyField()[0];
|
||||||
await game.toNextTurn();
|
expect(enemy.hp).toBe(enemy.getMaxHp());
|
||||||
|
expect(enemy.status?.effect).toBeUndefined();
|
||||||
|
|
||||||
game.forceOpponentToSwitch();
|
expect(game.scene.arena.tags.length).toBe(0);
|
||||||
game.doAttack(1);
|
}, TIMEOUT);
|
||||||
await game.toNextTurn();
|
|
||||||
const opponent = game.scene.currentBattle.enemyParty[0];
|
|
||||||
|
|
||||||
// Enemy pokemon should be undamaged, and not poisoned
|
it("shouldn't create multiple layers per use in doubles", async() => {
|
||||||
expect(opponent.hp).toBe(opponent.getMaxHp());
|
await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
|
||||||
expect(!opponent.status?.effect);
|
|
||||||
|
|
||||||
// There should be no Arena Tags, as the Toxic Spikes have been absorbed
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
expect(game.scene.arena.tags.length === 0);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("doubles - one stack per use ", async() => {
|
const arenaTags = (game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag);
|
||||||
game.override.startingWave(5);
|
expect(arenaTags.tagType).toBe(ArenaTagType.TOXIC_SPIKES);
|
||||||
game.override.startingLevel(5000);
|
expect(arenaTags.layers).toBe(1);
|
||||||
game.override.enemySpecies(Species.GRIMER);
|
}, TIMEOUT);
|
||||||
game.override.battleType("double");
|
|
||||||
// turn 1: player set toxic spikes, verify one layer down
|
|
||||||
// turn 2: player set toxic spikes, verify two layers down
|
|
||||||
// turn 3: player do splash, opponent switch pokemon
|
|
||||||
// incoming grimer should absorb all layers
|
|
||||||
await game.classicMode.runToSummon([
|
|
||||||
Species.MIGHTYENA,
|
|
||||||
Species.POOCHYENA,
|
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
game.doAttack(0);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
it("should persist through reload", async() => {
|
||||||
game.doAttack(1);
|
game.override.startingWave(1);
|
||||||
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
expect(game.scene.arena.tags[0].tagType).toBe(ArenaTagType.TOXIC_SPIKES);
|
|
||||||
expect(game.scene.arena.tags[0] instanceof ArenaTrapTag);
|
|
||||||
expect((game.scene.arena.tags[0] as ArenaTrapTag).layers).toBe(1);
|
|
||||||
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
expect(game.scene.arena.tags[0].tagType).toBe(ArenaTagType.TOXIC_SPIKES);
|
|
||||||
expect(game.scene.arena.tags[0] instanceof ArenaTrapTag);
|
|
||||||
expect((game.scene.arena.tags[0] as ArenaTrapTag).layers).toBe(2);
|
|
||||||
|
|
||||||
game.forceOpponentToSwitch();
|
|
||||||
game.doAttack(1);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
// There should ben o Arena Tags, as the Toxic Spikes have been absorbed
|
|
||||||
expect(game.scene.arena.tags.length === 0);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
it("persist through reload", async() => {
|
|
||||||
game.override.startingWave(5);
|
|
||||||
game.override.startingLevel(5000);
|
|
||||||
game.override.enemySpecies(Species.RATTATA);
|
|
||||||
const scene = game.scene;
|
const scene = game.scene;
|
||||||
const gameData = new GameData(scene);
|
const gameData = new GameData(scene);
|
||||||
|
|
||||||
|
await game.classicMode.runToSummon([Species.MIGHTYENA]);
|
||||||
|
|
||||||
// turn 1: player set toxic spikes, opponent do splash
|
game.move.select(Moves.TOXIC_SPIKES);
|
||||||
// export, save, and then load session Data
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
// tags should not change through reload.
|
game.move.select(Moves.SPLASH);
|
||||||
await game.classicMode.runToSummon([
|
await game.doKillOpponents();
|
||||||
Species.MIGHTYENA,
|
await game.phaseInterceptor.to("BattleEndPhase");
|
||||||
Species.POOCHYENA,
|
await game.toNextWave();
|
||||||
]);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase, true);
|
|
||||||
|
|
||||||
game.doAttack(0);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
const sessionData : SessionSaveData = gameData["getSessionSaveData"](game.scene);
|
const sessionData : SessionSaveData = gameData["getSessionSaveData"](game.scene);
|
||||||
localStorage.setItem("sessionTestData", encrypt(JSON.stringify(sessionData), true));
|
localStorage.setItem("sessionTestData", encrypt(JSON.stringify(sessionData), true));
|
||||||
const recoveredData : SessionSaveData = gameData.parseSessionData(decrypt(localStorage.getItem("sessionTestData")!, true));
|
const recoveredData : SessionSaveData = gameData.parseSessionData(decrypt(localStorage.getItem("sessionTestData")!, true));
|
||||||
gameData.loadSession(game.scene, 0, recoveredData);
|
gameData.loadSession(game.scene, 0, recoveredData);
|
||||||
|
|
||||||
|
|
||||||
expect(sessionData.arena.tags).toEqual(recoveredData.arena.tags);
|
expect(sessionData.arena.tags).toEqual(recoveredData.arena.tags);
|
||||||
localStorage.removeItem("sessionTestData");
|
localStorage.removeItem("sessionTestData");
|
||||||
}, 20000);
|
}, TIMEOUT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue