mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
[Bug] Removes firstHitOnly from AddArenaTagAttr to allow multi hit set up with Ceaseless Edge (#2727)
* Removes firstHitOnly from AddArenaTagAttr to allow multi hit set up with ceaseless edge * Creates initial test file with basic cases for ceaseless edge * Fixes ceaseless edge unit test and expands on case 3 * Adds truthy/falsy expectations prior to use
This commit is contained in:
parent
458245f542
commit
7474eac808
@ -4218,7 +4218,7 @@ export class AddArenaTagAttr extends MoveEffectAttr {
|
||||
public selfSideTarget: boolean;
|
||||
|
||||
constructor(tagType: ArenaTagType, turnCount?: integer, failOnOverlap: boolean = false, selfSideTarget: boolean = false) {
|
||||
super(true, MoveEffectTrigger.POST_APPLY, true);
|
||||
super(true, MoveEffectTrigger.POST_APPLY);
|
||||
|
||||
this.tagType = tagType;
|
||||
this.turnCount = turnCount;
|
||||
|
135
src/test/moves/ceaseless_edge.test.ts
Normal file
135
src/test/moves/ceaseless_edge.test.ts
Normal file
@ -0,0 +1,135 @@
|
||||
import {afterEach, beforeAll, beforeEach, describe, expect, test, vi} from "vitest";
|
||||
import Phaser from "phaser";
|
||||
import GameManager from "#app/test/utils/gameManager";
|
||||
import * as overrides from "#app/overrides";
|
||||
import {
|
||||
MoveEffectPhase,
|
||||
TurnEndPhase
|
||||
} from "#app/phases";
|
||||
import {getMovePosition} from "#app/test/utils/gameManagerUtils";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { ArenaTagType } from "#app/enums/arena-tag-type.js";
|
||||
import { allMoves } from "#app/data/move.js";
|
||||
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag.js";
|
||||
|
||||
const TIMEOUT = 20 * 1000;
|
||||
|
||||
describe("Moves - Ceaseless Edge", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.RATTATA);
|
||||
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
||||
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]);
|
||||
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]);
|
||||
vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
|
||||
|
||||
});
|
||||
|
||||
test(
|
||||
"move should hit and apply spikes",
|
||||
async () => {
|
||||
await game.startBattle([ Species.ILLUMISE ]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerPokemon();
|
||||
expect(leadPokemon).toBeDefined();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||
expect(enemyPokemon).toBeDefined();
|
||||
|
||||
const enemyStartingHp = enemyPokemon.hp;
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE));
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
// Spikes should not have any layers before move effect is applied
|
||||
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
|
||||
|
||||
await game.phaseInterceptor.to(TurnEndPhase);
|
||||
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
|
||||
expect(tagAfter.layers).toBe(1);
|
||||
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
||||
}, TIMEOUT
|
||||
);
|
||||
|
||||
test(
|
||||
"move should hit twice with multi lens and apply two layers of spikes",
|
||||
async () => {
|
||||
vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "MULTI_LENS"}]);
|
||||
await game.startBattle([ Species.ILLUMISE ]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerPokemon();
|
||||
expect(leadPokemon).toBeDefined();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||
expect(enemyPokemon).toBeDefined();
|
||||
|
||||
const enemyStartingHp = enemyPokemon.hp;
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE));
|
||||
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
// Spikes should not have any layers before move effect is applied
|
||||
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
|
||||
|
||||
await game.phaseInterceptor.to(TurnEndPhase);
|
||||
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
|
||||
expect(tagAfter.layers).toBe(2);
|
||||
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
||||
}, TIMEOUT
|
||||
);
|
||||
|
||||
test(
|
||||
"trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage",
|
||||
async () => {
|
||||
vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "MULTI_LENS"}]);
|
||||
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
||||
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(0);
|
||||
|
||||
await game.startBattle([ Species.SNORLAX, Species.MUNCHLAX ]);
|
||||
|
||||
const leadPokemon = game.scene.getPlayerPokemon();
|
||||
expect(leadPokemon).toBeDefined();
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||
expect(enemyPokemon).toBeDefined();
|
||||
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE));
|
||||
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
||||
// Spikes should not have any layers before move effect is applied
|
||||
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagBefore instanceof ArenaTrapTag).toBeFalsy();
|
||||
|
||||
await game.phaseInterceptor.to(TurnEndPhase, false);
|
||||
const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
|
||||
expect(tagAfter instanceof ArenaTrapTag).toBeTruthy();
|
||||
expect(tagAfter.layers).toBe(2);
|
||||
|
||||
const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp;
|
||||
// Check HP of pokemon that WILL BE switched in (index 1)
|
||||
game.forceOpponentToSwitch();
|
||||
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
||||
await game.phaseInterceptor.to(TurnEndPhase, false);
|
||||
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes);
|
||||
}, TIMEOUT
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user