-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] Stakeout should trigger if the enemy switches with U-Turn/etc (#…
- Loading branch information
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { BattlerIndex } from "#app/battle"; | ||
import { isBetween } from "#app/utils"; | ||
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 - Stakeout", () => { | ||
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 | ||
.moveset([ Moves.SPLASH, Moves.SURF ]) | ||
.ability(Abilities.STAKEOUT) | ||
.battleType("single") | ||
.disableCrits() | ||
.startingLevel(100) | ||
.enemyLevel(100) | ||
.enemySpecies(Species.SNORLAX) | ||
.enemyAbility(Abilities.BALL_FETCH) | ||
.enemyMoveset([ Moves.SPLASH, Moves.FLIP_TURN ]) | ||
.startingWave(5); | ||
}); | ||
|
||
it("should do double damage to a pokemon that switched out", async () => { | ||
await game.classicMode.startBattle([ Species.MILOTIC ]); | ||
|
||
const [ enemy1, ] = game.scene.getEnemyParty(); | ||
|
||
game.move.select(Moves.SURF); | ||
await game.forceEnemyMove(Moves.SPLASH); | ||
await game.toNextTurn(); | ||
const damage1 = enemy1.getInverseHp(); | ||
enemy1.hp = enemy1.getMaxHp(); | ||
|
||
game.move.select(Moves.SPLASH); | ||
game.forceEnemyToSwitch(); | ||
await game.toNextTurn(); | ||
|
||
game.move.select(Moves.SURF); | ||
game.forceEnemyToSwitch(); | ||
await game.toNextTurn(); | ||
|
||
expect(enemy1.isFainted()).toBe(false); | ||
expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); | ||
}); | ||
|
||
it("should do double damage to a pokemon that switched out via U-Turn/etc", async () => { | ||
await game.classicMode.startBattle([ Species.MILOTIC ]); | ||
|
||
const [ enemy1, ] = game.scene.getEnemyParty(); | ||
|
||
game.move.select(Moves.SURF); | ||
await game.forceEnemyMove(Moves.SPLASH); | ||
await game.toNextTurn(); | ||
const damage1 = enemy1.getInverseHp(); | ||
enemy1.hp = enemy1.getMaxHp(); | ||
|
||
game.move.select(Moves.SPLASH); | ||
await game.forceEnemyMove(Moves.FLIP_TURN); | ||
await game.toNextTurn(); | ||
|
||
game.move.select(Moves.SURF); | ||
await game.forceEnemyMove(Moves.FLIP_TURN); | ||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); | ||
await game.toNextTurn(); | ||
|
||
expect(enemy1.isFainted()).toBe(false); | ||
expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); | ||
}); | ||
}); |