mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 03:32:24 +02:00
Attempts to make new overrides for testing
This commit is contained in:
parent
2eb092e85b
commit
22b7f94b0b
@ -1439,8 +1439,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
*/
|
||||
public hasPassive(): boolean {
|
||||
// returns override if valid for current case
|
||||
if ((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && this.isPlayer())
|
||||
|| (Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE && !this.isPlayer())) {
|
||||
if (((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || Overrides.HAS_PASSIVE_ABILITY_OVERRIDE) && this.isPlayer())
|
||||
|| ((Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || Overrides.OPP_HAS_PASSIVE_ABILITY_OVERRIDE) && !this.isPlayer())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
110
src/test/abilities/desolate-land.test.ts
Normal file
110
src/test/abilities/desolate-land.test.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import { WeatherType } from "#app/enums/weather-type";
|
||||
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, it, expect, vi } from "vitest";
|
||||
|
||||
describe("Abilities - Desolate Land", () => {
|
||||
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)
|
||||
.hasPassiveAbility(true)
|
||||
.enemySpecies(Species.RALTS)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(Moves.SPLASH);
|
||||
});
|
||||
|
||||
/**
|
||||
* This checks that the weather has changed after the Enemy Pokemon with {@linkcode Abilities.DESOLATE_LAND}
|
||||
* is forcefully moved out of the field from moves such as Roar {@linkcode Moves.ROAR}
|
||||
*/
|
||||
it("should lift when all pokemon with this ability leave the field", async () => {
|
||||
game.override
|
||||
.battleType("double")
|
||||
.enemyMoveset([ Moves.SPLASH, Moves.ROAR ]);
|
||||
await game.classicMode.startBattle([ Species.MAGCARGO, Species.MAGCARGO, Species.MAGIKARP, Species.MAGIKARP ]);
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
|
||||
|
||||
vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => {
|
||||
return min;
|
||||
});
|
||||
|
||||
game.move.select(Moves.SPLASH, 0, 2);
|
||||
game.move.select(Moves.SPLASH, 1, 2);
|
||||
|
||||
await game.forceEnemyMove(Moves.ROAR, 0);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
||||
vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => {
|
||||
return min + 1;
|
||||
});
|
||||
|
||||
game.move.select(Moves.SPLASH, 0, 2);
|
||||
game.move.select(Moves.SPLASH, 1, 2);
|
||||
|
||||
await game.forceEnemyMove(Moves.ROAR, 1);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
|
||||
});
|
||||
|
||||
it("should lift when enemy faints", async () => {
|
||||
game.override
|
||||
.battleType("single")
|
||||
.moveset([ Moves.SHEER_COLD ])
|
||||
.ability(Abilities.NO_GUARD)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(1)
|
||||
.enemyMoveset([ Moves.SPLASH ])
|
||||
.enemySpecies(Species.MAGCARGO)
|
||||
.enemyHasPassiveAbility(true);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
|
||||
|
||||
game.move.select(Moves.SHEER_COLD);
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
|
||||
});
|
||||
|
||||
it("should lift when enemy is captured", async () => {
|
||||
game.override
|
||||
.battleType("single")
|
||||
.enemyMoveset([ Moves.SPLASH ])
|
||||
.enemySpecies(Species.MAGCARGO)
|
||||
.enemyHasPassiveAbility(true);
|
||||
await game.classicMode.startBattle([ Species.MAGIKARP ]);
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN);
|
||||
|
||||
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.HARSH_SUN);
|
||||
});
|
||||
});
|
@ -452,6 +452,25 @@ export default class GameManager {
|
||||
});
|
||||
}
|
||||
|
||||
doThrowPokeball(ballIndex: number) {
|
||||
this.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
||||
(this.scene.ui.getHandler() as CommandUiHandler).setCursor(1);
|
||||
(this.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION);
|
||||
});
|
||||
|
||||
this.doSelectPokeball(ballIndex, "CommandPhase");
|
||||
}
|
||||
// ???
|
||||
doSelectPokeball(slot: number, inPhase = "SwitchPhase") {
|
||||
this.onNextPrompt(inPhase, Mode.PARTY, () => {
|
||||
const partyHandler = this.scene.ui.getHandler() as PartyUiHandler;
|
||||
|
||||
partyHandler.setCursor(slot);
|
||||
partyHandler.processInput(Button.ACTION); // select party slot
|
||||
partyHandler.processInput(Button.ACTION); // send out (or whatever option is at the top)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Intercepts `TurnStartPhase` and mocks the getSpeedOrder's return value {@linkcode TurnStartPhase.getSpeedOrder}
|
||||
* Used to modify the turn order.
|
||||
|
@ -161,6 +161,11 @@ export class OverridesHelper extends GameManagerHelper {
|
||||
return this;
|
||||
}
|
||||
|
||||
public hasPassiveAbility(hasPassiveAbility: boolean): this {
|
||||
vi.spyOn(Overrides, "HAS_PASSIVE_ABILITY_OVERRIDE", "get").mockReturnValue(hasPassiveAbility);
|
||||
this.log("Player Pokemon PASSIVE ability is active!");
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Override the player (pokemon) {@linkcode Moves | moves}set
|
||||
* @param moveset the {@linkcode Moves | moves}set to set
|
||||
@ -305,6 +310,12 @@ export class OverridesHelper extends GameManagerHelper {
|
||||
return this;
|
||||
}
|
||||
|
||||
public enemyHasPassiveAbility(hasPassiveAbility: boolean): this {
|
||||
vi.spyOn(Overrides, "OPP_HAS_PASSIVE_ABILITY_OVERRIDE", "get").mockReturnValue(hasPassiveAbility);
|
||||
this.log("Enemy Pokemon PASSIVE ability is active!");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the enemy (pokemon) {@linkcode Moves | moves}set
|
||||
* @param moveset the {@linkcode Moves | moves}set to set
|
||||
|
Loading…
Reference in New Issue
Block a user