-
-
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] Honey Gather and Pickup will only activate if the battle was won (
#4903) * Honey Gather and Pickup will only activate if the battle was won * Add tests for Honey Gather * Moves `highestEndlessWave` and `battles` stats outside of victory condition
- Loading branch information
Showing
7 changed files
with
97 additions
and
18 deletions.
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
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
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
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,74 @@ | ||
import type { CommandPhase } from "#app/phases/command-phase"; | ||
import { Command } from "#app/ui/command-ui-handler"; | ||
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, vi } from "vitest"; | ||
|
||
describe("Abilities - Honey Gather", () => { | ||
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.ROAR, Moves.THUNDERBOLT ]) | ||
.startingLevel(100) | ||
.ability(Abilities.HONEY_GATHER) | ||
.passiveAbility(Abilities.RUN_AWAY) | ||
.battleType("single") | ||
.disableCrits() | ||
.enemySpecies(Species.MAGIKARP) | ||
.enemyAbility(Abilities.BALL_FETCH) | ||
.enemyMoveset(Moves.SPLASH); | ||
}); | ||
|
||
it("should give money when winning a battle", async () => { | ||
await game.classicMode.startBattle([ Species.MILOTIC ]); | ||
game.scene.money = 1000; | ||
|
||
game.move.select(Moves.THUNDERBOLT); | ||
await game.toNextWave(); | ||
|
||
expect(game.scene.money).toBeGreaterThan(1000); | ||
}); | ||
|
||
it("should not give money when the enemy pokemon flees", async () => { | ||
await game.classicMode.startBattle([ Species.MILOTIC ]); | ||
game.scene.money = 1000; | ||
|
||
game.move.select(Moves.ROAR); | ||
await game.toNextTurn(); | ||
|
||
expect(game.scene.money).toBe(1000); | ||
expect(game.scene.currentBattle.waveIndex).toBe(2); | ||
}); | ||
|
||
it("should not give money when the player flees", async () => { | ||
await game.classicMode.startBattle([ Species.MILOTIC ]); | ||
game.scene.money = 1000; | ||
|
||
// something weird is going on with the test framework, so this is required to prevent a crash | ||
const enemy = game.scene.getEnemyPokemon()!; | ||
vi.spyOn(enemy, "scene", "get").mockReturnValue(game.scene); | ||
|
||
const commandPhase = game.scene.getCurrentPhase() as CommandPhase; | ||
commandPhase.handleCommand(Command.RUN, 0); | ||
await game.toNextTurn(); | ||
|
||
expect(game.scene.money).toBe(1000); | ||
expect(game.scene.currentBattle.waveIndex).toBe(2); | ||
}); | ||
}); |