More partial test fixes

This commit is contained in:
Wlowscha 2025-07-12 13:22:49 +02:00
parent ee2412cafb
commit 6fc7db8939
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
5 changed files with 26 additions and 77 deletions

View File

@ -35,7 +35,7 @@ import { Stat } from "#enums/stat";
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
import { MoveUseMode } from "#enums/move-use-mode";
import type { PokemonItemMap } from "#app/items/held-item-data-types";
import { HeldItemCategoryId } from "#enums/held-item-id";
import { HeldItemCategoryId, type HeldItemId } from "#enums/held-item-id";
/** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/uncommonBreed";
@ -213,7 +213,7 @@ export const UncommonBreedEncounter: MysteryEncounter = MysteryEncounterBuilder.
for (let i = 0; i < 4; i++) {
const index = randSeedInt(berryMap.length);
const randBerry = berryMap[index];
globalScene.getPokemonById(randBerry.pokemonId)?.heldItemManager.remove(randBerry.item.id);
globalScene.getPokemonById(randBerry.pokemonId)?.heldItemManager.remove(randBerry.item.id as HeldItemId);
stolenBerryMap.push(randBerry);
berryMap.splice(index, 1);
}

View File

@ -3,20 +3,13 @@ import * as BattleAnims from "#app/data/battle-anims";
import { TrashToTreasureEncounter } from "#app/data/mystery-encounters/encounters/trash-to-treasure-encounter";
import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters";
import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import {
type EnemyPartyConfig,
type EnemyPokemonConfig,
generateModifierType,
} from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import type { EnemyPartyConfig, EnemyPokemonConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { getPokemonSpecies } from "#app/utils/pokemon-utils";
import { BiomeId } from "#enums/biome-id";
import { MysteryEncounterType } from "#app/enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id";
import { PokemonMove } from "#app/data/moves/pokemon-move";
import { HealShopCostModifier, HitHealModifier, TurnHealModifier } from "#app/modifier/modifier";
import { RewardTier } from "#enums/reward-tier";
import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
import { modifierTypes } from "#app/data/data-lists";
import { CommandPhase } from "#app/phases/command-phase";
import { MovePhase } from "#app/phases/move-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
@ -33,6 +26,9 @@ import {
import GameManager from "#test/testUtils/gameManager";
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { HeldItemCategoryId, HeldItemId } from "#enums/held-item-id";
import { randSeedInt } from "#app/utils/common";
import { TrainerItemId } from "#enums/trainer-item-id";
const namespace = "mysteryEncounters/trashToTreasure";
const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA];
@ -101,41 +97,13 @@ describe("Trash to Treasure - Mystery Encounter", () => {
formIndex: 1, // Gmax
bossSegmentModifier: 1, // +1 Segment from normal
moveSet: [MoveId.GUNK_SHOT, MoveId.STOMPING_TANTRUM, MoveId.HAMMER_ARM, MoveId.PAYBACK],
modifierConfigs: [
{
modifier: generateModifierType(modifierTypes.BERRY) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.BERRY) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.BERRY) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.BERRY) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER) as PokemonHeldItemModifierType,
},
{
modifier: generateModifierType(modifierTypes.TOXIC_ORB) as PokemonHeldItemModifierType,
stackCount: Utils.randSeedInt(2, 0),
},
{
modifier: generateModifierType(modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType,
stackCount: Utils.randSeedInt(2, 1),
},
{
modifier: generateModifierType(modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType,
stackCount: Utils.randSeedInt(3, 1),
},
{
modifier: generateModifierType(modifierTypes.GOLDEN_EGG) as PokemonHeldItemModifierType,
stackCount: Utils.randSeedInt(2, 0),
},
heldItemConfig: [
{ entry: HeldItemCategoryId.BERRY, count: 4 },
{ entry: HeldItemCategoryId.BASE_STAT_BOOST, count: 2 },
{ entry: HeldItemId.TOXIC_ORB, count: randSeedInt(2, 0) },
{ entry: HeldItemId.SOOTHE_BELL, count: randSeedInt(2, 1) },
{ entry: HeldItemId.LUCKY_EGG, count: randSeedInt(3, 1) },
{ entry: HeldItemId.GOLDEN_EGG, count: randSeedInt(2, 0) },
],
};
const config: EnemyPartyConfig = {
@ -175,17 +143,11 @@ describe("Trash to Treasure - Mystery Encounter", () => {
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const leftovers = scene.findModifier(m => m instanceof TurnHealModifier) as TurnHealModifier;
expect(leftovers).toBeDefined();
expect(leftovers?.stackCount).toBe(2);
expect(scene.getPlayerParty()[0].heldItemManager.getStack(HeldItemId.LEFTOVERS)).toBe(2);
const shellBell = scene.findModifier(m => m instanceof HitHealModifier) as HitHealModifier;
expect(shellBell).toBeDefined();
expect(shellBell?.stackCount).toBe(1);
expect(scene.getPlayerParty()[0].heldItemManager.getStack(HeldItemId.SHELL_BELL)).toBe(1);
const blackSludge = scene.findModifier(m => m instanceof HealShopCostModifier) as HealShopCostModifier;
expect(blackSludge).toBeDefined();
expect(blackSludge?.stackCount).toBe(1);
expect(scene.trainerItems.getStack(TrainerItemId.BLACK_SLUDGE)).toBe(1);
});
it("should leave encounter without battle", async () => {

View File

@ -15,19 +15,16 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { CommandPhase } from "#app/phases/command-phase";
import { UncommonBreedEncounter } from "#app/data/mystery-encounters/encounters/uncommon-breed-encounter";
import { MovePhase } from "#app/phases/move-phase";
import { speciesEggMoves } from "#app/data/balance/egg-moves";
import { getPokemonSpecies } from "#app/utils/pokemon-utils";
import { BerryType } from "#enums/berry-type";
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
import { Stat } from "#enums/stat";
import type { BerryModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { HeldItemId } from "#enums/held-item-id";
const namespace = "mysteryEncounters/uncommonBreed";
const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA];
@ -184,11 +181,6 @@ describe("Uncommon Breed - Mystery Encounter", () => {
// TODO: there is some severe test flakiness occurring for this file, needs to be looked at/addressed in separate issue
it.skip("should NOT be selectable if the player doesn't have enough berries", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
// Clear out any pesky mods that slipped through test spin-up
scene.modifiers.forEach(mod => {
scene.removeModifier(mod);
});
await scene.updateItems(true);
await game.phaseInterceptor.to(MysteryEncounterPhase, false);
const encounterPhase = scene.phaseManager.getCurrentPhase();
@ -213,15 +205,9 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
// Berries on party lead
const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!;
const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier;
sitrusMod.stackCount = 2;
scene.addModifier(sitrusMod, true, false, false, true);
const ganlon = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON])!;
const ganlonMod = ganlon.newModifier(scene.getPlayerParty()[0]) as BerryModifier;
ganlonMod.stackCount = 3;
scene.addModifier(ganlonMod, true, false, false, true);
await scene.updateItems(true);
scene.getPlayerParty()[0].heldItemManager.add(HeldItemId.SITRUS_BERRY, 2);
scene.getPlayerParty()[0].heldItemManager.add(HeldItemId.GANLON_BERRY, 3);
scene.updateItems(true);
await runMysteryEncounterToEnd(game, 2);

View File

@ -17,6 +17,7 @@ import GameManager from "#test/testUtils/gameManager";
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { TrainerItemId } from "#enums/trainer-item-id";
describe("SelectModifierPhase", () => {
let phaserGame: Phaser.Game;
@ -110,7 +111,7 @@ describe("SelectModifierPhase", () => {
});
it.todo("should generate random modifiers of same tier for reroll with reroll lock", async () => {
game.override.startingModifier([{ name: "LOCK_CAPSULE" }]);
game.override.startingTrainerItems([{ entry: TrainerItemId.LOCK_CAPSULE }]);
await game.classicMode.startBattle([SpeciesId.ABRA, SpeciesId.VOLCARONA]);
scene.money = 1000000;
// Just use fully random seed for this test

View File

@ -1,4 +1,3 @@
import { BerryType } from "#app/enums/berry-type";
import { Button } from "#app/enums/buttons";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
@ -9,6 +8,7 @@ import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { HeldItemId } from "#enums/held-item-id";
describe("UI - Transfer Items", () => {
let phaserGame: Phaser.Game;
@ -31,9 +31,9 @@ describe("UI - Transfer Items", () => {
.startingLevel(100)
.startingWave(1)
.startingHeldItems([
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
{ name: "BERRY", count: 2, type: BerryType.APICOT },
{ name: "BERRY", count: 2, type: BerryType.LUM },
{ entry: HeldItemId.SITRUS_BERRY, count: 1 },
{ entry: HeldItemId.APICOT_BERRY, count: 2 },
{ entry: HeldItemId.LUM_BERRY, count: 2 },
])
.moveset([MoveId.DRAGON_CLAW])
.enemySpecies(SpeciesId.MAGIKARP)