Cleaned up more tests

This commit is contained in:
Wlowscha 2025-07-13 00:42:29 +02:00
parent 9925b0c358
commit 414a6b10ea
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
19 changed files with 56 additions and 74 deletions

View File

@ -1,5 +1,4 @@
import { allSpecies } from "#app/data/data-lists"; import { allSpecies } from "#app/data/data-lists";
import { Stat } from "#enums/stat";
import { getGameMode } from "#app/game-mode"; import { getGameMode } from "#app/game-mode";
import { GameModes } from "#enums/game-modes"; import { GameModes } from "#enums/game-modes";
import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { BattleEndPhase } from "#app/phases/battle-end-phase";
@ -25,6 +24,7 @@ import { SpeciesId } from "#enums/species-id";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { BiomeId } from "#enums/biome-id"; import { BiomeId } from "#enums/biome-id";
import { TrainerItemId } from "#enums/trainer-item-id";
describe("Test Battle Phase", () => { describe("Test Battle Phase", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -312,7 +312,7 @@ describe("Test Battle Phase", () => {
.startingLevel(100) .startingLevel(100)
.moveset([moveToUse]) .moveset([moveToUse])
.enemyMoveset(MoveId.SPLASH) .enemyMoveset(MoveId.SPLASH)
.startingHeldItems([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]); .startingTrainerItems([{ entry: TrainerItemId.X_ACCURACY }]);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
game.scene.getPlayerPokemon()!.hp = 1; game.scene.getPlayerPokemon()!.hp = 1;

View File

@ -1,10 +1,9 @@
import { allMoves } from "#app/data/data-lists"; import { allMoves } from "#app/data/data-lists";
import type { EnemyPersistentModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/data/data-lists";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagType } from "#enums/arena-tag-type";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { TrainerItemId } from "#enums/trainer-item-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -72,9 +71,7 @@ describe("Battle Mechanics - Damage Calculation", () => {
await game.classicMode.startBattle([SpeciesId.SHUCKLE]); await game.classicMode.startBattle([SpeciesId.SHUCKLE]);
const dmg_redux_modifier = modifierTypes.ENEMY_DAMAGE_REDUCTION().newModifier() as EnemyPersistentModifier; game.scene.enemyTrainerItems.add(TrainerItemId.ENEMY_DAMAGE_REDUCTION, 1000);
dmg_redux_modifier.stackCount = 1000;
await game.scene.addEnemyModifier(modifierTypes.ENEMY_DAMAGE_REDUCTION().newModifier() as EnemyPersistentModifier);
const aggron = game.scene.getEnemyPokemon()!; const aggron = game.scene.getEnemyPokemon()!;

View File

@ -1,12 +1,12 @@
import { BiomeId } from "#enums/biome-id"; import { BiomeId } from "#enums/biome-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MapModifier } from "#app/modifier/modifier";
import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
import RewardSelectUiHandler from "#app/ui/reward-select-ui-handler"; import RewardSelectUiHandler from "#app/ui/reward-select-ui-handler";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import { TrainerItemId } from "#enums/trainer-item-id";
//const TIMEOUT = 20 * 1000; //const TIMEOUT = 20 * 1000;
@ -38,7 +38,7 @@ describe("Daily Mode", () => {
expect(pkm.level).toBe(20); expect(pkm.level).toBe(20);
expect(pkm.moveset.length).toBeGreaterThan(0); expect(pkm.moveset.length).toBeGreaterThan(0);
}); });
expect(game.scene.getModifiers(MapModifier).length).toBeGreaterThan(0); expect(game.scene.trainerItems.getStack(TrainerItemId.MAP)).toBe(1);
}); });
}); });

View File

@ -1,5 +1,4 @@
import { GameModes } from "#enums/game-modes"; import { GameModes } from "#enums/game-modes";
import { TurnHeldItemTransferModifier } from "#app/modifier/modifier";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BiomeId } from "#enums/biome-id"; import { BiomeId } from "#enums/biome-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
@ -7,6 +6,7 @@ import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
const FinalWave = { const FinalWave = {
Classic: 200, Classic: 200,
@ -93,9 +93,7 @@ describe("Final Boss", () => {
expect(eternatus.formIndex).toBe(1); expect(eternatus.formIndex).toBe(1);
expect(eternatus.bossSegments).toBe(5); expect(eternatus.bossSegments).toBe(5);
expect(eternatus.bossSegmentIndex).toBe(4); expect(eternatus.bossSegmentIndex).toBe(4);
const miniBlackHole = eternatus.getHeldItems().find(m => m instanceof TurnHeldItemTransferModifier); expect(eternatus.heldItemManager.getStack(HeldItemId.MINI_BLACK_HOLE)).toBe(1);
expect(miniBlackHole).toBeDefined();
expect(miniBlackHole?.stackCount).toBe(1);
}); });
it("should change form on status damage down to last boss fragment", async () => { it("should change form on status damage down to last boss fragment", async () => {
@ -136,8 +134,6 @@ describe("Final Boss", () => {
expect(eternatus.formIndex).toBe(1); expect(eternatus.formIndex).toBe(1);
expect(eternatus.bossSegments).toBe(5); expect(eternatus.bossSegments).toBe(5);
expect(eternatus.bossSegmentIndex).toBe(4); expect(eternatus.bossSegmentIndex).toBe(4);
const miniBlackHole = eternatus.getHeldItems().find(m => m instanceof TurnHeldItemTransferModifier); expect(eternatus.heldItemManager.getStack(HeldItemId.MINI_BLACK_HOLE)).toBe(1);
expect(miniBlackHole).toBeDefined();
expect(miniBlackHole?.stackCount).toBe(1);
}); });
}); });

View File

@ -6,6 +6,7 @@ import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("Items - Multi Lens", () => { describe("Items - Multi Lens", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -26,7 +27,7 @@ describe("Items - Multi Lens", () => {
game.override game.override
.moveset([MoveId.TACKLE, MoveId.TRAILBLAZE, MoveId.TACHYON_CUTTER, MoveId.FUTURE_SIGHT]) .moveset([MoveId.TACKLE, MoveId.TRAILBLAZE, MoveId.TACHYON_CUTTER, MoveId.FUTURE_SIGHT])
.ability(AbilityId.BALL_FETCH) .ability(AbilityId.BALL_FETCH)
.startingHeldItems([{ name: "MULTI_LENS" }]) .startingHeldItems([{ entry: HeldItemId.MULTI_LENS }])
.battleStyle("single") .battleStyle("single")
.criticalHits(false) .criticalHits(false)
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
@ -42,7 +43,7 @@ describe("Items - Multi Lens", () => {
])( ])(
"$stackCount count: should deal {$firstHitDamage}x damage on the first hit, then hit $stackCount times for 0.25x", "$stackCount count: should deal {$firstHitDamage}x damage on the first hit, then hit $stackCount times for 0.25x",
async ({ stackCount, firstHitDamage }) => { async ({ stackCount, firstHitDamage }) => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: stackCount }]); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS, count: stackCount }]);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]); await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
@ -116,7 +117,7 @@ describe("Items - Multi Lens", () => {
}); });
it("should enhance fixed-damage moves while also applying damage reduction", async () => { it("should enhance fixed-damage moves while also applying damage reduction", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]).moveset(MoveId.SEISMIC_TOSS); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS }]).moveset(MoveId.SEISMIC_TOSS);
await game.classicMode.startBattle([SpeciesId.MAGIKARP]); await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
@ -137,7 +138,7 @@ describe("Items - Multi Lens", () => {
it("should result in correct damage for hp% attacks with 1 lens", async () => { it("should result in correct damage for hp% attacks with 1 lens", async () => {
game.override game.override
.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]) .startingHeldItems([{ entry: HeldItemId.MULTI_LENS }])
.moveset(MoveId.SUPER_FANG) .moveset(MoveId.SUPER_FANG)
.ability(AbilityId.COMPOUND_EYES) .ability(AbilityId.COMPOUND_EYES)
.enemyLevel(1000) .enemyLevel(1000)
@ -155,7 +156,7 @@ describe("Items - Multi Lens", () => {
it("should result in correct damage for hp% attacks with 2 lenses", async () => { it("should result in correct damage for hp% attacks with 2 lenses", async () => {
game.override game.override
.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) .startingHeldItems([{ entry: HeldItemId.MULTI_LENS, count: 2 }])
.moveset(MoveId.SUPER_FANG) .moveset(MoveId.SUPER_FANG)
.ability(AbilityId.COMPOUND_EYES) .ability(AbilityId.COMPOUND_EYES)
.enemyMoveset(MoveId.SPLASH) .enemyMoveset(MoveId.SPLASH)
@ -174,7 +175,7 @@ describe("Items - Multi Lens", () => {
it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => { it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => {
game.override game.override
.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) .startingHeldItems([{ entry: HeldItemId.MULTI_LENS, count: 2 }])
.moveset(MoveId.SUPER_FANG) .moveset(MoveId.SUPER_FANG)
.ability(AbilityId.PARENTAL_BOND) .ability(AbilityId.PARENTAL_BOND)
.passiveAbility(AbilityId.COMPOUND_EYES) .passiveAbility(AbilityId.COMPOUND_EYES)

View File

@ -1,5 +1,5 @@
import { BattlerIndex } from "#enums/battler-index"; import { BattlerIndex } from "#enums/battler-index";
import { allMoves } from "#app/data/data-lists"; import { allHeldItems, allMoves } from "#app/data/data-lists";
import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
@ -8,6 +8,7 @@ import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id"; import { HeldItemId } from "#enums/held-item-id";
import type { InstantReviveHeldItem } from "#app/items/held-items/instant-revive";
describe("Items - Reviver Seed", () => { describe("Items - Reviver Seed", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -54,7 +55,7 @@ describe("Items - Reviver Seed", () => {
const player = game.scene.getPlayerPokemon()!; const player = game.scene.getPlayerPokemon()!;
player.damageAndUpdate(player.hp - 1); player.damageAndUpdate(player.hp - 1);
const reviverSeed = player.getHeldItems()[0] as PokemonInstantReviveModifier; const reviverSeed = allHeldItems[HeldItemId.REVIVER_SEED] as InstantReviveHeldItem;
vi.spyOn(reviverSeed, "apply"); vi.spyOn(reviverSeed, "apply");
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
@ -70,7 +71,7 @@ describe("Items - Reviver Seed", () => {
player.damageAndUpdate(player.hp - 1); player.damageAndUpdate(player.hp - 1);
player.addTag(BattlerTagType.CONFUSED, 3); player.addTag(BattlerTagType.CONFUSED, 3);
const reviverSeed = player.getHeldItems()[0] as PokemonInstantReviveModifier; const reviverSeed = allHeldItems[HeldItemId.REVIVER_SEED] as InstantReviveHeldItem;
vi.spyOn(reviverSeed, "apply"); vi.spyOn(reviverSeed, "apply");
vi.spyOn(player, "randBattleSeedInt").mockReturnValue(0); // Force confusion self-hit vi.spyOn(player, "randBattleSeedInt").mockReturnValue(0); // Force confusion self-hit
@ -122,8 +123,8 @@ describe("Items - Reviver Seed", () => {
const player = game.scene.getPlayerPokemon()!; const player = game.scene.getPlayerPokemon()!;
player.damageAndUpdate(player.hp - 1); player.damageAndUpdate(player.hp - 1);
const playerSeed = player.getHeldItems()[0] as PokemonInstantReviveModifier; const reviverSeed = allHeldItems[HeldItemId.REVIVER_SEED] as InstantReviveHeldItem;
vi.spyOn(playerSeed, "apply"); vi.spyOn(reviverSeed, "apply");
game.move.select(move); game.move.select(move);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");

View File

@ -10,6 +10,7 @@ import { UiMode } from "#enums/ui-mode";
import { Button } from "#app/enums/buttons"; import { Button } from "#app/enums/buttons";
import type RewardSelectUiHandler from "#app/ui/reward-select-ui-handler"; import type RewardSelectUiHandler from "#app/ui/reward-select-ui-handler";
import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target";
import { TrainerItemId } from "#enums/trainer-item-id";
describe("Items - Temporary Stat Stage Boosters", () => { describe("Items - Temporary Stat Stage Boosters", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -34,7 +35,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
.enemyMoveset(MoveId.SPLASH) .enemyMoveset(MoveId.SPLASH)
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.moveset([MoveId.TACKLE, MoveId.SPLASH, MoveId.HONE_CLAWS, MoveId.BELLY_DRUM]) .moveset([MoveId.TACKLE, MoveId.SPLASH, MoveId.HONE_CLAWS, MoveId.BELLY_DRUM])
.startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }]); .startingTrainerItems([{ entry: TrainerItemId.X_ATTACK }]);
}); });
it("should provide a x1.3 stat stage multiplier", async () => { it("should provide a x1.3 stat stage multiplier", async () => {
@ -52,7 +53,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
}); });
it("should increase existing ACC stat stage by 1 for X_ACCURACY only", async () => { it("should increase existing ACC stat stage by 1 for X_ACCURACY only", async () => {
game.override.startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]).ability(AbilityId.SIMPLE); game.override.startingTrainerItems([{ entry: TrainerItemId.X_ACCURACY }]).ability(AbilityId.SIMPLE);
await game.classicMode.startBattle([SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.PIKACHU]);
@ -94,10 +95,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
}); });
it("should not increase past maximum stat stage multiplier", async () => { it("should not increase past maximum stat stage multiplier", async () => {
game.override.startingModifier([ game.override.startingTrainerItems([{ entry: TrainerItemId.X_ATTACK }, { entry: TrainerItemId.X_ACCURACY }]);
{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC },
{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK },
]);
await game.classicMode.startBattle([SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.PIKACHU]);
@ -128,10 +126,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
await game.phaseInterceptor.to("BattleEndPhase"); await game.phaseInterceptor.to("BattleEndPhase");
const modifier = game.scene.findModifier( expect(game.scene.trainerItems.getStack(TrainerItemId.X_ATTACK)).toBe(4);
m => m instanceof TempStatStageBoosterModifier,
) as TempStatStageBoosterModifier;
expect(modifier.getBattleCount()).toBe(4);
// Forced X_ATTACK to spawn in the first slot with override // Forced X_ATTACK to spawn in the first slot with override
game.onNextPrompt( game.onNextPrompt(
@ -151,14 +146,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
await game.phaseInterceptor.to("TurnInitPhase"); await game.phaseInterceptor.to("TurnInitPhase");
// Making sure only one booster is in the modifier list even after picking up another // Making sure only one booster is in the modifier list even after picking up another
let count = 0;
for (const m of game.scene.modifiers) { expect(game.scene.trainerItems.getStack(TrainerItemId.X_ATTACK)).toBe(5);
if (m instanceof TempStatStageBoosterModifier) {
count++;
const modifierInstance = m as TempStatStageBoosterModifier;
expect(modifierInstance.getBattleCount()).toBe(modifierInstance.getMaxBattles());
}
}
expect(count).toBe(1);
}); });
}); });

View File

@ -1,5 +1,4 @@
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/data/data-lists"; import { modifierTypes } from "#app/data/data-lists";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import { NumberHolder, randInt } from "#app/utils/common"; import { NumberHolder, randInt } from "#app/utils/common";
@ -7,6 +6,7 @@ import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("Items - Thick Club", () => { describe("Items - Thick Club", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -29,7 +29,7 @@ describe("Items - Thick Club", () => {
}); });
it("THICK_CLUB activates in battle correctly", async () => { it("THICK_CLUB activates in battle correctly", async () => {
game.override.startingHeldItems([{ name: "RARE_SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]); game.override.startingHeldItems([{ entry: HeldItemId.THICK_CLUB }]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.classicMode.startBattle([SpeciesId.CUBONE]); await game.classicMode.startBattle([SpeciesId.CUBONE]);

View File

@ -4,6 +4,7 @@ import { BerryPhase } from "#app/phases/berry-phase";
import { MovePhase } from "#app/phases/move-phase"; import { MovePhase } from "#app/phases/move-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { HeldItemId } from "#enums/held-item-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
@ -87,7 +88,7 @@ describe("Moves - Beak Blast", () => {
}); });
it("should only hit twice with Multi-Lens", async () => { it("should only hit twice with Multi-Lens", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS }]);
await game.classicMode.startBattle([SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.BLASTOISE]);

View File

@ -10,6 +10,7 @@ import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Ceaseless Edge", () => { describe("Moves - Ceaseless Edge", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -61,7 +62,7 @@ describe("Moves - Ceaseless Edge", () => {
}); });
test("move should hit twice with multi lens and apply two layers of spikes", async () => { test("move should hit twice with multi lens and apply two layers of spikes", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS }]);
await game.classicMode.startBattle([SpeciesId.ILLUMISE]); await game.classicMode.startBattle([SpeciesId.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -83,7 +84,7 @@ describe("Moves - Ceaseless Edge", () => {
}); });
test("trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", async () => { test("trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS" }]).startingWave(25); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS }]).startingWave(25);
await game.classicMode.startBattle([SpeciesId.ILLUMISE]); await game.classicMode.startBattle([SpeciesId.ILLUMISE]);

View File

@ -10,7 +10,7 @@ import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { BattlerIndex } from "#enums/battler-index"; import { BattlerIndex } from "#enums/battler-index";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { PokemonInstantReviveModifier } from "#app/modifier/modifier"; import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Destiny Bond", () => { describe("Moves - Destiny Bond", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -232,7 +232,7 @@ describe("Moves - Destiny Bond", () => {
it("should not allow the opponent to revive via Reviver Seed", async () => { it("should not allow the opponent to revive via Reviver Seed", async () => {
const moveToUse = MoveId.TACKLE; const moveToUse = MoveId.TACKLE;
game.override.moveset(moveToUse).startingHeldItems([{ name: "REVIVER_SEED" }]); game.override.moveset(moveToUse).startingHeldItems([{ entry: HeldItemId.REVIVER_SEED }]);
await game.classicMode.startBattle(defaultParty); await game.classicMode.startBattle(defaultParty);
const enemyPokemon = game.scene.getEnemyPokemon(); const enemyPokemon = game.scene.getEnemyPokemon();
@ -246,9 +246,6 @@ describe("Moves - Destiny Bond", () => {
expect(playerPokemon?.isFainted()).toBe(true); expect(playerPokemon?.isFainted()).toBe(true);
// Check that the Tackle user's Reviver Seed did not activate // Check that the Tackle user's Reviver Seed did not activate
const revSeeds = game.scene expect(playerPokemon?.heldItemManager.getStack(HeldItemId.REVIVER_SEED)).toBe(1);
.getModifiers(PokemonInstantReviveModifier)
.filter(m => m.pokemonId === playerPokemon?.id);
expect(revSeeds.length).toBe(1);
}); });
}); });

View File

@ -10,6 +10,7 @@ import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Dragon Tail", () => { describe("Moves - Dragon Tail", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -162,7 +163,7 @@ describe("Moves - Dragon Tail", () => {
it("should not cause a softlock when activating an opponent trainer's reviver seed", async () => { it("should not cause a softlock when activating an opponent trainer's reviver seed", async () => {
game.override game.override
.startingWave(5) .startingWave(5)
.enemyHeldItems([{ name: "REVIVER_SEED" }]) .enemyHeldItems([{ entry: HeldItemId.REVIVER_SEED }])
.startingLevel(1000); // To make sure Dragon Tail KO's the opponent .startingLevel(1000); // To make sure Dragon Tail KO's the opponent
await game.classicMode.startBattle([SpeciesId.DRATINI]); await game.classicMode.startBattle([SpeciesId.DRATINI]);
@ -179,7 +180,7 @@ describe("Moves - Dragon Tail", () => {
it("should not cause a softlock when activating a player's reviver seed", async () => { it("should not cause a softlock when activating a player's reviver seed", async () => {
game.override game.override
.startingHeldItems([{ name: "REVIVER_SEED" }]) .startingHeldItems([{ entry: HeldItemId.REVIVER_SEED }])
.enemyMoveset(MoveId.DRAGON_TAIL) .enemyMoveset(MoveId.DRAGON_TAIL)
.enemyLevel(1000); // To make sure Dragon Tail KO's the player .enemyLevel(1000); // To make sure Dragon Tail KO's the player
await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.BULBASAUR]); await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.BULBASAUR]);

View File

@ -8,6 +8,7 @@ import { Stat } from "#enums/stat";
import { StatusEffect } from "#app/enums/status-effect"; import { StatusEffect } from "#app/enums/status-effect";
import { WeatherType } from "#app/enums/weather-type"; import { WeatherType } from "#app/enums/weather-type";
import { allMoves } from "#app/data/data-lists"; import { allMoves } from "#app/data/data-lists";
import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Fell Stinger", () => { describe("Moves - Fell Stinger", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -88,7 +89,7 @@ describe("Moves - Fell Stinger", () => {
}); });
it("should not grant stat boost if enemy is saved by Reviver Seed", async () => { it("should not grant stat boost if enemy is saved by Reviver Seed", async () => {
game.override.enemyAbility(AbilityId.BALL_FETCH).enemyHeldItems([{ name: "REVIVER_SEED" }]); game.override.enemyAbility(AbilityId.BALL_FETCH).enemyHeldItems([{ entry: HeldItemId.REVIVER_SEED }]);
await game.classicMode.startBattle([SpeciesId.LEAVANNY]); await game.classicMode.startBattle([SpeciesId.LEAVANNY]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;

View File

@ -164,7 +164,6 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
const enemyParty = game.scene.getEnemyParty(); const enemyParty = game.scene.getEnemyParty();
// Get rid of any modifiers that may alter power // Get rid of any modifiers that may alter power
game.scene.clearEnemyHeldItemModifiers();
game.scene.clearEnemyItems(); game.scene.clearEnemyItems();
// Mock stats by replacing entries in copy with desired values for specific stats // Mock stats by replacing entries in copy with desired values for specific stats
@ -218,7 +217,6 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
const enemyParty = game.scene.getEnemyParty(); const enemyParty = game.scene.getEnemyParty();
// Get rid of any modifiers that may alter power // Get rid of any modifiers that may alter power
game.scene.clearEnemyHeldItemModifiers();
game.scene.clearEnemyItems(); game.scene.clearEnemyItems();
// Mock stats by replacing entries in copy with desired values for specific stats // Mock stats by replacing entries in copy with desired values for specific stats

View File

@ -1,5 +1,6 @@
import { allMoves } from "#app/data/data-lists"; import { allMoves } from "#app/data/data-lists";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { HeldItemId } from "#enums/held-item-id";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager"; import GameManager from "#test/testUtils/gameManager";
@ -60,7 +61,7 @@ describe("Moves - Glaive Rush", () => {
}); });
it("interacts properly with multi-lens", async () => { it("interacts properly with multi-lens", async () => {
game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]).enemyMoveset([MoveId.AVALANCHE]); game.override.startingHeldItems([{ entry: HeldItemId.MULTI_LENS, count: 2 }]).enemyMoveset([MoveId.AVALANCHE]);
await game.classicMode.startBattle([SpeciesId.KLINK]); await game.classicMode.startBattle([SpeciesId.KLINK]);
const player = game.scene.getPlayerPokemon()!; const player = game.scene.getPlayerPokemon()!;

View File

@ -9,6 +9,7 @@ import { SpeciesId } from "#enums/species-id";
import { WeatherType } from "#enums/weather-type"; import { WeatherType } from "#enums/weather-type";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
// Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Heal_Block_(move) // Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Heal_Block_(move)
describe("Moves - Heal Block", () => { describe("Moves - Heal Block", () => {
@ -132,7 +133,7 @@ describe("Moves - Heal Block", () => {
}); });
it("should stop healing from items", async () => { it("should stop healing from items", async () => {
game.override.startingHeldItems([{ name: "LEFTOVERS" }]); game.override.startingHeldItems([{ entry: HeldItemId.LEFTOVERS }]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);

View File

@ -7,6 +7,7 @@ import { SpeciesId } from "#enums/species-id";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Safeguard", () => { describe("Moves - Safeguard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -113,7 +114,7 @@ describe("Moves - Safeguard", () => {
}); });
it("doesn't protect from self-inflicted status from Rest or Flame Orb", async () => { it("doesn't protect from self-inflicted status from Rest or Flame Orb", async () => {
game.override.enemyHeldItems([{ name: "FLAME_ORB" }]); game.override.enemyHeldItems([{ entry: HeldItemId.FLAME_ORB }]);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.hp = 1; enemyPokemon.hp = 1;

View File

@ -11,13 +11,13 @@ import { UiMode } from "#enums/ui-mode";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { BerryType } from "#enums/berry-type";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("Moves - Substitute", () => { describe("Moves - Substitute", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -296,7 +296,7 @@ describe("Moves - Substitute", () => {
}); });
it("should prevent the user's items from being stolen", async () => { it("should prevent the user's items from being stolen", async () => {
game.override.enemyMoveset(MoveId.THIEF).startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); game.override.enemyMoveset(MoveId.THIEF).startingHeldItems([{ entry: HeldItemId.SITRUS_BERRY }]);
vi.spyOn(allMoves[MoveId.THIEF], "attrs", "get").mockReturnValue([new StealHeldItemChanceAttr(1.0)]); // give Thief 100% steal rate vi.spyOn(allMoves[MoveId.THIEF], "attrs", "get").mockReturnValue([new StealHeldItemChanceAttr(1.0)]); // give Thief 100% steal rate
await game.classicMode.startBattle([SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.BLASTOISE]);
@ -313,7 +313,7 @@ describe("Moves - Substitute", () => {
}); });
it("should prevent the user's items from being removed", async () => { it("should prevent the user's items from being removed", async () => {
game.override.moveset([MoveId.KNOCK_OFF]).enemyHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); game.override.moveset([MoveId.KNOCK_OFF]).enemyHeldItems([{ entry: HeldItemId.SITRUS_BERRY }]);
await game.classicMode.startBattle([SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.BLASTOISE]);
@ -330,7 +330,7 @@ describe("Moves - Substitute", () => {
}); });
it("move effect should prevent the user's berries from being stolen and eaten", async () => { it("move effect should prevent the user's berries from being stolen and eaten", async () => {
game.override.enemyMoveset(MoveId.BUG_BITE).startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); game.override.enemyMoveset(MoveId.BUG_BITE).startingHeldItems([{ entry: HeldItemId.SITRUS_BERRY }]);
await game.classicMode.startBattle([SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.BLASTOISE]);

View File

@ -15,10 +15,10 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
import { getPokemonSpecies } from "#app/utils/pokemon-utils"; import { getPokemonSpecies } from "#app/utils/pokemon-utils";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { ShinyRateBoosterModifier } from "#app/modifier/modifier";
import { SelectRewardPhase } from "#app/phases/select-reward-phase"; import { SelectRewardPhase } from "#app/phases/select-reward-phase";
import i18next from "i18next"; import i18next from "i18next";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { TrainerItemId } from "#enums/trainer-item-id";
const namespace = "mysteryEncounters/anOfferYouCantRefuse"; const namespace = "mysteryEncounters/anOfferYouCantRefuse";
/** Gyarados for Indimidate */ /** Gyarados for Indimidate */
@ -144,10 +144,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, defaultParty);
await runMysteryEncounterToEnd(game, 1); await runMysteryEncounterToEnd(game, 1);
const itemModifier = scene.findModifier(m => m instanceof ShinyRateBoosterModifier) as ShinyRateBoosterModifier; expect(scene.trainerItems.getStack(TrainerItemId.SHINY_CHARM)).toBe(1);
expect(itemModifier).toBeDefined();
expect(itemModifier?.stackCount).toBe(1);
}); });
it("Should remove the Pokemon from the party", async () => { it("Should remove the Pokemon from the party", async () => {