Skip to content

Commit 224a5e0

Browse files
authored
test: add tests for first-turn-moves (#7095)
* test: add tests for first impression * fix mat block error
1 parent e6c515e commit 224a5e0

File tree

3 files changed

+26
-48
lines changed

3 files changed

+26
-48
lines changed

src/data/moves/move-condition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class FirstMoveCondition extends MoveCondition {
4949
super(user => user.tempSummonData.waveTurnCount === 1);
5050
}
5151

52-
// TODO: Update AI move selection logic to not require this method at all
52+
// TODO: Update AI move selection logic to not require this method (and this class) at all
5353
// Currently, it is used to avoid having the AI select the move if its condition will fail
5454
getUserBenefitScore(user: Pokemon, _target: Pokemon, _move: Move): number {
5555
return this.apply(user, _target, _move) ? 10 : -20;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { MoveId } from "#enums/move-id";
2+
import { MoveResult } from "#enums/move-result";
23
import { SpeciesId } from "#enums/species-id";
34
import { GameManager } from "#test/framework/game-manager";
45
import Phaser from "phaser";
56
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
67

7-
describe("Moves - Fake Out", () => {
8+
describe.each([
9+
{ move: MoveId.FAKE_OUT, name: "Fake Out" },
10+
{ move: MoveId.FIRST_IMPRESSION, name: "First Impression" },
11+
{ move: MoveId.MAT_BLOCK, name: "Mat Block" },
12+
])("Move - $name", ({ move }) => {
813
let phaserGame: Phaser.Game;
914
let game: GameManager;
1015

@@ -18,64 +23,56 @@ describe("Moves - Fake Out", () => {
1823
game = new GameManager(phaserGame);
1924
game.override
2025
.battleStyle("single")
21-
.enemySpecies(SpeciesId.CORVIKNIGHT)
26+
.enemySpecies(SpeciesId.SHUCKLE)
2227
.enemyMoveset(MoveId.SPLASH)
23-
.enemyLevel(10)
24-
.startingLevel(1) // prevent LevelUpPhase from happening
28+
.enemyLevel(100)
29+
.startingLevel(100)
2530
.criticalHits(false);
2631
});
2732

2833
it("should only work the first turn a pokemon is sent out in a battle", async () => {
2934
await game.classicMode.startBattle(SpeciesId.FEEBAS);
3035

31-
game.move.use(MoveId.FAKE_OUT);
36+
game.move.use(move);
3237
await game.toNextTurn();
3338

34-
const corv = game.field.getEnemyPokemon();
35-
expect(corv).not.toHaveFullHp();
36-
corv.hp = corv.getMaxHp();
39+
const feebas = game.field.getPlayerPokemon();
40+
expect(feebas).toHaveUsedMove({ move, result: MoveResult.SUCCESS });
3741

38-
game.move.use(MoveId.FAKE_OUT);
39-
await game.toNextTurn();
42+
game.move.use(move);
43+
await game.toEndOfTurn();
4044

41-
expect(corv).toHaveFullHp();
45+
expect(feebas).toHaveUsedMove({ move, result: MoveResult.FAIL });
4246
});
4347

44-
// This is a PokeRogue buff to Fake Out
48+
// This is a PokeRogue buff to Fake Out & co.
4549
it("should succeed at the start of each new wave, even if user wasn't recalled", async () => {
4650
await game.classicMode.startBattle(SpeciesId.FEEBAS);
4751

48-
// set hp to 1 for easy knockout
49-
game.field.getEnemyPokemon().hp = 1;
50-
game.move.use(MoveId.FAKE_OUT);
52+
game.move.use(MoveId.SPLASH);
53+
await game.doKillOpponents();
5154
await game.toNextWave();
5255

53-
game.move.use(MoveId.FAKE_OUT);
56+
game.move.use(move);
5457
await game.toNextTurn();
5558

56-
const corv = game.field.getEnemyPokemon();
57-
expect(corv).not.toHaveFullHp();
59+
const feebas = game.field.getPlayerPokemon();
60+
expect(feebas).toHaveUsedMove({ move, result: MoveResult.SUCCESS });
5861
});
5962

6063
it("should succeed if recalled and sent back out", async () => {
6164
await game.classicMode.startBattle(SpeciesId.FEEBAS, SpeciesId.MAGIKARP);
6265

63-
game.move.use(MoveId.FAKE_OUT);
64-
await game.toNextTurn();
65-
66-
const corv = game.field.getEnemyPokemon();
67-
expect(corv).not.toHaveFullHp();
68-
corv.hp = corv.getMaxHp();
69-
7066
game.doSwitchPokemon(1);
7167
await game.toNextTurn();
7268

7369
game.doSwitchPokemon(1);
7470
await game.toNextTurn();
7571

76-
game.move.use(MoveId.FAKE_OUT);
72+
game.move.use(move);
7773
await game.toNextTurn();
7874

79-
expect(corv).not.toHaveFullHp();
75+
const feebas = game.field.getPlayerPokemon();
76+
expect(feebas).toHaveUsedMove({ move, result: MoveResult.SUCCESS });
8077
});
8178
});

test/tests/moves/mat-block.test.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,5 @@ describe("Moves - Mat Block", () => {
6464
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(-2));
6565
});
6666

67-
test("should fail when used after the first turn", async () => {
68-
await game.classicMode.startBattle(SpeciesId.BLASTOISE, SpeciesId.CHARIZARD);
69-
70-
const leadPokemon = game.scene.getPlayerField();
71-
72-
game.move.select(MoveId.SPLASH);
73-
game.move.select(MoveId.SPLASH, 1);
74-
75-
await game.phaseInterceptor.to("TurnEndPhase");
76-
77-
const leadStartingHp = leadPokemon.map(p => p.hp);
78-
79-
await game.phaseInterceptor.to("CommandPhase", false);
80-
game.move.select(MoveId.MAT_BLOCK);
81-
game.move.select(MoveId.MAT_BLOCK, 1);
82-
83-
await game.phaseInterceptor.to("BerryPhase", false);
84-
85-
expect(leadPokemon.some((p, i) => p.hp < leadStartingHp[i])).toBeTruthy();
86-
});
67+
// first turn behavior covered inside first-turn-moves.test.ts
8768
});

0 commit comments

Comments
 (0)