[Test] Remove held item RNG (white herb) from intimidate tests (#3205)

Also add a helper function to remove enemy held items
This commit is contained in:
NightKev 2024-07-29 13:46:04 -07:00 committed by GitHub
parent 124ad5f970
commit 4b9c3e9b07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 11 deletions

View File

@ -12,6 +12,7 @@ import { GameModes, getGameMode } from "#app/game-mode";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { removeEnemyHeldItems } from "../utils/testUtils";
describe("Abilities - Intimidate", () => { describe("Abilities - Intimidate", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -40,6 +41,7 @@ describe("Abilities - Intimidate", () => {
it("single - wild with switch", async () => { it("single - wild with switch", async () => {
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -70,6 +72,7 @@ describe("Abilities - Intimidate", () => {
it("single - boss should only trigger once then switch", async () => { it("single - boss should only trigger once then switch", async () => {
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -99,6 +102,7 @@ describe("Abilities - Intimidate", () => {
it("single - trainer should only trigger once with switch", async () => { it("single - trainer should only trigger once with switch", async () => {
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -129,6 +133,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double"); vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double");
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -155,6 +160,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double"); vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double");
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(3); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(3);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -181,6 +187,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double"); vi.spyOn(Overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("double");
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10);
await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); await game.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
game.onNextPrompt( game.onNextPrompt(
"CheckSwitchPhase", "CheckSwitchPhase",
Mode.CONFIRM, Mode.CONFIRM,
@ -207,6 +214,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(2); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(2);
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.AERIAL_ACE]); vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.AERIAL_ACE]);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -233,6 +241,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(2); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(2);
vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH]); vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH]);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -258,6 +267,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH]); vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH, Moves.VOLT_SWITCH]);
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -297,6 +307,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]);
removeEnemyHeldItems(game.scene);
let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; let battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -336,9 +347,7 @@ describe("Abilities - Intimidate", () => {
vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(3); vi.spyOn(Overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(3);
vi.spyOn(Overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{ name: "COIN_CASE" }]); vi.spyOn(Overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{ name: "COIN_CASE" }]);
await game.runToSummon([Species.MIGHTYENA]); await game.runToSummon([Species.MIGHTYENA]);
// Get rid of any modifiers that may alter power removeEnemyHeldItems(game.scene);
game.scene.clearEnemyHeldItemModifiers();
game.scene.clearEnemyModifiers();
await game.phaseInterceptor.to(CommandPhase, false); await game.phaseInterceptor.to(CommandPhase, false);
const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
@ -365,6 +374,7 @@ describe("Abilities - Intimidate", () => {
}); });
await game.phaseInterceptor.run(EncounterPhase); await game.phaseInterceptor.run(EncounterPhase);
removeEnemyHeldItems(game.scene);
await game.phaseInterceptor.to(CommandPhase, false); await game.phaseInterceptor.to(CommandPhase, false);
const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; const battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;

View File

@ -1,14 +1,14 @@
// Function to convert Blob to string import { getDailyRunStarters } from "#app/data/daily-run";
import {getDailyRunStarters} from "#app/data/daily-run"; import { Gender } from "#app/data/gender";
import {Gender} from "#app/data/gender"; import { Species } from "#enums/species";
import {Species} from "#enums/species"; import { Starter } from "#app/ui/starter-select-ui-handler";
import {Starter} from "#app/ui/starter-select-ui-handler"; import { GameModes, getGameMode } from "#app/game-mode";
import {GameModes, getGameMode} from "#app/game-mode"; import { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
import {getPokemonSpecies, getPokemonSpeciesForm} from "#app/data/pokemon-species"; import { PlayerPokemon } from "#app/field/pokemon";
import {PlayerPokemon} from "#app/field/pokemon";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import BattleScene from "#app/battle-scene"; import BattleScene from "#app/battle-scene";
/** Function to convert Blob to string */
export function blobToString(blob) { export function blobToString(blob) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();

View File

@ -1,3 +1,4 @@
import BattleScene from "#app/battle-scene.js";
import { Moves } from "#app/enums/moves.js"; import { Moves } from "#app/enums/moves.js";
import i18next, { type ParseKeys } from "i18next"; import i18next, { type ParseKeys } from "i18next";
import { vi } from "vitest"; import { vi } from "vitest";
@ -26,3 +27,11 @@ export function arrayOfRange(start: integer, end: integer) {
return Array.from({ length: end - start }, (_v, k) => k + start); return Array.from({ length: end - start }, (_v, k) => k + start);
} }
/**
* Removes all held items from enemy pokemon
* @param scene `game.scene`
*/
export function removeEnemyHeldItems(scene: BattleScene) {
scene.clearEnemyHeldItemModifiers();
scene.clearEnemyModifiers();
}