Merge branch 'beta' into doTheAchievementShuffle

This commit is contained in:
damocleas 2025-08-19 21:02:38 -04:00 committed by GitHub
commit 4c5798e33c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
81 changed files with 591 additions and 849 deletions

@ -1 +1 @@
Subproject commit 17b353bd5752b7ce5c9e7051a17ec310e0b99c1e Subproject commit 813e5a34739100efd5936bc8a63301dfe451ff8d

View File

@ -674,10 +674,10 @@ export class SingleGenerationChallenge extends Challenge {
getDescription(overrideValue: number = this.value): string { getDescription(overrideValue: number = this.value): string {
if (overrideValue === 0) { if (overrideValue === 0) {
return i18next.t("challenges:singleGeneration.desc_default"); return i18next.t("challenges:singleGeneration.descDefault");
} }
return i18next.t("challenges:singleGeneration.desc", { return i18next.t("challenges:singleGeneration.desc", {
gen: i18next.t(`challenges:singleGeneration.gen_${overrideValue}`), gen: i18next.t(`challenges:singleGeneration.gen.${overrideValue}`),
}); });
} }
@ -758,7 +758,7 @@ export class SingleTypeChallenge extends Challenge {
getDescription(overrideValue: number = this.value): string { getDescription(overrideValue: number = this.value): string {
const type = i18next.t(`pokemonInfo:type.${toCamelCase(PokemonType[overrideValue - 1])}`); const type = i18next.t(`pokemonInfo:type.${toCamelCase(PokemonType[overrideValue - 1])}`);
const typeColor = `[color=${TypeColor[PokemonType[overrideValue - 1]]}][shadow=${TypeShadow[PokemonType[this.value - 1]]}]${type}[/shadow][/color]`; const typeColor = `[color=${TypeColor[PokemonType[overrideValue - 1]]}][shadow=${TypeShadow[PokemonType[this.value - 1]]}]${type}[/shadow][/color]`;
const defaultDesc = i18next.t("challenges:singleType.desc_default"); const defaultDesc = i18next.t("challenges:singleType.descDefault");
const typeDesc = i18next.t("challenges:singleType.desc", { const typeDesc = i18next.t("challenges:singleType.desc", {
type: typeColor, type: typeColor,
}); });

View File

@ -514,7 +514,7 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = MysteryEncounterBuilde
function getTrainerConfigForWave(waveIndex: number) { function getTrainerConfigForWave(waveIndex: number) {
// Bug type superfan trainer config // Bug type superfan trainer config
const config = trainerConfigs[TrainerType.BUG_TYPE_SUPERFAN].clone(); const config = trainerConfigs[TrainerType.BUG_TYPE_SUPERFAN].clone();
config.name = i18next.t("trainerNames:bug_type_superfan"); config.name = i18next.t("trainerNames:bugTypeSuperfan");
let pool3Copy = POOL_3_POKEMON.slice(0); let pool3Copy = POOL_3_POKEMON.slice(0);
pool3Copy = randSeedShuffle(pool3Copy); pool3Copy = randSeedShuffle(pool3Copy);

View File

@ -33,7 +33,7 @@ import i18next from "i18next";
/** the i18n namespace for the encounter */ /** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/theExpertPokemonBreeder"; const namespace = "mysteryEncounters/theExpertPokemonBreeder";
const trainerNameKey = "trainerNames:expert_pokemon_breeder"; const trainerNameKey = "trainerNames:expertPokemonBreeder";
const FIRST_STAGE_EVOLUTION_WAVE = 45; const FIRST_STAGE_EVOLUTION_WAVE = 45;
const SECOND_STAGE_EVOLUTION_WAVE = 60; const SECOND_STAGE_EVOLUTION_WAVE = 60;

View File

@ -100,7 +100,7 @@ const commonSplashMessages = [
"liveWoChienReaction", "liveWoChienReaction",
"itsAFeatureNotABug", "itsAFeatureNotABug",
"theEggsAreNotForEating", "theEggsAreNotForEating",
"7.8outOf10TooManyWaterBiomes", "tooManyWaterBiomes",
"butNothingHappened", "butNothingHappened",
"thePowerOfScienceIsAmazing", "thePowerOfScienceIsAmazing",
"freeToPlay", "freeToPlay",
@ -152,7 +152,7 @@ const commonSplashMessages = [
"insertTextHere", "insertTextHere",
"endingEndlessNotFound", "endingEndlessNotFound",
"iLikeMyEggsVouchered", "iLikeMyEggsVouchered",
"YOU", "you",
"noAddedSugar", "noAddedSugar",
"notSponsored", "notSponsored",
"notRated", "notRated",

View File

@ -43,7 +43,7 @@ import type {
} from "#types/trainer-funcs"; } from "#types/trainer-funcs";
import { coerceArray, isNullOrUndefined, randSeedInt, randSeedIntRange, randSeedItem } from "#utils/common"; import { coerceArray, isNullOrUndefined, randSeedInt, randSeedIntRange, randSeedItem } from "#utils/common";
import { getPokemonSpecies } from "#utils/pokemon-utils"; import { getPokemonSpecies } from "#utils/pokemon-utils";
import { toSnakeCase, toTitleCase } from "#utils/strings"; import { toCamelCase, toTitleCase } from "#utils/strings";
import i18next from "i18next"; import i18next from "i18next";
/** Minimum BST for Pokemon generated onto the Elite Four's teams */ /** Minimum BST for Pokemon generated onto the Elite Four's teams */
@ -193,8 +193,7 @@ export class TrainerConfig {
initI18n(); initI18n();
} }
// Make the title lowercase and replace spaces with underscores title = toCamelCase(title);
title = title.toLowerCase().replace(/\s/g, "_");
// Get the title from the i18n file // Get the title from the i18n file
this.title = i18next.t(`titles:${title}`); this.title = i18next.t(`titles:${title}`);
@ -288,7 +287,7 @@ export class TrainerConfig {
initI18n(); initI18n();
} }
// Set the localized name for the female rival. // Set the localized name for the female rival.
this.nameFemale = i18next.t("trainerNames:rival_female"); this.nameFemale = i18next.t("trainerNames:rivalFemale");
} else { } else {
// Otherwise, assign the provided female name. // Otherwise, assign the provided female name.
this.nameFemale = nameFemale!; // TODO: is this bang correct? this.nameFemale = nameFemale!; // TODO: is this bang correct?
@ -365,8 +364,7 @@ export class TrainerConfig {
initI18n(); initI18n();
} }
// Make the title lowercase and replace spaces with underscores titleDouble = toCamelCase(titleDouble);
titleDouble = titleDouble.toLowerCase().replace(/\s/g, "_");
// Get the title from the i18n file // Get the title from the i18n file
this.titleDouble = i18next.t(`titles:${titleDouble}`); this.titleDouble = i18next.t(`titles:${titleDouble}`);
@ -552,7 +550,7 @@ export class TrainerConfig {
this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool))); this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool)));
}); });
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
this.setHasVoucher(false); this.setHasVoucher(false);
this.setTitle(title); this.setTitle(title);
@ -577,7 +575,7 @@ export class TrainerConfig {
this.setPartyTemplates(trainerPartyTemplates.ELITE_FOUR); this.setPartyTemplates(trainerPartyTemplates.ELITE_FOUR);
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
this.setMoneyMultiplier(2); this.setMoneyMultiplier(2);
this.setBoss(); this.setBoss();
@ -618,7 +616,7 @@ export class TrainerConfig {
this.setSpeciesFilter(p => p.isOfType(specialtyType)); this.setSpeciesFilter(p => p.isOfType(specialtyType));
this.setSpecialtyType(specialtyType); this.setSpecialtyType(specialtyType);
} }
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
this.setTitle(title); this.setTitle(title);
this.setMoneyMultiplier(2.5); this.setMoneyMultiplier(2.5);
@ -665,14 +663,14 @@ export class TrainerConfig {
this.setSpeciesFilter(p => p.isOfType(specialtyType)); this.setSpeciesFilter(p => p.isOfType(specialtyType));
this.setSpecialtyType(specialtyType); this.setSpecialtyType(specialtyType);
// Localize the trainer's name by converting it to lowercase and replacing spaces with underscores. // Localize the trainer's name by converting it to camel case.
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
// Set the title to "gym_leader". (this is the key in the i18n file) // Set the title to "gymLeader". (this is the key in the i18n file)
this.setTitle("gym_leader"); this.setTitle("gymLeader");
if (!isMale) { if (!isMale) {
this.setTitle("gym_leader_female"); this.setTitle("gymLeaderFemale");
} }
// Configure various properties for the Gym Leader. // Configure various properties for the Gym Leader.
@ -726,14 +724,14 @@ export class TrainerConfig {
this.setSpeciesFilter(p => p.baseTotal >= ELITE_FOUR_MINIMUM_BST); this.setSpeciesFilter(p => p.baseTotal >= ELITE_FOUR_MINIMUM_BST);
} }
// Localize the trainer's name by converting it to lowercase and replacing spaces with underscores. // Localize the trainer's name by converting it to camel case.
const nameForCall = toSnakeCase(this.name); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
// Set the title to "elite_four". (this is the key in the i18n file) // Set the title to "elite_four". (this is the key in the i18n file)
this.setTitle("elite_four"); this.setTitle("eliteFour");
if (!isMale) { if (!isMale) {
this.setTitle("elite_four_female"); this.setTitle("eliteFourFemale");
} }
// Configure various properties for the Elite Four member. // Configure various properties for the Elite Four member.
@ -763,14 +761,14 @@ export class TrainerConfig {
// Set the party templates for the Champion. // Set the party templates for the Champion.
this.setPartyTemplates(trainerPartyTemplates.CHAMPION); this.setPartyTemplates(trainerPartyTemplates.CHAMPION);
// Localize the trainer's name by converting it to lowercase and replacing spaces with underscores. // Localize the trainer's name by converting it to camel case.
const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); const nameForCall = toCamelCase(this.name);
this.name = i18next.t(`trainerNames:${nameForCall}`); this.name = i18next.t(`trainerNames:${nameForCall}`);
// Set the title to "champion". (this is the key in the i18n file) // Set the title to "champion". (this is the key in the i18n file)
this.setTitle("champion"); this.setTitle("champion");
if (!isMale) { if (!isMale) {
this.setTitle("champion_female"); this.setTitle("championFemale");
} }
// Configure various properties for the Champion. // Configure various properties for the Champion.
@ -794,7 +792,7 @@ export class TrainerConfig {
if (!getIsInitialized()) { if (!getIsInitialized()) {
initI18n(); initI18n();
} }
this.name = i18next.t(`trainerNames:${name.toLowerCase().replace(/\s/g, "_")}`); this.name = i18next.t(`trainerNames:${toCamelCase(name)}`);
return this; return this;
} }
@ -830,9 +828,9 @@ export class TrainerConfig {
initI18n(); initI18n();
} }
// Check if the female version exists in the i18n file // Check if the female version exists in the i18n file
if (i18next.exists(`trainerClasses:${this.name.toLowerCase()}`)) { if (i18next.exists(`trainerClasses:${toCamelCase(this.name)}Female`)) {
// If it does, return // If it does, return
return ret + "_female"; return ret + "Female";
} }
} }
} }

View File

@ -5708,7 +5708,11 @@ export class PlayerPokemon extends Pokemon {
} }
if (!dataSource) { if (!dataSource) {
if (globalScene.gameMode.isDaily) { if (
globalScene.gameMode.isDaily ||
// Keldeo is excluded due to crashes involving its signature move and the associated form change
(Overrides.STARTER_SPECIES_OVERRIDE && Overrides.STARTER_SPECIES_OVERRIDE !== SpeciesId.KELDEO)
) {
this.generateAndPopulateMoveset(); this.generateAndPopulateMoveset();
} else { } else {
this.moveset = []; this.moveset = [];

View File

@ -23,7 +23,7 @@ import {
} from "#trainers/trainer-party-template"; } from "#trainers/trainer-party-template";
import { randSeedInt, randSeedItem, randSeedWeightedItem } from "#utils/common"; import { randSeedInt, randSeedItem, randSeedWeightedItem } from "#utils/common";
import { getPokemonSpecies } from "#utils/pokemon-utils"; import { getPokemonSpecies } from "#utils/pokemon-utils";
import { toSnakeCase } from "#utils/strings"; import { toCamelCase } from "#utils/strings";
import i18next from "i18next"; import i18next from "i18next";
export class Trainer extends Phaser.GameObjects.Container { export class Trainer extends Phaser.GameObjects.Container {
@ -170,7 +170,7 @@ export class Trainer extends Phaser.GameObjects.Container {
const evilTeamTitles = ["grunt"]; const evilTeamTitles = ["grunt"];
if (this.name === "" && evilTeamTitles.some(t => name.toLocaleLowerCase().includes(t))) { if (this.name === "" && evilTeamTitles.some(t => name.toLocaleLowerCase().includes(t))) {
// This is a evil team grunt so we localize it by only using the "name" as the title // This is a evil team grunt so we localize it by only using the "name" as the title
title = i18next.t(`trainerClasses:${toSnakeCase(name)}`); title = i18next.t(`trainerClasses:${toCamelCase(name)}`);
console.log("Localized grunt name: " + title); console.log("Localized grunt name: " + title);
// Since grunts are not named we can just return the title // Since grunts are not named we can just return the title
return title; return title;
@ -187,7 +187,7 @@ export class Trainer extends Phaser.GameObjects.Container {
} }
// Get the localized trainer class name from the i18n file and set it as the title. // Get the localized trainer class name from the i18n file and set it as the title.
// This is used for trainer class names, not titles like "Elite Four, Champion, etc." // This is used for trainer class names, not titles like "Elite Four, Champion, etc."
title = i18next.t(`trainerClasses:${toSnakeCase(name)}`); title = i18next.t(`trainerClasses:${toCamelCase(name)}`);
} }
// If no specific trainer slot is set. // If no specific trainer slot is set.
@ -208,7 +208,7 @@ export class Trainer extends Phaser.GameObjects.Container {
if (this.config.titleDouble && this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) { if (this.config.titleDouble && this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) {
title = this.config.titleDouble; title = this.config.titleDouble;
name = i18next.t(`trainerNames:${toSnakeCase(this.config.nameDouble)}`); name = i18next.t(`trainerNames:${toCamelCase(this.config.nameDouble)}`);
} }
console.log(title ? `${title} ${name}` : name); console.log(title ? `${title} ${name}` : name);

View File

@ -78,15 +78,19 @@ class DefaultOverrides {
readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null; readonly ARENA_TINT_OVERRIDE: TimeOfDay | null = null;
/** Multiplies XP gained by this value including 0. Set to null to ignore the override. */ /** Multiplies XP gained by this value including 0. Set to null to ignore the override. */
readonly XP_MULTIPLIER_OVERRIDE: number | null = null; readonly XP_MULTIPLIER_OVERRIDE: number | null = null;
/** Sets the level cap to this number during experience gain calculations. Set to `0` to disable override & use normal wave-based level caps, /**
or any negative number to set it to 9 quadrillion (effectively disabling it). */ * Sets the level cap to this number during experience gain calculations.
*
* Set to `0` to disable override & use normal wave-based level caps,
* or any negative number to disable level caps entirely.
*/
readonly LEVEL_CAP_OVERRIDE: number = 0; readonly LEVEL_CAP_OVERRIDE: number = 0;
/** /**
* If defined, overrides random critical hit rolls to always or never succeed. * If defined, overrides random critical hit rolls to always or never succeed.
* Ignored if the move is guaranteed to always/never crit. * Ignored if the move is guaranteed to always/never crit.
*/ */
readonly CRITICAL_HIT_OVERRIDE: boolean | null = null; readonly CRITICAL_HIT_OVERRIDE: boolean | null = null;
/** default 1000 */ /** @defaultValue `1000` */
readonly STARTING_MONEY_OVERRIDE: number = 0; readonly STARTING_MONEY_OVERRIDE: number = 0;
/** Sets all shop item prices to 0 */ /** Sets all shop item prices to 0 */
readonly WAIVE_SHOP_FEES_OVERRIDE: boolean = false; readonly WAIVE_SHOP_FEES_OVERRIDE: boolean = false;
@ -130,8 +134,8 @@ class DefaultOverrides {
// PLAYER OVERRIDES // PLAYER OVERRIDES
// ---------------- // ----------------
/** /**
* Set the form index of any starter in the party whose `speciesId` is inside this override * Set the form index of any starter in the party whose {@linkcode SpeciesId} is inside this override
* @see {@link allSpecies} in `src/data/pokemon-species.ts` for form indexes * @see `src/data/pokemon-species.ts` for form indexes
* @example * @example
* ``` * ```
* const STARTER_FORM_OVERRIDES = { * const STARTER_FORM_OVERRIDES = {
@ -141,23 +145,14 @@ class DefaultOverrides {
*/ */
readonly STARTER_FORM_OVERRIDES: Partial<Record<SpeciesId, number>> = {}; readonly STARTER_FORM_OVERRIDES: Partial<Record<SpeciesId, number>> = {};
/** default 5 or 20 for Daily */ /** @defaultValue `20` for Daily and `5` for all other modes */
readonly STARTING_LEVEL_OVERRIDE: number = 0; readonly STARTING_LEVEL_OVERRIDE: number = 0;
/** /** Will override the species of your pokemon when starting a new run */
* SPECIES OVERRIDE readonly STARTER_SPECIES_OVERRIDE: SpeciesId | 0 = 0;
* will only apply to the first starter in your party or each enemy pokemon /** This will force your starter to be a random fusion */
* default is 0 to not override
* @example SPECIES_OVERRIDE = SpeciesId.Bulbasaur;
*/
readonly STARTER_SPECIES_OVERRIDE: SpeciesId | number = 0;
/**
* This will force your starter to be a random fusion
*/
readonly STARTER_FUSION_OVERRIDE: boolean = false; readonly STARTER_FUSION_OVERRIDE: boolean = false;
/** /** This will override the species of the fusion */
* This will override the species of the fusion readonly STARTER_FUSION_SPECIES_OVERRIDE: SpeciesId | 0 = 0;
*/
readonly STARTER_FUSION_SPECIES_OVERRIDE: SpeciesId | number = 0;
readonly ABILITY_OVERRIDE: AbilityId = AbilityId.NONE; readonly ABILITY_OVERRIDE: AbilityId = AbilityId.NONE;
readonly PASSIVE_ABILITY_OVERRIDE: AbilityId = AbilityId.NONE; readonly PASSIVE_ABILITY_OVERRIDE: AbilityId = AbilityId.NONE;
readonly HAS_PASSIVE_ABILITY_OVERRIDE: boolean | null = null; readonly HAS_PASSIVE_ABILITY_OVERRIDE: boolean | null = null;
@ -180,13 +175,9 @@ class DefaultOverrides {
// OPPONENT / ENEMY OVERRIDES // OPPONENT / ENEMY OVERRIDES
// -------------------------- // --------------------------
readonly ENEMY_SPECIES_OVERRIDE: SpeciesId | number = 0; readonly ENEMY_SPECIES_OVERRIDE: SpeciesId | number = 0;
/** /** This will make all enemies fused Pokemon */
* This will make all opponents fused Pokemon
*/
readonly ENEMY_FUSION_OVERRIDE: boolean = false; readonly ENEMY_FUSION_OVERRIDE: boolean = false;
/** /** This will override the species of the fusion only when the enemy is already a fusion */
* This will override the species of the fusion only when the opponent is already a fusion
*/
readonly ENEMY_FUSION_SPECIES_OVERRIDE: SpeciesId | number = 0; readonly ENEMY_FUSION_SPECIES_OVERRIDE: SpeciesId | number = 0;
readonly ENEMY_LEVEL_OVERRIDE: number = 0; readonly ENEMY_LEVEL_OVERRIDE: number = 0;
readonly ENEMY_ABILITY_OVERRIDE: AbilityId = AbilityId.NONE; readonly ENEMY_ABILITY_OVERRIDE: AbilityId = AbilityId.NONE;
@ -197,6 +188,7 @@ class DefaultOverrides {
readonly ENEMY_MOVESET_OVERRIDE: MoveId | Array<MoveId> = []; readonly ENEMY_MOVESET_OVERRIDE: MoveId | Array<MoveId> = [];
readonly ENEMY_SHINY_OVERRIDE: boolean | null = null; readonly ENEMY_SHINY_OVERRIDE: boolean | null = null;
readonly ENEMY_VARIANT_OVERRIDE: Variant | null = null; readonly ENEMY_VARIANT_OVERRIDE: Variant | null = null;
/** /**
* Overrides the IVs of enemy pokemon. Values must never be outside the range `0` to `31`! * Overrides the IVs of enemy pokemon. Values must never be outside the range `0` to `31`!
* - If set to a number between `0` and `31`, set all IVs of all enemy pokemon to that number. * - If set to a number between `0` and `31`, set all IVs of all enemy pokemon to that number.
@ -210,9 +202,9 @@ class DefaultOverrides {
/** /**
* Override to give the enemy Pokemon a given amount of health segments * Override to give the enemy Pokemon a given amount of health segments
* *
* 0 (default): the health segments will be handled normally based on wave, level and species * - `0` (default): the health segments will be handled normally based on wave, level and species
* 1: the Pokemon will have a single health segment and therefore will not be a boss * - `1`: the Pokemon will have a single health segment and therefore will not be a boss
* 2+: the Pokemon will be a boss with the given number of health segments * - `2+`: the Pokemon will be a boss with the given number of health segments
*/ */
readonly ENEMY_HEALTH_SEGMENTS_OVERRIDE: number = 0; readonly ENEMY_HEALTH_SEGMENTS_OVERRIDE: number = 0;
@ -293,9 +285,7 @@ class DefaultOverrides {
*/ */
readonly ITEM_REWARD_OVERRIDE: ModifierOverride[] = []; readonly ITEM_REWARD_OVERRIDE: ModifierOverride[] = [];
/** /** If `true`, disable all non-scripted opponent trainer encounters. */
* If `true`, disable all non-scripted opponent trainer encounters.
*/
readonly DISABLE_STANDARD_TRAINERS_OVERRIDE: boolean = false; readonly DISABLE_STANDARD_TRAINERS_OVERRIDE: boolean = false;
/** /**

View File

@ -2,8 +2,10 @@ import { globalScene } from "#app/global-scene";
import type { PhaseMap, PhaseString } from "#types/phase-types"; import type { PhaseMap, PhaseString } from "#types/phase-types";
export abstract class Phase { export abstract class Phase {
/** Start the current phase. */
start() {} start() {}
/** End the current phase and start a new one. */
end() { end() {
globalScene.phaseManager.shiftPhase(); globalScene.phaseManager.shiftPhase();
} }

View File

@ -474,20 +474,21 @@ export class CommandPhase extends FieldPhase {
} }
if (trappedAbMessages.length > 0) { if (trappedAbMessages.length > 0) {
if (isSwitch) { if (isSwitch) {
globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
globalScene.ui.showText(
trappedAbMessages[0],
null,
() => {
globalScene.ui.showText("", 0);
if (isSwitch) {
globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex);
}
},
null,
true,
);
});
} }
globalScene.ui.showText(
trappedAbMessages[0],
null,
() => {
globalScene.ui.showText("", 0);
if (isSwitch) {
globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex);
}
},
null,
true,
);
} else { } else {
const trapTag = playerPokemon.getTag(TrappedTag); const trapTag = playerPokemon.getTag(TrappedTag);
const fairyLockTag = globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER); const fairyLockTag = globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER);

View File

@ -120,18 +120,24 @@ export class GameOverPhase extends BattlePhase {
*/ */
private awardRibbons(): void { private awardRibbons(): void {
let ribbonFlags = 0n; let ribbonFlags = 0n;
if (globalScene.gameMode.isClassic) {
ribbonFlags |= RibbonData.CLASSIC;
}
if (isNuzlockeChallenge()) {
ribbonFlags |= RibbonData.NUZLOCKE;
}
for (const challenge of globalScene.gameMode.challenges) { for (const challenge of globalScene.gameMode.challenges) {
const ribbon = challenge.ribbonAwarded; const ribbon = challenge.ribbonAwarded;
if (challenge.value && ribbon) { if (challenge.value && ribbon) {
ribbonFlags |= ribbon; ribbonFlags |= ribbon;
} }
} }
// Block other ribbons if flip stats or inverse is active
const flip_or_inverse = ribbonFlags & (RibbonData.FLIP_STATS | RibbonData.INVERSE);
if (flip_or_inverse) {
ribbonFlags = flip_or_inverse;
} else {
if (globalScene.gameMode.isClassic) {
ribbonFlags |= RibbonData.CLASSIC;
}
if (isNuzlockeChallenge()) {
ribbonFlags |= RibbonData.NUZLOCKE;
}
}
// Award ribbons to all Pokémon in the player's party that are considered valid // Award ribbons to all Pokémon in the player's party that are considered valid
// for the current game mode and challenges. // for the current game mode and challenges.
for (const pokemon of globalScene.getPlayerParty()) { for (const pokemon of globalScene.getPlayerParty()) {

View File

@ -197,35 +197,35 @@ export const Setting: Array<Setting> = [
options: [ options: [
{ {
value: "1", value: "1",
label: i18next.t("settings:gameSpeed1x"), label: i18next.t("settings:gameSpeed100x"),
}, },
{ {
value: "1.25", value: "1.25",
label: i18next.t("settings:gameSpeed1_25x"), label: i18next.t("settings:gameSpeed125x"),
}, },
{ {
value: "1.5", value: "1.5",
label: i18next.t("settings:gameSpeed1_5x"), label: i18next.t("settings:gameSpeed150x"),
}, },
{ {
value: "2", value: "2",
label: i18next.t("settings:gameSpeed2x"), label: i18next.t("settings:gameSpeed200x"),
}, },
{ {
value: "2.5", value: "2.5",
label: i18next.t("settings:gameSpeed2_5x"), label: i18next.t("settings:gameSpeed250x"),
}, },
{ {
value: "3", value: "3",
label: i18next.t("settings:gameSpeed3x"), label: i18next.t("settings:gameSpeed300x"),
}, },
{ {
value: "4", value: "4",
label: i18next.t("settings:gameSpeed4x"), label: i18next.t("settings:gameSpeed400x"),
}, },
{ {
value: "5", value: "5",
label: i18next.t("settings:gameSpeed5x"), label: i18next.t("settings:gameSpeed500x"),
}, },
], ],
default: 3, default: 3,
@ -566,7 +566,7 @@ export const Setting: Array<Setting> = [
}, },
{ {
value: "Back", value: "Back",
label: i18next.t("settings:timeOfDay_back"), label: i18next.t("settings:timeOfDayBack"),
}, },
], ],
default: 0, default: 0,

View File

@ -308,8 +308,8 @@ export class GameStatsUiHandler extends UiHandler {
private getUsername(): string { private getUsername(): string {
const usernameReplacement = const usernameReplacement =
globalScene.gameData.gender === PlayerGender.FEMALE globalScene.gameData.gender === PlayerGender.FEMALE
? i18next.t("trainerNames:player_f") ? i18next.t("trainerNames:playerF")
: i18next.t("trainerNames:player_m"); : i18next.t("trainerNames:playerM");
const displayName = !globalScene.hideUsername const displayName = !globalScene.hideUsername
? (loggedInUser?.username ?? i18next.t("common:guest")) ? (loggedInUser?.username ?? i18next.t("common:guest"))

View File

@ -640,7 +640,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
this.optionSelectText = addBBCodeTextObject( this.optionSelectText = addBBCodeTextObject(
0, 0,
0, 0,
this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`).join("\n"), this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${toCamelCase(`menu${MenuOptions[o]}`)}`)}`).join("\n"),
TextStyle.WINDOW, TextStyle.WINDOW,
{ maxLines: this.menuOptions.length, lineSpacing: 12 }, { maxLines: this.menuOptions.length, lineSpacing: 12 },
); );
@ -757,7 +757,7 @@ export class PokedexPageUiHandler extends MessageUiHandler {
return this.menuOptions return this.menuOptions
.map(o => { .map(o => {
const label = `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`; const label = i18next.t(`pokedexUiHandler:${toCamelCase(`menu${MenuOptions[o]}`)}`);
const isDark = const isDark =
!isSeen || !isSeen ||
(!isStarterCaught && (o === MenuOptions.TOGGLE_IVS || o === MenuOptions.NATURES)) || (!isStarterCaught && (o === MenuOptions.TOGGLE_IVS || o === MenuOptions.NATURES)) ||

View File

@ -5,7 +5,7 @@ import type { ModalConfig } from "./modal-ui-handler";
export class RenameRunFormUiHandler extends FormModalUiHandler { export class RenameRunFormUiHandler extends FormModalUiHandler {
getModalTitle(_config?: ModalConfig): string { getModalTitle(_config?: ModalConfig): string {
return i18next.t("menu:renamerun"); return i18next.t("menu:renameRun");
} }
getWidth(_config?: ModalConfig): number { getWidth(_config?: ModalConfig): number {

View File

@ -337,7 +337,7 @@ class RunEntryContainer extends Phaser.GameObjects.Container {
// Because of the interesting mechanics behind rival names, the rival name and title have to be retrieved differently // Because of the interesting mechanics behind rival names, the rival name and title have to be retrieved differently
const RIVAL_TRAINER_ID_THRESHOLD = 375; const RIVAL_TRAINER_ID_THRESHOLD = 375;
if (data.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) { if (data.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) {
const rivalName = tObj.variant === TrainerVariant.FEMALE ? "trainerNames:rival_female" : "trainerNames:rival"; const rivalName = tObj.variant === TrainerVariant.FEMALE ? "trainerNames:rivalFemale" : "trainerNames:rival";
const gameOutcomeLabel = addTextObject( const gameOutcomeLabel = addTextObject(
8, 8,
5, 5,

View File

@ -337,7 +337,7 @@ export class RunInfoUiHandler extends UiHandler {
if (this.runInfo.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) { if (this.runInfo.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) {
trainerName = trainerName =
trainerObj.variant === TrainerVariant.FEMALE trainerObj.variant === TrainerVariant.FEMALE
? i18next.t("trainerNames:rival_female") ? i18next.t("trainerNames:rivalFemale")
: i18next.t("trainerNames:rival"); : i18next.t("trainerNames:rival");
} else { } else {
trainerName = trainerObj.getName(0, true); trainerName = trainerObj.getName(0, true);
@ -805,7 +805,7 @@ export class RunInfoUiHandler extends UiHandler {
const spdef = i18next.t("pokemonInfo:stat.spdefShortened") + ": " + pStats[4]; const spdef = i18next.t("pokemonInfo:stat.spdefShortened") + ": " + pStats[4];
const speedLabel = const speedLabel =
currentLanguage === "es-ES" || currentLanguage === "pt_BR" currentLanguage === "es-ES" || currentLanguage === "pt_BR"
? i18next.t("runHistory:SPDshortened") ? i18next.t("runHistory:spdShortened")
: i18next.t("pokemonInfo:stat.spdShortened"); : i18next.t("pokemonInfo:stat.spdShortened");
const speed = speedLabel + ": " + pStats[5]; const speed = speedLabel + ": " + pStats[5];
// Column 1: HP Atk Def // Column 1: HP Atk Def

View File

@ -808,8 +808,8 @@ export class SummaryUiHandler extends UiHandler {
globalScene.gameData.gender === PlayerGender.FEMALE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE; globalScene.gameData.gender === PlayerGender.FEMALE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE;
const usernameReplacement = const usernameReplacement =
globalScene.gameData.gender === PlayerGender.FEMALE globalScene.gameData.gender === PlayerGender.FEMALE
? i18next.t("trainerNames:player_f") ? i18next.t("trainerNames:playerF")
: i18next.t("trainerNames:player_m"); : i18next.t("trainerNames:playerM");
// TODO: should add field for original trainer name to Pokemon object, to support gift/traded Pokemon from MEs // TODO: should add field for original trainer name to Pokemon object, to support gift/traded Pokemon from MEs
const trainerText = addBBCodeTextObject( const trainerText = addBBCodeTextObject(

View File

@ -122,8 +122,8 @@ export class TitleUiHandler extends OptionSelectUiHandler {
genderSplash(): void { genderSplash(): void {
if (this.splashMessage === "splashMessages:aprilFools.helloKyleAmber") { if (this.splashMessage === "splashMessages:aprilFools.helloKyleAmber") {
globalScene.gameData.gender === PlayerGender.MALE globalScene.gameData.gender === PlayerGender.MALE
? this.splashMessageText.setText(i18next.t(this.splashMessage, { name: i18next.t("trainerNames:player_m") })) ? this.splashMessageText.setText(i18next.t(this.splashMessage, { name: i18next.t("trainerNames:playerM") }))
: this.splashMessageText.setText(i18next.t(this.splashMessage, { name: i18next.t("trainerNames:player_f") })); : this.splashMessageText.setText(i18next.t(this.splashMessage, { name: i18next.t("trainerNames:playerF") }));
} }
} }

View File

@ -134,7 +134,7 @@ describe("Abilities - Disguise", () => {
}); });
await game.classicMode.startBattle([SpeciesId.FURRET, SpeciesId.MIMIKYU]); await game.classicMode.startBattle([SpeciesId.FURRET, SpeciesId.MIMIKYU]);
const mimikyu = game.scene.getPlayerParty()[1]!; const mimikyu = game.scene.getPlayerParty()[1];
expect(mimikyu.formIndex).toBe(bustedForm); expect(mimikyu.formIndex).toBe(bustedForm);
game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH);

View File

@ -3,9 +3,6 @@ import { BattlerIndex } from "#enums/battler-index";
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 { EnemyCommandPhase } from "#phases/enemy-command-phase";
import { TurnEndPhase } from "#phases/turn-end-phase";
import { VictoryPhase } from "#phases/victory-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -46,7 +43,7 @@ describe("Abilities - Moxie", () => {
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase); await game.phaseInterceptor.to("VictoryPhase");
expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1);
}); });
@ -67,7 +64,7 @@ describe("Abilities - Moxie", () => {
game.move.select(moveToUse, BattlerIndex.PLAYER_2); game.move.select(moveToUse, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
expect(firstPokemon.getStatStage(Stat.ATK)).toBe(1); expect(firstPokemon.getStatStage(Stat.ATK)).toBe(1);
}, },

View File

@ -121,8 +121,8 @@ describe("Abilities - Sheer Force", () => {
await game.classicMode.startBattle([SpeciesId.PIDGEOT]); await game.classicMode.startBattle([SpeciesId.PIDGEOT]);
const pidgeot = game.scene.getPlayerParty()[0]; const pidgeot = game.field.getPlayerPokemon();
const onix = game.scene.getEnemyParty()[0]; const onix = game.field.getEnemyPokemon();
pidgeot.stats[Stat.DEF] = 10000; pidgeot.stats[Stat.DEF] = 10000;
onix.stats[Stat.DEF] = 10000; onix.stats[Stat.DEF] = 10000;

View File

@ -1,7 +1,6 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-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 type { EnemyPokemon } from "#field/pokemon";
import { DamageAnimPhase } from "#phases/damage-anim-phase"; import { DamageAnimPhase } from "#phases/damage-anim-phase";
import { MoveEndPhase } from "#phases/move-end-phase"; import { MoveEndPhase } from "#phases/move-end-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
@ -38,13 +37,13 @@ describe("Abilities - Sturdy", () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
game.move.select(MoveId.CLOSE_COMBAT); game.move.select(MoveId.CLOSE_COMBAT);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(game.scene.getEnemyParty()[0].hp).toBe(1); expect(game.field.getEnemyPokemon().hp).toBe(1);
}); });
test("Sturdy doesn't activate when user is not at full HP", async () => { test("Sturdy doesn't activate when user is not at full HP", async () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon = game.field.getEnemyPokemon();
enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; enemyPokemon.hp = enemyPokemon.getMaxHp() - 1;
game.move.select(MoveId.CLOSE_COMBAT); game.move.select(MoveId.CLOSE_COMBAT);
@ -59,19 +58,7 @@ describe("Abilities - Sturdy", () => {
game.move.select(MoveId.FISSURE); game.move.select(MoveId.FISSURE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon = game.field.getEnemyPokemon();
expect(enemyPokemon.isFullHp()).toBe(true); expect(enemyPokemon.isFullHp()).toBe(true);
}); });
test("Sturdy is ignored by pokemon with `AbilityId.MOLD_BREAKER`", async () => {
game.override.ability(AbilityId.MOLD_BREAKER);
await game.classicMode.startBattle();
game.move.select(MoveId.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamageAnimPhase);
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
expect(enemyPokemon.hp).toBe(0);
expect(enemyPokemon.isFainted()).toBe(true);
});
}); });

View File

@ -336,7 +336,7 @@ describe("Abilities - Wimp Out", () => {
game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.getPlayerParty()[0].getHpRatio()).toEqual(0.51); expect(game.field.getPlayerPokemon().getHpRatio()).toEqual(0.51);
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.WIMPOD); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.WIMPOD);
}); });
@ -344,8 +344,7 @@ describe("Abilities - Wimp Out", () => {
it("Wimp Out activating should not cancel a double battle", async () => { it("Wimp Out activating should not cancel a double battle", async () => {
game.override.battleStyle("double").enemyAbility(AbilityId.WIMP_OUT).enemyMoveset([MoveId.SPLASH]).enemyLevel(1); game.override.battleStyle("double").enemyAbility(AbilityId.WIMP_OUT).enemyMoveset([MoveId.SPLASH]).enemyLevel(1);
await game.classicMode.startBattle([SpeciesId.WIMPOD, SpeciesId.TYRUNT]); await game.classicMode.startBattle([SpeciesId.WIMPOD, SpeciesId.TYRUNT]);
const enemyLeadPokemon = game.scene.getEnemyParty()[0]; const [enemyLeadPokemon, enemySecPokemon] = game.scene.getEnemyParty();
const enemySecPokemon = game.scene.getEnemyParty()[1];
game.move.select(MoveId.FALSE_SWIPE, 0, BattlerIndex.ENEMY); game.move.select(MoveId.FALSE_SWIPE, 0, BattlerIndex.ENEMY);
game.move.select(MoveId.SPLASH, 1); game.move.select(MoveId.SPLASH, 1);

View File

@ -40,8 +40,7 @@ describe("Abilities - ZERO TO HERO", () => {
await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.PALAFIN, SpeciesId.PALAFIN]); await game.classicMode.startBattle([SpeciesId.FEEBAS, SpeciesId.PALAFIN, SpeciesId.PALAFIN]);
const palafin1 = game.scene.getPlayerParty()[1]; const [, palafin1, palafin2] = game.scene.getPlayerParty();
const palafin2 = game.scene.getPlayerParty()[2];
expect(palafin1.formIndex).toBe(heroForm); expect(palafin1.formIndex).toBe(heroForm);
expect(palafin2.formIndex).toBe(heroForm); expect(palafin2.formIndex).toBe(heroForm);
palafin2.hp = 0; palafin2.hp = 0;

View File

@ -1,9 +1,7 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-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 { EnemyCommandPhase } from "#phases/enemy-command-phase"; import type { TurnStartPhase } from "#phases/turn-start-phase";
import { SelectTargetPhase } from "#phases/select-target-phase";
import { TurnStartPhase } from "#phases/turn-start-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -41,7 +39,7 @@ describe("Battle order", () => {
vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150 vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.run(EnemyCommandPhase); await game.phaseInterceptor.to("TurnStartPhase", false);
const playerPokemonIndex = playerPokemon.getBattlerIndex(); const playerPokemonIndex = playerPokemon.getBattlerIndex();
const enemyPokemonIndex = enemyPokemon.getBattlerIndex(); const enemyPokemonIndex = enemyPokemon.getBattlerIndex();
@ -60,7 +58,7 @@ describe("Battle order", () => {
vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set enemyPokemon's speed to 50 vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set enemyPokemon's speed to 50
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.run(EnemyCommandPhase); await game.phaseInterceptor.to("TurnStartPhase", false);
const playerPokemonIndex = playerPokemon.getBattlerIndex(); const playerPokemonIndex = playerPokemon.getBattlerIndex();
const enemyPokemonIndex = enemyPokemon.getBattlerIndex(); const enemyPokemonIndex = enemyPokemon.getBattlerIndex();
@ -84,7 +82,7 @@ describe("Battle order", () => {
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
game.move.select(MoveId.TACKLE, 1); game.move.select(MoveId.TACKLE, 1);
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.to("TurnStartPhase", false);
const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder(); const order = phase.getCommandOrder();
@ -108,7 +106,7 @@ describe("Battle order", () => {
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
game.move.select(MoveId.TACKLE, 1); game.move.select(MoveId.TACKLE, 1);
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.to("TurnStartPhase", false);
const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder(); const order = phase.getCommandOrder();
@ -132,7 +130,7 @@ describe("Battle order", () => {
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
game.move.select(MoveId.TACKLE, 1); game.move.select(MoveId.TACKLE, 1);
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.to("TurnStartPhase", false);
const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase;
const order = phase.getCommandOrder(); const order = phase.getCommandOrder();

View File

@ -1,28 +1,13 @@
import { getGameMode } from "#app/game-mode";
import { allSpecies } from "#data/data-lists"; import { allSpecies } from "#data/data-lists";
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 { GameModes } from "#enums/game-modes";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { PlayerGender } from "#enums/player-gender";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { BattleEndPhase } from "#phases/battle-end-phase";
import { CommandPhase } from "#phases/command-phase"; import { CommandPhase } from "#phases/command-phase";
import { DamageAnimPhase } from "#phases/damage-anim-phase";
import { EncounterPhase } from "#phases/encounter-phase";
import { EnemyCommandPhase } from "#phases/enemy-command-phase";
import { LoginPhase } from "#phases/login-phase";
import { NextEncounterPhase } from "#phases/next-encounter-phase"; import { NextEncounterPhase } from "#phases/next-encounter-phase";
import { SelectGenderPhase } from "#phases/select-gender-phase";
import { SelectStarterPhase } from "#phases/select-starter-phase";
import { SummonPhase } from "#phases/summon-phase";
import { SwitchPhase } from "#phases/switch-phase";
import { TitlePhase } from "#phases/title-phase";
import { TurnInitPhase } from "#phases/turn-init-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import { generateStarter } from "#test/test-utils/game-manager-utils";
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";
@ -45,55 +30,11 @@ describe("Phase - Battle Phase", () => {
game.scene.gameData.gender = undefined!; // just for these tests! game.scene.gameData.gender = undefined!; // just for these tests!
}); });
it("test phase interceptor with prompt", async () => {
await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => {
game.scene.gameData.gender = PlayerGender.MALE;
game.endPhase();
});
await game.phaseInterceptor.run(SelectGenderPhase);
await game.phaseInterceptor.run(TitlePhase);
await game.waitMode(UiMode.TITLE);
expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE);
expect(game.scene.gameData.gender).toBe(PlayerGender.MALE);
});
it("test phase interceptor with prompt with preparation for a future prompt", async () => {
await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => {
game.scene.gameData.gender = PlayerGender.MALE;
game.endPhase();
});
game.onNextPrompt("CheckSwitchPhase", UiMode.CONFIRM, () => {
game.setMode(UiMode.MESSAGE);
game.endPhase();
});
await game.phaseInterceptor.run(SelectGenderPhase);
await game.phaseInterceptor.run(TitlePhase);
await game.waitMode(UiMode.TITLE);
expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE);
expect(game.scene.gameData.gender).toBe(PlayerGender.MALE);
});
it("newGame one-liner", async () => {
await game.classicMode.startBattle();
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase");
});
it("do attack wave 3 - single battle - regular - OHKO", async () => { it("do attack wave 3 - single battle - regular - OHKO", async () => {
game.override.enemySpecies(SpeciesId.RATTATA).startingLevel(2000).battleStyle("single").startingWave(3); game.override.enemySpecies(SpeciesId.RATTATA).startingLevel(2000).battleStyle("single").startingWave(3);
await game.classicMode.startBattle([SpeciesId.MEWTWO]); await game.classicMode.startBattle([SpeciesId.MEWTWO]);
game.move.use(MoveId.TACKLE); game.move.use(MoveId.TACKLE);
await game.phaseInterceptor.to("SelectModifierPhase"); await game.toNextWave();
}); });
it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async () => { it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async () => {
@ -107,7 +48,7 @@ describe("Phase - Battle Phase", () => {
.battleStyle("single"); .battleStyle("single");
await game.classicMode.startBattle([SpeciesId.MEWTWO]); await game.classicMode.startBattle([SpeciesId.MEWTWO]);
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false); await game.phaseInterceptor.to("TurnInitPhase", false);
}); });
it("load 100% data file", async () => { it("load 100% data file", async () => {
@ -135,68 +76,6 @@ describe("Phase - Battle Phase", () => {
} }
}); });
it("wrong phase", async () => {
await game.phaseInterceptor.run(LoginPhase);
await game.phaseInterceptor.run(LoginPhase).catch(e => {
expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase");
});
});
it("wrong phase but skip", async () => {
await game.phaseInterceptor.run(LoginPhase);
await game.phaseInterceptor.run(LoginPhase, () => game.isCurrentPhase(SelectGenderPhase));
});
it("good run", async () => {
await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt(
"SelectGenderPhase",
UiMode.OPTION_SELECT,
() => {
game.scene.gameData.gender = PlayerGender.MALE;
game.endPhase();
},
() => game.isCurrentPhase(TitlePhase),
);
await game.phaseInterceptor.run(SelectGenderPhase, () => game.isCurrentPhase(TitlePhase));
await game.phaseInterceptor.run(TitlePhase);
});
it("good run from select gender to title", async () => {
await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt(
"SelectGenderPhase",
UiMode.OPTION_SELECT,
() => {
game.scene.gameData.gender = PlayerGender.MALE;
game.endPhase();
},
() => game.isCurrentPhase(TitlePhase),
);
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase);
});
it("good run to SummonPhase phase", async () => {
await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt(
"SelectGenderPhase",
UiMode.OPTION_SELECT,
() => {
game.scene.gameData.gender = PlayerGender.MALE;
game.endPhase();
},
() => game.isCurrentPhase(TitlePhase),
);
game.onNextPrompt("TitlePhase", UiMode.TITLE, () => {
game.scene.gameMode = getGameMode(GameModes.CLASSIC);
const starters = generateStarter(game.scene);
const selectStarterPhase = new SelectStarterPhase();
game.scene.phaseManager.pushPhase(new EncounterPhase(false));
selectStarterPhase.initBattle(starters);
});
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase);
});
it.each([ it.each([
{ name: "1v1", double: false, qty: 1 }, { name: "1v1", double: false, qty: 1 },
{ name: "2v1", double: false, qty: 2 }, { name: "2v1", double: false, qty: 2 },
@ -232,7 +111,7 @@ describe("Phase - Battle Phase", () => {
await game.classicMode.startBattle([SpeciesId.DARMANITAN, SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.DARMANITAN, SpeciesId.CHARIZARD]);
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
await game.killPokemon(game.scene.currentBattle.enemyParty[0]); await game.killPokemon(game.scene.currentBattle.enemyParty[0]);
expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true);
await game.phaseInterceptor.to("VictoryPhase"); await game.phaseInterceptor.to("VictoryPhase");
@ -296,7 +175,7 @@ describe("Phase - Battle Phase", () => {
game.field.getPlayerPokemon().hp = 1; game.field.getPlayerPokemon().hp = 1;
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.to(BattleEndPhase); await game.phaseInterceptor.to("BattleEndPhase");
game.doRevivePokemon(0); // pretend max revive was picked game.doRevivePokemon(0); // pretend max revive was picked
game.doSelectModifier(); game.doSelectModifier();
@ -308,6 +187,6 @@ describe("Phase - Battle Phase", () => {
}, },
() => game.isCurrentPhase(NextEncounterPhase), () => game.isCurrentPhase(NextEncounterPhase),
); );
await game.phaseInterceptor.to(SwitchPhase); await game.phaseInterceptor.to("SwitchPhase");
}); });
}); });

View File

@ -64,11 +64,9 @@ describe("Boss Pokemon / Shields", () => {
it("should reduce the number of shields if we are in a double battle", async () => { it("should reduce the number of shields if we are in a double battle", async () => {
game.override.battleStyle("double").startingWave(150); // Floor 150 > 2 shields / 3 health segments game.override.battleStyle("double").startingWave(150); // Floor 150 > 2 shields / 3 health segments
await game.classicMode.startBattle([SpeciesId.MEWTWO]); await game.classicMode.startBattle([SpeciesId.MEWTWO]);
const boss1: EnemyPokemon = game.scene.getEnemyParty()[0]!; const [boss1, boss2] = game.scene.getEnemyParty();
const boss2: EnemyPokemon = game.scene.getEnemyParty()[1]!;
expect(boss1.isBoss()).toBe(true); expect(boss1.isBoss()).toBe(true);
expect(boss1.bossSegments).toBe(2); expect(boss1.bossSegments).toBe(2);
expect(boss2.isBoss()).toBe(true); expect(boss2.isBoss()).toBe(true);
@ -112,7 +110,7 @@ describe("Boss Pokemon / Shields", () => {
// In this test we want to break through 3 shields at once // In this test we want to break through 3 shields at once
const brokenShields = 3; const brokenShields = 3;
const boss1: EnemyPokemon = game.scene.getEnemyParty()[0]!; const boss1 = game.field.getEnemyPokemon();
const boss1SegmentHp = boss1.getMaxHp() / boss1.bossSegments; const boss1SegmentHp = boss1.getMaxHp() / boss1.bossSegments;
const requiredDamageBoss1 = boss1SegmentHp * (1 + Math.pow(2, brokenShields)); const requiredDamageBoss1 = boss1SegmentHp * (1 + Math.pow(2, brokenShields));
expect(boss1.isBoss()).toBe(true); expect(boss1.isBoss()).toBe(true);
@ -124,7 +122,7 @@ describe("Boss Pokemon / Shields", () => {
expect(boss1.bossSegmentIndex).toBe(1); expect(boss1.bossSegmentIndex).toBe(1);
expect(boss1.hp).toBe(boss1.getMaxHp() - toDmgValue(boss1SegmentHp * 3)); expect(boss1.hp).toBe(boss1.getMaxHp() - toDmgValue(boss1SegmentHp * 3));
const boss2: EnemyPokemon = game.scene.getEnemyParty()[1]!; const boss2 = game.scene.getEnemyParty()[1];
const boss2SegmentHp = boss2.getMaxHp() / boss2.bossSegments; const boss2SegmentHp = boss2.getMaxHp() / boss2.bossSegments;
const requiredDamageBoss2 = boss2SegmentHp * (1 + Math.pow(2, brokenShields)); const requiredDamageBoss2 = boss2SegmentHp * (1 + Math.pow(2, brokenShields));
@ -144,7 +142,7 @@ describe("Boss Pokemon / Shields", () => {
await game.classicMode.startBattle([SpeciesId.MEWTWO]); await game.classicMode.startBattle([SpeciesId.MEWTWO]);
const boss1: EnemyPokemon = game.scene.getEnemyParty()[0]!; const boss1 = game.field.getEnemyPokemon();
const boss1SegmentHp = boss1.getMaxHp() / boss1.bossSegments; const boss1SegmentHp = boss1.getMaxHp() / boss1.bossSegments;
const singleShieldDamage = Math.ceil(boss1SegmentHp); const singleShieldDamage = Math.ceil(boss1SegmentHp);
expect(boss1.isBoss()).toBe(true); expect(boss1.isBoss()).toBe(true);
@ -167,7 +165,7 @@ describe("Boss Pokemon / Shields", () => {
expect(getTotalStatStageBoosts(boss1)).toBe(totalStatStages); expect(getTotalStatStageBoosts(boss1)).toBe(totalStatStages);
} }
const boss2: EnemyPokemon = game.scene.getEnemyParty()[1]!; const boss2 = game.scene.getEnemyParty()[1];
const boss2SegmentHp = boss2.getMaxHp() / boss2.bossSegments; const boss2SegmentHp = boss2.getMaxHp() / boss2.bossSegments;
const requiredDamage = boss2SegmentHp * (1 + Math.pow(2, shieldsToBreak - 1)); const requiredDamage = boss2SegmentHp * (1 + Math.pow(2, shieldsToBreak - 1));

View File

@ -34,8 +34,7 @@ describe("Evolution", () => {
it("should keep hidden ability after evolving", async () => { it("should keep hidden ability after evolving", async () => {
await game.classicMode.runToSummon([SpeciesId.EEVEE, SpeciesId.TRAPINCH]); await game.classicMode.runToSummon([SpeciesId.EEVEE, SpeciesId.TRAPINCH]);
const eevee = game.scene.getPlayerParty()[0]; const [eevee, trapinch] = game.scene.getPlayerParty();
const trapinch = game.scene.getPlayerParty()[1];
eevee.abilityIndex = 2; eevee.abilityIndex = 2;
trapinch.abilityIndex = 2; trapinch.abilityIndex = 2;
@ -49,8 +48,7 @@ describe("Evolution", () => {
it("should keep same ability slot after evolving", async () => { it("should keep same ability slot after evolving", async () => {
await game.classicMode.runToSummon([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]); await game.classicMode.runToSummon([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]);
const bulbasaur = game.scene.getPlayerParty()[0]; const [bulbasaur, charmander] = game.scene.getPlayerParty();
const charmander = game.scene.getPlayerParty()[1];
bulbasaur.abilityIndex = 0; bulbasaur.abilityIndex = 0;
charmander.abilityIndex = 1; charmander.abilityIndex = 1;
@ -80,8 +78,7 @@ describe("Evolution", () => {
nincada.gender = 1; nincada.gender = 1;
await nincada.evolve(pokemonEvolutions[SpeciesId.NINCADA][0], nincada.getSpeciesForm()); await nincada.evolve(pokemonEvolutions[SpeciesId.NINCADA][0], nincada.getSpeciesForm());
const ninjask = game.scene.getPlayerParty()[0]; const [ninjask, shedinja] = game.scene.getPlayerParty();
const shedinja = game.scene.getPlayerParty()[1];
expect(ninjask.abilityIndex).toBe(2); expect(ninjask.abilityIndex).toBe(2);
expect(shedinja.abilityIndex).toBe(1); expect(shedinja.abilityIndex).toBe(1);
expect(ninjask.gender).toBe(1); expect(ninjask.gender).toBe(1);

View File

@ -85,17 +85,14 @@ describe("Spec - Pokemon", () => {
}); });
describe("Get correct fusion type", () => { describe("Get correct fusion type", () => {
let scene: BattleScene;
beforeEach(async () => { beforeEach(async () => {
game.override.enemySpecies(SpeciesId.ZUBAT).starterSpecies(SpeciesId.ABRA).enableStarterFusion(); game.override.enemySpecies(SpeciesId.ZUBAT).starterSpecies(SpeciesId.ABRA).enableStarterFusion();
scene = game.scene;
}); });
it("Fusing two mons with a single type", async () => { it("Fusing two mons with a single type", async () => {
game.override.starterFusionSpecies(SpeciesId.CHARMANDER); game.override.starterFusionSpecies(SpeciesId.CHARMANDER);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const pokemon = scene.getPlayerParty()[0]; const pokemon = game.field.getPlayerPokemon();
let types = pokemon.getTypes(); let types = pokemon.getTypes();
expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[0]).toBe(PokemonType.PSYCHIC);
@ -136,7 +133,7 @@ describe("Spec - Pokemon", () => {
it("Fusing two mons with same single type", async () => { it("Fusing two mons with same single type", async () => {
game.override.starterFusionSpecies(SpeciesId.DROWZEE); game.override.starterFusionSpecies(SpeciesId.DROWZEE);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const pokemon = scene.getPlayerParty()[0]; const pokemon = game.field.getPlayerPokemon();
const types = pokemon.getTypes(); const types = pokemon.getTypes();
expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[0]).toBe(PokemonType.PSYCHIC);
@ -146,7 +143,7 @@ describe("Spec - Pokemon", () => {
it("Fusing mons with one and two types", async () => { it("Fusing mons with one and two types", async () => {
game.override.starterSpecies(SpeciesId.CHARMANDER).starterFusionSpecies(SpeciesId.HOUNDOUR); game.override.starterSpecies(SpeciesId.CHARMANDER).starterFusionSpecies(SpeciesId.HOUNDOUR);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const pokemon = scene.getPlayerParty()[0]; const pokemon = game.field.getPlayerPokemon();
const types = pokemon.getTypes(); const types = pokemon.getTypes();
expect(types[0]).toBe(PokemonType.FIRE); expect(types[0]).toBe(PokemonType.FIRE);
@ -156,7 +153,7 @@ describe("Spec - Pokemon", () => {
it("Fusing mons with two and one types", async () => { it("Fusing mons with two and one types", async () => {
game.override.starterSpecies(SpeciesId.NUMEL).starterFusionSpecies(SpeciesId.CHARMANDER); game.override.starterSpecies(SpeciesId.NUMEL).starterFusionSpecies(SpeciesId.CHARMANDER);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const pokemon = scene.getPlayerParty()[0]; const pokemon = game.field.getPlayerPokemon();
const types = pokemon.getTypes(); const types = pokemon.getTypes();
expect(types[0]).toBe(PokemonType.FIRE); expect(types[0]).toBe(PokemonType.FIRE);
@ -166,7 +163,7 @@ describe("Spec - Pokemon", () => {
it("Fusing two mons with two types", async () => { it("Fusing two mons with two types", async () => {
game.override.starterSpecies(SpeciesId.NATU).starterFusionSpecies(SpeciesId.HOUNDOUR); game.override.starterSpecies(SpeciesId.NATU).starterFusionSpecies(SpeciesId.HOUNDOUR);
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const pokemon = scene.getPlayerParty()[0]; const pokemon = game.field.getPlayerPokemon();
let types = pokemon.getTypes(); let types = pokemon.getTypes();
expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[0]).toBe(PokemonType.PSYCHIC);

View File

@ -33,7 +33,7 @@ describe("Items - Light Ball", () => {
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.classicMode.startBattle([SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.PIKACHU]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
// Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -84,7 +84,7 @@ describe("Items - Light Ball", () => {
it("LIGHT_BALL held by PIKACHU", async () => { it("LIGHT_BALL held by PIKACHU", async () => {
await game.classicMode.startBattle([SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.PIKACHU]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
const spAtkStat = partyMember.getStat(Stat.SPATK); const spAtkStat = partyMember.getStat(Stat.SPATK);
@ -113,8 +113,7 @@ describe("Items - Light Ball", () => {
it("LIGHT_BALL held by fused PIKACHU (base)", async () => { it("LIGHT_BALL held by fused PIKACHU (base)", async () => {
await game.classicMode.startBattle([SpeciesId.PIKACHU, SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.PIKACHU, SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -152,8 +151,7 @@ describe("Items - Light Ball", () => {
it("LIGHT_BALL held by fused PIKACHU (part)", async () => { it("LIGHT_BALL held by fused PIKACHU (part)", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.PIKACHU]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -191,7 +189,7 @@ describe("Items - Light Ball", () => {
it("LIGHT_BALL not held by PIKACHU", async () => { it("LIGHT_BALL not held by PIKACHU", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
const spAtkStat = partyMember.getStat(Stat.SPATK); const spAtkStat = partyMember.getStat(Stat.SPATK);

View File

@ -33,7 +33,7 @@ describe("Items - Metal Powder", () => {
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.classicMode.startBattle([SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
// Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -84,7 +84,7 @@ describe("Items - Metal Powder", () => {
it("METAL_POWDER held by DITTO", async () => { it("METAL_POWDER held by DITTO", async () => {
await game.classicMode.startBattle([SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const defStat = partyMember.getStat(Stat.DEF); const defStat = partyMember.getStat(Stat.DEF);
@ -107,8 +107,7 @@ describe("Items - Metal Powder", () => {
it("METAL_POWDER held by fused DITTO (base)", async () => { it("METAL_POWDER held by fused DITTO (base)", async () => {
await game.classicMode.startBattle([SpeciesId.DITTO, SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.DITTO, SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -140,8 +139,7 @@ describe("Items - Metal Powder", () => {
it("METAL_POWDER held by fused DITTO (part)", async () => { it("METAL_POWDER held by fused DITTO (part)", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -173,7 +171,7 @@ describe("Items - Metal Powder", () => {
it("METAL_POWDER not held by DITTO", async () => { it("METAL_POWDER not held by DITTO", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const defStat = partyMember.getStat(Stat.DEF); const defStat = partyMember.getStat(Stat.DEF);

View File

@ -33,7 +33,7 @@ describe("Items - Quick Powder", () => {
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.classicMode.startBattle([SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
// Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -84,7 +84,7 @@ describe("Items - Quick Powder", () => {
it("QUICK_POWDER held by DITTO", async () => { it("QUICK_POWDER held by DITTO", async () => {
await game.classicMode.startBattle([SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const spdStat = partyMember.getStat(Stat.SPD); const spdStat = partyMember.getStat(Stat.SPD);
@ -107,8 +107,7 @@ describe("Items - Quick Powder", () => {
it("QUICK_POWDER held by fused DITTO (base)", async () => { it("QUICK_POWDER held by fused DITTO (base)", async () => {
await game.classicMode.startBattle([SpeciesId.DITTO, SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.DITTO, SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -140,8 +139,7 @@ describe("Items - Quick Powder", () => {
it("QUICK_POWDER held by fused DITTO (part)", async () => { it("QUICK_POWDER held by fused DITTO (part)", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.DITTO]); await game.classicMode.startBattle([SpeciesId.MAROWAK, SpeciesId.DITTO]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -173,7 +171,7 @@ describe("Items - Quick Powder", () => {
it("QUICK_POWDER not held by DITTO", async () => { it("QUICK_POWDER not held by DITTO", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const spdStat = partyMember.getStat(Stat.SPD); const spdStat = partyMember.getStat(Stat.SPD);

View File

@ -6,7 +6,6 @@ import { SpeciesId } from "#enums/species-id";
import { BATTLE_STATS, Stat } from "#enums/stat"; import { BATTLE_STATS, Stat } from "#enums/stat";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { TempStatStageBoosterModifier } from "#modifiers/modifier"; import { TempStatStageBoosterModifier } from "#modifiers/modifier";
import { TurnEndPhase } from "#phases/turn-end-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler"; import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
import Phaser from "phaser"; import Phaser from "phaser";
@ -47,7 +46,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.runFrom("EnemyCommandPhase").to(TurnEndPhase); await game.toEndOfTurn();
expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.3); expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.3);
}); });
@ -64,11 +63,11 @@ describe("Items - Temporary Stat Stage Boosters", () => {
// Raise ACC by +2 stat stages // Raise ACC by +2 stat stages
game.move.select(MoveId.HONE_CLAWS); game.move.select(MoveId.HONE_CLAWS);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
// ACC at +3 stat stages yields a x2 multiplier // ACC at +3 stat stages yields a x2 multiplier
expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(2); expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(2);
@ -84,11 +83,11 @@ describe("Items - Temporary Stat Stage Boosters", () => {
// Raise ATK by +1 stat stage // Raise ATK by +1 stat stage
game.move.select(MoveId.HONE_CLAWS); game.move.select(MoveId.HONE_CLAWS);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
// ATK at +1 stat stage yields a x1.5 multiplier, add 0.3 from X_ATTACK // ATK at +1 stat stage yields a x1.5 multiplier, add 0.3 from X_ATTACK
expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.8); expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.8);
@ -112,7 +111,7 @@ describe("Items - Temporary Stat Stage Boosters", () => {
game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(3); expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(3);
expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(4); expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(4);

View File

@ -33,7 +33,7 @@ describe("Items - 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]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
// Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called // Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called
partyMember.getEffectiveStat(Stat.DEF); partyMember.getEffectiveStat(Stat.DEF);
@ -84,7 +84,7 @@ describe("Items - Thick Club", () => {
it("THICK_CLUB held by CUBONE", async () => { it("THICK_CLUB held by CUBONE", async () => {
await game.classicMode.startBattle([SpeciesId.CUBONE]); await game.classicMode.startBattle([SpeciesId.CUBONE]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -107,7 +107,7 @@ describe("Items - Thick Club", () => {
it("THICK_CLUB held by MAROWAK", async () => { it("THICK_CLUB held by MAROWAK", async () => {
await game.classicMode.startBattle([SpeciesId.MAROWAK]); await game.classicMode.startBattle([SpeciesId.MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -130,7 +130,7 @@ describe("Items - Thick Club", () => {
it("THICK_CLUB held by ALOLA_MAROWAK", async () => { it("THICK_CLUB held by ALOLA_MAROWAK", async () => {
await game.classicMode.startBattle([SpeciesId.ALOLA_MAROWAK]); await game.classicMode.startBattle([SpeciesId.ALOLA_MAROWAK]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);
@ -157,8 +157,7 @@ describe("Items - Thick Club", () => {
await game.classicMode.startBattle([species[randSpecies], SpeciesId.PIKACHU]); await game.classicMode.startBattle([species[randSpecies], SpeciesId.PIKACHU]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -194,8 +193,7 @@ describe("Items - Thick Club", () => {
await game.classicMode.startBattle([SpeciesId.PIKACHU, species[randSpecies]]); await game.classicMode.startBattle([SpeciesId.PIKACHU, species[randSpecies]]);
const partyMember = game.scene.getPlayerParty()[0]; const [partyMember, ally] = game.scene.getPlayerParty();
const ally = game.scene.getPlayerParty()[1];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
partyMember.fusionSpecies = ally.species; partyMember.fusionSpecies = ally.species;
@ -227,7 +225,7 @@ describe("Items - Thick Club", () => {
it("THICK_CLUB not held by CUBONE", async () => { it("THICK_CLUB not held by CUBONE", async () => {
await game.classicMode.startBattle([SpeciesId.PIKACHU]); await game.classicMode.startBattle([SpeciesId.PIKACHU]);
const partyMember = game.scene.getPlayerParty()[0]; const partyMember = game.field.getPlayerPokemon();
const atkStat = partyMember.getStat(Stat.ATK); const atkStat = partyMember.getStat(Stat.ATK);

View File

@ -46,7 +46,7 @@ describe("Moves - Dragon Rage", () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
partyPokemon = game.scene.getPlayerParty()[0]; partyPokemon = game.field.getPlayerPokemon();
enemyPokemon = game.field.getEnemyPokemon(); enemyPokemon = game.field.getEnemyPokemon();
}); });

View File

@ -76,10 +76,9 @@ describe("Moves - Dragon Tail", () => {
game.override.battleStyle("double").enemyMoveset(MoveId.SPLASH).enemyAbility(AbilityId.ROUGH_SKIN); game.override.battleStyle("double").enemyMoveset(MoveId.SPLASH).enemyAbility(AbilityId.ROUGH_SKIN);
await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.DRATINI, SpeciesId.WAILORD, SpeciesId.WAILORD]); await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.DRATINI, SpeciesId.WAILORD, SpeciesId.WAILORD]);
const leadPokemon = game.scene.getPlayerParty()[0]!; const leadPokemon = game.field.getPlayerPokemon();
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; const [enemyLeadPokemon, enemySecPokemon] = game.scene.getEnemyParty();
const enemySecPokemon = game.scene.getEnemyParty()[1]!;
game.move.select(MoveId.DRAGON_TAIL, 0, BattlerIndex.ENEMY); game.move.select(MoveId.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
game.move.select(MoveId.SPLASH, 1); game.move.select(MoveId.SPLASH, 1);
@ -105,11 +104,9 @@ describe("Moves - Dragon Tail", () => {
game.override.battleStyle("double").enemyMoveset(MoveId.SPLASH).enemyAbility(AbilityId.ROUGH_SKIN); game.override.battleStyle("double").enemyMoveset(MoveId.SPLASH).enemyAbility(AbilityId.ROUGH_SKIN);
await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.DRATINI, SpeciesId.WAILORD, SpeciesId.WAILORD]); await game.classicMode.startBattle([SpeciesId.DRATINI, SpeciesId.DRATINI, SpeciesId.WAILORD, SpeciesId.WAILORD]);
const leadPokemon = game.scene.getPlayerParty()[0]!; const [leadPokemon, secPokemon] = game.scene.getPlayerParty();
const secPokemon = game.scene.getPlayerParty()[1]!;
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!; const [enemyLeadPokemon, enemySecPokemon] = game.scene.getEnemyParty();
const enemySecPokemon = game.scene.getEnemyParty()[1]!;
game.move.select(MoveId.DRAGON_TAIL, 0, BattlerIndex.ENEMY); game.move.select(MoveId.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
// target the same pokemon, second move should be redirected after first flees // target the same pokemon, second move should be redirected after first flees

View File

@ -42,7 +42,7 @@ describe("Moves - Fissure", () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
partyPokemon = game.scene.getPlayerParty()[0]; partyPokemon = game.field.getPlayerPokemon();
enemyPokemon = game.field.getEnemyPokemon(); enemyPokemon = game.field.getEnemyPokemon();
}); });

View File

@ -4,10 +4,7 @@ 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 type { Move } from "#moves/move"; import type { Move } from "#moves/move";
import { DamageAnimPhase } from "#phases/damage-anim-phase"; import type { MoveEffectPhase } from "#phases/move-effect-phase";
import { MoveEffectPhase } from "#phases/move-effect-phase";
import { MoveEndPhase } from "#phases/move-end-phase";
import { MovePhase } from "#phases/move-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -55,14 +52,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force user party to act before enemy party // Force user party to act before enemy party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
@ -75,14 +72,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force user party to act before enemy party // Force user party to act before enemy party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
@ -95,19 +92,19 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force first enemy to act (and fail) in between party // Force first enemy to act (and fail) in between party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to("MoveEndPhase");
// Skip enemy move; because the enemy is at full HP, Rest should fail // Skip enemy move; because the enemy is at full HP, Rest should fail
await game.phaseInterceptor.runFrom(MovePhase).to(MoveEndPhase); await game.phaseInterceptor.to("MoveEndPhase");
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
@ -121,18 +118,18 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force first enemy to act in between party // Force first enemy to act in between party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to("MoveEndPhase");
// Skip enemy move // Skip enemy move
await game.phaseInterceptor.runFrom(MovePhase).to(MoveEndPhase); await game.phaseInterceptor.to("MoveEndPhase");
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
}); });
@ -145,14 +142,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force user party to act before enemy party // Force user party to act before enemy party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
@ -189,24 +186,24 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force first enemy to act in between party // Force first enemy to act in between party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
@ -243,24 +240,24 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
// Force first enemy to act in between party // Force first enemy to act in between party
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to("MoveEffectPhase", false);
expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id);
await game.phaseInterceptor.to(DamageAnimPhase, false); await game.phaseInterceptor.to("DamageAnimPhase", false);
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
}); });
}); });

View File

@ -2,8 +2,6 @@ import { AbilityId } from "#enums/ability-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 { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { EnemyCommandPhase } from "#phases/enemy-command-phase";
import { TurnInitPhase } from "#phases/turn-init-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -40,7 +38,7 @@ describe("Moves - Growth", () => {
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0);
game.move.select(MoveId.GROWTH); game.move.select(MoveId.GROWTH);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); await game.toEndOfTurn();
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1);
}); });

View File

@ -2,10 +2,6 @@ import { AbilityId } from "#enums/ability-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 { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BerryPhase } from "#phases/berry-phase";
import { FaintPhase } from "#phases/faint-phase";
import { MessagePhase } from "#phases/message-phase";
import { TurnInitPhase } from "#phases/turn-init-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, test } from "vitest";
@ -43,7 +39,7 @@ describe("Moves - Parting Shot", () => {
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
@ -58,7 +54,7 @@ describe("Moves - Parting Shot", () => {
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
@ -79,24 +75,24 @@ describe("Moves - Parting Shot", () => {
// use Memento 3 times to debuff enemy // use Memento 3 times to debuff enemy
game.move.select(MoveId.MEMENTO); game.move.select(MoveId.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to("FaintPhase");
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); expect(game.field.getPlayerPokemon().isFainted()).toBe(true);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to(TurnInitPhase, false); await game.phaseInterceptor.to("TurnInitPhase", false);
game.move.select(MoveId.MEMENTO); game.move.select(MoveId.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to("FaintPhase");
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); expect(game.field.getPlayerPokemon().isFainted()).toBe(true);
game.doSelectPartyPokemon(2); game.doSelectPartyPokemon(2);
await game.phaseInterceptor.to(TurnInitPhase, false); await game.phaseInterceptor.to("TurnInitPhase", false);
game.move.select(MoveId.MEMENTO); game.move.select(MoveId.MEMENTO);
await game.phaseInterceptor.to(FaintPhase); await game.phaseInterceptor.to("FaintPhase");
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); expect(game.field.getPlayerPokemon().isFainted()).toBe(true);
game.doSelectPartyPokemon(3); game.doSelectPartyPokemon(3);
// set up done // set up done
await game.phaseInterceptor.to(TurnInitPhase, false); await game.phaseInterceptor.to("TurnInitPhase", false);
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
expect(enemyPokemon).toBeDefined(); expect(enemyPokemon).toBeDefined();
@ -106,7 +102,7 @@ describe("Moves - Parting Shot", () => {
// now parting shot should fail // now parting shot should fail
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
@ -125,7 +121,7 @@ describe("Moves - Parting Shot", () => {
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
@ -144,7 +140,7 @@ describe("Moves - Parting Shot", () => {
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
@ -153,43 +149,24 @@ describe("Moves - Parting Shot", () => {
it.todo( it.todo(
// TODO: fix this bug to pass the test! // TODO: fix this bug to pass the test!
"Parting shot should de-buff and not fail if no party available to switch - party size 1", "should lower stats without failing if no alive party members available to switch",
async () => {
await game.classicMode.startBattle([SpeciesId.MURKROW]);
const enemyPokemon = game.field.getEnemyPokemon();
expect(enemyPokemon).toBeDefined();
game.move.select(MoveId.PARTING_SHOT);
await game.phaseInterceptor.to(BerryPhase, false);
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW);
},
);
it.todo(
// TODO: fix this bug to pass the test!
"Parting shot regularly not fail if no party available to switch - party fainted",
async () => { async () => {
await game.classicMode.startBattle([SpeciesId.MURKROW, SpeciesId.MEOWTH]); await game.classicMode.startBattle([SpeciesId.MURKROW, SpeciesId.MEOWTH]);
const meowth = game.scene.getPlayerParty()[1];
meowth.hp = 0;
game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH);
await game.toNextTurn();
// intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted)
await game.killPokemon(game.scene.getPlayerParty()[0]);
expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true);
await game.phaseInterceptor.run(MessagePhase);
game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to(TurnInitPhase, false);
game.move.select(MoveId.PARTING_SHOT); game.move.select(MoveId.PARTING_SHOT);
game.doSelectPartyPokemon(1);
await game.toEndOfTurn();
await game.phaseInterceptor.to(BerryPhase, false);
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0);
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.MURKROW);
}, },
); );
}); });

View File

@ -133,6 +133,6 @@ describe("Moves - Revival Blessing", () => {
await game.toNextTurn(); await game.toNextTurn();
// If there are incorrectly two switch phases into this slot, the fainted pokemon will end up in slot 3 // If there are incorrectly two switch phases into this slot, the fainted pokemon will end up in slot 3
// Make sure it's still in slot 1 // Make sure it's still in slot 1
expect(game.scene.getEnemyParty()[0]).toBe(enemyFainting); expect(game.field.getEnemyPokemon()).toBe(enemyFainting);
}); });
}); });

View File

@ -44,10 +44,10 @@ describe("Moves - Rollout", () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
const playerPkm = game.scene.getPlayerParty()[0]; const playerPkm = game.field.getPlayerPokemon();
vi.spyOn(playerPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD vi.spyOn(playerPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD
const enemyPkm = game.scene.getEnemyParty()[0]; const enemyPkm = game.field.getEnemyPokemon();
vi.spyOn(enemyPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD vi.spyOn(enemyPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD
vi.spyOn(enemyPkm, "getHeldItems").mockReturnValue([]); //no berries vi.spyOn(enemyPkm, "getHeldItems").mockReturnValue([]); //no berries

View File

@ -6,7 +6,6 @@ import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { RandomMoveAttr } from "#moves/move"; import { RandomMoveAttr } from "#moves/move";
import { PokemonMove } from "#moves/pokemon-move";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -40,7 +39,7 @@ describe("Moves - Sketch", () => {
await game.classicMode.startBattle([SpeciesId.REGIELEKI]); await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
const playerPokemon = game.field.getPlayerPokemon(); const playerPokemon = game.field.getPlayerPokemon();
// can't use normal moveset override because we need to check moveset changes // can't use normal moveset override because we need to check moveset changes
playerPokemon.moveset = [new PokemonMove(MoveId.SKETCH), new PokemonMove(MoveId.SKETCH)]; game.move.changeMoveset(playerPokemon, [MoveId.SKETCH, MoveId.SKETCH]);
game.move.select(MoveId.SKETCH); game.move.select(MoveId.SKETCH);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
@ -62,7 +61,7 @@ describe("Moves - Sketch", () => {
await game.classicMode.startBattle([SpeciesId.REGIELEKI]); await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
const playerPokemon = game.field.getPlayerPokemon(); const playerPokemon = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
playerPokemon.moveset = [new PokemonMove(MoveId.SKETCH), new PokemonMove(MoveId.GROWL)]; game.move.changeMoveset(playerPokemon, [MoveId.SKETCH, MoveId.GROWL]);
game.move.select(MoveId.GROWL); game.move.select(MoveId.GROWL);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
@ -88,8 +87,9 @@ describe("Moves - Sketch", () => {
game.override.enemyMoveset([MoveId.METRONOME]); game.override.enemyMoveset([MoveId.METRONOME]);
await game.classicMode.startBattle([SpeciesId.REGIELEKI]); await game.classicMode.startBattle([SpeciesId.REGIELEKI]);
const playerPokemon = game.field.getPlayerPokemon(); const playerPokemon = game.field.getPlayerPokemon();
playerPokemon.moveset = [new PokemonMove(MoveId.SKETCH)]; game.move.changeMoveset(playerPokemon, MoveId.SKETCH);
// Opponent uses Metronome -> False Swipe, then player uses Sketch, which should sketch Metronome // Opponent uses Metronome -> False Swipe, then player uses Sketch, which should sketch Metronome
game.move.select(MoveId.SKETCH); game.move.select(MoveId.SKETCH);

View File

@ -48,7 +48,7 @@ describe("Moves - Spikes", () => {
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
await game.toNextTurn(); await game.toNextTurn();
const player = game.scene.getPlayerParty()[0]; const player = game.field.getPlayerPokemon();
expect(player.hp).toBe(player.getMaxHp()); expect(player.hp).toBe(player.getMaxHp());
}); });
@ -62,7 +62,7 @@ describe("Moves - Spikes", () => {
game.move.select(MoveId.ROAR); game.move.select(MoveId.ROAR);
await game.toNextTurn(); await game.toNextTurn();
const enemy = game.scene.getEnemyParty()[0]; const enemy = game.field.getEnemyPokemon();
expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
}); });
@ -77,7 +77,7 @@ describe("Moves - Spikes", () => {
game.forceEnemyToSwitch(); game.forceEnemyToSwitch();
await game.toNextTurn(); await game.toNextTurn();
const enemy = game.scene.getEnemyParty()[0]; const enemy = game.field.getEnemyPokemon();
expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
}); });

View File

@ -1,8 +1,6 @@
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 { EnemyCommandPhase } from "#phases/enemy-command-phase";
import { TurnEndPhase } from "#phases/turn-end-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -41,7 +39,7 @@ describe("Moves - Tackle", () => {
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]); await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; const hpOpponent = game.scene.currentBattle.enemyParty[0].hp;
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); await game.toEndOfTurn();
const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp;
expect(hpLost).toBe(0); expect(hpLost).toBe(0);
}); });
@ -50,12 +48,12 @@ describe("Moves - Tackle", () => {
const moveToUse = MoveId.TACKLE; const moveToUse = MoveId.TACKLE;
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]); await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
game.scene.currentBattle.enemyParty[0].stats[Stat.DEF] = 50; game.scene.currentBattle.enemyParty[0].stats[Stat.DEF] = 50;
game.scene.getPlayerParty()[0].stats[Stat.ATK] = 50; game.field.getPlayerPokemon().stats[Stat.ATK] = 50;
const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; const hpOpponent = game.scene.currentBattle.enemyParty[0].hp;
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); await game.toEndOfTurn();
const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp;
expect(hpLost).toBeGreaterThan(0); expect(hpLost).toBeGreaterThan(0);
expect(hpLost).toBeLessThan(4); expect(hpLost).toBeLessThan(4);

View File

@ -2,8 +2,6 @@ import { AbilityId } from "#enums/ability-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 { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { EnemyCommandPhase } from "#phases/enemy-command-phase";
import { TurnInitPhase } from "#phases/turn-init-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
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";
@ -43,7 +41,7 @@ describe("Moves - Tail whip", () => {
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
game.move.select(moveToUse); game.move.select(moveToUse);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); await game.toEndOfTurn();
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1);
}); });

View File

@ -72,7 +72,7 @@ describe("Moves - Tera Starstorm", () => {
it("targets both opponents in a double battle when used by Terapagos immediately after terastallizing", async () => { it("targets both opponents in a double battle when used by Terapagos immediately after terastallizing", async () => {
await game.classicMode.startBattle([SpeciesId.TERAPAGOS]); await game.classicMode.startBattle([SpeciesId.TERAPAGOS]);
const terapagos = game.scene.getPlayerParty()[0]; const terapagos = game.field.getPlayerPokemon();
terapagos.isTerastallized = false; terapagos.isTerastallized = false;
game.move.selectWithTera(MoveId.TERA_STARSTORM, 0); game.move.selectWithTera(MoveId.TERA_STARSTORM, 0);
@ -89,7 +89,7 @@ describe("Moves - Tera Starstorm", () => {
it("targets only one opponent in a double battle when used by Terapagos without terastallizing", async () => { it("targets only one opponent in a double battle when used by Terapagos without terastallizing", async () => {
await game.classicMode.startBattle([SpeciesId.TERAPAGOS]); await game.classicMode.startBattle([SpeciesId.TERAPAGOS]);
const terapagos = game.scene.getPlayerParty()[0]; const terapagos = game.field.getPlayerPokemon();
terapagos.isTerastallized = false; terapagos.isTerastallized = false;
game.move.select(MoveId.TERA_STARSTORM, 0, BattlerIndex.ENEMY); game.move.select(MoveId.TERA_STARSTORM, 0, BattlerIndex.ENEMY);
@ -106,8 +106,7 @@ describe("Moves - Tera Starstorm", () => {
it("applies the effects when Terapagos in Stellar Form is fused with another Pokemon", async () => { it("applies the effects when Terapagos in Stellar Form is fused with another Pokemon", async () => {
await game.classicMode.startBattle([SpeciesId.TERAPAGOS, SpeciesId.CHARMANDER, SpeciesId.MAGIKARP]); await game.classicMode.startBattle([SpeciesId.TERAPAGOS, SpeciesId.CHARMANDER, SpeciesId.MAGIKARP]);
const fusionedMon = game.scene.getPlayerParty()[0]; const [fusionedMon, , magikarp] = game.scene.getPlayerParty();
const magikarp = game.scene.getPlayerParty()[2];
// Fuse party members (taken from PlayerPokemon.fuse(...) function) // Fuse party members (taken from PlayerPokemon.fuse(...) function)
fusionedMon.fusionSpecies = magikarp.species; fusionedMon.fusionSpecies = magikarp.species;

View File

@ -9,7 +9,6 @@ import { MessagePhase } from "#phases/message-phase";
import { import {
MysteryEncounterBattlePhase, MysteryEncounterBattlePhase,
MysteryEncounterOptionSelectedPhase, MysteryEncounterOptionSelectedPhase,
MysteryEncounterPhase,
MysteryEncounterRewardsPhase, MysteryEncounterRewardsPhase,
} from "#phases/mystery-encounter-phases"; } from "#phases/mystery-encounter-phases";
import { VictoryPhase } from "#phases/victory-phase"; import { VictoryPhase } from "#phases/victory-phase";
@ -89,9 +88,9 @@ export async function runMysteryEncounterToEnd(
uiHandler.processInput(Button.ACTION); uiHandler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.to(CommandPhase); await game.toNextTurn();
} else { } else {
await game.phaseInterceptor.to(MysteryEncounterRewardsPhase); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase");
} }
} }
@ -112,7 +111,7 @@ export async function runSelectMysteryEncounterOption(
); );
if (game.isCurrentPhase(MessagePhase)) { if (game.isCurrentPhase(MessagePhase)) {
await game.phaseInterceptor.run(MessagePhase); await game.phaseInterceptor.to("MessagePhase");
} }
// dispose of intro messages // dispose of intro messages
@ -126,7 +125,7 @@ export async function runSelectMysteryEncounterOption(
() => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase), () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase),
); );
await game.phaseInterceptor.to(MysteryEncounterPhase, true); await game.phaseInterceptor.to("MysteryEncounterPhase", true);
// select the desired option // select the desired option
const uiHandler = game.scene.ui.getHandler<MysteryEncounterUiHandler>(); const uiHandler = game.scene.ui.getHandler<MysteryEncounterUiHandler>();
@ -205,7 +204,7 @@ export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManage
game.scene.field.remove(p); game.scene.field.remove(p);
}); });
game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.scene.phaseManager.pushPhase(new VictoryPhase(0));
game.phaseInterceptor.superEndPhase(); game.endPhase();
game.setMode(UiMode.MESSAGE); game.setMode(UiMode.MESSAGE);
await game.phaseInterceptor.to(MysteryEncounterRewardsPhase, runRewardsPhase); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase", runRewardsPhase);
} }

View File

@ -7,7 +7,6 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { ShinyRateBoosterModifier } from "#modifiers/modifier"; import { ShinyRateBoosterModifier } from "#modifiers/modifier";
import { PokemonMove } from "#moves/pokemon-move";
import { AnOfferYouCantRefuseEncounter } from "#mystery-encounters/an-offer-you-cant-refuse-encounter"; import { AnOfferYouCantRefuseEncounter } from "#mystery-encounters/an-offer-you-cant-refuse-encounter";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
@ -207,9 +206,8 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => {
it("should award EXP to a pokemon with a move in EXTORTION_MOVES", async () => { it("should award EXP to a pokemon with a move in EXTORTION_MOVES", async () => {
game.override.ability(AbilityId.SYNCHRONIZE); // Not an extortion ability, so we can test extortion move game.override.ability(AbilityId.SYNCHRONIZE); // Not an extortion ability, so we can test extortion move
await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, [SpeciesId.ABRA]); await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, [SpeciesId.ABRA]);
const party = scene.getPlayerParty(); const abra = game.field.getPlayerPokemon();
const abra = party.find(pkm => pkm.species.speciesId === SpeciesId.ABRA)!; game.move.changeMoveset(abra, MoveId.BEAT_UP);
abra.moveset = [new PokemonMove(MoveId.BEAT_UP)];
const expBefore = abra.exp; const expBefore = abra.exp;
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);

View File

@ -134,7 +134,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const berriesAfter = scene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; const berriesAfter = scene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[];
@ -147,9 +147,7 @@ describe("Berries Abound - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.BERRIES_ABOUND, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.BERRIES_ABOUND, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase);
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -232,9 +230,9 @@ describe("Berries Abound - Mystery Encounter", () => {
}); });
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -368,9 +368,9 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterRewardsPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterRewardsPhase.name);
game.phaseInterceptor["prompts"] = []; // Clear out prompt handlers game.phaseInterceptor["prompts"] = []; // Clear out prompt handlers
game.onNextPrompt("MysteryEncounterRewardsPhase", UiMode.OPTION_SELECT, () => { game.onNextPrompt("MysteryEncounterRewardsPhase", UiMode.OPTION_SELECT, () => {
game.phaseInterceptor.superEndPhase(); game.endPhase();
}); });
await game.phaseInterceptor.run(MysteryEncounterRewardsPhase); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase");
expect(selectOptionSpy).toHaveBeenCalledTimes(1); expect(selectOptionSpy).toHaveBeenCalledTimes(1);
const optionData = selectOptionSpy.mock.calls[0][0]; const optionData = selectOptionSpy.mock.calls[0][0];
@ -395,7 +395,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't have any Bug types", async () => { it("should NOT be selectable if the player doesn't have any Bug types", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [SpeciesId.ABRA]); await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [SpeciesId.ABRA]);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -417,7 +417,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -436,7 +436,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -458,7 +458,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -482,7 +482,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -530,7 +530,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't have any Bug items", async () => { it("should NOT be selectable if the player doesn't have any Bug items", async () => {
game.scene.modifiers = []; game.scene.modifiers = [];
await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, defaultParty);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
game.scene.modifiers = []; game.scene.modifiers = [];
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
@ -558,7 +558,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -25,7 +25,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CommandPhase } from "#phases/command-phase"; import { CommandPhase } from "#phases/command-phase";
import { MovePhase } from "#phases/move-phase"; import { MovePhase } from "#phases/move-phase";
import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases"; import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { NewBattlePhase } from "#phases/new-battle-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { import {
runMysteryEncounterToEnd, runMysteryEncounterToEnd,
@ -200,9 +199,9 @@ describe("Clowning Around - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
const abilityToTrain = scene.currentBattle.mysteryEncounter?.misc.ability; const abilityToTrain = scene.currentBattle.mysteryEncounter?.misc.ability;
game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => { game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => {
@ -215,7 +214,7 @@ describe("Clowning Around - Mystery Encounter", () => {
const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler; const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler;
vi.spyOn(partyUiHandler, "show"); vi.spyOn(partyUiHandler, "show");
game.endPhase(); game.endPhase();
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(PostMysteryEncounterPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(PostMysteryEncounterPhase.name);
// Wait for Yes/No confirmation to appear // Wait for Yes/No confirmation to appear
@ -228,9 +227,9 @@ describe("Clowning Around - Mystery Encounter", () => {
// Click "Select" on Pokemon // Click "Select" on Pokemon
partyUiHandler.processInput(Button.ACTION); partyUiHandler.processInput(Button.ACTION);
// Stop next battle before it runs // Stop next battle before it runs
await game.phaseInterceptor.to(NewBattlePhase, false); await game.phaseInterceptor.to("NewBattlePhase", false);
const leadPokemon = scene.getPlayerParty()[0]; const leadPokemon = game.field.getPlayerPokemon();
expect(leadPokemon.customPokemonData?.ability).toBe(abilityToTrain); expect(leadPokemon.customPokemonData?.ability).toBe(abilityToTrain);
}); });
}); });
@ -263,30 +262,30 @@ describe("Clowning Around - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty);
// Set some moves on party for attack type booster generation // Set some moves on party for attack type booster generation
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.TACKLE), new PokemonMove(MoveId.THIEF)]; game.move.changeMoveset(game.field.getPlayerPokemon(), [MoveId.TACKLE, MoveId.THIEF]);
// 2 Sitrus Berries on lead // 2 Sitrus Berries on lead
scene.modifiers = []; scene.modifiers = [];
let itemType = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType; let itemType = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 2, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 2, itemType);
// 2 Ganlon Berries on lead // 2 Ganlon Berries on lead
itemType = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON]) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON]) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 2, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 2, itemType);
// 5 Golden Punch on lead (ultra) // 5 Golden Punch on lead (ultra)
itemType = generateModifierType(modifierTypes.GOLDEN_PUNCH) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.GOLDEN_PUNCH) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 5, itemType);
// 5 Lucky Egg on lead (ultra) // 5 Lucky Egg on lead (ultra)
itemType = generateModifierType(modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 5, itemType);
// 3 Soothe Bell on lead (great tier, but counted as ultra by this ME) // 3 Soothe Bell on lead (great tier, but counted as ultra by this ME)
itemType = generateModifierType(modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 3, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 3, itemType);
// 5 Soul Dew on lead (rogue) // 5 Soul Dew on lead (rogue)
itemType = generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 5, itemType);
// 2 Golden Egg on lead (rogue) // 2 Golden Egg on lead (rogue)
itemType = generateModifierType(modifierTypes.GOLDEN_EGG) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.GOLDEN_EGG) as PokemonHeldItemModifierType;
await addItemToPokemon(scene, scene.getPlayerParty()[0], 2, itemType); await addItemToPokemon(scene, game.field.getPlayerPokemon(), 2, itemType);
// 5 Soul Dew on second party pokemon (these should not change) // 5 Soul Dew on second party pokemon (these should not change)
itemType = generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType; itemType = generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType;
@ -294,7 +293,7 @@ describe("Clowning Around - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
const leadItemsAfter = scene.getPlayerParty()[0].getHeldItems(); const leadItemsAfter = game.field.getPlayerPokemon().getHeldItems();
const ultraCountAfter = leadItemsAfter const ultraCountAfter = leadItemsAfter
.filter(m => m.type.tier === ModifierTier.ULTRA) .filter(m => m.type.tier === ModifierTier.ULTRA)
.reduce((a, b) => a + b.stackCount, 0); .reduce((a, b) => a + b.stackCount, 0);
@ -348,14 +347,14 @@ describe("Clowning Around - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty);
// Same type moves on lead // Same type moves on lead
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.ICE_BEAM), new PokemonMove(MoveId.SURF)]; game.move.changeMoveset(game.field.getPlayerPokemon(), [MoveId.ICE_BEAM, MoveId.SURF]);
// Different type moves on second // Different type moves on second
scene.getPlayerParty()[1].moveset = [new PokemonMove(MoveId.GRASS_KNOT), new PokemonMove(MoveId.ELECTRO_BALL)]; game.move.changeMoveset(scene.getPlayerParty()[1], [MoveId.GRASS_KNOT, MoveId.ELECTRO_BALL]);
// No moves on third // No moves on third
scene.getPlayerParty()[2].moveset = []; scene.getPlayerParty()[2].moveset = [];
await runMysteryEncounterToEnd(game, 3); await runMysteryEncounterToEnd(game, 3);
const leadTypesAfter = scene.getPlayerParty()[0].getTypes(); const leadTypesAfter = game.field.getPlayerPokemon().getTypes();
const secondaryTypesAfter = scene.getPlayerParty()[1].getTypes(); const secondaryTypesAfter = scene.getPlayerParty()[1].getTypes();
const thirdTypesAfter = scene.getPlayerParty()[2].getTypes(); const thirdTypesAfter = scene.getPlayerParty()[2].getTypes();

View File

@ -6,7 +6,6 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
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 { PokemonMove } from "#moves/pokemon-move";
import { DancingLessonsEncounter } from "#mystery-encounters/dancing-lessons-encounter"; import { DancingLessonsEncounter } from "#mystery-encounters/dancing-lessons-encounter";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
@ -100,7 +99,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
// Make party lead's level arbitrarily high to not get KOed by move // Make party lead's level arbitrarily high to not get KOed by move
const partyLead = scene.getPlayerParty()[0]; const partyLead = game.field.getPlayerPokemon();
partyLead.level = 1000; partyLead.level = 1000;
partyLead.calculateStats(); partyLead.calculateStats();
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
@ -121,14 +120,14 @@ describe("Dancing Lessons - Mystery Encounter", () => {
it("should have a Baton in the rewards after battle", async () => { it("should have a Baton in the rewards after battle", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
// Make party lead's level arbitrarily high to not get KOed by move // Make party lead's level arbitrarily high to not get KOed by move
const partyLead = scene.getPlayerParty()[0]; const partyLead = game.field.getPlayerPokemon();
partyLead.level = 1000; partyLead.level = 1000;
partyLead.calculateStats(); partyLead.calculateStats();
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -159,7 +158,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
const phaseSpy = vi.spyOn(scene.phaseManager, "unshiftPhase"); const phaseSpy = vi.spyOn(scene.phaseManager, "unshiftPhase");
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
scene.getPlayerParty()[0].moveset = []; game.field.getPlayerPokemon().moveset = [];
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 }); await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof LearnMovePhase).map(p => p[0]); const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof LearnMovePhase).map(p => p[0]);
@ -171,7 +170,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
scene.getPlayerParty()[0].moveset = []; game.field.getPlayerPokemon().moveset = [];
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 }); await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
expect(leaveEncounterWithoutBattleSpy).toBeCalled(); expect(leaveEncounterWithoutBattleSpy).toBeCalled();
@ -199,7 +198,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
it("should add Oricorio to the party", async () => { it("should add Oricorio to the party", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
const partyCountBefore = scene.getPlayerParty().length; const partyCountBefore = scene.getPlayerParty().length;
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.DRAGON_DANCE)]; game.move.changeMoveset(game.field.getPlayerPokemon(), MoveId.DRAGON_DANCE);
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
const partyCountAfter = scene.getPlayerParty().length; const partyCountAfter = scene.getPlayerParty().length;
@ -215,7 +214,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
const partyCountBefore = scene.getPlayerParty().length; const partyCountBefore = scene.getPlayerParty().length;
scene.getPlayerParty().forEach(p => (p.moveset = [])); scene.getPlayerParty().forEach(p => (p.moveset = []));
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -238,7 +237,7 @@ describe("Dancing Lessons - Mystery Encounter", () => {
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty);
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.DRAGON_DANCE)]; game.move.changeMoveset(game.field.getPlayerPokemon(), MoveId.DRAGON_DANCE);
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
expect(leaveEncounterWithoutBattleSpy).toBeCalled(); expect(leaveEncounterWithoutBattleSpy).toBeCalled();

View File

@ -201,7 +201,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 2 Sitrus berries on party lead // Set 2 Sitrus berries on party lead
scene.modifiers = []; scene.modifiers = [];
const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!;
const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; const sitrusMod = sitrus.newModifier(game.field.getPlayerPokemon()) as BerryModifier;
sitrusMod.stackCount = 2; sitrusMod.stackCount = 2;
scene.addModifier(sitrusMod, true, false, false, true); scene.addModifier(sitrusMod, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -222,7 +222,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Reviver Seed on party lead // Set 1 Reviver Seed on party lead
scene.modifiers = []; scene.modifiers = [];
const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!; const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!;
const modifier = revSeed.newModifier(scene.getPlayerParty()[0]) as PokemonInstantReviveModifier; const modifier = revSeed.newModifier(game.field.getPlayerPokemon()) as PokemonInstantReviveModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -248,7 +248,7 @@ describe("Delibird-y - Mystery Encounter", () => {
const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!;
// Sitrus berries on party // Sitrus berries on party
const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; const sitrusMod = sitrus.newModifier(game.field.getPlayerPokemon()) as BerryModifier;
sitrusMod.stackCount = 2; sitrusMod.stackCount = 2;
scene.addModifier(sitrusMod, true, false, false, true); scene.addModifier(sitrusMod, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -277,7 +277,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Reviver Seed on party lead // Set 1 Reviver Seed on party lead
const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!; const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!;
const modifier = revSeed.newModifier(scene.getPlayerParty()[0]) as PokemonInstantReviveModifier; const modifier = revSeed.newModifier(game.field.getPlayerPokemon()) as PokemonInstantReviveModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -301,7 +301,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Soul Dew on party lead // Set 1 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]); const modifier = soulDew.newModifier(game.field.getPlayerPokemon());
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -329,7 +329,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Reviver Seed on party lead // Set 1 Reviver Seed on party lead
const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!; const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!;
const modifier = revSeed.newModifier(scene.getPlayerParty()[0]) as PokemonInstantReviveModifier; const modifier = revSeed.newModifier(game.field.getPlayerPokemon()) as PokemonInstantReviveModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -363,7 +363,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 2 Soul Dew on party lead // Set 2 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 2; modifier.stackCount = 2;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -384,7 +384,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Soul Dew on party lead // Set 1 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -410,7 +410,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Soul Dew on party lead // Set 1 Soul Dew on party lead
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -434,7 +434,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Reviver Seed on party lead // Set 1 Reviver Seed on party lead
scene.modifiers = []; scene.modifiers = [];
const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!; const revSeed = generateModifierType(modifierTypes.REVIVER_SEED)!;
const modifier = revSeed.newModifier(scene.getPlayerParty()[0]); const modifier = revSeed.newModifier(game.field.getPlayerPokemon());
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -463,7 +463,7 @@ describe("Delibird-y - Mystery Encounter", () => {
// Set 1 Soul Dew on party lead // Set 1 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);

View File

@ -94,7 +94,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 1); await runMysteryEncounterToEnd(game, 1);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -131,7 +131,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -171,7 +171,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 3); await runMysteryEncounterToEnd(game, 3);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -211,7 +211,7 @@ describe("Department Store Sale - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty);
await runMysteryEncounterToEnd(game, 4); await runMysteryEncounterToEnd(game, 4);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -6,7 +6,6 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
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 { PokemonMove } from "#moves/pokemon-move";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import { FightOrFlightEncounter } from "#mystery-encounters/fight-or-flight-encounter"; import { FightOrFlightEncounter } from "#mystery-encounters/fight-or-flight-encounter";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
@ -122,9 +121,9 @@ describe("Fight or Flight - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -155,7 +154,7 @@ describe("Fight or Flight - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't have a Stealing move", async () => { it("should NOT be selectable if the player doesn't have a Stealing move", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty);
scene.getPlayerParty().forEach(p => (p.moveset = [])); scene.getPlayerParty().forEach(p => (p.moveset = []));
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -178,13 +177,13 @@ describe("Fight or Flight - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty);
// Mock moveset // Mock moveset
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.KNOCK_OFF)]; game.move.changeMoveset(game.field.getPlayerPokemon(), MoveId.KNOCK_OFF);
const item = game.scene.currentBattle.mysteryEncounter!.misc; const item = game.scene.currentBattle.mysteryEncounter!.misc;
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -120,7 +120,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't have enough money", async () => { it("should NOT be selectable if the player doesn't have enough money", async () => {
game.scene.money = 0; game.scene.money = 0;
await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -162,7 +162,7 @@ describe("Fun And Games! - Mystery Encounter", () => {
// Turn 3 // Turn 3
(game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards // Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
@ -181,11 +181,11 @@ describe("Fun And Games! - Mystery Encounter", () => {
// Skip minigame // Skip minigame
scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0;
(game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards // Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -210,11 +210,11 @@ describe("Fun And Games! - Mystery Encounter", () => {
wobbuffet.hp = Math.floor(0.2 * wobbuffet.getMaxHp()); wobbuffet.hp = Math.floor(0.2 * wobbuffet.getMaxHp());
scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0;
(game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards // Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -240,11 +240,11 @@ describe("Fun And Games! - Mystery Encounter", () => {
wobbuffet.hp = Math.floor(0.1 * wobbuffet.getMaxHp()); wobbuffet.hp = Math.floor(0.1 * wobbuffet.getMaxHp());
scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0;
(game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards // Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -270,11 +270,11 @@ describe("Fun And Games! - Mystery Encounter", () => {
wobbuffet.hp = 1; wobbuffet.hp = 1;
scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0;
(game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
// Rewards // Rewards
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -105,14 +105,14 @@ describe("Global Trade System - Mystery Encounter", () => {
it("Should trade a Pokemon from the player's party for the first of 3 Pokemon options", async () => { it("Should trade a Pokemon from the player's party for the first of 3 Pokemon options", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.GLOBAL_TRADE_SYSTEM, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.GLOBAL_TRADE_SYSTEM, defaultParty);
const speciesBefore = scene.getPlayerParty()[0].species.speciesId; const speciesBefore = game.field.getPlayerPokemon().species.speciesId;
await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 1 }); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 1 });
const speciesAfter = scene.getPlayerParty().at(-1)?.species.speciesId; const speciesAfter = scene.getPlayerParty().at(-1)?.species.speciesId;
expect(speciesAfter).toBeDefined(); expect(speciesAfter).toBeDefined();
expect(speciesBefore).not.toBe(speciesAfter); expect(speciesBefore).not.toBe(speciesAfter);
expect(defaultParty.includes(speciesAfter!)).toBeFalsy(); expect(defaultParty).not.toContain(speciesAfter);
}); });
it("Should trade a Pokemon from the player's party for the second of 3 Pokemon options", async () => { it("Should trade a Pokemon from the player's party for the second of 3 Pokemon options", async () => {
@ -220,14 +220,14 @@ describe("Global Trade System - Mystery Encounter", () => {
// Set 2 Soul Dew on party lead // Set 2 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 2; modifier.stackCount = 2;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 });
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -247,7 +247,7 @@ describe("Global Trade System - Mystery Encounter", () => {
// Set 1 Soul Dew on party lead // Set 1 Soul Dew on party lead
scene.modifiers = []; scene.modifiers = [];
const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!; const soulDew = generateModifierType(modifierTypes.SOUL_DEW)!;
const modifier = soulDew.newModifier(scene.getPlayerParty()[0]) as PokemonNatureWeightModifier; const modifier = soulDew.newModifier(game.field.getPlayerPokemon()) as PokemonNatureWeightModifier;
modifier.stackCount = 1; modifier.stackCount = 1;
scene.addModifier(modifier, true, false, false, true); scene.addModifier(modifier, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);

View File

@ -161,9 +161,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -205,9 +205,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 2, undefined, true); await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -262,9 +262,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty);
await runMysteryEncounterToEnd(game, 3, undefined, true); await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -5,7 +5,6 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { PokemonMove } from "#moves/pokemon-move";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { CIVILIZATION_ENCOUNTER_BIOMES } from "#mystery-encounters/mystery-encounters"; import { CIVILIZATION_ENCOUNTER_BIOMES } from "#mystery-encounters/mystery-encounters";
@ -110,7 +109,7 @@ describe("Part-Timer - Mystery Encounter", () => {
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene.getWaveMoneyAmount(1), true, false); expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene.getWaveMoneyAmount(1), true, false);
// Expect PP of mon's moves to have been reduced to 2 // Expect PP of mon's moves to have been reduced to 2
const moves = scene.getPlayerParty()[0].moveset; const moves = game.field.getPlayerPokemon().moveset;
for (const move of moves) { for (const move of moves) {
expect((move?.getMovePp() ?? 0) - (move?.ppUsed ?? 0)).toBe(2); expect((move?.getMovePp() ?? 0) - (move?.ppUsed ?? 0)).toBe(2);
} }
@ -233,7 +232,9 @@ describe("Part-Timer - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
// Mock movesets // Mock movesets
scene.getPlayerParty().forEach(p => (p.moveset = [])); scene.getPlayerParty().forEach(p => {
p.moveset = [];
});
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to(MysteryEncounterPhase, false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
@ -257,14 +258,14 @@ describe("Part-Timer - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty);
// Mock moveset // Mock moveset
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.ATTRACT)]; game.move.changeMoveset(game.field.getPlayerPokemon(), MoveId.ATTRACT);
await runMysteryEncounterToEnd(game, 3); await runMysteryEncounterToEnd(game, 3);
expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene.getWaveMoneyAmount(2.5), true, false); expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene.getWaveMoneyAmount(2.5), true, false);
// Expect PP of mon's moves to have been reduced to 2 // Expect PP of mon's moves to have been reduced to 2
const moves = scene.getPlayerParty()[0].moveset; const moves = game.field.getPlayerPokemon().moveset;
for (const move of moves) { for (const move of moves) {
expect((move?.getMovePp() ?? 0) - (move?.ppUsed ?? 0)).toBe(2); expect(move.getMovePp() - move.ppUsed).toBe(2);
} }
}); });

View File

@ -146,7 +146,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't have enough money", async () => { it("should NOT be selectable if the player doesn't have enough money", async () => {
game.scene.money = 0; game.scene.money = 0;
await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -218,7 +218,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
it("should NOT be selectable if the player doesn't the right type pokemon", async () => { it("should NOT be selectable if the player doesn't the right type pokemon", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [SpeciesId.BLASTOISE]); await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [SpeciesId.BLASTOISE]);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
const encounterPhase = scene.phaseManager.getCurrentPhase(); const encounterPhase = scene.phaseManager.getCurrentPhase();
expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name);
@ -299,9 +299,9 @@ describe("Teleporting Hijinks - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty);
await runMysteryEncounterToEnd(game, 3, undefined, true); await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -13,7 +13,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters"; import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { TheExpertPokemonBreederEncounter } from "#mystery-encounters/the-expert-pokemon-breeder-encounter"; import { TheExpertPokemonBreederEncounter } from "#mystery-encounters/the-expert-pokemon-breeder-encounter";
import { CommandPhase } from "#phases/command-phase"; import { CommandPhase } from "#phases/command-phase";
import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { import {
runMysteryEncounterToEnd, runMysteryEncounterToEnd,
@ -70,7 +69,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
text: `${namespace}:intro`, text: `${namespace}:intro`,
}, },
{ {
speaker: "trainerNames:expert_pokemon_breeder", speaker: "trainerNames:expertPokemonBreeder",
text: `${namespace}:introDialogue`, text: `${namespace}:introDialogue`,
}, },
]); ]);
@ -123,7 +122,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
buttonTooltip: expect.any(String), // Varies based on pokemon buttonTooltip: expect.any(String), // Varies based on pokemon
selected: [ selected: [
{ {
speaker: "trainerNames:expert_pokemon_breeder", speaker: "trainerNames:expertPokemonBreeder",
text: `${namespace}:option.selected`, text: `${namespace}:option.selected`,
}, },
], ],
@ -176,7 +175,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 1, undefined, true); await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const eggsAfter = scene.gameData.eggs; const eggsAfter = scene.gameData.eggs;
@ -187,8 +186,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.endPhase();
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship;
// 20 from ME + extra from winning battle (that extra is not accurate to what happens in game. // 20 from ME + extra from winning battle (that extra is not accurate to what happens in game.
@ -208,7 +207,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
buttonTooltip: expect.any(String), // Varies based on pokemon buttonTooltip: expect.any(String), // Varies based on pokemon
selected: [ selected: [
{ {
speaker: "trainerNames:expert_pokemon_breeder", speaker: "trainerNames:expertPokemonBreeder",
text: `${namespace}:option.selected`, text: `${namespace}:option.selected`,
}, },
], ],
@ -261,7 +260,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 2, undefined, true); await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const eggsAfter = scene.gameData.eggs; const eggsAfter = scene.gameData.eggs;
@ -272,8 +271,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.endPhase();
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship;
expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 from ME + extra for friendship gained from winning battle expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 from ME + extra for friendship gained from winning battle
@ -290,7 +289,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
buttonTooltip: expect.any(String), // Varies based on pokemon buttonTooltip: expect.any(String), // Varies based on pokemon
selected: [ selected: [
{ {
speaker: "trainerNames:expert_pokemon_breeder", speaker: "trainerNames:expertPokemonBreeder",
text: `${namespace}:option.selected`, text: `${namespace}:option.selected`,
}, },
], ],
@ -343,7 +342,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
await runMysteryEncounterToEnd(game, 3, undefined, true); await runMysteryEncounterToEnd(game, 3, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const eggsAfter = scene.gameData.eggs; const eggsAfter = scene.gameData.eggs;
@ -354,8 +353,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => {
expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs);
expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs);
game.phaseInterceptor.superEndPhase(); game.endPhase();
await game.phaseInterceptor.to(PostMysteryEncounterPhase); await game.phaseInterceptor.to("PostMysteryEncounterPhase");
const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship; const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship;
expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 + extra for friendship gained from winning battle expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 + extra for friendship gained from winning battle

View File

@ -71,7 +71,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
]); ]);
const { title, description, query } = dialogue.encounterOptionsDialogue!; const { title, description, query } = dialogue.encounterOptionsDialogue!;
expect(title).toBe(`${namespace}:title`); expect(title).toBe(`${namespace}:title`);
expect(description).toMatch(new RegExp(`^${namespace}\\:description(_shiny)?$`)); expect(description).toMatch(new RegExp(`^${namespace}\\:description(Shiny)?$`));
expect(query).toBe(`${namespace}:query`); expect(query).toBe(`${namespace}:query`);
expect(options.length).toBe(2); expect(options.length).toBe(2);
}); });
@ -117,7 +117,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
expect(dialogue).toBeDefined(); expect(dialogue).toBeDefined();
expect(dialogue).toStrictEqual({ expect(dialogue).toStrictEqual({
buttonLabel: `${namespace}:option.1.label`, buttonLabel: `${namespace}:option.1.label`,
buttonTooltip: expect.stringMatching(new RegExp(`^${namespace}\\:option\\.1\\.tooltip(_shiny)?$`)), buttonTooltip: expect.stringMatching(new RegExp(`^${namespace}\\:option\\.1\\.tooltip(Shiny)?$`)),
selected: [ selected: [
{ {
text: `${namespace}:option.1.selectedMessage`, text: `${namespace}:option.1.selectedMessage`,

View File

@ -229,9 +229,9 @@ describe("The Strong Stuff - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.THE_STRONG_STUFF, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.THE_STRONG_STUFF, defaultParty);
await runMysteryEncounterToEnd(game, 2, undefined, true); await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -16,7 +16,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters"; import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters";
import { TheWinstrateChallengeEncounter } from "#mystery-encounters/the-winstrate-challenge-encounter"; import { TheWinstrateChallengeEncounter } from "#mystery-encounters/the-winstrate-challenge-encounter";
import { CommandPhase } from "#phases/command-phase"; import { CommandPhase } from "#phases/command-phase";
import { MysteryEncounterRewardsPhase } from "#phases/mystery-encounter-phases";
import { PartyHealPhase } from "#phases/party-heal-phase"; import { PartyHealPhase } from "#phases/party-heal-phase";
import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { SelectModifierPhase } from "#phases/select-modifier-phase";
import { VictoryPhase } from "#phases/victory-phase"; import { VictoryPhase } from "#phases/victory-phase";
@ -295,9 +294,9 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
// Should have Macho Brace in the rewards // Should have Macho Brace in the rewards
await skipBattleToNextBattle(game, true); await skipBattleToNextBattle(game, true);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -339,7 +338,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.THE_WINSTRATE_CHALLENGE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.THE_WINSTRATE_CHALLENGE, defaultParty);
await runMysteryEncounterToEnd(game, 2); await runMysteryEncounterToEnd(game, 2);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -366,11 +365,10 @@ async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false)
p.status = new Status(StatusEffect.FAINT); p.status = new Status(StatusEffect.FAINT);
game.scene.field.remove(p); game.scene.field.remove(p);
}); });
game.phaseInterceptor["onHold"] = [];
game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.scene.phaseManager.pushPhase(new VictoryPhase(0));
game.phaseInterceptor.superEndPhase(); game.endPhase();
if (isFinalBattle) { if (isFinalBattle) {
await game.phaseInterceptor.to(MysteryEncounterRewardsPhase); await game.phaseInterceptor.to("MysteryEncounterRewardsPhase");
} else { } else {
await game.toNextTurn(); await game.toNextTurn();
} }

View File

@ -172,7 +172,7 @@ describe("Trash to Treasure - Mystery Encounter", () => {
it("should give 2 Leftovers, 1 Shell Bell, and Black Sludge", async () => { it("should give 2 Leftovers, 1 Shell Bell, and Black Sludge", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty);
await runMysteryEncounterToEnd(game, 1); await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const leftovers = scene.findModifier(m => m instanceof TurnHealModifier) as TurnHealModifier; const leftovers = scene.findModifier(m => m instanceof TurnHealModifier) as TurnHealModifier;
@ -242,9 +242,9 @@ describe("Trash to Treasure - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty);
await runMysteryEncounterToEnd(game, 2, undefined, true); await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -11,7 +11,6 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import type { BerryModifier } from "#modifiers/modifier"; import type { BerryModifier } from "#modifiers/modifier";
import { PokemonMove } from "#moves/pokemon-move";
import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils"; import * as EncounterPhaseUtils from "#mystery-encounters/encounter-phase-utils";
import { generateModifierType } from "#mystery-encounters/encounter-phase-utils"; import { generateModifierType } from "#mystery-encounters/encounter-phase-utils";
import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import * as MysteryEncounters from "#mystery-encounters/mystery-encounters";
@ -214,11 +213,11 @@ describe("Uncommon Breed - Mystery Encounter", () => {
// Berries on party lead // Berries on party lead
const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!;
const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; const sitrusMod = sitrus.newModifier(game.field.getPlayerPokemon()) as BerryModifier;
sitrusMod.stackCount = 2; sitrusMod.stackCount = 2;
scene.addModifier(sitrusMod, true, false, false, true); scene.addModifier(sitrusMod, true, false, false, true);
const ganlon = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON])!; const ganlon = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON])!;
const ganlonMod = ganlon.newModifier(scene.getPlayerParty()[0]) as BerryModifier; const ganlonMod = ganlon.newModifier(game.field.getPlayerPokemon()) as BerryModifier;
ganlonMod.stackCount = 3; ganlonMod.stackCount = 3;
scene.addModifier(ganlonMod, true, false, false, true); scene.addModifier(ganlonMod, true, false, false, true);
await scene.updateModifiers(true); await scene.updateModifiers(true);
@ -270,7 +269,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
// Mock moveset // Mock moveset
scene.getPlayerParty()[0].moveset = [new PokemonMove(MoveId.CHARM)]; game.move.changeMoveset(game.field.getPlayerPokemon(), MoveId.CHARM);
await runMysteryEncounterToEnd(game, 3); await runMysteryEncounterToEnd(game, 3);
expect(leaveEncounterWithoutBattleSpy).toBeCalled(); expect(leaveEncounterWithoutBattleSpy).toBeCalled();

View File

@ -116,7 +116,7 @@ describe("Weird Dream - Mystery Encounter", () => {
const bstsPrior = pokemonPrior.map(species => species.getSpeciesForm().getBaseStatTotal()); const bstsPrior = pokemonPrior.map(species => species.getSpeciesForm().getBaseStatTotal());
await runMysteryEncounterToEnd(game, 1); await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
const pokemonAfter = scene.getPlayerParty(); const pokemonAfter = scene.getPlayerParty();
@ -139,9 +139,9 @@ describe("Weird Dream - Mystery Encounter", () => {
it("should have 1 Memory Mushroom, 5 Rogue Balls, and 3 Mints in rewards", async () => { it("should have 1 Memory Mushroom, 5 Rogue Balls, and 3 Mints in rewards", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty);
await runMysteryEncounterToEnd(game, 1); await runMysteryEncounterToEnd(game, 1);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -196,9 +196,9 @@ describe("Weird Dream - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty);
await runMysteryEncounterToEnd(game, 2, undefined, true); await runMysteryEncounterToEnd(game, 2, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game); await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -38,7 +38,7 @@ describe("Form Change Phase", () => {
await game.classicMode.startBattle([SpeciesId.ZACIAN]); await game.classicMode.startBattle([SpeciesId.ZACIAN]);
// Before the form change: Should be Hero form // Before the form change: Should be Hero form
const zacian = game.scene.getPlayerParty()[0]; const zacian = game.field.getPlayerPokemon();
expect(zacian.getFormKey()).toBe("hero-of-many-battles"); expect(zacian.getFormKey()).toBe("hero-of-many-battles");
expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY]); expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY]);
expect(zacian.calculateBaseStats()).toStrictEqual([92, 120, 115, 80, 115, 138]); expect(zacian.calculateBaseStats()).toStrictEqual([92, 120, 115, 80, 115, 138]);

View File

@ -37,7 +37,7 @@ describe("Mystery Encounter Phases", () => {
SpeciesId.VOLCARONA, SpeciesId.VOLCARONA,
]); ]);
await game.phaseInterceptor.to(MysteryEncounterPhase, false); await game.phaseInterceptor.to("MysteryEncounterPhase", false);
expect(game.scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name); expect(game.scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
}); });
@ -49,9 +49,9 @@ describe("Mystery Encounter Phases", () => {
game.onNextPrompt("MysteryEncounterPhase", UiMode.MYSTERY_ENCOUNTER, () => { game.onNextPrompt("MysteryEncounterPhase", UiMode.MYSTERY_ENCOUNTER, () => {
// End phase early for test // End phase early for test
game.phaseInterceptor.superEndPhase(); game.endPhase();
}); });
await game.phaseInterceptor.run(MysteryEncounterPhase); await game.phaseInterceptor.to("MysteryEncounterPhase");
expect(game.scene.mysteryEncounterSaveData.encounteredEvents.length).toBeGreaterThan(0); expect(game.scene.mysteryEncounterSaveData.encounteredEvents.length).toBeGreaterThan(0);
expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual( expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual(
@ -75,7 +75,7 @@ describe("Mystery Encounter Phases", () => {
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.run(MysteryEncounterPhase); await game.phaseInterceptor.to("MysteryEncounterPhase");
// Select option 1 for encounter // Select option 1 for encounter
const handler = game.scene.ui.getHandler() as MysteryEncounterUiHandler; const handler = game.scene.ui.getHandler() as MysteryEncounterUiHandler;

View File

@ -241,7 +241,7 @@ describe("SelectModifierPhase", () => {
const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers);
scene.phaseManager.unshiftPhase(selectModifierPhase); scene.phaseManager.unshiftPhase(selectModifierPhase);
game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(
@ -265,7 +265,7 @@ describe("SelectModifierPhase", () => {
const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers);
scene.phaseManager.unshiftPhase(selectModifierPhase); scene.phaseManager.unshiftPhase(selectModifierPhase);
game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH);
await game.phaseInterceptor.run(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT);
const modifierSelectHandler = scene.ui.handlers.find( const modifierSelectHandler = scene.ui.handlers.find(

View File

@ -20,13 +20,11 @@ import { ModifierTypeOption } from "#modifiers/modifier-type";
import { CheckSwitchPhase } from "#phases/check-switch-phase"; import { CheckSwitchPhase } from "#phases/check-switch-phase";
import { CommandPhase } from "#phases/command-phase"; import { CommandPhase } from "#phases/command-phase";
import { EncounterPhase } from "#phases/encounter-phase"; import { EncounterPhase } from "#phases/encounter-phase";
import { LoginPhase } from "#phases/login-phase";
import { MovePhase } from "#phases/move-phase"; import { MovePhase } from "#phases/move-phase";
import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases"; import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases";
import { NewBattlePhase } from "#phases/new-battle-phase"; import { NewBattlePhase } from "#phases/new-battle-phase";
import { SelectStarterPhase } from "#phases/select-starter-phase"; import { SelectStarterPhase } from "#phases/select-starter-phase";
import type { SelectTargetPhase } from "#phases/select-target-phase"; import type { SelectTargetPhase } from "#phases/select-target-phase";
import { TitlePhase } from "#phases/title-phase";
import { TurnEndPhase } from "#phases/turn-end-phase"; import { TurnEndPhase } from "#phases/turn-end-phase";
import { TurnInitPhase } from "#phases/turn-init-phase"; import { TurnInitPhase } from "#phases/turn-init-phase";
import { TurnStartPhase } from "#phases/turn-start-phase"; import { TurnStartPhase } from "#phases/turn-start-phase";
@ -188,10 +186,12 @@ export class GameManager {
* @returns A promise that resolves when the title phase is reached. * @returns A promise that resolves when the title phase is reached.
*/ */
async runToTitle(): Promise<void> { async runToTitle(): Promise<void> {
await this.phaseInterceptor.whenAboutToRun(LoginPhase); // Go to login phase and skip past it
this.phaseInterceptor.pop(); await this.phaseInterceptor.to("LoginPhase", false);
await this.phaseInterceptor.run(TitlePhase); this.phaseInterceptor.shiftPhase(true);
await this.phaseInterceptor.to("TitlePhase");
// TODO: This should be moved to a separate initialization method
this.scene.gameSpeed = 5; this.scene.gameSpeed = 5;
this.scene.moveAnimations = false; this.scene.moveAnimations = false;
this.scene.showLevelUpStats = false; this.scene.showLevelUpStats = false;
@ -270,7 +270,7 @@ export class GameManager {
true, true,
); );
await this.phaseInterceptor.run(EncounterPhase); await this.phaseInterceptor.to("EncounterPhase");
if (!isNullOrUndefined(encounterType)) { if (!isNullOrUndefined(encounterType)) {
expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType); expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType);
} }
@ -542,7 +542,7 @@ export class GameManager {
* ``` * ```
*/ */
async setTurnOrder(order: BattlerIndex[]): Promise<void> { async setTurnOrder(order: BattlerIndex[]): Promise<void> {
await this.phaseInterceptor.to(TurnStartPhase, false); await this.phaseInterceptor.to("TurnStartPhase", false);
vi.spyOn(this.scene.phaseManager.getCurrentPhase() as TurnStartPhase, "getSpeedOrder").mockReturnValue(order); vi.spyOn(this.scene.phaseManager.getCurrentPhase() as TurnStartPhase, "getSpeedOrder").mockReturnValue(order);
} }

View File

@ -49,7 +49,7 @@ export class ChallengeModeHelper extends GameManagerHelper {
selectStarterPhase.initBattle(starters); selectStarterPhase.initBattle(starters);
}); });
await this.game.phaseInterceptor.run(EncounterPhase); await this.game.phaseInterceptor.to("EncounterPhase");
if (overrides.ENEMY_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) { if (overrides.ENEMY_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) {
this.game.removeEnemyHeldItems(); this.game.removeEnemyHeldItems();
} }

View File

@ -57,7 +57,7 @@ export class ReloadHelper extends GameManagerHelper {
this.game.scene.modifiers = []; this.game.scene.modifiers = [];
} }
titlePhase.loadSaveSlot(-1); // Load the desired session data titlePhase.loadSaveSlot(-1); // Load the desired session data
this.game.phaseInterceptor.shift(); // Loading the save slot also ended TitlePhase, clean it up this.game.phaseInterceptor.shiftPhase(); // Loading the save slot also ended TitlePhase, clean it up
// Run through prompts for switching Pokemon, copied from classicModeHelper.ts // Run through prompts for switching Pokemon, copied from classicModeHelper.ts
if (this.game.scene.battleStyle === BattleStyle.SWITCH) { if (this.game.scene.battleStyle === BattleStyle.SWITCH) {

View File

@ -1,3 +1,4 @@
import type { BattleScene } from "#app/battle-scene";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { AttemptRunPhase } from "#phases/attempt-run-phase"; import { AttemptRunPhase } from "#phases/attempt-run-phase";
@ -64,6 +65,7 @@ import { UnlockPhase } from "#phases/unlock-phase";
import { VictoryPhase } from "#phases/victory-phase"; import { VictoryPhase } from "#phases/victory-phase";
import { ErrorInterceptor } from "#test/test-utils/error-interceptor"; import { ErrorInterceptor } from "#test/test-utils/error-interceptor";
import type { PhaseClass, PhaseString } from "#types/phase-types"; import type { PhaseClass, PhaseString } from "#types/phase-types";
import type { AwaitableUiHandler } from "#ui/awaitable-ui-handler";
import { UI } from "#ui/ui"; import { UI } from "#ui/ui";
export interface PromptHandler { export interface PromptHandler {
@ -76,20 +78,39 @@ export interface PromptHandler {
type PhaseInterceptorPhase = PhaseClass | PhaseString; type PhaseInterceptorPhase = PhaseClass | PhaseString;
interface PhaseStub {
start(): void;
endBySetMode: boolean;
}
interface InProgressStub {
name: string;
callback(): void;
onError(error: any): void;
}
interface onHoldStub {
name: string;
call(): void;
}
export class PhaseInterceptor { export class PhaseInterceptor {
public scene; public scene: BattleScene;
public phases = {}; // @ts-expect-error: initialized in `initPhases`
public log: string[]; public phases: Record<PhaseString, PhaseStub> = {};
private onHold; public log: PhaseString[];
private interval; /**
private promptInterval; * TODO: This should not be an array;
private intervalRun; * Our linear phase system means only 1 phase is ever started at once (if any)
*/
private onHold: onHoldStub[];
private interval: NodeJS.Timeout;
private promptInterval: NodeJS.Timeout;
private intervalRun: NodeJS.Timeout;
private prompts: PromptHandler[]; private prompts: PromptHandler[];
private phaseFrom; private inProgress?: InProgressStub;
private inProgress; private originalSetMode: UI["setMode"];
private originalSetMode; private originalSuperEnd: Phase["end"];
private originalSetOverlayMode;
private originalSuperEnd;
/** /**
* List of phases with their corresponding start methods. * List of phases with their corresponding start methods.
@ -100,72 +121,73 @@ export class PhaseInterceptor {
* `initPhases()` so that its subclasses can use `super.start()` properly. * `initPhases()` so that its subclasses can use `super.start()` properly.
*/ */
private PHASES = [ private PHASES = [
[LoginPhase, this.startPhase], LoginPhase,
[TitlePhase, this.startPhase], TitlePhase,
[SelectGenderPhase, this.startPhase], SelectGenderPhase,
[NewBiomeEncounterPhase, this.startPhase], NewBiomeEncounterPhase,
[SelectStarterPhase, this.startPhase], SelectStarterPhase,
[PostSummonPhase, this.startPhase], PostSummonPhase,
[SummonPhase, this.startPhase], SummonPhase,
[ToggleDoublePositionPhase, this.startPhase], ToggleDoublePositionPhase,
[CheckSwitchPhase, this.startPhase], CheckSwitchPhase,
[ShowAbilityPhase, this.startPhase], ShowAbilityPhase,
[MessagePhase, this.startPhase], MessagePhase,
[TurnInitPhase, this.startPhase], TurnInitPhase,
[CommandPhase, this.startPhase], CommandPhase,
[EnemyCommandPhase, this.startPhase], EnemyCommandPhase,
[TurnStartPhase, this.startPhase], TurnStartPhase,
[MovePhase, this.startPhase], MovePhase,
[MoveEffectPhase, this.startPhase], MoveEffectPhase,
[DamageAnimPhase, this.startPhase], DamageAnimPhase,
[FaintPhase, this.startPhase], FaintPhase,
[BerryPhase, this.startPhase], BerryPhase,
[TurnEndPhase, this.startPhase], TurnEndPhase,
[BattleEndPhase, this.startPhase], BattleEndPhase,
[EggLapsePhase, this.startPhase], EggLapsePhase,
[SelectModifierPhase, this.startPhase], SelectModifierPhase,
[NextEncounterPhase, this.startPhase], NextEncounterPhase,
[NewBattlePhase, this.startPhase], NewBattlePhase,
[VictoryPhase, this.startPhase], VictoryPhase,
[LearnMovePhase, this.startPhase], LearnMovePhase,
[MoveEndPhase, this.startPhase], MoveEndPhase,
[StatStageChangePhase, this.startPhase], StatStageChangePhase,
[ShinySparklePhase, this.startPhase], ShinySparklePhase,
[SelectTargetPhase, this.startPhase], SelectTargetPhase,
[UnavailablePhase, this.startPhase], UnavailablePhase,
[QuietFormChangePhase, this.startPhase], QuietFormChangePhase,
[SwitchPhase, this.startPhase], SwitchPhase,
[SwitchSummonPhase, this.startPhase], SwitchSummonPhase,
[PartyHealPhase, this.startPhase], PartyHealPhase,
[FormChangePhase, this.startPhase], FormChangePhase,
[EvolutionPhase, this.startPhase], EvolutionPhase,
[EndEvolutionPhase, this.startPhase], EndEvolutionPhase,
[LevelCapPhase, this.startPhase], LevelCapPhase,
[AttemptRunPhase, this.startPhase], AttemptRunPhase,
[SelectBiomePhase, this.startPhase], SelectBiomePhase,
[PositionalTagPhase, this.startPhase], PositionalTagPhase,
[PokemonTransformPhase, this.startPhase], PokemonTransformPhase,
[MysteryEncounterPhase, this.startPhase], MysteryEncounterPhase,
[MysteryEncounterOptionSelectedPhase, this.startPhase], MysteryEncounterOptionSelectedPhase,
[MysteryEncounterBattlePhase, this.startPhase], MysteryEncounterBattlePhase,
[MysteryEncounterRewardsPhase, this.startPhase], MysteryEncounterRewardsPhase,
[PostMysteryEncounterPhase, this.startPhase], PostMysteryEncounterPhase,
[RibbonModifierRewardPhase, this.startPhase], RibbonModifierRewardPhase,
[GameOverModifierRewardPhase, this.startPhase], GameOverModifierRewardPhase,
[ModifierRewardPhase, this.startPhase], ModifierRewardPhase,
[PartyExpPhase, this.startPhase], PartyExpPhase,
[ExpPhase, this.startPhase], ExpPhase,
[EncounterPhase, this.startPhase], EncounterPhase,
[GameOverPhase, this.startPhase], GameOverPhase,
[UnlockPhase, this.startPhase], UnlockPhase,
[PostGameOverPhase, this.startPhase], PostGameOverPhase,
[RevivalBlessingPhase, this.startPhase], RevivalBlessingPhase,
]; ];
private endBySetMode = [ private endBySetMode = [
TitlePhase, TitlePhase,
SelectGenderPhase, SelectGenderPhase,
CommandPhase, CommandPhase,
SelectStarterPhase,
SelectModifierPhase, SelectModifierPhase,
MysteryEncounterPhase, MysteryEncounterPhase,
PostMysteryEncounterPhase, PostMysteryEncounterPhase,
@ -175,7 +197,7 @@ export class PhaseInterceptor {
* Constructor to initialize the scene and properties, and to start the phase handling. * Constructor to initialize the scene and properties, and to start the phase handling.
* @param scene - The scene to be managed. * @param scene - The scene to be managed.
*/ */
constructor(scene) { constructor(scene: BattleScene) {
this.scene = scene; this.scene = scene;
this.onHold = []; this.onHold = [];
this.prompts = []; this.prompts = [];
@ -200,16 +222,6 @@ export class PhaseInterceptor {
} }
} }
/**
* Method to set the starting phase.
* @param phaseFrom - The phase to start from.
* @returns The instance of the PhaseInterceptor.
*/
runFrom(phaseFrom: PhaseInterceptorPhase): PhaseInterceptor {
this.phaseFrom = phaseFrom;
return this;
}
/** /**
* Method to transition to a target phase. * Method to transition to a target phase.
* @param phaseTo - The phase to transition to. * @param phaseTo - The phase to transition to.
@ -219,59 +231,50 @@ export class PhaseInterceptor {
async to(phaseTo: PhaseInterceptorPhase, runTarget = true): Promise<void> { async to(phaseTo: PhaseInterceptorPhase, runTarget = true): Promise<void> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
ErrorInterceptor.getInstance().add(this); ErrorInterceptor.getInstance().add(this);
if (this.phaseFrom) {
await this.run(this.phaseFrom).catch(e => reject(e));
this.phaseFrom = null;
}
const targetName = typeof phaseTo === "string" ? phaseTo : phaseTo.name; const targetName = typeof phaseTo === "string" ? phaseTo : phaseTo.name;
this.intervalRun = setInterval(async () => { this.intervalRun = setInterval(async () => {
const currentPhase = this.onHold?.length && this.onHold[0]; const currentPhase = this.onHold?.length && this.onHold[0];
if (currentPhase && currentPhase.name === targetName) { if (!currentPhase) {
clearInterval(this.intervalRun); // No current phase means the manager either hasn't started yet
if (!runTarget) { // or we were interrupted by prompt; wait for phase to finish
return resolve(); return;
} }
await this.run(currentPhase).catch(e => {
// If current phase is different, run it and wait for it to finish.
if (currentPhase.name !== targetName) {
await this.run().catch(e => {
clearInterval(this.intervalRun); clearInterval(this.intervalRun);
return reject(e); return reject(e);
}); });
return;
}
// Hit target phase; run it and resolve
clearInterval(this.intervalRun);
if (!runTarget) {
return resolve(); return resolve();
} }
if (currentPhase && currentPhase.name !== targetName) { await this.run().catch(e => {
await this.run(currentPhase).catch(e => { clearInterval(this.intervalRun);
clearInterval(this.intervalRun); return reject(e);
return reject(e); });
}); return resolve();
}
}); });
}); });
} }
/** /**
* Method to run a phase with an optional skip function. * Method to run the current phase with an optional skip function.
* @param phaseTarget - The phase to run.
* @param skipFn - Optional skip function.
* @returns A promise that resolves when the phase is run. * @returns A promise that resolves when the phase is run.
*/ */
run(phaseTarget: PhaseInterceptorPhase, skipFn?: (className: PhaseClass) => boolean): Promise<void> { private run(): Promise<void> {
const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; // @ts-expect-error: This is apparently mandatory to avoid a crash; review if this is needed
this.scene.moveAnimations = null; // Mandatory to avoid crash this.scene.moveAnimations = null;
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
ErrorInterceptor.getInstance().add(this); ErrorInterceptor.getInstance().add(this);
const interval = setInterval(async () => { const interval = setInterval(async () => {
const currentPhase = this.onHold.shift(); const currentPhase = this.onHold.shift();
if (currentPhase) { if (currentPhase) {
if (currentPhase.name !== targetName) {
clearInterval(interval);
const skip = skipFn?.(currentPhase.name);
if (skip) {
this.onHold.unshift(currentPhase);
ErrorInterceptor.getInstance().remove(this);
return resolve();
}
clearInterval(interval);
return reject(`Wrong phase: this is ${currentPhase.name} and not ${targetName}`);
}
clearInterval(interval); clearInterval(interval);
this.inProgress = { this.inProgress = {
name: currentPhase.name, name: currentPhase.name,
@ -287,26 +290,6 @@ export class PhaseInterceptor {
}); });
} }
whenAboutToRun(phaseTarget: PhaseInterceptorPhase, _skipFn?: (className: PhaseClass) => boolean): Promise<void> {
const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name;
this.scene.moveAnimations = null; // Mandatory to avoid crash
return new Promise(async (resolve, _reject) => {
ErrorInterceptor.getInstance().add(this);
const interval = setInterval(async () => {
const currentPhase = this.onHold[0];
if (currentPhase?.name === targetName) {
clearInterval(interval);
resolve();
}
});
});
}
pop() {
this.onHold.pop();
this.scene.phaseManager.shiftPhase();
}
/** /**
* Remove the current phase from the phase interceptor. * Remove the current phase from the phase interceptor.
* *
@ -316,7 +299,7 @@ export class PhaseInterceptor {
* *
* @param shouldRun Whether or not the current scene should also be run. * @param shouldRun Whether or not the current scene should also be run.
*/ */
shift(shouldRun = false): void { shiftPhase(shouldRun = false): void {
this.onHold.shift(); this.onHold.shift();
if (shouldRun) { if (shouldRun) {
this.scene.phaseManager.shiftPhase(); this.scene.phaseManager.shiftPhase();
@ -328,17 +311,16 @@ export class PhaseInterceptor {
*/ */
initPhases() { initPhases() {
this.originalSetMode = UI.prototype.setMode; this.originalSetMode = UI.prototype.setMode;
this.originalSetOverlayMode = UI.prototype.setOverlayMode;
this.originalSuperEnd = Phase.prototype.end; this.originalSuperEnd = Phase.prototype.end;
UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args); UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args);
Phase.prototype.end = () => this.superEndPhase.call(this); Phase.prototype.end = () => this.superEndPhase.call(this);
for (const [phase, methodStart] of this.PHASES) { for (const phase of this.PHASES) {
const originalStart = phase.prototype.start; const originalStart = phase.prototype.start;
this.phases[phase.name] = { this.phases[phase.name] = {
start: originalStart, start: originalStart,
endBySetMode: this.endBySetMode.some(elm => elm.name === phase.name), endBySetMode: this.endBySetMode.some(elm => elm.name === phase.name),
}; };
phase.prototype.start = () => methodStart.call(this, phase); phase.prototype.start = () => this.startPhase.call(this, phase);
} }
} }
@ -347,7 +329,7 @@ export class PhaseInterceptor {
* @param phase - The phase to start. * @param phase - The phase to start.
*/ */
startPhase(phase: PhaseClass) { startPhase(phase: PhaseClass) {
this.log.push(phase.name); this.log.push(phase.name as PhaseString);
const instance = this.scene.phaseManager.getCurrentPhase(); const instance = this.scene.phaseManager.getCurrentPhase();
this.onHold.push({ this.onHold.push({
name: phase.name, name: phase.name,
@ -357,16 +339,11 @@ export class PhaseInterceptor {
}); });
} }
unlock() {
this.inProgress?.callback();
this.inProgress = undefined;
}
/** /**
* Method to end a phase and log it. * Method to end a phase and log it.
* @param phase - The phase to start. * @param phase - The phase to start.
*/ */
superEndPhase() { private superEndPhase() {
const instance = this.scene.phaseManager.getCurrentPhase(); const instance = this.scene.phaseManager.getCurrentPhase();
this.originalSuperEnd.apply(instance); this.originalSuperEnd.apply(instance);
this.inProgress?.callback(); this.inProgress?.callback();
@ -379,7 +356,8 @@ export class PhaseInterceptor {
* @param args - Additional arguments to pass to the original method. * @param args - Additional arguments to pass to the original method.
*/ */
setMode(mode: UiMode, ...args: unknown[]): Promise<void> { setMode(mode: UiMode, ...args: unknown[]): Promise<void> {
const currentPhase = this.scene.phaseManager.getCurrentPhase(); // TODO: remove the `!` in PR 6243 / after PR 6243 is merged
const currentPhase = this.scene.phaseManager.getCurrentPhase()!;
const instance = this.scene.ui; const instance = this.scene.ui;
console.log("setMode", `${UiMode[mode]} (=${mode})`, args); console.log("setMode", `${UiMode[mode]} (=${mode})`, args);
const ret = this.originalSetMode.apply(instance, [mode, ...args]); const ret = this.originalSetMode.apply(instance, [mode, ...args]);
@ -395,18 +373,6 @@ export class PhaseInterceptor {
return ret; return ret;
} }
/**
* mock to set overlay mode
* @param mode - The {@linkcode Mode} to set.
* @param args - Additional arguments to pass to the original method.
*/
setOverlayMode(mode: UiMode, ...args: unknown[]): Promise<void> {
const instance = this.scene.ui;
console.log("setOverlayMode", `${UiMode[mode]} (=${mode})`, args);
const ret = this.originalSetOverlayMode.apply(instance, [mode, ...args]);
return ret;
}
/** /**
* Method to start the prompt handler. * Method to start the prompt handler.
*/ */
@ -425,7 +391,7 @@ export class PhaseInterceptor {
currentPhase === actionForNextPrompt.phaseTarget && currentPhase === actionForNextPrompt.phaseTarget &&
currentHandler.active && currentHandler.active &&
(!actionForNextPrompt.awaitingActionInput || (!actionForNextPrompt.awaitingActionInput ||
(actionForNextPrompt.awaitingActionInput && currentHandler.awaitingActionInput)) (actionForNextPrompt.awaitingActionInput && (currentHandler as AwaitableUiHandler)["awaitingActionInput"]))
) { ) {
const prompt = this.prompts.shift(); const prompt = this.prompts.shift();
if (prompt?.callback) { if (prompt?.callback) {
@ -467,11 +433,10 @@ export class PhaseInterceptor {
* function stored in `this.phases`. Additionally, it clears the `promptInterval` and `interval`. * function stored in `this.phases`. Additionally, it clears the `promptInterval` and `interval`.
*/ */
restoreOg() { restoreOg() {
for (const [phase] of this.PHASES) { for (const phase of this.PHASES) {
phase.prototype.start = this.phases[phase.name].start; phase.prototype.start = this.phases[phase.name].start;
} }
UI.prototype.setMode = this.originalSetMode; UI.prototype.setMode = this.originalSetMode;
UI.prototype.setOverlayMode = this.originalSetOverlayMode;
Phase.prototype.end = this.originalSuperEnd; Phase.prototype.end = this.originalSuperEnd;
clearInterval(this.promptInterval); clearInterval(this.promptInterval);
clearInterval(this.interval); clearInterval(this.interval);

View File

@ -69,7 +69,7 @@ describe("UI - Pokedex", () => {
// Open the pokedex UI. // Open the pokedex UI.
await game.runToTitle(); await game.runToTitle();
await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX); await game.scene.ui.setOverlayMode(UiMode.POKEDEX);
// Get the handler for the current UI. // Get the handler for the current UI.
const handler = game.scene.ui.getHandler(); const handler = game.scene.ui.getHandler();
@ -89,7 +89,7 @@ describe("UI - Pokedex", () => {
// Open the pokedex UI. // Open the pokedex UI.
await game.runToTitle(); await game.runToTitle();
await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes); await game.scene.ui.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes);
// Get the handler for the current UI. // Get the handler for the current UI.
const handler = game.scene.ui.getHandler(); const handler = game.scene.ui.getHandler();

View File

@ -6,8 +6,6 @@ import { GameModes } from "#enums/game-modes";
import { Nature } from "#enums/nature"; import { Nature } from "#enums/nature";
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 { EncounterPhase } from "#phases/encounter-phase";
import { SelectStarterPhase } from "#phases/select-starter-phase";
import type { TitlePhase } from "#phases/title-phase"; import type { TitlePhase } from "#phases/title-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import type { OptionSelectItem } from "#ui/abstract-option-select-ui-handler"; import type { OptionSelectItem } from "#ui/abstract-option-select-ui-handler";
@ -54,9 +52,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT);
handler.processInput(Button.LEFT); handler.processInput(Button.LEFT);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -88,12 +85,12 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(2); expect(game.field.getPlayerPokemon().variant).toBe(2);
expect(game.scene.getPlayerParty()[0].gender).toBe(Gender.MALE); expect(game.field.getPlayerPokemon().gender).toBe(Gender.MALE);
}); });
it("Bulbasaur - shiny - variant 2 female hardy overgrow", async () => { it("Bulbasaur - shiny - variant 2 female hardy overgrow", async () => {
@ -115,9 +112,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.LEFT); handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_GENDER); handler.processInput(Button.CYCLE_GENDER);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -149,13 +145,13 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(2); expect(game.field.getPlayerPokemon().variant).toBe(2);
expect(game.scene.getPlayerParty()[0].nature).toBe(Nature.HARDY); expect(game.field.getPlayerPokemon().nature).toBe(Nature.HARDY);
expect(game.scene.getPlayerParty()[0].getAbility().id).toBe(AbilityId.OVERGROW); expect(game.field.getPlayerPokemon().getAbility().id).toBe(AbilityId.OVERGROW);
}); });
it("Bulbasaur - shiny - variant 2 female lonely chlorophyl", async () => { it("Bulbasaur - shiny - variant 2 female lonely chlorophyl", async () => {
@ -179,9 +175,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.CYCLE_NATURE); handler.processInput(Button.CYCLE_NATURE);
handler.processInput(Button.CYCLE_ABILITY); handler.processInput(Button.CYCLE_ABILITY);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -213,14 +208,14 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(2); expect(game.field.getPlayerPokemon().variant).toBe(2);
expect(game.scene.getPlayerParty()[0].gender).toBe(Gender.FEMALE); expect(game.field.getPlayerPokemon().gender).toBe(Gender.FEMALE);
expect(game.scene.getPlayerParty()[0].nature).toBe(Nature.LONELY); expect(game.field.getPlayerPokemon().nature).toBe(Nature.LONELY);
expect(game.scene.getPlayerParty()[0].getAbility().id).toBe(AbilityId.CHLOROPHYLL); expect(game.field.getPlayerPokemon().getAbility().id).toBe(AbilityId.CHLOROPHYLL);
}); });
it("Bulbasaur - shiny - variant 2 female", async () => { it("Bulbasaur - shiny - variant 2 female", async () => {
@ -242,9 +237,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.LEFT); handler.processInput(Button.LEFT);
handler.processInput(Button.CYCLE_GENDER); handler.processInput(Button.CYCLE_GENDER);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -276,12 +270,12 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(2); expect(game.field.getPlayerPokemon().variant).toBe(2);
expect(game.scene.getPlayerParty()[0].gender).toBe(Gender.FEMALE); expect(game.field.getPlayerPokemon().gender).toBe(Gender.FEMALE);
}); });
it("Bulbasaur - not shiny", async () => { it("Bulbasaur - not shiny", async () => {
@ -303,9 +297,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.LEFT); handler.processInput(Button.LEFT);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -337,11 +330,11 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(false); expect(game.field.getPlayerPokemon().shiny).toBe(false);
expect(game.scene.getPlayerParty()[0].variant).toBe(0); expect(game.field.getPlayerPokemon().variant).toBe(0);
}); });
it("Bulbasaur - shiny - variant 1", async () => { it("Bulbasaur - shiny - variant 1", async () => {
@ -365,9 +358,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -399,11 +391,11 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(1); expect(game.field.getPlayerPokemon().variant).toBe(1);
}); });
it("Bulbasaur - shiny - variant 0", async () => { it("Bulbasaur - shiny - variant 0", async () => {
@ -426,9 +418,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -460,11 +451,11 @@ describe("UI - Starter select", () => {
resolve(); resolve();
}); });
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.BULBASAUR);
expect(game.scene.getPlayerParty()[0].shiny).toBe(true); expect(game.field.getPlayerPokemon().shiny).toBe(true);
expect(game.scene.getPlayerParty()[0].variant).toBe(0); expect(game.field.getPlayerPokemon().variant).toBe(0);
}); });
it("Check if first pokemon in party is caterpie from gen 1 and 1rd row, 3rd column", async () => { it("Check if first pokemon in party is caterpie from gen 1 and 1rd row, 3rd column", async () => {
@ -486,9 +477,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT);
handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -527,8 +517,8 @@ describe("UI - Starter select", () => {
const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler;
saveSlotSelectUiHandler.processInput(Button.ACTION); saveSlotSelectUiHandler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.CATERPIE); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.CATERPIE);
}); });
it("Check if first pokemon in party is nidoran_m from gen 1 and 2nd row, 4th column (cursor (9+4)-1)", async () => { it("Check if first pokemon in party is nidoran_m from gen 1 and 2nd row, 4th column (cursor (9+4)-1)", async () => {
@ -551,9 +541,8 @@ describe("UI - Starter select", () => {
handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT);
handler.processInput(Button.DOWN); handler.processInput(Button.DOWN);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.run(SelectStarterPhase); await game.phaseInterceptor.to("SelectStarterPhase");
let options: OptionSelectItem[] = []; let options: OptionSelectItem[] = [];
let optionSelectUiHandler: OptionSelectUiHandler | undefined; let optionSelectUiHandler: OptionSelectUiHandler | undefined;
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
@ -593,7 +582,7 @@ describe("UI - Starter select", () => {
const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler;
saveSlotSelectUiHandler.processInput(Button.ACTION); saveSlotSelectUiHandler.processInput(Button.ACTION);
}); });
await game.phaseInterceptor.whenAboutToRun(EncounterPhase); await game.phaseInterceptor.to("EncounterPhase", false);
expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.NIDORAN_M); expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.NIDORAN_M);
}); });
}); });

View File

@ -72,8 +72,6 @@ describe("UI - Transfer Items", () => {
expect( expect(
handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)), handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)),
).toBe(true); ).toBe(true);
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to("SelectModifierPhase"); await game.phaseInterceptor.to("SelectModifierPhase");
@ -93,8 +91,6 @@ describe("UI - Transfer Items", () => {
expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe( expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe(
true, true,
); );
game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to("SelectModifierPhase"); await game.phaseInterceptor.to("SelectModifierPhase");

View File

@ -2,7 +2,6 @@ import { Button } from "#enums/buttons";
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 { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
import { CommandPhase } from "#phases/command-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import type { MockText } from "#test/test-utils/mocks/mocks-container/mock-text"; import type { MockText } from "#test/test-utils/mocks/mocks-container/mock-text";
import { FightUiHandler } from "#ui/fight-ui-handler"; import { FightUiHandler } from "#ui/fight-ui-handler";
@ -46,7 +45,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
@ -59,7 +57,7 @@ describe("UI - Type Hints", () => {
expect.soft(dragonClawText.color).toBe("#929292"); expect.soft(dragonClawText.color).toBe("#929292");
ui.getHandler().processInput(Button.ACTION); ui.getHandler().processInput(Button.ACTION);
}); });
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to("CommandPhase");
}); });
it("check status move color", async () => { it("check status move color", async () => {
@ -71,7 +69,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
@ -84,7 +81,7 @@ describe("UI - Type Hints", () => {
expect.soft(growlText.color).toBe(undefined); expect.soft(growlText.color).toBe(undefined);
ui.getHandler().processInput(Button.ACTION); ui.getHandler().processInput(Button.ACTION);
}); });
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to("CommandPhase");
}); });
it("should show the proper hint for a move in doubles after one of the enemy pokemon flees", async () => { it("should show the proper hint for a move in doubles after one of the enemy pokemon flees", async () => {
@ -107,7 +104,6 @@ describe("UI - Type Hints", () => {
const { ui } = game.scene; const { ui } = game.scene;
const handler = ui.getHandler<FightUiHandler>(); const handler = ui.getHandler<FightUiHandler>();
handler.processInput(Button.ACTION); // select "Fight" handler.processInput(Button.ACTION); // select "Fight"
game.phaseInterceptor.unlock();
}); });
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
@ -121,6 +117,6 @@ describe("UI - Type Hints", () => {
expect.soft(shadowBallText.color).toBe(undefined); expect.soft(shadowBallText.color).toBe(undefined);
ui.getHandler().processInput(Button.ACTION); ui.getHandler().processInput(Button.ACTION);
}); });
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to("CommandPhase");
}); });
}); });