From 5854b21da0a191b19413325c1b3ff048e4582323 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sat, 19 Apr 2025 06:57:03 -0500 Subject: [PATCH] [Refactor] Remove circular imports part 1 (#5663) * Extract Mode enum out of UI and into its own file Reduces circular imports from 909 to 773 * Move around utility files Reduces cyclical dependencies from 773 to 765 * Remove starterColors and bypassLogin from battle-scene Reduces cyclical dependencies from 765 to 623 * Fix test runner error * Update import for bypassLogin in test * Update mocks for utils in tests * Fix broken tests * Update selectWithTera override * Update path for utils in ab-attr.ts * Update path for utils in ability-class.ts * Fix utils import path in healer.test.ts --- src/account.ts | 4 +- src/battle-scene.ts | 17 +- src/battle.ts | 2 +- src/data/abilities/ab-attrs/ab-attr.ts | 4 +- src/data/abilities/ability-class.ts | 2 +- src/data/abilities/ability.ts | 2 +- src/data/arena-tag.ts | 2 +- src/data/balance/biomes.ts | 2 +- src/data/balance/egg-moves.ts | 2 +- src/data/balance/pokemon-evolutions.ts | 6 +- src/data/battle-anims.ts | 4 +- src/data/battler-tags.ts | 4 +- src/data/berry.ts | 2 +- src/data/challenge.ts | 2 +- src/data/custom-pokemon-data.ts | 2 +- src/data/daily-run.ts | 2 +- src/data/egg.ts | 2 +- src/data/moves/move.ts | 2 +- .../encounters/a-trainers-test-encounter.ts | 2 +- .../encounters/absolute-avarice-encounter.ts | 2 +- .../encounters/berries-abound-encounter.ts | 2 +- .../encounters/bug-type-superfan-encounter.ts | 2 +- .../encounters/clowning-around-encounter.ts | 12 +- .../encounters/dark-deal-encounter.ts | 2 +- .../encounters/delibirdy-encounter.ts | 2 +- .../department-store-sale-encounter.ts | 2 +- .../encounters/fiery-fallout-encounter.ts | 2 +- .../encounters/fight-or-flight-encounter.ts | 2 +- .../global-trade-system-encounter.ts | 9 +- .../mysterious-challengers-encounter.ts | 2 +- .../encounters/mysterious-chest-encounter.ts | 2 +- .../encounters/safari-zone-encounter.ts | 2 +- .../shady-vitamin-dealer-encounter.ts | 2 +- .../teleporting-hijinks-encounter.ts | 2 +- .../the-expert-pokemon-breeder-encounter.ts | 2 +- .../the-pokemon-salesman-encounter.ts | 2 +- .../encounters/training-session-encounter.ts | 2 +- .../encounters/trash-to-treasure-encounter.ts | 2 +- .../encounters/uncommon-breed-encounter.ts | 2 +- .../encounters/weird-dream-encounter.ts | 2 +- .../mystery-encounter-option.ts | 2 +- .../mystery-encounter-requirements.ts | 2 +- .../mystery-encounter-save-data.ts | 2 +- .../mystery-encounters/mystery-encounter.ts | 4 +- .../can-learn-move-requirement.ts | 2 +- .../utils/encounter-dialogue-utils.ts | 2 +- .../utils/encounter-phase-utils.ts | 18 +- .../utils/encounter-pokemon-utils.ts | 20 +-- .../encounter-transformation-sequence.ts | 2 +- src/data/nature.ts | 2 +- src/data/pokeball.ts | 2 +- src/data/pokemon-forms.ts | 2 +- src/data/pokemon-species.ts | 2 +- src/data/status-effect.ts | 2 +- src/data/trainer-names.ts | 2 +- src/data/trainers/TrainerPartyTemplate.ts | 2 +- src/data/trainers/trainer-config.ts | 2 +- src/data/weather.ts | 2 +- src/enums/ui-mode.ts | 47 +++++ src/field/anims.ts | 2 +- src/field/arena.ts | 2 +- src/field/damage-number-handler.ts | 2 +- src/field/mystery-encounter-intro.ts | 2 +- src/field/pokemon-sprite-sparkle-handler.ts | 2 +- src/field/pokemon.ts | 8 +- src/field/trainer.ts | 2 +- src/game-mode.ts | 2 +- src/global-vars/bypass-login.ts | 1 + src/global-vars/starter-colors.ts | 4 + src/inputs-controller.ts | 12 +- src/loading-scene.ts | 2 +- src/modifier/modifier-type.ts | 2 +- src/modifier/modifier.ts | 2 +- src/phases/attempt-capture-phase.ts | 31 ++-- src/phases/attempt-run-phase.ts | 2 +- src/phases/berry-phase.ts | 2 +- src/phases/check-switch-phase.ts | 8 +- src/phases/command-phase.ts | 70 ++++---- src/phases/damage-anim-phase.ts | 2 +- src/phases/egg-hatch-phase.ts | 6 +- src/phases/egg-lapse-phase.ts | 4 +- src/phases/egg-summary-phase.ts | 6 +- src/phases/encounter-phase.ts | 6 +- src/phases/end-evolution-phase.ts | 4 +- src/phases/evolution-phase.ts | 8 +- src/phases/exp-phase.ts | 2 +- src/phases/faint-phase.ts | 2 +- src/phases/form-change-phase.ts | 8 +- src/phases/game-over-modifier-reward-phase.ts | 4 +- src/phases/game-over-phase.ts | 6 +- src/phases/learn-move-phase.ts | 14 +- src/phases/level-cap-phase.ts | 4 +- src/phases/level-up-phase.ts | 4 +- src/phases/login-phase.ts | 17 +- src/phases/money-reward-phase.ts | 2 +- src/phases/move-charge-phase.ts | 2 +- src/phases/move-effect-phase.ts | 4 +- src/phases/move-phase.ts | 2 +- src/phases/mystery-encounter-phases.ts | 12 +- src/phases/obtain-status-effect-phase.ts | 2 +- src/phases/party-heal-phase.ts | 2 +- src/phases/pokemon-anim-phase.ts | 2 +- src/phases/pokemon-heal-phase.ts | 2 +- src/phases/post-turn-status-effect-phase.ts | 2 +- src/phases/reload-session-phase.ts | 6 +- src/phases/revival-blessing-phase.ts | 8 +- src/phases/ribbon-modifier-reward-phase.ts | 4 +- src/phases/scan-ivs-phase.ts | 8 +- src/phases/select-biome-phase.ts | 8 +- src/phases/select-challenge-phase.ts | 4 +- src/phases/select-gender-phase.ts | 6 +- src/phases/select-modifier-phase.ts | 38 ++-- src/phases/select-starter-phase.ts | 8 +- src/phases/select-target-phase.ts | 6 +- src/phases/show-party-exp-bar-phase.ts | 2 +- src/phases/stat-stage-change-phase.ts | 2 +- src/phases/switch-phase.ts | 6 +- src/phases/title-phase.ts | 20 +-- src/phases/trainer-victory-phase.ts | 2 +- src/phases/turn-start-phase.ts | 2 +- src/phases/unavailable-phase.ts | 4 +- src/phases/unlock-phase.ts | 4 +- src/phases/weather-effect-phase.ts | 2 +- src/pipelines/field-sprite.ts | 2 +- src/pipelines/sprite.ts | 2 +- src/plugins/api/api-base.ts | 2 +- src/plugins/api/pokerogue-account-api.ts | 2 +- src/plugins/i18n.ts | 2 +- src/sprites/variant.ts | 2 +- src/starter-colors.ts | 4 + src/starting-wave.ts | 3 + src/system/achv.ts | 2 +- src/system/game-data.ts | 10 +- src/system/game-speed.ts | 2 +- src/system/settings/settings-gamepad.ts | 8 +- src/system/settings/settings-keyboard.ts | 4 +- src/system/settings/settings.ts | 6 +- .../version_migration/versions/v1_0_4.ts | 2 +- .../version_migration/versions/v1_7_0.ts | 2 +- src/timed-event-manager.ts | 4 +- src/tutorial.ts | 6 +- src/ui-inputs.ts | 24 +-- src/ui/abstact-option-select-ui-handler.ts | 12 +- src/ui/achvs-ui-handler.ts | 4 +- src/ui/admin-ui-handler.ts | 20 +-- src/ui/arena-flyout.ts | 2 +- src/ui/autocomplete-ui-handler.ts | 4 +- src/ui/awaitable-ui-handler.ts | 4 +- src/ui/ball-ui-handler.ts | 10 +- src/ui/base-stats-overlay.ts | 2 +- src/ui/battle-flyout.ts | 2 +- src/ui/battle-info.ts | 6 +- src/ui/battle-message-ui-handler.ts | 4 +- src/ui/bgm-bar.ts | 2 +- src/ui/candy-bar.ts | 4 +- src/ui/challenges-select-ui-handler.ts | 6 +- src/ui/char-sprite.ts | 2 +- src/ui/command-ui-handler.ts | 12 +- src/ui/confirm-ui-handler.ts | 4 +- src/ui/daily-run-scoreboard.ts | 2 +- src/ui/egg-gacha-ui-handler.ts | 6 +- src/ui/egg-hatch-scene-handler.ts | 4 +- src/ui/egg-list-ui-handler.ts | 4 +- src/ui/egg-summary-ui-handler.ts | 4 +- src/ui/evolution-scene-handler.ts | 4 +- src/ui/fight-ui-handler.ts | 19 +- src/ui/filter-text.ts | 4 +- src/ui/form-modal-ui-handler.ts | 6 +- src/ui/game-stats-ui-handler.ts | 6 +- src/ui/loading-modal-ui-handler.ts | 4 +- src/ui/login-form-ui-handler.ts | 16 +- src/ui/menu-ui-handler.ts | 46 ++--- src/ui/message-ui-handler.ts | 6 +- src/ui/modal-ui-handler.ts | 4 +- src/ui/modifier-select-ui-handler.ts | 6 +- src/ui/move-info-overlay.ts | 2 +- src/ui/mystery-encounter-ui-handler.ts | 10 +- src/ui/party-ui-handler.ts | 32 ++-- src/ui/pokedex-info-overlay.ts | 2 +- src/ui/pokedex-mon-container.ts | 2 +- src/ui/pokedex-page-ui-handler.ts | 84 ++++----- src/ui/pokedex-scan-ui-handler.ts | 12 +- src/ui/pokedex-ui-handler.ts | 18 +- src/ui/pokemon-hatch-info-container.ts | 4 +- src/ui/pokemon-icon-anim-handler.ts | 2 +- src/ui/pokemon-info-container.ts | 2 +- src/ui/registration-form-ui-handler.ts | 6 +- src/ui/run-history-ui-handler.ts | 8 +- src/ui/run-info-ui-handler.ts | 6 +- src/ui/save-slot-select-ui-handler.ts | 12 +- src/ui/saving-icon-handler.ts | 2 +- src/ui/session-reload-modal-ui-handler.ts | 4 +- .../settings/abstract-binding-ui-handler.ts | 4 +- .../abstract-control-settings-ui-handler.ts | 4 +- .../settings/abstract-settings-ui-handler.ts | 6 +- src/ui/settings/gamepad-binding-ui-handler.ts | 4 +- .../settings/keyboard-binding-ui-handler.ts | 4 +- src/ui/settings/navigationMenu.ts | 18 +- src/ui/settings/option-select-ui-handler.ts | 4 +- src/ui/settings/settings-audio-ui-handler.ts | 4 +- .../settings/settings-display-ui-handler.ts | 4 +- .../settings/settings-gamepad-ui-handler.ts | 6 +- .../settings/settings-keyboard-ui-handler.ts | 10 +- src/ui/settings/settings-ui-handler.ts | 4 +- src/ui/starter-select-ui-handler.ts | 78 ++++----- src/ui/summary-ui-handler.ts | 14 +- src/ui/target-select-ui-handler.ts | 6 +- src/ui/test-dialogue-ui-handler.ts | 12 +- src/ui/time-of-day-widget.ts | 2 +- src/ui/title-ui-handler.ts | 6 +- src/ui/ui-handler.ts | 4 +- src/ui/ui.ts | 163 +++++++----------- src/ui/unavailable-modal-ui-handler.ts | 7 +- src/{utils.ts => utils/common.ts} | 37 ---- src/utils/cookies.ts | 36 ++++ src/utils/utility-vars.ts | 1 + test/abilities/ability_timing.test.ts | 6 +- test/abilities/analytic.test.ts | 2 +- test/abilities/disguise.test.ts | 2 +- test/abilities/healer.test.ts | 2 +- test/abilities/heatproof.test.ts | 2 +- test/abilities/intimidate.test.ts | 10 +- test/abilities/parental_bond.test.ts | 2 +- test/abilities/shield_dust.test.ts | 2 +- test/abilities/stakeout.test.ts | 2 +- test/abilities/wimp_out.test.ts | 2 +- test/account.test.ts | 10 +- test/achievements/achievement.test.ts | 2 +- test/battle/battle.test.ts | 38 ++-- test/battle/special_battle.test.ts | 20 +-- test/boss-pokemon.test.ts | 2 +- test/daily_mode.test.ts | 6 +- test/eggs/egg.test.ts | 2 +- test/enemy_command.test.ts | 2 +- test/escape-calculations.test.ts | 2 +- test/evolution.test.ts | 2 +- test/game-mode.test.ts | 2 +- test/items/dire_hit.test.ts | 4 +- .../double_battle_chance_booster.test.ts | 4 +- test/items/eviolite.test.ts | 2 +- test/items/exp_booster.test.ts | 2 +- test/items/leek.test.ts | 2 +- test/items/light_ball.test.ts | 2 +- test/items/lock_capsule.test.ts | 4 +- test/items/metal_powder.test.ts | 2 +- test/items/quick_powder.test.ts | 2 +- test/items/temp_stat_stage_booster.test.ts | 4 +- test/items/thick_club.test.ts | 2 +- test/moves/aurora_veil.test.ts | 2 +- test/moves/belly_drum.test.ts | 2 +- test/moves/fillet_away.test.ts | 2 +- test/moves/light_screen.test.ts | 2 +- test/moves/multi_target.test.ts | 2 +- test/moves/pledge_moves.test.ts | 2 +- test/moves/reflect.test.ts | 2 +- test/moves/revival_blessing.test.ts | 2 +- test/moves/substitute.test.ts | 4 +- .../mystery-encounter/encounter-test-utils.ts | 30 ++-- .../a-trainers-test-encounter.test.ts | 6 +- .../berries-abound-encounter.test.ts | 6 +- .../bug-type-superfan-encounter.test.ts | 14 +- .../clowning-around-encounter.test.ts | 8 +- .../dancing-lessons-encounter.test.ts | 4 +- .../department-store-sale-encounter.test.ts | 10 +- .../encounters/field-trip-encounter.test.ts | 14 +- .../fight-or-flight-encounter.test.ts | 6 +- .../fun-and-games-encounter.test.ts | 20 +-- .../global-trade-system-encounter.test.ts | 6 +- .../mysterious-challengers-encounter.test.ts | 8 +- .../teleporting-hijinks-encounter.test.ts | 4 +- .../the-strong-stuff-encounter.test.ts | 4 +- .../the-winstrate-challenge-encounter.test.ts | 8 +- .../trash-to-treasure-encounter.test.ts | 6 +- .../encounters/weird-dream-encounter.test.ts | 6 +- test/phases/learn-move-phase.test.ts | 12 +- test/phases/mystery-encounter-phase.test.ts | 10 +- test/phases/phases.test.ts | 8 +- test/phases/select-modifier-phase.test.ts | 24 +-- .../plugins/api/pokerogue-account-api.test.ts | 17 +- test/reload.test.ts | 4 +- test/settingMenu/rebinding_setting.test.ts | 2 +- test/system/game_data.test.ts | 6 +- test/testUtils/gameManager.ts | 46 ++--- test/testUtils/gameWrapper.ts | 9 +- test/testUtils/helpers/challengeModeHelper.ts | 12 +- test/testUtils/helpers/classicModeHelper.ts | 12 +- test/testUtils/helpers/dailyModeHelper.ts | 14 +- test/testUtils/helpers/moveHelper.ts | 20 +-- test/testUtils/helpers/overridesHelper.ts | 2 +- test/testUtils/helpers/reloadHelper.ts | 10 +- test/testUtils/phaseInterceptor.ts | 13 +- test/testUtils/testFileInitialization.ts | 4 +- test/ui/starter-select.test.ts | 110 ++++++------ test/ui/transfer-item.test.ts | 10 +- test/ui/type-hints.test.ts | 10 +- {src => test}/utils.test.ts | 2 +- 296 files changed, 1186 insertions(+), 1147 deletions(-) create mode 100644 src/enums/ui-mode.ts create mode 100644 src/global-vars/bypass-login.ts create mode 100644 src/global-vars/starter-colors.ts create mode 100644 src/starter-colors.ts create mode 100644 src/starting-wave.ts rename src/{utils.ts => utils/common.ts} (92%) create mode 100644 src/utils/cookies.ts create mode 100644 src/utils/utility-vars.ts rename {src => test}/utils.test.ts (95%) diff --git a/src/account.ts b/src/account.ts index 7baa7d10a1a..3416fa6ed5e 100644 --- a/src/account.ts +++ b/src/account.ts @@ -1,7 +1,7 @@ import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import type { UserInfo } from "#app/@types/UserInfo"; -import { bypassLogin } from "#app/battle-scene"; -import { randomString } from "#app/utils"; +import { bypassLogin } from "./global-vars/bypass-login"; +import { randomString } from "#app/utils/common"; export let loggedInUser: UserInfo | null = null; // This is a random string that is used to identify the client session - unique per session (tab or window) so that the game will only save on the one that the server is expecting diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 0fe4c7f7e4f..ecaffc5ed07 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -18,7 +18,7 @@ import { isNullOrUndefined, BooleanHolder, type Constructor, -} from "#app/utils"; +} from "#app/utils/common"; import type { Modifier, ModifierPredicate, TurnHeldItemTransferModifier } from "./modifier/modifier"; import { ConsumableModifier, @@ -185,8 +185,8 @@ import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; import { expSpriteKeys } from "./sprites/sprite-keys"; import { hasExpSprite } from "./sprites/sprite-utils"; import { timedEventManager } from "./global-event-manager"; - -export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; +import { starterColors } from "./global-vars/starter-colors"; +import { startingWave } from "./starting-wave"; const DEBUG_RNG = false; @@ -194,13 +194,6 @@ const OPP_IVS_OVERRIDE_VALIDATED: number[] = ( Array.isArray(Overrides.OPP_IVS_OVERRIDE) ? Overrides.OPP_IVS_OVERRIDE : new Array(6).fill(Overrides.OPP_IVS_OVERRIDE) ).map(iv => (Number.isNaN(iv) || iv === null || iv > 31 ? -1 : iv)); -export const startingWave = Overrides.STARTING_WAVE_OVERRIDE || 1; - -export let starterColors: StarterColors; -interface StarterColors { - [key: string]: [string, string]; -} - export interface PokeballCounts { [pb: string]: number; } @@ -810,11 +803,11 @@ export default class BattleScene extends SceneBase { } async initStarterColors(): Promise { - if (starterColors) { + if (Object.keys(starterColors).length > 0) { + // already initialized return; } const sc = await this.cachedFetch("./starter-colors.json").then(res => res.json()); - starterColors = {}; for (const key of Object.keys(sc)) { starterColors[key] = sc[key]; } diff --git a/src/battle.ts b/src/battle.ts index 3e2f293065a..6630d53bd67 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -8,7 +8,7 @@ import { shiftCharCodes, randSeedItem, randInt, -} from "#app/utils"; +} from "#app/utils/common"; import Trainer, { TrainerVariant } from "./field/trainer"; import type { GameMode } from "./game-mode"; import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; diff --git a/src/data/abilities/ab-attrs/ab-attr.ts b/src/data/abilities/ab-attrs/ab-attr.ts index c8ead691b25..a653c3f372d 100644 --- a/src/data/abilities/ab-attrs/ab-attr.ts +++ b/src/data/abilities/ab-attrs/ab-attr.ts @@ -1,6 +1,6 @@ import type { AbAttrCondition } from "#app/@types/ability-types"; import type Pokemon from "#app/field/pokemon"; -import type * as Utils from "#app/utils"; +import type { BooleanHolder } from "#app/utils/common"; export abstract class AbAttr { public showAbility: boolean; @@ -22,7 +22,7 @@ export abstract class AbAttr { _pokemon: Pokemon, _passive: boolean, _simulated: boolean, - _cancelled: Utils.BooleanHolder | null, + _cancelled: BooleanHolder | null, _args: any[], ): void {} diff --git a/src/data/abilities/ability-class.ts b/src/data/abilities/ability-class.ts index b4cda2482d4..387c5fb328b 100644 --- a/src/data/abilities/ability-class.ts +++ b/src/data/abilities/ability-class.ts @@ -3,7 +3,7 @@ import type { AbAttrCondition } from "#app/@types/ability-types"; import type { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr"; import i18next from "i18next"; import type { Localizable } from "#app/interfaces/locales"; -import type { Constructor } from "#app/utils"; +import type { Constructor } from "#app/utils/common"; export class Ability implements Localizable { public id: Abilities; diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index a3bd9b728f5..55a1a4eb902 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -1,5 +1,5 @@ import { HitResult, MoveResult, PlayerPokemon } from "#app/field/pokemon"; -import { BooleanHolder, NumberHolder, toDmgValue, isNullOrUndefined, randSeedItem, randSeedInt, type Constructor } from "#app/utils"; +import { BooleanHolder, NumberHolder, toDmgValue, isNullOrUndefined, randSeedItem, randSeedInt, type Constructor } from "#app/utils/common"; import { getPokemonNameWithAffix } from "#app/messages"; import { BattlerTagLapseType, GroundedTag } from "#app/data/battler-tags"; import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect"; diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 1fe1eca4bba..2ef98723cea 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import type { Arena } from "#app/field/arena"; import { PokemonType } from "#enums/pokemon-type"; -import { BooleanHolder, NumberHolder, toDmgValue } from "#app/utils"; +import { BooleanHolder, NumberHolder, toDmgValue } from "#app/utils/common"; import { allMoves } from "#app/data/moves/move"; import { MoveTarget } from "#enums/MoveTarget"; import { MoveCategory } from "#enums/MoveCategory"; diff --git a/src/data/balance/biomes.ts b/src/data/balance/biomes.ts index c722291c66d..968164c7902 100644 --- a/src/data/balance/biomes.ts +++ b/src/data/balance/biomes.ts @@ -1,5 +1,5 @@ import { PokemonType } from "#enums/pokemon-type"; -import { randSeedInt, getEnumValues } from "#app/utils"; +import { randSeedInt, getEnumValues } from "#app/utils/common"; import type { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions"; import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import i18next from "i18next"; diff --git a/src/data/balance/egg-moves.ts b/src/data/balance/egg-moves.ts index 74f6a2c1afb..b0e8d5160fa 100644 --- a/src/data/balance/egg-moves.ts +++ b/src/data/balance/egg-moves.ts @@ -1,5 +1,5 @@ import { allMoves } from "#app/data/moves/move"; -import { getEnumKeys, getEnumValues } from "#app/utils"; +import { getEnumKeys, getEnumValues } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/src/data/balance/pokemon-evolutions.ts b/src/data/balance/pokemon-evolutions.ts index 17f71f3c3c9..64409c3c989 100644 --- a/src/data/balance/pokemon-evolutions.ts +++ b/src/data/balance/pokemon-evolutions.ts @@ -3,7 +3,7 @@ import { Gender } from "#app/data/gender"; import { PokeballType } from "#enums/pokeball"; import type Pokemon from "#app/field/pokemon"; import { PokemonType } from "#enums/pokemon-type"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { WeatherType } from "#enums/weather-type"; import { Nature } from "#enums/nature"; import { Biome } from "#enums/biome"; @@ -14,6 +14,7 @@ import { DamageMoneyRewardModifier, ExtraModifierModifier, MoneyMultiplierModifi import { SpeciesFormKey } from "#enums/species-form-key"; import { speciesStarterCosts } from "./starters"; import i18next from "i18next"; +import { initI18n } from "#app/plugins/i18n"; export enum SpeciesWildEvolutionDelay { @@ -95,6 +96,9 @@ export class SpeciesFormEvolution { public description = ""; constructor(speciesId: Species, preFormKey: string | null, evoFormKey: string | null, level: number, item: EvolutionItem | null, condition: SpeciesEvolutionCondition | null, wildDelay?: SpeciesWildEvolutionDelay) { + if (!i18next.isInitialized) { + initI18n(); + } this.speciesId = speciesId; this.preFormKey = preFormKey; this.evoFormKey = evoFormKey; diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 511c80bee72..0999e9db6ff 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -2,11 +2,11 @@ import { globalScene } from "#app/global-scene"; import { AttackMove, BeakBlastHeaderAttr, DelayedAttackAttr, SelfStatusMove, allMoves } from "./moves/move"; import { MoveFlags } from "#enums/MoveFlags"; import type Pokemon from "../field/pokemon"; -import { type nil, getFrameMs, getEnumKeys, getEnumValues, animationFileName } from "../utils"; +import { type nil, getFrameMs, getEnumKeys, getEnumValues, animationFileName } from "../utils/common"; import type { BattlerIndex } from "../battle"; import { Moves } from "#enums/moves"; import { SubstituteTag } from "./battler-tags"; -import { isNullOrUndefined } from "../utils"; +import { isNullOrUndefined } from "../utils/common"; import Phaser from "phaser"; import { EncounterAnim } from "#enums/encounter-anims"; diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 9b72f3083fd..3b2421897c9 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -33,7 +33,7 @@ import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import type { StatStageChangeCallback } from "#app/phases/stat-stage-change-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import i18next from "#app/plugins/i18n"; -import { BooleanHolder, getFrameMs, NumberHolder, toDmgValue } from "#app/utils"; +import { BooleanHolder, getFrameMs, NumberHolder, toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; @@ -42,7 +42,7 @@ import { Species } from "#enums/species"; import { EFFECTIVE_STATS, getStatKey, Stat, type BattleStat, type EffectiveStat } from "#enums/stat"; import { StatusEffect } from "#enums/status-effect"; import { WeatherType } from "#enums/weather-type"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; export enum BattlerTagLapseType { FAINT, diff --git a/src/data/berry.ts b/src/data/berry.ts index e118b45711c..22950c0beca 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -2,7 +2,7 @@ import { getPokemonNameWithAffix } from "../messages"; import type Pokemon from "../field/pokemon"; import { HitResult } from "../field/pokemon"; import { getStatusEffectHealText } from "./status-effect"; -import { NumberHolder, toDmgValue, randSeedInt } from "#app/utils"; +import { NumberHolder, toDmgValue, randSeedInt } from "#app/utils/common"; import { DoubleBerryEffectAbAttr, PostItemLostAbAttr, diff --git a/src/data/challenge.ts b/src/data/challenge.ts index cc5783ad1fb..f786152ca3d 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -1,4 +1,4 @@ -import { BooleanHolder, type NumberHolder, randSeedItem, deepCopy } from "#app/utils"; +import { BooleanHolder, type NumberHolder, randSeedItem, deepCopy } from "#app/utils/common"; import i18next from "i18next"; import type { DexAttrProps, GameData } from "#app/system/game-data"; import { defaultStarterSpecies } from "#app/system/game-data"; diff --git a/src/data/custom-pokemon-data.ts b/src/data/custom-pokemon-data.ts index d95d9f77b83..704835e9dbc 100644 --- a/src/data/custom-pokemon-data.ts +++ b/src/data/custom-pokemon-data.ts @@ -1,6 +1,6 @@ import type { Abilities } from "#enums/abilities"; import type { PokemonType } from "#enums/pokemon-type"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import type { Nature } from "#enums/nature"; /** diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index 3438510d613..8a1632ce160 100644 --- a/src/data/daily-run.ts +++ b/src/data/daily-run.ts @@ -3,7 +3,7 @@ import type { Species } from "#enums/species"; import { globalScene } from "#app/global-scene"; import { PlayerPokemon } from "#app/field/pokemon"; import type { Starter } from "#app/ui/starter-select-ui-handler"; -import { randSeedGauss, randSeedInt, randSeedItem, getEnumValues } from "#app/utils"; +import { randSeedGauss, randSeedInt, randSeedItem, getEnumValues } from "#app/utils/common"; import type { PokemonSpeciesForm } from "#app/data/pokemon-species"; import PokemonSpecies, { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; diff --git a/src/data/egg.ts b/src/data/egg.ts index 13ab0bec479..55a253e843f 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -4,7 +4,7 @@ import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; import { VariantTier } from "#enums/variant-tier"; -import { randInt, randomString, randSeedInt, getIvsFromId } from "#app/utils"; +import { randInt, randomString, randSeedInt, getIvsFromId } from "#app/utils/common"; import Overrides from "#app/overrides"; import { pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import type { PlayerPokemon } from "#app/field/pokemon"; diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 7a2834c0322..513ab3f6a74 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -29,7 +29,7 @@ import { } from "../status-effect"; import { getTypeDamageMultiplier } from "../type"; import { PokemonType } from "#enums/pokemon-type"; -import { BooleanHolder, NumberHolder, isNullOrUndefined, toDmgValue, randSeedItem, randSeedInt, getEnumValues, toReadableString, type Constructor } from "#app/utils"; +import { BooleanHolder, NumberHolder, isNullOrUndefined, toDmgValue, randSeedItem, randSeedInt, getEnumValues, toReadableString, type Constructor } from "#app/utils/common"; import { WeatherType } from "#enums/weather-type"; import type { ArenaTrapTag } from "../arena-tag"; import { ArenaTagSide, WeakenMoveTypeTag } from "../arena-tag"; diff --git a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts index a49157f8e88..d8af7b6aac8 100644 --- a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts +++ b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts @@ -14,7 +14,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { TrainerType } from "#enums/trainer-type"; import { Species } from "#enums/species"; import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import i18next from "i18next"; import type { IEggOptions } from "#app/data/egg"; import { EggSourceType } from "#enums/egg-source-types"; diff --git a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts index 85f40a41e51..0a270aebf37 100644 --- a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts +++ b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts @@ -24,7 +24,7 @@ import { BerryModifier, PokemonInstantReviveModifier } from "#app/modifier/modif import { getPokemonSpecies } from "#app/data/pokemon-species"; import { Moves } from "#enums/moves"; import { BattlerTagType } from "#enums/battler-tag-type"; -import { randInt } from "#app/utils"; +import { randInt } from "#app/utils/common"; import { BattlerIndex } from "#app/battle"; import { applyModifierTypeToPlayerPokemon, diff --git a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts index 94e27e32773..bf49dfdea91 100644 --- a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts +++ b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts @@ -13,7 +13,7 @@ import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import type { BerryModifierType, ModifierTypeOption } from "#app/modifier/modifier-type"; import { ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts b/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts index 1e4c9a3b957..8dfd1a270bd 100644 --- a/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts +++ b/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts @@ -16,7 +16,7 @@ import { TrainerSlot } from "#enums/trainer-slot"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PartyMemberStrength } from "#enums/party-member-strength"; import { globalScene } from "#app/global-scene"; -import { isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils"; +import { isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils/common"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts index 5edc2e6bbc5..07688db4583 100644 --- a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts +++ b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts @@ -31,9 +31,9 @@ import { import { PokemonType } from "#enums/pokemon-type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { randSeedInt, randSeedShuffle } from "#app/utils"; +import { randSeedInt, randSeedShuffle } from "#app/utils/common"; import { showEncounterDialogue, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import type { OptionSelectConfig } from "#app/ui/abstact-option-select-ui-handler"; import type { PlayerPokemon } from "#app/field/pokemon"; @@ -437,7 +437,7 @@ async function handleSwapAbility() { await showEncounterDialogue(`${namespace}:option.1.apply_ability_dialogue`, `${namespace}:speaker`); await showEncounterText(`${namespace}:option.1.apply_ability_message`); - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { displayYesNoOptions(resolve); }); }); @@ -467,7 +467,7 @@ function displayYesNoOptions(resolve) { maxOptions: 7, yOffset: 0, }; - globalScene.ui.setModeWithoutClear(Mode.OPTION_SELECT, config, null, true); + globalScene.ui.setModeWithoutClear(UiMode.OPTION_SELECT, config, null, true); } function onYesAbilitySwap(resolve) { @@ -477,11 +477,11 @@ function onYesAbilitySwap(resolve) { applyAbilityOverrideToPokemon(pokemon, encounter.misc.ability); encounter.setDialogueToken("chosenPokemon", pokemon.getNameToRender()); - globalScene.ui.setMode(Mode.MESSAGE).then(() => resolve(true)); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => resolve(true)); }; const onPokemonNotSelected = () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { displayYesNoOptions(resolve); }); }; diff --git a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts index 6c4c8f26deb..85ebf175f43 100644 --- a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts +++ b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts @@ -1,5 +1,5 @@ import type { PokemonType } from "#enums/pokemon-type"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts index 364484cb511..e57955c324a 100644 --- a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts +++ b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts @@ -32,7 +32,7 @@ import { modifierTypes } from "#app/modifier/modifier-type"; import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; import i18next from "#app/plugins/i18n"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; -import { randSeedItem } from "#app/utils"; +import { randSeedItem } from "#app/utils/common"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; diff --git a/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts b/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts index 9b8e2e24d12..6a26cf19d7f 100644 --- a/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts +++ b/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts @@ -4,7 +4,7 @@ import { } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { ModifierTypeFunc } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts index f0b7a05a21c..f0fb6398334 100644 --- a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts +++ b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts @@ -30,7 +30,7 @@ import { PokemonMove } from "#app/field/pokemon"; import { Moves } from "#enums/moves"; import { EncounterBattleAnim } from "#app/data/battle-anims"; import { WeatherType } from "#enums/weather-type"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { StatusEffect } from "#enums/status-effect"; import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { diff --git a/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts b/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts index 595d13cf727..d9b4140c6ee 100644 --- a/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts +++ b/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts @@ -31,7 +31,7 @@ import { import PokemonData from "#app/system/pokemon-data"; import { BattlerTagType } from "#enums/battler-tag-type"; import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; diff --git a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts index f80620647b0..63db5c7c5d6 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -23,7 +23,14 @@ import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import { getTypeRgb } from "#app/data/type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { NumberHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle, randSeedItem } from "#app/utils"; +import { + NumberHolder, + isNullOrUndefined, + randInt, + randSeedInt, + randSeedShuffle, + randSeedItem, +} from "#app/utils/common"; import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon, PokemonMove } from "#app/field/pokemon"; diff --git a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts index 5f88ca083c0..b10f2f3dba2 100644 --- a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts @@ -12,7 +12,7 @@ import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PartyMemberStrength } from "#enums/party-member-strength"; import { globalScene } from "#app/global-scene"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts index c295e36749a..8877bf36ce8 100644 --- a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts @@ -18,7 +18,7 @@ import { getPokemonSpecies } from "#app/data/pokemon-species"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { ModifierTier } from "#app/modifier/modifier-tier"; import { GameOverPhase } from "#app/phases/game-over-phase"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts index 8c45fde3079..602a8d397db 100644 --- a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts +++ b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts @@ -15,7 +15,7 @@ import { HiddenAbilityRateBoosterModifier, IvScannerModifier } from "#app/modifi import type { EnemyPokemon } from "#app/field/pokemon"; import { PokeballType } from "#enums/pokeball"; import { PlayerGender } from "#enums/player-gender"; -import { NumberHolder, randSeedInt } from "#app/utils"; +import { NumberHolder, randSeedInt } from "#app/utils/common"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; diff --git a/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts b/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts index b9476d49fec..79f4b53a73e 100644 --- a/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts +++ b/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts @@ -8,7 +8,7 @@ import { import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { modifierTypes } from "#app/modifier/modifier-type"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts index 806a89a7131..ef3532b080e 100644 --- a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts +++ b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts @@ -7,7 +7,7 @@ import { transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts index c189e341089..ab2f19cfb77 100644 --- a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts @@ -7,7 +7,7 @@ import { import { trainerConfigs } from "#app/data/trainers/trainer-config"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; -import { randSeedShuffle } from "#app/utils"; +import { randSeedShuffle } from "#app/utils/common"; import type MysteryEncounter from "../mystery-encounter"; import { MysteryEncounterBuilder } from "../mystery-encounter"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts index fb55c55a1a3..4e8e1c2524e 100644 --- a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts @@ -3,7 +3,7 @@ import { transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/training-session-encounter.ts b/src/data/mystery-encounters/encounters/training-session-encounter.ts index e8711be172d..11d00f1dd8c 100644 --- a/src/data/mystery-encounters/encounters/training-session-encounter.ts +++ b/src/data/mystery-encounters/encounters/training-session-encounter.ts @@ -15,7 +15,7 @@ import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; import { AbilityAttr } from "#app/system/game-data"; import PokemonData from "#app/system/pokemon-data"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; -import { isNullOrUndefined, randSeedShuffle } from "#app/utils"; +import { isNullOrUndefined, randSeedShuffle } from "#app/utils/common"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts b/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts index e60fe0ddc18..1ff96f21edc 100644 --- a/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts +++ b/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts @@ -27,7 +27,7 @@ import { Moves } from "#enums/moves"; import { BattlerIndex } from "#app/battle"; import { PokemonMove } from "#app/field/pokemon"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; /** the i18n namespace for this encounter */ const namespace = "mysteryEncounters/trashToTreasure"; diff --git a/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts b/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts index ed1866c7a1b..66c7f7afc56 100644 --- a/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts +++ b/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts @@ -27,7 +27,7 @@ import { getSpriteKeysFromPokemon, } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import PokemonData from "#app/system/pokemon-data"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import type { Moves } from "#enums/moves"; import { BattlerIndex } from "#app/battle"; import { SelfStatusMove } from "#app/data/moves/move"; diff --git a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts index 22ec52e976c..cd9ffefb516 100644 --- a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts +++ b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts @@ -17,7 +17,7 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; -import { NumberHolder, isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils"; +import { NumberHolder, isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils/common"; import type PokemonSpecies from "#app/data/pokemon-species"; import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; diff --git a/src/data/mystery-encounters/mystery-encounter-option.ts b/src/data/mystery-encounters/mystery-encounter-option.ts index f360658c2dc..57dd50fa972 100644 --- a/src/data/mystery-encounters/mystery-encounter-option.ts +++ b/src/data/mystery-encounters/mystery-encounter-option.ts @@ -12,7 +12,7 @@ import { } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import type { CanLearnMoveRequirementOptions } from "./requirements/can-learn-move-requirement"; import { CanLearnMoveRequirement } from "./requirements/can-learn-move-requirement"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; // biome-ignore lint/suspicious/noConfusingVoidType: void unions in callbacks are OK diff --git a/src/data/mystery-encounters/mystery-encounter-requirements.ts b/src/data/mystery-encounters/mystery-encounter-requirements.ts index 948e3e96ef0..49fd632932c 100644 --- a/src/data/mystery-encounters/mystery-encounter-requirements.ts +++ b/src/data/mystery-encounters/mystery-encounter-requirements.ts @@ -9,7 +9,7 @@ import { WeatherType } from "#enums/weather-type"; import type { PlayerPokemon } from "#app/field/pokemon"; import { AttackTypeBoosterModifier } from "#app/modifier/modifier"; import type { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import type { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; diff --git a/src/data/mystery-encounters/mystery-encounter-save-data.ts b/src/data/mystery-encounters/mystery-encounter-save-data.ts index 7c8110628f0..dd633390e46 100644 --- a/src/data/mystery-encounters/mystery-encounter-save-data.ts +++ b/src/data/mystery-encounters/mystery-encounter-save-data.ts @@ -1,6 +1,6 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT } from "#app/data/mystery-encounters/mystery-encounters"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import type { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; export class SeenEncounterData { diff --git a/src/data/mystery-encounters/mystery-encounter.ts b/src/data/mystery-encounters/mystery-encounter.ts index ff098d4d7dd..e305252ed0f 100644 --- a/src/data/mystery-encounters/mystery-encounter.ts +++ b/src/data/mystery-encounters/mystery-encounter.ts @@ -1,11 +1,11 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PlayerPokemon, PokemonMove } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; -import { capitalizeFirstLetter, isNullOrUndefined } from "#app/utils"; +import { capitalizeFirstLetter, isNullOrUndefined } from "#app/utils/common"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import type { MysteryEncounterSpriteConfig } from "#app/field/mystery-encounter-intro"; import MysteryEncounterIntroVisuals from "#app/field/mystery-encounter-intro"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import type { StatusEffect } from "#enums/status-effect"; import type { OptionTextDisplay } from "./mystery-encounter-dialogue"; import type MysteryEncounterDialogue from "./mystery-encounter-dialogue"; diff --git a/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts b/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts index a7ffe3e26ca..37194aef78e 100644 --- a/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts +++ b/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts @@ -1,7 +1,7 @@ import type { Moves } from "#app/enums/moves"; import type { PlayerPokemon } from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { EncounterPokemonRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts b/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts index 94790145687..296d94093d9 100644 --- a/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import type { TextStyle } from "#app/ui/text"; import { getTextWithColors } from "#app/ui/text"; import { UiTheme } from "#enums/ui-theme"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import i18next from "i18next"; /** diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 69b0d81520a..d77b70caa31 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -30,8 +30,8 @@ import type PokemonData from "#app/system/pokemon-data"; import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import type { PartyOption, PokemonSelectFilter } from "#app/ui/party-ui-handler"; import { PartyUiMode } from "#app/ui/party-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { isNullOrUndefined, randSeedInt, randomString, randSeedItem } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isNullOrUndefined, randSeedInt, randomString, randSeedItem } from "#app/utils/common"; import type { BattlerTagType } from "#enums/battler-tag-type"; import { Biome } from "#enums/biome"; import type { TrainerType } from "#enums/trainer-type"; @@ -563,7 +563,7 @@ export function selectPokemonForOption( // Open party screen to choose pokemon globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, _option: PartyOption) => { @@ -581,7 +581,7 @@ export function selectPokemonForOption( } // There is a second option to choose after selecting the Pokemon - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { const displayOptions = () => { // Always appends a cancel option to bottom of options const fullOptions = secondaryOptions @@ -623,7 +623,7 @@ export function selectPokemonForOption( if (fullOptions[0].onHover) { fullOptions[0].onHover(); } - globalScene.ui.setModeWithoutClear(Mode.OPTION_SELECT, config, null, true); + globalScene.ui.setModeWithoutClear(UiMode.OPTION_SELECT, config, null, true); }; const textPromptKey = @@ -673,20 +673,20 @@ export function selectOptionThenPokemon( const modeToSetOnExit = globalScene.ui.getMode(); const displayOptions = (config: OptionSelectConfig) => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { if (!optionSelectPromptKey) { // Do hover over the starting selection option if (fullOptions[0].onHover) { fullOptions[0].onHover(); } - globalScene.ui.setMode(Mode.OPTION_SELECT, config); + globalScene.ui.setMode(UiMode.OPTION_SELECT, config); } else { showEncounterText(optionSelectPromptKey).then(() => { // Do hover over the starting selection option if (fullOptions[0].onHover) { fullOptions[0].onHover(); } - globalScene.ui.setMode(Mode.OPTION_SELECT, config); + globalScene.ui.setMode(UiMode.OPTION_SELECT, config); }); } }); @@ -695,7 +695,7 @@ export function selectOptionThenPokemon( const selectPokemonAfterOption = (selectedOptionIndex: number) => { // Open party screen to choose a Pokemon globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, _option: PartyOption) => { diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index a4787e819b8..ed94a46ac18 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import i18next from "i18next"; -import { isNullOrUndefined, randSeedInt } from "#app/utils"; +import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { PokemonHeldItemModifier } from "#app/modifier/modifier"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; @@ -14,7 +14,7 @@ import { PlayerGender } from "#enums/player-gender"; import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims"; import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; import { achvs } from "#app/system/achv"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { PartyOption } from "#app/ui/party-ui-handler"; import { PartyUiMode } from "#app/ui/party-ui-handler"; import { Species } from "#enums/species"; @@ -714,7 +714,7 @@ export async function catchPokemon( () => { globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); globalScene.ui.setMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { const newPokemon = globalScene.addPlayerPokemon( pokemon.species, @@ -729,12 +729,12 @@ export async function catchPokemon( pokemon, ); globalScene.ui.setMode( - Mode.SUMMARY, + UiMode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { promptRelease(); }); }, @@ -749,13 +749,13 @@ export async function catchPokemon( female: pokemon.gender === Gender.FEMALE, }; globalScene.ui.setOverlayMode( - Mode.POKEDEX_PAGE, + UiMode.POKEDEX_PAGE, pokemon.species, pokemon.formIndex, attributes, null, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { promptRelease(); }); }, @@ -763,11 +763,11 @@ export async function catchPokemon( }, () => { globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.RELEASE, 0, (slotIndex: number, _option: PartyOption) => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { if (slotIndex < 6) { addToParty(slotIndex); } else { @@ -778,7 +778,7 @@ export async function catchPokemon( ); }, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { removePokemon(); end(); }); diff --git a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts index 15085bb2bf8..578c2efefdb 100644 --- a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts +++ b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts @@ -1,5 +1,5 @@ import type { PlayerPokemon } from "#app/field/pokemon"; -import { getFrameMs } from "#app/utils"; +import { getFrameMs } from "#app/utils/common"; import { cos, sin } from "#app/field/anims"; import { getTypeRgb } from "#app/data/type"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/nature.ts b/src/data/nature.ts index 2ab4723c10d..83b3ee7538d 100644 --- a/src/data/nature.ts +++ b/src/data/nature.ts @@ -1,4 +1,4 @@ -import { toReadableString } from "#app/utils"; +import { toReadableString } from "#app/utils/common"; import { TextStyle, getBBCodeFrag } from "../ui/text"; import { Nature } from "#enums/nature"; import { UiTheme } from "#enums/ui-theme"; diff --git a/src/data/pokeball.ts b/src/data/pokeball.ts index b0744237755..7a44ebdda7c 100644 --- a/src/data/pokeball.ts +++ b/src/data/pokeball.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { CriticalCatchChanceBoosterModifier } from "#app/modifier/modifier"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { PokeballType } from "#enums/pokeball"; import i18next from "i18next"; diff --git a/src/data/pokemon-forms.ts b/src/data/pokemon-forms.ts index 63e166c7fc4..f76462d2725 100644 --- a/src/data/pokemon-forms.ts +++ b/src/data/pokemon-forms.ts @@ -3,7 +3,7 @@ import type Pokemon from "../field/pokemon"; import { StatusEffect } from "#enums/status-effect"; import { allMoves } from "./moves/move"; import { MoveCategory } from "#enums/MoveCategory"; -import type { Constructor, nil } from "#app/utils"; +import type { Constructor, nil } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 75ea07edd40..95ff28e61e0 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -8,7 +8,7 @@ import type { AnySound } from "#app/battle-scene"; import { globalScene } from "#app/global-scene"; import type { GameMode } from "#app/game-mode"; import { DexAttr, type StarterMoveset } from "#app/system/game-data"; -import { isNullOrUndefined, capitalizeString, randSeedInt, randSeedGauss, randSeedItem } from "#app/utils"; +import { isNullOrUndefined, capitalizeString, randSeedInt, randSeedGauss, randSeedItem } from "#app/utils/common"; import { uncatchableSpecies } from "#app/data/balance/biomes"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { GrowthRate } from "#app/data/exp"; diff --git a/src/data/status-effect.ts b/src/data/status-effect.ts index fe4fa380d46..a90304c9f7d 100644 --- a/src/data/status-effect.ts +++ b/src/data/status-effect.ts @@ -1,4 +1,4 @@ -import { randIntRange } from "#app/utils"; +import { randIntRange } from "#app/utils/common"; import { StatusEffect } from "#enums/status-effect"; import type { ParseKeys } from "i18next"; import i18next from "i18next"; diff --git a/src/data/trainer-names.ts b/src/data/trainer-names.ts index 195e5041d28..8714dad0fc9 100644 --- a/src/data/trainer-names.ts +++ b/src/data/trainer-names.ts @@ -1,5 +1,5 @@ import { TrainerType } from "#enums/trainer-type"; -import { toReadableString } from "#app/utils"; +import { toReadableString } from "#app/utils/common"; class TrainerNameConfig { public urls: string[]; diff --git a/src/data/trainers/TrainerPartyTemplate.ts b/src/data/trainers/TrainerPartyTemplate.ts index adbaacc6b55..5d02ffdc6af 100644 --- a/src/data/trainers/TrainerPartyTemplate.ts +++ b/src/data/trainers/TrainerPartyTemplate.ts @@ -1,4 +1,4 @@ -import { startingWave } from "#app/battle-scene"; +import { startingWave } from "#app/starting-wave"; import { globalScene } from "#app/global-scene"; import { PartyMemberStrength } from "#enums/party-member-strength"; diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index d9922ecc097..fec1d4757e7 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import { modifierTypes } from "#app/modifier/modifier-type"; import { PokemonMove } from "#app/field/pokemon"; -import { toReadableString, isNullOrUndefined, randSeedItem, randSeedInt } from "#app/utils"; +import { toReadableString, isNullOrUndefined, randSeedItem, randSeedInt } from "#app/utils/common"; import { pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { tmSpecies } from "#app/data/balance/tms"; diff --git a/src/data/weather.ts b/src/data/weather.ts index 31b460bbddb..81559304661 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -5,7 +5,7 @@ import type Pokemon from "../field/pokemon"; import { PokemonType } from "#enums/pokemon-type"; import type Move from "./moves/move"; import { AttackMove } from "./moves/move"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { SuppressWeatherEffectAbAttr } from "./abilities/ability"; import { TerrainType, getTerrainName } from "./terrain"; import i18next from "i18next"; diff --git a/src/enums/ui-mode.ts b/src/enums/ui-mode.ts new file mode 100644 index 00000000000..dcf6bd2a238 --- /dev/null +++ b/src/enums/ui-mode.ts @@ -0,0 +1,47 @@ +export enum UiMode { + MESSAGE, + TITLE, + COMMAND, + FIGHT, + BALL, + TARGET_SELECT, + MODIFIER_SELECT, + SAVE_SLOT, + PARTY, + SUMMARY, + STARTER_SELECT, + EVOLUTION_SCENE, + EGG_HATCH_SCENE, + EGG_HATCH_SUMMARY, + CONFIRM, + OPTION_SELECT, + MENU, + MENU_OPTION_SELECT, + SETTINGS, + SETTINGS_DISPLAY, + SETTINGS_AUDIO, + SETTINGS_GAMEPAD, + GAMEPAD_BINDING, + SETTINGS_KEYBOARD, + KEYBOARD_BINDING, + ACHIEVEMENTS, + GAME_STATS, + EGG_LIST, + EGG_GACHA, + POKEDEX, + POKEDEX_SCAN, + POKEDEX_PAGE, + LOGIN_FORM, + REGISTRATION_FORM, + LOADING, + SESSION_RELOAD, + UNAVAILABLE, + CHALLENGE_SELECT, + RENAME_POKEMON, + RUN_HISTORY, + RUN_INFO, + TEST_DIALOGUE, + AUTO_COMPLETE, + ADMIN, + MYSTERY_ENCOUNTER +} diff --git a/src/field/anims.ts b/src/field/anims.ts index eb895c2d8f9..2fd23e4262b 100644 --- a/src/field/anims.ts +++ b/src/field/anims.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import { PokeballType } from "#enums/pokeball"; import type { Variant } from "#app/sprites/variant"; -import { getFrameMs, randGauss } from "#app/utils"; +import { getFrameMs, randGauss } from "#app/utils/common"; export function addPokeballOpenParticles(x: number, y: number, pokeballType: PokeballType): void { switch (pokeballType) { diff --git a/src/field/arena.ts b/src/field/arena.ts index 1bc465c7dbb..f083180490b 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import type { BiomeTierTrainerPools, PokemonPools } from "#app/data/balance/biomes"; import { biomePokemonPools, BiomePoolTier, biomeTrainerPools } from "#app/data/balance/biomes"; -import { randSeedInt, NumberHolder, isNullOrUndefined, type Constructor } from "#app/utils"; +import { randSeedInt, NumberHolder, isNullOrUndefined, type Constructor } from "#app/utils/common"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { diff --git a/src/field/damage-number-handler.ts b/src/field/damage-number-handler.ts index a527b148fff..bfb85018dd6 100644 --- a/src/field/damage-number-handler.ts +++ b/src/field/damage-number-handler.ts @@ -2,7 +2,7 @@ import { TextStyle, addTextObject } from "../ui/text"; import type { DamageResult } from "./pokemon"; import type Pokemon from "./pokemon"; import { HitResult } from "./pokemon"; -import { formatStat, fixedInt } from "#app/utils"; +import { formatStat, fixedInt } from "#app/utils/common"; import type { BattlerIndex } from "../battle"; import { globalScene } from "#app/global-scene"; diff --git a/src/field/mystery-encounter-intro.ts b/src/field/mystery-encounter-intro.ts index e1fb0c37074..b6212b6b031 100644 --- a/src/field/mystery-encounter-intro.ts +++ b/src/field/mystery-encounter-intro.ts @@ -2,7 +2,7 @@ import type { GameObjects } from "phaser"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import type { Species } from "#enums/species"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import type { Variant } from "#app/sprites/variant"; import { doShinySparkleAnim } from "#app/field/anims"; diff --git a/src/field/pokemon-sprite-sparkle-handler.ts b/src/field/pokemon-sprite-sparkle-handler.ts index d2f69500258..cceb0bd7717 100644 --- a/src/field/pokemon-sprite-sparkle-handler.ts +++ b/src/field/pokemon-sprite-sparkle-handler.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import Pokemon from "./pokemon"; -import { fixedInt, randInt } from "#app/utils"; +import { fixedInt, randInt } from "#app/utils/common"; export default class PokemonSpriteSparkleHandler { private sprites: Set; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 27c4edea297..0242820dcde 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -55,7 +55,7 @@ import { getStarterValueFriendshipCap, speciesStarterCosts, } from "#app/data/balance/starters"; -import { NumberHolder, randSeedInt, getIvsFromId, BooleanHolder, randSeedItem, isNullOrUndefined, getEnumValues, toDmgValue, fixedInt, rgbaToInt, rgbHexToRgba, rgbToHsv, deltaRgb, isBetween, type nil, type Constructor } from "#app/utils"; +import { NumberHolder, randSeedInt, getIvsFromId, BooleanHolder, randSeedItem, isNullOrUndefined, getEnumValues, toDmgValue, fixedInt, rgbaToInt, rgbHexToRgba, rgbToHsv, deltaRgb, isBetween, type nil, type Constructor } from "#app/utils/common"; import type { TypeDamageMultiplier } from "#app/data/type"; import { getTypeDamageMultiplier, getTypeRgb } from "#app/data/type"; import { PokemonType } from "#enums/pokemon-type"; @@ -193,7 +193,7 @@ import { import { allAbilities } from "#app/data/data-lists"; import type PokemonData from "#app/system/pokemon-data"; import { BattlerIndex } from "#app/battle"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { PartyOption } from "#app/ui/party-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler"; import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; @@ -6581,7 +6581,7 @@ export class PlayerPokemon extends Pokemon { this.leaveField(switchType === SwitchType.SWITCH); globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.FAINT_SWITCH, this.getFieldIndex(), (slotIndex: number, option: PartyOption) => { @@ -6599,7 +6599,7 @@ export class PlayerPokemon extends Pokemon { MoveEndPhase, ); } - globalScene.ui.setMode(Mode.MESSAGE).then(resolve); + globalScene.ui.setMode(UiMode.MESSAGE).then(resolve); }, PartyUiHandler.FilterNonFainted, ); diff --git a/src/field/trainer.ts b/src/field/trainer.ts index 1679e6f12e0..6b0a54b2103 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -11,7 +11,7 @@ import { TrainerSlot } from "#enums/trainer-slot"; import { TrainerPoolTier } from "#enums/trainer-pool-tier"; import { TeraAIMode } from "#enums/tera-ai-mode"; import type { EnemyPokemon } from "#app/field/pokemon"; -import { randSeedWeightedItem, randSeedItem, randSeedInt } from "#app/utils"; +import { randSeedWeightedItem, randSeedItem, randSeedInt } from "#app/utils/common"; import type { PersistentModifier } from "#app/modifier/modifier"; import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag"; import { getIsInitialized, initI18n } from "#app/plugins/i18n"; diff --git a/src/game-mode.ts b/src/game-mode.ts index 4779fda50e8..dfe6b8cf123 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -7,7 +7,7 @@ import type PokemonSpecies from "./data/pokemon-species"; import { allSpecies } from "./data/pokemon-species"; import type { Arena } from "./field/arena"; import Overrides from "#app/overrides"; -import { randSeedInt, randSeedItem } from "#app/utils"; +import { randSeedInt, randSeedItem } from "#app/utils/common"; import { Biome } from "#enums/biome"; import { Species } from "#enums/species"; import { Challenges } from "./enums/challenges"; diff --git a/src/global-vars/bypass-login.ts b/src/global-vars/bypass-login.ts new file mode 100644 index 00000000000..3595a076101 --- /dev/null +++ b/src/global-vars/bypass-login.ts @@ -0,0 +1 @@ +export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; diff --git a/src/global-vars/starter-colors.ts b/src/global-vars/starter-colors.ts new file mode 100644 index 00000000000..6abe028be99 --- /dev/null +++ b/src/global-vars/starter-colors.ts @@ -0,0 +1,4 @@ +export const starterColors: StarterColors = {}; +interface StarterColors { + [key: string]: [string, string]; +} diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index f92ce3957ab..7fde0f2aca8 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -1,11 +1,11 @@ import Phaser from "phaser"; -import { deepCopy, getEnumValues } from "#app/utils"; +import { deepCopy, getEnumValues } from "#app/utils/common"; import pad_generic from "./configs/inputs/pad_generic"; import pad_unlicensedSNES from "./configs/inputs/pad_unlicensedSNES"; import pad_xbox360 from "./configs/inputs/pad_xbox360"; import pad_dualshock from "./configs/inputs/pad_dualshock"; import pad_procon from "./configs/inputs/pad_procon"; -import { Mode } from "./ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type SettingsGamepadUiHandler from "./ui/settings/settings-gamepad-ui-handler"; import type SettingsKeyboardUiHandler from "./ui/settings/settings-keyboard-ui-handler"; import cfg_keyboard_qwerty from "./configs/inputs/cfg_keyboard_qwerty"; @@ -235,7 +235,7 @@ export class InputsController { if (gamepadName) { this.selectedDevice[Device.GAMEPAD] = gamepadName.toLowerCase(); } - const handler = globalScene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; + const handler = globalScene.ui?.handlers[UiMode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; handler?.updateChosenGamepadDisplay(); } @@ -248,7 +248,7 @@ export class InputsController { if (layoutKeyboard) { this.selectedDevice[Device.KEYBOARD] = layoutKeyboard.toLowerCase(); } - const handler = globalScene.ui?.handlers[Mode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler; + const handler = globalScene.ui?.handlers[UiMode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler; handler?.updateChosenKeyboardDisplay(); } @@ -296,7 +296,7 @@ export class InputsController { globalScene.gameData?.saveMappingConfigs(gamepadID, this.configs[gamepadID]); } this.lastSource = "gamepad"; - const handler = globalScene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; + const handler = globalScene.ui?.handlers[UiMode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; handler?.updateChosenGamepadDisplay(); } @@ -406,7 +406,7 @@ export class InputsController { this.lastSource = "gamepad"; if ( !this.selectedDevice[Device.GAMEPAD] || - (globalScene.ui.getMode() !== Mode.GAMEPAD_BINDING && + (globalScene.ui.getMode() !== UiMode.GAMEPAD_BINDING && this.selectedDevice[Device.GAMEPAD] !== pad.id.toLowerCase()) ) { this.setChosenGamepad(pad.id); diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 4ec2fdf1bb2..914e6e961e2 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -4,7 +4,7 @@ import CacheBustedLoaderPlugin from "#app/plugins/cache-busted-loader-plugin"; import { SceneBase } from "#app/scene-base"; import { WindowVariant, getWindowVariantSuffix } from "#app/ui/ui-theme"; import { isMobile } from "#app/touch-controls"; -import { localPing, getEnumValues, hasAllLocalizedSprites, getEnumKeys } from "#app/utils"; +import { localPing, getEnumValues, hasAllLocalizedSprites, getEnumKeys } from "#app/utils/common"; import { initPokemonPrevolutions, initPokemonStarters } from "#app/data/balance/pokemon-evolutions"; import { initBiomes } from "#app/data/balance/biomes"; import { initEggMoves } from "#app/data/balance/egg-moves"; diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 8feb60c7778..219a6b6344b 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -114,7 +114,7 @@ import { NumberHolder, padInt, randSeedInt, -} from "#app/utils"; +} from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 851fa33cedc..3eaf4e3c510 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -15,7 +15,7 @@ import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import type { VoucherType } from "#app/system/voucher"; import { Command } from "#app/ui/command-ui-handler"; import { addTextObject, TextStyle } from "#app/ui/text"; -import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue } from "#app/utils"; +import { BooleanHolder, hslToHex, isNullOrUndefined, NumberHolder, toDmgValue } from "#app/utils/common"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; import type { Moves } from "#enums/moves"; diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 78021da4066..795aa7010e1 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -19,7 +19,7 @@ import { achvs } from "#app/system/achv"; import type { PartyOption } from "#app/ui/party-ui-handler"; import { PartyUiMode } from "#app/ui/party-ui-handler"; import { SummaryUiMode } from "#app/ui/summary-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { PokeballType } from "#enums/pokeball"; import { StatusEffect } from "#enums/status-effect"; import i18next from "i18next"; @@ -295,7 +295,7 @@ export class AttemptCapturePhase extends PokemonPhase { () => { globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); globalScene.ui.setMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { const newPokemon = globalScene.addPlayerPokemon( pokemon.species, @@ -310,12 +310,12 @@ export class AttemptCapturePhase extends PokemonPhase { pokemon, ); globalScene.ui.setMode( - Mode.SUMMARY, + UiMode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { promptRelease(); }); }, @@ -329,19 +329,26 @@ export class AttemptCapturePhase extends PokemonPhase { form: pokemon.formIndex, female: pokemon.gender === Gender.FEMALE, }; - globalScene.ui.setOverlayMode(Mode.POKEDEX_PAGE, pokemon.species, attributes, null, null, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - promptRelease(); - }); - }); + globalScene.ui.setOverlayMode( + UiMode.POKEDEX_PAGE, + pokemon.species, + attributes, + null, + null, + () => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { + promptRelease(); + }); + }, + ); }, () => { globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: number, _option: PartyOption) => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { if (slotIndex < 6) { addToParty(slotIndex); } else { @@ -352,7 +359,7 @@ export class AttemptCapturePhase extends PokemonPhase { ); }, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { removePokemon(); end(); }); diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 5c51e5c589d..eed5c3c522e 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -9,7 +9,7 @@ import { StatusEffect } from "#enums/status-effect"; import type { PlayerPokemon, EnemyPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import i18next from "i18next"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { BattleEndPhase } from "./battle-end-phase"; import { NewBattlePhase } from "./new-battle-phase"; import { PokemonPhase } from "./pokemon-phase"; diff --git a/src/phases/berry-phase.ts b/src/phases/berry-phase.ts index ae593f66f34..b20b1736d4f 100644 --- a/src/phases/berry-phase.ts +++ b/src/phases/berry-phase.ts @@ -4,7 +4,7 @@ import { BerryUsedEvent } from "#app/events/battle-scene"; import { getPokemonNameWithAffix } from "#app/messages"; import { BerryModifier } from "#app/modifier/modifier"; import i18next from "i18next"; -import { BooleanHolder } from "#app/utils"; +import { BooleanHolder } from "#app/utils/common"; import { FieldPhase } from "./field-phase"; import { CommonAnimPhase } from "./common-anim-phase"; import { globalScene } from "#app/global-scene"; diff --git a/src/phases/check-switch-phase.ts b/src/phases/check-switch-phase.ts index ba4837fd7cc..9d73411fd37 100644 --- a/src/phases/check-switch-phase.ts +++ b/src/phases/check-switch-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { BattleStyle } from "#app/enums/battle-style"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { getPokemonNameWithAffix } from "#app/messages"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { BattlePhase } from "./battle-phase"; import { SummonMissingPhase } from "./summon-missing-phase"; @@ -64,14 +64,14 @@ export class CheckSwitchPhase extends BattlePhase { null, () => { globalScene.ui.setMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.unshiftPhase(new SwitchPhase(SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true)); this.end(); }, () => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); this.end(); }, ); diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 30343f92aa3..c3e558e1d86 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -15,12 +15,12 @@ import type { PlayerPokemon, TurnMove } from "#app/field/pokemon"; import { FieldPosition } from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { FieldPhase } from "./field-phase"; import { SelectTargetPhase } from "./select-target-phase"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { ArenaTagSide } from "#app/data/arena-tag"; import { ArenaTagType } from "#app/enums/arena-tag-type"; @@ -38,7 +38,7 @@ export class CommandPhase extends FieldPhase { globalScene.updateGameInfo(); - const commandUiHandler = globalScene.ui.handlers[Mode.COMMAND]; + const commandUiHandler = globalScene.ui.handlers[UiMode.COMMAND]; // If one of these conditions is true, we always reset the cursor to Command.FIGHT const cursorResetEvent = @@ -127,7 +127,7 @@ export class CommandPhase extends FieldPhase { ) { this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, queuedMove); } else { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); } } } else { @@ -136,9 +136,9 @@ export class CommandPhase extends FieldPhase { globalScene.currentBattle.mysteryEncounter?.skipToFightInput ) { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex); + globalScene.ui.setMode(UiMode.FIGHT, this.fieldIndex); } else { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); } } } @@ -209,7 +209,7 @@ export class CommandPhase extends FieldPhase { success = true; } else if (cursor < playerPokemon.getMoveset().length) { const move = playerPokemon.getMoveset()[cursor]; - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); // Decides between a Disabled, Not Implemented, or No PP translation message const errorMessage = playerPokemon.isMoveRestricted(move.moveId, playerPokemon) @@ -226,7 +226,7 @@ export class CommandPhase extends FieldPhase { null, () => { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex); + globalScene.ui.setMode(UiMode.FIGHT, this.fieldIndex); }, null, true, @@ -244,27 +244,27 @@ export class CommandPhase extends FieldPhase { globalScene.arena.biomeType === Biome.END && (!globalScene.gameMode.isClassic || globalScene.gameMode.isFreshStartChallenge() || notInDex) ) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noPokeballForce"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, ); } else if (globalScene.currentBattle.battleType === BattleType.TRAINER) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noPokeballTrainer"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -273,14 +273,14 @@ export class CommandPhase extends FieldPhase { globalScene.currentBattle.isBattleMysteryEncounter() && !globalScene.currentBattle.mysteryEncounter!.catchAllowed ) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noPokeballMysteryEncounter"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -291,14 +291,14 @@ export class CommandPhase extends FieldPhase { .filter(p => p.isActive(true)) .map(p => p.getBattlerIndex()); if (targets.length > 1) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noPokeballMulti"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -311,14 +311,14 @@ export class CommandPhase extends FieldPhase { !targetPokemon?.hasAbility(Abilities.WONDER_GUARD, false, true) && cursor < PokeballType.MASTER_BALL ) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noPokeballStrong"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -347,14 +347,14 @@ export class CommandPhase extends FieldPhase { (arena.biomeType === Biome.END || (!isNullOrUndefined(mysteryEncounterFleeAllowed) && !mysteryEncounterFleeAllowed)) ) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noEscapeForce"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -364,14 +364,14 @@ export class CommandPhase extends FieldPhase { (currentBattle.battleType === BattleType.TRAINER || currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) ) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:noEscapeTrainer"), null, () => { globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); }, null, true, @@ -389,7 +389,7 @@ export class CommandPhase extends FieldPhase { } } else if (trappedAbMessages.length > 0) { if (!isSwitch) { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); } globalScene.ui.showText( trappedAbMessages[0], @@ -397,7 +397,7 @@ export class CommandPhase extends FieldPhase { () => { globalScene.ui.showText("", 0); if (!isSwitch) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); } }, null, @@ -412,8 +412,8 @@ export class CommandPhase extends FieldPhase { break; } if (!isSwitch) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.MESSAGE); } const showNoEscapeText = (tag: any) => { globalScene.ui.showText( @@ -429,7 +429,7 @@ export class CommandPhase extends FieldPhase { () => { globalScene.ui.showText("", 0); if (!isSwitch) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + globalScene.ui.setMode(UiMode.COMMAND, this.fieldIndex); } }, null, @@ -471,6 +471,6 @@ export class CommandPhase extends FieldPhase { } end() { - globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => super.end()); } } diff --git a/src/phases/damage-anim-phase.ts b/src/phases/damage-anim-phase.ts index 696a2e55b6f..b9581573f2e 100644 --- a/src/phases/damage-anim-phase.ts +++ b/src/phases/damage-anim-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; import { BattleSpec } from "#enums/battle-spec"; import { type DamageResult, HitResult } from "#app/field/pokemon"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { PokemonPhase } from "#app/phases/pokemon-phase"; export class DamageAnimPhase extends PokemonPhase { diff --git a/src/phases/egg-hatch-phase.ts b/src/phases/egg-hatch-phase.ts index 07eeeb0f8ae..69bcf741383 100644 --- a/src/phases/egg-hatch-phase.ts +++ b/src/phases/egg-hatch-phase.ts @@ -8,10 +8,10 @@ import { achvs } from "#app/system/achv"; import EggCounterContainer from "#app/ui/egg-counter-container"; import type EggHatchSceneHandler from "#app/ui/egg-hatch-scene-handler"; import PokemonInfoContainer from "#app/ui/pokemon-info-container"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; -import { fixedInt, getFrameMs, randInt } from "#app/utils"; +import { fixedInt, getFrameMs, randInt } from "#app/utils/common"; import type { EggLapsePhase } from "./egg-lapse-phase"; import type { EggHatchData } from "#app/data/egg-hatch-data"; import { doShinySparkleAnim } from "#app/field/anims"; @@ -76,7 +76,7 @@ export class EggHatchPhase extends Phase { start() { super.start(); - globalScene.ui.setModeForceTransition(Mode.EGG_HATCH_SCENE).then(() => { + globalScene.ui.setModeForceTransition(UiMode.EGG_HATCH_SCENE).then(() => { if (!this.egg) { return this.end(); } diff --git a/src/phases/egg-lapse-phase.ts b/src/phases/egg-lapse-phase.ts index 397eb970fec..4632e264c1d 100644 --- a/src/phases/egg-lapse-phase.ts +++ b/src/phases/egg-lapse-phase.ts @@ -5,7 +5,7 @@ import { Phase } from "#app/phase"; import i18next from "i18next"; import Overrides from "#app/overrides"; import { EggHatchPhase } from "./egg-hatch-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { achvs } from "#app/system/achv"; import type { PlayerPokemon } from "#app/field/pokemon"; import { EggSummaryPhase } from "./egg-summary-phase"; @@ -41,7 +41,7 @@ export class EggLapsePhase extends Phase { 0, ); globalScene.ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { this.hatchEggsSkipped(eggsToHatch); this.showSummary(); diff --git a/src/phases/egg-summary-phase.ts b/src/phases/egg-summary-phase.ts index 9d9259d1e67..d16cafa7611 100644 --- a/src/phases/egg-summary-phase.ts +++ b/src/phases/egg-summary-phase.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { EggHatchData } from "#app/data/egg-hatch-data"; /** @@ -22,7 +22,7 @@ export class EggSummaryPhase extends Phase { // updates next pokemon once the current update has been completed const updateNextPokemon = (i: number) => { if (i >= this.eggHatchData.length) { - globalScene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => { + globalScene.ui.setModeForceTransition(UiMode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => { globalScene.fadeOutBgm(undefined, false); }); } else { @@ -39,7 +39,7 @@ export class EggSummaryPhase extends Phase { end() { globalScene.time.delayedCall(250, () => globalScene.setModifiersVisible(true)); - globalScene.ui.setModeForceTransition(Mode.MESSAGE).then(() => { + globalScene.ui.setModeForceTransition(UiMode.MESSAGE).then(() => { super.end(); }); } diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index c196608f91e..6fd11c416a2 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -29,8 +29,8 @@ import { SummonPhase } from "#app/phases/summon-phase"; import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase"; import { achvs } from "#app/system/achv"; import { handleTutorial, Tutorial } from "#app/tutorial"; -import { Mode } from "#app/ui/ui"; -import { randSeedInt, randSeedItem } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { randSeedInt, randSeedItem } from "#app/utils/common"; import { BattleSpec } from "#enums/battle-spec"; import { Biome } from "#enums/biome"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; @@ -298,7 +298,7 @@ export class EncounterPhase extends BattlePhase { globalScene.currentBattle.trainer!.genAI(globalScene.getEnemyParty()); } - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { if (!this.loaded) { this.trySetWeatherIfNewBiome(); // Set weather before session gets saved // Game syncs to server on waves X1 and X6 (As of 1.2.0) diff --git a/src/phases/end-evolution-phase.ts b/src/phases/end-evolution-phase.ts index e0bdc7e0d68..579920dde90 100644 --- a/src/phases/end-evolution-phase.ts +++ b/src/phases/end-evolution-phase.ts @@ -1,11 +1,11 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; export class EndEvolutionPhase extends Phase { start() { super.start(); - globalScene.ui.setModeForceTransition(Mode.MESSAGE).then(() => this.end()); + globalScene.ui.setModeForceTransition(UiMode.MESSAGE).then(() => this.end()); } } diff --git a/src/phases/evolution-phase.ts b/src/phases/evolution-phase.ts index 203c7542eff..7b013555f40 100644 --- a/src/phases/evolution-phase.ts +++ b/src/phases/evolution-phase.ts @@ -5,8 +5,8 @@ import { globalScene } from "#app/global-scene"; import type { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions"; import { FusionSpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions"; import type EvolutionSceneHandler from "#app/ui/evolution-scene-handler"; -import { fixedInt, getFrameMs, randInt } from "#app/utils"; -import { Mode } from "#app/ui/ui"; +import { fixedInt, getFrameMs, randInt } from "#app/utils/common"; +import { UiMode } from "#enums/ui-mode"; import { cos, sin } from "#app/field/anims"; import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; @@ -53,7 +53,7 @@ export class EvolutionPhase extends Phase { } setMode(): Promise { - return globalScene.ui.setModeForceTransition(Mode.EVOLUTION_SCENE); + return globalScene.ui.setModeForceTransition(UiMode.EVOLUTION_SCENE); } start() { @@ -280,7 +280,7 @@ export class EvolutionPhase extends Phase { this.end(); }; globalScene.ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { globalScene.ui.revertMode(); this.pokemon.pauseEvolutions = true; diff --git a/src/phases/exp-phase.ts b/src/phases/exp-phase.ts index b7d62c92bcf..8841a90d5b1 100644 --- a/src/phases/exp-phase.ts +++ b/src/phases/exp-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { getPokemonNameWithAffix } from "#app/messages"; import { ExpBoosterModifier } from "#app/modifier/modifier"; import i18next from "i18next"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase"; import { LevelUpPhase } from "./level-up-phase"; diff --git a/src/phases/faint-phase.ts b/src/phases/faint-phase.ts index 2719206a6cc..5a25cf6330d 100644 --- a/src/phases/faint-phase.ts +++ b/src/phases/faint-phase.ts @@ -29,7 +29,7 @@ import { SwitchPhase } from "./switch-phase"; import { SwitchSummonPhase } from "./switch-summon-phase"; import { ToggleDoublePositionPhase } from "./toggle-double-position-phase"; import { VictoryPhase } from "./victory-phase"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { FRIENDSHIP_LOSS_FROM_FAINT } from "#app/data/balance/starters"; import { BattlerTagType } from "#enums/battler-tag-type"; diff --git a/src/phases/form-change-phase.ts b/src/phases/form-change-phase.ts index bf94284b117..ac7edadf244 100644 --- a/src/phases/form-change-phase.ts +++ b/src/phases/form-change-phase.ts @@ -1,10 +1,10 @@ import { globalScene } from "#app/global-scene"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { achvs } from "../system/achv"; import type { SpeciesFormChange } from "../data/pokemon-forms"; import { getSpeciesFormChangeMessage } from "../data/pokemon-forms"; import type { PlayerPokemon } from "../field/pokemon"; -import { Mode } from "../ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type PartyUiHandler from "../ui/party-ui-handler"; import { getPokemonNameWithAffix } from "../messages"; import { EndEvolutionPhase } from "./end-evolution-phase"; @@ -31,7 +31,7 @@ export class FormChangePhase extends EvolutionPhase { if (!this.modal) { return super.setMode(); } - return globalScene.ui.setOverlayMode(Mode.EVOLUTION_SCENE); + return globalScene.ui.setOverlayMode(UiMode.EVOLUTION_SCENE); } doEvolution(): void { @@ -181,7 +181,7 @@ export class FormChangePhase extends EvolutionPhase { this.pokemon.findAndRemoveTags(t => t.tagType === BattlerTagType.AUTOTOMIZED); if (this.modal) { globalScene.ui.revertMode().then(() => { - if (globalScene.ui.getMode() === Mode.PARTY) { + if (globalScene.ui.getMode() === UiMode.PARTY) { const partyUiHandler = globalScene.ui.getHandler() as PartyUiHandler; partyUiHandler.clearPartySlots(); partyUiHandler.populatePartySlots(); diff --git a/src/phases/game-over-modifier-reward-phase.ts b/src/phases/game-over-modifier-reward-phase.ts index d0a39a4031a..ab6f6554c99 100644 --- a/src/phases/game-over-modifier-reward-phase.ts +++ b/src/phases/game-over-modifier-reward-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { ModifierRewardPhase } from "./modifier-reward-phase"; @@ -10,7 +10,7 @@ export class GameOverModifierRewardPhase extends ModifierRewardPhase { globalScene.addModifier(newModifier); // Sound loaded into game as is globalScene.playSound("level_up_fanfare"); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.fadeIn(250).then(() => { globalScene.ui.showText( i18next.t("battle:rewardGain", { diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index 9e79eafe88b..304d876a99e 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -19,8 +19,8 @@ import { SummonPhase } from "#app/phases/summon-phase"; import { UnlockPhase } from "#app/phases/unlock-phase"; import { achvs, ChallengeAchv } from "#app/system/achv"; import { Unlockables } from "#app/system/unlockables"; -import { Mode } from "#app/ui/ui"; -import { isLocal, isLocalServerConnected } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isLocal, isLocalServerConnected } from "#app/utils/common"; import { PlayerGender } from "#enums/player-gender"; import { TrainerType } from "#enums/trainer-type"; import i18next from "i18next"; @@ -78,7 +78,7 @@ export class GameOverPhase extends BattlePhase { } else { globalScene.ui.showText(i18next.t("battle:retryBattle"), null, () => { globalScene.ui.setMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { globalScene.ui.fadeOut(1250).then(() => { globalScene.reset(); diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index 4107a9cf087..515ce492b92 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -8,7 +8,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import Overrides from "#app/overrides"; import EvolutionSceneHandler from "#app/ui/evolution-scene-handler"; import { SummaryUiMode } from "#app/ui/summary-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-pokemon-phase"; import type Pokemon from "#app/field/pokemon"; @@ -25,7 +25,7 @@ export enum LearnMoveType { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { private moveId: Moves; - private messageMode: Mode; + private messageMode: UiMode; private learnMoveType: LearnMoveType; private cost: number; @@ -55,7 +55,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { } this.messageMode = - globalScene.ui.getHandler() instanceof EvolutionSceneHandler ? Mode.EVOLUTION_SCENE : Mode.MESSAGE; + globalScene.ui.getHandler() instanceof EvolutionSceneHandler ? UiMode.EVOLUTION_SCENE : UiMode.MESSAGE; globalScene.ui.setMode(this.messageMode); // If the Pokemon has less than 4 moves, the new move is added to the largest empty moveset index // If it has 4 moves, the phase then checks if the player wants to replace the move itself. @@ -90,7 +90,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { await globalScene.ui.showTextPromise(preQText); await globalScene.ui.showTextPromise(shouldReplaceQ, undefined, false); await globalScene.ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => this.forgetMoveProcess(move, pokemon), // Yes () => { // No @@ -115,7 +115,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { globalScene.ui.setMode(this.messageMode); await globalScene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true); await globalScene.ui.setModeWithoutClear( - Mode.SUMMARY, + UiMode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, @@ -153,7 +153,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { false, ); globalScene.ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { globalScene.ui.setMode(this.messageMode); globalScene.ui @@ -228,7 +228,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeMoveLearnedTrigger, true); this.end(); }, - this.messageMode === Mode.EVOLUTION_SCENE ? 1000 : undefined, + this.messageMode === UiMode.EVOLUTION_SCENE ? 1000 : undefined, true, ); } diff --git a/src/phases/level-cap-phase.ts b/src/phases/level-cap-phase.ts index 567ac922124..6f3fa6fdb39 100644 --- a/src/phases/level-cap-phase.ts +++ b/src/phases/level-cap-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { FieldPhase } from "./field-phase"; @@ -7,7 +7,7 @@ export class LevelCapPhase extends FieldPhase { start(): void { super.start(); - globalScene.ui.setMode(Mode.MESSAGE).then(() => { + globalScene.ui.setMode(UiMode.MESSAGE).then(() => { // Sound loaded into game as is globalScene.playSound("level_up_fanfare"); globalScene.ui.showText( diff --git a/src/phases/level-up-phase.ts b/src/phases/level-up-phase.ts index c6ca17d583e..8c4f4f58095 100644 --- a/src/phases/level-up-phase.ts +++ b/src/phases/level-up-phase.ts @@ -6,7 +6,7 @@ import { EvolutionPhase } from "#app/phases/evolution-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-pokemon-phase"; import { LevelAchv } from "#app/system/achv"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import i18next from "i18next"; export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { @@ -71,7 +71,7 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { if (!this.pokemon.pauseEvolutions) { const evolution = this.pokemon.getEvolution(); if (evolution) { - this.pokemon.breakIllusion() + this.pokemon.breakIllusion(); globalScene.unshiftPhase(new EvolutionPhase(this.pokemon, evolution, this.lastLevel)); } } diff --git a/src/phases/login-phase.ts b/src/phases/login-phase.ts index 846482ff726..673b94b1148 100644 --- a/src/phases/login-phase.ts +++ b/src/phases/login-phase.ts @@ -1,11 +1,12 @@ import { updateUserInfo } from "#app/account"; -import { bypassLogin } from "#app/battle-scene"; +import { bypassLogin } from "#app/global-vars/bypass-login"; import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; import { handleTutorial, Tutorial } from "#app/tutorial"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next, { t } from "i18next"; -import { getCookie, sessionIdKey, executeIf, removeCookie } from "#app/utils"; +import { sessionIdKey, executeIf } from "#app/utils/common"; +import { getCookie, removeCookie } from "#app/utils/cookies"; import { SelectGenderPhase } from "./select-gender-phase"; import { UnavailablePhase } from "./unavailable-phase"; @@ -23,7 +24,7 @@ export class LoginPhase extends Phase { const hasSession = !!getCookie(sessionIdKey); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); executeIf(bypassLogin || hasSession, updateUserInfo).then(response => { const success = response ? response[0] : false; const statusCode = response ? response[1] : null; @@ -46,7 +47,7 @@ export class LoginPhase extends Phase { }); }; - globalScene.ui.setMode(Mode.LOGIN_FORM, { + globalScene.ui.setMode(UiMode.LOGIN_FORM, { buttonActions: [ () => { globalScene.ui.playSelect(); @@ -54,7 +55,7 @@ export class LoginPhase extends Phase { }, () => { globalScene.playSound("menu_open"); - globalScene.ui.setMode(Mode.REGISTRATION_FORM, { + globalScene.ui.setMode(UiMode.REGISTRATION_FORM, { buttonActions: [ () => { globalScene.ui.playSelect(); @@ -101,7 +102,7 @@ export class LoginPhase extends Phase { if (success || bypassLogin) { this.end(); } else { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText(t("menu:failedToLoadSaveData")); } }); @@ -109,7 +110,7 @@ export class LoginPhase extends Phase { } end(): void { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); if (!globalScene.gameData.gender) { globalScene.unshiftPhase(new SelectGenderPhase()); diff --git a/src/phases/money-reward-phase.ts b/src/phases/money-reward-phase.ts index ae8dc90616d..708bb3a2fa8 100644 --- a/src/phases/money-reward-phase.ts +++ b/src/phases/money-reward-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import { MoneyMultiplierModifier } from "#app/modifier/modifier"; import i18next from "i18next"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { BattlePhase } from "./battle-phase"; export class MoneyRewardPhase extends BattlePhase { diff --git a/src/phases/move-charge-phase.ts b/src/phases/move-charge-phase.ts index 26ad85bbe03..ea43f1ddb88 100644 --- a/src/phases/move-charge-phase.ts +++ b/src/phases/move-charge-phase.ts @@ -5,7 +5,7 @@ import { applyMoveChargeAttrs, MoveEffectAttr, InstantChargeAttr } from "#app/da import type { PokemonMove } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { MoveResult } from "#app/field/pokemon"; -import { BooleanHolder } from "#app/utils"; +import { BooleanHolder } from "#app/utils/common"; import { MovePhase } from "#app/phases/move-phase"; import { PokemonPhase } from "#app/phases/pokemon-phase"; import { BattlerTagType } from "#enums/battler-tag-type"; diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 3a4e5f32ede..c29e3fe5cda 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -61,8 +61,8 @@ import { PokemonMultiHitModifier, } from "#app/modifier/modifier"; import { PokemonPhase } from "#app/phases/pokemon-phase"; -import { BooleanHolder, isNullOrUndefined, NumberHolder } from "#app/utils"; -import type { nil } from "#app/utils"; +import { BooleanHolder, isNullOrUndefined, NumberHolder } from "#app/utils/common"; +import type { nil } from "#app/utils/common"; import { BattlerTagType } from "#enums/battler-tag-type"; import type { Moves } from "#enums/moves"; import i18next from "i18next"; diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index dc394b8a134..f42a2aefa34 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -43,7 +43,7 @@ import { CommonAnimPhase } from "#app/phases/common-anim-phase"; import { MoveChargePhase } from "#app/phases/move-charge-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; diff --git a/src/phases/mystery-encounter-phases.ts b/src/phases/mystery-encounter-phases.ts index f42290ff872..100be47e4e9 100644 --- a/src/phases/mystery-encounter-phases.ts +++ b/src/phases/mystery-encounter-phases.ts @@ -25,8 +25,8 @@ import { transitionMysteryEncounterIntroVisuals } from "../data/mystery-encounte import { TrainerSlot } from "#enums/trainer-slot"; import { IvScannerModifier } from "../modifier/modifier"; import { Phase } from "../phase"; -import { Mode } from "../ui/ui"; -import { isNullOrUndefined, randSeedItem } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isNullOrUndefined, randSeedItem } from "#app/utils/common"; /** * Will handle (in order): @@ -72,7 +72,7 @@ export class MysteryEncounterPhase extends Phase { } // Initiates encounter dialogue window and option select - globalScene.ui.setMode(Mode.MYSTERY_ENCOUNTER, this.optionSelectSettings); + globalScene.ui.setMode(UiMode.MYSTERY_ENCOUNTER, this.optionSelectSettings); } /** @@ -130,7 +130,7 @@ export class MysteryEncounterPhase extends Phase { const optionSelectDialogue = globalScene.currentBattle?.mysteryEncounter?.selectedOption?.dialogue; if (optionSelectDialogue?.selected && optionSelectDialogue.selected.length > 0) { // Handle intermediate dialogue (between player selection event and the onOptionSelect logic) - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); const selectedDialogue = optionSelectDialogue.selected; let i = 0; const showNextDialogue = () => { @@ -167,7 +167,7 @@ export class MysteryEncounterPhase extends Phase { * Ends phase */ end() { - globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => super.end()); } } @@ -629,7 +629,7 @@ export class PostMysteryEncounterPhase extends Phase { } i++; - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); if (title) { globalScene.ui.showDialogue( text ?? "", diff --git a/src/phases/obtain-status-effect-phase.ts b/src/phases/obtain-status-effect-phase.ts index 10ae195b02f..47cae2dcbf6 100644 --- a/src/phases/obtain-status-effect-phase.ts +++ b/src/phases/obtain-status-effect-phase.ts @@ -8,7 +8,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { PokemonPhase } from "./pokemon-phase"; import { SpeciesFormChangeStatusEffectTrigger } from "#app/data/pokemon-forms"; import { applyPostSetStatusAbAttrs, PostSetStatusAbAttr } from "#app/data/abilities/ability"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; export class ObtainStatusEffectPhase extends PokemonPhase { private statusEffect?: StatusEffect; diff --git a/src/phases/party-heal-phase.ts b/src/phases/party-heal-phase.ts index 137af9f3a2d..a208ccfff92 100644 --- a/src/phases/party-heal-phase.ts +++ b/src/phases/party-heal-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { BattlePhase } from "./battle-phase"; export class PartyHealPhase extends BattlePhase { diff --git a/src/phases/pokemon-anim-phase.ts b/src/phases/pokemon-anim-phase.ts index f0693a52aaa..1889b238f05 100644 --- a/src/phases/pokemon-anim-phase.ts +++ b/src/phases/pokemon-anim-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { SubstituteTag } from "#app/data/battler-tags"; import type Pokemon from "#app/field/pokemon"; import { BattlePhase } from "#app/phases/battle-phase"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { PokemonAnimType } from "#enums/pokemon-anim-type"; import { Species } from "#enums/species"; diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index 651c625b23a..7cb013251f6 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -8,7 +8,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { HealingBoosterModifier } from "#app/modifier/modifier"; import { HealAchv } from "#app/system/achv"; import i18next from "i18next"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { CommonAnimPhase } from "./common-anim-phase"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import type { HealBlockTag } from "#app/data/battler-tags"; diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index af9a9ac1c29..9b530d48196 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -13,7 +13,7 @@ import { getStatusEffectActivationText } from "#app/data/status-effect"; import { BattleSpec } from "#app/enums/battle-spec"; import { StatusEffect } from "#app/enums/status-effect"; import { getPokemonNameWithAffix } from "#app/messages"; -import { BooleanHolder, NumberHolder } from "#app/utils"; +import { BooleanHolder, NumberHolder } from "#app/utils/common"; import { PokemonPhase } from "./pokemon-phase"; export class PostTurnStatusEffectPhase extends PokemonPhase { diff --git a/src/phases/reload-session-phase.ts b/src/phases/reload-session-phase.ts index a7ac0002b03..8cd5f67b43a 100644 --- a/src/phases/reload-session-phase.ts +++ b/src/phases/reload-session-phase.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import { Mode } from "#app/ui/ui"; -import { fixedInt } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { fixedInt } from "#app/utils/common"; export class ReloadSessionPhase extends Phase { private systemDataStr?: string; @@ -13,7 +13,7 @@ export class ReloadSessionPhase extends Phase { } start(): void { - globalScene.ui.setMode(Mode.SESSION_RELOAD); + globalScene.ui.setMode(UiMode.SESSION_RELOAD); let delayElapsed = false; let loaded = false; diff --git a/src/phases/revival-blessing-phase.ts b/src/phases/revival-blessing-phase.ts index f6fe4d9a3ee..2de1c616f69 100644 --- a/src/phases/revival-blessing-phase.ts +++ b/src/phases/revival-blessing-phase.ts @@ -2,9 +2,9 @@ import { SwitchType } from "#enums/switch-type"; import { globalScene } from "#app/global-scene"; import type { PartyOption } from "#app/ui/party-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; -import { toDmgValue, isNullOrUndefined } from "#app/utils"; +import { toDmgValue, isNullOrUndefined } from "#app/utils/common"; import { BattlePhase } from "#app/phases/battle-phase"; import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase"; @@ -21,7 +21,7 @@ export class RevivalBlessingPhase extends BattlePhase { public override start(): void { globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.user.getFieldIndex(), (slotIndex: integer, _option: PartyOption) => { @@ -63,7 +63,7 @@ export class RevivalBlessingPhase extends BattlePhase { } } } - globalScene.ui.setMode(Mode.MESSAGE).then(() => this.end()); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => this.end()); }, PartyUiHandler.FilterFainted, ); diff --git a/src/phases/ribbon-modifier-reward-phase.ts b/src/phases/ribbon-modifier-reward-phase.ts index 0ee38250ce1..21114ab3de9 100644 --- a/src/phases/ribbon-modifier-reward-phase.ts +++ b/src/phases/ribbon-modifier-reward-phase.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import type PokemonSpecies from "#app/data/pokemon-species"; import type { ModifierTypeFunc } from "#app/modifier/modifier-type"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { ModifierRewardPhase } from "./modifier-reward-phase"; @@ -19,7 +19,7 @@ export class RibbonModifierRewardPhase extends ModifierRewardPhase { const newModifier = this.modifierType.newModifier(); globalScene.addModifier(newModifier); globalScene.playSound("level_up_fanfare"); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:beatModeFirstTime", { speciesName: this.species.name, diff --git a/src/phases/scan-ivs-phase.ts b/src/phases/scan-ivs-phase.ts index aaeeb7f84f8..d79a32bd47e 100644 --- a/src/phases/scan-ivs-phase.ts +++ b/src/phases/scan-ivs-phase.ts @@ -3,7 +3,7 @@ import type { BattlerIndex } from "#app/battle"; import { PERMANENT_STATS, Stat } from "#app/enums/stat"; import { getPokemonNameWithAffix } from "#app/messages"; import { getTextColor, TextStyle } from "#app/ui/text"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { PokemonPhase } from "./pokemon-phase"; @@ -51,9 +51,9 @@ export class ScanIvsPhase extends PokemonPhase { null, () => { globalScene.ui.setMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.clearText(); globalScene.ui .getMessageHandler() @@ -61,7 +61,7 @@ export class ScanIvsPhase extends PokemonPhase { .then(() => this.end()); }, () => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.clearText(); this.end(); }, diff --git a/src/phases/select-biome-phase.ts b/src/phases/select-biome-phase.ts index b27e2d0e7cc..0ea2841a2d3 100644 --- a/src/phases/select-biome-phase.ts +++ b/src/phases/select-biome-phase.ts @@ -3,9 +3,9 @@ import { biomeLinks, getBiomeName } from "#app/data/balance/biomes"; import { Biome } from "#app/enums/biome"; import { MoneyInterestModifier, MapModifier } from "#app/modifier/modifier"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { BattlePhase } from "./battle-phase"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import { PartyHealPhase } from "./party-heal-phase"; import { SwitchBiomePhase } from "./switch-biome-phase"; @@ -42,14 +42,14 @@ export class SelectBiomePhase extends BattlePhase { const ret: OptionSelectItem = { label: getBiomeName(b), handler: () => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); setNextBiome(b); return true; }, }; return ret; }); - globalScene.ui.setMode(Mode.OPTION_SELECT, { + globalScene.ui.setMode(UiMode.OPTION_SELECT, { options: biomeSelectItems, delay: 1000, }); diff --git a/src/phases/select-challenge-phase.ts b/src/phases/select-challenge-phase.ts index 5e6f20f93ee..76ac8a60c4f 100644 --- a/src/phases/select-challenge-phase.ts +++ b/src/phases/select-challenge-phase.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; export class SelectChallengePhase extends Phase { start() { @@ -8,6 +8,6 @@ export class SelectChallengePhase extends Phase { globalScene.playBgm("menu"); - globalScene.ui.setMode(Mode.CHALLENGE_SELECT); + globalScene.ui.setMode(UiMode.CHALLENGE_SELECT); } } diff --git a/src/phases/select-gender-phase.ts b/src/phases/select-gender-phase.ts index 4da60b38aa1..a1171c1a5db 100644 --- a/src/phases/select-gender-phase.ts +++ b/src/phases/select-gender-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { PlayerGender } from "#app/enums/player-gender"; import { Phase } from "#app/phase"; import { SettingKeys } from "#app/system/settings/settings"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; export class SelectGenderPhase extends Phase { @@ -10,7 +10,7 @@ export class SelectGenderPhase extends Phase { super.start(); globalScene.ui.showText(i18next.t("menu:boyOrGirl"), null, () => { - globalScene.ui.setMode(Mode.OPTION_SELECT, { + globalScene.ui.setMode(UiMode.OPTION_SELECT, { options: [ { label: i18next.t("settings:boy"), @@ -36,7 +36,7 @@ export class SelectGenderPhase extends Phase { } end(): void { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); super.end(); } } diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 27ab7e374a2..5f11441333b 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -24,12 +24,12 @@ import { import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { SHOP_OPTIONS_ROW_LIMIT } from "#app/ui/modifier-select-ui-handler"; import PartyUiHandler, { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { BattlePhase } from "./battle-phase"; import Overrides from "#app/overrides"; import type { CustomModifierSettings } from "#app/modifier/modifier-type"; -import { isNullOrUndefined, NumberHolder } from "#app/utils"; +import { isNullOrUndefined, NumberHolder } from "#app/utils/common"; export class SelectModifierPhase extends BattlePhase { private rerollCount: number; @@ -92,15 +92,15 @@ export class SelectModifierPhase extends BattlePhase { if (rowCursor < 0 || cursor < 0) { globalScene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => { globalScene.ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { globalScene.ui.revertMode(); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); super.end(); }, () => globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, @@ -129,7 +129,7 @@ export class SelectModifierPhase extends BattlePhase { ), ); globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => super.end()); if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) { globalScene.money -= rerollCost; globalScene.updateMoneyText(); @@ -139,7 +139,7 @@ export class SelectModifierPhase extends BattlePhase { break; case 1: globalScene.ui.setModeWithoutClear( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: number, itemIndex: number, itemQuantity: number, toSlotIndex: number) => { @@ -168,7 +168,7 @@ export class SelectModifierPhase extends BattlePhase { ); } else { globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, @@ -180,9 +180,9 @@ export class SelectModifierPhase extends BattlePhase { ); break; case 2: - globalScene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.CHECK, -1, () => { + globalScene.ui.setModeWithoutClear(UiMode.PARTY, PartyUiMode.CHECK, -1, () => { globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, @@ -207,7 +207,7 @@ export class SelectModifierPhase extends BattlePhase { case 1: if (this.typeOptions.length === 0) { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); super.end(); return true; } @@ -263,7 +263,7 @@ export class SelectModifierPhase extends BattlePhase { } } else { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); super.end(); } }; @@ -272,7 +272,7 @@ export class SelectModifierPhase extends BattlePhase { //TODO: is the bang correct? if (modifierType instanceof FusePokemonModifierType) { globalScene.ui.setModeWithoutClear( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: number, spliceSlotIndex: number) => { @@ -282,13 +282,13 @@ export class SelectModifierPhase extends BattlePhase { spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex ) { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { + globalScene.ui.setMode(UiMode.MODIFIER_SELECT, this.isPlayer()).then(() => { const modifier = modifierType.newModifier(party[fromSlotIndex], party[spliceSlotIndex])!; //TODO: is the bang correct? applyModifier(modifier, true); }); } else { globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, @@ -314,12 +314,12 @@ export class SelectModifierPhase extends BattlePhase { : PartyUiMode.MODIFIER; const tmMoveId = isTmModifier ? (modifierType as TmModifierType).moveId : undefined; globalScene.ui.setModeWithoutClear( - Mode.PARTY, + UiMode.PARTY, partyUiMode, -1, (slotIndex: number, option: PartyOption) => { if (slotIndex < 6) { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { + globalScene.ui.setMode(UiMode.MODIFIER_SELECT, this.isPlayer()).then(() => { const modifier = !isMoveModifier ? !isRememberMoveModifier ? modifierType.newModifier(party[slotIndex]) @@ -329,7 +329,7 @@ export class SelectModifierPhase extends BattlePhase { }); } else { globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, @@ -352,7 +352,7 @@ export class SelectModifierPhase extends BattlePhase { return !cost!; // TODO: is the bang correct? }; globalScene.ui.setMode( - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, diff --git a/src/phases/select-starter-phase.ts b/src/phases/select-starter-phase.ts index 35511531609..0a76df31a2c 100644 --- a/src/phases/select-starter-phase.ts +++ b/src/phases/select-starter-phase.ts @@ -9,10 +9,10 @@ import { Phase } from "#app/phase"; import { TitlePhase } from "#app/phases/title-phase"; import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler"; import type { Starter } from "#app/ui/starter-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { Species } from "#enums/species"; import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; export class SelectStarterPhase extends Phase { start() { @@ -20,9 +20,9 @@ export class SelectStarterPhase extends Phase { globalScene.playBgm("menu"); - globalScene.ui.setMode(Mode.STARTER_SELECT, (starters: Starter[]) => { + globalScene.ui.setMode(UiMode.STARTER_SELECT, (starters: Starter[]) => { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { + globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { if (slotId === -1) { globalScene.clearPhaseQueue(); globalScene.pushPhase(new TitlePhase()); diff --git a/src/phases/select-target-phase.ts b/src/phases/select-target-phase.ts index 035eaff41fa..c969b9ca421 100644 --- a/src/phases/select-target-phase.ts +++ b/src/phases/select-target-phase.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { CommandPhase } from "./command-phase"; import { PokemonPhase } from "./pokemon-phase"; import i18next from "#app/plugins/i18n"; @@ -18,8 +18,8 @@ export class SelectTargetPhase extends PokemonPhase { const turnCommand = globalScene.currentBattle.turnCommands[this.fieldIndex]; const move = turnCommand?.move?.move; - globalScene.ui.setMode(Mode.TARGET_SELECT, this.fieldIndex, move, (targets: BattlerIndex[]) => { - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.TARGET_SELECT, this.fieldIndex, move, (targets: BattlerIndex[]) => { + globalScene.ui.setMode(UiMode.MESSAGE); const fieldSide = globalScene.getField(); const user = fieldSide[this.fieldIndex]; const moveObject = allMoves[move!]; diff --git a/src/phases/show-party-exp-bar-phase.ts b/src/phases/show-party-exp-bar-phase.ts index 139f4efcc49..89bec6d8fdd 100644 --- a/src/phases/show-party-exp-bar-phase.ts +++ b/src/phases/show-party-exp-bar-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { ExpGainsSpeed } from "#app/enums/exp-gains-speed"; import { ExpNotification } from "#app/enums/exp-notification"; import { ExpBoosterModifier } from "#app/modifier/modifier"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { HidePartyExpBarPhase } from "./hide-party-exp-bar-phase"; import { LevelUpPhase } from "./level-up-phase"; import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase"; diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index f52e4fb06a0..9d64a81bbb4 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -17,7 +17,7 @@ import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { ResetNegativeStatStageModifier } from "#app/modifier/modifier"; import { handleTutorial, Tutorial } from "#app/tutorial"; -import { NumberHolder, BooleanHolder, isNullOrUndefined } from "#app/utils"; +import { NumberHolder, BooleanHolder, isNullOrUndefined } from "#app/utils/common"; import i18next from "i18next"; import { PokemonPhase } from "./pokemon-phase"; import { Stat, type BattleStat, getStatKey, getStatStageChangeDescriptionKey } from "#enums/stat"; diff --git a/src/phases/switch-phase.ts b/src/phases/switch-phase.ts index 8562309ede5..c056b186021 100644 --- a/src/phases/switch-phase.ts +++ b/src/phases/switch-phase.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import PartyUiHandler, { PartyOption, PartyUiMode } from "#app/ui/party-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { SwitchType } from "#enums/switch-type"; import { BattlePhase } from "./battle-phase"; import { PostSummonPhase } from "./post-summon-phase"; @@ -69,7 +69,7 @@ export class SwitchPhase extends BattlePhase { : 0; globalScene.ui.setMode( - Mode.PARTY, + UiMode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: number, option: PartyOption) => { @@ -80,7 +80,7 @@ export class SwitchPhase extends BattlePhase { const switchType = option === PartyOption.PASS_BATON ? SwitchType.BATON_PASS : this.switchType; globalScene.unshiftPhase(new SwitchSummonPhase(switchType, fieldIndex, slotIndex, this.doReturn)); } - globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); + globalScene.ui.setMode(UiMode.MESSAGE).then(() => super.end()); }, PartyUiHandler.FilterNonFainted, ); diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index bc1b157e98e..56057c23372 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -17,8 +17,8 @@ import { Unlockables } from "#app/system/unlockables"; import { vouchers } from "#app/system/voucher"; import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { isLocal, isLocalServerConnected, isNullOrUndefined } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isLocal, isLocalServerConnected, isNullOrUndefined } from "#app/utils/common"; import i18next from "i18next"; import { CheckSwitchPhase } from "./check-switch-phase"; import { EncounterPhase } from "./encounter-phase"; @@ -75,7 +75,7 @@ export class TitlePhase extends Phase { handler: () => { const setModeAndEnd = (gameMode: GameModes) => { this.gameMode = gameMode; - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.clearText(); this.end(); }; @@ -130,7 +130,7 @@ export class TitlePhase extends Phase { }, }); globalScene.ui.showText(i18next.t("menu:selectGameMode"), null, () => - globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + globalScene.ui.setOverlayMode(UiMode.OPTION_SELECT, { options: options, }), ); @@ -140,7 +140,7 @@ export class TitlePhase extends Phase { { label: i18next.t("menu:loadGame"), handler: () => { - globalScene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD, (slotId: number) => { + globalScene.ui.setOverlayMode(UiMode.SAVE_SLOT, SaveSlotUiMode.LOAD, (slotId: number) => { if (slotId === -1) { return this.showOptions(); } @@ -152,7 +152,7 @@ export class TitlePhase extends Phase { { label: i18next.t("menu:runHistory"), handler: () => { - globalScene.ui.setOverlayMode(Mode.RUN_HISTORY); + globalScene.ui.setOverlayMode(UiMode.RUN_HISTORY); return true; }, keepOpen: true, @@ -160,7 +160,7 @@ export class TitlePhase extends Phase { { label: i18next.t("menu:settings"), handler: () => { - globalScene.ui.setOverlayMode(Mode.SETTINGS); + globalScene.ui.setOverlayMode(UiMode.SETTINGS); return true; }, keepOpen: true, @@ -171,12 +171,12 @@ export class TitlePhase extends Phase { noCancel: true, yOffset: 47, }; - globalScene.ui.setMode(Mode.TITLE, config); + globalScene.ui.setMode(UiMode.TITLE, config); } loadSaveSlot(slotId: number): void { globalScene.sessionSlotId = slotId > -1 || !loggedInUser ? slotId : loggedInUser.lastSessionSlot; - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.resetModeChain(); globalScene.gameData .loadSession(slotId, slotId === -1 ? this.lastSessionData : undefined) @@ -196,7 +196,7 @@ export class TitlePhase extends Phase { initDailyRun(): void { globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { + globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { globalScene.clearPhaseQueue(); if (slotId === -1) { globalScene.pushPhase(new TitlePhase()); diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index f17071f118e..f7005b1300d 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -3,7 +3,7 @@ import { TrainerType } from "#app/enums/trainer-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import { vouchers } from "#app/system/voucher"; import i18next from "i18next"; -import { randSeedItem } from "#app/utils"; +import { randSeedItem } from "#app/utils/common"; import { BattlePhase } from "./battle-phase"; import { ModifierRewardPhase } from "./modifier-reward-phase"; import { MoneyRewardPhase } from "./money-reward-phase"; diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index ba6ace2d188..622b9cdcbd1 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -6,7 +6,7 @@ import type Pokemon from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; import { BypassSpeedChanceModifier } from "#app/modifier/modifier"; import { Command } from "#app/ui/command-ui-handler"; -import { randSeedShuffle, BooleanHolder } from "#app/utils"; +import { randSeedShuffle, BooleanHolder } from "#app/utils/common"; import { AttemptCapturePhase } from "./attempt-capture-phase"; import { AttemptRunPhase } from "./attempt-run-phase"; import { BerryPhase } from "./berry-phase"; diff --git a/src/phases/unavailable-phase.ts b/src/phases/unavailable-phase.ts index 33042739971..e5f1d899191 100644 --- a/src/phases/unavailable-phase.ts +++ b/src/phases/unavailable-phase.ts @@ -1,11 +1,11 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { LoginPhase } from "./login-phase"; export class UnavailablePhase extends Phase { start(): void { - globalScene.ui.setMode(Mode.UNAVAILABLE, () => { + globalScene.ui.setMode(UiMode.UNAVAILABLE, () => { globalScene.unshiftPhase(new LoginPhase(true)); this.end(); }); diff --git a/src/phases/unlock-phase.ts b/src/phases/unlock-phase.ts index b420a4b3a61..7a69fc207bb 100644 --- a/src/phases/unlock-phase.ts +++ b/src/phases/unlock-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; import type { Unlockables } from "#app/system/unlockables"; import { getUnlockableName } from "#app/system/unlockables"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; export class UnlockPhase extends Phase { @@ -19,7 +19,7 @@ export class UnlockPhase extends Phase { globalScene.gameData.unlocks[this.unlockable] = true; // Sound loaded into game as is globalScene.playSound("level_up_fanfare"); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.MESSAGE); globalScene.ui.showText( i18next.t("battle:unlockedSomething", { unlockedThing: getUnlockableName(this.unlockable), diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index b83eab43b65..d89c78e96c7 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -15,7 +15,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; import { WeatherType } from "#app/enums/weather-type"; import type Pokemon from "#app/field/pokemon"; import { HitResult } from "#app/field/pokemon"; -import { BooleanHolder, toDmgValue } from "#app/utils"; +import { BooleanHolder, toDmgValue } from "#app/utils/common"; import { CommonAnimPhase } from "./common-anim-phase"; export class WeatherEffectPhase extends CommonAnimPhase { diff --git a/src/pipelines/field-sprite.ts b/src/pipelines/field-sprite.ts index a55b6a9adb6..a6e248c9998 100644 --- a/src/pipelines/field-sprite.ts +++ b/src/pipelines/field-sprite.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { TerrainType, getTerrainColor } from "../data/terrain"; -import { getCurrentTime } from "#app/utils"; +import { getCurrentTime } from "#app/utils/common"; import fieldSpriteFragShader from "./glsl/fieldSpriteFragShader.frag?raw"; import spriteVertShader from "./glsl/spriteShader.vert?raw"; diff --git a/src/pipelines/sprite.ts b/src/pipelines/sprite.ts index 0aa9409617a..307c2cee4cc 100644 --- a/src/pipelines/sprite.ts +++ b/src/pipelines/sprite.ts @@ -3,7 +3,7 @@ import MysteryEncounterIntroVisuals from "#app/field/mystery-encounter-intro"; import Pokemon from "#app/field/pokemon"; import Trainer from "#app/field/trainer"; import { globalScene } from "#app/global-scene"; -import { rgbHexToRgba } from "#app/utils"; +import { rgbHexToRgba } from "#app/utils/common"; import FieldSpritePipeline from "./field-sprite"; import spriteFragShader from "./glsl/spriteFragShader.frag?raw"; import spriteVertShader from "./glsl/spriteShader.vert?raw"; diff --git a/src/plugins/api/api-base.ts b/src/plugins/api/api-base.ts index 6a0eca56eaa..f55ffe2d3fd 100644 --- a/src/plugins/api/api-base.ts +++ b/src/plugins/api/api-base.ts @@ -1,5 +1,5 @@ import { SESSION_ID_COOKIE_NAME } from "#app/constants"; -import { getCookie } from "#app/utils"; +import { getCookie } from "#app/utils/cookies"; type DataType = "json" | "form-urlencoded"; diff --git a/src/plugins/api/pokerogue-account-api.ts b/src/plugins/api/pokerogue-account-api.ts index bab74799677..9cd82c24430 100644 --- a/src/plugins/api/pokerogue-account-api.ts +++ b/src/plugins/api/pokerogue-account-api.ts @@ -6,7 +6,7 @@ import type { } from "#app/@types/PokerogueAccountApi"; import { SESSION_ID_COOKIE_NAME } from "#app/constants"; import { ApiBase } from "#app/plugins/api/api-base"; -import { removeCookie, setCookie } from "#app/utils"; +import { removeCookie, setCookie } from "#app/utils/cookies"; /** * A wrapper for PokéRogue account API requests. diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 5e145d08e28..ff9e54fcf50 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -1,4 +1,4 @@ -import { camelCaseToKebabCase } from "#app/utils"; +import { camelCaseToKebabCase } from "#app/utils/common"; import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import HttpBackend from "i18next-http-backend"; diff --git a/src/sprites/variant.ts b/src/sprites/variant.ts index 7552f63b778..985068015c6 100644 --- a/src/sprites/variant.ts +++ b/src/sprites/variant.ts @@ -2,7 +2,7 @@ import { VariantTier } from "#app/enums/variant-tier"; import { hasExpSprite } from "#app/sprites/sprite-utils"; import { globalScene } from "#app/global-scene"; import type Pokemon from "#app/field/pokemon"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; export type Variant = 0 | 1 | 2; diff --git a/src/starter-colors.ts b/src/starter-colors.ts new file mode 100644 index 00000000000..6abe028be99 --- /dev/null +++ b/src/starter-colors.ts @@ -0,0 +1,4 @@ +export const starterColors: StarterColors = {}; +interface StarterColors { + [key: string]: [string, string]; +} diff --git a/src/starting-wave.ts b/src/starting-wave.ts new file mode 100644 index 00000000000..3d36dabe652 --- /dev/null +++ b/src/starting-wave.ts @@ -0,0 +1,3 @@ +import Overrides from "./overrides"; + +export const startingWave = Overrides.STARTING_WAVE_OVERRIDE || 1; diff --git a/src/system/achv.ts b/src/system/achv.ts index 62e69e6fbfe..90816ff65c3 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -2,7 +2,7 @@ import type { Modifier } from "typescript"; import { TurnHeldItemTransferModifier } from "../modifier/modifier"; import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import i18next from "i18next"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { PlayerGender } from "#enums/player-gender"; import type { Challenge } from "#app/data/challenge"; import { diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 698299845a3..8b7987556ee 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -1,6 +1,6 @@ import i18next from "i18next"; import type { PokeballCounts } from "#app/battle-scene"; -import { bypassLogin } from "#app/battle-scene"; +import { bypassLogin } from "#app/global-vars/bypass-login"; import { globalScene } from "#app/global-scene"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; @@ -8,7 +8,7 @@ import { pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import type PokemonSpecies from "#app/data/pokemon-species"; import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; -import { randInt, getEnumKeys, isLocal, executeIf, fixedInt, randSeedItem, NumberHolder } from "#app/utils"; +import { randInt, getEnumKeys, isLocal, executeIf, fixedInt, randSeedItem, NumberHolder } from "#app/utils/common"; import Overrides from "#app/overrides"; import PokemonData from "#app/system/pokemon-data"; import PersistentModifierData from "#app/system/modifier-data"; @@ -24,7 +24,7 @@ import EggData from "#app/system/egg-data"; import type { Egg } from "#app/data/egg"; import { vouchers, VoucherType } from "#app/system/voucher"; import { AES, enc } from "crypto-js"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { clientSessionId, loggedInUser, updateUserInfo } from "#app/account"; import { Nature } from "#enums/nature"; import { GameStats } from "#app/system/game-stats"; @@ -1430,7 +1430,7 @@ export class GameData { const systemData = useCachedSystem ? this.parseSystemData(decrypt(localStorage.getItem(`data_${loggedInUser?.username}`)!, bypassLogin)) : this.getSystemSaveData(); // TODO: is this bang correct? - + const request = { system: systemData, session: sessionData, @@ -1604,7 +1604,7 @@ export class GameData { null, () => { globalScene.ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { localStorage.setItem(dataKey, encrypt(dataStr, bypassLogin)); diff --git a/src/system/game-speed.ts b/src/system/game-speed.ts index 3df47fafc6c..712870dfaf1 100644 --- a/src/system/game-speed.ts +++ b/src/system/game-speed.ts @@ -3,7 +3,7 @@ import type FadeIn from "phaser3-rex-plugins/plugins/audio/fade/FadeIn"; import type FadeOut from "phaser3-rex-plugins/plugins/audio/fade/FadeOut"; import type BattleScene from "#app/battle-scene"; import { globalScene } from "#app/global-scene"; -import { FixedInt } from "#app/utils"; +import { FixedInt } from "#app/utils/common"; type FadeInType = typeof FadeIn; type FadeOutType = typeof FadeOut; diff --git a/src/system/settings/settings-gamepad.ts b/src/system/settings/settings-gamepad.ts index f4a6bd465af..12add905096 100644 --- a/src/system/settings/settings-gamepad.ts +++ b/src/system/settings/settings-gamepad.ts @@ -1,6 +1,6 @@ import type SettingsGamepadUiHandler from "../../ui/settings/settings-gamepad-ui-handler"; -import { Mode } from "../../ui/ui"; -import { truncateString } from "../../utils"; +import { UiMode } from "#enums/ui-mode"; +import { truncateString } from "../../utils/common"; import { Button } from "#enums/buttons"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import { globalScene } from "#app/global-scene"; @@ -107,7 +107,7 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole (globalScene.ui.getHandler() as SettingsGamepadUiHandler).updateBindings(); return success; }; - globalScene.ui.setOverlayMode(Mode.GAMEPAD_BINDING, { + globalScene.ui.setOverlayMode(UiMode.GAMEPAD_BINDING, { target: setting, cancelHandler: cancelHandler, }); @@ -133,7 +133,7 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole cancelHandler(); return true; }; - globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + globalScene.ui.setOverlayMode(UiMode.OPTION_SELECT, { options: [ ...gp.map((g: string) => ({ label: truncateString(g, 30), // Truncate the gamepad name for display diff --git a/src/system/settings/settings-keyboard.ts b/src/system/settings/settings-keyboard.ts index ffe8811e5d9..ec5c9ad6b0e 100644 --- a/src/system/settings/settings-keyboard.ts +++ b/src/system/settings/settings-keyboard.ts @@ -1,5 +1,5 @@ import { Button } from "#enums/buttons"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type SettingsKeyboardUiHandler from "#app/ui/settings/settings-keyboard-ui-handler"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; @@ -174,7 +174,7 @@ export function setSettingKeyboard(setting: SettingKeyboard, value: number): boo (globalScene.ui.getHandler() as SettingsKeyboardUiHandler).updateBindings(); return success; }; - globalScene.ui.setOverlayMode(Mode.KEYBOARD_BINDING, { + globalScene.ui.setOverlayMode(UiMode.KEYBOARD_BINDING, { target: setting, cancelHandler: cancelHandler, }); diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index 377216291e2..31faf2b6283 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -1,4 +1,4 @@ -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; import { hasTouchscreen } from "#app/touch-controls"; @@ -9,7 +9,7 @@ import { EaseType } from "#enums/ease-type"; import { MoneyFormat } from "#enums/money-format"; import { PlayerGender } from "#enums/player-gender"; import { ShopCursorTarget } from "#enums/shop-cursor-target"; -import { isLocal } from "#app/utils"; +import { isLocal } from "#app/utils/common"; const VOLUME_OPTIONS: SettingOption[] = new Array(11).fill(null).map((_, i) => i @@ -906,7 +906,7 @@ export function setSetting(setting: string, value: number): boolean { return false; } }; - globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + globalScene.ui.setOverlayMode(UiMode.OPTION_SELECT, { options: [ { label: "English", diff --git a/src/system/version_migration/versions/v1_0_4.ts b/src/system/version_migration/versions/v1_0_4.ts index 2139352b783..9e30ccdc2a7 100644 --- a/src/system/version_migration/versions/v1_0_4.ts +++ b/src/system/version_migration/versions/v1_0_4.ts @@ -3,7 +3,7 @@ import type { SystemSaveData, SessionSaveData } from "#app/system/game-data"; import { AbilityAttr, defaultStarterSpecies, DexAttr } from "#app/system/game-data"; import { allSpecies } from "#app/data/pokemon-species"; import { CustomPokemonData } from "#app/data/custom-pokemon-data"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import type { SystemSaveMigrator } from "#app/@types/SystemSaveMigrator"; import type { SettingsSaveMigrator } from "#app/@types/SettingsSaveMigrator"; import type { SessionSaveMigrator } from "#app/@types/SessionSaveMigrator"; diff --git a/src/system/version_migration/versions/v1_7_0.ts b/src/system/version_migration/versions/v1_7_0.ts index a1213ccf64c..dc7c0f48640 100644 --- a/src/system/version_migration/versions/v1_7_0.ts +++ b/src/system/version_migration/versions/v1_7_0.ts @@ -3,7 +3,7 @@ import type { SystemSaveMigrator } from "#app/@types/SystemSaveMigrator"; import { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; import { globalScene } from "#app/global-scene"; import { DexAttr, type SessionSaveData, type SystemSaveData } from "#app/system/game-data"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; /** * If a starter is caught, but the only forms registered as caught are not starterSelectable, diff --git a/src/timed-event-manager.ts b/src/timed-event-manager.ts index 7bbd157948b..8f5a9c75428 100644 --- a/src/timed-event-manager.ts +++ b/src/timed-event-manager.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import { TextStyle, addTextObject } from "#app/ui/text"; -import type { nil } from "#app/utils"; -import { isNullOrUndefined } from "#app/utils"; +import type { nil } from "#app/utils/common"; +import { isNullOrUndefined } from "#app/utils/common"; import i18next from "i18next"; import { Species } from "#enums/species"; import type { WeatherPoolEntry } from "#app/data/weather"; diff --git a/src/tutorial.ts b/src/tutorial.ts index 82912f73979..d9ae3a03290 100644 --- a/src/tutorial.ts +++ b/src/tutorial.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import AwaitableUiHandler from "./ui/awaitable-ui-handler"; import type UiHandler from "./ui/ui-handler"; -import { Mode } from "./ui/ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import Overrides from "#app/overrides"; @@ -92,13 +92,13 @@ const tutorialHandlers = { }, [Tutorial.Select_Item]: () => { return new Promise(resolve => { - globalScene.ui.setModeWithoutClear(Mode.MESSAGE).then(() => { + globalScene.ui.setModeWithoutClear(UiMode.MESSAGE).then(() => { globalScene.ui.showText( i18next.t("tutorial:selectItem"), null, () => globalScene.ui.showText("", null, () => - globalScene.ui.setModeWithoutClear(Mode.MODIFIER_SELECT).then(() => resolve()), + globalScene.ui.setModeWithoutClear(UiMode.MODIFIER_SELECT).then(() => resolve()), ), null, true, diff --git a/src/ui-inputs.ts b/src/ui-inputs.ts index c9898f9b71e..bf4f51e5af7 100644 --- a/src/ui-inputs.ts +++ b/src/ui-inputs.ts @@ -1,5 +1,5 @@ import type Phaser from "phaser"; -import { Mode } from "./ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { InputsController } from "./inputs-controller"; import type MessageUiHandler from "./ui/message-ui-handler"; import StarterSelectUiHandler from "./ui/starter-select-ui-handler"; @@ -176,22 +176,22 @@ export class UiInputs { return; } switch (globalScene.ui?.getMode()) { - case Mode.MESSAGE: + case UiMode.MESSAGE: const messageHandler = globalScene.ui.getHandler(); if (!messageHandler.pendingPrompt || messageHandler.isTextAnimationInProgress()) { return; } - case Mode.TITLE: - case Mode.COMMAND: - case Mode.MODIFIER_SELECT: - case Mode.MYSTERY_ENCOUNTER: - globalScene.ui.setOverlayMode(Mode.MENU); + case UiMode.TITLE: + case UiMode.COMMAND: + case UiMode.MODIFIER_SELECT: + case UiMode.MYSTERY_ENCOUNTER: + globalScene.ui.setOverlayMode(UiMode.MENU); break; - case Mode.STARTER_SELECT: - case Mode.POKEDEX_PAGE: + case UiMode.STARTER_SELECT: + case UiMode.POKEDEX_PAGE: this.buttonTouch(); break; - case Mode.MENU: + case UiMode.MENU: globalScene.ui.revertMode(); globalScene.playSound("ui/select"); break; @@ -227,7 +227,7 @@ export class UiInputs { SettingKeys.Game_Speed, Setting[settingGameSpeed].options.findIndex(item => item.label === `${globalScene.gameSpeed}x`) + 1, ); - if (globalScene.ui?.getMode() === Mode.SETTINGS) { + if (globalScene.ui?.getMode() === UiMode.SETTINGS) { (globalScene.ui.getHandler() as SettingsUiHandler).show([]); } } else if (!up && globalScene.gameSpeed > 1) { @@ -238,7 +238,7 @@ export class UiInputs { 0, ), ); - if (globalScene.ui?.getMode() === Mode.SETTINGS) { + if (globalScene.ui?.getMode() === UiMode.SETTINGS) { (globalScene.ui.getHandler() as SettingsUiHandler).show([]); } } diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index b360065f61d..07609648a4e 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -1,9 +1,9 @@ import { globalScene } from "#app/global-scene"; import { TextStyle, addBBCodeTextObject, getTextColor, getTextStyleOptions } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { addWindow } from "./ui-theme"; -import { rgbHexToRgba, fixedInt } from "#app/utils"; +import { rgbHexToRgba, fixedInt } from "#app/utils/common"; import { argbFromRgba } from "@material/material-color-utilities"; import { Button } from "#enums/buttons"; import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodetext/BBCodeText"; @@ -56,7 +56,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { protected defaultTextStyle: TextStyle = TextStyle.WINDOW; protected textContent: string; - constructor(mode: Mode | null) { + constructor(mode: UiMode | null) { super(mode); } @@ -70,7 +70,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { const ui = this.getUi(); this.optionSelectContainer = globalScene.add.container(globalScene.game.canvas.width / 6 - 1, -48); - this.optionSelectContainer.setName(`option-select-${this.mode ? Mode[this.mode] : "UNKNOWN"}`); + this.optionSelectContainer.setName(`option-select-${this.mode ? UiMode[this.mode] : "UNKNOWN"}`); this.optionSelectContainer.setVisible(false); ui.add(this.optionSelectContainer); @@ -120,7 +120,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { // Setting the initial text to establish the width of the select object. We consider all options, even ones that are not displayed, // Except in the case of autocomplete, where we don't want to set up a text element with potentially hundreds of lines. - const optionsForWidth = globalScene.ui.getMode() === Mode.AUTO_COMPLETE ? optionsWithScroll : options; + const optionsForWidth = globalScene.ui.getMode() === UiMode.AUTO_COMPLETE ? optionsWithScroll : options; this.optionSelectText = addBBCodeTextObject( 0, 0, @@ -250,7 +250,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { } else { ui.playError(); } - } else if (button === Button.SUBMIT && ui.getMode() === Mode.AUTO_COMPLETE) { + } else if (button === Button.SUBMIT && ui.getMode() === UiMode.AUTO_COMPLETE) { // this is here to differentiate between a Button.SUBMIT vs Button.ACTION within the autocomplete handler // this is here because Button.ACTION is picked up as z on the keyboard, meaning if you're typing and hit z, it'll select the option you've chosen success = true; diff --git a/src/ui/achvs-ui-handler.ts b/src/ui/achvs-ui-handler.ts index 8b5a4dbd395..d0c8b716c7a 100644 --- a/src/ui/achvs-ui-handler.ts +++ b/src/ui/achvs-ui-handler.ts @@ -6,7 +6,7 @@ import type { Voucher } from "#app/system/voucher"; import { getVoucherTypeIcon, getVoucherTypeName, vouchers } from "#app/system/voucher"; import MessageUiHandler from "#app/ui/message-ui-handler"; import { addTextObject, TextStyle } from "#app/ui/text"; -import type { Mode } from "#app/ui/ui"; +import type { UiMode } from "#enums/ui-mode"; import { addWindow } from "#app/ui/ui-theme"; import { ScrollBar } from "#app/ui/scroll-bar"; import { PlayerGender } from "#enums/player-gender"; @@ -59,7 +59,7 @@ export default class AchvsUiHandler extends MessageUiHandler { private cursorObj: Phaser.GameObjects.NineSlice | null; private currentPage: Page; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.achvsTotal = Object.keys(achvs).length; diff --git a/src/ui/admin-ui-handler.ts b/src/ui/admin-ui-handler.ts index 34b6e59145f..67ae3118863 100644 --- a/src/ui/admin-ui-handler.ts +++ b/src/ui/admin-ui-handler.ts @@ -1,11 +1,11 @@ import { Button } from "#app/enums/buttons"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; -import { formatText } from "#app/utils"; +import { formatText } from "#app/utils/common"; import type { InputFieldConfig } from "./form-modal-ui-handler"; import { FormModalUiHandler } from "./form-modal-ui-handler"; import type { ModalConfig } from "./modal-ui-handler"; import { TextStyle } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { globalScene } from "#app/global-scene"; type AdminUiHandlerService = "discord" | "google"; @@ -30,7 +30,7 @@ export default class AdminUiHandler extends FormModalUiHandler { return `Username and ${service} successfully ${mode.toLowerCase()}ed`; }; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } @@ -143,10 +143,10 @@ export default class AdminUiHandler extends FormModalUiHandler { const adminSearchResult: AdminSearchInfo = this.convertInputsToAdmin(); // this converts the input texts into a single object for use later const validFields = this.areFieldsValid(this.adminMode); if (validFields.error) { - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); // this is here to force a loading screen to allow the admin tool to reopen again if there's an error + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); // this is here to force a loading screen to allow the admin tool to reopen again if there's an error return this.showMessage(validFields.errorMessage ?? "", adminSearchResult, true); } - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); if (this.adminMode === AdminMode.LINK) { this.adminLinkUnlink(adminSearchResult, "discord", "Link") // calls server to link discord .then(response => { @@ -174,7 +174,7 @@ export default class AdminUiHandler extends FormModalUiHandler { showMessage(message: string, adminResult: AdminSearchInfo, isError: boolean) { globalScene.ui.setMode( - Mode.ADMIN, + UiMode.ADMIN, Object.assign(this.config, { errorMessage: message?.trim() }), this.adminMode, adminResult, @@ -221,18 +221,18 @@ export default class AdminUiHandler extends FormModalUiHandler { const mode = adminResult[aR] === "" ? "Link" : "Unlink"; // this figures out if we're linking or unlinking a service const validFields = this.areFieldsValid(this.adminMode, service); if (validFields.error) { - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); // this is here to force a loading screen to allow the admin tool to reopen again if there's an error + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); // this is here to force a loading screen to allow the admin tool to reopen again if there's an error return this.showMessage(validFields.errorMessage ?? "", adminResult, true); } this.adminLinkUnlink(this.convertInputsToAdmin(), service as AdminUiHandlerService, mode).then( response => { // attempts to link/unlink depending on the service if (response.error) { - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); return this.showMessage(response.errorType, adminResult, true); // fail } // success, reload panel with new results - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); this.adminSearch(adminResult).then(response => { if (response.error) { return this.showMessage(response.errorType, adminResult, true); @@ -385,7 +385,7 @@ export default class AdminUiHandler extends FormModalUiHandler { private updateAdminPanelInfo(adminSearchResult: AdminSearchInfo, mode?: AdminMode) { mode = mode ?? AdminMode.ADMIN; globalScene.ui.setMode( - Mode.ADMIN, + UiMode.ADMIN, { buttonActions: [ // we double revert here and below to go back 2 layers of menus diff --git a/src/ui/arena-flyout.ts b/src/ui/arena-flyout.ts index 1eb18a32f98..ab3bd13b47a 100644 --- a/src/ui/arena-flyout.ts +++ b/src/ui/arena-flyout.ts @@ -16,7 +16,7 @@ import type { TurnEndEvent } from "../events/battle-scene"; import { BattleSceneEventType } from "../events/battle-scene"; import { ArenaTagType } from "#enums/arena-tag-type"; import TimeOfDayWidget from "./time-of-day-widget"; -import { toCamelCaseString, formatText, fixedInt } from "#app/utils"; +import { toCamelCaseString, formatText, fixedInt } from "#app/utils/common"; import type { ParseKeys } from "i18next"; import i18next from "i18next"; diff --git a/src/ui/autocomplete-ui-handler.ts b/src/ui/autocomplete-ui-handler.ts index a170ae43f23..ba1802c8582 100644 --- a/src/ui/autocomplete-ui-handler.ts +++ b/src/ui/autocomplete-ui-handler.ts @@ -1,10 +1,10 @@ import { Button } from "#enums/buttons"; import AbstractOptionSelectUiHandler from "./abstact-option-select-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler { modalContainer: Phaser.GameObjects.Container; - constructor(mode: Mode = Mode.OPTION_SELECT) { + constructor(mode: UiMode = UiMode.OPTION_SELECT) { super(mode); } diff --git a/src/ui/awaitable-ui-handler.ts b/src/ui/awaitable-ui-handler.ts index 890e2884fd5..3c577fd4411 100644 --- a/src/ui/awaitable-ui-handler.ts +++ b/src/ui/awaitable-ui-handler.ts @@ -1,4 +1,4 @@ -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; @@ -9,7 +9,7 @@ export default abstract class AwaitableUiHandler extends UiHandler { public tutorialActive = false; public tutorialOverlay: Phaser.GameObjects.Rectangle; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } diff --git a/src/ui/ball-ui-handler.ts b/src/ui/ball-ui-handler.ts index cfa44832824..abb106a6553 100644 --- a/src/ui/ball-ui-handler.ts +++ b/src/ui/ball-ui-handler.ts @@ -1,7 +1,7 @@ import { getPokeballName } from "../data/pokeball"; import { addTextObject, getTextStyleOptions, TextStyle } from "./text"; import { Command } from "./command-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { addWindow } from "./ui-theme"; import { Button } from "#enums/buttons"; @@ -18,7 +18,7 @@ export default class BallUiHandler extends UiHandler { private scale = 0.1666666667; constructor() { - super(Mode.BALL); + super(UiMode.BALL); } setup() { @@ -82,15 +82,15 @@ export default class BallUiHandler extends UiHandler { if (button === Button.ACTION && this.cursor < pokeballTypeCount) { if (globalScene.pokeballCounts[this.cursor]) { if (commandPhase.handleCommand(Command.BALL, this.cursor)) { - globalScene.ui.setMode(Mode.COMMAND, commandPhase.getFieldIndex()); - globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.setMode(UiMode.COMMAND, commandPhase.getFieldIndex()); + globalScene.ui.setMode(UiMode.MESSAGE); success = true; } } else { ui.playError(); } } else { - ui.setMode(Mode.COMMAND, commandPhase.getFieldIndex()); + ui.setMode(UiMode.COMMAND, commandPhase.getFieldIndex()); success = true; } } else { diff --git a/src/ui/base-stats-overlay.ts b/src/ui/base-stats-overlay.ts index d0b0aff3a9d..0541ae766e5 100644 --- a/src/ui/base-stats-overlay.ts +++ b/src/ui/base-stats-overlay.ts @@ -1,7 +1,7 @@ import type { InfoToggle } from "../battle-scene"; import { TextStyle, addTextObject } from "./text"; import { addWindow } from "./ui-theme"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; diff --git a/src/ui/battle-flyout.ts b/src/ui/battle-flyout.ts index 854f4cc4dd9..e590bebcf5a 100644 --- a/src/ui/battle-flyout.ts +++ b/src/ui/battle-flyout.ts @@ -1,6 +1,6 @@ import type { default as Pokemon } from "../field/pokemon"; import { addTextObject, TextStyle } from "./text"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { globalScene } from "#app/global-scene"; import type Move from "#app/data/moves/move"; import type { BerryUsedEvent, MoveUsedEvent } from "../events/battle-scene"; diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 06c5f7fb3f1..4f9e59c8c89 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -1,6 +1,6 @@ import type { EnemyPokemon, default as Pokemon } from "../field/pokemon"; import { getLevelTotalExp, getLevelRelExp } from "../data/exp"; -import { getLocalizedSpriteKey, fixedInt } from "#app/utils"; +import { getLocalizedSpriteKey, fixedInt } from "#app/utils/common"; import { addTextObject, TextStyle } from "./text"; import { getGenderSymbol, getGenderColor, Gender } from "../data/gender"; import { StatusEffect } from "#enums/status-effect"; @@ -617,7 +617,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { return resolve(); } - const gender: Gender = !!pokemon.summonData?.illusion ? pokemon.summonData?.illusion.gender : pokemon.gender; + const gender: Gender = pokemon.summonData?.illusion ? pokemon.summonData?.illusion.gender : pokemon.gender; this.genderText.setText(getGenderSymbol(gender)); this.genderText.setColor(getGenderColor(gender)); @@ -794,7 +794,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const nameSizeTest = addTextObject(0, 0, displayName, TextStyle.BATTLE_INFO); nameTextWidth = nameSizeTest.displayWidth; - const gender: Gender = !!pokemon.summonData?.illusion ? pokemon.summonData?.illusion.gender : pokemon.gender; + const gender: Gender = pokemon.summonData?.illusion ? pokemon.summonData?.illusion.gender : pokemon.gender; while ( nameTextWidth > (this.player || !this.boss ? 60 : 98) - diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index ccb9378c688..d1102bbe53e 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import MessageUiHandler from "./message-ui-handler"; import { addWindow } from "./ui-theme"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; @@ -23,7 +23,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { public readonly wordWrapWidth: number = 1780; constructor() { - super(Mode.MESSAGE); + super(UiMode.MESSAGE); } setup(): void { diff --git a/src/ui/bgm-bar.ts b/src/ui/bgm-bar.ts index d944453ba2c..e331d82f6d9 100644 --- a/src/ui/bgm-bar.ts +++ b/src/ui/bgm-bar.ts @@ -1,6 +1,6 @@ import { addTextObject, TextStyle } from "./text"; import i18next from "i18next"; -import { formatText } from "#app/utils"; +import { formatText } from "#app/utils/common"; import { globalScene } from "#app/global-scene"; const hiddenX = -150; diff --git a/src/ui/candy-bar.ts b/src/ui/candy-bar.ts index 0cf3e0c91e9..f7a01b83093 100644 --- a/src/ui/candy-bar.ts +++ b/src/ui/candy-bar.ts @@ -1,8 +1,8 @@ -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { globalScene } from "#app/global-scene"; import { TextStyle, addTextObject } from "./text"; import { argbFromRgba } from "@material/material-color-utilities"; -import { rgbHexToRgba } from "#app/utils"; +import { rgbHexToRgba } from "#app/utils/common"; import type { Species } from "#enums/species"; export default class CandyBar extends Phaser.GameObjects.Container { diff --git a/src/ui/challenges-select-ui-handler.ts b/src/ui/challenges-select-ui-handler.ts index caffede2487..d1df16a457b 100644 --- a/src/ui/challenges-select-ui-handler.ts +++ b/src/ui/challenges-select-ui-handler.ts @@ -1,11 +1,11 @@ import { TextStyle, addTextObject } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { addWindow } from "./ui-theme"; import { Button } from "#enums/buttons"; import i18next from "i18next"; import type { Challenge } from "#app/data/challenge"; -import { getLocalizedSpriteKey } from "#app/utils"; +import { getLocalizedSpriteKey } from "#app/utils/common"; import { Challenges } from "#app/enums/challenges"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { Color, ShadowColor } from "#app/enums/color"; @@ -50,7 +50,7 @@ export default class GameChallengesUiHandler extends UiHandler { private readonly leftArrowGap: number = 90; // distance from the label to the left arrow private readonly arrowSpacing: number = 3; // distance between the arrows and the value area - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } diff --git a/src/ui/char-sprite.ts b/src/ui/char-sprite.ts index f717927c107..a8451f4bb9c 100644 --- a/src/ui/char-sprite.ts +++ b/src/ui/char-sprite.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { MissingTextureKey } from "#app/utils"; +import { MissingTextureKey } from "#app/utils/common"; export default class CharSprite extends Phaser.GameObjects.Container { private sprite: Phaser.GameObjects.Sprite; diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index 55937bb8b00..57c5b5a82a2 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -1,6 +1,6 @@ import { addTextObject, TextStyle } from "./text"; import PartyUiHandler, { PartyUiMode } from "./party-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import i18next from "i18next"; import { Button } from "#enums/buttons"; @@ -30,7 +30,7 @@ export default class CommandUiHandler extends UiHandler { protected cursor2 = 0; constructor() { - super(Mode.COMMAND); + super(UiMode.COMMAND); } setup() { @@ -124,18 +124,18 @@ export default class CommandUiHandler extends UiHandler { switch (cursor) { // Fight case Command.FIGHT: - ui.setMode(Mode.FIGHT, (globalScene.getCurrentPhase() as CommandPhase).getFieldIndex()); + ui.setMode(UiMode.FIGHT, (globalScene.getCurrentPhase() as CommandPhase).getFieldIndex()); success = true; break; // Ball case Command.BALL: - ui.setModeWithoutClear(Mode.BALL); + ui.setModeWithoutClear(UiMode.BALL); success = true; break; // Pokemon case Command.POKEMON: ui.setMode( - Mode.PARTY, + UiMode.PARTY, PartyUiMode.SWITCH, (globalScene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex(), null, @@ -149,7 +149,7 @@ export default class CommandUiHandler extends UiHandler { success = true; break; case Command.TERA: - ui.setMode(Mode.FIGHT, (globalScene.getCurrentPhase() as CommandPhase).getFieldIndex(), Command.TERA); + ui.setMode(UiMode.FIGHT, (globalScene.getCurrentPhase() as CommandPhase).getFieldIndex(), Command.TERA); success = true; break; } diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index eb7018051b7..7b5ca3d7e63 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -1,6 +1,6 @@ import type { OptionSelectConfig } from "./abstact-option-select-ui-handler"; import AbstractOptionSelectUiHandler from "./abstact-option-select-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; @@ -12,7 +12,7 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { private switchCheckCursor: number; constructor() { - super(Mode.CONFIRM); + super(UiMode.CONFIRM); } getWindowWidth(): number { diff --git a/src/ui/daily-run-scoreboard.ts b/src/ui/daily-run-scoreboard.ts index 896f2171676..076a782908b 100644 --- a/src/ui/daily-run-scoreboard.ts +++ b/src/ui/daily-run-scoreboard.ts @@ -1,6 +1,6 @@ import i18next from "i18next"; import { globalScene } from "#app/global-scene"; -import { getEnumKeys, executeIf } from "#app/utils"; +import { getEnumKeys, executeIf } from "#app/utils/common"; import { TextStyle, addTextObject } from "./text"; import { WindowVariant, addWindow } from "./ui-theme"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 956a308448b..5377cf3d283 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -1,7 +1,7 @@ -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { TextStyle, addTextObject, getEggTierTextTint, getTextStyleOptions } from "./text"; import MessageUiHandler from "./message-ui-handler"; -import { getEnumValues, getEnumKeys, fixedInt, randSeedShuffle } from "#app/utils"; +import { getEnumValues, getEnumKeys, fixedInt, randSeedShuffle } from "#app/utils/common"; import type { IEggOptions } from "../data/egg"; import { Egg, getLegendaryGachaSpeciesForTimestamp } from "../data/egg"; import { VoucherType, getVoucherTypeIcon } from "../system/voucher"; @@ -41,7 +41,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { private scale = 0.1666666667; constructor() { - super(Mode.EGG_GACHA); + super(UiMode.EGG_GACHA); this.gachaContainers = []; this.gachaKnobs = []; diff --git a/src/ui/egg-hatch-scene-handler.ts b/src/ui/egg-hatch-scene-handler.ts index 6ede68b7ae6..76e2c54f4b6 100644 --- a/src/ui/egg-hatch-scene-handler.ts +++ b/src/ui/egg-hatch-scene-handler.ts @@ -1,4 +1,4 @@ -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { Button } from "#enums/buttons"; import { EggHatchPhase } from "#app/phases/egg-hatch-phase"; @@ -16,7 +16,7 @@ export default class EggHatchSceneHandler extends UiHandler { public readonly eventTarget: EventTarget = new EventTarget(); constructor() { - super(Mode.EGG_HATCH_SCENE); + super(UiMode.EGG_HATCH_SCENE); } setup() { diff --git a/src/ui/egg-list-ui-handler.ts b/src/ui/egg-list-ui-handler.ts index cf3326bec13..9f41feea8ab 100644 --- a/src/ui/egg-list-ui-handler.ts +++ b/src/ui/egg-list-ui-handler.ts @@ -1,4 +1,4 @@ -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "#app/ui/pokemon-icon-anim-handler"; import { TextStyle, addTextObject } from "#app/ui/text"; import MessageUiHandler from "#app/ui/message-ui-handler"; @@ -29,7 +29,7 @@ export default class EggListUiHandler extends MessageUiHandler { private iconAnimHandler: PokemonIconAnimHandler; constructor() { - super(Mode.EGG_LIST); + super(UiMode.EGG_LIST); } setup() { diff --git a/src/ui/egg-summary-ui-handler.ts b/src/ui/egg-summary-ui-handler.ts index f335f83d8bf..ddc536fe1ad 100644 --- a/src/ui/egg-summary-ui-handler.ts +++ b/src/ui/egg-summary-ui-handler.ts @@ -1,4 +1,4 @@ -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler"; import MessageUiHandler from "./message-ui-handler"; import { getEggTierForSpecies } from "../data/egg"; @@ -54,7 +54,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler { public readonly eventTarget: EventTarget = new EventTarget(); constructor() { - super(Mode.EGG_HATCH_SUMMARY); + super(UiMode.EGG_HATCH_SUMMARY); } setup() { diff --git a/src/ui/evolution-scene-handler.ts b/src/ui/evolution-scene-handler.ts index 91f3360a3d4..cea91ce4e2c 100644 --- a/src/ui/evolution-scene-handler.ts +++ b/src/ui/evolution-scene-handler.ts @@ -1,6 +1,6 @@ import MessageUiHandler from "./message-ui-handler"; import { TextStyle, addTextObject } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; @@ -12,7 +12,7 @@ export default class EvolutionSceneHandler extends MessageUiHandler { public cancelled: boolean; constructor() { - super(Mode.EVOLUTION_SCENE); + super(UiMode.EVOLUTION_SCENE); } setup() { diff --git a/src/ui/fight-ui-handler.ts b/src/ui/fight-ui-handler.ts index 285a1dd36cc..e0a73d62934 100644 --- a/src/ui/fight-ui-handler.ts +++ b/src/ui/fight-ui-handler.ts @@ -4,9 +4,9 @@ import { addTextObject, TextStyle } from "./text"; import { getTypeDamageMultiplierColor } from "#app/data/type"; import { PokemonType } from "#enums/pokemon-type"; import { Command } from "./command-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; -import { getLocalizedSpriteKey, fixedInt, padInt } from "#app/utils"; +import { getLocalizedSpriteKey, fixedInt, padInt } from "#app/utils/common"; import { MoveCategory } from "#enums/MoveCategory"; import i18next from "i18next"; import { Button } from "#enums/buttons"; @@ -37,7 +37,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { protected cursor2 = 0; constructor() { - super(Mode.FIGHT); + super(UiMode.FIGHT); } setup() { @@ -156,7 +156,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { // Cannot back out of fight menu if skipToFightInput is enabled const { battleType, mysteryEncounter } = globalScene.currentBattle; if (battleType !== BattleType.MYSTERY_ENCOUNTER || !mysteryEncounter?.skipToFightInput) { - ui.setMode(Mode.COMMAND, this.fieldIndex); + ui.setMode(UiMode.COMMAND, this.fieldIndex); success = true; } } @@ -308,7 +308,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { !opponent.battleData?.abilityRevealed, undefined, undefined, - true + true, ); if (effectiveness === undefined) { return undefined; @@ -353,7 +353,14 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { const moveColors = opponents .map(opponent => - opponent.getMoveEffectiveness(pokemon, pokemonMove.getMove(), !opponent.battleData.abilityRevealed, undefined, undefined, true), + opponent.getMoveEffectiveness( + pokemon, + pokemonMove.getMove(), + !opponent.battleData.abilityRevealed, + undefined, + undefined, + true, + ), ) .sort((a, b) => b - a) .map(effectiveness => getTypeDamageMultiplierColor(effectiveness ?? 0, "offense")); diff --git a/src/ui/filter-text.ts b/src/ui/filter-text.ts index a6b01ba39e6..8b13b76db31 100644 --- a/src/ui/filter-text.ts +++ b/src/ui/filter-text.ts @@ -5,7 +5,7 @@ import { addWindow, WindowVariant } from "./ui-theme"; import i18next from "i18next"; import type AwaitableUiHandler from "./awaitable-ui-handler"; import type UI from "./ui"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { globalScene } from "#app/global-scene"; export enum FilterTextRow { @@ -154,7 +154,7 @@ export class FilterText extends Phaser.GameObjects.Container { this.onChange; }, ]; - ui.setOverlayMode(Mode.POKEDEX_SCAN, buttonAction, prefilledText, index); + ui.setOverlayMode(UiMode.POKEDEX_SCAN, buttonAction, prefilledText, index); } setCursor(cursor: number): void { diff --git a/src/ui/form-modal-ui-handler.ts b/src/ui/form-modal-ui-handler.ts index e27b2e9ed89..e8e67d591d5 100644 --- a/src/ui/form-modal-ui-handler.ts +++ b/src/ui/form-modal-ui-handler.ts @@ -1,10 +1,10 @@ import type { ModalConfig } from "./modal-ui-handler"; import { ModalUiHandler } from "./modal-ui-handler"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import { TextStyle, addTextInputObject, addTextObject } from "./text"; import { WindowVariant, addWindow } from "./ui-theme"; import type InputText from "phaser3-rex-plugins/plugins/inputtext"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; @@ -21,7 +21,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler { protected tween: Phaser.Tweens.Tween; protected formLabels: Phaser.GameObjects.Text[]; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.editing = false; diff --git a/src/ui/game-stats-ui-handler.ts b/src/ui/game-stats-ui-handler.ts index 2e2112dfda4..dc184a34866 100644 --- a/src/ui/game-stats-ui-handler.ts +++ b/src/ui/game-stats-ui-handler.ts @@ -1,9 +1,9 @@ import Phaser from "phaser"; import { TextStyle, addTextObject } from "#app/ui/text"; -import type { Mode } from "#app/ui/ui"; +import type { UiMode } from "#enums/ui-mode"; import UiHandler from "#app/ui/ui-handler"; import { addWindow } from "#app/ui/ui-theme"; -import { getPlayTimeString, formatFancyLargeNumber, toReadableString } from "#app/utils"; +import { getPlayTimeString, formatFancyLargeNumber, toReadableString } from "#app/utils/common"; import type { GameData } from "#app/system/game-data"; import { DexAttr } from "#app/system/game-data"; import { speciesStarterCosts } from "#app/data/balance/starters"; @@ -223,7 +223,7 @@ export default class GameStatsUiHandler extends UiHandler { private arrowUp: Phaser.GameObjects.Sprite; private arrowDown: Phaser.GameObjects.Sprite; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.statLabels = []; diff --git a/src/ui/loading-modal-ui-handler.ts b/src/ui/loading-modal-ui-handler.ts index 9626276245d..13dffe5614c 100644 --- a/src/ui/loading-modal-ui-handler.ts +++ b/src/ui/loading-modal-ui-handler.ts @@ -1,10 +1,10 @@ import i18next from "i18next"; import { ModalUiHandler } from "./modal-ui-handler"; import { addTextObject, TextStyle } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; export default class LoadingModalUiHandler extends ModalUiHandler { - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } diff --git a/src/ui/login-form-ui-handler.ts b/src/ui/login-form-ui-handler.ts index 5c009357443..2dfab9c0c40 100644 --- a/src/ui/login-form-ui-handler.ts +++ b/src/ui/login-form-ui-handler.ts @@ -1,8 +1,8 @@ import type { InputFieldConfig } from "./form-modal-ui-handler"; import { FormModalUiHandler } from "./form-modal-ui-handler"; import type { ModalConfig } from "./modal-ui-handler"; -import { fixedInt } from "#app/utils"; -import { Mode } from "./ui"; +import { fixedInt } from "#app/utils/common"; +import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { addTextObject, TextStyle } from "./text"; import { addWindow } from "./ui-theme"; @@ -34,7 +34,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { private infoContainer: Phaser.GameObjects.Container; private externalPartyBg: Phaser.GameObjects.NineSlice; private externalPartyTitle: Phaser.GameObjects.Text; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } @@ -146,9 +146,9 @@ export default class LoginFormUiHandler extends FormModalUiHandler { // Prevent overlapping overrides on action modification this.submitAction = originalLoginAction; this.sanitizeInputs(); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); const onFail = error => { - globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); + globalScene.ui.setMode(UiMode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); }; if (!this.inputs[0].text) { @@ -215,8 +215,8 @@ export default class LoginFormUiHandler extends FormModalUiHandler { }); const onFail = error => { - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); - globalScene.ui.setModeForceTransition(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); + globalScene.ui.setModeForceTransition(UiMode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); }; @@ -236,7 +236,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { }, }); } - globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + globalScene.ui.setOverlayMode(UiMode.OPTION_SELECT, { options: options, delay: 1000, }); diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 241ddbb91a8..7f0cd4d6a78 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -1,8 +1,10 @@ -import { bypassLogin } from "#app/battle-scene"; +import { bypassLogin } from "#app/global-vars/bypass-login"; import { globalScene } from "#app/global-scene"; import { TextStyle, addTextObject, getTextStyleOptions } from "./text"; -import { Mode } from "./ui"; -import { getEnumKeys, isLocal, isBeta, fixedInt, getCookie, sessionIdKey } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { getEnumKeys, isLocal, fixedInt, sessionIdKey } from "#app/utils/common"; +import { isBeta } from "#app/utils/utility-vars"; +import { getCookie } from "#app/utils/cookies"; import { addWindow, WindowVariant } from "./ui-theme"; import MessageUiHandler from "./message-ui-handler"; import type { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler"; @@ -64,12 +66,12 @@ export default class MenuUiHandler extends MessageUiHandler { public bgmBar: BgmBar; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.excludedMenus = () => [ { - condition: [Mode.COMMAND, Mode.TITLE].includes(mode ?? Mode.TITLE), + condition: [UiMode.COMMAND, UiMode.TITLE].includes(mode ?? UiMode.TITLE), options: [MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST], }, { condition: bypassLogin, options: [MenuOptions.LOG_OUT] }, @@ -234,7 +236,7 @@ export default class MenuUiHandler extends MessageUiHandler { ]), xOffset: 98, }; - ui.setOverlayMode(Mode.MENU_OPTION_SELECT, config); + ui.setOverlayMode(UiMode.MENU_OPTION_SELECT, config); }); }; @@ -377,7 +379,7 @@ export default class MenuUiHandler extends MessageUiHandler { ui.revertMode(); }, ]; - ui.setMode(Mode.TEST_DIALOGUE, buttonAction, prefilledText); + ui.setMode(UiMode.TEST_DIALOGUE, buttonAction, prefilledText); return true; }, keepOpen: true, @@ -456,7 +458,7 @@ export default class MenuUiHandler extends MessageUiHandler { handler: () => { ui.playSelect(); ui.setOverlayMode( - Mode.ADMIN, + UiMode.ADMIN, { buttonActions: [ // we double revert here and below to go back 2 layers of menus @@ -483,7 +485,7 @@ export default class MenuUiHandler extends MessageUiHandler { return true; }, }); - globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + globalScene.ui.setOverlayMode(UiMode.OPTION_SELECT, { options: options, delay: 0, }); @@ -557,21 +559,21 @@ export default class MenuUiHandler extends MessageUiHandler { this.showText("", 0); switch (adjustedCursor) { case MenuOptions.GAME_SETTINGS: - ui.setOverlayMode(Mode.SETTINGS); + ui.setOverlayMode(UiMode.SETTINGS); success = true; break; case MenuOptions.ACHIEVEMENTS: - ui.setOverlayMode(Mode.ACHIEVEMENTS); + ui.setOverlayMode(UiMode.ACHIEVEMENTS); success = true; break; case MenuOptions.STATS: - ui.setOverlayMode(Mode.GAME_STATS); + ui.setOverlayMode(UiMode.GAME_STATS); success = true; break; case MenuOptions.EGG_LIST: if (globalScene.gameData.eggs.length) { ui.revertMode(); - ui.setOverlayMode(Mode.EGG_LIST); + ui.setOverlayMode(UiMode.EGG_LIST); success = true; } else { ui.showText(i18next.t("menuUiHandler:noEggs"), null, () => ui.showText(""), fixedInt(1500)); @@ -580,12 +582,12 @@ export default class MenuUiHandler extends MessageUiHandler { break; case MenuOptions.EGG_GACHA: ui.revertMode(); - ui.setOverlayMode(Mode.EGG_GACHA); + ui.setOverlayMode(UiMode.EGG_GACHA); success = true; break; case MenuOptions.POKEDEX: ui.revertMode(); - ui.setOverlayMode(Mode.POKEDEX); + ui.setOverlayMode(UiMode.POKEDEX); success = true; break; case MenuOptions.MANAGE_DATA: @@ -642,18 +644,18 @@ export default class MenuUiHandler extends MessageUiHandler { }, ); } - ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.manageDataConfig); + ui.setOverlayMode(UiMode.MENU_OPTION_SELECT, this.manageDataConfig); success = true; break; case MenuOptions.COMMUNITY: - ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.communityConfig); + ui.setOverlayMode(UiMode.MENU_OPTION_SELECT, this.communityConfig); success = true; break; case MenuOptions.SAVE_AND_QUIT: if (globalScene.currentBattle) { success = true; const doSaveQuit = () => { - ui.setMode(Mode.LOADING, { + ui.setMode(UiMode.LOADING, { buttonActions: [], fadeOut: () => globalScene.gameData.saveAll(true, true, true, true).then(() => { @@ -668,7 +670,7 @@ export default class MenuUiHandler extends MessageUiHandler { return; } ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, doSaveQuit, () => { ui.revertMode(); @@ -688,7 +690,7 @@ export default class MenuUiHandler extends MessageUiHandler { case MenuOptions.LOG_OUT: success = true; const doLogout = () => { - ui.setMode(Mode.LOADING, { + ui.setMode(UiMode.LOADING, { buttonActions: [], fadeOut: () => pokerogueApi.account.logout().then(() => { @@ -703,7 +705,7 @@ export default class MenuUiHandler extends MessageUiHandler { return; } ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, doLogout, () => { ui.revertMode(); @@ -722,7 +724,7 @@ export default class MenuUiHandler extends MessageUiHandler { success = true; ui.revertMode().then(result => { if (!result) { - ui.setMode(Mode.MESSAGE); + ui.setMode(UiMode.MESSAGE); } }); } else { diff --git a/src/ui/message-ui-handler.ts b/src/ui/message-ui-handler.ts index b57b236531c..efa53b63808 100644 --- a/src/ui/message-ui-handler.ts +++ b/src/ui/message-ui-handler.ts @@ -1,6 +1,6 @@ import AwaitableUiHandler from "./awaitable-ui-handler"; -import type { Mode } from "./ui"; -import { getFrameMs } from "#app/utils"; +import type { UiMode } from "#enums/ui-mode"; +import { getFrameMs } from "#app/utils/common"; import { globalScene } from "#app/global-scene"; export default abstract class MessageUiHandler extends AwaitableUiHandler { @@ -11,7 +11,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { public message: Phaser.GameObjects.Text; public prompt: Phaser.GameObjects.Sprite; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.pendingPrompt = false; diff --git a/src/ui/modal-ui-handler.ts b/src/ui/modal-ui-handler.ts index b7dbbeb202d..a3b94296d3f 100644 --- a/src/ui/modal-ui-handler.ts +++ b/src/ui/modal-ui-handler.ts @@ -1,5 +1,5 @@ import { TextStyle, addTextObject } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { WindowVariant, addWindow } from "./ui-theme"; import type { Button } from "#enums/buttons"; @@ -17,7 +17,7 @@ export abstract class ModalUiHandler extends UiHandler { protected buttonBgs: Phaser.GameObjects.NineSlice[]; protected buttonLabels: Phaser.GameObjects.Text[]; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.buttonContainers = []; diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 26351d4dbf1..9ba54491175 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -4,13 +4,13 @@ import { getPlayerShopModifierTypeOptionsForWave, TmModifierType } from "../modi import { getPokeballAtlasKey } from "#app/data/pokeball"; import { addTextObject, getTextStyleOptions, getModifierTierTextTint, getTextColor, TextStyle } from "./text"; import AwaitableUiHandler from "./awaitable-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { LockModifierTiersModifier, PokemonHeldItemModifier, HealShopCostModifier } from "../modifier/modifier"; import { handleTutorial, Tutorial } from "../tutorial"; import { Button } from "#enums/buttons"; import MoveInfoOverlay from "./move-info-overlay"; import { allMoves } from "../data/moves/move"; -import { formatMoney, NumberHolder } from "#app/utils"; +import { formatMoney, NumberHolder } from "#app/utils/common"; import Overrides from "#app/overrides"; import i18next from "i18next"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; @@ -50,7 +50,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { private cursorObj: Phaser.GameObjects.Image | null; constructor() { - super(Mode.CONFIRM); + super(UiMode.CONFIRM); this.options = []; this.shopOptionsRows = []; diff --git a/src/ui/move-info-overlay.ts b/src/ui/move-info-overlay.ts index bd9fdf00c72..2b230d609fd 100644 --- a/src/ui/move-info-overlay.ts +++ b/src/ui/move-info-overlay.ts @@ -2,7 +2,7 @@ import type { InfoToggle } from "#app/battle-scene"; import { globalScene } from "#app/global-scene"; import { TextStyle, addTextObject } from "./text"; import { addWindow } from "./ui-theme"; -import { getLocalizedSpriteKey, fixedInt } from "#app/utils"; +import { getLocalizedSpriteKey, fixedInt } from "#app/utils/common"; import type Move from "../data/moves/move"; import { MoveCategory } from "#enums/MoveCategory"; import { PokemonType } from "#enums/pokemon-type"; diff --git a/src/ui/mystery-encounter-ui-handler.ts b/src/ui/mystery-encounter-ui-handler.ts index 2bf05302c55..0866ed8788e 100644 --- a/src/ui/mystery-encounter-ui-handler.ts +++ b/src/ui/mystery-encounter-ui-handler.ts @@ -1,12 +1,12 @@ import { addBBCodeTextObject, getBBCodeFrag, TextStyle } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; import { Button } from "#enums/buttons"; import { addWindow, WindowVariant } from "./ui-theme"; import type { MysteryEncounterPhase } from "../phases/mystery-encounter-phases"; import { PartyUiMode } from "./party-ui-handler"; import type MysteryEncounterOption from "#app/data/mystery-encounters/mystery-encounter-option"; -import { fixedInt, isNullOrUndefined } from "#app/utils"; +import { fixedInt, isNullOrUndefined } from "#app/utils/common"; import { getPokeballAtlasKey } from "../data/pokeball"; import type { OptionSelectSettings } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; @@ -47,7 +47,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { protected blockInput = true; constructor() { - super(Mode.MYSTERY_ENCOUNTER); + super(UiMode.MYSTERY_ENCOUNTER); } override setup() { @@ -141,8 +141,8 @@ export default class MysteryEncounterUiHandler extends UiHandler { ...this.overrideSettings, slideInDescription: false, }; - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.CHECK, -1, () => { - globalScene.ui.setMode(Mode.MYSTERY_ENCOUNTER, overrideSettings); + globalScene.ui.setMode(UiMode.PARTY, PartyUiMode.CHECK, -1, () => { + globalScene.ui.setMode(UiMode.MYSTERY_ENCOUNTER, overrideSettings); setTimeout(() => { this.setCursor(this.viewPartyIndex); this.unblockInput(); diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index ba90108c274..7c3689e757c 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -4,8 +4,8 @@ import { MoveResult } from "#app/field/pokemon"; import { addBBCodeTextObject, addTextObject, getTextColor, TextStyle } from "#app/ui/text"; import { Command } from "#app/ui/command-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { BooleanHolder, toReadableString, randInt, getLocalizedSpriteKey } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { BooleanHolder, toReadableString, randInt, getLocalizedSpriteKey } from "#app/utils/common"; import { PokemonFormChangeItemModifier, PokemonHeldItemModifier, @@ -252,7 +252,7 @@ export default class PartyUiHandler extends MessageUiHandler { ]; constructor() { - super(Mode.PARTY); + super(UiMode.PARTY); } setup() { @@ -556,7 +556,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.showText(filterResult as string, undefined, () => this.showText("", 0), undefined, true); } else if (option === PartyOption.SUMMARY) { ui.playSelect(); - ui.setModeWithoutClear(Mode.SUMMARY, pokemon).then(() => this.clearOptions()); + ui.setModeWithoutClear(UiMode.SUMMARY, pokemon).then(() => this.clearOptions()); return true; } else if (option === PartyOption.POKEDEX) { ui.playSelect(); @@ -566,7 +566,7 @@ export default class PartyUiHandler extends MessageUiHandler { form: pokemon.formIndex, female: pokemon.gender === Gender.FEMALE, }; - ui.setOverlayMode(Mode.POKEDEX_PAGE, pokemon.species, attributes).then(() => this.clearOptions()); + ui.setOverlayMode(UiMode.POKEDEX_PAGE, pokemon.species, attributes).then(() => this.clearOptions()); return true; } else if (option === PartyOption.UNPAUSE_EVOLUTION) { this.clearOptions(); @@ -593,13 +593,13 @@ export default class PartyUiHandler extends MessageUiHandler { null, () => { ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { const fusionName = pokemon.getName(); pokemon.unfuse().then(() => { this.clearPartySlots(); this.populatePartySlots(); - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); this.showText( i18next.t("partyUiHandler:wasReverted", { fusionName: fusionName, @@ -607,7 +607,7 @@ export default class PartyUiHandler extends MessageUiHandler { }), undefined, () => { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); this.showText("", 0); }, null, @@ -616,7 +616,7 @@ export default class PartyUiHandler extends MessageUiHandler { }); }, () => { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); this.showText("", 0); }, ); @@ -635,13 +635,13 @@ export default class PartyUiHandler extends MessageUiHandler { () => { this.blockInput = false; ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); this.doRelease(this.cursor); }, () => { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); this.showText("", 0); }, ); @@ -655,7 +655,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.clearOptions(); ui.playSelect(); ui.setModeWithoutClear( - Mode.RENAME_POKEMON, + UiMode.RENAME_POKEMON, { buttonActions: [ (nickname: string) => { @@ -664,10 +664,10 @@ export default class PartyUiHandler extends MessageUiHandler { pokemon.updateInfo(); this.clearPartySlots(); this.populatePartySlots(); - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); }, () => { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); }, ], }, @@ -788,7 +788,7 @@ export default class PartyUiHandler extends MessageUiHandler { selectCallback(6, PartyOption.CANCEL); ui.playSelect(); } else { - ui.setMode(Mode.COMMAND, this.fieldIndex); + ui.setMode(UiMode.COMMAND, this.fieldIndex); ui.playSelect(); } } diff --git a/src/ui/pokedex-info-overlay.ts b/src/ui/pokedex-info-overlay.ts index 43e9bbc1a65..2e889f6d2a9 100644 --- a/src/ui/pokedex-info-overlay.ts +++ b/src/ui/pokedex-info-overlay.ts @@ -1,7 +1,7 @@ import type { InfoToggle } from "../battle-scene"; import { TextStyle, addTextObject } from "./text"; import { addWindow } from "./ui-theme"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; diff --git a/src/ui/pokedex-mon-container.ts b/src/ui/pokedex-mon-container.ts index 410effda40d..da79320850d 100644 --- a/src/ui/pokedex-mon-container.ts +++ b/src/ui/pokedex-mon-container.ts @@ -1,6 +1,6 @@ import type { Variant } from "#app/sprites/variant"; import { globalScene } from "#app/global-scene"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import type PokemonSpecies from "../data/pokemon-species"; import { addTextObject, TextStyle } from "./text"; diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index 3f8959c6219..d0b85544494 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -4,7 +4,7 @@ import type { Variant } from "#app/sprites/variant"; import { getVariantTint, getVariantIcon } from "#app/sprites/variant"; import { argbFromRgba } from "@material/material-color-utilities"; import i18next from "i18next"; -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { allAbilities } from "#app/data/data-lists"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { GrowthRate, getGrowthRateColor } from "#app/data/exp"; @@ -26,7 +26,7 @@ import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler" import MessageUiHandler from "#app/ui/message-ui-handler"; import { StatsContainer } from "#app/ui/stats-container"; import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor, getTextStyleOptions } from "#app/ui/text"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { addWindow } from "#app/ui/ui-theme"; import { Egg } from "#app/data/egg"; import Overrides from "#app/overrides"; @@ -52,9 +52,9 @@ import { padInt, rgbHexToRgba, toReadableString, -} from "#app/utils"; +} from "#app/utils/common"; import type { Nature } from "#enums/nature"; -import { getEnumKeys } from "#app/utils"; +import { getEnumKeys } from "#app/utils/common"; import { speciesTmMoves } from "#app/data/balance/tms"; import type { BiomeTierTod } from "#app/data/balance/biomes"; import { BiomePoolTier, catchableSpecies } from "#app/data/balance/biomes"; @@ -265,7 +265,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { private exitCallback; constructor() { - super(Mode.POKEDEX_PAGE); + super(UiMode.POKEDEX_PAGE); } setup() { @@ -1140,12 +1140,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler { success = true; } else if (this.previousSpecies.length > 0) { this.blockInput = true; - ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => { + ui.setModeWithoutClear(UiMode.OPTION_SELECT).then(() => { const species = this.previousSpecies.pop(); const starterAttributes = this.previousStarterAttributes.pop(); this.moveInfoOverlay.clear(); this.clearText(); - ui.setModeForceTransition(Mode.POKEDEX_PAGE, species, starterAttributes); + ui.setModeForceTransition(UiMode.POKEDEX_PAGE, species, starterAttributes); success = true; }); this.blockInput = false; @@ -1173,7 +1173,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showBaseStats"), null, () => { this.baseStatsOverlay.show(this.baseStats, this.baseTotal); @@ -1193,11 +1193,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showLevelMoves"), null, () => { this.moveInfoOverlay.show(allMoves[this.levelMoves[0][1]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: this.levelMoves .map(m => { const levelNumber = m[0] > 0 ? String(m[0]) : ""; @@ -1226,7 +1226,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => { @@ -1251,7 +1251,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { if (this.eggMoves.length === 0) { ui.showText(i18next.t("pokedexUiHandler:noEggMoves")); this.blockInput = false; @@ -1261,7 +1261,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.showText(i18next.t("pokedexUiHandler:showEggMoves"), null, () => { this.moveInfoOverlay.show(allMoves[this.eggMoves[0]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: [ { label: i18next.t("pokedexUiHandler:common"), @@ -1294,7 +1294,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => this.moveInfoOverlay.clear(), @@ -1321,11 +1321,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showTmMoves"), null, () => { this.moveInfoOverlay.show(allMoves[this.tmMoves[0]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: this.tmMoves .map(m => { const option: OptionSelectItem = { @@ -1344,7 +1344,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => { @@ -1369,7 +1369,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showAbilities"), null, () => { this.infoOverlay.show(allAbilities[this.ability1].description); @@ -1431,13 +1431,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.infoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => this.infoOverlay.clear(), }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, @@ -1457,7 +1457,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { if ((!this.biomes || this.biomes?.length === 0) && (!this.preBiomes || this.preBiomes?.length === 0)) { ui.showText(i18next.t("pokedexUiHandler:noBiomes")); ui.playError(); @@ -1510,13 +1510,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => this.moveInfoOverlay.clear(), }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, @@ -1536,7 +1536,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { const options: any[] = []; if ( @@ -1589,7 +1589,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes); + ui.setMode(UiMode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes); return true; }, onHover: () => this.showText(conditionText), @@ -1631,7 +1631,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, evoSpecies, this.savedStarterAttributes); + ui.setMode(UiMode.POKEDEX_PAGE, evoSpecies, this.savedStarterAttributes); return true; }, onHover: () => this.showText(conditionText), @@ -1676,7 +1676,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.moveInfoOverlay.clear(); this.clearText(); ui.setMode( - Mode.POKEDEX_PAGE, + UiMode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes, this.filteredIndices, @@ -1694,13 +1694,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, onHover: () => this.moveInfoOverlay.clear(), }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, @@ -1719,7 +1719,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { error = true; } else { this.toggleStatsMode(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); success = true; } break; @@ -1729,10 +1729,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { error = true; } else { this.blockInput = true; - ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { + ui.setMode(UiMode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showNature"), null, () => { const natures = globalScene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: natures .map((n: Nature, _i: number) => { const option: OptionSelectItem = { @@ -1747,7 +1747,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { label: i18next.t("menu:cancel"), handler: () => { this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); this.blockInput = false; return true; }, @@ -1897,7 +1897,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { }); this.setSpeciesDetails(this.species); globalScene.playSound("se/buy"); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; } @@ -1927,7 +1927,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return globalScene.reset(true); } }); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); globalScene.playSound("se/buy"); return true; @@ -1976,7 +1976,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return globalScene.reset(true); } }); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); globalScene.playSound("se/buy"); return true; @@ -1990,11 +1990,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { options.push({ label: i18next.t("menu:cancel"), handler: () => { - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + ui.setMode(UiMode.POKEDEX_PAGE, "refresh"); return true; }, }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, yOffset: 47, }); @@ -2032,7 +2032,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return true; } this.blockInput = true; - ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => { + ui.setModeWithoutClear(UiMode.OPTION_SELECT).then(() => { // Always go back to first selection after scrolling around if (this.previousSpecies.length === 0) { this.previousSpecies.push(this.species); @@ -2057,7 +2057,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.moveInfoOverlay.clear(); this.clearText(); ui.setModeForceTransition( - Mode.POKEDEX_PAGE, + UiMode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes, this.filteredIndices, @@ -2071,7 +2071,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.blockInput = false; return true; } - ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => { + ui.setModeWithoutClear(UiMode.OPTION_SELECT).then(() => { // Always go back to first selection after scrolling around if (this.previousSpecies.length === 0) { this.previousSpecies.push(this.species); @@ -2096,7 +2096,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.moveInfoOverlay.clear(); this.clearText(); ui.setModeForceTransition( - Mode.POKEDEX_PAGE, + UiMode.POKEDEX_PAGE, newSpecies, this.savedStarterAttributes, this.filteredIndices, diff --git a/src/ui/pokedex-scan-ui-handler.ts b/src/ui/pokedex-scan-ui-handler.ts index 171040f6f12..45092d461a3 100644 --- a/src/ui/pokedex-scan-ui-handler.ts +++ b/src/ui/pokedex-scan-ui-handler.ts @@ -3,8 +3,8 @@ import { FormModalUiHandler } from "./form-modal-ui-handler"; import type { ModalConfig } from "./modal-ui-handler"; import type { PlayerPokemon } from "#app/field/pokemon"; import type { OptionSelectItem } from "./abstact-option-select-ui-handler"; -import { isNullOrUndefined } from "#app/utils"; -import { Mode } from "./ui"; +import { isNullOrUndefined } from "#app/utils/common"; +import { UiMode } from "#enums/ui-mode"; import { FilterTextRow } from "./filter-text"; import { allAbilities } from "#app/data/data-lists"; import { allMoves } from "#app/data/moves/move"; @@ -115,7 +115,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { input.on("keydown", (inputObject, evt: KeyboardEvent) => { if ( ["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && - ui.getMode() === Mode.AUTO_COMPLETE + ui.getMode() === UiMode.AUTO_COMPLETE ) { // Delete autocomplete list and recovery focus. inputObject.on("blur", () => inputObject.node.focus(), { once: true }); @@ -125,7 +125,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { input.on("textchange", (inputObject, evt: InputEvent) => { // Delete autocomplete. - if (ui.getMode() === Mode.AUTO_COMPLETE) { + if (ui.getMode() === UiMode.AUTO_COMPLETE) { ui.revertMode(); } @@ -154,7 +154,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { maxOptions: 5, modalContainer: this.modalContainer, }; - ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOpts); + ui.setOverlayMode(UiMode.AUTO_COMPLETE, modalOpts); } }); @@ -168,7 +168,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { this.inputs[0].text = args[1]; } this.submitAction = _ => { - if (ui.getMode() === Mode.POKEDEX_SCAN) { + if (ui.getMode() === UiMode.POKEDEX_SCAN) { this.sanitizeInputs(); const outputName = this.reducedKeys.includes(this.inputs[0].text) ? this.inputs[0].text : ""; const sanitizedName = btoa(unescape(encodeURIComponent(outputName))); diff --git a/src/ui/pokedex-ui-handler.ts b/src/ui/pokedex-ui-handler.ts index 5fd3ca3e379..e9726031bf5 100644 --- a/src/ui/pokedex-ui-handler.ts +++ b/src/ui/pokedex-ui-handler.ts @@ -2,7 +2,7 @@ import type { Variant } from "#app/sprites/variant"; import { getVariantTint, getVariantIcon } from "#app/sprites/variant"; import { argbFromRgba } from "@material/material-color-utilities"; import i18next from "i18next"; -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves"; import type { PokemonForm } from "#app/data/pokemon-species"; @@ -16,7 +16,7 @@ import { AbilityAttr, DexAttr, loadStarterPreferences } from "#app/system/game-d import MessageUiHandler from "#app/ui/message-ui-handler"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "#app/ui/pokemon-icon-anim-handler"; import { TextStyle, addTextObject } from "#app/ui/text"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import { Passive as PassiveAttr } from "#enums/passive"; import type { Species } from "#enums/species"; @@ -31,7 +31,7 @@ import { getValueReductionCandyCounts, getSameSpeciesEggCandyCounts, } from "#app/data/balance/starters"; -import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#app/utils"; +import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#app/utils/common"; import type { Nature } from "#enums/nature"; import { addWindow } from "./ui-theme"; import type { OptionSelectConfig } from "./abstact-option-select-ui-handler"; @@ -231,7 +231,7 @@ export default class PokedexUiHandler extends MessageUiHandler { private filteredIndices: Species[]; constructor() { - super(Mode.POKEDEX); + super(UiMode.POKEDEX); } setup() { @@ -1133,7 +1133,7 @@ export default class PokedexUiHandler extends MessageUiHandler { } else if (this.showingTray) { if (button === Button.ACTION) { const formIndex = this.trayForms[this.trayCursor].formIndex; - ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, { form: formIndex }, this.filteredIndices); + ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, { form: formIndex }, this.filteredIndices); success = true; } else { const numberOfForms = this.trayContainers.length; @@ -1182,7 +1182,7 @@ export default class PokedexUiHandler extends MessageUiHandler { } } else { if (button === Button.ACTION) { - ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, null, this.filteredIndices); + ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, null, this.filteredIndices); success = true; } else { switch (button) { @@ -2268,15 +2268,15 @@ export default class PokedexUiHandler extends MessageUiHandler { const ui = this.getUi(); const cancel = () => { - ui.setMode(Mode.POKEDEX, "refresh"); + ui.setMode(UiMode.POKEDEX, "refresh"); this.clearText(); this.blockInput = false; }; ui.showText(i18next.t("pokedexUiHandler:confirmExit"), null, () => { ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { - ui.setMode(Mode.POKEDEX, "refresh"); + ui.setMode(UiMode.POKEDEX, "refresh"); this.clearText(); this.clear(); ui.revertMode(); diff --git a/src/ui/pokemon-hatch-info-container.ts b/src/ui/pokemon-hatch-info-container.ts index 692f0f1d374..f3095cb48bf 100644 --- a/src/ui/pokemon-hatch-info-container.ts +++ b/src/ui/pokemon-hatch-info-container.ts @@ -1,13 +1,13 @@ import PokemonInfoContainer from "#app/ui/pokemon-info-container"; import { Gender } from "#app/data/gender"; import { PokemonType } from "#enums/pokemon-type"; -import { rgbHexToRgba, padInt } from "#app/utils"; +import { rgbHexToRgba, padInt } from "#app/utils/common"; import { TextStyle, addTextObject } from "#app/ui/text"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { allMoves } from "#app/data/moves/move"; import { Species } from "#enums/species"; import { getEggTierForSpecies } from "#app/data/egg"; -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { globalScene } from "#app/global-scene"; import { argbFromRgba } from "@material/material-color-utilities"; import type { EggHatchData } from "#app/data/egg-hatch-data"; diff --git a/src/ui/pokemon-icon-anim-handler.ts b/src/ui/pokemon-icon-anim-handler.ts index b6944c0fd84..253ccbe3623 100644 --- a/src/ui/pokemon-icon-anim-handler.ts +++ b/src/ui/pokemon-icon-anim-handler.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; export enum PokemonIconAnimMode { NONE, diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 0ccece46ab9..18b5d2384ef 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -8,7 +8,7 @@ import type Pokemon from "../field/pokemon"; import i18next from "i18next"; import type { DexEntry, StarterDataEntry } from "../system/game-data"; import { DexAttr } from "../system/game-data"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import ConfirmUiHandler from "./confirm-ui-handler"; import { StatsContainer } from "./stats-container"; import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text"; diff --git a/src/ui/registration-form-ui-handler.ts b/src/ui/registration-form-ui-handler.ts index 74669bc1f44..bb10efc5869 100644 --- a/src/ui/registration-form-ui-handler.ts +++ b/src/ui/registration-form-ui-handler.ts @@ -1,7 +1,7 @@ import type { InputFieldConfig } from "./form-modal-ui-handler"; import { FormModalUiHandler } from "./form-modal-ui-handler"; import type { ModalConfig } from "./modal-ui-handler"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { TextStyle, addTextObject } from "./text"; import i18next from "i18next"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; @@ -101,9 +101,9 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler { // Prevent overlapping overrides on action modification this.submitAction = originalRegistrationAction; this.sanitizeInputs(); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + globalScene.ui.setMode(UiMode.LOADING, { buttonActions: [] }); const onFail = error => { - globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() })); + globalScene.ui.setMode(UiMode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); const errorMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.errorMessageFontSize; if (errorMessageFontSize) { diff --git a/src/ui/run-history-ui-handler.ts b/src/ui/run-history-ui-handler.ts index 16aad7b8634..92c5a2fde07 100644 --- a/src/ui/run-history-ui-handler.ts +++ b/src/ui/run-history-ui-handler.ts @@ -1,9 +1,9 @@ import { globalScene } from "#app/global-scene"; import { GameModes } from "../game-mode"; import { TextStyle, addTextObject } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { addWindow } from "./ui-theme"; -import { fixedInt, formatLargeNumber } from "#app/utils"; +import { fixedInt, formatLargeNumber } from "#app/utils/common"; import type PokemonData from "../system/pokemon-data"; import MessageUiHandler from "./message-ui-handler"; import i18next from "i18next"; @@ -40,7 +40,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { private runContainerInitialY: number; constructor() { - super(Mode.RUN_HISTORY); + super(UiMode.RUN_HISTORY); } override setup() { @@ -110,7 +110,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { if (button === Button.ACTION) { const cursor = this.cursor + this.scrollCursor; if (this.runs[cursor]) { - globalScene.ui.setOverlayMode(Mode.RUN_INFO, this.runs[cursor].entryData, RunDisplayMode.RUN_HISTORY, true); + globalScene.ui.setOverlayMode(UiMode.RUN_INFO, this.runs[cursor].entryData, RunDisplayMode.RUN_HISTORY, true); } else { return false; } diff --git a/src/ui/run-info-ui-handler.ts b/src/ui/run-info-ui-handler.ts index 60667035147..8487533f465 100644 --- a/src/ui/run-info-ui-handler.ts +++ b/src/ui/run-info-ui-handler.ts @@ -2,10 +2,10 @@ import { GameModes } from "../game-mode"; import UiHandler from "./ui-handler"; import type { SessionSaveData } from "../system/game-data"; import { TextStyle, addTextObject, addBBCodeTextObject, getTextColor } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { addWindow } from "./ui-theme"; import { getPokeballAtlasKey } from "#app/data/pokeball"; -import { formatLargeNumber, getPlayTimeString, formatMoney, formatFancyLargeNumber } from "#app/utils"; +import { formatLargeNumber, getPlayTimeString, formatMoney, formatFancyLargeNumber } from "#app/utils/common"; import type PokemonData from "../system/pokemon-data"; import i18next from "i18next"; import { Button } from "../enums/buttons"; @@ -69,7 +69,7 @@ export default class RunInfoUiHandler extends UiHandler { private modifiersModule: any; constructor() { - super(Mode.RUN_INFO); + super(UiMode.RUN_INFO); } override async setup() { diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 0c16e41bbef..7b4d46203c9 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -6,10 +6,10 @@ import { GameMode } from "../game-mode"; import * as Modifier from "#app/modifier/modifier"; import type { SessionSaveData } from "../system/game-data"; import type PokemonData from "../system/pokemon-data"; -import { isNullOrUndefined, fixedInt, getPlayTimeString, formatLargeNumber } from "#app/utils"; +import { isNullOrUndefined, fixedInt, getPlayTimeString, formatLargeNumber } from "#app/utils/common"; import MessageUiHandler from "./message-ui-handler"; import { TextStyle, addTextObject } from "./text"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import { addWindow } from "./ui-theme"; import { RunDisplayMode } from "#app/ui/run-info-ui-handler"; @@ -40,7 +40,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { private sessionSlotsContainerInitialY: number; constructor() { - super(Mode.SAVE_SLOT); + super(UiMode.SAVE_SLOT); } setup() { @@ -122,13 +122,13 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { this.saveSlotSelectCallback = null; ui.revertMode(); ui.showText("", 0); - ui.setMode(Mode.MESSAGE); + ui.setMode(UiMode.MESSAGE); originalCallback?.(cursor); }; if (this.sessionSlots[cursor].hasData) { ui.showText(i18next.t("saveSlotSelectUiHandler:overwriteData"), null, () => { ui.setOverlayMode( - Mode.CONFIRM, + UiMode.CONFIRM, () => { globalScene.gameData.deleteSession(cursor).then(response => { if (response === false) { @@ -198,7 +198,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { case Button.RIGHT: if (this.sessionSlots[cursorPosition].hasData && this.sessionSlots[cursorPosition].saveData) { globalScene.ui.setOverlayMode( - Mode.RUN_INFO, + UiMode.RUN_INFO, this.sessionSlots[cursorPosition].saveData, RunDisplayMode.SESSION_PREVIEW, ); diff --git a/src/ui/saving-icon-handler.ts b/src/ui/saving-icon-handler.ts index 3db84f128a1..3b7db549a4a 100644 --- a/src/ui/saving-icon-handler.ts +++ b/src/ui/saving-icon-handler.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; export default class SavingIconHandler extends Phaser.GameObjects.Container { private icon: Phaser.GameObjects.Sprite; diff --git a/src/ui/session-reload-modal-ui-handler.ts b/src/ui/session-reload-modal-ui-handler.ts index d3b88da9e63..f866783afe8 100644 --- a/src/ui/session-reload-modal-ui-handler.ts +++ b/src/ui/session-reload-modal-ui-handler.ts @@ -1,10 +1,10 @@ import type { ModalConfig } from "./modal-ui-handler"; import { ModalUiHandler } from "./modal-ui-handler"; import { addTextObject, TextStyle } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; export default class SessionReloadModalUiHandler extends ModalUiHandler { - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } diff --git a/src/ui/settings/abstract-binding-ui-handler.ts b/src/ui/settings/abstract-binding-ui-handler.ts index 62f78da89f5..a4707418b7c 100644 --- a/src/ui/settings/abstract-binding-ui-handler.ts +++ b/src/ui/settings/abstract-binding-ui-handler.ts @@ -1,5 +1,5 @@ import UiHandler from "../ui-handler"; -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import { addWindow } from "../ui-theme"; import { addTextObject, TextStyle } from "../text"; import { Button } from "#enums/buttons"; @@ -51,7 +51,7 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { * * @param mode - The UI mode. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); } diff --git a/src/ui/settings/abstract-control-settings-ui-handler.ts b/src/ui/settings/abstract-control-settings-ui-handler.ts index 2c634e2c5bf..495a0f68540 100644 --- a/src/ui/settings/abstract-control-settings-ui-handler.ts +++ b/src/ui/settings/abstract-control-settings-ui-handler.ts @@ -1,5 +1,5 @@ import UiHandler from "#app/ui/ui-handler"; -import type { Mode } from "#app/ui/ui"; +import type { UiMode } from "#enums/ui-mode"; import type { InterfaceConfig } from "#app/inputs-controller"; import { addWindow } from "#app/ui/ui-theme"; import { addTextObject, TextStyle } from "#app/ui/text"; @@ -74,7 +74,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler * * @param mode - The UI mode. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.rowsToDisplay = 8; } diff --git a/src/ui/settings/abstract-settings-ui-handler.ts b/src/ui/settings/abstract-settings-ui-handler.ts index 0c14b91251e..27ca95c25ac 100644 --- a/src/ui/settings/abstract-settings-ui-handler.ts +++ b/src/ui/settings/abstract-settings-ui-handler.ts @@ -1,5 +1,5 @@ import { TextStyle, addTextObject } from "#app/ui/text"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import MessageUiHandler from "#app/ui/message-ui-handler"; import { addWindow } from "#app/ui/ui-theme"; import { ScrollBar } from "#app/ui/scroll-bar"; @@ -42,7 +42,7 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { protected settings: Array; protected localStorageKey: string; - constructor(type: SettingType, mode: Mode | null = null) { + constructor(type: SettingType, mode: UiMode | null = null) { super(mode); this.settings = Setting.filter(s => s.type === type && !s?.isHidden?.()); this.reloadRequired = false; @@ -425,7 +425,7 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { const confirmationMessage = setting.options[cursor].confirmationMessage ?? i18next.t("settings:defaultConfirmMessage"); globalScene.ui.showText(confirmationMessage, null, () => { - globalScene.ui.setOverlayMode(Mode.CONFIRM, confirmUpdateSetting, cancelUpdateSetting, null, null, 1, 750); + globalScene.ui.setOverlayMode(UiMode.CONFIRM, confirmUpdateSetting, cancelUpdateSetting, null, null, 1, 750); }); } else { saveSetting(); diff --git a/src/ui/settings/gamepad-binding-ui-handler.ts b/src/ui/settings/gamepad-binding-ui-handler.ts index 62bc2db7825..0f226ddcafa 100644 --- a/src/ui/settings/gamepad-binding-ui-handler.ts +++ b/src/ui/settings/gamepad-binding-ui-handler.ts @@ -1,12 +1,12 @@ import AbstractBindingUiHandler from "./abstract-binding-ui-handler"; -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import { Device } from "#enums/devices"; import { getIconWithSettingName, getKeyWithKeycode } from "#app/configs/inputs/configHandler"; import { addTextObject, TextStyle } from "#app/ui/text"; import { globalScene } from "#app/global-scene"; export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); globalScene.input.gamepad?.on("down", this.gamepadButtonDown, this); } diff --git a/src/ui/settings/keyboard-binding-ui-handler.ts b/src/ui/settings/keyboard-binding-ui-handler.ts index 8735faeaaab..c05a31ca91e 100644 --- a/src/ui/settings/keyboard-binding-ui-handler.ts +++ b/src/ui/settings/keyboard-binding-ui-handler.ts @@ -1,12 +1,12 @@ import AbstractBindingUiHandler from "./abstract-binding-ui-handler"; -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import { getKeyWithKeycode } from "#app/configs/inputs/configHandler"; import { Device } from "#enums/devices"; import { addTextObject, TextStyle } from "#app/ui/text"; import { globalScene } from "#app/global-scene"; export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler { - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); // Listen to gamepad button down events to initiate binding. globalScene.input.keyboard?.on("keydown", this.onKeyDown, this); diff --git a/src/ui/settings/navigationMenu.ts b/src/ui/settings/navigationMenu.ts index 1d2d71e1e20..ad3d4ccf0b5 100644 --- a/src/ui/settings/navigationMenu.ts +++ b/src/ui/settings/navigationMenu.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type { InputsIcons } from "#app/ui/settings/abstract-control-settings-ui-handler"; import { addTextObject, setTextStyle, TextStyle } from "#app/ui/text"; import { addWindow } from "#app/ui/ui-theme"; @@ -14,8 +14,8 @@ const RIGHT = "RIGHT"; */ export class NavigationManager { private static instance: NavigationManager; - public modes: Mode[]; - public selectedMode: Mode = Mode.SETTINGS; + public modes: UiMode[]; + public selectedMode: UiMode = UiMode.SETTINGS; public navigationMenus: NavigationMenu[] = new Array(); public labels: string[]; @@ -27,11 +27,11 @@ export class NavigationManager { */ constructor() { this.modes = [ - Mode.SETTINGS, - Mode.SETTINGS_DISPLAY, - Mode.SETTINGS_AUDIO, - Mode.SETTINGS_GAMEPAD, - Mode.SETTINGS_KEYBOARD, + UiMode.SETTINGS, + UiMode.SETTINGS_DISPLAY, + UiMode.SETTINGS_AUDIO, + UiMode.SETTINGS_GAMEPAD, + UiMode.SETTINGS_KEYBOARD, ]; this.labels = [ i18next.t("settings:general"), @@ -43,7 +43,7 @@ export class NavigationManager { } public reset() { - this.selectedMode = Mode.SETTINGS; + this.selectedMode = UiMode.SETTINGS; this.updateNavigationMenus(); } diff --git a/src/ui/settings/option-select-ui-handler.ts b/src/ui/settings/option-select-ui-handler.ts index b3d1735dc19..af9760814ac 100644 --- a/src/ui/settings/option-select-ui-handler.ts +++ b/src/ui/settings/option-select-ui-handler.ts @@ -1,8 +1,8 @@ import AbstractOptionSelectUiHandler from "../abstact-option-select-ui-handler"; -import { Mode } from "../ui"; +import { UiMode } from "#enums/ui-mode"; export default class OptionSelectUiHandler extends AbstractOptionSelectUiHandler { - constructor(mode: Mode = Mode.OPTION_SELECT) { + constructor(mode: UiMode = UiMode.OPTION_SELECT) { super(mode); } diff --git a/src/ui/settings/settings-audio-ui-handler.ts b/src/ui/settings/settings-audio-ui-handler.ts index f8cb4da4ba2..019d66d7428 100644 --- a/src/ui/settings/settings-audio-ui-handler.ts +++ b/src/ui/settings/settings-audio-ui-handler.ts @@ -1,4 +1,4 @@ -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import AbstractSettingsUiHandler from "./abstract-settings-ui-handler"; import { SettingType } from "#app/system/settings/settings"; ("#app/inputs-controller"); @@ -9,7 +9,7 @@ export default class SettingsAudioUiHandler extends AbstractSettingsUiHandler { * * @param mode - The UI mode, optional. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(SettingType.AUDIO, mode); this.title = "Audio"; this.localStorageKey = "settings"; diff --git a/src/ui/settings/settings-display-ui-handler.ts b/src/ui/settings/settings-display-ui-handler.ts index 985aa9adca2..4878bae72cb 100644 --- a/src/ui/settings/settings-display-ui-handler.ts +++ b/src/ui/settings/settings-display-ui-handler.ts @@ -1,4 +1,4 @@ -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import AbstractSettingsUiHandler from "./abstract-settings-ui-handler"; import { SettingKeys, SettingType } from "#app/system/settings/settings"; ("#app/inputs-controller"); @@ -9,7 +9,7 @@ export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler * * @param mode - The UI mode, optional. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(SettingType.DISPLAY, mode); this.title = "Display"; diff --git a/src/ui/settings/settings-gamepad-ui-handler.ts b/src/ui/settings/settings-gamepad-ui-handler.ts index 0b3a7241ff2..7d269deab14 100644 --- a/src/ui/settings/settings-gamepad-ui-handler.ts +++ b/src/ui/settings/settings-gamepad-ui-handler.ts @@ -1,5 +1,5 @@ import { addTextObject, TextStyle } from "../text"; -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import { setSettingGamepad, SettingGamepad, @@ -13,7 +13,7 @@ import pad_unlicensedSNES from "#app/configs/inputs/pad_unlicensedSNES"; import type { InterfaceConfig } from "#app/inputs-controller"; import AbstractControlSettingsUiHandler from "#app/ui/settings/abstract-control-settings-ui-handler"; import { Device } from "#enums/devices"; -import { truncateString } from "#app/utils"; +import { truncateString } from "#app/utils/common"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; @@ -29,7 +29,7 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH * * @param mode - The UI mode, optional. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.titleSelected = "Gamepad"; this.setting = SettingGamepad; diff --git a/src/ui/settings/settings-keyboard-ui-handler.ts b/src/ui/settings/settings-keyboard-ui-handler.ts index a7837c8961e..c334ee8f1fc 100644 --- a/src/ui/settings/settings-keyboard-ui-handler.ts +++ b/src/ui/settings/settings-keyboard-ui-handler.ts @@ -1,4 +1,4 @@ -import { Mode } from "../ui"; +import { UiMode } from "#enums/ui-mode"; import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty"; import { setSettingKeyboard, @@ -7,7 +7,7 @@ import { settingKeyboardDefaults, settingKeyboardOptions, } from "#app/system/settings/settings-keyboard"; -import { reverseValueToKeySetting, truncateString } from "#app/utils"; +import { reverseValueToKeySetting, truncateString } from "#app/utils/common"; import AbstractControlSettingsUiHandler from "#app/ui/settings/abstract-control-settings-ui-handler"; import type { InterfaceConfig } from "#app/inputs-controller"; import { addTextObject, TextStyle } from "#app/ui/text"; @@ -28,7 +28,7 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi * * @param mode - The UI mode, optional. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.titleSelected = "Keyboard"; this.setting = SettingKeyboard; @@ -84,7 +84,7 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi * Handle the home key press event. */ onHomeDown(): void { - if (![Mode.SETTINGS_KEYBOARD, Mode.SETTINGS_GAMEPAD].includes(globalScene.ui.getMode())) { + if (![UiMode.SETTINGS_KEYBOARD, UiMode.SETTINGS_GAMEPAD].includes(globalScene.ui.getMode())) { return; } globalScene.gameData.resetMappingToFactory(); @@ -95,7 +95,7 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi * Handle the delete key press event. */ onDeleteDown(): void { - if (globalScene.ui.getMode() !== Mode.SETTINGS_KEYBOARD) { + if (globalScene.ui.getMode() !== UiMode.SETTINGS_KEYBOARD) { return; } const cursor = this.cursor + this.scrollCursor; // Calculate the absolute cursor position. diff --git a/src/ui/settings/settings-ui-handler.ts b/src/ui/settings/settings-ui-handler.ts index 22ea76d798b..8d61044ff91 100644 --- a/src/ui/settings/settings-ui-handler.ts +++ b/src/ui/settings/settings-ui-handler.ts @@ -1,5 +1,5 @@ import { SettingType } from "../../system/settings/settings"; -import type { Mode } from "../ui"; +import type { UiMode } from "#enums/ui-mode"; import AbstractSettingsUiHandler from "./abstract-settings-ui-handler"; export default class SettingsUiHandler extends AbstractSettingsUiHandler { @@ -8,7 +8,7 @@ export default class SettingsUiHandler extends AbstractSettingsUiHandler { * * @param mode - The UI mode, optional. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(SettingType.GENERAL, mode); this.title = "General"; this.localStorageKey = "settings"; diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 9b0009d666e..1902c691715 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -6,7 +6,7 @@ import { getVariantTint, getVariantIcon } from "#app/sprites/variant"; import { argbFromRgba } from "@material/material-color-utilities"; import i18next from "i18next"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { globalScene } from "#app/global-scene"; import type { Ability } from "#app/data/abilities/ability-class"; import { allAbilities } from "#app/data/data-lists"; @@ -37,7 +37,7 @@ import MessageUiHandler from "#app/ui/message-ui-handler"; import PokemonIconAnimHandler, { PokemonIconAnimMode } from "#app/ui/pokemon-icon-anim-handler"; import { StatsContainer } from "#app/ui/stats-container"; import { TextStyle, addBBCodeTextObject, addTextObject } from "#app/ui/text"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { addWindow } from "#app/ui/ui-theme"; import { Egg } from "#app/data/egg"; import Overrides from "#app/overrides"; @@ -74,7 +74,7 @@ import { randIntRange, rgbHexToRgba, toReadableString, -} from "#app/utils"; +} from "#app/utils/common"; import type { Nature } from "#enums/nature"; import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { achvs } from "#app/system/achv"; @@ -375,7 +375,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { protected blockInput = false; constructor() { - super(Mode.STARTER_SELECT); + super(UiMode.STARTER_SELECT); } setup() { @@ -1888,7 +1888,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { { label: i18next.t("starterSelectUiHandler:addToParty"), handler: () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); const isOverValueLimit = this.tryUpdateValue( globalScene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId), true, @@ -1921,7 +1921,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { label: i18next.t("starterSelectUiHandler:removeFromParty"), handler: () => { this.popStarter(removeIndex); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }, @@ -1934,7 +1934,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { label: i18next.t("starterSelectUiHandler:toggleIVs"), handler: () => { this.toggleStatsMode(); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }, @@ -1944,18 +1944,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const showSwapOptions = (moveset: StarterMoveset) => { this.blockInput = true; - ui.setMode(Mode.STARTER_SELECT).then(() => { + ui.setMode(UiMode.STARTER_SELECT).then(() => { ui.showText(i18next.t("starterSelectUiHandler:selectMoveSwapOut"), null, () => { this.moveInfoOverlay.show(allMoves[moveset[0]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: moveset .map((m: Moves, i: number) => { const option: OptionSelectItem = { label: allMoves[m].name, handler: () => { this.blockInput = true; - ui.setMode(Mode.STARTER_SELECT).then(() => { + ui.setMode(UiMode.STARTER_SELECT).then(() => { ui.showText( `${i18next.t("starterSelectUiHandler:selectMoveSwapWith")} ${allMoves[m].name}.`, null, @@ -1963,7 +1963,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const possibleMoves = this.speciesStarterMoves.filter((sm: Moves) => sm !== m); this.moveInfoOverlay.show(allMoves[possibleMoves[0]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: possibleMoves .map(sm => { // make an option for each available starter move @@ -2011,7 +2011,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { handler: () => { this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, onHover: () => { @@ -2039,10 +2039,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const showNatureOptions = () => { this.blockInput = true; - ui.setMode(Mode.STARTER_SELECT).then(() => { + ui.setMode(UiMode.STARTER_SELECT).then(() => { ui.showText(i18next.t("starterSelectUiHandler:selectNature"), null, () => { const natures = globalScene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: natures .map((n: Nature, _i: number) => { const option: OptionSelectItem = { @@ -2054,7 +2054,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } starterAttributes.nature = n; this.clearText(); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); // set nature for starter this.setSpeciesDetails(this.lastSpecies, { natureIndex: n, @@ -2069,7 +2069,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { label: i18next.t("menu:cancel"), handler: () => { this.clearText(); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); this.blockInput = false; return true; }, @@ -2097,7 +2097,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { label: i18next.t("starterSelectUiHandler:enablePassive"), handler: () => { starterData.passiveAttr |= PassiveAttr.ENABLED; - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies); return true; }, @@ -2107,7 +2107,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { label: i18next.t("starterSelectUiHandler:disablePassive"), handler: () => { starterData.passiveAttr ^= PassiveAttr.ENABLED; - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies); return true; }, @@ -2125,7 +2125,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (starterContainer) { starterContainer.favoriteIcon.setVisible(starterAttributes.favorite); } - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }); @@ -2138,7 +2138,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (starterContainer) { starterContainer.favoriteIcon.setVisible(starterAttributes.favorite); } - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }); @@ -2150,7 +2150,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { let nickname = starterAttributes.nickname ? String(starterAttributes.nickname) : ""; nickname = decodeURIComponent(escape(atob(nickname))); ui.setModeWithoutClear( - Mode.RENAME_POKEMON, + UiMode.RENAME_POKEMON, { buttonActions: [ (sanitizedName: string) => { @@ -2162,10 +2162,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } else { this.pokemonNameText.setText(this.lastSpecies.name); } - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); }, () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); }, ], }, @@ -2197,7 +2197,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return globalScene.reset(true); } }); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies); globalScene.playSound("se/buy"); @@ -2238,7 +2238,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } }); this.tryUpdateValue(0); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); globalScene.playSound("se/buy"); // update the value label and icon/animation for available upgrade @@ -2290,7 +2290,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return globalScene.reset(true); } }); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); globalScene.playSound("se/buy"); // update the icon/animation for available upgrade @@ -2308,11 +2308,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { options.push({ label: i18next.t("menu:cancel"), handler: () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, yOffset: 47, }); @@ -2320,14 +2320,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { options.push({ label: i18next.t("menuUiHandler:POKEDEX"), handler: () => { - ui.setMode(Mode.STARTER_SELECT).then(() => { + ui.setMode(UiMode.STARTER_SELECT).then(() => { const attributes = { shiny: starterAttributes.shiny, variant: starterAttributes.variant, form: starterAttributes.form, female: starterAttributes.female, }; - ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, attributes); + ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, attributes); }); return true; }, @@ -2336,7 +2336,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { options.push({ label: i18next.t("starterSelectUiHandler:useCandies"), handler: () => { - ui.setMode(Mode.STARTER_SELECT).then(() => showUseCandies()); + ui.setMode(UiMode.STARTER_SELECT).then(() => showUseCandies()); return true; }, }); @@ -2344,11 +2344,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { options.push({ label: i18next.t("menu:cancel"), handler: () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); return true; }, }); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { + ui.setModeWithoutClear(UiMode.OPTION_SELECT, { options: options, yOffset: 47, }); @@ -4281,15 +4281,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const ui = this.getUi(); const cancel = () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); this.clearText(); this.blockInput = false; }; ui.showText(i18next.t("starterSelectUiHandler:confirmExit"), null, () => { ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); globalScene.clearPhaseQueue(); if (globalScene.gameMode.isChallenge) { globalScene.pushPhase(new SelectChallengePhase()); @@ -4318,7 +4318,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const ui = this.getUi(); const cancel = () => { - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); if (!manualTrigger) { this.popStarter(this.starterSpecies.length - 1); } @@ -4330,11 +4330,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (canStart) { ui.showText(i18next.t("starterSelectUiHandler:confirmStartTeam"), null, () => { ui.setModeWithoutClear( - Mode.CONFIRM, + UiMode.CONFIRM, () => { const startRun = () => { globalScene.money = globalScene.gameMode.getStartingMoney(); - ui.setMode(Mode.STARTER_SELECT); + ui.setMode(UiMode.STARTER_SELECT); const thisObj = this; const originalStarterSelectCallback = this.starterSelectCallback; this.starterSelectCallback = null; diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 5ff4a02793d..877c342651f 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -1,6 +1,6 @@ -import { starterColors } from "#app/battle-scene"; +import { starterColors } from "#app/global-vars/starter-colors"; import { globalScene } from "#app/global-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "#app/ui/ui-handler"; import { getLocalizedSpriteKey, @@ -11,7 +11,7 @@ import { isNullOrUndefined, toReadableString, formatStat, -} from "#app/utils"; +} from "#app/utils/common"; import type { PlayerPokemon, PokemonMove } from "#app/field/pokemon"; import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; import { argbFromRgba } from "@material/material-color-utilities"; @@ -128,7 +128,7 @@ export default class SummaryUiHandler extends UiHandler { private selectCallback: Function | null; constructor() { - super(Mode.SUMMARY); + super(UiMode.SUMMARY); } setup() { @@ -510,7 +510,7 @@ export default class SummaryUiHandler extends UiHandler { } const ui = this.getUi(); - const fromPartyMode = ui.handlers[Mode.PARTY].active; + const fromPartyMode = ui.handlers[UiMode.PARTY].active; let success = false; let error = false; @@ -610,9 +610,9 @@ export default class SummaryUiHandler extends UiHandler { } if (!fromPartyMode) { - ui.setMode(Mode.MESSAGE); + ui.setMode(UiMode.MESSAGE); } else { - ui.setMode(Mode.PARTY); + ui.setMode(UiMode.PARTY); } } success = true; diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index a9f88b337f3..0db2020c25a 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -1,7 +1,7 @@ import { BattlerIndex } from "../battle"; -import { Mode } from "./ui"; +import { UiMode } from "#enums/ui-mode"; import UiHandler from "./ui-handler"; -import { isNullOrUndefined, fixedInt } from "#app/utils"; +import { isNullOrUndefined, fixedInt } from "#app/utils/common"; import { getMoveTargets } from "../data/moves/move"; import { Button } from "#enums/buttons"; import type { Moves } from "#enums/moves"; @@ -27,7 +27,7 @@ export default class TargetSelectUiHandler extends UiHandler { private targetBattleInfoMoveTween: Phaser.Tweens.Tween[] = []; constructor() { - super(Mode.TARGET_SELECT); + super(UiMode.TARGET_SELECT); this.cursor = -1; } diff --git a/src/ui/test-dialogue-ui-handler.ts b/src/ui/test-dialogue-ui-handler.ts index 9fbfc01a317..9ecf1641e7b 100644 --- a/src/ui/test-dialogue-ui-handler.ts +++ b/src/ui/test-dialogue-ui-handler.ts @@ -4,8 +4,8 @@ import type { ModalConfig } from "./modal-ui-handler"; import i18next from "i18next"; import type { PlayerPokemon } from "#app/field/pokemon"; import type { OptionSelectItem } from "./abstact-option-select-ui-handler"; -import { isNullOrUndefined } from "#app/utils"; -import { Mode } from "./ui"; +import { isNullOrUndefined } from "#app/utils/common"; +import { UiMode } from "#enums/ui-mode"; export default class TestDialogueUiHandler extends FormModalUiHandler { keys: string[]; @@ -88,7 +88,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { input.on("keydown", (inputObject, evt: KeyboardEvent) => { if ( ["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && - ui.getMode() === Mode.AUTO_COMPLETE + ui.getMode() === UiMode.AUTO_COMPLETE ) { // Delete autocomplete list and recovery focus. inputObject.on("blur", () => inputObject.node.focus(), { once: true }); @@ -98,7 +98,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { input.on("textchange", (inputObject, evt: InputEvent) => { // Delete autocomplete. - if (ui.getMode() === Mode.AUTO_COMPLETE) { + if (ui.getMode() === UiMode.AUTO_COMPLETE) { ui.revertMode(); } @@ -133,7 +133,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { maxOptions: 5, modalContainer: this.modalContainer, }; - ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOpts); + ui.setOverlayMode(UiMode.AUTO_COMPLETE, modalOpts); } }); @@ -147,7 +147,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { this.inputs[0].text = args[1]; } this.submitAction = _ => { - if (ui.getMode() === Mode.TEST_DIALOGUE) { + if (ui.getMode() === UiMode.TEST_DIALOGUE) { this.sanitizeInputs(); const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); config.buttonActions[0](sanitizedName); diff --git a/src/ui/time-of-day-widget.ts b/src/ui/time-of-day-widget.ts index 5e42e6215f8..5f5116a2da0 100644 --- a/src/ui/time-of-day-widget.ts +++ b/src/ui/time-of-day-widget.ts @@ -1,4 +1,4 @@ -import { fixedInt } from "#app/utils"; +import { fixedInt } from "#app/utils/common"; import { globalScene } from "#app/global-scene"; import { BattleSceneEventType } from "../events/battle-scene"; import { EaseType } from "#enums/ease-type"; diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index 405e3cc4a27..bed4d568481 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -1,6 +1,6 @@ import OptionSelectUiHandler from "./settings/option-select-ui-handler"; -import { Mode } from "./ui"; -import { fixedInt, randInt, randItem } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { fixedInt, randInt, randItem } from "#app/utils/common"; import { TextStyle, addTextObject } from "./text"; import { getSplashMessages } from "../data/splash-messages"; import i18next from "i18next"; @@ -26,7 +26,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { private titleStatsTimer: NodeJS.Timeout | null; - constructor(mode: Mode = Mode.TITLE) { + constructor(mode: UiMode = UiMode.TITLE) { super(mode); } diff --git a/src/ui/ui-handler.ts b/src/ui/ui-handler.ts index 433f85d0f92..d3784c1225c 100644 --- a/src/ui/ui-handler.ts +++ b/src/ui/ui-handler.ts @@ -1,7 +1,7 @@ import { globalScene } from "#app/global-scene"; import type { TextStyle } from "./text"; import { getTextColor } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import type { Button } from "#enums/buttons"; /** @@ -15,7 +15,7 @@ export default abstract class UiHandler { /** * @param mode The mode of the UI element. These should be unique. */ - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { this.mode = mode; } diff --git a/src/ui/ui.ts b/src/ui/ui.ts index c7981cd5fba..ad496df6382 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -28,7 +28,7 @@ import { addWindow } from "./ui-theme"; import LoginFormUiHandler from "./login-form-ui-handler"; import RegistrationFormUiHandler from "./registration-form-ui-handler"; import LoadingModalUiHandler from "./loading-modal-ui-handler"; -import { executeIf } from "#app/utils"; +import { executeIf } from "#app/utils/common"; import GameStatsUiHandler from "./game-stats-ui-handler"; import AwaitableUiHandler from "./awaitable-ui-handler"; import SaveSlotSelectUiHandler from "./save-slot-select-ui-handler"; @@ -57,102 +57,55 @@ import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler"; import PokedexScanUiHandler from "./pokedex-scan-ui-handler"; import PokedexPageUiHandler from "./pokedex-page-ui-handler"; import { NavigationManager } from "./settings/navigationMenu"; - -export enum Mode { - MESSAGE, - TITLE, - COMMAND, - FIGHT, - BALL, - TARGET_SELECT, - MODIFIER_SELECT, - SAVE_SLOT, - PARTY, - SUMMARY, - STARTER_SELECT, - EVOLUTION_SCENE, - EGG_HATCH_SCENE, - EGG_HATCH_SUMMARY, - CONFIRM, - OPTION_SELECT, - MENU, - MENU_OPTION_SELECT, - SETTINGS, - SETTINGS_DISPLAY, - SETTINGS_AUDIO, - SETTINGS_GAMEPAD, - GAMEPAD_BINDING, - SETTINGS_KEYBOARD, - KEYBOARD_BINDING, - ACHIEVEMENTS, - GAME_STATS, - EGG_LIST, - EGG_GACHA, - POKEDEX, - POKEDEX_SCAN, - POKEDEX_PAGE, - LOGIN_FORM, - REGISTRATION_FORM, - LOADING, - SESSION_RELOAD, - UNAVAILABLE, - CHALLENGE_SELECT, - RENAME_POKEMON, - RUN_HISTORY, - RUN_INFO, - TEST_DIALOGUE, - AUTO_COMPLETE, - ADMIN, - MYSTERY_ENCOUNTER, -} +import { UiMode } from "#enums/ui-mode"; const transitionModes = [ - Mode.SAVE_SLOT, - Mode.PARTY, - Mode.SUMMARY, - Mode.STARTER_SELECT, - Mode.EVOLUTION_SCENE, - Mode.EGG_HATCH_SCENE, - Mode.EGG_LIST, - Mode.EGG_GACHA, - Mode.POKEDEX, - Mode.POKEDEX_PAGE, - Mode.CHALLENGE_SELECT, - Mode.RUN_HISTORY, + UiMode.SAVE_SLOT, + UiMode.PARTY, + UiMode.SUMMARY, + UiMode.STARTER_SELECT, + UiMode.EVOLUTION_SCENE, + UiMode.EGG_HATCH_SCENE, + UiMode.EGG_LIST, + UiMode.EGG_GACHA, + UiMode.POKEDEX, + UiMode.POKEDEX_PAGE, + UiMode.CHALLENGE_SELECT, + UiMode.RUN_HISTORY, ]; const noTransitionModes = [ - Mode.TITLE, - Mode.CONFIRM, - Mode.OPTION_SELECT, - Mode.MENU, - Mode.MENU_OPTION_SELECT, - Mode.GAMEPAD_BINDING, - Mode.KEYBOARD_BINDING, - Mode.SETTINGS, - Mode.SETTINGS_AUDIO, - Mode.SETTINGS_DISPLAY, - Mode.SETTINGS_GAMEPAD, - Mode.SETTINGS_KEYBOARD, - Mode.ACHIEVEMENTS, - Mode.GAME_STATS, - Mode.POKEDEX_SCAN, - Mode.LOGIN_FORM, - Mode.REGISTRATION_FORM, - Mode.LOADING, - Mode.SESSION_RELOAD, - Mode.UNAVAILABLE, - Mode.RENAME_POKEMON, - Mode.TEST_DIALOGUE, - Mode.AUTO_COMPLETE, - Mode.ADMIN, - Mode.MYSTERY_ENCOUNTER, - Mode.RUN_INFO, + UiMode.TITLE, + UiMode.CONFIRM, + UiMode.OPTION_SELECT, + UiMode.MENU, + UiMode.MENU_OPTION_SELECT, + UiMode.GAMEPAD_BINDING, + UiMode.KEYBOARD_BINDING, + UiMode.SETTINGS, + UiMode.SETTINGS_AUDIO, + UiMode.SETTINGS_DISPLAY, + UiMode.SETTINGS_GAMEPAD, + UiMode.SETTINGS_KEYBOARD, + UiMode.ACHIEVEMENTS, + UiMode.GAME_STATS, + UiMode.POKEDEX_SCAN, + UiMode.LOGIN_FORM, + UiMode.REGISTRATION_FORM, + UiMode.LOADING, + UiMode.SESSION_RELOAD, + UiMode.UNAVAILABLE, + UiMode.RENAME_POKEMON, + UiMode.TEST_DIALOGUE, + UiMode.AUTO_COMPLETE, + UiMode.ADMIN, + UiMode.MYSTERY_ENCOUNTER, + UiMode.RUN_INFO, ]; export default class UI extends Phaser.GameObjects.Container { - private mode: Mode; - private modeChain: Mode[]; + private mode: UiMode; + private modeChain: UiMode[]; public handlers: UiHandler[]; private overlay: Phaser.GameObjects.Rectangle; public achvBar: AchvBar; @@ -169,7 +122,7 @@ export default class UI extends Phaser.GameObjects.Container { constructor() { super(globalScene, 0, globalScene.game.canvas.height / 6); - this.mode = Mode.MESSAGE; + this.mode = UiMode.MESSAGE; this.modeChain = []; this.handlers = [ new BattleMessageUiHandler(), @@ -189,7 +142,7 @@ export default class UI extends Phaser.GameObjects.Container { new ConfirmUiHandler(), new OptionSelectUiHandler(), new MenuUiHandler(), - new OptionSelectUiHandler(Mode.MENU_OPTION_SELECT), + new OptionSelectUiHandler(UiMode.MENU_OPTION_SELECT), // settings new SettingsUiHandler(), new SettingsDisplayUiHandler(), @@ -203,7 +156,7 @@ export default class UI extends Phaser.GameObjects.Container { new EggListUiHandler(), new EggGachaUiHandler(), new PokedexUiHandler(), - new PokedexScanUiHandler(Mode.TEST_DIALOGUE), + new PokedexScanUiHandler(UiMode.TEST_DIALOGUE), new PokedexPageUiHandler(), new LoginFormUiHandler(), new RegistrationFormUiHandler(), @@ -214,7 +167,7 @@ export default class UI extends Phaser.GameObjects.Container { new RenameFormUiHandler(), new RunHistoryUiHandler(), new RunInfoUiHandler(), - new TestDialogueUiHandler(Mode.TEST_DIALOGUE), + new TestDialogueUiHandler(UiMode.TEST_DIALOGUE), new AutoCompleteUiHandler(), new AdminUiHandler(), new MysteryEncounterUiHandler(), @@ -222,7 +175,7 @@ export default class UI extends Phaser.GameObjects.Container { } setup(): void { - this.setName(`ui-${Mode[this.mode]}`); + this.setName(`ui-${UiMode[this.mode]}`); for (const handler of this.handlers) { handler.setup(); } @@ -279,7 +232,7 @@ export default class UI extends Phaser.GameObjects.Container { } getMessageHandler(): BattleMessageUiHandler { - return this.handlers[Mode.MESSAGE] as BattleMessageUiHandler; + return this.handlers[UiMode.MESSAGE] as BattleMessageUiHandler; } processInfoButton(pressed: boolean) { @@ -287,7 +240,7 @@ export default class UI extends Phaser.GameObjects.Container { return false; } - if ([Mode.CONFIRM, Mode.COMMAND, Mode.FIGHT, Mode.MESSAGE, Mode.TARGET_SELECT].includes(this.mode)) { + if ([UiMode.CONFIRM, UiMode.COMMAND, UiMode.FIGHT, UiMode.MESSAGE, UiMode.TARGET_SELECT].includes(this.mode)) { globalScene?.processInfoButton(pressed); return true; } @@ -564,7 +517,7 @@ export default class UI extends Phaser.GameObjects.Container { } private setModeInternal( - mode: Mode, + mode: UiMode, clear: boolean, forceTransition: boolean, chainMode: boolean, @@ -587,7 +540,7 @@ export default class UI extends Phaser.GameObjects.Container { this.mode = mode; const touchControls = document?.getElementById("touchControls"); if (touchControls) { - touchControls.dataset.uiMode = Mode[mode]; + touchControls.dataset.uiMode = UiMode[mode]; } this.getHandler().show(args); } @@ -612,23 +565,23 @@ export default class UI extends Phaser.GameObjects.Container { }); } - getMode(): Mode { + getMode(): UiMode { return this.mode; } - setMode(mode: Mode, ...args: any[]): Promise { + setMode(mode: UiMode, ...args: any[]): Promise { return this.setModeInternal(mode, true, false, false, args); } - setModeForceTransition(mode: Mode, ...args: any[]): Promise { + setModeForceTransition(mode: UiMode, ...args: any[]): Promise { return this.setModeInternal(mode, true, true, false, args); } - setModeWithoutClear(mode: Mode, ...args: any[]): Promise { + setModeWithoutClear(mode: UiMode, ...args: any[]): Promise { return this.setModeInternal(mode, false, false, false, args); } - setOverlayMode(mode: Mode, ...args: any[]): Promise { + setOverlayMode(mode: UiMode, ...args: any[]): Promise { return this.setModeInternal(mode, false, false, true, args); } @@ -651,7 +604,7 @@ export default class UI extends Phaser.GameObjects.Container { globalScene.updateGameInfo(); const touchControls = document.getElementById("touchControls"); if (touchControls) { - touchControls.dataset.uiMode = Mode[this.mode]; + touchControls.dataset.uiMode = UiMode[this.mode]; } resolve(true); }; @@ -678,7 +631,7 @@ export default class UI extends Phaser.GameObjects.Container { }); } - public getModeChain(): Mode[] { + public getModeChain(): UiMode[] { return this.modeChain; } diff --git a/src/ui/unavailable-modal-ui-handler.ts b/src/ui/unavailable-modal-ui-handler.ts index 01ed850f6d0..5bed55ec24a 100644 --- a/src/ui/unavailable-modal-ui-handler.ts +++ b/src/ui/unavailable-modal-ui-handler.ts @@ -1,9 +1,10 @@ import type { ModalConfig } from "./modal-ui-handler"; import { ModalUiHandler } from "./modal-ui-handler"; import { addTextObject, TextStyle } from "./text"; -import type { Mode } from "./ui"; +import type { UiMode } from "#enums/ui-mode"; import { updateUserInfo } from "#app/account"; -import { removeCookie, sessionIdKey } from "#app/utils"; +import { sessionIdKey } from "#app/utils/common"; +import { removeCookie } from "#app/utils/cookies"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; @@ -17,7 +18,7 @@ export default class UnavailableModalUiHandler extends ModalUiHandler { private readonly randVarianceTime = 1000 * 10; - constructor(mode: Mode | null = null) { + constructor(mode: UiMode | null = null) { super(mode); this.reconnectDuration = this.minTime; } diff --git a/src/utils.ts b/src/utils/common.ts similarity index 92% rename from src/utils.ts rename to src/utils/common.ts index ce9966c0d7f..4acfabce080 100644 --- a/src/utils.ts +++ b/src/utils/common.ts @@ -276,43 +276,6 @@ export const apiUrl = localServerUrl ?? "https://api.pokerogue.net"; // used to disable api calls when isLocal is true and a server is not found export let isLocalServerConnected = true; -export const isBeta = import.meta.env.MODE === "beta"; // this checks to see if the env mode is development. Technically this gives the same value for beta AND for dev envs - -export function setCookie(cName: string, cValue: string): void { - const expiration = new Date(); - expiration.setTime(new Date().getTime() + 3600000 * 24 * 30 * 3 /*7*/); - document.cookie = `${cName}=${cValue};Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=${expiration.toUTCString()}`; -} - -export function removeCookie(cName: string): void { - if (isBeta) { - document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=pokerogue.net;Path=/;Max-Age=-1`; // we need to remove the cookie from the main domain as well - } - - document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Max-Age=-1`; - document.cookie = `${cName}=;Secure;SameSite=Strict;Path=/;Max-Age=-1`; // legacy cookie without domain, for older cookies to prevent a login loop -} - -export function getCookie(cName: string): string { - // check if there are multiple cookies with the same name and delete them - if (document.cookie.split(";").filter(c => c.includes(cName)).length > 1) { - removeCookie(cName); - return ""; - } - const name = `${cName}=`; - const ca = document.cookie.split(";"); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) === " ") { - c = c.substring(1); - } - if (c.indexOf(name) === 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} - /** * When locally running the game, "pings" the local server * with a GET request to verify if a server is running, diff --git a/src/utils/cookies.ts b/src/utils/cookies.ts new file mode 100644 index 00000000000..5ed793c0451 --- /dev/null +++ b/src/utils/cookies.ts @@ -0,0 +1,36 @@ +import { isBeta } from "./utility-vars"; + +export function setCookie(cName: string, cValue: string): void { + const expiration = new Date(); + expiration.setTime(new Date().getTime() + 3600000 * 24 * 30 * 3 /*7*/); + document.cookie = `${cName}=${cValue};Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=${expiration.toUTCString()}`; +} + +export function removeCookie(cName: string): void { + if (isBeta) { + document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=pokerogue.net;Path=/;Max-Age=-1`; // we need to remove the cookie from the main domain as well + } + + document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Max-Age=-1`; + document.cookie = `${cName}=;Secure;SameSite=Strict;Path=/;Max-Age=-1`; // legacy cookie without domain, for older cookies to prevent a login loop +} + +export function getCookie(cName: string): string { + // check if there are multiple cookies with the same name and delete them + if (document.cookie.split(";").filter(c => c.includes(cName)).length > 1) { + removeCookie(cName); + return ""; + } + const name = `${cName}=`; + const ca = document.cookie.split(";"); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === " ") { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; +} diff --git a/src/utils/utility-vars.ts b/src/utils/utility-vars.ts new file mode 100644 index 00000000000..081f70164c8 --- /dev/null +++ b/src/utils/utility-vars.ts @@ -0,0 +1 @@ +export const isBeta = import.meta.env.MODE === "beta"; // this checks to see if the env mode is development. Technically this gives the same value for beta AND for dev envs diff --git a/test/abilities/ability_timing.test.ts b/test/abilities/ability_timing.test.ts index 9df4fe0d1c9..6128a3e6196 100644 --- a/test/abilities/ability_timing.test.ts +++ b/test/abilities/ability_timing.test.ts @@ -2,7 +2,7 @@ import { BattleStyle } from "#app/enums/battle-style"; import { CommandPhase } from "#app/phases/command-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; import i18next from "#app/plugins/i18n"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Abilities } from "#enums/abilities"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; @@ -40,9 +40,9 @@ describe("Ability Timing", () => { game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); game.endPhase(); }, () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(TurnInitPhase), diff --git a/test/abilities/analytic.test.ts b/test/abilities/analytic.test.ts index 1aadf2c0746..108c712da00 100644 --- a/test/abilities/analytic.test.ts +++ b/test/abilities/analytic.test.ts @@ -1,5 +1,5 @@ import { BattlerIndex } from "#app/battle"; -import { isBetween, toDmgValue } from "#app/utils"; +import { isBetween, toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/abilities/disguise.test.ts b/test/abilities/disguise.test.ts index fd8289312db..aeaf8ea2363 100644 --- a/test/abilities/disguise.test.ts +++ b/test/abilities/disguise.test.ts @@ -1,5 +1,5 @@ import { BattlerIndex } from "#app/battle"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/abilities/healer.test.ts b/test/abilities/healer.test.ts index d06c4680e36..d292ad0f625 100644 --- a/test/abilities/healer.test.ts +++ b/test/abilities/healer.test.ts @@ -5,7 +5,7 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest"; -import { isNullOrUndefined } from "#app/utils"; +import { isNullOrUndefined } from "#app/utils/common"; import { PostTurnResetStatusAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import type Pokemon from "#app/field/pokemon"; diff --git a/test/abilities/heatproof.test.ts b/test/abilities/heatproof.test.ts index f2fabf953d6..016237bb02f 100644 --- a/test/abilities/heatproof.test.ts +++ b/test/abilities/heatproof.test.ts @@ -1,7 +1,7 @@ import { Species } from "#app/enums/species"; import { StatusEffect } from "#app/enums/status-effect"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/abilities/intimidate.test.ts b/test/abilities/intimidate.test.ts index 2888c575b0d..8db39270dcf 100644 --- a/test/abilities/intimidate.test.ts +++ b/test/abilities/intimidate.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Stat } from "#enums/stat"; import { getMovePosition } from "#test/testUtils/gameManagerUtils"; import { Abilities } from "#enums/abilities"; @@ -38,9 +38,9 @@ describe("Abilities - Intimidate", () => { await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); game.endPhase(); }, () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase"), @@ -69,9 +69,9 @@ describe("Abilities - Intimidate", () => { await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); game.endPhase(); }, () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase"), diff --git a/test/abilities/parental_bond.test.ts b/test/abilities/parental_bond.test.ts index d81486e7316..a75fea82830 100644 --- a/test/abilities/parental_bond.test.ts +++ b/test/abilities/parental_bond.test.ts @@ -1,6 +1,6 @@ import { PokemonType } from "#enums/pokemon-type"; import { BattlerTagType } from "#enums/battler-tag-type"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/abilities/shield_dust.test.ts b/test/abilities/shield_dust.test.ts index 4f6783eb66a..0b96640a29f 100644 --- a/test/abilities/shield_dust.test.ts +++ b/test/abilities/shield_dust.test.ts @@ -6,7 +6,7 @@ import { MoveEffectChanceMultiplierAbAttr, } from "#app/data/abilities/ability"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/abilities/stakeout.test.ts b/test/abilities/stakeout.test.ts index b3a7bdbf287..8a2231bba0b 100644 --- a/test/abilities/stakeout.test.ts +++ b/test/abilities/stakeout.test.ts @@ -1,5 +1,5 @@ import { BattlerIndex } from "#app/battle"; -import { isBetween } from "#app/utils"; +import { isBetween } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/abilities/wimp_out.test.ts b/test/abilities/wimp_out.test.ts index c46675376c1..463ec7587dc 100644 --- a/test/abilities/wimp_out.test.ts +++ b/test/abilities/wimp_out.test.ts @@ -2,7 +2,7 @@ import { BattlerIndex } from "#app/battle"; import { ArenaTagSide } from "#app/data/arena-tag"; import { allMoves } from "#app/data/moves/move"; import GameManager from "#test/testUtils/gameManager"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; diff --git a/test/account.test.ts b/test/account.test.ts index 3f6b9f3f80b..77368b0b64c 100644 --- a/test/account.test.ts +++ b/test/account.test.ts @@ -1,4 +1,4 @@ -import * as battleScene from "#app/battle-scene"; +import * as bypassLogin from "#app/global-vars/bypass-login"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { describe, expect, it, vi } from "vitest"; import { initLoggedInUser, loggedInUser, updateUserInfo } from "#app/account"; @@ -15,7 +15,7 @@ describe("account", () => { describe("updateUserInfo", () => { it("should set loggedInUser! to Guest if bypassLogin is true", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(true); const [success, status] = await updateUserInfo(); @@ -26,7 +26,7 @@ describe("account", () => { }); it("should fetch user info from the API if bypassLogin is false", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([ { username: "test", @@ -47,7 +47,7 @@ describe("account", () => { }); it("should handle resolved API errors", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 401]); const [success, status] = await updateUserInfo(); @@ -57,7 +57,7 @@ describe("account", () => { }); it("should handle 500 API errors", async () => { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLogin, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 500]); const [success, status] = await updateUserInfo(); diff --git a/test/achievements/achievement.test.ts b/test/achievements/achievement.test.ts index 5c53e38e208..0b49c4d23ab 100644 --- a/test/achievements/achievement.test.ts +++ b/test/achievements/achievement.test.ts @@ -10,7 +10,7 @@ import { RibbonAchv, achvs, } from "#app/system/achv"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/test/battle/battle.test.ts b/test/battle/battle.test.ts index 51304c7d5dd..e980984580e 100644 --- a/test/battle/battle.test.ts +++ b/test/battle/battle.test.ts @@ -18,7 +18,7 @@ import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { VictoryPhase } from "#app/phases/victory-phase"; import GameManager from "#test/testUtils/gameManager"; import { generateStarter } from "#test/testUtils/gameManagerUtils"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { PlayerGender } from "#enums/player-gender"; @@ -49,7 +49,7 @@ describe("Test Battle Phase", () => { it("test phase interceptor with prompt", async () => { await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; game.endPhase(); }); @@ -57,36 +57,36 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(SelectGenderPhase); await game.phaseInterceptor.run(TitlePhase); - await game.waitMode(Mode.TITLE); + await game.waitMode(UiMode.TITLE); - expect(game.scene.ui?.getMode()).toBe(Mode.TITLE); + expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); it("test phase interceptor with prompt with preparation for a future prompt", async () => { await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; game.endPhase(); }); - game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); + game.onNextPrompt("CheckSwitchPhase", UiMode.CONFIRM, () => { + game.setMode(UiMode.MESSAGE); game.endPhase(); }); await game.phaseInterceptor.run(SelectGenderPhase); await game.phaseInterceptor.run(TitlePhase); - await game.waitMode(Mode.TITLE); + await game.waitMode(UiMode.TITLE); - expect(game.scene.ui?.getMode()).toBe(Mode.TITLE); + expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); it("newGame one-liner", async () => { await game.startBattle(); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -156,7 +156,7 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt( "SelectGenderPhase", - Mode.OPTION_SELECT, + UiMode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; game.endPhase(); @@ -171,7 +171,7 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt( "SelectGenderPhase", - Mode.OPTION_SELECT, + UiMode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; game.endPhase(); @@ -185,14 +185,14 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(LoginPhase); game.onNextPrompt( "SelectGenderPhase", - Mode.OPTION_SELECT, + UiMode.OPTION_SELECT, () => { game.scene.gameData.gender = PlayerGender.MALE; game.endPhase(); }, () => game.isCurrentPhase(TitlePhase), ); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { game.scene.gameMode = getGameMode(GameModes.CLASSIC); const starters = generateStarter(game.scene); const selectStarterPhase = new SelectStarterPhase(); @@ -208,7 +208,7 @@ describe("Test Battle Phase", () => { game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -218,7 +218,7 @@ describe("Test Battle Phase", () => { game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); await game.startBattle([Species.BLASTOISE]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -229,7 +229,7 @@ describe("Test Battle Phase", () => { game.override.ability(Abilities.HYDRATION); game.override.startingWave(3); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -240,7 +240,7 @@ describe("Test Battle Phase", () => { game.override.ability(Abilities.HYDRATION); game.override.startingWave(3); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -328,7 +328,7 @@ describe("Test Battle Phase", () => { game.onNextPrompt( "SwitchPhase", - Mode.PARTY, + UiMode.PARTY, () => { expect.fail("Switch was forced"); }, diff --git a/test/battle/special_battle.test.ts b/test/battle/special_battle.test.ts index 46dd8eaa010..163f23e488d 100644 --- a/test/battle/special_battle.test.ts +++ b/test/battle/special_battle.test.ts @@ -1,5 +1,5 @@ import { CommandPhase } from "#app/phases/command-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; @@ -34,63 +34,63 @@ describe("Test Battle Phase", () => { it("startBattle 2vs1 boss", async () => { game.override.battleStyle("single").startingWave(10); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs2 boss", async () => { game.override.battleStyle("double").startingWave(10); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs2 trainer", async () => { game.override.battleStyle("double").startingWave(5); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs1 trainer", async () => { game.override.battleStyle("single").startingWave(5); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs1 rival", async () => { game.override.battleStyle("single").startingWave(8); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs2 rival", async () => { game.override.battleStyle("double").startingWave(8); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 1vs1 trainer", async () => { game.override.battleStyle("single").startingWave(5); await game.startBattle([Species.BLASTOISE]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 2vs2 trainer", async () => { game.override.battleStyle("double").startingWave(5); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); it("startBattle 4vs2 trainer", async () => { game.override.battleStyle("double").startingWave(5); await game.startBattle([Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE]); - expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); + expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); }); diff --git a/test/boss-pokemon.test.ts b/test/boss-pokemon.test.ts index 9df69da09b7..ef95ae9bcc2 100644 --- a/test/boss-pokemon.test.ts +++ b/test/boss-pokemon.test.ts @@ -6,7 +6,7 @@ import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { EFFECTIVE_STATS } from "#app/enums/stat"; import type { EnemyPokemon } from "#app/field/pokemon"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; describe("Boss Pokemon / Shields", () => { let phaserGame: Phaser.Game; diff --git a/test/daily_mode.test.ts b/test/daily_mode.test.ts index 6b95543fb3b..a7f5784087a 100644 --- a/test/daily_mode.test.ts +++ b/test/daily_mode.test.ts @@ -4,7 +4,7 @@ import { MapModifier } from "#app/modifier/modifier"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { Species } from "#enums/species"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import GameManager from "#test/testUtils/gameManager"; @@ -76,7 +76,7 @@ describe("Shop modifications", async () => { game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to("BattleEndPhase"); - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); game.modifiers.testCheck("EVIOLITE", false).testCheck("MINI_BLACK_HOLE", false); }); @@ -87,7 +87,7 @@ describe("Shop modifications", async () => { game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to("BattleEndPhase"); - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); game.modifiers.testCheck("EVIOLITE", true).testCheck("MINI_BLACK_HOLE", true); }); diff --git a/test/eggs/egg.test.ts b/test/eggs/egg.test.ts index 8875300780b..0110aa5fdaf 100644 --- a/test/eggs/egg.test.ts +++ b/test/eggs/egg.test.ts @@ -5,7 +5,7 @@ import { EggSourceType } from "#app/enums/egg-source-types"; import { EggTier } from "#app/enums/egg-type"; import { VariantTier } from "#app/enums/variant-tier"; import EggData from "#app/system/egg-data"; -import * as Utils from "#app/utils"; +import * as Utils from "#app/utils/common"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; diff --git a/test/enemy_command.test.ts b/test/enemy_command.test.ts index 6d5cc2698a3..ae1f2918798 100644 --- a/test/enemy_command.test.ts +++ b/test/enemy_command.test.ts @@ -6,7 +6,7 @@ import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; import type { EnemyPokemon } from "#app/field/pokemon"; import { AiType } from "#app/field/pokemon"; -import { randSeedInt } from "#app/utils"; +import { randSeedInt } from "#app/utils/common"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/test/escape-calculations.test.ts b/test/escape-calculations.test.ts index d591bdec9fc..56333432cee 100644 --- a/test/escape-calculations.test.ts +++ b/test/escape-calculations.test.ts @@ -1,7 +1,7 @@ import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; import type { CommandPhase } from "#app/phases/command-phase"; import { Command } from "#app/ui/command-ui-handler"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/evolution.test.ts b/test/evolution.test.ts index 68d02402eac..4f91cd99382 100644 --- a/test/evolution.test.ts +++ b/test/evolution.test.ts @@ -6,7 +6,7 @@ import { import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; -import * as Utils from "#app/utils"; +import * as Utils from "#app/utils/common"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/test/game-mode.test.ts b/test/game-mode.test.ts index a2da7d1690a..0483d18e492 100644 --- a/test/game-mode.test.ts +++ b/test/game-mode.test.ts @@ -1,7 +1,7 @@ import type { GameMode } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import * as Utils from "#app/utils"; +import * as Utils from "#app/utils/common"; import GameManager from "#test/testUtils/gameManager"; describe("game-mode", () => { diff --git a/test/items/dire_hit.test.ts b/test/items/dire_hit.test.ts index f6197e097c2..b409b2ac7cb 100644 --- a/test/items/dire_hit.test.ts +++ b/test/items/dire_hit.test.ts @@ -6,7 +6,7 @@ import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { TempCritBoosterModifier } from "#app/modifier/modifier"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { Button } from "#app/enums/buttons"; import { CommandPhase } from "#app/phases/command-phase"; @@ -71,7 +71,7 @@ describe("Items - Dire Hit", () => { // Forced DIRE_HIT to spawn in the first slot with override game.onNextPrompt( "SelectModifierPhase", - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, () => { const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; // Traverse to first modifier slot diff --git a/test/items/double_battle_chance_booster.test.ts b/test/items/double_battle_chance_booster.test.ts index b4818e7e7ba..68a29ef823e 100644 --- a/test/items/double_battle_chance_booster.test.ts +++ b/test/items/double_battle_chance_booster.test.ts @@ -5,7 +5,7 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { Button } from "#app/enums/buttons"; @@ -69,7 +69,7 @@ describe("Items - Double Battle Chance Boosters", () => { // Forced LURE to spawn in the first slot with override game.onNextPrompt( "SelectModifierPhase", - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, () => { const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; // Traverse to first modifier slot diff --git a/test/items/eviolite.test.ts b/test/items/eviolite.test.ts index 43fd6a795bb..fafc0f4a10c 100644 --- a/test/items/eviolite.test.ts +++ b/test/items/eviolite.test.ts @@ -1,5 +1,5 @@ import { StatBoosterModifier } from "#app/modifier/modifier"; -import { NumberHolder, randItem } from "#app/utils"; +import { NumberHolder, randItem } from "#app/utils/common"; import { Species } from "#enums/species"; import { Stat } from "#enums/stat"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/items/exp_booster.test.ts b/test/items/exp_booster.test.ts index 3fe31e5c202..ec7528c3b23 100644 --- a/test/items/exp_booster.test.ts +++ b/test/items/exp_booster.test.ts @@ -1,6 +1,6 @@ import { Abilities } from "#app/enums/abilities"; import { PokemonExpBoosterModifier } from "#app/modifier/modifier"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; diff --git a/test/items/leek.test.ts b/test/items/leek.test.ts index 5f9be882bc1..7589b89bc15 100644 --- a/test/items/leek.test.ts +++ b/test/items/leek.test.ts @@ -1,5 +1,5 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { randInt } from "#app/utils"; +import { randInt } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/items/light_ball.test.ts b/test/items/light_ball.test.ts index e85fb1b602b..91195d0b1e5 100644 --- a/test/items/light_ball.test.ts +++ b/test/items/light_ball.test.ts @@ -2,7 +2,7 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; diff --git a/test/items/lock_capsule.test.ts b/test/items/lock_capsule.test.ts index 9cc6046307e..19829578d87 100644 --- a/test/items/lock_capsule.test.ts +++ b/test/items/lock_capsule.test.ts @@ -2,7 +2,7 @@ import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { ModifierTier } from "#app/modifier/modifier-tier"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -41,7 +41,7 @@ describe("Items - Lock Capsule", () => { }), ); - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => { const selectModifierPhase = game.scene.getCurrentPhase() as SelectModifierPhase; const rerollCost = selectModifierPhase.getRerollCost(true); expect(rerollCost).toBe(150); diff --git a/test/items/metal_powder.test.ts b/test/items/metal_powder.test.ts index 37686710848..6be7655ec70 100644 --- a/test/items/metal_powder.test.ts +++ b/test/items/metal_powder.test.ts @@ -2,7 +2,7 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; diff --git a/test/items/quick_powder.test.ts b/test/items/quick_powder.test.ts index 6937d6093f3..d77f981f04d 100644 --- a/test/items/quick_powder.test.ts +++ b/test/items/quick_powder.test.ts @@ -2,7 +2,7 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; diff --git a/test/items/temp_stat_stage_booster.test.ts b/test/items/temp_stat_stage_booster.test.ts index ccbabf01ccb..a3cfc3256bb 100644 --- a/test/items/temp_stat_stage_booster.test.ts +++ b/test/items/temp_stat_stage_booster.test.ts @@ -7,7 +7,7 @@ import { Moves } from "#app/enums/moves"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { Abilities } from "#app/enums/abilities"; import { TempStatStageBoosterModifier } from "#app/modifier/modifier"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Button } from "#app/enums/buttons"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; @@ -137,7 +137,7 @@ describe("Items - Temporary Stat Stage Boosters", () => { // Forced X_ATTACK to spawn in the first slot with override game.onNextPrompt( "SelectModifierPhase", - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, () => { const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; // Traverse to first modifier slot diff --git a/test/items/thick_club.test.ts b/test/items/thick_club.test.ts index 9e9cd2e2ec8..2a63a60a0e6 100644 --- a/test/items/thick_club.test.ts +++ b/test/items/thick_club.test.ts @@ -2,7 +2,7 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import { NumberHolder, randInt } from "#app/utils"; +import { NumberHolder, randInt } from "#app/utils/common"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; diff --git a/test/moves/aurora_veil.test.ts b/test/moves/aurora_veil.test.ts index ef53b69b4e4..e9ab66d4203 100644 --- a/test/moves/aurora_veil.test.ts +++ b/test/moves/aurora_veil.test.ts @@ -5,7 +5,7 @@ import { allMoves, CritOnlyAttr } from "#app/data/moves/move"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/moves/belly_drum.test.ts b/test/moves/belly_drum.test.ts index f01a50f8a79..8ee1026bf20 100644 --- a/test/moves/belly_drum.test.ts +++ b/test/moves/belly_drum.test.ts @@ -1,5 +1,5 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { Stat } from "#enums/stat"; diff --git a/test/moves/fillet_away.test.ts b/test/moves/fillet_away.test.ts index cc462b3746a..477cdf76fc7 100644 --- a/test/moves/fillet_away.test.ts +++ b/test/moves/fillet_away.test.ts @@ -1,5 +1,5 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { Stat } from "#enums/stat"; diff --git a/test/moves/light_screen.test.ts b/test/moves/light_screen.test.ts index 12aeb29577a..cea26f29542 100644 --- a/test/moves/light_screen.test.ts +++ b/test/moves/light_screen.test.ts @@ -6,7 +6,7 @@ import { Abilities } from "#app/enums/abilities"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/moves/multi_target.test.ts b/test/moves/multi_target.test.ts index fccf650416c..ad47d540a14 100644 --- a/test/moves/multi_target.test.ts +++ b/test/moves/multi_target.test.ts @@ -1,7 +1,7 @@ import { BattlerIndex } from "#app/battle"; import { Abilities } from "#app/enums/abilities"; import { Species } from "#app/enums/species"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Moves } from "#enums/moves"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; diff --git a/test/moves/pledge_moves.test.ts b/test/moves/pledge_moves.test.ts index b3d13a27b83..2bfd408e5fb 100644 --- a/test/moves/pledge_moves.test.ts +++ b/test/moves/pledge_moves.test.ts @@ -5,7 +5,7 @@ import { allMoves, FlinchAttr } from "#app/data/moves/move"; import { PokemonType } from "#enums/pokemon-type"; import { ArenaTagType } from "#enums/arena-tag-type"; import { Stat } from "#enums/stat"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/moves/reflect.test.ts b/test/moves/reflect.test.ts index 473b46bf097..b8338cea8cf 100644 --- a/test/moves/reflect.test.ts +++ b/test/moves/reflect.test.ts @@ -6,7 +6,7 @@ import { Abilities } from "#app/enums/abilities"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils/common"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/moves/revival_blessing.test.ts b/test/moves/revival_blessing.test.ts index 860ce5524d4..b36cd43eb83 100644 --- a/test/moves/revival_blessing.test.ts +++ b/test/moves/revival_blessing.test.ts @@ -1,6 +1,6 @@ import { BattlerIndex } from "#app/battle"; import { MoveResult } from "#app/field/pokemon"; -import { toDmgValue } from "#app/utils"; +import { toDmgValue } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; diff --git a/test/moves/substitute.test.ts b/test/moves/substitute.test.ts index 2e82078418b..7f4a2e69f9e 100644 --- a/test/moves/substitute.test.ts +++ b/test/moves/substitute.test.ts @@ -6,7 +6,7 @@ import { MoveResult } from "#app/field/pokemon"; import type { CommandPhase } from "#app/phases/command-phase"; import GameManager from "#test/testUtils/gameManager"; import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Abilities } from "#enums/abilities"; import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; @@ -398,7 +398,7 @@ describe("Moves - Substitute", () => { leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); // Simulate a Baton switch for the player this turn - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, 1, true); }); diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 93629778e0a..977f40bc90e 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -14,8 +14,8 @@ import type MessageUiHandler from "#app/ui/message-ui-handler"; import type MysteryEncounterUiHandler from "#app/ui/mystery-encounter-ui-handler"; import type PartyUiHandler from "#app/ui/party-ui-handler"; import type OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { isNullOrUndefined } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isNullOrUndefined } from "#app/utils/common"; import { Button } from "#enums/buttons"; import { StatusEffect } from "#enums/status-effect"; import type GameManager from "#test/testUtils/gameManager"; @@ -40,7 +40,7 @@ export async function runMysteryEncounterToEnd( // run the selected options phase game.onNextPrompt( "MysteryEncounterOptionSelectedPhase", - Mode.MESSAGE, + UiMode.MESSAGE, () => { const uiHandler = game.scene.ui.getHandler(); uiHandler.processInput(Button.ACTION); @@ -51,9 +51,9 @@ export async function runMysteryEncounterToEnd( if (isBattle) { game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); game.endPhase(); }, () => game.isCurrentPhase(CommandPhase), @@ -61,16 +61,16 @@ export async function runMysteryEncounterToEnd( game.onNextPrompt( "CheckSwitchPhase", - Mode.MESSAGE, + UiMode.MESSAGE, () => { - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); game.endPhase(); }, () => game.isCurrentPhase(CommandPhase), ); // If a battle is started, fast forward to end of the battle - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { game.scene.clearPhaseQueue(); game.scene.clearPhaseQueueSplice(); game.scene.unshiftPhase(new VictoryPhase(0)); @@ -78,13 +78,13 @@ export async function runMysteryEncounterToEnd( }); // Handle end of battle trainer messages - game.onNextPrompt("TrainerVictoryPhase", Mode.MESSAGE, () => { + game.onNextPrompt("TrainerVictoryPhase", UiMode.MESSAGE, () => { const uiHandler = game.scene.ui.getHandler(); uiHandler.processInput(Button.ACTION); }); // Handle egg hatch dialogue - game.onNextPrompt("EggLapsePhase", Mode.MESSAGE, () => { + game.onNextPrompt("EggLapsePhase", UiMode.MESSAGE, () => { const uiHandler = game.scene.ui.getHandler(); uiHandler.processInput(Button.ACTION); }); @@ -103,7 +103,7 @@ export async function runSelectMysteryEncounterOption( // Handle any eventual queued messages (e.g. weather phase, etc.) game.onNextPrompt( "MessagePhase", - Mode.MESSAGE, + UiMode.MESSAGE, () => { const uiHandler = game.scene.ui.getHandler(); uiHandler.processInput(Button.ACTION); @@ -118,7 +118,7 @@ export async function runSelectMysteryEncounterOption( // dispose of intro messages game.onNextPrompt( "MysteryEncounterPhase", - Mode.MESSAGE, + UiMode.MESSAGE, () => { const uiHandler = game.scene.ui.getHandler(); uiHandler.processInput(Button.ACTION); @@ -157,7 +157,7 @@ export async function runSelectMysteryEncounterOption( async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, optionNo?: number) { // Handle secondary option selections - const partyUiHandler = game.scene.ui.handlers[Mode.PARTY] as PartyUiHandler; + const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler; vi.spyOn(partyUiHandler, "show"); const encounterUiHandler = game.scene.ui.getHandler(); @@ -177,7 +177,7 @@ async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, // If there is a second choice to make after selecting a Pokemon if (!isNullOrUndefined(optionNo)) { // Wait for Summary menu to close and second options to spawn - const secondOptionUiHandler = game.scene.ui.handlers[Mode.OPTION_SELECT] as OptionSelectUiHandler; + const secondOptionUiHandler = game.scene.ui.handlers[UiMode.OPTION_SELECT] as OptionSelectUiHandler; vi.spyOn(secondOptionUiHandler, "show"); await vi.waitFor(() => expect(secondOptionUiHandler.show).toHaveBeenCalled()); @@ -206,6 +206,6 @@ export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManage }); game.scene.pushPhase(new VictoryPhase(0)); game.phaseInterceptor.superEndPhase(); - game.setMode(Mode.MESSAGE); + game.setMode(UiMode.MESSAGE); await game.phaseInterceptor.to(MysteryEncounterRewardsPhase, runRewardsPhase); } diff --git a/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts b/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts index 43d582c5b70..a4c043ad13f 100644 --- a/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts +++ b/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts @@ -117,10 +117,8 @@ describe("A Trainer's Test - Mystery Encounter", () => { i18next.t("trainerNames:marley"), i18next.t("trainerNames:mira"), i18next.t("trainerNames:riley"), - ] - .map(name => name.toLowerCase()) - .includes(scene.currentBattle.trainer!.config.name), - ).toBeTruthy(); + ].map(name => name.toLowerCase()), + ).toContain(scene.currentBattle.trainer!.config.name.toLowerCase()); expect(enemyField[0]).toBeDefined(); }); diff --git a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts index e19726f49fd..3f85b0b89d9 100644 --- a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts +++ b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts @@ -9,7 +9,7 @@ import { skipBattleRunMysteryEncounterRewardsPhase, } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { BerryModifier } from "#app/modifier/modifier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -153,7 +153,7 @@ describe("Berries Abound - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -238,7 +238,7 @@ describe("Berries Abound - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts b/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts index 9befe77e688..fc208ed7180 100644 --- a/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts +++ b/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts @@ -12,7 +12,7 @@ import { import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -364,7 +364,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterRewardsPhase.name); game.phaseInterceptor["prompts"] = []; // Clear out prompt handlers - game.onNextPrompt("MysteryEncounterRewardsPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("MysteryEncounterRewardsPhase", UiMode.OPTION_SELECT, () => { game.phaseInterceptor.superEndPhase(); }); await game.phaseInterceptor.run(MysteryEncounterRewardsPhase); @@ -416,7 +416,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -432,7 +432,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -454,7 +454,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -478,7 +478,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -554,7 +554,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts index 4bbe76e5c72..afc4a83e9bf 100644 --- a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -16,7 +16,7 @@ import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import type Pokemon from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -206,14 +206,14 @@ describe("Clowning Around - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); const abilityToTrain = scene.currentBattle.mysteryEncounter?.misc.ability; - game.onNextPrompt("PostMysteryEncounterPhase", Mode.MESSAGE, () => { + game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => { game.scene.ui.getHandler().processInput(Button.ACTION); }); // Run to ability train option selection - const optionSelectUiHandler = game.scene.ui.handlers[Mode.OPTION_SELECT] as OptionSelectUiHandler; + const optionSelectUiHandler = game.scene.ui.handlers[UiMode.OPTION_SELECT] as OptionSelectUiHandler; vi.spyOn(optionSelectUiHandler, "show"); - const partyUiHandler = game.scene.ui.handlers[Mode.PARTY] as PartyUiHandler; + const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler; vi.spyOn(partyUiHandler, "show"); game.endPhase(); await game.phaseInterceptor.to(PostMysteryEncounterPhase); diff --git a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts index 77cd65e51b9..873bed2f213 100644 --- a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts +++ b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts @@ -15,7 +15,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters"; import { Moves } from "#enums/moves"; import { DancingLessonsEncounter } from "#app/data/mystery-encounters/encounters/dancing-lessons-encounter"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { PokemonMove } from "#app/field/pokemon"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; @@ -132,7 +132,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts b/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts index d4b0de30535..2488d12dad1 100644 --- a/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts +++ b/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts @@ -7,7 +7,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { DepartmentStoreSaleEncounter } from "#app/data/mystery-encounters/encounters/department-store-sale-encounter"; import { CIVILIZATION_ENCOUNTER_BIOMES } from "#app/data/mystery-encounters/mystery-encounters"; @@ -98,7 +98,7 @@ describe("Department Store Sale - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -135,7 +135,7 @@ describe("Department Store Sale - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -175,7 +175,7 @@ describe("Department Store Sale - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -215,7 +215,7 @@ describe("Department Store Sale - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/field-trip-encounter.test.ts b/test/mystery-encounter/encounters/field-trip-encounter.test.ts index 8bd35d6013f..75a6fe77492 100644 --- a/test/mystery-encounter/encounters/field-trip-encounter.test.ts +++ b/test/mystery-encounter/encounters/field-trip-encounter.test.ts @@ -12,7 +12,7 @@ import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encount import { FieldTripEncounter } from "#app/data/mystery-encounters/encounters/field-trip-encounter"; import { Moves } from "#enums/moves"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import i18next from "i18next"; @@ -88,7 +88,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 2 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -100,7 +100,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 1 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -149,7 +149,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1, optionNo: 1 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -161,7 +161,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1, optionNo: 2 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -210,7 +210,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -223,7 +223,7 @@ describe("Field Trip - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 3 }); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts index d233e72932a..d47266268ee 100644 --- a/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts +++ b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts @@ -12,7 +12,7 @@ import { import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -126,7 +126,7 @@ describe("Fight or Flight - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase, false); expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, @@ -186,7 +186,7 @@ describe("Fight or Flight - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase, false); expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, diff --git a/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts b/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts index 4bb44c4d19e..f8375c1aa78 100644 --- a/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts +++ b/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts @@ -10,7 +10,7 @@ import { runSelectMysteryEncounterOption, } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -147,7 +147,7 @@ describe("Fun And Games! - Mystery Encounter", () => { expect(scene.getEnemyPokemon()?.ivs).toEqual([0, 0, 0, 0, 0, 0]); expect(scene.getEnemyPokemon()?.nature).toBe(Nature.MILD); - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { + game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => { game.endPhase(); }); @@ -173,7 +173,7 @@ describe("Fun And Games! - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { + game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => { game.endPhase(); }); @@ -186,7 +186,7 @@ describe("Fun And Games! - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -200,7 +200,7 @@ describe("Fun And Games! - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { + game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => { game.endPhase(); }); @@ -215,7 +215,7 @@ describe("Fun And Games! - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -230,7 +230,7 @@ describe("Fun And Games! - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { + game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => { game.endPhase(); }); @@ -245,7 +245,7 @@ describe("Fun And Games! - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -260,7 +260,7 @@ describe("Fun And Games! - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { + game.onNextPrompt("MessagePhase", UiMode.MESSAGE, () => { game.endPhase(); }); @@ -275,7 +275,7 @@ describe("Fun And Games! - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts index f68561c2286..576e99c4e18 100644 --- a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts +++ b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts @@ -15,10 +15,10 @@ import { modifierTypes } from "#app/modifier/modifier-type"; import { GlobalTradeSystemEncounter } from "#app/data/mystery-encounters/encounters/global-trade-system-encounter"; import { CIVILIZATION_ENCOUNTER_BIOMES } from "#app/data/mystery-encounters/mystery-encounters"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { ModifierTier } from "#app/modifier/modifier-tier"; -import * as Utils from "#app/utils"; +import * as Utils from "#app/utils/common"; const namespace = "mysteryEncounters/globalTradeSystem"; const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; @@ -231,7 +231,7 @@ describe("Global Trade System - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts index f620cbd6c36..2c61d03b29d 100644 --- a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts +++ b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts @@ -10,7 +10,7 @@ import { skipBattleRunMysteryEncounterRewardsPhase, } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -166,7 +166,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -210,7 +210,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -267,7 +267,7 @@ describe("Mysterious Challengers - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts index 85c823038e8..4ff94c5a9bd 100644 --- a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts +++ b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts @@ -10,7 +10,7 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import GameManager from "#test/testUtils/gameManager"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { @@ -301,7 +301,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts b/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts index a9e6a339d36..e3440aee9e0 100644 --- a/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts @@ -18,7 +18,7 @@ import { Nature } from "#enums/nature"; import { BerryType } from "#enums/berry-type"; import { BattlerTagType } from "#enums/battler-tag-type"; import { PokemonMove } from "#app/field/pokemon"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { BerryModifier, PokemonBaseStatTotalModifier } from "#app/modifier/modifier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -236,7 +236,7 @@ describe("The Strong Stuff - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts index 94c8141aa1e..4cb712ce779 100644 --- a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts @@ -7,7 +7,7 @@ import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -299,7 +299,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -341,7 +341,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -359,7 +359,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false) { game.scene.clearPhaseQueue(); game.scene.clearPhaseQueueSplice(); - const commandUiHandler = game.scene.ui.handlers[Mode.COMMAND]; + const commandUiHandler = game.scene.ui.handlers[UiMode.COMMAND]; commandUiHandler.clear(); game.scene.getEnemyParty().forEach(p => { p.hp = 0; diff --git a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts index df7bbb9f424..2f910a9250f 100644 --- a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts +++ b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts @@ -20,8 +20,8 @@ import { CommandPhase } from "#app/phases/command-phase"; import { MovePhase } from "#app/phases/move-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import * as Utils from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import * as Utils from "#app/utils/common"; import { Moves } from "#enums/moves"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -246,7 +246,7 @@ describe("Trash to Treasure - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts index fbb88e346a8..f51ab45e4d4 100644 --- a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts +++ b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts @@ -10,7 +10,7 @@ import { skipBattleRunMysteryEncounterRewardsPhase, } from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -144,7 +144,7 @@ describe("Weird Dream - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -200,7 +200,7 @@ describe("Weird Dream - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/phases/learn-move-phase.test.ts b/test/phases/learn-move-phase.test.ts index 55b9d8b79d4..019b833d386 100644 --- a/test/phases/learn-move-phase.test.ts +++ b/test/phases/learn-move-phase.test.ts @@ -4,7 +4,7 @@ import GameManager from "#test/testUtils/gameManager"; import { Species } from "#enums/species"; import { Moves } from "#enums/moves"; import { LearnMovePhase } from "#app/phases/learn-move-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Button } from "#app/enums/buttons"; describe("Learn Move Phase", () => { @@ -52,10 +52,10 @@ describe("Learn Move Phase", () => { await game.doKillOpponents(); // queue up inputs to confirm dialog boxes - game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => { + game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { game.scene.ui.processInput(Button.ACTION); }); - game.onNextPrompt("LearnMovePhase", Mode.SUMMARY, () => { + game.onNextPrompt("LearnMovePhase", UiMode.SUMMARY, () => { for (let x = 0; x < moveSlotNum; x++) { game.scene.ui.processInput(Button.DOWN); } @@ -84,16 +84,16 @@ describe("Learn Move Phase", () => { await game.doKillOpponents(); // queue up inputs to confirm dialog boxes - game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => { + game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { game.scene.ui.processInput(Button.ACTION); }); - game.onNextPrompt("LearnMovePhase", Mode.SUMMARY, () => { + game.onNextPrompt("LearnMovePhase", UiMode.SUMMARY, () => { for (let x = 0; x < 4; x++) { game.scene.ui.processInput(Button.DOWN); // moves down 4 times to the 5th move slot } game.scene.ui.processInput(Button.ACTION); }); - game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => { + game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { game.scene.ui.processInput(Button.ACTION); }); await game.phaseInterceptor.to(LearnMovePhase); diff --git a/test/phases/mystery-encounter-phase.test.ts b/test/phases/mystery-encounter-phase.test.ts index f903932d2cb..34078b65039 100644 --- a/test/phases/mystery-encounter-phase.test.ts +++ b/test/phases/mystery-encounter-phase.test.ts @@ -3,7 +3,7 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { Species } from "#enums/species"; import { MysteryEncounterOptionSelectedPhase, MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Button } from "#enums/buttons"; import type MysteryEncounterUiHandler from "#app/ui/mystery-encounter-ui-handler"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -50,7 +50,7 @@ describe("Mystery Encounter Phases", () => { Species.VOLCARONA, ]); - game.onNextPrompt("MysteryEncounterPhase", Mode.MYSTERY_ENCOUNTER, () => { + game.onNextPrompt("MysteryEncounterPhase", UiMode.MYSTERY_ENCOUNTER, () => { // End phase early for test game.phaseInterceptor.superEndPhase(); }); @@ -61,7 +61,7 @@ describe("Mystery Encounter Phases", () => { MysteryEncounterType.MYSTERIOUS_CHALLENGERS, ); expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].tier).toEqual(MysteryEncounterTier.GREAT); - expect(game.scene.ui.getMode()).toBe(Mode.MYSTERY_ENCOUNTER); + expect(game.scene.ui.getMode()).toBe(UiMode.MYSTERY_ENCOUNTER); }); it("Selects an option for MysteryEncounterPhase", async () => { @@ -73,7 +73,7 @@ describe("Mystery Encounter Phases", () => { Species.VOLCARONA, ]); - game.onNextPrompt("MysteryEncounterPhase", Mode.MESSAGE, () => { + game.onNextPrompt("MysteryEncounterPhase", UiMode.MESSAGE, () => { const handler = game.scene.ui.getHandler() as MessageUiHandler; handler.processInput(Button.ACTION); }); @@ -89,7 +89,7 @@ describe("Mystery Encounter Phases", () => { await vi.waitFor(() => expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterOptionSelectedPhase.name), ); - expect(ui.getMode()).toBe(Mode.MESSAGE); + expect(ui.getMode()).toBe(UiMode.MESSAGE); expect(ui.showDialogue).toHaveBeenCalledTimes(1); expect(ui.showText).toHaveBeenCalledTimes(2); expect(ui.showDialogue).toHaveBeenCalledWith( diff --git a/test/phases/phases.test.ts b/test/phases/phases.test.ts index 96225c9151c..2483cfb317f 100644 --- a/test/phases/phases.test.ts +++ b/test/phases/phases.test.ts @@ -2,7 +2,7 @@ import type BattleScene from "#app/battle-scene"; import { LoginPhase } from "#app/phases/login-phase"; import { TitlePhase } from "#app/phases/title-phase"; import { UnavailablePhase } from "#app/phases/unavailable-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -32,7 +32,7 @@ describe("Phases", () => { const loginPhase = new LoginPhase(); scene.unshiftPhase(loginPhase); await game.phaseInterceptor.to(LoginPhase); - expect(scene.ui.getMode()).to.equal(Mode.MESSAGE); + expect(scene.ui.getMode()).to.equal(UiMode.MESSAGE); }); }); @@ -41,7 +41,7 @@ describe("Phases", () => { const titlePhase = new TitlePhase(); scene.unshiftPhase(titlePhase); await game.phaseInterceptor.to(TitlePhase); - expect(scene.ui.getMode()).to.equal(Mode.TITLE); + expect(scene.ui.getMode()).to.equal(UiMode.TITLE); }); }); @@ -50,7 +50,7 @@ describe("Phases", () => { const unavailablePhase = new UnavailablePhase(); scene.unshiftPhase(unavailablePhase); await game.phaseInterceptor.to(UnavailablePhase); - expect(scene.ui.getMode()).to.equal(Mode.UNAVAILABLE); + expect(scene.ui.getMode()).to.equal(UiMode.UNAVAILABLE); }, 20000); }); }); diff --git a/test/phases/select-modifier-phase.test.ts b/test/phases/select-modifier-phase.test.ts index d352acea77a..85f8b472c4a 100644 --- a/test/phases/select-modifier-phase.test.ts +++ b/test/phases/select-modifier-phase.test.ts @@ -6,8 +6,8 @@ import type { CustomModifierSettings } from "#app/modifier/modifier-type"; import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { shiftCharCodes } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { shiftCharCodes } from "#app/utils/common"; import { Abilities } from "#enums/abilities"; import { Button } from "#enums/buttons"; import { Moves } from "#enums/moves"; @@ -51,7 +51,7 @@ describe("SelectModifierPhase", () => { scene.unshiftPhase(selectModifierPhase); await game.phaseInterceptor.to(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); }); it("should generate random modifiers", async () => { @@ -59,7 +59,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.FISSURE); await game.phaseInterceptor.to("SelectModifierPhase"); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -97,7 +97,7 @@ describe("SelectModifierPhase", () => { // TODO: nagivate the ui to reroll somehow //const smphase = scene.getCurrentPhase() as SelectModifierPhase; - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -106,7 +106,7 @@ describe("SelectModifierPhase", () => { modifierSelectHandler.processInput(Button.ACTION); expect(scene.money).toBe(1000000 - 250); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(modifierSelectHandler.options.length).toEqual(3); }); @@ -125,7 +125,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.FISSURE); await game.phaseInterceptor.to("SelectModifierPhase"); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -134,7 +134,7 @@ describe("SelectModifierPhase", () => { // TODO: nagivate ui to reroll with lock capsule enabled - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); expect(modifierSelectHandler.options.length).toEqual(3); // Reroll with lock can still upgrade expect( @@ -168,7 +168,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("SelectModifierPhase"); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -205,7 +205,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("SelectModifierPhase"); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -244,7 +244,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; @@ -268,7 +268,7 @@ describe("SelectModifierPhase", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); + expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; diff --git a/test/plugins/api/pokerogue-account-api.test.ts b/test/plugins/api/pokerogue-account-api.test.ts index e7e1b2d52b0..3c37451960a 100644 --- a/test/plugins/api/pokerogue-account-api.test.ts +++ b/test/plugins/api/pokerogue-account-api.test.ts @@ -2,7 +2,8 @@ import type { AccountInfoResponse } from "#app/@types/PokerogueAccountApi"; import { SESSION_ID_COOKIE_NAME } from "#app/constants"; import { PokerogueAccountApi } from "#app/plugins/api/pokerogue-account-api"; import { getApiBaseUrl } from "#test/testUtils/testUtils"; -import * as Utils from "#app/utils"; +import * as CookieUtils from "#app/utils/cookies"; +import * as cookies from "#app/utils/cookies"; import { http, HttpResponse } from "msw"; import { beforeAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { initServerForApiTests } from "#test/testUtils/testFileInitialization"; @@ -98,13 +99,13 @@ describe("Pokerogue Account API", () => { const loginParams = { username: "test", password: "test" }; it("should return null and set the cookie on SUCCESS", async () => { - vi.spyOn(Utils, "setCookie"); + vi.spyOn(CookieUtils, "setCookie"); server.use(http.post(`${apiBase}/account/login`, () => HttpResponse.json({ token: "abctest" }))); const error = await accountApi.login(loginParams); expect(error).toBeNull(); - expect(Utils.setCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME, "abctest"); + expect(cookies.setCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME, "abctest"); }); it("should return error message and report a warning on FAILURE", async () => { @@ -130,16 +131,16 @@ describe("Pokerogue Account API", () => { describe("Logout", () => { beforeEach(() => { - vi.spyOn(Utils, "removeCookie"); + vi.spyOn(CookieUtils, "removeCookie"); }); it("should remove cookie on success", async () => { - vi.spyOn(Utils, "setCookie"); + vi.spyOn(CookieUtils, "setCookie"); server.use(http.get(`${apiBase}/account/logout`, () => new HttpResponse("", { status: 200 }))); await accountApi.logout(); - expect(Utils.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); + expect(cookies.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); }); it("should report a warning on and remove cookie on FAILURE", async () => { @@ -147,7 +148,7 @@ describe("Pokerogue Account API", () => { await accountApi.logout(); - expect(Utils.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); + expect(cookies.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); expect(console.warn).toHaveBeenCalledWith("Log out failed!", expect.any(Error)); }); @@ -156,7 +157,7 @@ describe("Pokerogue Account API", () => { await accountApi.logout(); - expect(Utils.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); + expect(cookies.removeCookie).toHaveBeenCalledWith(SESSION_ID_COOKIE_NAME); expect(console.warn).toHaveBeenCalledWith("Log out failed!", expect.any(Error)); }); }); diff --git a/test/reload.test.ts b/test/reload.test.ts index c69c0f9f484..93823e06cce 100644 --- a/test/reload.test.ts +++ b/test/reload.test.ts @@ -1,7 +1,7 @@ import { GameModes } from "#app/game-mode"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import type OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Biome } from "#enums/biome"; import { Button } from "#enums/buttons"; import { Moves } from "#enums/moves"; @@ -58,7 +58,7 @@ describe("Reload", () => { // Transition from Wave 10 to Wave 11 in order to trigger biome switch game.move.select(Moves.SPLASH); await game.doKillOpponents(); - game.onNextPrompt("SelectBiomePhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectBiomePhase", UiMode.OPTION_SELECT, () => { (game.scene.time as MockClock).overrideDelay = null; const optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; game.scene.time.delayedCall(1010, () => optionSelectUiHandler.processInput(Button.ACTION)); diff --git a/test/settingMenu/rebinding_setting.test.ts b/test/settingMenu/rebinding_setting.test.ts index 28b5d73d7cc..45c647248c4 100644 --- a/test/settingMenu/rebinding_setting.test.ts +++ b/test/settingMenu/rebinding_setting.test.ts @@ -2,7 +2,7 @@ import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty"; import { getKeyWithKeycode, getKeyWithSettingName } from "#app/configs/inputs/configHandler"; import type { InterfaceConfig } from "#app/inputs-controller"; import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; -import { deepCopy } from "#app/utils"; +import { deepCopy } from "#app/utils/common"; import { Button } from "#enums/buttons"; import { Device } from "#enums/devices"; import { InGameManip } from "#test/settingMenu/helpers/inGameManip"; diff --git a/test/system/game_data.test.ts b/test/system/game_data.test.ts index 94e82949fe6..900fb672320 100644 --- a/test/system/game_data.test.ts +++ b/test/system/game_data.test.ts @@ -1,4 +1,4 @@ -import * as BattleScene from "#app/battle-scene"; +import * as bypassLoginModule from "#app/global-vars/bypass-login"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import type { SessionSaveData } from "#app/system/game-data"; import { Abilities } from "#enums/abilities"; @@ -33,13 +33,13 @@ describe("System - Game Data", () => { describe("tryClearSession", () => { beforeEach(() => { - vi.spyOn(BattleScene, "bypassLogin", "get").mockReturnValue(false); + vi.spyOn(bypassLoginModule, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(game.scene.gameData, "getSessionSaveData").mockReturnValue({} as SessionSaveData); vi.spyOn(account, "updateUserInfo").mockImplementation(async () => [true, 1]); }); it("should return [true, true] if bypassLogin is true", async () => { - vi.spyOn(BattleScene, "bypassLogin", "get").mockReturnValue(true); + vi.spyOn(bypassLoginModule, "bypassLogin", "get").mockReturnValue(true); const result = await game.scene.gameData.tryClearSession(0); diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index 390e71af126..874d8f786b8 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -30,8 +30,8 @@ import type CommandUiHandler from "#app/ui/command-ui-handler"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import type PartyUiHandler from "#app/ui/party-ui-handler"; import type TargetSelectUiHandler from "#app/ui/target-select-ui-handler"; -import { Mode } from "#app/ui/ui"; -import { isNullOrUndefined } from "#app/utils"; +import { UiMode } from "#enums/ui-mode"; +import { isNullOrUndefined } from "#app/utils/common"; import { BattleStyle } from "#enums/battle-style"; import { Button } from "#enums/buttons"; import { ExpGainsSpeed } from "#enums/exp-gains-speed"; @@ -102,7 +102,7 @@ export default class GameManager { if (!firstTimeScene) { this.scene.reset(false, true); - (this.scene.ui.handlers[Mode.STARTER_SELECT] as StarterSelectUiHandler).clearStarterPreferences(); + (this.scene.ui.handlers[UiMode.STARTER_SELECT] as StarterSelectUiHandler).clearStarterPreferences(); this.scene.clearAllPhases(); // Must be run after phase interceptor has been initialized. @@ -135,7 +135,7 @@ export default class GameManager { * Sets the game mode. * @param mode - The mode to set. */ - setMode(mode: Mode) { + setMode(mode: UiMode) { this.scene.ui?.setMode(mode); } @@ -144,7 +144,7 @@ export default class GameManager { * @param mode - The mode to wait for. * @returns A promise that resolves when the mode is set. */ - waitMode(mode: Mode): Promise { + waitMode(mode: UiMode): Promise { return new Promise(async resolve => { await waitUntil(() => this.scene.ui?.getMode() === mode); return resolve(); @@ -168,7 +168,7 @@ export default class GameManager { */ onNextPrompt( phaseTarget: string, - mode: Mode, + mode: UiMode, callback: () => void, expireFn?: () => void, awaitingActionInput = false, @@ -208,7 +208,7 @@ export default class GameManager { console.log("===to final boss encounter==="); await this.runToTitle(); - this.onNextPrompt("TitlePhase", Mode.TITLE, () => { + this.onNextPrompt("TitlePhase", UiMode.TITLE, () => { this.scene.gameMode = getGameMode(mode); const starters = generateStarter(this.scene, species); const selectStarterPhase = new SelectStarterPhase(); @@ -243,7 +243,7 @@ export default class GameManager { this.onNextPrompt( "TitlePhase", - Mode.TITLE, + UiMode.TITLE, () => { this.scene.gameMode = getGameMode(GameModes.CLASSIC); const starters = generateStarter(this.scene, species); @@ -256,7 +256,7 @@ export default class GameManager { this.onNextPrompt( "EncounterPhase", - Mode.MESSAGE, + UiMode.MESSAGE, () => { const handler = this.scene.ui.getHandler() as BattleMessageUiHandler; handler.processInput(Button.ACTION); @@ -284,9 +284,9 @@ export default class GameManager { if (this.scene.battleStyle === BattleStyle.SWITCH) { this.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); + this.setMode(UiMode.MESSAGE); this.endPhase(); }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase), @@ -294,9 +294,9 @@ export default class GameManager { this.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); + this.setMode(UiMode.MESSAGE); this.endPhase(); }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase), @@ -316,7 +316,7 @@ export default class GameManager { selectTarget(movePosition: number, targetIndex?: BattlerIndex) { this.onNextPrompt( "SelectTargetPhase", - Mode.TARGET_SELECT, + UiMode.TARGET_SELECT, () => { const handler = this.scene.ui.getHandler() as TargetSelectUiHandler; const move = (this.scene.getCurrentPhase() as SelectTargetPhase) @@ -351,7 +351,7 @@ export default class GameManager { doSelectModifier() { this.onNextPrompt( "SelectModifierPhase", - Mode.MODIFIER_SELECT, + UiMode.MODIFIER_SELECT, () => { const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; handler.processInput(Button.CANCEL); @@ -365,7 +365,7 @@ export default class GameManager { this.onNextPrompt( "SelectModifierPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; handler.processInput(Button.ACTION); @@ -427,9 +427,9 @@ export default class GameManager { this.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); + this.setMode(UiMode.MESSAGE); this.endPhase(); }, () => this.isCurrentPhase(TurnInitPhase), @@ -461,7 +461,7 @@ export default class GameManager { * @param mode - The target mode. * @returns True if the current mode matches the target mode, otherwise false. */ - isCurrentMode(mode: Mode) { + isCurrentMode(mode: UiMode) { return this.scene.ui?.getMode() === mode; } @@ -516,7 +516,7 @@ export default class GameManager { * @param pokemonIndex the index of the pokemon in your party to switch to */ doSwitchPokemon(pokemonIndex: number) { - this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + this.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { (this.scene.ui.getHandler() as CommandUiHandler).setCursor(2); (this.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION); }); @@ -545,7 +545,7 @@ export default class GameManager { * non-command switch actions happen in SwitchPhase. */ doSelectPartyPokemon(slot: number, inPhase = "SwitchPhase") { - this.onNextPrompt(inPhase, Mode.PARTY, () => { + this.onNextPrompt(inPhase, UiMode.PARTY, () => { const partyHandler = this.scene.ui.getHandler() as PartyUiHandler; partyHandler.setCursor(slot); @@ -560,12 +560,12 @@ export default class GameManager { * @param ballIndex the index of the pokeball to throw */ public doThrowPokeball(ballIndex: number) { - this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + this.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { (this.scene.ui.getHandler() as CommandUiHandler).setCursor(1); (this.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION); }); - this.onNextPrompt("CommandPhase", Mode.BALL, () => { + this.onNextPrompt("CommandPhase", UiMode.BALL, () => { const ballHandler = this.scene.ui.getHandler() as BallUiHandler; ballHandler.setCursor(ballIndex); ballHandler.processInput(Button.ACTION); // select ball and throw diff --git a/test/testUtils/gameWrapper.ts b/test/testUtils/gameWrapper.ts index 02865701ed0..050e9f13257 100644 --- a/test/testUtils/gameWrapper.ts +++ b/test/testUtils/gameWrapper.ts @@ -1,8 +1,9 @@ // @ts-nocheck - TODO: remove this -import BattleScene, * as battleScene from "#app/battle-scene"; +import BattleScene from "#app/battle-scene"; import { MoveAnim } from "#app/data/battle-anims"; import Pokemon from "#app/field/pokemon"; -import { setCookie, sessionIdKey } from "#app/utils"; +import { sessionIdKey } from "#app/utils/common"; +import { setCookie } from "#app/utils/cookies"; import { blobToString } from "#test/testUtils/gameManagerUtils"; import { MockClock } from "#test/testUtils/mocks/mockClock"; import { MockFetch } from "#test/testUtils/mocks/mockFetch"; @@ -20,6 +21,8 @@ import KeyboardPlugin = Phaser.Input.Keyboard.KeyboardPlugin; import GamepadPlugin = Phaser.Input.Gamepad.GamepadPlugin; import EventEmitter = Phaser.Events.EventEmitter; import UpdateList = Phaser.GameObjects.UpdateList; +// biome-ignore lint/style/noNamespaceImport: Necessary in order to mock the var +import * as bypassLoginModule from "#app/global-vars/bypass-login"; window.URL.createObjectURL = (blob: Blob) => { blobToString(blob).then((data: string) => { @@ -43,7 +46,7 @@ export default class GameWrapper { Phaser.Math.RND.sow(["test"]); // vi.spyOn(Utils, "apiFetch", "get").mockReturnValue(fetch); if (bypassLogin) { - vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); + vi.spyOn(bypassLoginModule, "bypassLogin", "get").mockReturnValue(true); } this.game = phaserGame; MoveAnim.prototype.getAnim = () => ({ diff --git a/test/testUtils/helpers/challengeModeHelper.ts b/test/testUtils/helpers/challengeModeHelper.ts index 0b7826eda7e..3a4f2adcd09 100644 --- a/test/testUtils/helpers/challengeModeHelper.ts +++ b/test/testUtils/helpers/challengeModeHelper.ts @@ -3,7 +3,7 @@ import type { Species } from "#app/enums/species"; import overrides from "#app/overrides"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { SelectStarterPhase } from "#app/phases/select-starter-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { generateStarter } from "../gameManagerUtils"; import { GameManagerHelper } from "./gameManagerHelper"; import type { Challenge } from "#app/data/challenge"; @@ -41,7 +41,7 @@ export class ChallengeModeHelper extends GameManagerHelper { this.game.override.shiny(false).enemyShiny(false); } - this.game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + this.game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { this.game.scene.gameMode.challenges = this.challenges; const starters = generateStarter(this.game.scene, species); const selectStarterPhase = new SelectStarterPhase(); @@ -66,9 +66,9 @@ export class ChallengeModeHelper extends GameManagerHelper { if (this.game.scene.battleStyle === BattleStyle.SWITCH) { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), @@ -76,9 +76,9 @@ export class ChallengeModeHelper extends GameManagerHelper { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), diff --git a/test/testUtils/helpers/classicModeHelper.ts b/test/testUtils/helpers/classicModeHelper.ts index 5b6a38f5747..8e1ac95c733 100644 --- a/test/testUtils/helpers/classicModeHelper.ts +++ b/test/testUtils/helpers/classicModeHelper.ts @@ -6,7 +6,7 @@ import { CommandPhase } from "#app/phases/command-phase"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { SelectStarterPhase } from "#app/phases/select-starter-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { generateStarter } from "../gameManagerUtils"; import { GameManagerHelper } from "./gameManagerHelper"; @@ -26,7 +26,7 @@ export class ClassicModeHelper extends GameManagerHelper { this.game.override.shiny(false).enemyShiny(false); } - this.game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + this.game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { this.game.scene.gameMode = getGameMode(GameModes.CLASSIC); const starters = generateStarter(this.game.scene, species); const selectStarterPhase = new SelectStarterPhase(); @@ -51,9 +51,9 @@ export class ClassicModeHelper extends GameManagerHelper { if (this.game.scene.battleStyle === BattleStyle.SWITCH) { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), @@ -61,9 +61,9 @@ export class ClassicModeHelper extends GameManagerHelper { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), diff --git a/test/testUtils/helpers/dailyModeHelper.ts b/test/testUtils/helpers/dailyModeHelper.ts index 0f5bc84df68..8ee03ce5f89 100644 --- a/test/testUtils/helpers/dailyModeHelper.ts +++ b/test/testUtils/helpers/dailyModeHelper.ts @@ -6,7 +6,7 @@ import { EncounterPhase } from "#app/phases/encounter-phase"; import { TitlePhase } from "#app/phases/title-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { GameManagerHelper } from "./gameManagerHelper"; /** @@ -24,12 +24,12 @@ export class DailyModeHelper extends GameManagerHelper { this.game.override.shiny(false).enemyShiny(false); } - this.game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + this.game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const titlePhase = new TitlePhase(); titlePhase.initDailyRun(); }); - this.game.onNextPrompt("TitlePhase", Mode.SAVE_SLOT, () => { + this.game.onNextPrompt("TitlePhase", UiMode.SAVE_SLOT, () => { const uihandler = this.game.scene.ui.getHandler(); uihandler.processInput(Button.ACTION); // select first slot. that's fine }); @@ -51,9 +51,9 @@ export class DailyModeHelper extends GameManagerHelper { if (this.game.scene.battleStyle === BattleStyle.SWITCH) { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), @@ -61,9 +61,9 @@ export class DailyModeHelper extends GameManagerHelper { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index a54028ebca0..edade109966 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -7,7 +7,7 @@ import type { CommandPhase } from "#app/phases/command-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Command } from "#app/ui/command-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Moves } from "#enums/moves"; import { getMovePosition } from "#test/testUtils/gameManagerUtils"; import { GameManagerHelper } from "#test/testUtils/helpers/gameManagerHelper"; @@ -53,10 +53,10 @@ export class MoveHelper extends GameManagerHelper { public select(move: Moves, pkmIndex: 0 | 1 = 0, targetIndex?: BattlerIndex | null) { const movePosition = getMovePosition(this.game.scene, pkmIndex, move); - this.game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - this.game.scene.ui.setMode(Mode.FIGHT, (this.game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); + this.game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { + this.game.scene.ui.setMode(UiMode.FIGHT, (this.game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); }); - this.game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { + this.game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { (this.game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false); }); @@ -76,14 +76,14 @@ export class MoveHelper extends GameManagerHelper { const movePosition = getMovePosition(this.game.scene, pkmIndex, move); this.game.scene.getPlayerParty()[pkmIndex].isTerastallized = false; - this.game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + this.game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { this.game.scene.ui.setMode( - Mode.FIGHT, + UiMode.FIGHT, (this.game.scene.getCurrentPhase() as CommandPhase).getFieldIndex(), Command.TERA, ); }); - this.game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { + this.game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { (this.game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.TERA, movePosition, false); }); @@ -135,16 +135,16 @@ export class MoveHelper extends GameManagerHelper { // if slots are full, queue up inputs to replace existing moves if (this.game.scene.getPlayerParty()[partyIndex].moveset.filter(m => m).length === 4) { - this.game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => { + this.game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { this.game.scene.ui.processInput(Button.ACTION); // "Should a move be forgotten and replaced with XXX?" }); - this.game.onNextPrompt("LearnMovePhase", Mode.SUMMARY, () => { + this.game.onNextPrompt("LearnMovePhase", UiMode.SUMMARY, () => { for (let x = 0; x < (moveSlotIndex ?? 0); x++) { this.game.scene.ui.processInput(Button.DOWN); // Scrolling in summary pane to move position } this.game.scene.ui.processInput(Button.ACTION); if (moveSlotIndex === 4) { - this.game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => { + this.game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { this.game.scene.ui.processInput(Button.ACTION); // "Give up on learning XXX?" }); } diff --git a/test/testUtils/helpers/overridesHelper.ts b/test/testUtils/helpers/overridesHelper.ts index d570a1a4195..6aa382ef59a 100644 --- a/test/testUtils/helpers/overridesHelper.ts +++ b/test/testUtils/helpers/overridesHelper.ts @@ -14,7 +14,7 @@ import { StatusEffect } from "#enums/status-effect"; import type { WeatherType } from "#enums/weather-type"; import { expect, vi } from "vitest"; import { GameManagerHelper } from "./gameManagerHelper"; -import { shiftCharCodes } from "#app/utils"; +import { shiftCharCodes } from "#app/utils/common"; import type { RandomTrainerOverride } from "#app/overrides"; import type { BattleType } from "#enums/battle-type"; diff --git a/test/testUtils/helpers/reloadHelper.ts b/test/testUtils/helpers/reloadHelper.ts index 842cd88b95c..4867a146aaf 100644 --- a/test/testUtils/helpers/reloadHelper.ts +++ b/test/testUtils/helpers/reloadHelper.ts @@ -1,6 +1,6 @@ import { GameManagerHelper } from "./gameManagerHelper"; import { TitlePhase } from "#app/phases/title-phase"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { vi } from "vitest"; import { BattleStyle } from "#app/enums/battle-style"; import { CommandPhase } from "#app/phases/command-phase"; @@ -53,9 +53,9 @@ export class ReloadHelper extends GameManagerHelper { if (this.game.scene.battleStyle === BattleStyle.SWITCH) { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), @@ -63,9 +63,9 @@ export class ReloadHelper extends GameManagerHelper { this.game.onNextPrompt( "CheckSwitchPhase", - Mode.CONFIRM, + UiMode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); + this.game.setMode(UiMode.MESSAGE); this.game.endPhase(); }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 742a6bc8441..3d56c513c00 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -43,7 +43,8 @@ import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { UnavailablePhase } from "#app/phases/unavailable-phase"; import { VictoryPhase } from "#app/phases/victory-phase"; import { PartyHealPhase } from "#app/phases/party-heal-phase"; -import UI, { Mode } from "#app/ui/ui"; +import UI from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { SelectBiomePhase } from "#app/phases/select-biome-phase"; import { MysteryEncounterBattlePhase, @@ -64,7 +65,7 @@ import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase"; export interface PromptHandler { phaseTarget?: string; - mode?: Mode; + mode?: UiMode; callback?: () => void; expireFn?: () => void; awaitingActionInput?: boolean; @@ -487,13 +488,13 @@ export default class PhaseInterceptor { /** * m2m to set mode. - * @param mode - The {@linkcode Mode} to set. + * @param mode - The {@linkcode UiMode} to set. * @param args - Additional arguments to pass to the original method. */ - setMode(mode: Mode, ...args: unknown[]): Promise { + setMode(mode: UiMode, ...args: unknown[]): Promise { const currentPhase = this.scene.getCurrentPhase(); const instance = this.scene.ui; - console.log("setMode", `${Mode[mode]} (=${mode})`, args); + console.log("setMode", `${UiMode[mode]} (=${mode})`, args); const ret = this.originalSetMode.apply(instance, [mode, ...args]); if (!this.phases[currentPhase.constructor.name]) { throw new Error( @@ -546,7 +547,7 @@ export default class PhaseInterceptor { */ addToNextPrompt( phaseTarget: string, - mode: Mode, + mode: UiMode, callback: () => void, expireFn?: () => void, awaitingActionInput = false, diff --git a/test/testUtils/testFileInitialization.ts b/test/testUtils/testFileInitialization.ts index cb2cd57044d..414e34e024b 100644 --- a/test/testUtils/testFileInitialization.ts +++ b/test/testUtils/testFileInitialization.ts @@ -11,7 +11,7 @@ import { initSpecies } from "#app/data/pokemon-species"; import { initAchievements } from "#app/system/achv"; import { initVouchers } from "#app/system/voucher"; import { initStatsKeys } from "#app/ui/game-stats-ui-handler"; -import { setCookie } from "#app/utils"; +import { setCookie } from "#app/utils/cookies"; import { blobToString } from "#test/testUtils/gameManagerUtils"; import { MockConsoleLog } from "#test/testUtils/mocks/mockConsoleLog"; import { mockContext } from "#test/testUtils/mocks/mockContextCanvas"; @@ -21,6 +21,7 @@ import Phaser from "phaser"; import InputText from "phaser3-rex-plugins/plugins/inputtext"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { manageListeners } from "./listenersManager"; +import { initI18n } from "#app/plugins/i18n"; let wasInitialized = false; /** @@ -87,6 +88,7 @@ export function initTestFile() { // initSpecies(); if (!wasInitialized) { wasInitialized = true; + initI18n(); initVouchers(); initAchievements(); initStatsKeys(); diff --git a/test/ui/starter-select.test.ts b/test/ui/starter-select.test.ts index 1d523c3bbd5..b402e02e2d7 100644 --- a/test/ui/starter-select.test.ts +++ b/test/ui/starter-select.test.ts @@ -9,7 +9,7 @@ import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler" import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; import type OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; import type StarterSelectUiHandler from "#app/ui/starter-select-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import { Abilities } from "#enums/abilities"; import { Button } from "#enums/buttons"; import { Species } from "#enums/species"; @@ -44,12 +44,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -60,7 +60,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -74,15 +74,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -104,12 +104,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -121,7 +121,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -135,15 +135,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -166,12 +166,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -185,7 +185,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -199,15 +199,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -231,12 +231,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -248,7 +248,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -262,15 +262,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -292,12 +292,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -309,7 +309,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -323,15 +323,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -352,12 +352,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -371,7 +371,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -385,15 +385,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -414,12 +414,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); @@ -432,7 +432,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -446,15 +446,15 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); }); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); resolve(); @@ -475,12 +475,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT); @@ -492,7 +492,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -507,7 +507,7 @@ describe("UI - Starter select", () => { let starterSelectUiHandler: StarterSelectUiHandler; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { starterSelectUiHandler = game.scene.ui.getHandler() as StarterSelectUiHandler; starterSelectUiHandler.processInput(Button.SUBMIT); resolve(); @@ -519,11 +519,11 @@ describe("UI - Starter select", () => { // expect(starterSelectUiHandler.cursorObj.x).toBe(132 + 4 * 18); // expect(starterSelectUiHandler.cursorObj.y).toBe(10); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); }); @@ -539,12 +539,12 @@ describe("UI - Starter select", () => { }).length; expect(caughtCount).toBe(Object.keys(allSpecies).length); await game.runToTitle(); - game.onNextPrompt("TitlePhase", Mode.TITLE, () => { + game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { const currentPhase = game.scene.getCurrentPhase() as TitlePhase; currentPhase.gameMode = GameModes.CLASSIC; currentPhase.end(); }); - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT); @@ -557,7 +557,7 @@ describe("UI - Starter select", () => { let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); resolve(); @@ -572,7 +572,7 @@ describe("UI - Starter select", () => { let starterSelectUiHandler: StarterSelectUiHandler | undefined; await new Promise(resolve => { - game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.STARTER_SELECT, () => { starterSelectUiHandler = game.scene.ui.getHandler() as StarterSelectUiHandler; starterSelectUiHandler.processInput(Button.SUBMIT); resolve(); @@ -585,11 +585,11 @@ describe("UI - Starter select", () => { expect(starterSelectUiHandler?.cursorObj.x).toBe(53); expect(starterSelectUiHandler?.cursorObj.y).toBe(31); - game.onNextPrompt("SelectStarterPhase", Mode.CONFIRM, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.CONFIRM, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.ACTION); }); - game.onNextPrompt("SelectStarterPhase", Mode.SAVE_SLOT, () => { + game.onNextPrompt("SelectStarterPhase", UiMode.SAVE_SLOT, () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); }); diff --git a/test/ui/transfer-item.test.ts b/test/ui/transfer-item.test.ts index cbbdc1d50ee..f0ea8f84005 100644 --- a/test/ui/transfer-item.test.ts +++ b/test/ui/transfer-item.test.ts @@ -4,7 +4,7 @@ import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; @@ -42,21 +42,21 @@ describe("UI - Transfer Items", () => { game.move.select(Moves.DRAGON_CLAW); - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; handler.setCursor(1); handler.processInput(Button.ACTION); - void game.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER); + void game.scene.ui.setModeWithoutClear(UiMode.PARTY, PartyUiMode.MODIFIER_TRANSFER); }); await game.phaseInterceptor.to("BattleEndPhase"); }); it("check red tint for held item limit in transfer menu", async () => { - game.onNextPrompt("SelectModifierPhase", Mode.PARTY, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler); const handler = game.scene.ui.getHandler() as PartyUiHandler; @@ -79,7 +79,7 @@ describe("UI - Transfer Items", () => { }, 20000); it("check transfer option for pokemon to transfer to", async () => { - game.onNextPrompt("SelectModifierPhase", Mode.PARTY, () => { + game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler); const handler = game.scene.ui.getHandler() as PartyUiHandler; diff --git a/test/ui/type-hints.test.ts b/test/ui/type-hints.test.ts index fcb71186448..08d9806ec7f 100644 --- a/test/ui/type-hints.test.ts +++ b/test/ui/type-hints.test.ts @@ -3,7 +3,7 @@ import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; import { CommandPhase } from "#app/phases/command-phase"; import FightUiHandler from "#app/ui/fight-ui-handler"; -import { Mode } from "#app/ui/ui"; +import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -42,14 +42,14 @@ describe("UI - Type Hints", () => { await game.startBattle([Species.RAYQUAZA]); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { const { ui } = game.scene; const handler = ui.getHandler(); handler.processInput(Button.ACTION); // select "Fight" game.phaseInterceptor.unlock(); }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { + game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { const { ui } = game.scene; const movesContainer = ui.getByName(FightUiHandler.MOVES_CONTAINER_NAME); const dragonClawText = movesContainer @@ -67,14 +67,14 @@ describe("UI - Type Hints", () => { await game.startBattle([Species.RAYQUAZA]); - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => { const { ui } = game.scene; const handler = ui.getHandler(); handler.processInput(Button.ACTION); // select "Fight" game.phaseInterceptor.unlock(); }); - game.onNextPrompt("CommandPhase", Mode.FIGHT, () => { + game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { const { ui } = game.scene; const movesContainer = ui.getByName(FightUiHandler.MOVES_CONTAINER_NAME); const growlText = movesContainer diff --git a/src/utils.test.ts b/test/utils.test.ts similarity index 95% rename from src/utils.test.ts rename to test/utils.test.ts index cc3f2bb1a04..33f7906738c 100644 --- a/src/utils.test.ts +++ b/test/utils.test.ts @@ -1,5 +1,5 @@ import { expect, describe, it, beforeAll } from "vitest"; -import { randomString, padInt } from "./utils"; +import { randomString, padInt } from "#app/utils/common"; import Phaser from "phaser";