From 74553608244d626cd92c11a8d6ea86a3f14a08a6 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sat, 8 Mar 2025 21:31:36 -0600 Subject: [PATCH 1/3] [Misc] Add Wlowscha and SirzBenjie to credits (#5498) --- CREDITS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index 099d410417e..6d884c8fd60 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -364,11 +364,13 @@ In addition to the lists below, please check [the PokéRogue wiki](https://wiki. - Opaquer - OrangeRed - Sam aka Flashfyre (initial developer, started PokéRogue) +- SirzBenjie - sirzento - SN34KZ - Swain aka torranx - Temp aka Tempo-anon - Walker +- Wlowscha (aka Curbio) - Xavion ## Bug/Issue Managers From 408b66f9135004e128d7d737904facc30529c771 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 9 Mar 2025 16:13:25 -0500 Subject: [PATCH 2/3] [Misc][Refactor][GitHub] Ditch eslint for biome, and add a formatter (#5495) Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- .dependency-cruiser.cjs | 210 +- .github/workflows/{eslint.yml => quality.yml} | 9 +- README.md | 13 +- biome.jsonc | 106 + create-test-boilerplate.js | 9 +- dependency-graph.js | 2 +- eslint.config.js | 109 +- index.css | 190 +- lefthook.yml | 8 +- package-lock.json | 14189 ++++++++-------- package.json | 135 +- src/account.ts | 29 +- src/battle-scene.ts | 1335 +- src/battle.ts | 539 +- src/configs/inputs/cfg_keyboard_qwerty.ts | 9 +- src/configs/inputs/configHandler.ts | 9 +- src/configs/inputs/pad_dualshock.ts | 8 +- src/configs/inputs/pad_generic.ts | 15 +- src/configs/inputs/pad_procon.ts | 6 +- src/configs/inputs/pad_unlicensedSNES.ts | 10 +- src/configs/inputs/pad_xbox360.ts | 8 +- src/data/ability.ts | 102 +- src/data/arena-tag.ts | 523 +- src/data/balance/biomes.ts | 10 +- src/data/balance/egg-moves.ts | 4 +- src/data/balance/pokemon-evolutions.ts | 6 +- src/data/battle-anims.ts | 1489 +- src/data/battler-tags.ts | 1027 +- src/data/berry.ts | 44 +- src/data/challenge.ts | 459 +- src/data/daily-run.ts | 77 +- src/data/dialogue.ts | 3053 +--- src/data/egg-hatch-data.ts | 44 +- src/data/egg.ts | 166 +- src/data/exp.ts | 72 +- src/data/gender.ts | 6 +- .../encounters/a-trainers-test-encounter.ts | 320 +- .../encounters/absolute-avarice-encounter.ts | 724 +- .../an-offer-you-cant-refuse-encounter.ts | 286 +- .../encounters/berries-abound-encounter.ts | 457 +- .../encounters/bug-type-superfan-encounter.ts | 622 +- .../encounters/clowning-around-encounter.ts | 712 +- .../encounters/dancing-lessons-encounter.ts | 477 +- .../encounters/dark-deal-encounter.ts | 254 +- .../encounters/delibirdy-encounter.ts | 569 +- .../department-store-sale-encounter.ts | 285 +- .../encounters/field-trip-encounter.ts | 352 +- .../encounters/fiery-fallout-encounter.ts | 424 +- .../encounters/fight-or-flight-encounter.ts | 287 +- .../encounters/fun-and-games-encounter.ts | 237 +- .../global-trade-system-encounter.ts | 874 +- .../encounters/lost-at-sea-encounter.ts | 18 +- .../mysterious-challengers-encounter.ts | 374 +- .../encounters/mysterious-chest-encounter.ts | 354 +- .../encounters/part-timer-encounter.ts | 278 +- .../encounters/safari-zone-encounter.ts | 255 +- .../shady-vitamin-dealer-encounter.ts | 405 +- .../slumbering-snorlax-encounter.ts | 280 +- .../teleporting-hijinks-encounter.ts | 297 +- .../the-expert-pokemon-breeder-encounter.ts | 780 +- .../the-pokemon-salesman-encounter.ts | 262 +- .../encounters/the-strong-stuff-encounter.ts | 356 +- .../the-winstrate-challenge-encounter.ts | 403 +- .../encounters/training-session-encounter.ts | 625 +- .../encounters/trash-to-treasure-encounter.ts | 307 +- .../encounters/uncommon-breed-encounter.ts | 406 +- .../encounters/weird-dream-encounter.ts | 591 +- .../mystery-encounter-dialogue.ts | 1 - .../mystery-encounter-option.ts | 108 +- .../mystery-encounter-requirements.ts | 600 +- .../mystery-encounters/mystery-encounter.ts | 253 +- .../mystery-encounters/mystery-encounters.ts | 126 +- .../can-learn-move-requirement.ts | 25 +- .../requirements/requirement-groups.ts | 21 +- .../utils/encounter-dialogue-utils.ts | 15 +- .../utils/encounter-phase-utils.ts | 498 +- .../utils/encounter-pokemon-utils.ts | 399 +- .../encounter-transformation-sequence.ts | 134 +- src/data/nature.ts | 16 +- src/data/pokeball.ts | 41 +- src/data/pokemon-forms.ts | 150 +- src/data/pokemon-species.ts | 560 +- src/data/splash-messages.ts | 26 +- src/data/status-effect.ts | 48 +- src/data/terrain.ts | 20 +- src/data/trainer-config.ts | 6591 +++++-- src/data/trainer-names.ts | 2730 ++- src/data/type.ts | 50 +- src/data/weather.ts | 74 +- src/debug.js | 4 +- src/enums/stat.ts | 6 +- src/events/arena.ts | 16 +- src/events/battle-scene.ts | 16 +- src/events/egg.ts | 4 +- src/field/anims.ts | 51 +- src/field/arena.ts | 326 +- src/field/damage-number-handler.ts | 62 +- src/field/mystery-encounter-intro.ts | 66 +- src/field/pokemon-sprite-sparkle-handler.ts | 24 +- src/field/pokemon.ts | 4338 +++-- src/field/trainer.ts | 364 +- src/game-mode.ts | 120 +- src/inputs-controller.ts | 388 +- src/interfaces/locales.ts | 108 +- src/loading-scene.ts | 46 +- src/main.ts | 68 +- src/messages.ts | 12 +- src/modifier/modifier-tier.ts | 2 +- src/modifier/modifier-type.ts | 2444 ++- src/modifier/modifier.ts | 788 +- src/phases/add-enemy-buff-modifier-phase.ts | 21 +- src/phases/attempt-capture-phase.ts | 211 +- src/phases/attempt-run-phase.ts | 28 +- src/phases/battle-end-phase.ts | 11 +- src/phases/battle-phase.ts | 6 +- src/phases/berry-phase.ts | 14 +- src/phases/check-status-effect-phase.ts | 6 +- src/phases/check-switch-phase.ts | 45 +- src/phases/command-phase.ts | 296 +- src/phases/common-anim-phase.ts | 7 +- src/phases/damage-anim-phase.ts | 18 +- src/phases/egg-hatch-phase.ts | 99 +- src/phases/egg-lapse-phase.ts | 65 +- src/phases/egg-summary-phase.ts | 2 - src/phases/encounter-phase.ts | 287 +- src/phases/end-card-phase.ts | 34 +- src/phases/end-evolution-phase.ts | 5 - src/phases/enemy-command-phase.ts | 46 +- src/phases/evolution-phase.ts | 307 +- src/phases/exp-phase.ts | 27 +- src/phases/faint-phase.ts | 90 +- src/phases/field-phase.ts | 4 +- src/phases/form-change-phase.ts | 41 +- src/phases/game-over-modifier-reward-phase.ts | 8 +- src/phases/game-over-phase.ts | 128 +- src/phases/hide-party-exp-bar-phase.ts | 4 - src/phases/learn-move-phase.ts | 111 +- src/phases/level-cap-phase.ts | 14 +- src/phases/level-up-phase.ts | 23 +- src/phases/load-move-anim-phase.ts | 2 +- src/phases/login-phase.ts | 41 +- src/phases/message-phase.ts | 36 +- src/phases/modifier-reward-phase.ts | 10 +- src/phases/money-reward-phase.ts | 4 +- src/phases/move-anim-phase.ts | 2 +- src/phases/move-anim-test-phase.ts | 28 +- src/phases/move-charge-phase.ts | 16 +- src/phases/move-effect-phase.ts | 258 +- src/phases/move-end-phase.ts | 4 - src/phases/move-phase.ts | 140 +- src/phases/mystery-encounter-phases.ts | 121 +- src/phases/new-biome-encounter-phase.ts | 4 +- src/phases/next-encounter-phase.ts | 15 +- src/phases/obtain-status-effect-phase.ts | 20 +- src/phases/party-heal-phase.ts | 2 +- src/phases/party-member-pokemon-phase.ts | 4 +- src/phases/pokemon-anim-phase.ts | 77 +- src/phases/pokemon-heal-phase.ts | 23 +- src/phases/pokemon-phase.ts | 5 +- src/phases/pokemon-transform-phase.ts | 13 +- src/phases/post-game-over-phase.ts | 18 +- src/phases/post-summon-phase.ts | 13 +- src/phases/post-turn-status-effect-phase.ts | 14 +- src/phases/quiet-form-change-phase.ts | 55 +- src/phases/reload-session-phase.ts | 16 +- src/phases/return-phase.ts | 2 +- src/phases/revival-blessing-phase.ts | 10 +- src/phases/ribbon-modifier-reward-phase.ts | 21 +- src/phases/scan-ivs-phase.ts | 43 +- src/phases/select-biome-phase.ts | 26 +- src/phases/select-gender-phase.ts | 8 +- src/phases/select-modifier-phase.ts | 292 +- src/phases/select-starter-phase.ts | 24 +- src/phases/select-target-phase.ts | 8 +- src/phases/show-ability-phase.ts | 3 +- src/phases/show-party-exp-bar-phase.ts | 12 +- src/phases/show-trainer-phase.ts | 2 +- src/phases/stat-stage-change-phase.ts | 178 +- src/phases/summon-missing-phase.ts | 6 +- src/phases/summon-phase.ts | 77 +- src/phases/switch-biome-phase.ts | 10 +- src/phases/switch-phase.ts | 53 +- src/phases/switch-summon-phase.ts | 121 +- src/phases/tera-phase.ts | 8 +- src/phases/title-phase.ts | 273 +- src/phases/toggle-double-position-phase.ts | 21 +- src/phases/trainer-message-test-phase.ts | 22 +- src/phases/trainer-victory-phase.ts | 97 +- src/phases/turn-end-phase.ts | 20 +- src/phases/turn-init-phase.ts | 12 +- src/phases/turn-start-phase.ts | 89 +- src/phases/unlock-phase.ts | 17 +- src/phases/victory-phase.ts | 39 +- src/phases/weather-effect-phase.ts | 32 +- src/pipelines/field-sprite.ts | 38 +- src/pipelines/invert.ts | 6 +- src/pipelines/sprite.ts | 139 +- src/plugins/api/api-base.ts | 4 +- src/plugins/api/pokerogue-account-api.ts | 17 +- src/plugins/api/pokerogue-admin-api.ts | 49 +- src/plugins/api/pokerogue-api.ts | 6 +- src/plugins/api/pokerogue-savedata-api.ts | 2 +- .../api/pokerogue-session-savedata-api.ts | 3 +- src/plugins/cache-busted-loader-plugin.ts | 2 +- src/plugins/i18n.ts | 71 +- src/plugins/vite/vite-minify-json-plugin.ts | 8 +- src/scene-base.ts | 29 +- src/system/achv.ts | 757 +- src/system/arena-data.ts | 14 +- src/system/egg-data.ts | 28 +- src/system/game-data.ts | 831 +- src/system/game-speed.ts | 36 +- src/system/modifier-data.ts | 14 +- src/system/pokemon-data.ts | 65 +- src/system/session-history.ts | 4 +- src/system/settings/settings-gamepad.ts | 105 +- src/system/settings/settings-keyboard.ts | 142 +- src/system/settings/settings.ts | 345 +- src/system/trainer-data.ts | 8 +- src/system/unlockables.ts | 2 +- .../version_migration/version_converter.ts | 17 +- .../version_migration/versions/v1_0_4.ts | 82 +- .../version_migration/versions/v1_7_0.ts | 17 +- src/system/voucher.ts | 40 +- src/timed-event-manager.ts | 257 +- src/touch-controls.ts | 33 +- src/tutorial.ts | 74 +- src/ui-inputs.ts | 140 +- src/ui/ability-bar.ts | 15 +- src/ui/abstact-option-select-ui-handler.ts | 72 +- src/ui/achv-bar.ts | 47 +- src/ui/achvs-ui-handler.ts | 71 +- src/ui/admin-ui-handler.ts | 210 +- src/ui/arena-flyout.ts | 124 +- src/ui/autocomplete-ui-handler.ts | 11 +- src/ui/awaitable-ui-handler.ts | 11 +- src/ui/ball-ui-handler.ts | 17 +- src/ui/base-stats-overlay.ts | 25 +- src/ui/battle-flyout.ts | 60 +- src/ui/battle-info.ts | 221 +- src/ui/battle-message-ui-handler.ts | 61 +- src/ui/bgm-bar.ts | 23 +- src/ui/candy-bar.ts | 19 +- src/ui/challenges-select-ui-handler.ts | 118 +- src/ui/char-sprite.ts | 14 +- src/ui/command-ui-handler.ts | 50 +- src/ui/confirm-ui-handler.ts | 57 +- src/ui/daily-run-scoreboard.ts | 125 +- src/ui/dropdown.ts | 174 +- src/ui/egg-gacha-ui-handler.ts | 177 +- src/ui/egg-hatch-scene-handler.ts | 4 +- src/ui/egg-list-ui-handler.ts | 16 +- src/ui/egg-summary-ui-handler.ts | 40 +- src/ui/evolution-scene-handler.ts | 4 +- src/ui/fight-ui-handler.ts | 41 +- src/ui/filter-bar.ts | 39 +- src/ui/filter-text.ts | 44 +- src/ui/form-modal-ui-handler.ts | 33 +- src/ui/game-stats-ui-handler.ts | 109 +- src/ui/hatched-pokemon-container.ts | 4 +- src/ui/loading-modal-ui-handler.ts | 4 +- src/ui/login-form-ui-handler.ts | 58 +- src/ui/menu-ui-handler.ts | 385 +- src/ui/message-ui-handler.ts | 42 +- src/ui/modal-ui-handler.ts | 39 +- src/ui/modifier-select-ui-handler.ts | 230 +- src/ui/move-info-overlay.ts | 86 +- src/ui/mystery-encounter-ui-handler.ts | 185 +- src/ui/party-exp-bar.ts | 16 +- src/ui/party-ui-handler.ts | 675 +- src/ui/pokeball-tray.ts | 36 +- src/ui/pokedex-info-overlay.ts | 57 +- src/ui/pokedex-mon-container.ts | 27 +- src/ui/pokedex-page-ui-handler.ts | 918 +- src/ui/pokedex-scan-ui-handler.ts | 39 +- src/ui/pokedex-ui-handler.ts | 653 +- src/ui/pokemon-hatch-info-container.ts | 22 +- src/ui/pokemon-icon-anim-handler.ts | 12 +- src/ui/pokemon-info-container.ts | 139 +- src/ui/registration-form-ui-handler.ts | 55 +- src/ui/rename-form-ui-handler.ts | 14 +- src/ui/run-history-ui-handler.ts | 82 +- src/ui/run-info-ui-handler.ts | 390 +- src/ui/save-slot-select-ui-handler.ts | 120 +- src/ui/saving-icon-handler.ts | 4 +- src/ui/scroll-bar.ts | 19 +- src/ui/scrollable-grid-handler.ts | 9 +- src/ui/session-reload-modal-ui-handler.ts | 18 +- .../settings/abstract-binding-ui-handler.ts | 117 +- .../abstract-control-settings-ui-handler.ts | 117 +- .../settings/abstract-settings-ui-handler.ts | 122 +- src/ui/settings/gamepad-binding-ui-handler.ts | 23 +- .../settings/keyboard-binding-ui-handler.ts | 3 - .../settings/move-touch-controls-handler.ts | 77 +- src/ui/settings/navigationMenu.ts | 17 +- src/ui/settings/settings-audio-ui-handler.ts | 2 +- .../settings/settings-display-ui-handler.ts | 2 +- .../settings/settings-gamepad-ui-handler.ts | 55 +- .../settings/settings-keyboard-ui-handler.ts | 78 +- src/ui/settings/shiny_icons.json | 78 +- src/ui/starter-container.ts | 16 +- src/ui/starter-select-ui-handler.ts | 1747 +- src/ui/stats-container.ts | 89 +- src/ui/summary-ui-handler.ts | 293 +- src/ui/target-select-ui-handler.ts | 36 +- src/ui/test-dialogue-ui-handler.ts | 67 +- src/ui/text.ts | 106 +- src/ui/time-of-day-widget.ts | 69 +- src/ui/title-ui-handler.ts | 38 +- src/ui/ui-handler.ts | 6 +- src/ui/ui-theme.ts | 125 +- src/ui/ui.ts | 101 +- src/ui/unavailable-modal-ui-handler.ts | 28 +- src/utils.test.ts | 1 - src/utils.ts | 142 +- test/abilities/ability_duplication.test.ts | 10 +- test/abilities/ability_timing.test.ts | 16 +- test/abilities/analytic.test.ts | 18 +- test/abilities/arena_trap.test.ts | 14 +- test/abilities/aroma_veil.test.ts | 8 +- test/abilities/aura_break.test.ts | 10 +- test/abilities/battery.test.ts | 8 +- test/abilities/battle_bond.test.ts | 12 +- test/abilities/beast_boost.test.ts | 24 +- test/abilities/commander.test.ts | 50 +- test/abilities/competitive.test.ts | 11 +- test/abilities/contrary.test.ts | 18 +- test/abilities/corrosion.test.ts | 4 +- test/abilities/costar.test.ts | 74 +- test/abilities/dancer.test.ts | 28 +- test/abilities/defiant.test.ts | 11 +- test/abilities/desolate-land.test.ts | 27 +- test/abilities/disguise.test.ts | 29 +- test/abilities/dry_skin.test.ts | 8 +- test/abilities/early_bird.test.ts | 8 +- test/abilities/flash_fire.test.ts | 33 +- test/abilities/flower_gift.test.ts | 24 +- test/abilities/forecast.test.ts | 202 +- test/abilities/friend_guard.test.ts | 20 +- test/abilities/galvanize.test.ts | 7 +- test/abilities/good_as_gold.test.ts | 38 +- test/abilities/gorilla_tactics.test.ts | 12 +- test/abilities/gulp_missile.test.ts | 58 +- test/abilities/heatproof.test.ts | 10 +- test/abilities/honey_gather.test.ts | 8 +- test/abilities/hustle.test.ts | 10 +- test/abilities/hyper_cutter.test.ts | 8 +- test/abilities/ice_face.test.ts | 50 +- test/abilities/illuminate.test.ts | 6 +- test/abilities/imposter.test.ts | 12 +- test/abilities/infiltrator.test.ts | 28 +- test/abilities/intimidate.test.ts | 24 +- test/abilities/intrepid_sword.test.ts | 7 +- test/abilities/libero.test.ts | 392 +- test/abilities/magic_bounce.test.ts | 159 +- test/abilities/magic_guard.test.ts | 377 +- test/abilities/mimicry.test.ts | 17 +- test/abilities/mirror_armor.test.ts | 52 +- test/abilities/moody.test.ts | 75 +- test/abilities/moxie.test.ts | 40 +- test/abilities/mummy.test.ts | 6 +- test/abilities/mycelium_might.test.ts | 24 +- test/abilities/neutralizing_gas.test.ts | 45 +- test/abilities/no_guard.test.ts | 12 +- test/abilities/parental_bond.test.ts | 523 +- test/abilities/pastel_veil.test.ts | 6 +- test/abilities/perish_body.test.ts | 22 +- test/abilities/power_construct.test.ts | 95 +- test/abilities/power_spot.test.ts | 8 +- test/abilities/protean.test.ts | 392 +- test/abilities/protosynthesis.test.ts | 13 +- test/abilities/quick_draw.test.ts | 41 +- test/abilities/sand_spit.test.ts | 13 +- test/abilities/sand_veil.test.ts | 58 +- test/abilities/sap_sipper.test.ts | 21 +- test/abilities/schooling.test.ts | 50 +- test/abilities/screen_cleaner.test.ts | 14 +- test/abilities/seed_sower.test.ts | 13 +- test/abilities/serene_grace.test.ts | 8 +- test/abilities/sheer_force.test.ts | 41 +- test/abilities/shield_dust.test.ts | 35 +- test/abilities/shields_down.test.ts | 220 +- test/abilities/simple.test.ts | 6 +- test/abilities/speed_boost.test.ts | 134 +- test/abilities/stakeout.test.ts | 18 +- test/abilities/stall.test.ts | 22 +- test/abilities/steely_spirit.test.ts | 18 +- test/abilities/sturdy.test.ts | 78 +- test/abilities/supreme_overlord.test.ts | 68 +- test/abilities/sweet_veil.test.ts | 14 +- test/abilities/synchronize.test.ts | 10 +- test/abilities/tera_shell.test.ts | 165 +- test/abilities/trace.test.ts | 6 +- test/abilities/unburden.test.ts | 87 +- test/abilities/unseen_fist.test.ts | 74 +- test/abilities/volt_absorb.test.ts | 8 +- test/abilities/wandering_spirit.test.ts | 8 +- test/abilities/wimp_out.test.ts | 307 +- test/abilities/wind_power.test.ts | 10 +- test/abilities/wind_rider.test.ts | 24 +- test/abilities/wonder_skin.test.ts | 10 +- test/abilities/zen_mode.test.ts | 13 +- test/abilities/zero_to_hero.test.ts | 9 +- test/account.test.ts | 12 +- test/achievements/achievement.test.ts | 52 +- test/arena/arena_gravity.test.ts | 27 +- test/arena/grassy_terrain.test.ts | 6 +- test/arena/weather_fog.test.ts | 10 +- test/arena/weather_hail.test.ts | 12 +- test/arena/weather_sandstorm.test.ts | 10 +- test/arena/weather_strong_winds.test.ts | 12 +- test/battle/ability_swap.test.ts | 8 +- test/battle/battle-order.test.ts | 51 +- test/battle/battle.test.ts | 115 +- test/battle/damage_calculation.test.ts | 44 +- test/battle/double_battle.test.ts | 11 +- test/battle/inverse_battle.test.ts | 97 +- test/battle/special_battle.test.ts | 105 +- test/battlerTags/octolock.test.ts | 4 +- test/battlerTags/stockpiling.test.ts | 29 +- test/battlerTags/substitute.test.ts | 243 +- test/boss-pokemon.test.ts | 34 +- test/daily_mode.test.ts | 18 +- test/data/splash_messages.test.ts | 6 +- test/data/status_effect.test.ts | 12 +- test/eggs/egg.test.ts | 166 +- test/eggs/manaphy-egg.test.ts | 31 +- test/endless_boss.test.ts | 16 +- test/enemy_command.test.ts | 90 +- test/escape-calculations.test.ts | 109 +- test/evolution.test.ts | 26 +- test/field/pokemon.test.ts | 34 +- test/final_boss.test.ts | 15 +- test/game-mode.test.ts | 4 +- test/imports.test.ts | 1 - test/inputs/inputs.test.ts | 16 +- test/internals.test.ts | 4 +- test/items/dire_hit.test.ts | 33 +- .../double_battle_chance_booster.test.ts | 45 +- test/items/eviolite.test.ts | 45 +- test/items/exp_booster.test.ts | 2 +- test/items/grip_claw.test.ts | 16 +- test/items/leek.test.ts | 39 +- test/items/leftovers.test.ts | 7 +- test/items/light_ball.test.ts | 82 +- test/items/lock_capsule.test.ts | 9 +- test/items/metal_powder.test.ts | 82 +- test/items/multi_lens.test.ts | 62 +- test/items/quick_powder.test.ts | 82 +- test/items/scope_lens.test.ts | 7 +- test/items/temp_stat_stage_booster.test.ts | 71 +- test/items/thick_club.test.ts | 108 +- test/items/toxic_orb.test.ts | 10 +- test/misc.test.ts | 22 +- test/moves/after_you.test.ts | 7 +- test/moves/alluring_voice.test.ts | 8 +- test/moves/aromatherapy.test.ts | 14 +- test/moves/assist.test.ts | 34 +- test/moves/astonish.test.ts | 38 +- test/moves/aurora_veil.test.ts | 65 +- test/moves/autotomize.test.ts | 121 +- test/moves/baddy_bad.test.ts | 4 +- test/moves/baneful_bunker.test.ts | 80 +- test/moves/baton_pass.test.ts | 34 +- test/moves/beak_blast.test.ts | 124 +- test/moves/beat_up.test.ts | 68 +- test/moves/belly_drum.test.ts | 93 +- test/moves/burning_jealousy.test.ts | 29 +- test/moves/camouflage.test.ts | 6 +- test/moves/ceaseless_edge.test.ts | 115 +- test/moves/chilly_reception.test.ts | 28 +- test/moves/chloroblast.test.ts | 4 +- test/moves/clangorous_soul.test.ts | 135 +- test/moves/copycat.test.ts | 10 +- test/moves/crafty_shield.test.ts | 97 +- test/moves/defog.test.ts | 10 +- test/moves/destiny_bond.test.ts | 38 +- test/moves/diamond_storm.test.ts | 4 +- test/moves/dig.test.ts | 14 +- test/moves/disable.test.ts | 48 +- test/moves/dive.test.ts | 18 +- test/moves/doodle.test.ts | 11 +- test/moves/double_team.test.ts | 8 +- test/moves/dragon_cheer.test.ts | 20 +- test/moves/dragon_rage.test.ts | 8 +- test/moves/dragon_tail.test.ts | 81 +- test/moves/dynamax_cannon.test.ts | 38 +- test/moves/effectiveness.test.ts | 90 +- test/moves/electrify.test.ts | 8 +- test/moves/electro_shot.test.ts | 12 +- test/moves/encore.test.ts | 22 +- test/moves/endure.test.ts | 8 +- test/moves/entrainment.test.ts | 6 +- test/moves/fairy_lock.test.ts | 16 +- test/moves/fake_out.test.ts | 14 +- test/moves/fell_stinger.test.ts | 53 +- test/moves/fillet_away.test.ts | 111 +- test/moves/fissure.test.ts | 2 +- test/moves/flame_burst.test.ts | 32 +- test/moves/flower_shield.test.ts | 14 +- test/moves/fly.test.ts | 16 +- test/moves/focus_punch.test.ts | 121 +- test/moves/follow_me.test.ts | 123 +- test/moves/foresight.test.ts | 4 +- test/moves/forests_curse.test.ts | 4 +- test/moves/freeze_dry.test.ts | 86 +- test/moves/freezy_frost.test.ts | 104 +- test/moves/fusion_bolt.test.ts | 8 +- test/moves/fusion_flare.test.ts | 8 +- test/moves/fusion_flare_bolt.test.ts | 95 +- test/moves/future_sight.test.ts | 4 +- test/moves/gastro_acid.test.ts | 5 +- test/moves/geomancy.test.ts | 18 +- test/moves/gigaton_hammer.test.ts | 10 +- test/moves/glaive_rush.test.ts | 30 +- test/moves/growth.test.ts | 8 +- test/moves/grudge.test.ts | 20 +- test/moves/guard_split.test.ts | 12 +- test/moves/guard_swap.test.ts | 6 +- test/moves/hard_press.test.ts | 16 +- test/moves/haze.test.ts | 4 +- test/moves/heal_bell.test.ts | 14 +- test/moves/heal_block.test.ts | 39 +- test/moves/heart_swap.test.ts | 6 +- test/moves/hyper_beam.test.ts | 43 +- test/moves/imprison.test.ts | 17 +- test/moves/instruct.test.ts | 268 +- test/moves/jaw_lock.test.ts | 162 +- test/moves/lash_out.test.ts | 8 +- test/moves/last_respects.test.ts | 76 +- test/moves/light_screen.test.ts | 47 +- test/moves/lucky_chant.test.ts | 94 +- test/moves/lunar_blessing.test.ts | 11 +- test/moves/lunar_dance.test.ts | 10 +- test/moves/magic_coat.test.ts | 115 +- test/moves/magnet_rise.test.ts | 4 +- test/moves/make_it_rain.test.ts | 11 +- test/moves/mat_block.test.ts | 82 +- test/moves/metal_burst.test.ts | 14 +- test/moves/metronome.test.ts | 8 +- test/moves/miracle_eye.test.ts | 4 +- test/moves/mirror_move.test.ts | 22 +- test/moves/mist.test.ts | 4 +- test/moves/moongeist_beam.test.ts | 10 +- test/moves/multi_target.test.ts | 21 +- test/moves/nightmare.test.ts | 7 +- test/moves/obstruct.test.ts | 5 +- test/moves/octolock.test.ts | 16 +- test/moves/order_up.test.ts | 37 +- test/moves/parting_shot.test.ts | 104 +- test/moves/plasma_fists.test.ts | 23 +- test/moves/pledge_moves.test.ts | 424 +- test/moves/powder.test.ts | 405 +- test/moves/power_shift.test.ts | 4 +- test/moves/power_split.test.ts | 12 +- test/moves/power_swap.test.ts | 6 +- test/moves/power_trick.test.ts | 14 +- test/moves/protect.test.ts | 112 +- test/moves/psycho_shift.test.ts | 4 +- test/moves/purify.test.ts | 56 +- test/moves/quash.test.ts | 18 +- test/moves/quick_guard.test.ts | 99 +- test/moves/rage_fist.test.ts | 56 +- test/moves/rage_powder.test.ts | 65 +- test/moves/reflect.test.ts | 55 +- test/moves/reflect_type.test.ts | 12 +- test/moves/relic_song.test.ts | 12 +- test/moves/retaliate.test.ts | 6 +- test/moves/revival_blessing.test.ts | 20 +- test/moves/role_play.test.ts | 6 +- test/moves/rollout.test.ts | 8 +- test/moves/roost.test.ts | 354 +- test/moves/round.test.ts | 17 +- test/moves/safeguard.test.ts | 33 +- test/moves/scale_shot.test.ts | 8 +- test/moves/secret_power.test.ts | 58 +- test/moves/shed_tail.test.ts | 6 +- test/moves/shell_side_arm.test.ts | 14 +- test/moves/shell_trap.test.ts | 160 +- test/moves/simple_beam.test.ts | 4 +- test/moves/sketch.test.ts | 20 +- test/moves/skill_swap.test.ts | 6 +- test/moves/sleep_talk.test.ts | 14 +- test/moves/solar_beam.test.ts | 10 +- test/moves/sparkly_swirl.test.ts | 18 +- test/moves/spectral_thief.test.ts | 36 +- test/moves/speed_swap.test.ts | 6 +- test/moves/spikes.test.ts | 10 +- test/moves/spit_up.test.ts | 30 +- test/moves/spotlight.test.ts | 55 +- test/moves/steamroller.test.ts | 10 +- test/moves/stockpile.test.ts | 19 +- test/moves/substitute.test.ts | 667 +- test/moves/swallow.test.ts | 32 +- test/moves/syrup_bomb.test.ts | 88 +- test/moves/tackle.test.ts | 14 +- test/moves/tail_whip.test.ts | 10 +- test/moves/tailwind.test.ts | 9 +- test/moves/tar_shot.test.ts | 18 +- test/moves/taunt.test.ts | 6 +- test/moves/telekinesis.test.ts | 25 +- test/moves/tera_blast.test.ts | 381 +- test/moves/tera_starstorm.test.ts | 10 +- test/moves/thousand_arrows.test.ts | 84 +- test/moves/throat_chop.test.ts | 6 +- test/moves/thunder_wave.test.ts | 3 +- test/moves/tidy_up.test.ts | 26 +- test/moves/torment.test.ts | 6 +- test/moves/toxic.test.ts | 22 +- test/moves/toxic_spikes.test.ts | 22 +- test/moves/transform.test.ts | 17 +- test/moves/trick_or_treat.test.ts | 4 +- test/moves/triple_arrows.test.ts | 6 +- test/moves/u_turn.test.ts | 17 +- test/moves/upper_hand.test.ts | 20 +- test/moves/whirlwind.test.ts | 34 +- test/moves/wide_guard.test.ts | 99 +- test/moves/will_o_wisp.test.ts | 6 +- .../mystery-encounter/encounter-test-utils.ts | 107 +- .../a-trainers-test-encounter.test.ts | 26 +- .../absolute-avarice-encounter.test.ts | 49 +- ...an-offer-you-cant-refuse-encounter.test.ts | 41 +- .../berries-abound-encounter.test.ts | 26 +- .../bug-type-superfan-encounter.test.ts | 104 +- .../clowning-around-encounter.test.ts | 54 +- .../dancing-lessons-encounter.test.ts | 26 +- .../encounters/delibirdy-encounter.test.ts | 29 +- .../department-store-sale-encounter.test.ts | 40 +- .../encounters/field-trip-encounter.test.ts | 106 +- .../fiery-fallout-encounter.test.ts | 65 +- .../fight-or-flight-encounter.test.ts | 26 +- .../fun-and-games-encounter.test.ts | 41 +- .../global-trade-system-encounter.test.ts | 14 +- .../encounters/lost-at-sea-encounter.test.ts | 37 +- .../mysterious-challengers-encounter.test.ts | 91 +- .../encounters/part-timer-encounter.test.ts | 39 +- .../encounters/safari-zone.test.ts | 24 +- .../teleporting-hijinks-encounter.test.ts | 52 +- .../the-expert-breeder-encounter.test.ts | 70 +- .../the-pokemon-salesman-encounter.test.ts | 18 +- .../the-strong-stuff-encounter.test.ts | 52 +- .../the-winstrate-challenge-encounter.test.ts | 98 +- .../trash-to-treasure-encounter.test.ts | 48 +- .../uncommon-breed-encounter.test.ts | 30 +- .../encounters/weird-dream-encounter.test.ts | 55 +- .../mystery-encounter-utils.test.ts | 49 +- .../mystery-encounter.test.ts | 6 +- test/phases/form-change-phase.test.ts | 14 +- test/phases/frenzy-move-reset.test.ts | 28 +- test/phases/game-over-phase.test.ts | 6 +- test/phases/learn-move-phase.test.ts | 65 +- test/phases/mystery-encounter-phase.test.ts | 113 +- test/phases/select-modifier-phase.test.ts | 129 +- .../plugins/api/pokerogue-account-api.test.ts | 14 +- test/plugins/api/pokerogue-admin-api.test.ts | 28 +- .../pokerogue-session-savedata-api.test.ts | 12 +- .../api/pokerogue-system-savedata-api.test.ts | 8 +- test/reload.test.ts | 11 +- test/settingMenu/helpers/inGameManip.ts | 4 +- test/settingMenu/helpers/menuManip.ts | 8 +- test/settingMenu/rebinding_setting.test.ts | 267 +- test/sprites/pokemonSprite.test.ts | 29 +- test/sprites/spritesUtils.ts | 6 +- test/system/game_data.test.ts | 24 +- test/testUtils/TextInterceptor.ts | 18 +- test/testUtils/errorInterceptor.ts | 5 +- test/testUtils/gameManager.ts | 171 +- test/testUtils/gameManagerUtils.ts | 38 +- test/testUtils/gameWrapper.ts | 53 +- test/testUtils/helpers/challengeModeHelper.ts | 27 +- test/testUtils/helpers/classicModeHelper.ts | 27 +- test/testUtils/helpers/dailyModeHelper.ts | 27 +- test/testUtils/helpers/moveHelper.ts | 25 +- test/testUtils/helpers/overridesHelper.ts | 16 +- test/testUtils/helpers/reloadHelper.ts | 34 +- test/testUtils/helpers/settingsHelper.ts | 6 +- test/testUtils/inputsHandler.ts | 30 +- test/testUtils/mocks/mockClock.ts | 1 - test/testUtils/mocks/mockConsoleLog.ts | 44 +- test/testUtils/mocks/mockFetch.ts | 13 +- test/testUtils/mocks/mockLoader.ts | 22 +- test/testUtils/mocks/mockLocalStorage.ts | 4 +- test/testUtils/mocks/mockTextureManager.ts | 16 +- test/testUtils/mocks/mockVideoGameObject.ts | 2 - .../mocks/mocksContainer/mockContainer.ts | 53 +- .../mocks/mocksContainer/mockGraphics.ts | 28 +- .../mocks/mocksContainer/mockImage.ts | 1 - .../mocks/mocksContainer/mockNineslice.ts | 3 +- .../mocks/mocksContainer/mockPolygon.ts | 4 +- .../mocks/mocksContainer/mockRectangle.ts | 21 +- .../mocks/mocksContainer/mockSprite.ts | 16 +- .../mocks/mocksContainer/mockText.ts | 53 +- .../mocks/mocksContainer/mockTexture.ts | 5 +- test/testUtils/phaseInterceptor.ts | 172 +- test/ui/battle_info.test.ts | 11 +- test/ui/starter-select.test.ts | 73 +- test/ui/transfer-item.test.ts | 22 +- test/ui/type-hints.test.ts | 12 +- test/vitest.setup.ts | 8 +- tsconfig.json | 58 +- vite.config.ts | 70 +- 701 files changed, 55737 insertions(+), 38672 deletions(-) rename .github/workflows/{eslint.yml => quality.yml} (88%) create mode 100644 biome.jsonc diff --git a/.dependency-cruiser.cjs b/.dependency-cruiser.cjs index 8c6dff55c8c..b7de80a70de 100644 --- a/.dependency-cruiser.cjs +++ b/.dependency-cruiser.cjs @@ -2,92 +2,86 @@ module.exports = { forbidden: [ { - name: 'no-circular-at-runtime', - severity: 'warn', + name: "no-circular-at-runtime", + severity: "warn", comment: - 'This dependency is part of a circular relationship. You might want to revise ' + - 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ', + "This dependency is part of a circular relationship. You might want to revise " + + "your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ", from: {}, to: { circular: true, viaOnly: { - dependencyTypesNot: [ - 'type-only' - ] - } - } + dependencyTypesNot: ["type-only"], + }, + }, }, { - name: 'no-orphans', + name: "no-orphans", comment: "This is an orphan module - it's likely not used (anymore?). Either use it or " + "remove it. If it's logical this module is an orphan (i.e. it's a config file), " + "add an exception for it in your dependency-cruiser configuration. By default " + "this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " + "files (.d.ts), tsconfig.json and some of the babel and webpack configs.", - severity: 'warn', + severity: "warn", from: { orphan: true, pathNot: [ - '(^|/)[.][^/]+[.](?:js|cjs|mjs|ts|cts|mts|json)$', // dot files - '[.]d[.]ts$', // TypeScript declaration files - '(^|/)tsconfig[.]json$', // TypeScript config - '(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$' // other configs - ] + "(^|/)[.][^/]+[.](?:js|cjs|mjs|ts|cts|mts|json)$", // dot files + "[.]d[.]ts$", // TypeScript declaration files + "(^|/)tsconfig[.]json$", // TypeScript config + "(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$", // other configs + ], }, to: {}, }, { - name: 'no-deprecated-core', + name: "no-deprecated-core", comment: - 'A module depends on a node core module that has been deprecated. Find an alternative - these are ' + + "A module depends on a node core module that has been deprecated. Find an alternative - these are " + "bound to exist - node doesn't deprecate lightly.", - severity: 'warn', + severity: "warn", from: {}, to: { - dependencyTypes: [ - 'core' - ], + dependencyTypes: ["core"], path: [ - '^v8/tools/codemap$', - '^v8/tools/consarray$', - '^v8/tools/csvparser$', - '^v8/tools/logreader$', - '^v8/tools/profile_view$', - '^v8/tools/profile$', - '^v8/tools/SourceMap$', - '^v8/tools/splaytree$', - '^v8/tools/tickprocessor-driver$', - '^v8/tools/tickprocessor$', - '^node-inspect/lib/_inspect$', - '^node-inspect/lib/internal/inspect_client$', - '^node-inspect/lib/internal/inspect_repl$', - '^async_hooks$', - '^punycode$', - '^domain$', - '^constants$', - '^sys$', - '^_linklist$', - '^_stream_wrap$' + "^v8/tools/codemap$", + "^v8/tools/consarray$", + "^v8/tools/csvparser$", + "^v8/tools/logreader$", + "^v8/tools/profile_view$", + "^v8/tools/profile$", + "^v8/tools/SourceMap$", + "^v8/tools/splaytree$", + "^v8/tools/tickprocessor-driver$", + "^v8/tools/tickprocessor$", + "^node-inspect/lib/_inspect$", + "^node-inspect/lib/internal/inspect_client$", + "^node-inspect/lib/internal/inspect_repl$", + "^async_hooks$", + "^punycode$", + "^domain$", + "^constants$", + "^sys$", + "^_linklist$", + "^_stream_wrap$", ], - } + }, }, { - name: 'not-to-deprecated', + name: "not-to-deprecated", comment: - 'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' + - 'version of that module, or find an alternative. Deprecated modules are a security risk.', - severity: 'warn', + "This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later " + + "version of that module, or find an alternative. Deprecated modules are a security risk.", + severity: "warn", from: {}, to: { - dependencyTypes: [ - 'deprecated' - ] - } + dependencyTypes: ["deprecated"], + }, }, { - name: 'no-non-package-json', - severity: 'error', + name: "no-non-package-json", + severity: "error", comment: "This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " + "That's problematic as the package either (1) won't be available on live (2 - worse) will be " + @@ -95,87 +89,75 @@ module.exports = { "in your package.json.", from: {}, to: { - dependencyTypes: [ - 'npm-no-pkg', - 'npm-unknown' - ] - } + dependencyTypes: ["npm-no-pkg", "npm-unknown"], + }, }, { - name: 'not-to-unresolvable', + name: "not-to-unresolvable", comment: "This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " + - 'module: add it to your package.json. In all other cases you likely already know what to do.', - severity: 'error', + "module: add it to your package.json. In all other cases you likely already know what to do.", + severity: "error", from: {}, to: { - couldNotResolve: true - } + couldNotResolve: true, + }, }, { - name: 'no-duplicate-dep-types', + name: "no-duplicate-dep-types", comment: "Likely this module depends on an external ('npm') package that occurs more than once " + "in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " + "maintenance problems later on.", - severity: 'warn', + severity: "warn", from: {}, to: { moreThanOneDependencyType: true, - // as it's pretty common to have a type import be a type only import + // as it's pretty common to have a type import be a type only import // _and_ (e.g.) a devDependency - don't consider type-only dependency // types for this rule - dependencyTypesNot: ["type-only"] - } + dependencyTypesNot: ["type-only"], + }, }, /* rules you might want to tweak for your specific situation: */ { - name: 'not-to-spec', + name: "not-to-spec", comment: - 'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' + + "This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. " + "If there's something in a spec that's of use to other modules, it doesn't have that single " + - 'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.', - severity: 'error', + "responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.", + severity: "error", from: {}, to: { - path: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$' - } + path: "[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$", + }, }, { - name: 'not-to-dev-dep', - severity: 'error', + name: "not-to-dev-dep", + severity: "error", comment: "This module depends on an npm package from the 'devDependencies' section of your " + - 'package.json. It looks like something that ships to production, though. To prevent problems ' + + "package.json. It looks like something that ships to production, though. To prevent problems " + "with npm packages that aren't there on production declare it (only!) in the 'dependencies'" + - 'section of your package.json. If this module is development only - add it to the ' + - 'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration', + "section of your package.json. If this module is development only - add it to the " + + "from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration", from: { - path: '^(src)', - pathNot: [ - '[.](?:spec|test|setup|script)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$', - './test' - ] + path: "^(src)", + pathNot: ["[.](?:spec|test|setup|script)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$", "./test"], }, to: { - dependencyTypes: [ - 'npm-dev', - ], + dependencyTypes: ["npm-dev"], // type only dependencies are not a problem as they don't end up in the // production code or are ignored by the runtime. - dependencyTypesNot: [ - 'type-only' - ], - pathNot: [ - 'node_modules/@types/' - ] - } + dependencyTypesNot: ["type-only"], + pathNot: ["node_modules/@types/"], + }, }, { - name: 'optional-deps-used', - severity: 'info', + name: "optional-deps-used", + severity: "info", comment: "This module depends on an npm package that is declared as an optional dependency " + "in your package.json. As this makes sense in limited situations only, it's flagged here. " + @@ -183,33 +165,28 @@ module.exports = { "dependency-cruiser configuration.", from: {}, to: { - dependencyTypes: [ - 'npm-optional' - ] - } + dependencyTypes: ["npm-optional"], + }, }, { - name: 'peer-deps-used', + name: "peer-deps-used", comment: "This module depends on an npm package that is declared as a peer dependency " + "in your package.json. This makes sense if your package is e.g. a plugin, but in " + "other cases - maybe not so much. If the use of a peer dependency is intentional " + "add an exception to your dependency-cruiser configuration.", - severity: 'warn', + severity: "warn", from: {}, to: { - dependencyTypes: [ - 'npm-peer' - ] - } - } + dependencyTypes: ["npm-peer"], + }, + }, ], options: { - /* Which modules not to follow further when encountered */ doNotFollow: { /* path: an array of regular expressions in strings to match against */ - path: ['node_modules'] + path: ["node_modules"], }, /* Which modules to exclude */ @@ -271,7 +248,7 @@ module.exports = { defaults to './tsconfig.json'. */ tsConfig: { - fileName: 'tsconfig.json' + fileName: "tsconfig.json", }, /* Webpack configuration to use to get resolve options from. @@ -345,7 +322,7 @@ module.exports = { collapses everything in node_modules to one folder deep so you see the external modules, but their innards. */ - collapsePattern: 'node_modules/(?:@[^/]+/[^/]+|[^/]+)', + collapsePattern: "node_modules/(?:@[^/]+/[^/]+|[^/]+)", /* Options to tweak the appearance of your graph.See https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions @@ -367,7 +344,8 @@ module.exports = { dependency graph reporter (`archi`) you probably want to tweak this collapsePattern to your situation. */ - collapsePattern: '^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)', + collapsePattern: + "^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)", /* Options to tweak the appearance of your graph. If you don't specify a theme for 'archi' dependency-cruiser will use the one specified in the @@ -375,10 +353,10 @@ module.exports = { */ // theme: { }, }, - "text": { - "highlightFocused": true + text: { + highlightFocused: true, }, - } - } + }, + }, }; // generated: dependency-cruiser@16.3.3 on 2024-06-13T23:26:36.169Z diff --git a/.github/workflows/eslint.yml b/.github/workflows/quality.yml similarity index 88% rename from .github/workflows/eslint.yml rename to .github/workflows/quality.yml index d863c96a643..7e33a77a73a 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/quality.yml @@ -1,4 +1,4 @@ -name: ESLint +name: Biome Code Quality on: # Trigger the workflow on push or pull request, @@ -28,10 +28,13 @@ jobs: - name: Set up Node.js # Step to set up Node.js environment uses: actions/setup-node@v4 # Use the setup-node action version 4 with: - node-version: 20 # Specify Node.js version 20 + node-version-file: '.nvmrc' - name: Install Node.js dependencies # Step to install Node.js dependencies run: npm ci # Use 'npm ci' to install dependencies - + - name: eslint # Step to run linters run: npm run eslint-ci + + - name: Lint with Biome # Step to run linters + run: npm run biome-ci \ No newline at end of file diff --git a/README.md b/README.md index 607a42e5125..5bb3ecfd26f 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,30 @@ PokéRogue is a browser based Pokémon fangame heavily inspired by the roguelite genre. Battle endlessly while gathering stacking items, exploring many different biomes, fighting trainers, bosses, and more! # Contributing + ## 🛠️ Development + If you have the motivation and experience with Typescript/Javascript (or are willing to learn) please feel free to fork the repository and make pull requests with contributions. If you don't know what to work on but want to help, reference the below **To-Do** section or the **#feature-vote** channel in the discord. ### 💻 Environment Setup + #### Prerequisites + - node: 20.13.1 - npm: [how to install](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) #### Running Locally + 1. Clone the repo and in the root directory run `npm install` - *if you run into any errors, reach out in the **#dev-corner** channel in discord* 2. Run `npm run start:dev` to locally run the project in `localhost:8000` #### Linting -We're using ESLint as our common linter and formatter. It will run automatically during the pre-commit hook but if you would like to manually run it, use the `npm run eslint` script. To view the complete rules, check out the [eslint.config.js](./eslint.config.js) file. + +We're using Biome as our common linter and formatter. It will run automatically during the pre-commit hook but if you would like to manually run it, use the `npm run biome` script. To view the complete rules, check out the [biome.jsonc](./biome.jsonc) file. ### 📚 Documentation + You can find the auto-generated documentation [here](https://pagefaultgames.github.io/pokerogue/main/index.html). For information on enemy AI, check out the [enemy-ai.md](./docs/enemy-ai.md) file. For detailed guidelines on documenting your code, refer to the [comments.md](./docs/comments.md) file. @@ -27,16 +34,20 @@ For detailed guidelines on documenting your code, refer to the [comments.md](./d ### ❔ FAQ **How do I test a new _______?** + - In the `src/overrides.ts` file there are overrides for most values you'll need to change for testing **How do I retrieve the translations?** + - The translations were moved to the [dedicated translation repository](https://github.com/pagefaultgames/pokerogue-locales) and are now applied as a submodule in this project. - The command to retrieve the translations is `git submodule update --init --recursive`. If you still struggle to get it working, please reach out to #dev-corner channel in Discord. ## 🪧 To Do + Check out [Github Issues](https://github.com/pagefaultgames/pokerogue/issues) to see how can you help us! # 📝 Credits +> > If this project contains assets you have produced and you do not see your name, **please** reach out, either [here on GitHub](https://github.com/pagefaultgames/pokerogue/issues/new) or via [Discord](https://discord.gg/pokerogue). Thank you to all the wonderful people that have contributed to the PokéRogue project! You can find the credits [here](./CREDITS.md). diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 00000000000..3ec4552d359 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,106 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "vcs": { + "enabled": false, + "clientKind": "git", + "useIgnoreFile": true, + "defaultBranch": "beta" + }, + "formatter": { + "enabled": true, + "useEditorconfig": true, + "indentStyle": "space", + "ignore": ["src/enums/*", "src/data/balance/*"], + "lineWidth": 120 + }, + "files": { + "ignoreUnknown": true, + // Adding folders to the ignore list is GREAT for performance because it prevents biome from descending into them + // and having to verify whether each individual file is ignored + "ignore": [ + "**/*.d.ts", + "dist/*", + "build/*", + "coverage/*", + "public/*", + ".github/*", + "node_modules/*", + ".vscode/*", + "*.css", // TODO? + "*.html", // TODO? + "src/overrides.ts", + // TODO: these files are too big and complex, ignore them until their respective refactors + "src/data/moves/move.ts", + "src/data/ability.ts", + "src/field/pokemon.ts", + + // this file is just too big: + "src/data/balance/tms.ts" + ] + }, + "organizeImports": { "enabled": false }, + "linter": { + "ignore": [ + "src/phases/move-effect-phase.ts" // TODO: unignore after move-effect-phase refactor + ], + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUndeclaredVariables": "off", + "noUnusedVariables": "error", + "noSwitchDeclarations": "warn", // TODO: refactor and make this an error + "noVoidTypeReturn": "warn" // TODO: Refactor and make this an error + }, + "style": { + "noVar": "error", + "useEnumInitializers": "off", + "useBlockStatements": "error", + "useConst": "error", + "useImportType": "error", + "noNonNullAssertion": "off", // TODO: Turn this on ASAP and fix all non-null assertions + "noParameterAssign": "off", + "useExponentiationOperator": "off", + "useDefaultParameterLast": "off", // TODO: Fix spots in the codebase where this flag would be triggered, and then enable + "useSingleVarDeclarator": "off", + "useNodejsImportProtocol": "off", + "useTemplate": "off" // string concatenation is faster: https://stackoverflow.com/questions/29055518/are-es6-template-literals-faster-than-string-concatenation + }, + "suspicious": { + "noDoubleEquals": "error", + "noExplicitAny": "off", + "noAssignInExpressions": "off", + "noPrototypeBuiltins": "off", + "noFallthroughSwitchClause": "off", + "noImplicitAnyLet": "info", // TODO: Refactor and make this an error + "noRedeclare": "off", // TODO: Refactor and make this an error + "noGlobalIsNan": "off", + "noAsyncPromiseExecutor": "warn" // TODO: Refactor and make this an error + }, + "complexity": { + "noExcessiveCognitiveComplexity": "warn", + "useLiteralKeys": "off", + "noForEach": "off", // Foreach vs for of is not that simple. + "noUselessSwitchCase": "off", // Explicit > Implicit + "noUselessConstructor": "warn", // TODO: Refactor and make this an error + "noBannedTypes": "warn" // TODO: Refactor and make this an error + } + } + }, + "javascript": { + "formatter": { "quoteStyle": "double", "arrowParentheses": "asNeeded" } + }, + "overrides": [ + { + "include": ["test/**/*.test.ts"], + "javascript": { "globals": [] }, + "linter": { + "rules": { + "performance": { + "noDelete": "off" + } + } + } + } + ] +} diff --git a/create-test-boilerplate.js b/create-test-boilerplate.js index 1ea61e0dc48..d47b7c4afeb 100644 --- a/create-test-boilerplate.js +++ b/create-test-boilerplate.js @@ -1,5 +1,5 @@ /** - * This script creates a test boilerplate file in the appropriate + * This script creates a test boilerplate file in the appropriate * directory based on the type selected. * @example npm run create-test */ @@ -31,7 +31,8 @@ async function promptTestType() { if (typeAnswer.selectedOption === "EXIT") { console.log("Exiting..."); return process.exit(); - } else if (!typeChoices.includes(typeAnswer.selectedOption)) { + } + if (!typeChoices.includes(typeAnswer.selectedOption)) { console.error(`Please provide a valid type (${typeChoices.join(", ")})!`); return await promptTestType(); } @@ -74,11 +75,11 @@ async function runInteractive() { const fileName = fileNameAnswer.userInput .replace(/-+/g, "_") // Convert kebab-case (dashes) to underscores .replace(/([a-z])([A-Z])/g, "$1_$2") // Convert camelCase to snake_case - .replace(/\s+/g, '_') // Replace spaces with underscores + .replace(/\s+/g, "_") // Replace spaces with underscores .toLowerCase(); // Ensure all lowercase // Format the description for the test case - const formattedName = fileName.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase()); + const formattedName = fileName.replace(/_/g, " ").replace(/\b\w/g, char => char.toUpperCase()); // Determine the directory based on the type let dir; let description; diff --git a/dependency-graph.js b/dependency-graph.js index 627aa3dcf13..dff960d8781 100644 --- a/dependency-graph.js +++ b/dependency-graph.js @@ -10,4 +10,4 @@ for await (const chunk of process.stdin) { const file = Buffer.concat(inputFile).toString("utf-8"); const svg = graphviz.dot(file, "svg"); -process.stdout.write(svg); \ No newline at end of file +process.stdout.write(svg); diff --git a/eslint.config.js b/eslint.config.js index e79395e1900..a97e3902411 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,70 +1,43 @@ -import tseslint from '@typescript-eslint/eslint-plugin'; -import stylisticTs from '@stylistic/eslint-plugin-ts'; -import parser from '@typescript-eslint/parser'; -import importX from 'eslint-plugin-import-x'; +import tseslint from "@typescript-eslint/eslint-plugin"; +import stylisticTs from "@stylistic/eslint-plugin-ts"; +import parser from "@typescript-eslint/parser"; +import importX from "eslint-plugin-import-x"; -export default [ - { - name: "eslint-config", - files: ["src/**/*.{ts,tsx,js,jsx}", "test/**/*.{ts,tsx,js,jsx}"], - ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"], - languageOptions: { - parser: parser - }, - plugins: { - "import-x": importX, - '@stylistic/ts': stylisticTs, - '@typescript-eslint': tseslint - }, - rules: { - "eqeqeq": ["error", "always"], // Enforces the use of `===` and `!==` instead of `==` and `!=` - "indent": ["error", 2, { "SwitchCase": 1 }], // Enforces a 2-space indentation, enforces indentation of `case ...:` statements - "quotes": ["error", "double"], // Enforces the use of double quotes for strings - "no-var": "error", // Disallows the use of `var`, enforcing `let` or `const` instead - "prefer-const": "error", // Enforces the use of `const` for variables that are never reassigned - "no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this) - "@typescript-eslint/no-unused-vars": [ "error", { - "args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used. - "ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the others. - }], - "eol-last": ["error", "always"], // Enforces at least one newline at the end of files - "@stylistic/ts/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax - "semi": "off", // Disables the general semi rule for TypeScript files - "no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax - "brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors - "curly": ["error", "all"], // Enforces the use of curly braces for all control statements - "@stylistic/ts/brace-style": ["error", "1tbs"], // Enforces the following brace style: https://eslint.style/rules/js/brace-style#_1tbs - "no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines - "skipBlankLines": false, // Enforces the rule even on blank lines - "ignoreComments": false // Enforces the rule on lines containing comments - }], - "space-before-blocks": ["error", "always"], // Enforces a space before blocks - "keyword-spacing": ["error", { "before": true, "after": true }], // Enforces spacing before and after keywords - "comma-spacing": ["error", { "before": false, "after": true }], // Enforces spacing after commas - "import-x/extensions": ["error", "never", { "json": "always" }], // Enforces no extension for imports unless json - "array-bracket-spacing": ["error", "always", { "objectsInArrays": false, "arraysInArrays": false }], // Enforces consistent spacing inside array brackets - "object-curly-spacing": ["error", "always", { "arraysInObjects": false, "objectsInObjects": false }], // Enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers - "computed-property-spacing": ["error", "never" ], // Enforces consistent spacing inside computed property brackets - "space-infix-ops": ["error", { "int32Hint": false }], // Enforces spacing around infix operators - "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], // Disallows multiple empty lines - "@typescript-eslint/consistent-type-imports": "error", // Enforces type-only imports wherever possible - } +export default [ + { + name: "eslint-config", + files: ["src/**/*.{ts,tsx,js,jsx}", "test/**/*.{ts,tsx,js,jsx}"], + ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"], + languageOptions: { + parser: parser, }, - { - name: "eslint-tests", - files: ["test/**/**.test.ts"], - languageOptions: { - parser: parser, - parserOptions: { - "project": ["./tsconfig.json"] - } - }, - plugins: { - "@typescript-eslint": tseslint - }, - rules: { - "@typescript-eslint/no-floating-promises": "error", // Require Promise-like statements to be handled appropriately. - https://typescript-eslint.io/rules/no-floating-promises/ - "@typescript-eslint/no-misused-promises": "error", // Disallow Promises in places not designed to handle them. - https://typescript-eslint.io/rules/no-misused-promises/ - } - } -] + plugins: { + "import-x": importX, + "@stylistic/ts": stylisticTs, + "@typescript-eslint": tseslint, + }, + rules: { + "prefer-const": "error", // Enforces the use of `const` for variables that are never reassigned + "no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this) + "no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax + "import-x/extensions": ["error", "never", { json: "always" }], // Enforces no extension for imports unless json + }, + }, + { + name: "eslint-tests", + files: ["test/**/**.test.ts"], + languageOptions: { + parser: parser, + parserOptions: { + project: ["./tsconfig.json"], + }, + }, + plugins: { + "@typescript-eslint": tseslint, + }, + rules: { + "@typescript-eslint/no-floating-promises": "error", // Require Promise-like statements to be handled appropriately. - https://typescript-eslint.io/rules/no-floating-promises/ + "@typescript-eslint/no-misused-promises": "error", // Disallow Promises in places not designed to handle them. - https://typescript-eslint.io/rules/no-misused-promises/ + }, + }, +]; diff --git a/index.css b/index.css index 9226f968e3e..49e570bdccc 100644 --- a/index.css +++ b/index.css @@ -11,7 +11,7 @@ html { body { margin: 0; - display:flex; + display: flex; flex-direction: column; align-items: center; background: #484050; @@ -49,16 +49,17 @@ body { @media (pointer: coarse) { /* hasTouchscreen() && !isTouchControlsEnabled */ - body:has(> #touchControls[class=visible]) #app { + body:has(> #touchControls[class="visible"]) #app { align-items: start; } - body:has(> #touchControls[class=visible]) #app > div:first-child { + body:has(> #touchControls[class="visible"]) #app > div:first-child { transform-origin: top !important; } } -#layout:fullscreen #dpad, #layout:fullscreen { +#layout:fullscreen #dpad, +#layout:fullscreen { bottom: 6rem; } @@ -76,7 +77,6 @@ input { display: none !important; } - input:-internal-autofill-selected { -webkit-background-clip: text; background-clip: text; @@ -91,18 +91,33 @@ input:-internal-autofill-selected { --controls-padding: 1rem; - --controls-size-with-padding: calc(var(--controls-size) + var(--controls-padding)); - --controls-size-with-wide-padding: calc(var(--controls-size) *1.2 + var(--controls-padding)); + --controls-size-with-padding: calc( + var(--controls-size) + + var(--controls-padding) + ); + --controls-size-with-wide-padding: calc( + var(--controls-size) * + 1.2 + + var(--controls-padding) + ); --control-group-extra-size: calc(var(--controls-size) * 0.8); --control-group-extra-wide-size: calc(var(--controls-size) * 1.2); - --control-group-extra-2-offset: calc(var(--controls-size-with-padding) + (var(--controls-size) - var(--control-group-extra-size)) / 2); - --control-group-extra-1-offset: calc(var(--controls-padding) + (var(--controls-size) - var(--control-group-extra-size)) / 2); + --control-group-extra-2-offset: calc( + var(--controls-size-with-padding) + + (var(--controls-size) - var(--control-group-extra-size)) / + 2 + ); + --control-group-extra-1-offset: calc( + var(--controls-padding) + + (var(--controls-size) - var(--control-group-extra-size)) / + 2 + ); --small-control-size: calc(var(--controls-size) / 3); --rect-control-size: calc(var(--controls-size) * 0.74); - font-family: 'emerald'; + font-family: "emerald"; font-size: var(--controls-size); text-shadow: var(--color-dark) var(--text-shadow-size) var(--text-shadow-size); color: var(--color-light); @@ -146,32 +161,69 @@ input:-internal-autofill-selected { /* Hide buttons on specific UIs */ /* Show #apadPreviousTab and #apadNextTab only in settings, except in touch configuration panel */ -#touchControls:not([data-ui-mode^='SETTINGS']) #apadPreviousTab, -#touchControls:not([data-ui-mode^='SETTINGS']) #apadNextTab, +#touchControls:not([data-ui-mode^="SETTINGS"]) #apadPreviousTab, +#touchControls:not([data-ui-mode^="SETTINGS"]) #apadNextTab, #touchControls:is(.config-mode) #apadPreviousTab, #touchControls:is(.config-mode) #apadNextTab { display: none; } /* Show #apadInfo only in battle */ -#touchControls:not([data-ui-mode='COMMAND']):not([data-ui-mode='FIGHT']):not([data-ui-mode='BALL']):not([data-ui-mode='TARGET_SELECT']) #apadInfo { +#touchControls:not([data-ui-mode="COMMAND"]):not([data-ui-mode="FIGHT"]):not( + [data-ui-mode="BALL"] + ):not([data-ui-mode="TARGET_SELECT"]) + #apadInfo { display: none; } /* Show #apadStats only in battle and shop */ -#touchControls:not([data-ui-mode='COMMAND']):not([data-ui-mode='FIGHT']):not([data-ui-mode='BALL']):not([data-ui-mode='TARGET_SELECT']):not([data-ui-mode='MODIFIER_SELECT']) #apadStats { +#touchControls:not([data-ui-mode="COMMAND"]):not([data-ui-mode="FIGHT"]):not( + [data-ui-mode="BALL"] + ):not([data-ui-mode="TARGET_SELECT"]):not([data-ui-mode="MODIFIER_SELECT"]) + #apadStats { display: none; } /* Show cycle buttons only on STARTER_SELECT and on touch configuration panel */ -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX'], [data-ui-mode='POKEDEX_PAGE']) #apadOpenFilters, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX'], [data-ui-mode='POKEDEX_PAGE'], [data-ui-mode='RUN_INFO']) #apadCycleForm, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX'], [data-ui-mode='POKEDEX_PAGE'], [data-ui-mode='RUN_INFO']) #apadCycleShiny, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT']) #apadCycleNature, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX_PAGE'], [data-ui-mode='RUN_INFO']) #apadCycleAbility, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX_PAGE']) #apadCycleGender, -#touchControls:not(.config-mode):not([data-ui-mode='STARTER_SELECT'], [data-ui-mode='POKEDEX']) #apadCycleTera { - display: none; +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX"], + [data-ui-mode="POKEDEX_PAGE"] + ) + #apadOpenFilters, +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX"], + [data-ui-mode="POKEDEX_PAGE"], + [data-ui-mode="RUN_INFO"] + ) + #apadCycleForm, +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX"], + [data-ui-mode="POKEDEX_PAGE"], + [data-ui-mode="RUN_INFO"] + ) + #apadCycleShiny, +#touchControls:not(.config-mode):not([data-ui-mode="STARTER_SELECT"]) + #apadCycleNature, +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX_PAGE"], + [data-ui-mode="RUN_INFO"] + ) + #apadCycleAbility, +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX_PAGE"] + ) + #apadCycleGender, +#touchControls:not(.config-mode):not( + [data-ui-mode="STARTER_SELECT"], + [data-ui-mode="POKEDEX"] + ) + #apadCycleTera { + display: none; } /* Configuration toolbar */ @@ -217,16 +269,18 @@ input:-internal-autofill-selected { font-size: var(--small-control-size); border-radius: 8px; padding: 2px 8px; - text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) calc(var(--text-shadow-size) / 3); + text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) + calc(var(--text-shadow-size) / 3); } #configToolbar .button:active { - opacity: var(--touch-control-opacity) + opacity: var(--touch-control-opacity); } #configToolbar .orientation-label { font-size: var(--small-control-size); - text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) calc(var(--text-shadow-size) / 3); + text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) + calc(var(--text-shadow-size) / 3); } /* dpad */ @@ -270,7 +324,8 @@ input:-internal-autofill-selected { .apad-small > .apad-label { font-size: var(--small-control-size); - text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) calc(var(--text-shadow-size) / 3); + text-shadow: var(--color-dark) calc(var(--text-shadow-size) / 3) + calc(var(--text-shadow-size) / 3); } .apad-rectangle { @@ -320,7 +375,8 @@ input:-internal-autofill-selected { /* Layout */ -#layout:fullscreen #dpad, #layout:fullscreen #apad { +#layout:fullscreen #dpad, +#layout:fullscreen #apad { bottom: 6rem; } @@ -353,55 +409,55 @@ a { /* Firefox old*/ @-moz-keyframes blink { - 0% { - opacity:1; - } - 50% { - opacity:0; - } - 100% { - opacity:1; - } + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } } @-webkit-keyframes blink { - 0% { - opacity:1; - } - 50% { - opacity:0; - } - 100% { - opacity:1; - } + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } } /* IE */ @-ms-keyframes blink { - 0% { - opacity:1; - } - 50% { - opacity:0; - } - 100% { - opacity:1; - } + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } } /* Opera and prob css3 final iteration */ @keyframes blink { - 0% { - opacity:1; - } - 50% { - opacity:0; - } - 100% { - opacity:1; - } + 0% { + opacity: 1; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } } .blink-image { - -moz-animation: blink normal 4s infinite ease-in-out; /* Firefox */ - -webkit-animation: blink normal 4s infinite ease-in-out; /* Webkit */ - -ms-animation: blink normal 4s infinite ease-in-out; /* IE */ - animation: blink normal 4s infinite ease-in-out; /* Opera and prob css3 final iteration */ + -moz-animation: blink normal 4s infinite ease-in-out; /* Firefox */ + -webkit-animation: blink normal 4s infinite ease-in-out; /* Webkit */ + -ms-animation: blink normal 4s infinite ease-in-out; /* IE */ + animation: blink normal 4s infinite ease-in-out; /* Opera and prob css3 final iteration */ } diff --git a/lefthook.yml b/lefthook.yml index 06eb0446ee5..4eff2ad1f8e 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,9 +1,9 @@ pre-commit: parallel: true commands: - eslint: + biome-lint: glob: "*.{js,jsx,ts,tsx}" - run: npx eslint --fix {staged_files} + run: npx @biomejs/biome check --write --reporter=summary {staged_files} --no-errors-on-unmatched stage_fixed: true skip: - merge @@ -11,9 +11,9 @@ pre-commit: pre-push: commands: - eslint: + biome-lint: glob: "*.{js,ts,jsx,tsx}" - run: npx eslint --fix {push_files} + run: npx @biomejs/biome check --write --reporter=summary {push_files} --no-errors-on-unmatched post-merge: commands: diff --git a/package-lock.json b/package-lock.json index b1c7564a2ee..87e2e150c65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7014 +1,7179 @@ { - "name": "pokemon-rogue-battle", - "version": "1.7.7", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "pokemon-rogue-battle", - "version": "1.7.7", - "hasInstallScript": true, - "dependencies": { - "@material/material-color-utilities": "^0.2.7", - "crypto-js": "^4.2.0", - "i18next": "^23.11.1", - "i18next-browser-languagedetector": "^7.2.1", - "i18next-http-backend": "^2.6.1", - "i18next-korean-postposition-processor": "^1.0.0", - "json-stable-stringify": "^1.1.0", - "jszip": "^3.10.1", - "phaser": "^3.70.0", - "phaser3-rex-plugins": "^1.1.84" - }, - "devDependencies": { - "@eslint/js": "^9.3.0", - "@hpcc-js/wasm": "^2.18.0", - "@stylistic/eslint-plugin-ts": "^2.6.0-beta.0", - "@types/jsdom": "^21.1.7", - "@types/node": "^20.12.13", - "@typescript-eslint/eslint-plugin": "^8.0.0-alpha.54", - "@typescript-eslint/parser": "^8.0.0-alpha.54", - "@vitest/coverage-istanbul": "^2.1.9", - "dependency-cruiser": "^16.3.10", - "eslint": "^9.7.0", - "eslint-plugin-import-x": "^4.2.1", - "inquirer": "^11.0.2", - "jsdom": "^24.0.0", - "lefthook": "^1.6.12", - "msw": "^2.4.9", - "phaser3spectorjs": "^0.0.8", - "typedoc": "^0.26.4", - "typescript": "^5.5.3", - "typescript-eslint": "^8.0.0-alpha.54", - "vite": "^5.4.14", - "vite-tsconfig-paths": "^4.3.2", - "vitest": "^2.1.9", - "vitest-canvas-mock": "^0.3.3" - }, - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/highlight": "^7.24.7", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", - "integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", - "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.9", - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.9", - "@babel/helpers": "^7.24.8", - "@babel/parser": "^7.24.8", - "@babel/template": "^7.24.7", - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.9", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.24.10", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", - "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.24.9", - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^2.5.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", - "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.24.8", - "@babel/helper-validator-option": "^7.24.8", - "browserslist": "^4.23.1", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", - "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", - "dev": true, - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", - "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", - "dev": true, - "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", - "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", - "dev": true, - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", - "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", - "integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-module-imports": "^7.24.7", - "@babel/helper-simple-access": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", - "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", - "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", - "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", - "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", - "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.8.tgz", - "integrity": "sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/parser": { - "version": "7.26.8", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.8.tgz", - "integrity": "sha512-TZIQ25pkSoaKEYYaHbbxkfL36GNsQ6iFiBbeuzAkLnXayKR1yP1zFe+NxuZWWsUyvt8icPU9CCq0sgWGXR1GEw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.26.8" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/runtime": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", - "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.7.tgz", - "integrity": "sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.8.tgz", - "integrity": "sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-function-name": "^7.24.7", - "@babel/helper-hoist-variables": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/parser": "^7.24.8", - "@babel/types": "^7.24.8", - "debug": "^4.3.1", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse/node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/types": { - "version": "7.26.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.8.tgz", - "integrity": "sha512-eUuWapzEGWFEpHFxgEaBG8e3n6S8L3MSu0oda755rOfabWPnh0Our1AozNFVUxGFIhbKgd1ksprsoDGMinTOTA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-string-parser": "^7.25.9", - "@babel/helper-validator-identifier": "^7.25.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@bundled-es-modules/cookie": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.0.tgz", - "integrity": "sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==", - "dev": true, - "license": "ISC", - "dependencies": { - "cookie": "^0.5.0" - } - }, - "node_modules/@bundled-es-modules/statuses": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz", - "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==", - "dev": true, - "license": "ISC", - "dependencies": { - "statuses": "^2.0.1" - } - }, - "node_modules/@bundled-es-modules/tough-cookie": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz", - "integrity": "sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==", - "dev": true, - "license": "ISC", - "dependencies": { - "@types/tough-cookie": "^4.0.5", - "tough-cookie": "^4.1.4" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", - "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", - "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", - "dev": true, - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", - "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/@eslint/config-array": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", - "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@eslint/object-schema": "^2.1.4", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/config-array/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/@eslint/eslintrc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", - "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/eslintrc/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/@eslint/js": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.7.0.tgz", - "integrity": "sha512-ChuWDQenef8OSFnvuxv0TCVxEwmu3+hPNKvM9B34qpM0rDRbjL8t5QkQeHHeAfsKQjuH9wS82WeCi1J/owatng==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/object-schema": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", - "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@hpcc-js/wasm": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@hpcc-js/wasm/-/wasm-2.18.0.tgz", - "integrity": "sha512-M9XVIvAXGH4Xcyb5UoiohWcn6fil89pcos/gClNdBZG2v+W48xSf2bjcA8BW131X/AFHUerVY28n1P1Jw81/9A==", - "dev": true, - "dependencies": { - "yargs": "17.7.2" - }, - "bin": { - "dot-wasm": "bin/dot-wasm.js" - } - }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/retry": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", - "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@inquirer/checkbox": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz", - "integrity": "sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/figures": "^1.0.6", - "@inquirer/type": "^2.0.0", - "ansi-escapes": "^4.3.2", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/confirm": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-4.0.1.tgz", - "integrity": "sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/core": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.2.1.tgz", - "integrity": "sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/figures": "^1.0.6", - "@inquirer/type": "^2.0.0", - "@types/mute-stream": "^0.0.4", - "@types/node": "^22.5.5", - "@types/wrap-ansi": "^3.0.0", - "ansi-escapes": "^4.3.2", - "cli-width": "^4.1.0", - "mute-stream": "^1.0.0", - "signal-exit": "^4.1.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^6.2.0", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/core/node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.19.2" - } - }, - "node_modules/@inquirer/core/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/@inquirer/core/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@inquirer/core/node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@inquirer/core/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@inquirer/editor": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-3.0.1.tgz", - "integrity": "sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0", - "external-editor": "^3.1.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/expand": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-3.0.1.tgz", - "integrity": "sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/figures": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.6.tgz", - "integrity": "sha512-yfZzps3Cso2UbM7WlxKwZQh2Hs6plrbjs1QnzQDZhK2DgyCo6D8AaHps9olkNcUFlcYERMqU3uJSp1gmy3s/qQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/input": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-3.0.1.tgz", - "integrity": "sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/number": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-2.0.1.tgz", - "integrity": "sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/password": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-3.0.1.tgz", - "integrity": "sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0", - "ansi-escapes": "^4.3.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/prompts": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-6.0.1.tgz", - "integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/checkbox": "^3.0.1", - "@inquirer/confirm": "^4.0.1", - "@inquirer/editor": "^3.0.1", - "@inquirer/expand": "^3.0.1", - "@inquirer/input": "^3.0.1", - "@inquirer/number": "^2.0.1", - "@inquirer/password": "^3.0.1", - "@inquirer/rawlist": "^3.0.1", - "@inquirer/search": "^2.0.1", - "@inquirer/select": "^3.0.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/rawlist": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-3.0.1.tgz", - "integrity": "sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/type": "^2.0.0", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/search": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-2.0.1.tgz", - "integrity": "sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/figures": "^1.0.6", - "@inquirer/type": "^2.0.0", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/select": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-3.0.1.tgz", - "integrity": "sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/figures": "^1.0.6", - "@inquirer/type": "^2.0.0", - "ansi-escapes": "^4.3.2", - "yoctocolors-cjs": "^2.1.2" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@inquirer/type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-2.0.0.tgz", - "integrity": "sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==", - "dev": true, - "license": "MIT", - "dependencies": { - "mute-stream": "^1.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@material/material-color-utilities": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/@material/material-color-utilities/-/material-color-utilities-0.2.7.tgz", - "integrity": "sha512-0FCeqG6WvK4/Cc06F/xXMd/pv4FeisI0c1tUpBbfhA2n9Y8eZEv4Karjbmf2ZqQCPUWMrGp8A571tCjizxoTiQ==", - "license": "Apache-2.0" - }, - "node_modules/@mswjs/interceptors": { - "version": "0.35.8", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.35.8.tgz", - "integrity": "sha512-PFfqpHplKa7KMdoQdj5td03uG05VK2Ng1dG0sP4pT9h0dGSX2v9txYt/AnrzPb/vAmfyBBC0NQV7VaBEX+efgQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@open-draft/deferred-promise": "^2.2.0", - "@open-draft/logger": "^0.3.0", - "@open-draft/until": "^2.0.0", - "is-node-process": "^1.2.0", - "outvariant": "^1.4.3", - "strict-event-emitter": "^0.5.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@open-draft/deferred-promise": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", - "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@open-draft/logger": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", - "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-node-process": "^1.2.0", - "outvariant": "^1.4.0" - } - }, - "node_modules/@open-draft/until": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", - "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", - "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", - "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", - "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", - "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", - "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", - "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", - "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", - "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", - "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", - "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", - "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", - "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", - "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", - "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", - "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", - "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@shikijs/core": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.12.0.tgz", - "integrity": "sha512-mc1cLbm6UQ8RxLc0dZES7v5rkH+99LxQp/ZvTqV3NLyYsO/fD6JhEflP1H5b2SDq9gI0+0G36AVZWxvounfR9w==", - "dev": true, - "dependencies": { - "@types/hast": "^3.0.4" - } - }, - "node_modules/@stylistic/eslint-plugin-js": { - "version": "2.6.0-beta.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.6.0-beta.0.tgz", - "integrity": "sha512-KQiNvzNzvl9AmMs1MiIBszLIy/Xy1bTExnyaVy5dSzOF9c+yT64JQfH0p0jP6XpGwoCnZsrPUNflwP30G42QBQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/eslint": "^8.56.10", - "acorn": "^8.12.0", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@stylistic/eslint-plugin-ts": { - "version": "2.6.0-beta.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.6.0-beta.0.tgz", - "integrity": "sha512-WMz1zgmMC3bvg1L/tiYt5ygvDbTDKlbezoHoX2lV9MnUCAEQZUP4xJ9Wj3jmIKxb4mUuK5+vFZJVcOygvbbqow==", - "dev": true, - "license": "MIT", - "dependencies": { - "@stylistic/eslint-plugin-js": "2.6.0-beta.0", - "@types/eslint": "^8.56.10", - "@typescript-eslint/utils": "^8.0.0-alpha.34" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - } - }, - "node_modules/@types/cookie": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", - "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/eslint": { - "version": "8.56.11", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.11.tgz", - "integrity": "sha512-sVBpJMf7UPo/wGecYOpk2aQya2VUGeHhe38WG7/mN5FufNSubf5VT9Uh9Uyp8/eLJpu1/tuhJ/qTo4mhSB4V4Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, - "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", - "dev": true, - "dependencies": { - "@types/unist": "*" - } - }, - "node_modules/@types/jsdom": { - "version": "21.1.7", - "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-21.1.7.tgz", - "integrity": "sha512-yOriVnggzrnQ3a9OKOCxaVuSug3w3/SbOj5i7VwXWZEyUNl3bLF9V3MfxGbZKuwqJOQyRfqXyROBB1CoZLFWzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*", - "@types/tough-cookie": "*", - "parse5": "^7.0.0" - } - }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/mute-stream": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz", - "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/node": { - "version": "20.14.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", - "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/@types/statuses": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", - "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/tough-cookie": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", - "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", - "dev": true - }, - "node_modules/@types/wrap-ansi": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz", - "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.0.0-alpha.58.tgz", - "integrity": "sha512-5G9oIj8jvosj8RTa0VDFXvRmUg1U6FxXJu7ZEfyJYMvFkdMJoY5YnzFvgAvHbYsXOj+YgXZu81fNOTRWQzwk5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.0.0-alpha.58", - "@typescript-eslint/type-utils": "8.0.0-alpha.58", - "@typescript-eslint/utils": "8.0.0-alpha.58", - "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", - "graphemer": "^1.4.0", - "ignore": "^5.3.1", - "natural-compare": "^1.4.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.0.0-alpha.58.tgz", - "integrity": "sha512-/RpgxIejBui6WXJgV9ukwzxmvbZt5TlfHUGGLB/BsNLj+NRZEbXVtWT9rKuxVOqsGb1Dn9c5gxvBI/XzyuIsMQ==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "@typescript-eslint/scope-manager": "8.0.0-alpha.58", - "@typescript-eslint/types": "8.0.0-alpha.58", - "@typescript-eslint/typescript-estree": "8.0.0-alpha.58", - "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.0.0-alpha.58.tgz", - "integrity": "sha512-bGgJXn8B3Pf3mzEOUQTPxEqhux54MOJSqw4HcgBReuP7dudz/hsN4TH9GqHbMXkFv8N4Ed1iqVRfgGeC8b1mGw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.0.0-alpha.58", - "@typescript-eslint/visitor-keys": "8.0.0-alpha.58" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.0.0-alpha.58.tgz", - "integrity": "sha512-spW/I/UAY6HM0lKj+/333Zb9arOvUoi8+H0cVNYHELPhOti9re9NjyyJFhck84PNiwi8WmpkEf3GXe7/h+Cquw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/typescript-estree": "8.0.0-alpha.58", - "@typescript-eslint/utils": "8.0.0-alpha.58", - "debug": "^4.3.4", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.0.0-alpha.58.tgz", - "integrity": "sha512-6+jM4y31a6pwKeV3MVQuVXPZl6d3I1ySMvP5WjZdZ+n57uovMvasZ3ZJstXngoRpa7JtkjVZ7NrMhQ1J8dxKCQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.0.0-alpha.58.tgz", - "integrity": "sha512-hm4nsoJnQcA7axMopUJrH7CD0MJhAMtE2zQt65uMFCy+U2YDdKPwE0g6qEAUBoKn6UBLQJWthJgUmwDbWrnwZg==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "@typescript-eslint/types": "8.0.0-alpha.58", - "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/utils": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.0.0-alpha.58.tgz", - "integrity": "sha512-lZuGnpK23jr3huebgY4/qqrOKsWJ8dX0Q1Fo4oVYcyAy+sK6p+6nObK4VEPJG098gUmrriiavRiDKIhPDFm4Ig==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.0.0-alpha.58", - "@typescript-eslint/types": "8.0.0-alpha.58", - "@typescript-eslint/typescript-estree": "8.0.0-alpha.58" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.0.0-alpha.58.tgz", - "integrity": "sha512-V//E9PRY2216kh9fN/ihRvTtjpobAXEtmrsr3utlVUwHa2iklcofq1J12yl3KOjx9QBRfBrtfQnYaeruF7L0Fw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.0.0-alpha.58", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@vitest/coverage-istanbul": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/coverage-istanbul/-/coverage-istanbul-2.1.9.tgz", - "integrity": "sha512-vdYE4FkC/y2lxcN3Dcj54Bw+ericmDwiex0B8LV5F/YNYEYP1mgVwhPnHwWGAXu38qizkjOuyczKbFTALfzFKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@istanbuljs/schema": "^0.1.3", - "debug": "^4.3.7", - "istanbul-lib-coverage": "^3.2.2", - "istanbul-lib-instrument": "^6.0.3", - "istanbul-lib-report": "^3.0.1", - "istanbul-lib-source-maps": "^5.0.6", - "istanbul-reports": "^3.1.7", - "magicast": "^0.3.5", - "test-exclude": "^7.0.1", - "tinyrainbow": "^1.2.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "vitest": "2.1.9" - } - }, - "node_modules/@vitest/expect": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", - "integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/spy": "2.1.9", - "@vitest/utils": "2.1.9", - "chai": "^5.1.2", - "tinyrainbow": "^1.2.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/mocker": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.9.tgz", - "integrity": "sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/spy": "2.1.9", - "estree-walker": "^3.0.3", - "magic-string": "^0.30.12" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "msw": "^2.4.9", - "vite": "^5.0.0" - }, - "peerDependenciesMeta": { - "msw": { - "optional": true - }, - "vite": { - "optional": true - } - } - }, - "node_modules/@vitest/pretty-format": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz", - "integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyrainbow": "^1.2.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/runner": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.9.tgz", - "integrity": "sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/utils": "2.1.9", - "pathe": "^1.1.2" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/snapshot": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.9.tgz", - "integrity": "sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "2.1.9", - "magic-string": "^0.30.12", - "pathe": "^1.1.2" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/spy": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz", - "integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyspy": "^3.0.2" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/utils": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz", - "integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "2.1.9", - "loupe": "^3.1.2", - "tinyrainbow": "^1.2.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/acorn-jsx-walk": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/acorn-jsx-walk/-/acorn-jsx-walk-2.0.0.tgz", - "integrity": "sha512-uuo6iJj4D4ygkdzd6jPtcxs8vZgDX9YFIkqczGImoypX2fQ4dVImmu3UzA4ynixCIMTrEOWW+95M2HuBaCEOVA==", - "dev": true, - "license": "MIT" - }, - "node_modules/acorn-loose": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/acorn-loose/-/acorn-loose-8.4.0.tgz", - "integrity": "sha512-M0EUka6rb+QC4l9Z3T0nJEzNOO7JcoJlYMrBlyBCiFSXRyxjLKayd4TbQs2FDRWQU1h9FR7QVNHt+PEaoNL5rQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", - "dev": true, - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/agent-base": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", - "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-escapes": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", - "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "type-fest": "^0.21.3" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "license": "Python-2.0" - }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/assertion-error": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", - "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true, - "dependencies": { - "possible-typed-array-names": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browserslist": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", - "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "caniuse-lite": "^1.0.30001640", - "electron-to-chromium": "^1.4.820", - "node-releases": "^2.0.14", - "update-browserslist-db": "^1.1.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/cac": { - "version": "6.7.14", - "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", - "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/call-bind": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001642", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001642.tgz", - "integrity": "sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, - "node_modules/chai": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.2.tgz", - "integrity": "sha512-aGtmf24DW6MLHHG5gCx4zaI3uBq3KRtxeVs0DjFH6Z0rDNbsvTxFASFvdj79pxjxZ8/5u3PIiN3IwEIQkiiuPw==", - "dev": true, - "license": "MIT", - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.1.1", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true, - "license": "MIT" - }, - "node_modules/check-error": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", - "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, - "node_modules/cli-width": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", - "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">= 12" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/commander": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", - "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT" - }, - "node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "dev": true, - "license": "MIT" - }, - "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "node_modules/cross-fetch": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", - "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "license": "MIT", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/crypto-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", - "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", - "license": "MIT" - }, - "node_modules/cssfontparser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz", - "integrity": "sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==", - "dev": true, - "license": "MIT" - }, - "node_modules/cssstyle": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.0.1.tgz", - "integrity": "sha512-8ZYiJ3A/3OkDd093CBT/0UKDWry7ak4BdPTFP2+QEP7cmhouyq/Up709ASSj2cK02BbZiMgk7kYjZNS4QP5qrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "rrweb-cssom": "^0.6.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/cssstyle/node_modules/rrweb-cssom": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz", - "integrity": "sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==", - "dev": true - }, - "node_modules/data-urls": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", - "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", - "dev": true, - "license": "MIT", - "dependencies": { - "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", - "dev": true, - "license": "MIT" - }, - "node_modules/deep-eql": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", - "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/dependency-cruiser": { - "version": "16.3.10", - "resolved": "https://registry.npmjs.org/dependency-cruiser/-/dependency-cruiser-16.3.10.tgz", - "integrity": "sha512-WkCnibHBfvaiaQ+S46LZ6h4AR6oj42Vsf5/0Vgtrwdwn7ZekMJdZ/ALoTwNp/RaGlKW+MbV/fhSZOvmhAWVWzQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "8.12.1", - "acorn-jsx": "5.3.2", - "acorn-jsx-walk": "2.0.0", - "acorn-loose": "8.4.0", - "acorn-walk": "8.3.3", - "ajv": "8.17.1", - "commander": "12.1.0", - "enhanced-resolve": "5.17.1", - "ignore": "5.3.1", - "interpret": "^3.1.1", - "is-installed-globally": "1.0.0", - "json5": "2.2.3", - "memoize": "10.0.0", - "picocolors": "1.0.1", - "picomatch": "4.0.2", - "prompts": "2.4.2", - "rechoir": "^0.8.0", - "safe-regex": "2.1.1", - "semver": "^7.6.3", - "teamcity-service-messages": "0.1.14", - "tsconfig-paths-webpack-plugin": "4.1.0", - "watskeburt": "4.1.0" - }, - "bin": { - "depcruise": "bin/dependency-cruise.mjs", - "depcruise-baseline": "bin/depcruise-baseline.mjs", - "depcruise-fmt": "bin/depcruise-fmt.mjs", - "depcruise-wrap-stream-in-html": "bin/wrap-stream-in-html.mjs", - "dependency-cruise": "bin/dependency-cruise.mjs", - "dependency-cruiser": "bin/dependency-cruise.mjs" - }, - "engines": { - "node": "^18.17||>=20" - } - }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true, - "license": "MIT" - }, - "node_modules/electron-to-chromium": { - "version": "1.4.830", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.830.tgz", - "integrity": "sha512-TrPKKH20HeN0J1LHzsYLs2qwXrp8TF4nHdu4sq61ozGbzMpWhI7iIOPYPPkxeq1azMT9PZ8enPFcftbs/Npcjg==", - "dev": true - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true, - "license": "MIT" - }, - "node_modules/enhanced-resolve": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", - "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", - "license": "MIT", - "dependencies": { - "get-intrinsic": "^1.2.4" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-module-lexer": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz", - "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/esbuild": { - "version": "0.21.5", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", - "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.21.5", - "@esbuild/android-arm": "0.21.5", - "@esbuild/android-arm64": "0.21.5", - "@esbuild/android-x64": "0.21.5", - "@esbuild/darwin-arm64": "0.21.5", - "@esbuild/darwin-x64": "0.21.5", - "@esbuild/freebsd-arm64": "0.21.5", - "@esbuild/freebsd-x64": "0.21.5", - "@esbuild/linux-arm": "0.21.5", - "@esbuild/linux-arm64": "0.21.5", - "@esbuild/linux-ia32": "0.21.5", - "@esbuild/linux-loong64": "0.21.5", - "@esbuild/linux-mips64el": "0.21.5", - "@esbuild/linux-ppc64": "0.21.5", - "@esbuild/linux-riscv64": "0.21.5", - "@esbuild/linux-s390x": "0.21.5", - "@esbuild/linux-x64": "0.21.5", - "@esbuild/netbsd-x64": "0.21.5", - "@esbuild/openbsd-x64": "0.21.5", - "@esbuild/sunos-x64": "0.21.5", - "@esbuild/win32-arm64": "0.21.5", - "@esbuild/win32-ia32": "0.21.5", - "@esbuild/win32-x64": "0.21.5" - } - }, - "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.7.0.tgz", - "integrity": "sha512-FzJ9D/0nGiCGBf8UXO/IGLTgLVzIxze1zpfA8Ton2mjLovXdAPlYDv+MQDcqj3TmrhAGYfOpz9RfR+ent0AgAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.11.0", - "@eslint/config-array": "^0.17.0", - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.7.0", - "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.3.0", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.0.2", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.1.0", - "esquery": "^1.5.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-import-resolver-node": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", - "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^3.2.7", - "is-core-module": "^2.13.0", - "resolve": "^1.22.4" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/eslint-plugin-import-x": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.2.1.tgz", - "integrity": "sha512-WWi2GedccIJa0zXxx3WDnTgouGQTtdYK1nhXMwywbqqAgB0Ov+p1pYBsWh3VaB0bvBOwLse6OfVII7jZD9xo5Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/utils": "^8.1.0", - "debug": "^4.3.4", - "doctrine": "^3.0.0", - "eslint-import-resolver-node": "^0.3.9", - "get-tsconfig": "^4.7.3", - "is-glob": "^4.0.3", - "minimatch": "^9.0.3", - "semver": "^7.6.3", - "stable-hash": "^0.0.4", - "tslib": "^2.6.3" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/scope-manager": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.5.0.tgz", - "integrity": "sha512-06JOQ9Qgj33yvBEx6tpC8ecP9o860rsR22hWMEd12WcTRrfaFgHr2RB/CA/B+7BMhHkXT4chg2MyboGdFGawYg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/types": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.5.0.tgz", - "integrity": "sha512-qjkormnQS5wF9pjSi6q60bKUHH44j2APxfh9TQRXK8wbYVeDYYdYJGIROL87LGZZ2gz3Rbmjc736qyL8deVtdw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/typescript-estree": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.5.0.tgz", - "integrity": "sha512-vEG2Sf9P8BPQ+d0pxdfndw3xIXaoSjliG0/Ejk7UggByZPKXmJmw3GW5jV2gHNQNawBUyfahoSiCFVov0Ruf7Q==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/utils": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.5.0.tgz", - "integrity": "sha512-6yyGYVL0e+VzGYp60wvkBHiqDWOpT63pdMV2CVG4LVDd5uR6q1qQN/7LafBZtAtNIn/mqXjsSeS5ggv/P0iECw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.5.0", - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/typescript-estree": "8.5.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - } - }, - "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/visitor-keys": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.5.0.tgz", - "integrity": "sha512-yTPqMnbAZJNy2Xq2XU8AdtOW9tJIr+UQb64aXB9f3B1498Zx9JorVgFJcZpEc9UBuCCrdzKID2RGAMkYcDtZOw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.5.0", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/eslint-scope": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", - "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/espree": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", - "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^8.12.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", - "license": "MIT" - }, - "node_modules/expect-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", - "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, - "license": "MIT", - "dependencies": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-uri": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", - "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==", - "dev": true - }, - "node_modules/fastq": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", - "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", - "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "flat-cache": "^4.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", - "dev": true, - "license": "MIT", - "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.4" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", - "dev": true, - "license": "ISC" - }, - "node_modules/foreground-child": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", - "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-intrinsic": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-tsconfig": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.0.tgz", - "integrity": "sha512-Pgba6TExTZ0FJAn1qkJAjIeKoDJ3CsI2ChuLohJnZl/tTU8MVrq3b+2t5UOPfRa4RMsorClBjJALkJUMjG1PAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "resolve-pkg-maps": "^1.0.0" - }, - "funding": { - "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" - } - }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/global-directory": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz", - "integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ini": "4.1.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/globrex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", - "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", - "dev": true, - "license": "MIT" - }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "license": "MIT", - "dependencies": { - "get-intrinsic": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true, - "license": "MIT" - }, - "node_modules/graphql": { - "version": "16.9.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", - "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-proto": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/headers-polyfill": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz", - "integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/html-encoding-sniffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", - "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "whatwg-encoding": "^3.1.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true, - "license": "MIT" - }, - "node_modules/http-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", - "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/https-proxy-agent": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", - "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.0.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/i18next": { - "version": "23.12.2", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.12.2.tgz", - "integrity": "sha512-XIeh5V+bi8SJSWGL3jqbTEBW5oD6rbP5L+E7dVQh1MNTxxYef0x15rhJVcRb7oiuq4jLtgy2SD8eFlf6P2cmqg==", - "funding": [ - { - "type": "individual", - "url": "https://locize.com" - }, - { - "type": "individual", - "url": "https://locize.com/i18next.html" - }, - { - "type": "individual", - "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" - } - ], - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.23.2" - } - }, - "node_modules/i18next-browser-languagedetector": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-7.2.1.tgz", - "integrity": "sha512-h/pM34bcH6tbz8WgGXcmWauNpQupCGr25XPp9cZwZInR9XHSjIFDYp1SIok7zSPsTOMxdvuLyu86V+g2Kycnfw==", - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.23.2" - } - }, - "node_modules/i18next-http-backend": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.6.1.tgz", - "integrity": "sha512-rCilMAnlEQNeKOZY1+x8wLM5IpYOj10guGvEpeC59tNjj6MMreLIjIW8D1RclhD3ifLwn6d/Y9HEM1RUE6DSog==", - "license": "MIT", - "dependencies": { - "cross-fetch": "4.0.0" - } - }, - "node_modules/i18next-korean-postposition-processor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/i18next-korean-postposition-processor/-/i18next-korean-postposition-processor-1.0.0.tgz", - "integrity": "sha512-ruNXjI9awsFK6Ie+F9gYaMW8ciLMuCkeRjH9QkSv2Wb8xI0mnm773v3M9eua8dtvAXudIUk4p6Ho7hNkEASXDg==", - "license": "MIT", - "peerDependencies": { - "i18next": ">=8.4.0" - } - }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, - "node_modules/immediate": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "license": "MIT", - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ini": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", - "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/inquirer": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-11.0.2.tgz", - "integrity": "sha512-pnbn3nL+JFrTw/pLhzyE/IQ3+gA3n5JxTAZQDjB6qu4gbjOaiTnpZbxT6HY2DDCT7bzDjTTsd3snRP+B6N//Pg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.2.1", - "@inquirer/prompts": "^6.0.1", - "@inquirer/type": "^2.0.0", - "@types/mute-stream": "^0.0.4", - "ansi-escapes": "^4.3.2", - "mute-stream": "^1.0.0", - "run-async": "^3.0.0", - "rxjs": "^7.8.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/interpret": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", - "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/is-core-module": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", - "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", - "dev": true, - "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-installed-globally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-1.0.0.tgz", - "integrity": "sha512-K55T22lfpQ63N4KEN57jZUAaAYqYHEe8veb/TycJRk9DdSCLLcovXz/mL6mOnhQaZsQGwPhuFopdQIlqGSEjiQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "global-directory": "^4.0.1", - "is-path-inside": "^4.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-installed-globally/node_modules/is-path-inside": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", - "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-node-process": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", - "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", - "dev": true, - "license": "MIT" - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-potential-custom-element-name": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "license": "MIT" - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, - "license": "ISC" - }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", - "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", - "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@babel/core": "^7.23.9", - "@babel/parser": "^7.23.9", - "@istanbuljs/schema": "^0.1.3", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", - "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^4.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-source-maps": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", - "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.23", - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-reports": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", - "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, - "node_modules/jest-canvas-mock": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.5.2.tgz", - "integrity": "sha512-vgnpPupjOL6+L5oJXzxTxFrlGEIbHdZqFU+LFNdtLxZ3lRDCl17FlTMM7IatoRQkrcyOTMlDinjUguqmQ6bR2A==", - "dev": true, - "license": "MIT", - "dependencies": { - "cssfontparser": "^1.2.1", - "moo-color": "^1.0.2" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/jsdom": { - "version": "24.1.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-24.1.0.tgz", - "integrity": "sha512-6gpM7pRXCwIOKxX47cgOyvyQDN/Eh0f1MeKySBV2xGdKtqJBLj8P25eY3EVCWo2mglDDzozR2r2MW4T+JiNUZA==", - "dev": true, - "license": "MIT", - "dependencies": { - "cssstyle": "^4.0.1", - "data-urls": "^5.0.0", - "decimal.js": "^10.4.3", - "form-data": "^4.0.0", - "html-encoding-sniffer": "^4.0.0", - "http-proxy-agent": "^7.0.2", - "https-proxy-agent": "^7.0.4", - "is-potential-custom-element-name": "^1.0.1", - "nwsapi": "^2.2.10", - "parse5": "^7.1.2", - "rrweb-cssom": "^0.7.0", - "saxes": "^6.0.0", - "symbol-tree": "^3.2.4", - "tough-cookie": "^4.1.4", - "w3c-xmlserializer": "^5.0.0", - "webidl-conversions": "^7.0.0", - "whatwg-encoding": "^3.1.1", - "whatwg-mimetype": "^4.0.0", - "whatwg-url": "^14.0.0", - "ws": "^8.17.0", - "xml-name-validator": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "canvas": "^2.11.2" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, - "node_modules/json-stable-stringify": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.1.tgz", - "integrity": "sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg==", - "license": "MIT", - "dependencies": { - "call-bind": "^1.0.5", - "isarray": "^2.0.5", - "jsonify": "^0.0.1", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", - "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", - "license": "Public Domain", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/jszip": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", - "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", - "dependencies": { - "lie": "~3.3.0", - "pako": "~1.0.2", - "readable-stream": "~2.3.6", - "setimmediate": "^1.0.5" - } - }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "json-buffer": "3.0.1" - } - }, - "node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/lefthook": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-1.7.4.tgz", - "integrity": "sha512-lVv3nKH9l3KMDS3bySROvWJSw1+AsBHUO7xaA0rg1IEBZrj3+ePmM+a8elX+GU3Go1OzsZEYjo5AOOeLoZ7FQg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "lefthook": "bin/index.js" - }, - "optionalDependencies": { - "lefthook-darwin-arm64": "1.7.4", - "lefthook-darwin-x64": "1.7.4", - "lefthook-freebsd-arm64": "1.7.4", - "lefthook-freebsd-x64": "1.7.4", - "lefthook-linux-arm64": "1.7.4", - "lefthook-linux-x64": "1.7.4", - "lefthook-windows-arm64": "1.7.4", - "lefthook-windows-x64": "1.7.4" - } - }, - "node_modules/lefthook-darwin-arm64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-1.7.4.tgz", - "integrity": "sha512-6XpenaP0W7ZYA3lhHey/C1U+KmYz6eCq2cGswQsrTX+xdtHdWW3NbbOKngxATRTF8+CtF6m9UB2afP7qqkCghQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/lefthook-darwin-x64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-1.7.4.tgz", - "integrity": "sha512-lpQXbPMHiaWE7+9fV+spjuMKiZ3J/+oI6hY1/l48MO3LmSpIv6DNy0VHho1fZVQnHdBU4bDh5c1G0r1f5T0irg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/lefthook-freebsd-arm64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-1.7.4.tgz", - "integrity": "sha512-wv+JZgkD1/wi4X5aKKNodvxNcFcYmvL7uyzKkbtd/LgX5ssh9r5pO9J/71ULGtEuTXH4kqORRtez7u/ygqMEew==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ] - }, - "node_modules/lefthook-freebsd-x64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-1.7.4.tgz", - "integrity": "sha512-xoYR0Ay8pbyY9W9mI+iI9VDkkCVYSXhMf9XyOChSlu2XmjKiqi23hjCXvSOpvHQ7jphGvAVpE3Byijr6Xjuihw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ] - }, - "node_modules/lefthook-linux-arm64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-1.7.4.tgz", - "integrity": "sha512-WvXWzSM/e08n2f5lcC8j+pUMS0RzZftJK4zuBQ36TstSYXfBjWiw+FMnKCVZk6Q8Zc0icyF8sTmKQAyKCgX+UA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/lefthook-linux-x64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.7.4.tgz", - "integrity": "sha512-eR5NxGzqPJm3wDTm4HStwGxOZ8Omb0ooodyuQdEOxtYidLrd4U18N14huwCEFd3BAOrjIWYV8plH+ReTZE56eg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/lefthook-windows-arm64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-1.7.4.tgz", - "integrity": "sha512-C+MdHH+0ylermetMHwfHsYYNI5HI6QEOx7N4Iw4Ea6c3Yuj3eG3LsAzrhsup7KLSSBmDgIHOCJUx/Mfh2z+ATw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/lefthook-windows-x64": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-1.7.4.tgz", - "integrity": "sha512-BDQhiRzmMYPFQFtVtkRfUfeZuSlemG1oJfGKYXlCGFskvK9Jm1nGFnG0Ig63FAQaFdW33DFoLdr9ZKFTUQeSwQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lie": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", - "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", - "dependencies": { - "immediate": "~3.0.5" - } - }, - "node_modules/linkify-it": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", - "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", - "dev": true, - "dependencies": { - "uc.micro": "^2.0.0" - } - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/loupe": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", - "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", - "dev": true, - "license": "MIT" - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/lunr": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", - "dev": true, - "license": "MIT" - }, - "node_modules/magic-string": { - "version": "0.30.17", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", - "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0" - } - }, - "node_modules/magicast": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", - "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.25.4", - "@babel/types": "^7.25.4", - "source-map-js": "^1.2.0" - } - }, - "node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1", - "entities": "^4.4.0", - "linkify-it": "^5.0.0", - "mdurl": "^2.0.0", - "punycode.js": "^2.3.1", - "uc.micro": "^2.1.0" - }, - "bin": { - "markdown-it": "bin/markdown-it.mjs" - } - }, - "node_modules/mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", - "dev": true - }, - "node_modules/memoize": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/memoize/-/memoize-10.0.0.tgz", - "integrity": "sha512-H6cBLgsi6vMWOcCpvVCdFFnl3kerEXbrYh9q+lY6VXvQSmM6CkmV08VOwT+WE2tzIEqRPFfAq3fm4v/UIW6mSA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-function": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sindresorhus/memoize?sponsor=1" - } - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/micromatch/node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-function": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", - "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/moo-color": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz", - "integrity": "sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "^1.1.4" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/msw": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/msw/-/msw-2.4.9.tgz", - "integrity": "sha512-1m8xccT6ipN4PTqLinPwmzhxQREuxaEJYdx4nIbggxP8aM7r1e71vE7RtOUSQoAm1LydjGfZKy7370XD/tsuYg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "@bundled-es-modules/cookie": "^2.0.0", - "@bundled-es-modules/statuses": "^1.0.1", - "@bundled-es-modules/tough-cookie": "^0.1.6", - "@inquirer/confirm": "^3.0.0", - "@mswjs/interceptors": "^0.35.8", - "@open-draft/until": "^2.1.0", - "@types/cookie": "^0.6.0", - "@types/statuses": "^2.0.4", - "chalk": "^4.1.2", - "graphql": "^16.8.1", - "headers-polyfill": "^4.0.2", - "is-node-process": "^1.2.0", - "outvariant": "^1.4.2", - "path-to-regexp": "^6.3.0", - "strict-event-emitter": "^0.5.1", - "type-fest": "^4.9.0", - "yargs": "^17.7.2" - }, - "bin": { - "msw": "cli/index.js" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/mswjs" - }, - "peerDependencies": { - "typescript": ">= 4.8.x" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/msw/node_modules/@inquirer/confirm": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.2.0.tgz", - "integrity": "sha512-oOIwPs0Dvq5220Z8lGL/6LHRTEr9TgLHmiI99Rj1PJ1p1czTys+olrgBqZk4E2qC0YTzeHprxSQmoHioVdJ7Lw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@inquirer/core": "^9.1.0", - "@inquirer/type": "^1.5.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/msw/node_modules/@inquirer/type": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.5.5.tgz", - "integrity": "sha512-MzICLu4yS7V8AA61sANROZ9vT1H3ooca5dSmI1FjZkzq7o/koMsRfQSzRtFo+F3Ao4Sf1C0bpLKejpKB/+j6MA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mute-stream": "^1.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/msw/node_modules/type-fest": { - "version": "4.26.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz", - "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mustache": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", - "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", - "license": "MIT", - "bin": { - "mustache": "bin/mustache" - } - }, - "node_modules/mute-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", - "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/node-releases": { - "version": "2.0.17", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.17.tgz", - "integrity": "sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==", - "dev": true - }, - "node_modules/nwsapi": { - "version": "2.2.12", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz", - "integrity": "sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==", - "dev": true - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/optionator": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", - "dev": true, - "license": "MIT", - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.5" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/outvariant": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", - "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", - "dev": true, - "license": "MIT" - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", - "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, - "node_modules/pako": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" - }, - "node_modules/papaparse": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", - "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==", - "license": "MIT" - }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "license": "MIT", - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true, - "license": "MIT" - }, - "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/path-to-regexp": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", - "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/pathe": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", - "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/pathval": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", - "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14.16" - } - }, - "node_modules/phaser": { - "version": "3.80.1", - "resolved": "https://registry.npmjs.org/phaser/-/phaser-3.80.1.tgz", - "integrity": "sha512-VQGAWoDOkEpAWYkI+PUADv5Ql+SM0xpLuAMBJHz9tBcOLqjJ2wd8bUhxJgOqclQlLTg97NmMd9MhS75w16x1Cw==", - "license": "MIT", - "dependencies": { - "eventemitter3": "^5.0.1" - } - }, - "node_modules/phaser3-rex-plugins": { - "version": "1.80.5", - "resolved": "https://registry.npmjs.org/phaser3-rex-plugins/-/phaser3-rex-plugins-1.80.5.tgz", - "integrity": "sha512-hdL3Cm6dK72w6phQdGnEiqqntlwT8SvjU0yit7DkdqiPy/Io1g3KnsRFqndtY+Hu69zaMEuckpIVeQK6yVwx4A==", - "dependencies": { - "eventemitter3": "^3.1.2", - "i18next": "^22.5.1", - "i18next-http-backend": "^2.5.2", - "js-yaml": "^4.1.0", - "mustache": "^4.2.0", - "papaparse": "^5.4.1", - "webfontloader": "^1.6.28" - } - }, - "node_modules/phaser3-rex-plugins/node_modules/eventemitter3": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", - "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", - "license": "MIT" - }, - "node_modules/phaser3-rex-plugins/node_modules/i18next": { - "version": "22.5.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.5.1.tgz", - "integrity": "sha512-8TGPgM3pAD+VRsMtUMNknRz3kzqwp/gPALrWMsDnmC1mKqJwpWyooQRLMcbTwq8z8YwSmuj+ZYvc+xCuEpkssA==", - "funding": [ - { - "type": "individual", - "url": "https://locize.com" - }, - { - "type": "individual", - "url": "https://locize.com/i18next.html" - }, - { - "type": "individual", - "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" - } - ], - "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.20.6" - } - }, - "node_modules/phaser3spectorjs": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/phaser3spectorjs/-/phaser3spectorjs-0.0.8.tgz", - "integrity": "sha512-0dSO7/aMjEUPrp5EcjRvRRsEf+jXDbmzalPeJ6VtTB2Pn1PeaKc+qlL/DmO3l1Dvc5lkzc+Sil1Ta+Hkyi5cbA==", - "dev": true, - "license": "MIT" - }, - "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", - "dev": true - }, - "node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/possible-typed-array-names": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", - "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/postcss": { - "version": "8.4.47", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", - "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.1.0", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/postcss/node_modules/picocolors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", - "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", - "dev": true - }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", - "dev": true, - "license": "MIT" - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/punycode.js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/readable-stream/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/rechoir": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", - "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "resolve": "^1.20.0" - }, - "engines": { - "node": ">= 10.13.0" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "license": "MIT" - }, - "node_modules/regexp-tree": { - "version": "0.1.27", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", - "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", - "dev": true, - "license": "MIT", - "bin": { - "regexp-tree": "bin/regexp-tree" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/resolve-pkg-maps": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", - "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/rollup": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", - "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", - "dev": true, - "dependencies": { - "@types/estree": "1.0.5" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.22.4", - "@rollup/rollup-android-arm64": "4.22.4", - "@rollup/rollup-darwin-arm64": "4.22.4", - "@rollup/rollup-darwin-x64": "4.22.4", - "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", - "@rollup/rollup-linux-arm-musleabihf": "4.22.4", - "@rollup/rollup-linux-arm64-gnu": "4.22.4", - "@rollup/rollup-linux-arm64-musl": "4.22.4", - "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", - "@rollup/rollup-linux-riscv64-gnu": "4.22.4", - "@rollup/rollup-linux-s390x-gnu": "4.22.4", - "@rollup/rollup-linux-x64-gnu": "4.22.4", - "@rollup/rollup-linux-x64-musl": "4.22.4", - "@rollup/rollup-win32-arm64-msvc": "4.22.4", - "@rollup/rollup-win32-ia32-msvc": "4.22.4", - "@rollup/rollup-win32-x64-msvc": "4.22.4", - "fsevents": "~2.3.2" - } - }, - "node_modules/rrweb-cssom": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz", - "integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==", - "dev": true - }, - "node_modules/run-async": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-3.0.0.tgz", - "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.1.0" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/safe-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz", - "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", - "dev": true, - "license": "MIT", - "dependencies": { - "regexp-tree": "~0.1.1" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, - "license": "MIT" - }, - "node_modules/saxes": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", - "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", - "dev": true, - "license": "ISC", - "dependencies": { - "xmlchars": "^2.2.0" - }, - "engines": { - "node": ">=v12.22.7" - } - }, - "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/set-function-length": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "license": "MIT", - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/shiki": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.12.0.tgz", - "integrity": "sha512-BuAxWOm5JhRcbSOl7XCei8wGjgJJonnV0oipUupPY58iULxUGyHhW5CF+9FRMuM1pcJ5cGEJGll1LusX6FwpPA==", - "dev": true, - "dependencies": { - "@shikijs/core": "1.12.0", - "@types/hast": "^3.0.4" - } - }, - "node_modules/siginfo": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", - "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", - "dev": true, - "license": "ISC" - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true, - "license": "MIT" - }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/stable-hash": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", - "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", - "dev": true, - "license": "MIT" - }, - "node_modules/stackback": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", - "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", - "dev": true, - "license": "MIT" - }, - "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/std-env": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", - "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", - "dev": true, - "license": "MIT" - }, - "node_modules/strict-event-emitter": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", - "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/string-width/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/string-width/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", - "dev": true, - "license": "MIT" - }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/teamcity-service-messages": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/teamcity-service-messages/-/teamcity-service-messages-0.1.14.tgz", - "integrity": "sha512-29aQwaHqm8RMX74u2o/h1KbMLP89FjNiMxD9wbF2BbWOnbM+q+d1sCEC+MqCc4QW3NJykn77OMpTFw/xTHIc0w==", - "dev": true, - "license": "MIT" - }, - "node_modules/test-exclude": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", - "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", - "dev": true, - "license": "ISC", - "dependencies": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^10.4.1", - "minimatch": "^9.0.4" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/test-exclude/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true, - "license": "MIT" - }, - "node_modules/tinybench": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", - "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", - "dev": true, - "license": "MIT" - }, - "node_modules/tinyexec": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", - "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", - "dev": true, - "license": "MIT" - }, - "node_modules/tinypool": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", - "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.0.0 || >=20.0.0" - } - }, - "node_modules/tinyrainbow": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", - "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tinyspy": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", - "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "license": "MIT", - "dependencies": { - "os-tmpdir": "~1.0.2" - }, - "engines": { - "node": ">=0.6.0" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/tough-cookie": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", - "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tr46": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz", - "integrity": "sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==", - "dev": true, - "dependencies": { - "punycode": "^2.3.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/ts-api-utils": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", - "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "typescript": ">=4.2.0" - } - }, - "node_modules/tsconfck": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-3.1.1.tgz", - "integrity": "sha512-00eoI6WY57SvZEVjm13stEVE90VkEdJAFGgpFLTsZbJyW/LwFQ7uQxJHWpZ2hzSWgCPKc9AnBnNP+0X7o3hAmQ==", - "dev": true, - "license": "MIT", - "bin": { - "tsconfck": "bin/tsconfck.js" - }, - "engines": { - "node": "^18 || >=20" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/tsconfig-paths-webpack-plugin": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.1.0.tgz", - "integrity": "sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "enhanced-resolve": "^5.7.0", - "tsconfig-paths": "^4.1.2" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", - "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", - "dev": true, - "license": "MIT", - "dependencies": { - "json5": "^2.2.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", - "dev": true, - "license": "0BSD" - }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "license": "MIT", - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/typedoc": { - "version": "0.26.5", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", - "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", - "dev": true, - "dependencies": { - "lunr": "^2.3.9", - "markdown-it": "^14.1.0", - "minimatch": "^9.0.5", - "shiki": "^1.9.1", - "yaml": "^2.4.5" - }, - "bin": { - "typedoc": "bin/typedoc" - }, - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" - } - }, - "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/typescript-eslint": { - "version": "8.0.0-alpha.58", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.0.0-alpha.58.tgz", - "integrity": "sha512-0mvrodNhExpkWns+5RaZP8YqsAfPyjmPVVM1p+kaJkvApMH58/VFcQ0iSQuun0bFRNCMvW0ZUdulS9AsHqVXkg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@typescript-eslint/eslint-plugin": "8.0.0-alpha.58", - "@typescript-eslint/parser": "8.0.0-alpha.58", - "@typescript-eslint/utils": "8.0.0-alpha.58" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "dev": true - }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true, - "license": "MIT" - }, - "node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/update-browserslist-db": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", - "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.1.2", - "picocolors": "^1.0.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" - }, - "node_modules/vite": { - "version": "5.4.14", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz", - "integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "^0.21.3", - "postcss": "^8.4.43", - "rollup": "^4.20.0" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^18.0.0 || >=20.0.0", - "less": "*", - "lightningcss": "^1.21.0", - "sass": "*", - "sass-embedded": "*", - "stylus": "*", - "sugarss": "*", - "terser": "^5.4.0" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "less": { - "optional": true - }, - "lightningcss": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - }, - "stylus": { - "optional": true - }, - "sugarss": { - "optional": true - }, - "terser": { - "optional": true - } - } - }, - "node_modules/vite-node": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz", - "integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==", - "dev": true, - "license": "MIT", - "dependencies": { - "cac": "^6.7.14", - "debug": "^4.3.7", - "es-module-lexer": "^1.5.4", - "pathe": "^1.1.2", - "vite": "^5.0.0" - }, - "bin": { - "vite-node": "vite-node.mjs" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/vite-tsconfig-paths": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.3.2.tgz", - "integrity": "sha512-0Vd/a6po6Q+86rPlntHye7F31zA2URZMbH8M3saAZ/xR9QoGN/L21bxEGfXdWmFdNkqPpRdxFT7nmNe12e9/uA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "globrex": "^0.1.2", - "tsconfck": "^3.0.3" - }, - "peerDependencies": { - "vite": "*" - }, - "peerDependenciesMeta": { - "vite": { - "optional": true - } - } - }, - "node_modules/vitest": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.9.tgz", - "integrity": "sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/expect": "2.1.9", - "@vitest/mocker": "2.1.9", - "@vitest/pretty-format": "^2.1.9", - "@vitest/runner": "2.1.9", - "@vitest/snapshot": "2.1.9", - "@vitest/spy": "2.1.9", - "@vitest/utils": "2.1.9", - "chai": "^5.1.2", - "debug": "^4.3.7", - "expect-type": "^1.1.0", - "magic-string": "^0.30.12", - "pathe": "^1.1.2", - "std-env": "^3.8.0", - "tinybench": "^2.9.0", - "tinyexec": "^0.3.1", - "tinypool": "^1.0.1", - "tinyrainbow": "^1.2.0", - "vite": "^5.0.0", - "vite-node": "2.1.9", - "why-is-node-running": "^2.3.0" - }, - "bin": { - "vitest": "vitest.mjs" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "@edge-runtime/vm": "*", - "@types/node": "^18.0.0 || >=20.0.0", - "@vitest/browser": "2.1.9", - "@vitest/ui": "2.1.9", - "happy-dom": "*", - "jsdom": "*" - }, - "peerDependenciesMeta": { - "@edge-runtime/vm": { - "optional": true - }, - "@types/node": { - "optional": true - }, - "@vitest/browser": { - "optional": true - }, - "@vitest/ui": { - "optional": true - }, - "happy-dom": { - "optional": true - }, - "jsdom": { - "optional": true - } - } - }, - "node_modules/vitest-canvas-mock": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/vitest-canvas-mock/-/vitest-canvas-mock-0.3.3.tgz", - "integrity": "sha512-3P968tYBpqYyzzOaVtqnmYjqbe13576/fkjbDEJSfQAkHtC5/UjuRHOhFEN/ZV5HVZIkaROBUWgazDKJ+Ibw+Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "jest-canvas-mock": "~2.5.2" - }, - "peerDependencies": { - "vitest": "*" - } - }, - "node_modules/w3c-xmlserializer": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", - "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", - "dev": true, - "license": "MIT", - "dependencies": { - "xml-name-validator": "^5.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/watskeburt": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/watskeburt/-/watskeburt-4.1.0.tgz", - "integrity": "sha512-KkY5H51ajqy9HYYI+u9SIURcWnqeVVhdH0I+ab6aXPGHfZYxgRCwnR6Lm3+TYB6jJVt5jFqw4GAKmwf1zHmGQw==", - "dev": true, - "bin": { - "watskeburt": "dist/run-cli.js" - }, - "engines": { - "node": "^18||>=20" - } - }, - "node_modules/webfontloader": { - "version": "1.6.28", - "resolved": "https://registry.npmjs.org/webfontloader/-/webfontloader-1.6.28.tgz", - "integrity": "sha512-Egb0oFEga6f+nSgasH3E0M405Pzn6y3/9tOVanv/DLfa1YBIgcv90L18YyWnvXkRbIM17v5Kv6IT2N6g1x5tvQ==", - "license": "Apache-2.0" - }, - "node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-encoding": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", - "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "iconv-lite": "0.6.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/whatwg-encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/whatwg-mimetype": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", - "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/whatwg-url": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.0.0.tgz", - "integrity": "sha512-1lfMEm2IEr7RIV+f4lUNPOqfFL+pO+Xw3fJSqmjX9AbXcXcYOkCe1P6+9VBZB6n94af16NfZf+sSk0JCBZC9aw==", - "dev": true, - "dependencies": { - "tr46": "^5.0.0", - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/why-is-node-running": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", - "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", - "dev": true, - "license": "MIT", - "dependencies": { - "siginfo": "^2.0.0", - "stackback": "0.0.2" - }, - "bin": { - "why-is-node-running": "cli.js" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/ws": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", - "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/xml-name-validator": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", - "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=18" - } - }, - "node_modules/xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", - "dev": true, - "license": "MIT" - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, - "license": "ISC" - }, - "node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", - "dev": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yoctocolors-cjs": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz", - "integrity": "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } + "name": "pokemon-rogue-battle", + "version": "1.7.7", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pokemon-rogue-battle", + "version": "1.7.7", + "hasInstallScript": true, + "dependencies": { + "@material/material-color-utilities": "^0.2.7", + "crypto-js": "^4.2.0", + "i18next": "^23.11.1", + "i18next-browser-languagedetector": "^7.2.1", + "i18next-http-backend": "^2.6.1", + "i18next-korean-postposition-processor": "^1.0.0", + "json-stable-stringify": "^1.1.0", + "jszip": "^3.10.1", + "phaser": "^3.70.0", + "phaser3-rex-plugins": "^1.1.84" + }, + "devDependencies": { + "@biomejs/biome": "1.9.4", + "@eslint/js": "^9.3.0", + "@hpcc-js/wasm": "^2.18.0", + "@stylistic/eslint-plugin-ts": "^2.6.0-beta.0", + "@types/jsdom": "^21.1.7", + "@types/node": "^20.12.13", + "@typescript-eslint/eslint-plugin": "^8.0.0-alpha.54", + "@typescript-eslint/parser": "^8.0.0-alpha.54", + "@vitest/coverage-istanbul": "^2.1.9", + "dependency-cruiser": "^16.3.10", + "eslint": "^9.7.0", + "eslint-plugin-import-x": "^4.2.1", + "inquirer": "^11.0.2", + "jsdom": "^24.0.0", + "lefthook": "^1.6.12", + "msw": "^2.4.9", + "phaser3spectorjs": "^0.0.8", + "typedoc": "^0.26.4", + "typescript": "^5.5.3", + "typescript-eslint": "^8.0.0-alpha.54", + "vite": "^5.4.14", + "vite-tsconfig-paths": "^4.3.2", + "vitest": "^2.1.9", + "vitest-canvas-mock": "^0.3.3" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", + "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/highlight": "^7.24.7", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", + "integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", + "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.24.9", + "@babel/helper-compilation-targets": "^7.24.8", + "@babel/helper-module-transforms": "^7.24.9", + "@babel/helpers": "^7.24.8", + "@babel/parser": "^7.24.8", + "@babel/template": "^7.24.7", + "@babel/traverse": "^7.24.8", + "@babel/types": "^7.24.9", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.24.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", + "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.9", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", + "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.24.8", + "@babel/helper-validator-option": "^7.24.8", + "browserslist": "^4.23.1", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", + "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", + "dev": true, + "dependencies": { + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", + "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", + "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", + "integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-environment-visitor": "^7.24.7", + "@babel/helper-module-imports": "^7.24.7", + "@babel/helper-simple-access": "^7.24.7", + "@babel/helper-split-export-declaration": "^7.24.7", + "@babel/helper-validator-identifier": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", + "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", + "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", + "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.8.tgz", + "integrity": "sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.8" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", + "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.24.7", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.26.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.8.tgz", + "integrity": "sha512-TZIQ25pkSoaKEYYaHbbxkfL36GNsQ6iFiBbeuzAkLnXayKR1yP1zFe+NxuZWWsUyvt8icPU9CCq0sgWGXR1GEw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", + "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.7.tgz", + "integrity": "sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.24.7", + "@babel/parser": "^7.24.7", + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.8.tgz", + "integrity": "sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.24.8", + "@babel/helper-environment-visitor": "^7.24.7", + "@babel/helper-function-name": "^7.24.7", + "@babel/helper-hoist-variables": "^7.24.7", + "@babel/helper-split-export-declaration": "^7.24.7", + "@babel/parser": "^7.24.8", + "@babel/types": "^7.24.8", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/types": { + "version": "7.26.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.8.tgz", + "integrity": "sha512-eUuWapzEGWFEpHFxgEaBG8e3n6S8L3MSu0oda755rOfabWPnh0Our1AozNFVUxGFIhbKgd1ksprsoDGMinTOTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@biomejs/biome": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz", + "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==", + "dev": true, + "hasInstallScript": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.9.4", + "@biomejs/cli-darwin-x64": "1.9.4", + "@biomejs/cli-linux-arm64": "1.9.4", + "@biomejs/cli-linux-arm64-musl": "1.9.4", + "@biomejs/cli-linux-x64": "1.9.4", + "@biomejs/cli-linux-x64-musl": "1.9.4", + "@biomejs/cli-win32-arm64": "1.9.4", + "@biomejs/cli-win32-x64": "1.9.4" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz", + "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz", + "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz", + "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz", + "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz", + "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz", + "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz", + "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz", + "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@bundled-es-modules/cookie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.0.tgz", + "integrity": "sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cookie": "^0.5.0" + } + }, + "node_modules/@bundled-es-modules/statuses": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/statuses/-/statuses-1.0.1.tgz", + "integrity": "sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==", + "dev": true, + "license": "ISC", + "dependencies": { + "statuses": "^2.0.1" + } + }, + "node_modules/@bundled-es-modules/tough-cookie": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@bundled-es-modules/tough-cookie/-/tough-cookie-0.1.6.tgz", + "integrity": "sha512-dvMHbL464C0zI+Yqxbz6kZ5TOEp7GLW+pry/RWndAR8MJQAXZ2rPmIs8tziTZjeIyhSNZgZbCePtfSbdWqStJw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@types/tough-cookie": "^4.0.5", + "tough-cookie": "^4.1.4" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", + "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", + "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.7.0.tgz", + "integrity": "sha512-ChuWDQenef8OSFnvuxv0TCVxEwmu3+hPNKvM9B34qpM0rDRbjL8t5QkQeHHeAfsKQjuH9wS82WeCi1J/owatng==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@hpcc-js/wasm": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@hpcc-js/wasm/-/wasm-2.18.0.tgz", + "integrity": "sha512-M9XVIvAXGH4Xcyb5UoiohWcn6fil89pcos/gClNdBZG2v+W48xSf2bjcA8BW131X/AFHUerVY28n1P1Jw81/9A==", + "dev": true, + "dependencies": { + "yargs": "17.7.2" + }, + "bin": { + "dot-wasm": "bin/dot-wasm.js" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", + "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@inquirer/checkbox": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz", + "integrity": "sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/figures": "^1.0.6", + "@inquirer/type": "^2.0.0", + "ansi-escapes": "^4.3.2", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/confirm": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-4.0.1.tgz", + "integrity": "sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.2.1.tgz", + "integrity": "sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/figures": "^1.0.6", + "@inquirer/type": "^2.0.0", + "@types/mute-stream": "^0.0.4", + "@types/node": "^22.5.5", + "@types/wrap-ansi": "^3.0.0", + "ansi-escapes": "^4.3.2", + "cli-width": "^4.1.0", + "mute-stream": "^1.0.0", + "signal-exit": "^4.1.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/core/node_modules/@types/node": { + "version": "22.5.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", + "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@inquirer/core/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@inquirer/core/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@inquirer/core/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@inquirer/core/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@inquirer/editor": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-3.0.1.tgz", + "integrity": "sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0", + "external-editor": "^3.1.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/expand": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-3.0.1.tgz", + "integrity": "sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/figures": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.6.tgz", + "integrity": "sha512-yfZzps3Cso2UbM7WlxKwZQh2Hs6plrbjs1QnzQDZhK2DgyCo6D8AaHps9olkNcUFlcYERMqU3uJSp1gmy3s/qQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/input": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-3.0.1.tgz", + "integrity": "sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/number": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-2.0.1.tgz", + "integrity": "sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/password": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-3.0.1.tgz", + "integrity": "sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0", + "ansi-escapes": "^4.3.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/prompts": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-6.0.1.tgz", + "integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/checkbox": "^3.0.1", + "@inquirer/confirm": "^4.0.1", + "@inquirer/editor": "^3.0.1", + "@inquirer/expand": "^3.0.1", + "@inquirer/input": "^3.0.1", + "@inquirer/number": "^2.0.1", + "@inquirer/password": "^3.0.1", + "@inquirer/rawlist": "^3.0.1", + "@inquirer/search": "^2.0.1", + "@inquirer/select": "^3.0.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/rawlist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-3.0.1.tgz", + "integrity": "sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/type": "^2.0.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/search": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-2.0.1.tgz", + "integrity": "sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/figures": "^1.0.6", + "@inquirer/type": "^2.0.0", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/select": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-3.0.1.tgz", + "integrity": "sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/figures": "^1.0.6", + "@inquirer/type": "^2.0.0", + "ansi-escapes": "^4.3.2", + "yoctocolors-cjs": "^2.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@inquirer/type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-2.0.0.tgz", + "integrity": "sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==", + "dev": true, + "license": "MIT", + "dependencies": { + "mute-stream": "^1.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@material/material-color-utilities": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@material/material-color-utilities/-/material-color-utilities-0.2.7.tgz", + "integrity": "sha512-0FCeqG6WvK4/Cc06F/xXMd/pv4FeisI0c1tUpBbfhA2n9Y8eZEv4Karjbmf2ZqQCPUWMrGp8A571tCjizxoTiQ==", + "license": "Apache-2.0" + }, + "node_modules/@mswjs/interceptors": { + "version": "0.35.8", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.35.8.tgz", + "integrity": "sha512-PFfqpHplKa7KMdoQdj5td03uG05VK2Ng1dG0sP4pT9h0dGSX2v9txYt/AnrzPb/vAmfyBBC0NQV7VaBEX+efgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@open-draft/deferred-promise": "^2.2.0", + "@open-draft/logger": "^0.3.0", + "@open-draft/until": "^2.0.0", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.3", + "strict-event-emitter": "^0.5.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@open-draft/deferred-promise": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", + "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@open-draft/logger": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", + "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-node-process": "^1.2.0", + "outvariant": "^1.4.0" + } + }, + "node_modules/@open-draft/until": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", + "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@shikijs/core": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.12.0.tgz", + "integrity": "sha512-mc1cLbm6UQ8RxLc0dZES7v5rkH+99LxQp/ZvTqV3NLyYsO/fD6JhEflP1H5b2SDq9gI0+0G36AVZWxvounfR9w==", + "dev": true, + "dependencies": { + "@types/hast": "^3.0.4" + } + }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "2.6.0-beta.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.6.0-beta.0.tgz", + "integrity": "sha512-KQiNvzNzvl9AmMs1MiIBszLIy/Xy1bTExnyaVy5dSzOF9c+yT64JQfH0p0jP6XpGwoCnZsrPUNflwP30G42QBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/eslint": "^8.56.10", + "acorn": "^8.12.0", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts": { + "version": "2.6.0-beta.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.6.0-beta.0.tgz", + "integrity": "sha512-WMz1zgmMC3bvg1L/tiYt5ygvDbTDKlbezoHoX2lV9MnUCAEQZUP4xJ9Wj3jmIKxb4mUuK5+vFZJVcOygvbbqow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@stylistic/eslint-plugin-js": "2.6.0-beta.0", + "@types/eslint": "^8.56.10", + "@typescript-eslint/utils": "^8.0.0-alpha.34" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/eslint": { + "version": "8.56.11", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.11.tgz", + "integrity": "sha512-sVBpJMf7UPo/wGecYOpk2aQya2VUGeHhe38WG7/mN5FufNSubf5VT9Uh9Uyp8/eLJpu1/tuhJ/qTo4mhSB4V4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/jsdom": { + "version": "21.1.7", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-21.1.7.tgz", + "integrity": "sha512-yOriVnggzrnQ3a9OKOCxaVuSug3w3/SbOj5i7VwXWZEyUNl3bLF9V3MfxGbZKuwqJOQyRfqXyROBB1CoZLFWzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/tough-cookie": "*", + "parse5": "^7.0.0" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mute-stream": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz", + "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/statuses": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.5.tgz", + "integrity": "sha512-jmIUGWrAiwu3dZpxntxieC+1n/5c3mjrImkmOSQ2NC5uP6cYO4aAZDdSmRcI5C1oiTmqlZGHC+/NmJrKogbP5A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/unist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", + "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", + "dev": true + }, + "node_modules/@types/wrap-ansi": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz", + "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.0.0-alpha.58.tgz", + "integrity": "sha512-5G9oIj8jvosj8RTa0VDFXvRmUg1U6FxXJu7ZEfyJYMvFkdMJoY5YnzFvgAvHbYsXOj+YgXZu81fNOTRWQzwk5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.0.0-alpha.58", + "@typescript-eslint/type-utils": "8.0.0-alpha.58", + "@typescript-eslint/utils": "8.0.0-alpha.58", + "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.0.0-alpha.58.tgz", + "integrity": "sha512-/RpgxIejBui6WXJgV9ukwzxmvbZt5TlfHUGGLB/BsNLj+NRZEbXVtWT9rKuxVOqsGb1Dn9c5gxvBI/XzyuIsMQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/scope-manager": "8.0.0-alpha.58", + "@typescript-eslint/types": "8.0.0-alpha.58", + "@typescript-eslint/typescript-estree": "8.0.0-alpha.58", + "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.0.0-alpha.58.tgz", + "integrity": "sha512-bGgJXn8B3Pf3mzEOUQTPxEqhux54MOJSqw4HcgBReuP7dudz/hsN4TH9GqHbMXkFv8N4Ed1iqVRfgGeC8b1mGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.0.0-alpha.58", + "@typescript-eslint/visitor-keys": "8.0.0-alpha.58" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.0.0-alpha.58.tgz", + "integrity": "sha512-spW/I/UAY6HM0lKj+/333Zb9arOvUoi8+H0cVNYHELPhOti9re9NjyyJFhck84PNiwi8WmpkEf3GXe7/h+Cquw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.0.0-alpha.58", + "@typescript-eslint/utils": "8.0.0-alpha.58", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.0.0-alpha.58.tgz", + "integrity": "sha512-6+jM4y31a6pwKeV3MVQuVXPZl6d3I1ySMvP5WjZdZ+n57uovMvasZ3ZJstXngoRpa7JtkjVZ7NrMhQ1J8dxKCQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.0.0-alpha.58.tgz", + "integrity": "sha512-hm4nsoJnQcA7axMopUJrH7CD0MJhAMtE2zQt65uMFCy+U2YDdKPwE0g6qEAUBoKn6UBLQJWthJgUmwDbWrnwZg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.0.0-alpha.58", + "@typescript-eslint/visitor-keys": "8.0.0-alpha.58", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.0.0-alpha.58.tgz", + "integrity": "sha512-lZuGnpK23jr3huebgY4/qqrOKsWJ8dX0Q1Fo4oVYcyAy+sK6p+6nObK4VEPJG098gUmrriiavRiDKIhPDFm4Ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.0.0-alpha.58", + "@typescript-eslint/types": "8.0.0-alpha.58", + "@typescript-eslint/typescript-estree": "8.0.0-alpha.58" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.0.0-alpha.58.tgz", + "integrity": "sha512-V//E9PRY2216kh9fN/ihRvTtjpobAXEtmrsr3utlVUwHa2iklcofq1J12yl3KOjx9QBRfBrtfQnYaeruF7L0Fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.0.0-alpha.58", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@vitest/coverage-istanbul": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/coverage-istanbul/-/coverage-istanbul-2.1.9.tgz", + "integrity": "sha512-vdYE4FkC/y2lxcN3Dcj54Bw+ericmDwiex0B8LV5F/YNYEYP1mgVwhPnHwWGAXu38qizkjOuyczKbFTALfzFKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@istanbuljs/schema": "^0.1.3", + "debug": "^4.3.7", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-instrument": "^6.0.3", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.1.7", + "magicast": "^0.3.5", + "test-exclude": "^7.0.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": "2.1.9" + } + }, + "node_modules/@vitest/expect": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", + "integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.9", + "@vitest/utils": "2.1.9", + "chai": "^5.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.9.tgz", + "integrity": "sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.9", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.12" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz", + "integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.9.tgz", + "integrity": "sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "2.1.9", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.9.tgz", + "integrity": "sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.9", + "magic-string": "^0.30.12", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz", + "integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz", + "integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.9", + "loupe": "^3.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/acorn-jsx-walk": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/acorn-jsx-walk/-/acorn-jsx-walk-2.0.0.tgz", + "integrity": "sha512-uuo6iJj4D4ygkdzd6jPtcxs8vZgDX9YFIkqczGImoypX2fQ4dVImmu3UzA4ynixCIMTrEOWW+95M2HuBaCEOVA==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn-loose": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/acorn-loose/-/acorn-loose-8.4.0.tgz", + "integrity": "sha512-M0EUka6rb+QC4l9Z3T0nJEzNOO7JcoJlYMrBlyBCiFSXRyxjLKayd4TbQs2FDRWQU1h9FR7QVNHt+PEaoNL5rQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", + "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", + "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001640", + "electron-to-chromium": "^1.4.820", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.1.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001642", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001642.tgz", + "integrity": "sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chai": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.2.tgz", + "integrity": "sha512-aGtmf24DW6MLHHG5gCx4zaI3uBq3KRtxeVs0DjFH6Z0rDNbsvTxFASFvdj79pxjxZ8/5u3PIiN3IwEIQkiiuPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true, + "license": "MIT" + }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "node_modules/cross-fetch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", + "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "license": "MIT" + }, + "node_modules/cssfontparser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz", + "integrity": "sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cssstyle": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.0.1.tgz", + "integrity": "sha512-8ZYiJ3A/3OkDd093CBT/0UKDWry7ak4BdPTFP2+QEP7cmhouyq/Up709ASSj2cK02BbZiMgk7kYjZNS4QP5qrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "rrweb-cssom": "^0.6.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cssstyle/node_modules/rrweb-cssom": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz", + "integrity": "sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==", + "dev": true + }, + "node_modules/data-urls": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dependency-cruiser": { + "version": "16.3.10", + "resolved": "https://registry.npmjs.org/dependency-cruiser/-/dependency-cruiser-16.3.10.tgz", + "integrity": "sha512-WkCnibHBfvaiaQ+S46LZ6h4AR6oj42Vsf5/0Vgtrwdwn7ZekMJdZ/ALoTwNp/RaGlKW+MbV/fhSZOvmhAWVWzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "8.12.1", + "acorn-jsx": "5.3.2", + "acorn-jsx-walk": "2.0.0", + "acorn-loose": "8.4.0", + "acorn-walk": "8.3.3", + "ajv": "8.17.1", + "commander": "12.1.0", + "enhanced-resolve": "5.17.1", + "ignore": "5.3.1", + "interpret": "^3.1.1", + "is-installed-globally": "1.0.0", + "json5": "2.2.3", + "memoize": "10.0.0", + "picocolors": "1.0.1", + "picomatch": "4.0.2", + "prompts": "2.4.2", + "rechoir": "^0.8.0", + "safe-regex": "2.1.1", + "semver": "^7.6.3", + "teamcity-service-messages": "0.1.14", + "tsconfig-paths-webpack-plugin": "4.1.0", + "watskeburt": "4.1.0" + }, + "bin": { + "depcruise": "bin/dependency-cruise.mjs", + "depcruise-baseline": "bin/depcruise-baseline.mjs", + "depcruise-fmt": "bin/depcruise-fmt.mjs", + "depcruise-wrap-stream-in-html": "bin/wrap-stream-in-html.mjs", + "dependency-cruise": "bin/dependency-cruise.mjs", + "dependency-cruiser": "bin/dependency-cruise.mjs" + }, + "engines": { + "node": "^18.17||>=20" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.4.830", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.830.tgz", + "integrity": "sha512-TrPKKH20HeN0J1LHzsYLs2qwXrp8TF4nHdu4sq61ozGbzMpWhI7iIOPYPPkxeq1azMT9PZ8enPFcftbs/Npcjg==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/enhanced-resolve": { + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-module-lexer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz", + "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.7.0.tgz", + "integrity": "sha512-FzJ9D/0nGiCGBf8UXO/IGLTgLVzIxze1zpfA8Ton2mjLovXdAPlYDv+MQDcqj3TmrhAGYfOpz9RfR+ent0AgAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.11.0", + "@eslint/config-array": "^0.17.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.7.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.3.0", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.0.2", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import-x": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.2.1.tgz", + "integrity": "sha512-WWi2GedccIJa0zXxx3WDnTgouGQTtdYK1nhXMwywbqqAgB0Ov+p1pYBsWh3VaB0bvBOwLse6OfVII7jZD9xo5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^8.1.0", + "debug": "^4.3.4", + "doctrine": "^3.0.0", + "eslint-import-resolver-node": "^0.3.9", + "get-tsconfig": "^4.7.3", + "is-glob": "^4.0.3", + "minimatch": "^9.0.3", + "semver": "^7.6.3", + "stable-hash": "^0.0.4", + "tslib": "^2.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/scope-manager": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.5.0.tgz", + "integrity": "sha512-06JOQ9Qgj33yvBEx6tpC8ecP9o860rsR22hWMEd12WcTRrfaFgHr2RB/CA/B+7BMhHkXT4chg2MyboGdFGawYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.5.0", + "@typescript-eslint/visitor-keys": "8.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/types": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.5.0.tgz", + "integrity": "sha512-qjkormnQS5wF9pjSi6q60bKUHH44j2APxfh9TQRXK8wbYVeDYYdYJGIROL87LGZZ2gz3Rbmjc736qyL8deVtdw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.5.0.tgz", + "integrity": "sha512-vEG2Sf9P8BPQ+d0pxdfndw3xIXaoSjliG0/Ejk7UggByZPKXmJmw3GW5jV2gHNQNawBUyfahoSiCFVov0Ruf7Q==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.5.0", + "@typescript-eslint/visitor-keys": "8.5.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/utils": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.5.0.tgz", + "integrity": "sha512-6yyGYVL0e+VzGYp60wvkBHiqDWOpT63pdMV2CVG4LVDd5uR6q1qQN/7LafBZtAtNIn/mqXjsSeS5ggv/P0iECw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.5.0", + "@typescript-eslint/types": "8.5.0", + "@typescript-eslint/typescript-estree": "8.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-import-x/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.5.0.tgz", + "integrity": "sha512-yTPqMnbAZJNy2Xq2XU8AdtOW9tJIr+UQb64aXB9f3B1498Zx9JorVgFJcZpEc9UBuCCrdzKID2RGAMkYcDtZOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.5.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-scope": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", + "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, + "node_modules/expect-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", + "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "license": "MIT", + "dependencies": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", + "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true, + "license": "ISC" + }, + "node_modules/foreground-child": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-tsconfig": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.0.tgz", + "integrity": "sha512-Pgba6TExTZ0FJAn1qkJAjIeKoDJ3CsI2ChuLohJnZl/tTU8MVrq3b+2t5UOPfRa4RMsorClBjJALkJUMjG1PAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/global-directory": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz", + "integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ini": "4.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globrex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", + "dev": true, + "license": "MIT" + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, + "license": "MIT" + }, + "node_modules/graphql": { + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/headers-polyfill": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-4.0.3.tgz", + "integrity": "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-encoding-sniffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", + "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-encoding": "^3.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", + "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/i18next": { + "version": "23.12.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.12.2.tgz", + "integrity": "sha512-XIeh5V+bi8SJSWGL3jqbTEBW5oD6rbP5L+E7dVQh1MNTxxYef0x15rhJVcRb7oiuq4jLtgy2SD8eFlf6P2cmqg==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.23.2" + } + }, + "node_modules/i18next-browser-languagedetector": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-7.2.1.tgz", + "integrity": "sha512-h/pM34bcH6tbz8WgGXcmWauNpQupCGr25XPp9cZwZInR9XHSjIFDYp1SIok7zSPsTOMxdvuLyu86V+g2Kycnfw==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.23.2" + } + }, + "node_modules/i18next-http-backend": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.6.1.tgz", + "integrity": "sha512-rCilMAnlEQNeKOZY1+x8wLM5IpYOj10guGvEpeC59tNjj6MMreLIjIW8D1RclhD3ifLwn6d/Y9HEM1RUE6DSog==", + "license": "MIT", + "dependencies": { + "cross-fetch": "4.0.0" + } + }, + "node_modules/i18next-korean-postposition-processor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/i18next-korean-postposition-processor/-/i18next-korean-postposition-processor-1.0.0.tgz", + "integrity": "sha512-ruNXjI9awsFK6Ie+F9gYaMW8ciLMuCkeRjH9QkSv2Wb8xI0mnm773v3M9eua8dtvAXudIUk4p6Ho7hNkEASXDg==", + "license": "MIT", + "peerDependencies": { + "i18next": ">=8.4.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ini": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", + "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/inquirer": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-11.0.2.tgz", + "integrity": "sha512-pnbn3nL+JFrTw/pLhzyE/IQ3+gA3n5JxTAZQDjB6qu4gbjOaiTnpZbxT6HY2DDCT7bzDjTTsd3snRP+B6N//Pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.2.1", + "@inquirer/prompts": "^6.0.1", + "@inquirer/type": "^2.0.0", + "@types/mute-stream": "^0.0.4", + "ansi-escapes": "^4.3.2", + "mute-stream": "^1.0.0", + "run-async": "^3.0.0", + "rxjs": "^7.8.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/interpret": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", + "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/is-core-module": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "dev": true, + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-installed-globally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-1.0.0.tgz", + "integrity": "sha512-K55T22lfpQ63N4KEN57jZUAaAYqYHEe8veb/TycJRk9DdSCLLcovXz/mL6mOnhQaZsQGwPhuFopdQIlqGSEjiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "global-directory": "^4.0.1", + "is-path-inside": "^4.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-installed-globally/node_modules/is-path-inside": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", + "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-node-process": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", + "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/jest-canvas-mock": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.5.2.tgz", + "integrity": "sha512-vgnpPupjOL6+L5oJXzxTxFrlGEIbHdZqFU+LFNdtLxZ3lRDCl17FlTMM7IatoRQkrcyOTMlDinjUguqmQ6bR2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssfontparser": "^1.2.1", + "moo-color": "^1.0.2" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsdom": { + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-24.1.0.tgz", + "integrity": "sha512-6gpM7pRXCwIOKxX47cgOyvyQDN/Eh0f1MeKySBV2xGdKtqJBLj8P25eY3EVCWo2mglDDzozR2r2MW4T+JiNUZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssstyle": "^4.0.1", + "data-urls": "^5.0.0", + "decimal.js": "^10.4.3", + "form-data": "^4.0.0", + "html-encoding-sniffer": "^4.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.4", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.10", + "parse5": "^7.1.2", + "rrweb-cssom": "^0.7.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^4.1.4", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^3.1.1", + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0", + "ws": "^8.17.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "canvas": "^2.11.2" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/json-stable-stringify": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.1.tgz", + "integrity": "sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.5", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "license": "Public Domain", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lefthook": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-1.7.4.tgz", + "integrity": "sha512-lVv3nKH9l3KMDS3bySROvWJSw1+AsBHUO7xaA0rg1IEBZrj3+ePmM+a8elX+GU3Go1OzsZEYjo5AOOeLoZ7FQg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "lefthook": "bin/index.js" + }, + "optionalDependencies": { + "lefthook-darwin-arm64": "1.7.4", + "lefthook-darwin-x64": "1.7.4", + "lefthook-freebsd-arm64": "1.7.4", + "lefthook-freebsd-x64": "1.7.4", + "lefthook-linux-arm64": "1.7.4", + "lefthook-linux-x64": "1.7.4", + "lefthook-windows-arm64": "1.7.4", + "lefthook-windows-x64": "1.7.4" + } + }, + "node_modules/lefthook-darwin-arm64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-1.7.4.tgz", + "integrity": "sha512-6XpenaP0W7ZYA3lhHey/C1U+KmYz6eCq2cGswQsrTX+xdtHdWW3NbbOKngxATRTF8+CtF6m9UB2afP7qqkCghQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-darwin-x64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-1.7.4.tgz", + "integrity": "sha512-lpQXbPMHiaWE7+9fV+spjuMKiZ3J/+oI6hY1/l48MO3LmSpIv6DNy0VHho1fZVQnHdBU4bDh5c1G0r1f5T0irg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-freebsd-arm64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-1.7.4.tgz", + "integrity": "sha512-wv+JZgkD1/wi4X5aKKNodvxNcFcYmvL7uyzKkbtd/LgX5ssh9r5pO9J/71ULGtEuTXH4kqORRtez7u/ygqMEew==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-freebsd-x64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-1.7.4.tgz", + "integrity": "sha512-xoYR0Ay8pbyY9W9mI+iI9VDkkCVYSXhMf9XyOChSlu2XmjKiqi23hjCXvSOpvHQ7jphGvAVpE3Byijr6Xjuihw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-linux-arm64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-1.7.4.tgz", + "integrity": "sha512-WvXWzSM/e08n2f5lcC8j+pUMS0RzZftJK4zuBQ36TstSYXfBjWiw+FMnKCVZk6Q8Zc0icyF8sTmKQAyKCgX+UA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-linux-x64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.7.4.tgz", + "integrity": "sha512-eR5NxGzqPJm3wDTm4HStwGxOZ8Omb0ooodyuQdEOxtYidLrd4U18N14huwCEFd3BAOrjIWYV8plH+ReTZE56eg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-windows-arm64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-1.7.4.tgz", + "integrity": "sha512-C+MdHH+0ylermetMHwfHsYYNI5HI6QEOx7N4Iw4Ea6c3Yuj3eG3LsAzrhsup7KLSSBmDgIHOCJUx/Mfh2z+ATw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/lefthook-windows-x64": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-1.7.4.tgz", + "integrity": "sha512-BDQhiRzmMYPFQFtVtkRfUfeZuSlemG1oJfGKYXlCGFskvK9Jm1nGFnG0Ig63FAQaFdW33DFoLdr9ZKFTUQeSwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dependencies": { + "immediate": "~3.0.5" + } + }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/loupe": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", + "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true + }, + "node_modules/memoize": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/memoize/-/memoize-10.0.0.tgz", + "integrity": "sha512-H6cBLgsi6vMWOcCpvVCdFFnl3kerEXbrYh9q+lY6VXvQSmM6CkmV08VOwT+WE2tzIEqRPFfAq3fm4v/UIW6mSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-function": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/memoize?sponsor=1" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", + "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/moo-color": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz", + "integrity": "sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "^1.1.4" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/msw": { + "version": "2.4.9", + "resolved": "https://registry.npmjs.org/msw/-/msw-2.4.9.tgz", + "integrity": "sha512-1m8xccT6ipN4PTqLinPwmzhxQREuxaEJYdx4nIbggxP8aM7r1e71vE7RtOUSQoAm1LydjGfZKy7370XD/tsuYg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@bundled-es-modules/cookie": "^2.0.0", + "@bundled-es-modules/statuses": "^1.0.1", + "@bundled-es-modules/tough-cookie": "^0.1.6", + "@inquirer/confirm": "^3.0.0", + "@mswjs/interceptors": "^0.35.8", + "@open-draft/until": "^2.1.0", + "@types/cookie": "^0.6.0", + "@types/statuses": "^2.0.4", + "chalk": "^4.1.2", + "graphql": "^16.8.1", + "headers-polyfill": "^4.0.2", + "is-node-process": "^1.2.0", + "outvariant": "^1.4.2", + "path-to-regexp": "^6.3.0", + "strict-event-emitter": "^0.5.1", + "type-fest": "^4.9.0", + "yargs": "^17.7.2" + }, + "bin": { + "msw": "cli/index.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/mswjs" + }, + "peerDependencies": { + "typescript": ">= 4.8.x" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/msw/node_modules/@inquirer/confirm": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-3.2.0.tgz", + "integrity": "sha512-oOIwPs0Dvq5220Z8lGL/6LHRTEr9TgLHmiI99Rj1PJ1p1czTys+olrgBqZk4E2qC0YTzeHprxSQmoHioVdJ7Lw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@inquirer/core": "^9.1.0", + "@inquirer/type": "^1.5.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/msw/node_modules/@inquirer/type": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-1.5.5.tgz", + "integrity": "sha512-MzICLu4yS7V8AA61sANROZ9vT1H3ooca5dSmI1FjZkzq7o/koMsRfQSzRtFo+F3Ao4Sf1C0bpLKejpKB/+j6MA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mute-stream": "^1.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/msw/node_modules/type-fest": { + "version": "4.26.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz", + "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "license": "MIT", + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/node-releases": { + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.17.tgz", + "integrity": "sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==", + "dev": true + }, + "node_modules/nwsapi": { + "version": "2.2.12", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz", + "integrity": "sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==", + "dev": true + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/outvariant": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", + "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", + "dev": true, + "license": "MIT" + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, + "node_modules/papaparse": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", + "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==", + "license": "MIT" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse5": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", + "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/phaser": { + "version": "3.80.1", + "resolved": "https://registry.npmjs.org/phaser/-/phaser-3.80.1.tgz", + "integrity": "sha512-VQGAWoDOkEpAWYkI+PUADv5Ql+SM0xpLuAMBJHz9tBcOLqjJ2wd8bUhxJgOqclQlLTg97NmMd9MhS75w16x1Cw==", + "license": "MIT", + "dependencies": { + "eventemitter3": "^5.0.1" + } + }, + "node_modules/phaser3-rex-plugins": { + "version": "1.80.5", + "resolved": "https://registry.npmjs.org/phaser3-rex-plugins/-/phaser3-rex-plugins-1.80.5.tgz", + "integrity": "sha512-hdL3Cm6dK72w6phQdGnEiqqntlwT8SvjU0yit7DkdqiPy/Io1g3KnsRFqndtY+Hu69zaMEuckpIVeQK6yVwx4A==", + "dependencies": { + "eventemitter3": "^3.1.2", + "i18next": "^22.5.1", + "i18next-http-backend": "^2.5.2", + "js-yaml": "^4.1.0", + "mustache": "^4.2.0", + "papaparse": "^5.4.1", + "webfontloader": "^1.6.28" + } + }, + "node_modules/phaser3-rex-plugins/node_modules/eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", + "license": "MIT" + }, + "node_modules/phaser3-rex-plugins/node_modules/i18next": { + "version": "22.5.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.5.1.tgz", + "integrity": "sha512-8TGPgM3pAD+VRsMtUMNknRz3kzqwp/gPALrWMsDnmC1mKqJwpWyooQRLMcbTwq8z8YwSmuj+ZYvc+xCuEpkssA==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.20.6" + } + }, + "node_modules/phaser3spectorjs": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/phaser3spectorjs/-/phaser3spectorjs-0.0.8.tgz", + "integrity": "sha512-0dSO7/aMjEUPrp5EcjRvRRsEf+jXDbmzalPeJ6VtTB2Pn1PeaKc+qlL/DmO3l1Dvc5lkzc+Sil1Ta+Hkyi5cbA==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", + "dev": true + }, + "node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", + "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/postcss": { + "version": "8.4.47", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", + "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss/node_modules/picocolors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "dev": true + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", + "dev": true, + "license": "MIT" + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, + "node_modules/rechoir": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve": "^1.20.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "license": "MIT" + }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", + "dev": true, + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", + "fsevents": "~2.3.2" + } + }, + "node_modules/rrweb-cssom": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz", + "integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==", + "dev": true + }, + "node_modules/run-async": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-3.0.0.tgz", + "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/safe-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz", + "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "regexp-tree": "~0.1.1" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shiki": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.12.0.tgz", + "integrity": "sha512-BuAxWOm5JhRcbSOl7XCei8wGjgJJonnV0oipUupPY58iULxUGyHhW5CF+9FRMuM1pcJ5cGEJGll1LusX6FwpPA==", + "dev": true, + "dependencies": { + "@shikijs/core": "1.12.0", + "@types/hast": "^3.0.4" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stable-hash": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", + "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", + "dev": true, + "license": "MIT" + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/std-env": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/strict-event-emitter": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", + "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/teamcity-service-messages": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/teamcity-service-messages/-/teamcity-service-messages-0.1.14.tgz", + "integrity": "sha512-29aQwaHqm8RMX74u2o/h1KbMLP89FjNiMxD9wbF2BbWOnbM+q+d1sCEC+MqCc4QW3NJykn77OMpTFw/xTHIc0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", + "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tough-cookie": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", + "integrity": "sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tr46": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz", + "integrity": "sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==", + "dev": true, + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/ts-api-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "node_modules/tsconfck": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-3.1.1.tgz", + "integrity": "sha512-00eoI6WY57SvZEVjm13stEVE90VkEdJAFGgpFLTsZbJyW/LwFQ7uQxJHWpZ2hzSWgCPKc9AnBnNP+0X7o3hAmQ==", + "dev": true, + "license": "MIT", + "bin": { + "tsconfck": "bin/tsconfck.js" + }, + "engines": { + "node": "^18 || >=20" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/tsconfig-paths-webpack-plugin": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.1.0.tgz", + "integrity": "sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.7.0", + "tsconfig-paths": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tsconfig-paths-webpack-plugin/node_modules/tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "json5": "^2.2.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "dev": true, + "license": "0BSD" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typedoc": { + "version": "0.26.5", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", + "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", + "dev": true, + "dependencies": { + "lunr": "^2.3.9", + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", + "yaml": "^2.4.5" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" + } + }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.0.0-alpha.58", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.0.0-alpha.58.tgz", + "integrity": "sha512-0mvrodNhExpkWns+5RaZP8YqsAfPyjmPVVM1p+kaJkvApMH58/VFcQ0iSQuun0bFRNCMvW0ZUdulS9AsHqVXkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.0.0-alpha.58", + "@typescript-eslint/parser": "8.0.0-alpha.58", + "@typescript-eslint/utils": "8.0.0-alpha.58" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, + "node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.1.2", + "picocolors": "^1.0.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/vite": { + "version": "5.4.14", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz", + "integrity": "sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz", + "integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.7", + "es-module-lexer": "^1.5.4", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vite-tsconfig-paths": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.3.2.tgz", + "integrity": "sha512-0Vd/a6po6Q+86rPlntHye7F31zA2URZMbH8M3saAZ/xR9QoGN/L21bxEGfXdWmFdNkqPpRdxFT7nmNe12e9/uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "globrex": "^0.1.2", + "tsconfck": "^3.0.3" + }, + "peerDependencies": { + "vite": "*" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.9.tgz", + "integrity": "sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "2.1.9", + "@vitest/mocker": "2.1.9", + "@vitest/pretty-format": "^2.1.9", + "@vitest/runner": "2.1.9", + "@vitest/snapshot": "2.1.9", + "@vitest/spy": "2.1.9", + "@vitest/utils": "2.1.9", + "chai": "^5.1.2", + "debug": "^4.3.7", + "expect-type": "^1.1.0", + "magic-string": "^0.30.12", + "pathe": "^1.1.2", + "std-env": "^3.8.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.1", + "tinypool": "^1.0.1", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.9", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.9", + "@vitest/ui": "2.1.9", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest-canvas-mock": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/vitest-canvas-mock/-/vitest-canvas-mock-0.3.3.tgz", + "integrity": "sha512-3P968tYBpqYyzzOaVtqnmYjqbe13576/fkjbDEJSfQAkHtC5/UjuRHOhFEN/ZV5HVZIkaROBUWgazDKJ+Ibw+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-canvas-mock": "~2.5.2" + }, + "peerDependencies": { + "vitest": "*" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/watskeburt": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/watskeburt/-/watskeburt-4.1.0.tgz", + "integrity": "sha512-KkY5H51ajqy9HYYI+u9SIURcWnqeVVhdH0I+ab6aXPGHfZYxgRCwnR6Lm3+TYB6jJVt5jFqw4GAKmwf1zHmGQw==", + "dev": true, + "bin": { + "watskeburt": "dist/run-cli.js" + }, + "engines": { + "node": "^18||>=20" + } + }, + "node_modules/webfontloader": { + "version": "1.6.28", + "resolved": "https://registry.npmjs.org/webfontloader/-/webfontloader-1.6.28.tgz", + "integrity": "sha512-Egb0oFEga6f+nSgasH3E0M405Pzn6y3/9tOVanv/DLfa1YBIgcv90L18YyWnvXkRbIM17v5Kv6IT2N6g1x5tvQ==", + "license": "Apache-2.0" + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-url": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.0.0.tgz", + "integrity": "sha512-1lfMEm2IEr7RIV+f4lUNPOqfFL+pO+Xw3fJSqmjX9AbXcXcYOkCe1P6+9VBZB6n94af16NfZf+sSk0JCBZC9aw==", + "dev": true, + "dependencies": { + "tr46": "^5.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yaml": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "dev": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yoctocolors-cjs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.2.tgz", + "integrity": "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } } diff --git a/package.json b/package.json index 4175ce899e6..ce9e8b4a07b 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,71 @@ { - "name": "pokemon-rogue-battle", - "private": true, - "version": "1.7.7", - "type": "module", - "scripts": { - "start": "vite", - "start:dev": "vite --mode development", - "build": "vite build", - "build:beta": "vite build --mode beta", - "preview": "vite preview", - "test": "vitest run --project pre && vitest run --project main", - "test:cov": "vitest run --project pre && vitest run --project main --coverage", - "test:watch": "vitest run --project pre && vitest watch --project main --coverage", - "test:silent": "vitest run --project pre && vitest run --project main --silent", - "typecheck": "tsc --noEmit", - "eslint": "eslint --fix .", - "eslint-ci": "eslint .", - "docs": "typedoc", - "depcruise": "depcruise src", - "depcruise:graph": "depcruise src --output-type dot | node dependency-graph.js > dependency-graph.svg", - "create-test": "node ./create-test-boilerplate.js", - "postinstall": "npx lefthook install && npx lefthook run post-merge", - "update-version:patch": "npm version patch --force --no-git-tag-version", - "update-version:minor": "npm version minor --force --no-git-tag-version", - "update-locales:remote": "git submodule update --progress --init --recursive --force --remote" - }, - "devDependencies": { - "@eslint/js": "^9.3.0", - "@hpcc-js/wasm": "^2.18.0", - "@stylistic/eslint-plugin-ts": "^2.6.0-beta.0", - "@types/jsdom": "^21.1.7", - "@types/node": "^20.12.13", - "@typescript-eslint/eslint-plugin": "^8.0.0-alpha.54", - "@typescript-eslint/parser": "^8.0.0-alpha.54", - "@vitest/coverage-istanbul": "^2.1.9", - "dependency-cruiser": "^16.3.10", - "eslint": "^9.7.0", - "eslint-plugin-import-x": "^4.2.1", - "inquirer": "^11.0.2", - "jsdom": "^24.0.0", - "lefthook": "^1.6.12", - "msw": "^2.4.9", - "phaser3spectorjs": "^0.0.8", - "typedoc": "^0.26.4", - "typescript": "^5.5.3", - "typescript-eslint": "^8.0.0-alpha.54", - "vite": "^5.4.14", - "vite-tsconfig-paths": "^4.3.2", - "vitest": "^2.1.9", - "vitest-canvas-mock": "^0.3.3" - }, - "dependencies": { - "@material/material-color-utilities": "^0.2.7", - "crypto-js": "^4.2.0", - "i18next": "^23.11.1", - "i18next-browser-languagedetector": "^7.2.1", - "i18next-http-backend": "^2.6.1", - "i18next-korean-postposition-processor": "^1.0.0", - "json-stable-stringify": "^1.1.0", - "jszip": "^3.10.1", - "phaser": "^3.70.0", - "phaser3-rex-plugins": "^1.1.84" - }, - "engines": { - "node": ">=20.0.0" - } + "name": "pokemon-rogue-battle", + "private": true, + "version": "1.7.7", + "type": "module", + "scripts": { + "start": "vite", + "start:dev": "vite --mode development", + "build": "vite build", + "build:beta": "vite build --mode beta", + "preview": "vite preview", + "test": "vitest run --project pre && vitest run --project main", + "test:cov": "vitest run --project pre && vitest run --project main --coverage", + "test:watch": "vitest run --project pre && vitest watch --project main --coverage", + "test:silent": "vitest run --project pre && vitest run --project main --silent", + "typecheck": "tsc --noEmit", + "eslint": "eslint --fix .", + "eslint-ci": "eslint .", + "biome": "biome check --write --changed --no-errors-on-unmatched", + "biome-ci": "biome ci --diagnostic-level=error --reporter=github --changed --no-errors-on-unmatched", + "docs": "typedoc", + "depcruise": "depcruise src", + "depcruise:graph": "depcruise src --output-type dot | node dependency-graph.js > dependency-graph.svg", + "create-test": "node ./create-test-boilerplate.js", + "postinstall": "npx lefthook install && npx lefthook run post-merge", + "update-version:patch": "npm version patch --force --no-git-tag-version", + "update-version:minor": "npm version minor --force --no-git-tag-version", + "update-locales:remote": "git submodule update --progress --init --recursive --force --remote" + }, + "devDependencies": { + "@biomejs/biome": "1.9.4", + "@eslint/js": "^9.3.0", + "@hpcc-js/wasm": "^2.18.0", + "@stylistic/eslint-plugin-ts": "^2.6.0-beta.0", + "@types/jsdom": "^21.1.7", + "@types/node": "^20.12.13", + "@typescript-eslint/eslint-plugin": "^8.0.0-alpha.54", + "@typescript-eslint/parser": "^8.0.0-alpha.54", + "@vitest/coverage-istanbul": "^2.1.9", + "dependency-cruiser": "^16.3.10", + "eslint": "^9.7.0", + "eslint-plugin-import-x": "^4.2.1", + "inquirer": "^11.0.2", + "jsdom": "^24.0.0", + "lefthook": "^1.6.12", + "msw": "^2.4.9", + "phaser3spectorjs": "^0.0.8", + "typedoc": "^0.26.4", + "typescript": "^5.5.3", + "typescript-eslint": "^8.0.0-alpha.54", + "vite": "^5.4.14", + "vite-tsconfig-paths": "^4.3.2", + "vitest": "^2.1.9", + "vitest-canvas-mock": "^0.3.3" + }, + "dependencies": { + "@material/material-color-utilities": "^0.2.7", + "crypto-js": "^4.2.0", + "i18next": "^23.11.1", + "i18next-browser-languagedetector": "^7.2.1", + "i18next-http-backend": "^2.6.1", + "i18next-korean-postposition-processor": "^1.0.0", + "json-stable-stringify": "^1.1.0", + "jszip": "^3.10.1", + "phaser": "^3.70.0", + "phaser3-rex-plugins": "^1.1.84" + }, + "engines": { + "node": ">=20.0.0" + } } diff --git a/src/account.ts b/src/account.ts index 4c86595a5e6..96ce32714bb 100644 --- a/src/account.ts +++ b/src/account.ts @@ -8,13 +8,25 @@ export let loggedInUser: UserInfo | null = null; export const clientSessionId = Utils.randomString(32); export function initLoggedInUser(): void { - loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: "", hasAdminRole: false }; + loggedInUser = { + username: "Guest", + lastSessionSlot: -1, + discordId: "", + googleId: "", + hasAdminRole: false, + }; } export function updateUserInfo(): Promise<[boolean, number]> { return new Promise<[boolean, number]>(resolve => { if (bypassLogin) { - loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: "", hasAdminRole: false }; + loggedInUser = { + username: "Guest", + lastSessionSlot: -1, + discordId: "", + googleId: "", + hasAdminRole: false, + }; let lastSessionSlot = -1; for (let s = 0; s < 5; s++) { if (localStorage.getItem(`sessionData${s ? s : ""}_${loggedInUser.username}`)) { @@ -24,7 +36,7 @@ export function updateUserInfo(): Promise<[boolean, number]> { } loggedInUser.lastSessionSlot = lastSessionSlot; // Migrate old data from before the username was appended - [ "data", "sessionData", "sessionData1", "sessionData2", "sessionData3", "sessionData4" ].map(d => { + ["data", "sessionData", "sessionData1", "sessionData2", "sessionData3", "sessionData4"].map(d => { const lsItem = localStorage.getItem(d); if (lsItem && !!loggedInUser?.username) { const lsUserItem = localStorage.getItem(`${d}_${loggedInUser.username}`); @@ -35,16 +47,15 @@ export function updateUserInfo(): Promise<[boolean, number]> { localStorage.removeItem(d); } }); - return resolve([ true, 200 ]); + return resolve([true, 200]); } - pokerogueApi.account.getInfo().then(([ accountInfo, status ]) => { + pokerogueApi.account.getInfo().then(([accountInfo, status]) => { if (!accountInfo) { - resolve([ false, status ]); + resolve([false, status]); return; - } else { - loggedInUser = accountInfo; - resolve([ true, 200 ]); } + loggedInUser = accountInfo; + resolve([true, 200]); }); }); } diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 208c3368038..1712cf9236f 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -8,11 +8,7 @@ import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import type { Constructor } from "#app/utils"; import { isNullOrUndefined, randSeedInt } from "#app/utils"; import * as Utils from "#app/utils"; -import type { - Modifier, - ModifierPredicate, - TurnHeldItemTransferModifier, -} from "./modifier/modifier"; +import type { Modifier, ModifierPredicate, TurnHeldItemTransferModifier } from "./modifier/modifier"; import { ConsumableModifier, ConsumablePokemonModifier, @@ -93,10 +89,7 @@ import type UIPlugin from "phaser3-rex-plugins/templates/ui/ui-plugin"; import { addUiThemeOverrides } from "#app/ui/ui-theme"; import type PokemonData from "#app/system/pokemon-data"; import { Nature } from "#enums/nature"; -import type { - SpeciesFormChange, - SpeciesFormChangeTrigger, -} from "#app/data/pokemon-forms"; +import type { SpeciesFormChange, SpeciesFormChangeTrigger } from "#app/data/pokemon-forms"; import { FormChangeItem, pokemonFormChanges, @@ -181,10 +174,8 @@ export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; const DEBUG_RNG = false; 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) => (isNaN(iv) || iv === null || iv > 31 ? -1 : iv)); + 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; @@ -199,10 +190,7 @@ export interface PokeballCounts { [pb: string]: number; } -export type AnySound = - | Phaser.Sound.WebAudioSound - | Phaser.Sound.HTML5AudioSound - | Phaser.Sound.NoAudioSound; +export type AnySound = Phaser.Sound.WebAudioSound | Phaser.Sound.HTML5AudioSound | Phaser.Sound.NoAudioSound; export interface InfoToggle { toggleInfo(force?: boolean): void; @@ -216,55 +204,54 @@ export default class BattleScene extends SceneBase { public sessionPlayTime: number | null = null; public lastSavePlayTime: number | null = null; - public masterVolume: number = 0.5; - public bgmVolume: number = 1; - public fieldVolume: number = 1; - public seVolume: number = 1; - public uiVolume: number = 1; - public gameSpeed: number = 1; - public damageNumbersMode: number = 0; - public reroll: boolean = false; + public masterVolume = 0.5; + public bgmVolume = 1; + public fieldVolume = 1; + public seVolume = 1; + public uiVolume = 1; + public gameSpeed = 1; + public damageNumbersMode = 0; + public reroll = false; public shopCursorTarget: number = ShopCursorTarget.REWARDS; - public commandCursorMemory: boolean = false; - public dexForDevs: boolean = false; - public showMovesetFlyout: boolean = true; - public showArenaFlyout: boolean = true; - public showTimeOfDayWidget: boolean = true; + public commandCursorMemory = false; + public dexForDevs = false; + public showMovesetFlyout = true; + public showArenaFlyout = true; + public showTimeOfDayWidget = true; public timeOfDayAnimation: EaseType = EaseType.NONE; - public showLevelUpStats: boolean = true; - public enableTutorials: boolean = - import.meta.env.VITE_BYPASS_TUTORIAL === "1"; - public enableMoveInfo: boolean = true; - public enableRetries: boolean = false; - public hideIvs: boolean = false; + public showLevelUpStats = true; + public enableTutorials: boolean = import.meta.env.VITE_BYPASS_TUTORIAL === "1"; + public enableMoveInfo = true; + public enableRetries = false; + public hideIvs = false; /** * Determines the condition for a notification should be shown for Candy Upgrades * - 0 = 'Off' * - 1 = 'Passives Only' * - 2 = 'On' */ - public candyUpgradeNotification: number = 0; + public candyUpgradeNotification = 0; /** * Determines what type of notification is used for Candy Upgrades * - 0 = 'Icon' * - 1 = 'Animation' */ - public candyUpgradeDisplay: number = 0; + public candyUpgradeDisplay = 0; public moneyFormat: MoneyFormat = MoneyFormat.NORMAL; public uiTheme: UiTheme = UiTheme.DEFAULT; - public windowType: number = 0; - public experimentalSprites: boolean = false; + public windowType = 0; + public experimentalSprites = false; public musicPreference: number = MusicPreference.ALLGENS; - public moveAnimations: boolean = true; + public moveAnimations = true; public expGainsSpeed: ExpGainsSpeed = ExpGainsSpeed.DEFAULT; - public skipSeenDialogues: boolean = false; + public skipSeenDialogues = false; /** * Determines if the egg hatching animation should be skipped * - 0 = Never (never skip animation) * - 1 = Ask (ask to skip animation when hatching 2 or more eggs) * - 2 = Always (automatically skip animation when hatching 2 or more eggs) */ - public eggSkipPreference: number = 0; + public eggSkipPreference = 0; /** * Defines the experience gain display mode. @@ -279,11 +266,11 @@ export default class BattleScene extends SceneBase { * @default 0 - Uses the default normal experience gain display. */ public expParty: ExpNotification = 0; - public hpBarSpeed: number = 0; - public fusionPaletteSwaps: boolean = true; - public enableTouchControls: boolean = false; - public enableVibration: boolean = false; - public showBgmBar: boolean = true; + public hpBarSpeed = 0; + public fusionPaletteSwaps = true; + public enableTouchControls = false; + public enableVibration = false; + public showBgmBar = true; /** * Determines the selected battle style. @@ -297,9 +284,9 @@ export default class BattleScene extends SceneBase { * - true: No hints * - false: Show hints for moves */ - public typeHints: boolean = false; + public typeHints = false; - public disableMenu: boolean = false; + public disableMenu = false; public gameData: GameData; public sessionSlotId: number; @@ -342,8 +329,7 @@ export default class BattleScene extends SceneBase { public pokemonInfoContainer: PokemonInfoContainer; private party: PlayerPokemon[]; /** Session save data that pertains to Mystery Encounters */ - public mysteryEncounterSaveData: MysteryEncounterSaveData = - new MysteryEncounterSaveData(); + public mysteryEncounterSaveData: MysteryEncounterSaveData = new MysteryEncounterSaveData(); /** If the previous wave was a MysteryEncounter, tracks the object with this variable. Mostly used for visual object cleanup */ public lastMysteryEncounter?: MysteryEncounter; /** Combined Biome and Wave count text */ @@ -358,8 +344,8 @@ export default class BattleScene extends SceneBase { private fieldOverlay: Phaser.GameObjects.Rectangle; private shopOverlay: Phaser.GameObjects.Rectangle; - private shopOverlayShown: boolean = false; - private shopOverlayOpacity: number = 0.8; + private shopOverlayShown = false; + private shopOverlayOpacity = 0.8; public modifiers: PersistentModifier[]; private enemyModifiers: PersistentModifier[]; @@ -382,9 +368,9 @@ export default class BattleScene extends SceneBase { private bgmCache: Set = new Set(); private playTimeTimer: Phaser.Time.TimerEvent; - public rngCounter: number = 0; - public rngSeedOverride: string = ""; - public rngOffset: number = 0; + public rngCounter = 0; + public rngSeedOverride = ""; + public rngOffset = 0; public inputMethod: string; private infoToggles: InfoToggle[] = []; @@ -435,30 +421,23 @@ export default class BattleScene extends SceneBase { /** * Load the variant assets for the given sprite and stores them in {@linkcode variantColorCache} */ - public async loadPokemonVariantAssets( - spriteKey: string, - fileRoot: string, - variant?: Variant, - ): Promise { - const useExpSprite = - this.experimentalSprites && this.hasExpSprite(spriteKey); + public async loadPokemonVariantAssets(spriteKey: string, fileRoot: string, variant?: Variant): Promise { + const useExpSprite = this.experimentalSprites && this.hasExpSprite(spriteKey); if (useExpSprite) { fileRoot = `exp/${fileRoot}`; } let variantConfig = variantData; - fileRoot - .split("/") - .map((p) => (variantConfig ? (variantConfig = variantConfig[p]) : null)); + fileRoot.split("/").map(p => (variantConfig ? (variantConfig = variantConfig[p]) : null)); const variantSet = variantConfig as VariantSet; - return new Promise((resolve) => { + return new Promise(resolve => { if (variantSet && variant !== undefined && variantSet[variant] === 1) { if (variantColorCache.hasOwnProperty(spriteKey)) { return resolve(); } this.cachedFetch(`./images/pokemon/variant/${fileRoot}.json`) - .then((res) => res.json()) - .then((c) => { + .then(res => res.json()) + .then(c => { variantColorCache[spriteKey] = c; resolve(); }); @@ -471,20 +450,10 @@ export default class BattleScene extends SceneBase { async preload() { if (DEBUG_RNG) { const originalRealInRange = Phaser.Math.RND.realInRange; - Phaser.Math.RND.realInRange = function ( - min: number, - max: number, - ): number { - const ret = originalRealInRange.apply(this, [ min, max ]); - const args = [ - "RNG", - ++this.rngCounter, - ret / (max - min), - `min: ${min} / max: ${max}`, - ]; - args.push( - `seed: ${this.rngSeedOverride || this.waveSeed || this.seed}`, - ); + Phaser.Math.RND.realInRange = function (min: number, max: number): number { + const ret = originalRealInRange.apply(this, [min, max]); + const args = ["RNG", ++this.rngCounter, ret / (max - min), `min: ${min} / max: ${max}`]; + args.push(`seed: ${this.rngSeedOverride || this.waveSeed || this.seed}`); if (this.rngOffset) { args.push(`offset: ${this.rngOffset}`); } @@ -511,16 +480,10 @@ export default class BattleScene extends SceneBase { this.load.setBaseURL(); this.spritePipeline = new SpritePipeline(this.game); - (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add( - "Sprite", - this.spritePipeline, - ); + (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add("Sprite", this.spritePipeline); this.fieldSpritePipeline = new FieldSpritePipeline(this.game); - (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add( - "FieldSprite", - this.fieldSpritePipeline, - ); + (this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add("FieldSprite", this.fieldSpritePipeline); this.launchBattle(); } @@ -535,12 +498,12 @@ export default class BattleScene extends SceneBase { this.arenaBgTransition = this.add.sprite(0, 0, "plains_bg"); this.arenaBgTransition.setName("sprite-arena-bg-transition"); - [ this.arenaBgTransition, this.arenaBg ].forEach((a) => { + for (const a of [this.arenaBgTransition, this.arenaBg]) { a.setPipeline(this.fieldSpritePipeline); a.setScale(6); a.setOrigin(0); a.setSize(320, 240); - }); + } const field = this.add.container(0, 0); field.setName("field"); @@ -587,25 +550,13 @@ export default class BattleScene extends SceneBase { const overlayWidth = this.game.canvas.width / 6; const overlayHeight = this.game.canvas.height / 6 - 48; - this.fieldOverlay = this.add.rectangle( - 0, - overlayHeight * -1 - 48, - overlayWidth, - overlayHeight, - 0x424242, - ); + this.fieldOverlay = this.add.rectangle(0, overlayHeight * -1 - 48, overlayWidth, overlayHeight, 0x424242); this.fieldOverlay.setName("rect-field-overlay"); this.fieldOverlay.setOrigin(0, 0); this.fieldOverlay.setAlpha(0); this.fieldUI.add(this.fieldOverlay); - this.shopOverlay = this.add.rectangle( - 0, - overlayHeight * -1 - 48, - overlayWidth, - overlayHeight, - 0x070707, - ); + this.shopOverlay = this.add.rectangle(0, overlayHeight * -1 - 48, overlayWidth, overlayHeight, 0x070707); this.shopOverlay.setName("rect-shop-overlay"); this.shopOverlay.setOrigin(0, 0); this.shopOverlay.setAlpha(0); @@ -666,34 +617,17 @@ export default class BattleScene extends SceneBase { this.biomeWaveText.setOrigin(1, 0.5); this.fieldUI.add(this.biomeWaveText); - this.moneyText = addTextObject( - this.game.canvas.width / 6 - 2, - 0, - "", - TextStyle.MONEY, - ); + this.moneyText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.MONEY); this.moneyText.setName("text-money"); this.moneyText.setOrigin(1, 0.5); this.fieldUI.add(this.moneyText); - this.scoreText = addTextObject( - this.game.canvas.width / 6 - 2, - 0, - "", - TextStyle.PARTY, - { fontSize: "54px" }, - ); + this.scoreText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" }); this.scoreText.setName("text-score"); this.scoreText.setOrigin(1, 0.5); this.fieldUI.add(this.scoreText); - this.luckText = addTextObject( - this.game.canvas.width / 6 - 2, - 0, - "", - TextStyle.PARTY, - { fontSize: "54px" }, - ); + this.luckText = addTextObject(this.game.canvas.width / 6 - 2, 0, "", TextStyle.PARTY, { fontSize: "54px" }); this.luckText.setName("text-luck"); this.luckText.setOrigin(1, 0.5); this.luckText.setVisible(false); @@ -713,10 +647,7 @@ export default class BattleScene extends SceneBase { this.arenaFlyout = new ArenaFlyout(); this.fieldUI.add(this.arenaFlyout); - this.fieldUI.moveBelow( - this.arenaFlyout, - this.fieldOverlay, - ); + this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); this.updateUIPositions(); @@ -750,17 +681,12 @@ export default class BattleScene extends SceneBase { this.arenaPlayerTransition.setVisible(false); this.arenaNextEnemy.setVisible(false); - [ - this.arenaPlayer, - this.arenaPlayerTransition, - this.arenaEnemy, - this.arenaNextEnemy, - ].forEach((a) => { + for (const a of [this.arenaPlayer, this.arenaPlayerTransition, this.arenaEnemy, this.arenaNextEnemy]) { if (a instanceof Phaser.GameObjects.Sprite) { a.setOrigin(0, 0); } field.add(a); - }); + } const trainer = this.addFieldSprite( 0, @@ -803,21 +729,14 @@ export default class BattleScene extends SceneBase { ui.setup(); - const defaultMoves = [ - Moves.TACKLE, - Moves.TAIL_WHIP, - Moves.FOCUS_ENERGY, - Moves.STRUGGLE, - ]; + const defaultMoves = [Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE]; Promise.all([ Promise.all(loadPokemonAssets), initCommonAnims().then(() => loadCommonAnimAssets(true)), - Promise.all( - [ Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE ].map( - (m) => initMoveAnim(m), - ), - ).then(() => loadMoveAnimAssets(defaultMoves, true)), + Promise.all([Moves.TACKLE, Moves.TAIL_WHIP, Moves.FOCUS_ENERGY, Moves.STRUGGLE].map(m => initMoveAnim(m))).then( + () => loadMoveAnimAssets(defaultMoves, true), + ), this.initStarterColors(), ]).then(() => { this.pushPhase(new LoginPhase()); @@ -865,8 +784,8 @@ export default class BattleScene extends SceneBase { return; } this.cachedFetch("./exp-sprites.json") - .then((res) => res.json()) - .then((keys) => { + .then(res => res.json()) + .then(keys => { if (Array.isArray(keys)) { expSpriteKeys.push(...keys); } @@ -875,11 +794,15 @@ export default class BattleScene extends SceneBase { } async initVariantData(): Promise { - Object.keys(variantData).forEach((key) => delete variantData[key]); + for (const key of Object.keys(variantData)) { + delete variantData[key]; + } await this.cachedFetch("./images/pokemon/variant/_masterlist.json") - .then((res) => res.json()) - .then((v) => { - Object.keys(v).forEach((k) => (variantData[k] = v[k])); + .then(res => res.json()) + .then(v => { + for (const k of Object.keys(v)) { + variantData[k] = v[k]; + } if (this.experimentalSprites) { const expVariantData = variantData["exp"]; const traverseVariantData = (keys: string[]) => { @@ -889,11 +812,8 @@ export default class BattleScene extends SceneBase { if (i < keys.length - 1) { variantTree = variantTree[k]; expTree = expTree[k]; - } else if ( - variantTree.hasOwnProperty(k) && - expTree.hasOwnProperty(k) - ) { - if ([ "back", "female" ].includes(k)) { + } else if (variantTree.hasOwnProperty(k) && expTree.hasOwnProperty(k)) { + if (["back", "female"].includes(k)) { traverseVariantData(keys.concat(k)); } else { variantTree[k] = expTree[k]; @@ -901,9 +821,9 @@ export default class BattleScene extends SceneBase { } }); }; - Object.keys(expVariantData).forEach((ek) => - traverseVariantData([ ek ]), - ); + for (const ek of Object.keys(expVariantData)) { + traverseVariantData([ek]); + } } Promise.resolve(); }); @@ -921,40 +841,18 @@ export default class BattleScene extends SceneBase { } initStarterColors(): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { if (starterColors) { return resolve(); } this.cachedFetch("./starter-colors.json") - .then((res) => res.json()) - .then((sc) => { + .then(res => res.json()) + .then(sc => { starterColors = {}; - Object.keys(sc).forEach((key) => { + for (const key of Object.keys(sc)) { starterColors[key] = sc[key]; - }); - - /*const loadPokemonAssets: Promise[] = []; - - for (let s of Object.keys(speciesStarters)) { - const species = getPokemonSpecies(parseInt(s)); - loadPokemonAssets.push(species.loadAssets(this, false, 0, false)); - } - - Promise.all(loadPokemonAssets).then(() => { - const starterCandyColors = {}; - const rgbaToHexFunc = (r, g, b) => [r, g, b].map(x => x.toString(16).padStart(2, '0')).join(''); - - for (let s of Object.keys(speciesStarters)) { - const species = getPokemonSpecies(parseInt(s)); - - starterCandyColors[species.speciesId] = species.generateCandyColors(this).map(c => rgbaToHexFunc(c[0], c[1], c[2])); - } - - console.log(JSON.stringify(starterCandyColors)); - - resolve(); - });*/ + } resolve(); }); @@ -962,10 +860,7 @@ export default class BattleScene extends SceneBase { } hasExpSprite(key: string): boolean { - const keyMatch = - /^pkmn__?(back__)?(shiny__)?(female__)?(\d+)(\-.*?)?(?:_[1-3])?$/g.exec( - key, - ); + const keyMatch = /^pkmn__?(back__)?(shiny__)?(female__)?(\d+)(\-.*?)?(?:_[1-3])?$/g.exec(key); if (!keyMatch) { return false; } @@ -998,7 +893,7 @@ export default class BattleScene extends SceneBase { * that are {@linkcode Pokemon.isAllowedInBattle | allowed in battle}. */ public getPokemonAllowedInBattle(): PlayerPokemon[] { - return this.getPlayerParty().filter((p) => p.isAllowedInBattle()); + return this.getPlayerParty().filter(p => p.isAllowedInBattle()); } /** @@ -1008,12 +903,8 @@ export default class BattleScene extends SceneBase { * or `undefined` if there are no valid pokemon * @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true` */ - public getPlayerPokemon( - includeSwitching: boolean = true, - ): PlayerPokemon | undefined { - return this.getPlayerField().find( - (p) => p.isActive() && (includeSwitching || p.switchOutStatus === false), - ); + public getPlayerPokemon(includeSwitching = true): PlayerPokemon | undefined { + return this.getPlayerField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false)); } /** @@ -1023,10 +914,7 @@ export default class BattleScene extends SceneBase { */ public getPlayerField(): PlayerPokemon[] { const party = this.getPlayerParty(); - return party.slice( - 0, - Math.min(party.length, this.currentBattle?.double ? 2 : 1), - ); + return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1)); } public getEnemyParty(): EnemyPokemon[] { @@ -1040,12 +928,8 @@ export default class BattleScene extends SceneBase { * or `undefined` if there are no valid pokemon * @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true` */ - public getEnemyPokemon( - includeSwitching: boolean = true, - ): EnemyPokemon | undefined { - return this.getEnemyField().find( - (p) => p.isActive() && (includeSwitching || p.switchOutStatus === false), - ); + public getEnemyPokemon(includeSwitching = true): EnemyPokemon | undefined { + return this.getEnemyField().find(p => p.isActive() && (includeSwitching || p.switchOutStatus === false)); } /** @@ -1055,10 +939,7 @@ export default class BattleScene extends SceneBase { */ public getEnemyField(): EnemyPokemon[] { const party = this.getEnemyParty(); - return party.slice( - 0, - Math.min(party.length, this.currentBattle?.double ? 2 : 1), - ); + return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1)); } /** @@ -1067,13 +948,13 @@ export default class BattleScene extends SceneBase { * @param activeOnly Whether to consider only active pokemon * @returns array of {@linkcode Pokemon} */ - public getField(activeOnly: boolean = false): Pokemon[] { + public getField(activeOnly = false): Pokemon[] { const ret = new Array(4).fill(null); const playerField = this.getPlayerField(); const enemyField = this.getEnemyField(); ret.splice(0, playerField.length, ...playerField); ret.splice(2, enemyField.length, ...enemyField); - return activeOnly ? ret.filter((p) => p?.isActive()) : ret; + return activeOnly ? ret.filter(p => p?.isActive()) : ret; } /** @@ -1090,16 +971,13 @@ export default class BattleScene extends SceneBase { let targetingMovePhase: MovePhase; do { targetingMovePhase = this.findPhase( - (mp) => + mp => mp instanceof MovePhase && mp.targets.length === 1 && mp.targets[0] === removedPokemon.getBattlerIndex() && mp.pokemon.isPlayer() !== allyPokemon.isPlayer(), ) as MovePhase; - if ( - targetingMovePhase && - targetingMovePhase.targets[0] !== allyPokemon.getBattlerIndex() - ) { + if (targetingMovePhase && targetingMovePhase.targets[0] !== allyPokemon.getBattlerIndex()) { targetingMovePhase.targets[0] = allyPokemon.getBattlerIndex(); } } while (targetingMovePhase); @@ -1121,20 +999,13 @@ export default class BattleScene extends SceneBase { } // return the stored info toggles; used by ui-inputs - getInfoToggles(activeOnly: boolean = false): InfoToggle[] { - return activeOnly - ? this.infoToggles.filter((t) => t?.isActive()) - : this.infoToggles; + getInfoToggles(activeOnly = false): InfoToggle[] { + return activeOnly ? this.infoToggles.filter(t => t?.isActive()) : this.infoToggles; } getPokemonById(pokemonId: number): Pokemon | null { - const findInParty = (party: Pokemon[]) => - party.find((p) => p.id === pokemonId); - return ( - (findInParty(this.getPlayerParty()) || - findInParty(this.getEnemyParty())) ?? - null - ); + const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId); + return (findInParty(this.getPlayerParty()) || findInParty(this.getEnemyParty())) ?? null; } addPlayerPokemon( @@ -1173,8 +1044,8 @@ export default class BattleScene extends SceneBase { species: PokemonSpecies, level: number, trainerSlot: TrainerSlot, - boss: boolean = false, - shinyLock: boolean = false, + boss = false, + shinyLock = false, dataSource?: PokemonData, postProcess?: (enemyPokemon: EnemyPokemon) => void, ): EnemyPokemon { @@ -1184,22 +1055,10 @@ export default class BattleScene extends SceneBase { if (Overrides.OPP_SPECIES_OVERRIDE) { species = getPokemonSpecies(Overrides.OPP_SPECIES_OVERRIDE); // The fact that a Pokemon is a boss or not can change based on its Species and level - boss = - this.getEncounterBossSegments( - this.currentBattle.waveIndex, - level, - species, - ) > 1; + boss = this.getEncounterBossSegments(this.currentBattle.waveIndex, level, species) > 1; } - const pokemon = new EnemyPokemon( - species, - level, - trainerSlot, - boss, - shinyLock, - dataSource, - ); + const pokemon = new EnemyPokemon(species, level, trainerSlot, boss, shinyLock, dataSource); if (Overrides.OPP_FUSION_OVERRIDE) { pokemon.generateFusionSpecies(); } @@ -1237,10 +1096,7 @@ export default class BattleScene extends SceneBase { * @param pokemon * @param destroy Default true. If true, will destroy the {@linkcode PlayerPokemon} after removing */ - removePokemonFromPlayerParty( - pokemon: PlayerPokemon, - destroy: boolean = true, - ) { + removePokemonFromPlayerParty(pokemon: PlayerPokemon, destroy = true) { if (!pokemon) { return; } @@ -1258,9 +1114,9 @@ export default class BattleScene extends SceneBase { pokemon: Pokemon, x: number, y: number, - originX: number = 0.5, - originY: number = 0.5, - ignoreOverride: boolean = false, + originX = 0.5, + originY = 0.5, + ignoreOverride = false, ): Phaser.GameObjects.Container { const container = this.add.container(x, y); container.setName(`${pokemon.name}-icon`); @@ -1270,9 +1126,7 @@ export default class BattleScene extends SceneBase { icon.setFrame(pokemon.getIconId(true)); // Temporary fix to show pokemon's default icon if variant icon doesn't exist if (icon.frame.name !== pokemon.getIconId(true)) { - console.log( - `${pokemon.name}'s variant icon does not exist. Replacing with default.`, - ); + console.log(`${pokemon.name}'s variant icon does not exist. Replacing with default.`); const temp = pokemon.shiny; pokemon.shiny = false; icon.setTexture(pokemon.getIconAtlasKey(ignoreOverride)); @@ -1284,11 +1138,7 @@ export default class BattleScene extends SceneBase { container.add(icon); if (pokemon.isFusion()) { - const fusionIcon = this.add.sprite( - 0, - 0, - pokemon.getFusionIconAtlasKey(ignoreOverride), - ); + const fusionIcon = this.add.sprite(0, 0, pokemon.getFusionIconAtlasKey(ignoreOverride)); fusionIcon.setName("sprite-fusion-icon"); fusionIcon.setOrigin(0.5, 0); fusionIcon.setFrame(pokemon.getFusionIconId(true)); @@ -1297,11 +1147,9 @@ export default class BattleScene extends SceneBase { const originalHeight = icon.height; const originalFrame = icon.frame; - const iconHeight = ( - icon.frame.cutHeight <= fusionIcon.frame.cutHeight - ? Math.ceil - : Math.floor - )((icon.frame.cutHeight + fusionIcon.frame.cutHeight) / 4); + const iconHeight = (icon.frame.cutHeight <= fusionIcon.frame.cutHeight ? Math.ceil : Math.floor)( + (icon.frame.cutHeight + fusionIcon.frame.cutHeight) / 4, + ); // Inefficient, but for some reason didn't work with only the unique properties as part of the name const iconFrameId = `${icon.frame.name}f${fusionIcon.frame.name}`; @@ -1324,8 +1172,7 @@ export default class BattleScene extends SceneBase { const originalFusionFrame = fusionIcon.frame; const fusionIconY = fusionIcon.frame.cutY + icon.frame.cutHeight; - const fusionIconHeight = - fusionIcon.frame.cutHeight - icon.frame.cutHeight; + const fusionIconHeight = fusionIcon.frame.cutHeight - icon.frame.cutHeight; // Inefficient, but for some reason didn't work with only the unique properties as part of the name const fusionIconFrameId = `${fusionIcon.frame.name}f${icon.frame.name}`; @@ -1382,15 +1229,11 @@ export default class BattleScene extends SceneBase { * @param min The minimum integer to pick, default `0` * @returns A random integer between {@linkcode min} and ({@linkcode min} + {@linkcode range} - 1) */ - randBattleSeedInt(range: number, min: number = 0): number { + randBattleSeedInt(range: number, min = 0): number { return this.currentBattle?.randSeedInt(range, min); } - reset( - clearScene: boolean = false, - clearData: boolean = false, - reloadI18n: boolean = false, - ): void { + reset(clearScene = false, clearData = false, reloadI18n = false): void { if (clearData) { this.gameData = new GameData(); } @@ -1406,8 +1249,8 @@ export default class BattleScene extends SceneBase { this.pokeballCounts = Object.fromEntries( Utils.getEnumValues(PokeballType) - .filter((p) => p <= PokeballType.MASTER_BALL) - .map((t) => [ t, 0 ]), + .filter(p => p <= PokeballType.MASTER_BALL) + .map(t => [t, 0]), ); this.pokeballCounts[PokeballType.POKEBALL] += 5; if (Overrides.POKEBALL_OVERRIDE.active) { @@ -1429,10 +1272,7 @@ export default class BattleScene extends SceneBase { // If this is a ME, clear any residual visual sprites before reloading if (this.currentBattle?.mysteryEncounter?.introVisuals) { - this.field.remove( - this.currentBattle.mysteryEncounter?.introVisuals, - true, - ); + this.field.remove(this.currentBattle.mysteryEncounter?.introVisuals, true); } //@ts-ignore - allowing `null` for currentBattle causes a lot of trouble @@ -1453,7 +1293,7 @@ export default class BattleScene extends SceneBase { this.updateScoreText(); this.scoreText.setVisible(false); - [ this.luckLabelText, this.luckText ].map((t) => t.setVisible(false)); + [this.luckLabelText, this.luckText].map(t => t.setVisible(false)); this.newArena(Overrides.STARTING_BIOME_OVERRIDE || Biome.TOWN); @@ -1462,16 +1302,13 @@ export default class BattleScene extends SceneBase { this.arenaBgTransition.setPosition(0, 0); this.arenaPlayer.setPosition(300, 0); this.arenaPlayerTransition.setPosition(0, 0); - [ this.arenaEnemy, this.arenaNextEnemy ].forEach((a) => - a.setPosition(-280, 0), - ); + this.arenaEnemy.setPosition(-280, 0); + this.arenaNextEnemy.setPosition(-280, 0); this.arenaNextEnemy.setVisible(false); this.arena.init(); - this.trainer.setTexture( - `trainer_${this.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`, - ); + this.trainer.setTexture(`trainer_${this.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`); this.trainer.setPosition(406, 186); this.trainer.setVisible(true); @@ -1485,15 +1322,14 @@ export default class BattleScene extends SceneBase { ...allMoves, ...allAbilities, ...Utils.getEnumValues(ModifierPoolType) - .map((mpt) => getModifierPoolForType(mpt)) - .map((mp) => + .map(mpt => getModifierPoolForType(mpt)) + .flatMap(mp => Object.values(mp) .flat() - .map((mt) => mt.modifierType) - .filter((mt) => "localize" in mt) - .map((lpb) => lpb as unknown as Localizable), - ) - .flat(), + .map(mt => mt.modifierType) + .filter(mt => "localize" in mt) + .map(lpb => lpb as unknown as Localizable), + ), ]; for (const item of localizable) { item.localize(); @@ -1506,7 +1342,7 @@ export default class BattleScene extends SceneBase { this.fadeOutBgm(250, false); this.tweens.add({ - targets: [ this.uiContainer ], + targets: [this.uiContainer], alpha: 0, duration: 250, ease: "Sine.easeInOut", @@ -1525,13 +1361,11 @@ export default class BattleScene extends SceneBase { } getDoubleBattleChance(newWaveIndex: number, playerField: PlayerPokemon[]) { - const doubleChance = new Utils.NumberHolder( - newWaveIndex % 10 === 0 ? 32 : 8, - ); + const doubleChance = new Utils.NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); - playerField.forEach((p) => - applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance), - ); + for (const p of playerField) { + applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance); + } return Math.max(doubleChance.value, 1); } @@ -1543,8 +1377,7 @@ export default class BattleScene extends SceneBase { mysteryEncounterType?: MysteryEncounterType, ): Battle | null { const _startingWave = Overrides.STARTING_WAVE_OVERRIDE || startingWave; - const newWaveIndex = - waveIndex || (this.currentBattle?.waveIndex || _startingWave - 1) + 1; + const newWaveIndex = waveIndex || (this.currentBattle?.waveIndex || _startingWave - 1) + 1; let newDouble: boolean | undefined; let newBattleType: BattleType; let newTrainer: Trainer | undefined; @@ -1555,10 +1388,7 @@ export default class BattleScene extends SceneBase { const playerField = this.getPlayerField(); - if ( - this.gameMode.isFixedBattle(newWaveIndex) && - trainerData === undefined - ) { + if (this.gameMode.isFixedBattle(newWaveIndex) && trainerData === undefined) { battleConfig = this.gameMode.getFixedBattle(newWaveIndex); newDouble = battleConfig.double; newBattleType = battleConfig.battleType; @@ -1573,9 +1403,7 @@ export default class BattleScene extends SceneBase { if (!this.gameMode.hasTrainers) { newBattleType = BattleType.WILD; } else if (battleType === undefined) { - newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this.arena) - ? BattleType.TRAINER - : BattleType.WILD; + newBattleType = this.gameMode.isWaveTrainer(newWaveIndex, this.arena) ? BattleType.TRAINER : BattleType.WILD; } else { newBattleType = battleType; } @@ -1586,13 +1414,11 @@ export default class BattleScene extends SceneBase { if (trainerConfigs[trainerType].doubleOnly) { doubleTrainer = true; } else if (trainerConfigs[trainerType].hasDouble) { - doubleTrainer = !Utils.randSeedInt( - this.getDoubleBattleChance(newWaveIndex, playerField), - ); + doubleTrainer = !Utils.randSeedInt(this.getDoubleBattleChance(newWaveIndex, playerField)); // Add a check that special trainers can't be double except for tate and liza - they should use the normal double chance if ( trainerConfigs[trainerType].trainerTypeDouble && - ![ TrainerType.TATE, TrainerType.LIZA ].includes(trainerType) + ![TrainerType.TATE, TrainerType.LIZA].includes(trainerType) ) { doubleTrainer = false; } @@ -1602,34 +1428,22 @@ export default class BattleScene extends SceneBase { : Utils.randSeedInt(2) ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT; - newTrainer = - trainerData !== undefined - ? trainerData.toTrainer() - : new Trainer(trainerType, variant); + newTrainer = trainerData !== undefined ? trainerData.toTrainer() : new Trainer(trainerType, variant); this.field.add(newTrainer); } // Check for mystery encounter // Can only occur in place of a standard (non-boss) wild battle, waves 10-180 - if ( - this.isWaveMysteryEncounter(newBattleType, newWaveIndex) || - newBattleType === BattleType.MYSTERY_ENCOUNTER - ) { + if (this.isWaveMysteryEncounter(newBattleType, newWaveIndex) || newBattleType === BattleType.MYSTERY_ENCOUNTER) { newBattleType = BattleType.MYSTERY_ENCOUNTER; // Reset to base spawn weight - this.mysteryEncounterSaveData.encounterSpawnChance = - BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT; + this.mysteryEncounterSaveData.encounterSpawnChance = BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT; } } if (double === undefined && newWaveIndex > 1) { - if ( - newBattleType === BattleType.WILD && - !this.gameMode.isWaveFinal(newWaveIndex) - ) { - newDouble = !Utils.randSeedInt( - this.getDoubleBattleChance(newWaveIndex, playerField), - ); + if (newBattleType === BattleType.WILD && !this.gameMode.isWaveFinal(newWaveIndex)) { + newDouble = !Utils.randSeedInt(this.getDoubleBattleChance(newWaveIndex, playerField)); } else if (newBattleType === BattleType.TRAINER) { newDouble = newTrainer?.variant === TrainerVariant.DOUBLE; } @@ -1667,10 +1481,7 @@ export default class BattleScene extends SceneBase { * Override battles into single only if not fighting with trainers. * @see {@link https://github.com/pagefaultgames/pokerogue/issues/1948 | GitHub Issue #1948} */ - if ( - newBattleType !== BattleType.TRAINER && - doubleOverrideForWave === "single" - ) { + if (newBattleType !== BattleType.TRAINER && doubleOverrideForWave === "single") { newDouble = false; } } @@ -1688,21 +1499,15 @@ export default class BattleScene extends SceneBase { } if (lastBattle?.double && !newDouble) { - this.tryRemovePhase((p) => p instanceof SwitchPhase); - this.getPlayerField().forEach((p) => - p.lapseTag(BattlerTagType.COMMANDED), - ); + this.tryRemovePhase(p => p instanceof SwitchPhase); + for (const p of this.getPlayerField()) { + p.lapseTag(BattlerTagType.COMMANDED); + } } this.executeWithSeedOffset( () => { - this.currentBattle = new Battle( - this.gameMode, - newWaveIndex, - newBattleType, - newTrainer, - newDouble, - ); + this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble); }, newWaveIndex << 3, this.waveSeed, @@ -1718,23 +1523,18 @@ export default class BattleScene extends SceneBase { if (!waveIndex && lastBattle) { const isWaveIndexMultipleOfTen = !(lastBattle.waveIndex % 10); - const isEndlessOrDaily = - this.gameMode.hasShortBiomes || this.gameMode.isDaily; - const isEndlessFifthWave = - this.gameMode.hasShortBiomes && lastBattle.waveIndex % 5 === 0; - const isWaveIndexMultipleOfFiftyMinusOne = - lastBattle.waveIndex % 50 === 49; + const isEndlessOrDaily = this.gameMode.hasShortBiomes || this.gameMode.isDaily; + const isEndlessFifthWave = this.gameMode.hasShortBiomes && lastBattle.waveIndex % 5 === 0; + const isWaveIndexMultipleOfFiftyMinusOne = lastBattle.waveIndex % 50 === 49; const isNewBiome = - isWaveIndexMultipleOfTen || - isEndlessFifthWave || - (isEndlessOrDaily && isWaveIndexMultipleOfFiftyMinusOne); + isWaveIndexMultipleOfTen || isEndlessFifthWave || (isEndlessOrDaily && isWaveIndexMultipleOfFiftyMinusOne); const resetArenaState = isNewBiome || - [ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes( - this.currentBattle.battleType, - ) || + [BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER].includes(this.currentBattle.battleType) || this.currentBattle.battleSpec === BattleSpec.FINAL_BOSS; - this.getEnemyParty().forEach((enemyPokemon) => enemyPokemon.destroy()); + for (const enemyPokemon of this.getEnemyParty()) { + enemyPokemon.destroy(); + } this.trySpreadPokerus(); if (!isNewBiome && newWaveIndex % 10 === 5) { this.arena.updatePoolsForTimeOfDay(); @@ -1742,9 +1542,9 @@ export default class BattleScene extends SceneBase { if (resetArenaState) { this.arena.resetArenaEffects(); - playerField.forEach((pokemon) => - pokemon.lapseTag(BattlerTagType.COMMANDED), - ); + for (const pokemon of playerField) { + pokemon.lapseTag(BattlerTagType.COMMANDED); + } playerField.forEach((pokemon, p) => { if (pokemon.isOnField()) { @@ -1758,9 +1558,7 @@ export default class BattleScene extends SceneBase { applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon); if ( pokemon.hasSpecies(Species.TERAPAGOS) || - (this.gameMode.isClassic && - this.currentBattle.waveIndex > 180 && - this.currentBattle.waveIndex <= 190) + (this.gameMode.isClassic && this.currentBattle.waveIndex > 180 && this.currentBattle.waveIndex <= 190) ) { this.arena.playerTerasUsed = 0; } @@ -1772,10 +1570,7 @@ export default class BattleScene extends SceneBase { } for (const pokemon of this.getPlayerParty()) { - this.triggerPokemonFormChange( - pokemon, - SpeciesFormChangeTimeOfDayTrigger, - ); + this.triggerPokemonFormChange(pokemon, SpeciesFormChangeTimeOfDayTrigger); } if (!this.gameMode.hasRandomBiomes && !isNewBiome) { @@ -1806,18 +1601,14 @@ export default class BattleScene extends SceneBase { } updateFieldScale(): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { const fieldScale = Math.floor( Math.pow( 1 / this.getField(true) - .map((p) => p.getSpriteScale()) - .reduce( - (highestScale: number, scale: number) => - (highestScale = Math.max(scale, highestScale)), - 0, - ), + .map(p => p.getSpriteScale()) + .reduce((highestScale: number, scale: number) => (highestScale = Math.max(scale, highestScale)), 0), 0.7, ) * 40, ) / 40; @@ -1825,8 +1616,8 @@ export default class BattleScene extends SceneBase { }); } - setFieldScale(scale: number, instant: boolean = false): Promise { - return new Promise((resolve) => { + setFieldScale(scale: number, instant = false): Promise { + return new Promise(resolve => { scale *= 6; if (this.field.scale === scale) { return resolve(); @@ -1842,32 +1633,27 @@ export default class BattleScene extends SceneBase { scale: scale, x: (defaultWidth - scaledWidth) / 2, y: defaultHeight - scaledHeight, - duration: !instant - ? Utils.fixedInt(Math.abs(this.field.scale - scale) * 200) - : 0, + duration: !instant ? Utils.fixedInt(Math.abs(this.field.scale - scale) * 200) : 0, ease: "Sine.easeInOut", onComplete: () => resolve(), }); }); } - getSpeciesFormIndex( - species: PokemonSpecies, - gender?: Gender, - nature?: Nature, - ignoreArena?: boolean, - ): number { + getSpeciesFormIndex(species: PokemonSpecies, gender?: Gender, nature?: Nature, ignoreArena?: boolean): number { if (!species.forms?.length) { return 0; } - const isEggPhase: boolean = [ "EggLapsePhase", "EggHatchPhase" ].includes( + const isEggPhase: boolean = ["EggLapsePhase", "EggHatchPhase"].includes( this.getCurrentPhase()?.constructor.name ?? "", ); - if ( // Give trainers with specialty types an appropriately-typed form for Wormadam, Rotom, Arceus, Oricorio, Silvally, or Paldean Tauros. + if ( + // Give trainers with specialty types an appropriately-typed form for Wormadam, Rotom, Arceus, Oricorio, Silvally, or Paldean Tauros. !isEggPhase && - this.currentBattle?.battleType === BattleType.TRAINER && !isNullOrUndefined(this.currentBattle.trainer) && + this.currentBattle?.battleType === BattleType.TRAINER && + !isNullOrUndefined(this.currentBattle.trainer) && this.currentBattle.trainer.config.hasSpecialtyType() ) { if (species.speciesId === Species.WORMADAM) { @@ -1879,7 +1665,8 @@ export default class BattleScene extends SceneBase { case PokemonType.GRASS: return 0; // Plant Cloak } - } else if (species.speciesId === Species.ROTOM) { + } + if (species.speciesId === Species.ROTOM) { switch (this.currentBattle.trainer.config.specialtyType) { case PokemonType.FLYING: return 4; // Fan Rotom @@ -1894,7 +1681,8 @@ export default class BattleScene extends SceneBase { case PokemonType.ICE: return 3; // Frost Rotom } - } else if (species.speciesId === Species.ORICORIO) { + } + if (species.speciesId === Species.ORICORIO) { switch (this.currentBattle.trainer.config.specialtyType) { case PokemonType.GHOST: return 3; // Sensu Style @@ -1905,14 +1693,17 @@ export default class BattleScene extends SceneBase { case PokemonType.PSYCHIC: return 2; // Pa'u Style } - } else if (species.speciesId === Species.PALDEA_TAUROS) { + } + if (species.speciesId === Species.PALDEA_TAUROS) { switch (this.currentBattle.trainer.config.specialtyType) { case PokemonType.FIRE: return 1; // Blaze Breed case PokemonType.WATER: return 2; // Aqua Breed } - } else if (species.speciesId === Species.SILVALLY || species.speciesId === Species.ARCEUS) { // Would probably never happen, but might as well + } + if (species.speciesId === Species.SILVALLY || species.speciesId === Species.ARCEUS) { + // Would probably never happen, but might as well return this.currentBattle.trainer.config.specialtyType; } } @@ -1941,10 +1732,7 @@ export default class BattleScene extends SceneBase { case Species.PALDEA_TAUROS: return Utils.randSeedInt(species.forms.length); case Species.PIKACHU: - if ( - this.currentBattle?.battleType === BattleType.TRAINER && - this.currentBattle?.waveIndex < 30 - ) { + if (this.currentBattle?.battleType === BattleType.TRAINER && this.currentBattle?.waveIndex < 30) { return 0; // Ban Cosplay and Partner Pika from Trainers before wave 30 } return Utils.randSeedInt(8); @@ -1960,10 +1748,7 @@ export default class BattleScene extends SceneBase { case Species.FROAKIE: case Species.FROGADIER: case Species.GRENINJA: - if ( - this.currentBattle?.battleType === BattleType.TRAINER && - !isEggPhase - ) { + if (this.currentBattle?.battleType === BattleType.TRAINER && !isEggPhase) { return 0; // Don't give trainers Battle Bond Greninja, Froakie or Frogadier } return Utils.randSeedInt(2); @@ -1980,7 +1765,7 @@ export default class BattleScene extends SceneBase { case Species.BASCULEGION: case Species.OINKOLOGNE: return gender === Gender.FEMALE ? 1 : 0; - case Species.TOXTRICITY: + case Species.TOXTRICITY: { const lowkeyNatures = [ Nature.LONELY, Nature.BOLD, @@ -1999,13 +1784,13 @@ export default class BattleScene extends SceneBase { return 1; } return 0; + } case Species.GIMMIGHOUL: // Chest form can only be found in Mysterious Chest Encounter, if this is a game mode with MEs if (this.gameMode.hasMysteryEncounters && !isEggPhase) { return 1; // Wandering form - } else { - return Utils.randSeedInt(species.forms.length); } + return Utils.randSeedInt(species.forms.length); } if (ignoreArena) { @@ -2046,15 +1831,11 @@ export default class BattleScene extends SceneBase { return ret; } - getEncounterBossSegments( - waveIndex: number, - level: number, - species?: PokemonSpecies, - forceBoss: boolean = false, - ): number { + getEncounterBossSegments(waveIndex: number, level: number, species?: PokemonSpecies, forceBoss = false): number { if (Overrides.OPP_HEALTH_SEGMENTS_OVERRIDE > 1) { return Overrides.OPP_HEALTH_SEGMENTS_OVERRIDE; - } else if (Overrides.OPP_HEALTH_SEGMENTS_OVERRIDE === 1) { + } + if (Overrides.OPP_HEALTH_SEGMENTS_OVERRIDE === 1) { // The rest of the code expects to be returned 0 and not 1 if the enemy is not a boss return 0; } @@ -2064,26 +1845,21 @@ export default class BattleScene extends SceneBase { } let isBoss: boolean | undefined; - if ( - forceBoss || - (species && - (species.subLegendary || species.legendary || species.mythical)) - ) { + if (forceBoss || (species && (species.subLegendary || species.legendary || species.mythical))) { isBoss = true; } else { this.executeWithSeedOffset(() => { isBoss = waveIndex % 10 === 0 || (this.gameMode.hasRandomBosses && - Utils.randSeedInt(100) < - Math.min(Math.max(Math.ceil((waveIndex - 250) / 50), 0) * 2, 30)); + Utils.randSeedInt(100) < Math.min(Math.max(Math.ceil((waveIndex - 250) / 50), 0) * 2, 30)); }, waveIndex << 2); } if (!isBoss) { return 0; } - let ret: number = 2; + let ret = 2; if (level >= 100) { ret++; @@ -2130,12 +1906,13 @@ export default class BattleScene extends SceneBase { resetSeed(waveIndex?: number): void { const wave = waveIndex || this.currentBattle?.waveIndex || 0; this.waveSeed = Utils.shiftCharCodes(this.seed, wave); - Phaser.Math.RND.sow([ this.waveSeed ]); + Phaser.Math.RND.sow([this.waveSeed]); console.log("Wave Seed:", this.waveSeed, wave); this.rngCounter = 0; } executeWithSeedOffset( + // biome-ignore lint/complexity/noBannedTypes: Refactor to not use Function func: Function, offset: number, seedOverride?: string, @@ -2147,9 +1924,7 @@ export default class BattleScene extends SceneBase { const tempRngOffset = this.rngOffset; const tempRngSeedOverride = this.rngSeedOverride; const state = Phaser.Math.RND.state(); - Phaser.Math.RND.sow([ - Utils.shiftCharCodes(seedOverride || this.seed, offset), - ]); + Phaser.Math.RND.sow([Utils.shiftCharCodes(seedOverride || this.seed, offset)]); this.rngCounter = 0; this.rngOffset = offset; this.rngSeedOverride = seedOverride || ""; @@ -2165,7 +1940,7 @@ export default class BattleScene extends SceneBase { y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, - terrainColorRatio: number = 0, + terrainColorRatio = 0, ): Phaser.GameObjects.Sprite { const ret = this.add.sprite(x, y, texture, frame); ret.setPipeline(this.fieldSpritePipeline); @@ -2182,8 +1957,8 @@ export default class BattleScene extends SceneBase { y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, - hasShadow: boolean = false, - ignoreOverride: boolean = false, + hasShadow = false, + ignoreOverride = false, ): Phaser.GameObjects.Sprite { const ret = this.addFieldSprite(x, y, texture, frame); this.initPokemonSprite(ret, pokemon, hasShadow, ignoreOverride); @@ -2193,11 +1968,11 @@ export default class BattleScene extends SceneBase { initPokemonSprite( sprite: Phaser.GameObjects.Sprite, pokemon?: Pokemon, - hasShadow: boolean = false, - ignoreOverride: boolean = false, + hasShadow = false, + ignoreOverride = false, ): Phaser.GameObjects.Sprite { sprite.setPipeline(this.spritePipeline, { - tone: [ 0.0, 0.0, 0.0, 0.0 ], + tone: [0.0, 0.0, 0.0, 0.0], hasShadow: hasShadow, ignoreOverride: ignoreOverride, teraColor: pokemon ? getTypeRgb(pokemon.getTeraType()) : undefined, @@ -2215,7 +1990,7 @@ export default class BattleScene extends SceneBase { } showFieldOverlay(duration: number): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { this.tweens.add({ targets: this.fieldOverlay, alpha: 0.5, @@ -2227,7 +2002,7 @@ export default class BattleScene extends SceneBase { } hideFieldOverlay(duration: number): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { this.tweens.add({ targets: this.fieldOverlay, alpha: 0, @@ -2248,7 +2023,7 @@ export default class BattleScene extends SceneBase { showShopOverlay(duration: number): Promise { this.shopOverlayShown = true; - return new Promise((resolve) => { + return new Promise(resolve => { this.tweens.add({ targets: this.shopOverlay, alpha: this.shopOverlayOpacity, @@ -2261,7 +2036,7 @@ export default class BattleScene extends SceneBase { hideShopOverlay(duration: number): Promise { this.shopOverlayShown = false; - return new Promise((resolve) => { + return new Promise(resolve => { this.tweens.add({ targets: this.shopOverlay, alpha: 0, @@ -2284,22 +2059,18 @@ export default class BattleScene extends SceneBase { const isBoss = !(this.currentBattle.waveIndex % 10); const biomeString: string = getBiomeName(this.arena.biomeType); this.fieldUI.moveAbove(this.biomeWaveText, this.luckText); - this.biomeWaveText.setText( - biomeString + " - " + this.currentBattle.waveIndex.toString(), - ); + this.biomeWaveText.setText(biomeString + " - " + this.currentBattle.waveIndex.toString()); this.biomeWaveText.setColor(!isBoss ? "#ffffff" : "#f89890"); this.biomeWaveText.setShadowColor(!isBoss ? "#636363" : "#984038"); this.biomeWaveText.setVisible(true); } - updateMoneyText(forceVisible: boolean = true): void { + updateMoneyText(forceVisible = true): void { if (this.money === undefined) { return; } const formattedMoney = Utils.formatMoney(this.moneyFormat, this.money); - this.moneyText.setText( - i18next.t("battleScene:moneyOwned", { formattedMoney }), - ); + this.moneyText.setText(i18next.t("battleScene:moneyOwned", { formattedMoney })); this.fieldUI.moveAbove(this.moneyText, this.luckText); if (forceVisible) { this.moneyText.setVisible(true); @@ -2318,8 +2089,7 @@ export default class BattleScene extends SceneBase { scale: this.moneyText.scale + deltaScale, loop: 0, yoyo: true, - onComplete: (_) => - this.moneyText.setShadowColor(getTextColor(TextStyle.MONEY, true)), + onComplete: _ => this.moneyText.setShadowColor(getTextColor(TextStyle.MONEY, true)), }); } @@ -2333,8 +2103,10 @@ export default class BattleScene extends SceneBase { * @param duration The time for this label to fade in, if it is not already visible. */ updateAndShowText(duration: number): void { - const labels = [ this.luckLabelText, this.luckText ]; - labels.forEach((t) => t.setAlpha(0)); + const labels = [this.luckLabelText, this.luckText]; + for (const label of labels) { + label.setAlpha(0); + } const luckValue = getPartyLuckValue(this.getPlayerParty()); this.luckText.setText(getLuckString(luckValue)); if (luckValue < 14) { @@ -2342,15 +2114,15 @@ export default class BattleScene extends SceneBase { } else { this.luckText.setTint(0xffef5c, 0x47ff69, 0x6b6bff, 0xff6969); } - this.luckLabelText.setX( - this.game.canvas.width / 6 - 2 - (this.luckText.displayWidth + 2), - ); + this.luckLabelText.setX(this.game.canvas.width / 6 - 2 - (this.luckText.displayWidth + 2)); this.tweens.add({ targets: labels, duration: duration, alpha: 1, onComplete: () => { - labels.forEach((t) => t.setVisible(true)); + for (const label of labels) { + label.setVisible(true); + } }, }); } @@ -2359,23 +2131,22 @@ export default class BattleScene extends SceneBase { if (this.reroll) { return; } - const labels = [ this.luckLabelText, this.luckText ]; + const labels = [this.luckLabelText, this.luckText]; this.tweens.add({ targets: labels, duration: duration, alpha: 0, onComplete: () => { - labels.forEach((l) => l.setVisible(false)); + for (const label of labels) { + label.setVisible(false); + } }, }); } updateUIPositions(): void { - const enemyModifierCount = this.enemyModifiers.filter((m) => - m.isIconVisible(), - ).length; - const biomeWaveTextHeight = - this.biomeWaveText.getBottomLeft().y - this.biomeWaveText.getTopLeft().y; + const enemyModifierCount = this.enemyModifiers.filter(m => m.isIconVisible()).length; + const biomeWaveTextHeight = this.biomeWaveText.getBottomLeft().y - this.biomeWaveText.getTopLeft().y; this.biomeWaveText.setY( -(this.game.canvas.height / 6) + (enemyModifierCount ? (enemyModifierCount <= 12 ? 15 : 24) : 0) + @@ -2383,11 +2154,10 @@ export default class BattleScene extends SceneBase { ); this.moneyText.setY(this.biomeWaveText.y + 10); this.scoreText.setY(this.moneyText.y + 10); - [ this.luckLabelText, this.luckText ].map((l) => + [this.luckLabelText, this.luckText].map(l => l.setY((this.scoreText.visible ? this.scoreText : this.moneyText).y + 10), ); - const offsetY = - (this.scoreText.visible ? this.scoreText : this.moneyText).y + 15; + const offsetY = (this.scoreText.visible ? this.scoreText : this.moneyText).y + 15; this.partyExpBar.setY(offsetY); this.candyBar.setY(offsetY + 15); this.ui?.achvBar.setY(this.game.canvas.height / 6 + offsetY); @@ -2406,16 +2176,9 @@ export default class BattleScene extends SceneBase { let scoreIncrease = enemy.getSpeciesForm().getBaseExp() * (enemy.level / this.getMaxExpLevel()) * - ((enemy.ivs.reduce((iv: number, total: number) => (total += iv), 0) / - 93) * - 0.2 + - 0.8); - this.findModifiers( - (m) => m instanceof PokemonHeldItemModifier && m.pokemonId === enemy.id, - false, - ).map( - (m) => - (scoreIncrease *= (m as PokemonHeldItemModifier).getScoreMultiplier()), + ((enemy.ivs.reduce((iv: number, total: number) => (total += iv), 0) / 93) * 0.2 + 0.8); + this.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemy.id, false).map( + m => (scoreIncrease *= (m as PokemonHeldItemModifier).getScoreMultiplier()), ); if (enemy.isBoss()) { scoreIncrease *= Math.sqrt(enemy.bossSegments); @@ -2423,17 +2186,16 @@ export default class BattleScene extends SceneBase { this.currentBattle.battleScore += Math.ceil(scoreIncrease); } - getMaxExpLevel(ignoreLevelCap: boolean = false): number { + getMaxExpLevel(ignoreLevelCap = false): number { if (Overrides.LEVEL_CAP_OVERRIDE > 0) { return Overrides.LEVEL_CAP_OVERRIDE; - } else if (ignoreLevelCap || Overrides.LEVEL_CAP_OVERRIDE < 0) { + } + if (ignoreLevelCap || Overrides.LEVEL_CAP_OVERRIDE < 0) { return Number.MAX_SAFE_INTEGER; } const waveIndex = Math.ceil((this.currentBattle?.waveIndex || 1) / 10) * 10; const difficultyWaveIndex = this.gameMode.getWaveForDifficulty(waveIndex); - const baseLevel = - (1 + difficultyWaveIndex / 2 + Math.pow(difficultyWaveIndex / 25, 2)) * - 1.2; + const baseLevel = (1 + difficultyWaveIndex / 2 + Math.pow(difficultyWaveIndex / 25, 2)) * 1.2; return Math.ceil(baseLevel / 2) * 2 + 2; } @@ -2445,54 +2207,39 @@ export default class BattleScene extends SceneBase { filterAllEvolutions?: boolean, ): PokemonSpecies { if (fromArenaPool) { - return this.arena.randomSpecies( - waveIndex, - level, - undefined, - getPartyLuckValue(this.party), - ); + return this.arena.randomSpecies(waveIndex, level, undefined, getPartyLuckValue(this.party)); } const filteredSpecies = speciesFilter ? [ - ...new Set( - allSpecies - .filter((s) => s.isCatchable()) - .filter(speciesFilter) - .map((s) => { - if (!filterAllEvolutions) { - while (pokemonPrevolutions.hasOwnProperty(s.speciesId)) { - s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]); + ...new Set( + allSpecies + .filter(s => s.isCatchable()) + .filter(speciesFilter) + .map(s => { + if (!filterAllEvolutions) { + while (pokemonPrevolutions.hasOwnProperty(s.speciesId)) { + s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]); + } } - } - return s; - }), - ), - ] - : allSpecies.filter((s) => s.isCatchable()); + return s; + }), + ), + ] + : allSpecies.filter(s => s.isCatchable()); return filteredSpecies[Utils.randSeedInt(filteredSpecies.length)]; } generateRandomBiome(waveIndex: number): Biome { const relWave = waveIndex % 250; - const biomes = Utils.getEnumValues(Biome).filter( - (b) => b !== Biome.TOWN && b !== Biome.END, - ); + const biomes = Utils.getEnumValues(Biome).filter(b => b !== Biome.TOWN && b !== Biome.END); const maxDepth = biomeDepths[Biome.END][0] - 2; const depthWeights = new Array(maxDepth + 1) .fill(null) - .map( - (_, i: number) => - ((1 - - Math.min(Math.abs(i / (maxDepth - 1) - relWave / 250) + 0.25, 1)) / - 0.75) * - 250, - ); + .map((_, i: number) => ((1 - Math.min(Math.abs(i / (maxDepth - 1) - relWave / 250) + 0.25, 1)) / 0.75) * 250); const biomeThresholds: number[] = []; let totalWeight = 0; for (const biome of biomes) { - totalWeight += Math.ceil( - depthWeights[biomeDepths[biome][0] - 1] / biomeDepths[biome][1], - ); + totalWeight += Math.ceil(depthWeights[biomeDepths[biome][0] - 1] / biomeDepths[biome][1]); biomeThresholds.push(totalWeight); } @@ -2508,7 +2255,7 @@ export default class BattleScene extends SceneBase { } isBgmPlaying(): boolean { - return this.bgm && this.bgm.isPlaying; + return this.bgm?.isPlaying ?? false; } playBgm(bgmName?: string, fadeOut?: boolean): void { @@ -2529,10 +2276,7 @@ export default class BattleScene extends SceneBase { this.bgmCache.add(bgmName); this.loadBgm(bgmName); let loopPoint = 0; - loopPoint = - bgmName === this.arena.bgm - ? this.arena.getBgmLoopPoint() - : this.getBgmLoopPoint(bgmName); + loopPoint = bgmName === this.arena.bgm ? this.arena.getBgmLoopPoint() : this.getBgmLoopPoint(bgmName); let loaded = false; const playNewBgm = () => { this.ui.bgmBar.setBgmToBgmBar(bgmName); @@ -2613,13 +2357,11 @@ export default class BattleScene extends SceneBase { } } - fadeOutBgm(duration: number = 500, destroy: boolean = true): boolean { + fadeOutBgm(duration = 500, destroy = true): boolean { if (!this.bgm) { return false; } - const bgm = this.sound - .getAllPlaying() - .find((bgm) => bgm.key === this.bgm.key); + const bgm = this.sound.getAllPlaying().find(bgm => bgm.key === this.bgm.key); if (bgm) { SoundFade.fadeOut(this, this.bgm, duration, destroy); return true; @@ -2634,11 +2376,7 @@ export default class BattleScene extends SceneBase { * @param destroy * @param delay */ - fadeAndSwitchBgm( - newBgmKey: string, - destroy: boolean = false, - delay: number = 2000, - ) { + fadeAndSwitchBgm(newBgmKey: string, destroy = false, delay = 2000) { this.fadeOutBgm(delay, destroy); this.time.delayedCall(delay, () => { this.playBgm(newBgmKey); @@ -2695,13 +2433,10 @@ export default class BattleScene extends SceneBase { this.bgmResumeTimer.destroy(); } if (resumeBgm) { - this.bgmResumeTimer = this.time.delayedCall( - pauseDuration || Utils.fixedInt(sound.totalDuration * 1000), - () => { - this.resumeBgm(); - this.bgmResumeTimer = null; - }, - ); + this.bgmResumeTimer = this.time.delayedCall(pauseDuration || Utils.fixedInt(sound.totalDuration * 1000), () => { + this.resumeBgm(); + this.bgmResumeTimer = null; + }); } return sound; } @@ -2952,7 +2687,7 @@ export default class BattleScene extends SceneBase { * */ pushConditionalPhase(phase: Phase, condition: () => boolean): void { - this.conditionalQueue.push([ condition, phase ]); + this.conditionalQueue.push([condition, phase]); } /** @@ -2960,7 +2695,7 @@ export default class BattleScene extends SceneBase { * @param phase {@linkcode Phase} the phase to add * @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue */ - pushPhase(phase: Phase, defer: boolean = false): void { + pushPhase(phase: Phase, defer = false): void { (!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase); } @@ -2972,11 +2707,7 @@ export default class BattleScene extends SceneBase { if (this.phaseQueuePrependSpliceIndex === -1) { this.phaseQueuePrepend.push(...phases); } else { - this.phaseQueuePrepend.splice( - this.phaseQueuePrependSpliceIndex, - 0, - ...phases, - ); + this.phaseQueuePrepend.splice(this.phaseQueuePrependSpliceIndex, 0, ...phases); } } @@ -3049,10 +2780,7 @@ export default class BattleScene extends SceneBase { } if (this.currentPhase) { - console.log( - `%cStart Phase ${this.currentPhase.constructor.name}`, - "color:green;", - ); + console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;"); this.currentPhase.start(); } } @@ -3076,16 +2804,11 @@ export default class BattleScene extends SceneBase { * @param phaseFilter filter function to use to find the wanted phase * @returns the found phase or undefined if none found */ - findPhase

( - phaseFilter: (phase: P) => boolean, - ): P | undefined { + findPhase

(phaseFilter: (phase: P) => boolean): P | undefined { return this.phaseQueue.find(phaseFilter) as P; } - tryReplacePhase( - phaseFilter: (phase: Phase) => boolean, - phase: Phase, - ): boolean { + tryReplacePhase(phaseFilter: (phase: Phase) => boolean, phase: Phase): boolean { const phaseIndex = this.phaseQueue.findIndex(phaseFilter); if (phaseIndex > -1) { this.phaseQueue[phaseIndex] = phase; @@ -3122,24 +2845,18 @@ export default class BattleScene extends SceneBase { * @param targetPhase {@linkcode Phase} the type of phase to search for in phaseQueue * @returns boolean if a targetPhase was found and added */ - prependToPhase( - phase: Phase | Phase[], - targetPhase: Constructor, - ): boolean { + prependToPhase(phase: Phase | Phase[], targetPhase: Constructor): boolean { if (!Array.isArray(phase)) { - phase = [ phase ]; + phase = [phase]; } - const targetIndex = this.phaseQueue.findIndex( - (ph) => ph instanceof targetPhase, - ); + const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase); if (targetIndex !== -1) { this.phaseQueue.splice(targetIndex, 0, ...phase); return true; - } else { - this.unshiftPhase(...phase); - return false; } + this.unshiftPhase(...phase); + return false; } /** @@ -3148,24 +2865,18 @@ export default class BattleScene extends SceneBase { * @param targetPhase {@linkcode Phase} the type of phase to search for in {@linkcode phaseQueue} * @returns `true` if a `targetPhase` was found to append to */ - appendToPhase( - phase: Phase | Phase[], - targetPhase: Constructor, - ): boolean { + appendToPhase(phase: Phase | Phase[], targetPhase: Constructor): boolean { if (!Array.isArray(phase)) { - phase = [ phase ]; + phase = [phase]; } - const targetIndex = this.phaseQueue.findIndex( - (ph) => ph instanceof targetPhase, - ); + const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase); if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) { this.phaseQueue.splice(targetIndex + 1, 0, ...phase); return true; - } else { - this.unshiftPhase(...phase); - return false; } + this.unshiftPhase(...phase); + return false; } /** @@ -3215,10 +2926,8 @@ export default class BattleScene extends SceneBase { const waveIndex = this.currentBattle.waveIndex; const waveSetIndex = Math.ceil(waveIndex / 10) - 1; const moneyValue = - Math.pow( - (waveSetIndex + 1 + (0.75 + (((waveIndex - 1) % 10) + 1) / 10)) * 100, - 1 + 0.005 * waveSetIndex, - ) * moneyMultiplier; + Math.pow((waveSetIndex + 1 + (0.75 + (((waveIndex - 1) % 10) + 1) / 10)) * 100, 1 + 0.005 * waveSetIndex) * + moneyMultiplier; return Math.floor(moneyValue / 10) * 10; } @@ -3249,9 +2958,7 @@ export default class BattleScene extends SceneBase { this.playSound(soundName); } } else if (!virtual) { - const defaultModifierType = getDefaultModifierTypeForTier( - modifier.type.tier, - ); + const defaultModifierType = getDefaultModifierTypeForTier(modifier.type.tier); this.queueMessage( i18next.t("battle:itemStackFull", { fullItemName: modifier.type.name, @@ -3261,13 +2968,7 @@ export default class BattleScene extends SceneBase { false, 3000, ); - return this.addModifier( - defaultModifierType.newModifier(), - ignoreUpdate, - playSound, - false, - instant, - ); + return this.addModifier(defaultModifierType.newModifier(), ignoreUpdate, playSound, false, instant); } for (const rm of modifiersToRemove) { @@ -3290,23 +2991,14 @@ export default class BattleScene extends SceneBase { if (modifier instanceof PokemonHpRestoreModifier) { if (!(modifier as PokemonHpRestoreModifier).fainted) { const hpRestoreMultiplier = new Utils.NumberHolder(1); - this.applyModifiers( - HealingBoosterModifier, - true, - hpRestoreMultiplier, - ); + this.applyModifiers(HealingBoosterModifier, true, hpRestoreMultiplier); args.push(hpRestoreMultiplier.value); } else { args.push(1); } } else if (modifier instanceof FusePokemonModifier) { - args.push( - this.getPokemonById(modifier.fusePokemonId) as PlayerPokemon, - ); - } else if ( - modifier instanceof RememberMoveModifier && - !Utils.isNullOrUndefined(cost) - ) { + args.push(this.getPokemonById(modifier.fusePokemonId) as PlayerPokemon); + } else if (modifier instanceof RememberMoveModifier && !Utils.isNullOrUndefined(cost)) { args.push(cost); } @@ -3316,9 +3008,9 @@ export default class BattleScene extends SceneBase { } } - this.party.map((p) => p.updateInfo(instant)); + this.party.map(p => p.updateInfo(instant)); } else { - const args = [ this ]; + const args = [this]; if (modifier.shouldApply(...args)) { const result = modifier.apply(...args); success ||= result; @@ -3328,12 +3020,8 @@ export default class BattleScene extends SceneBase { return success; } - addEnemyModifier( - modifier: PersistentModifier, - ignoreUpdate?: boolean, - instant?: boolean, - ): Promise { - return new Promise((resolve) => { + addEnemyModifier(modifier: PersistentModifier, ignoreUpdate?: boolean, instant?: boolean): Promise { + return new Promise(resolve => { const modifiersToRemove: PersistentModifier[] = []; if ((modifier as PersistentModifier).add(this.enemyModifiers, false)) { if (modifier instanceof PokemonFormChangeItemModifier) { @@ -3373,10 +3061,10 @@ export default class BattleScene extends SceneBase { itemModifier: PokemonHeldItemModifier, target: Pokemon, playSound: boolean, - transferQuantity: number = 1, + transferQuantity = 1, instant?: boolean, ignoreUpdate?: boolean, - itemLost: boolean = true, + itemLost = true, ): boolean { const source = itemModifier.pokemonId ? itemModifier.getPokemon() : null; const cancelled = new Utils.BooleanHolder(false); @@ -3392,10 +3080,7 @@ export default class BattleScene extends SceneBase { const newItemModifier = itemModifier.clone() as PokemonHeldItemModifier; newItemModifier.pokemonId = target.id; const matchingModifier = this.findModifier( - (m) => - m instanceof PokemonHeldItemModifier && - m.matchType(itemModifier) && - m.pokemonId === target.id, + m => m instanceof PokemonHeldItemModifier && m.matchType(itemModifier) && m.pokemonId === target.id, target.isPlayer(), ) as PokemonHeldItemModifier; @@ -3419,35 +3104,21 @@ export default class BattleScene extends SceneBase { const removeOld = itemModifier.stackCount === 0; - if ( - !removeOld || - !source || - this.removeModifier(itemModifier, !source.isPlayer()) - ) { + if (!removeOld || !source || this.removeModifier(itemModifier, !source.isPlayer())) { const addModifier = () => { - if ( - !matchingModifier || - this.removeModifier(matchingModifier, !target.isPlayer()) - ) { + if (!matchingModifier || this.removeModifier(matchingModifier, !target.isPlayer())) { if (target.isPlayer()) { - this.addModifier( - newItemModifier, - ignoreUpdate, - playSound, - false, - instant, - ); - if (source && itemLost) { - applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); - } - return true; - } else { - this.addEnemyModifier(newItemModifier, ignoreUpdate, instant); + this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant); if (source && itemLost) { applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); } return true; } + this.addEnemyModifier(newItemModifier, ignoreUpdate, instant); + if (source && itemLost) { + applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); + } + return true; } return false; }; @@ -3463,12 +3134,10 @@ export default class BattleScene extends SceneBase { } removePartyMemberModifiers(partyMemberIndex: number): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { const pokemonId = this.getPlayerParty()[partyMemberIndex].id; const modifiersToRemove = this.modifiers.filter( - (m) => - m instanceof PokemonHeldItemModifier && - (m as PokemonHeldItemModifier).pokemonId === pokemonId, + m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemonId, ); for (const m of modifiersToRemove) { this.modifiers.splice(this.modifiers.indexOf(m), 1); @@ -3478,19 +3147,13 @@ export default class BattleScene extends SceneBase { }); } - generateEnemyModifiers( - heldModifiersConfigs?: HeldModifierConfig[][], - ): Promise { - return new Promise((resolve) => { + generateEnemyModifiers(heldModifiersConfigs?: HeldModifierConfig[][]): Promise { + return new Promise(resolve => { if (this.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) { return resolve(); } - const difficultyWaveIndex = this.gameMode.getWaveForDifficulty( - this.currentBattle.waveIndex, - ); - const isFinalBoss = this.gameMode.isWaveFinal( - this.currentBattle.waveIndex, - ); + const difficultyWaveIndex = this.gameMode.getWaveForDifficulty(this.currentBattle.waveIndex); + const isFinalBoss = this.gameMode.isWaveFinal(this.currentBattle.waveIndex); let chances = Math.ceil(difficultyWaveIndex / 10); if (isFinalBoss) { chances = Math.ceil(chances * 2.5); @@ -3506,12 +3169,8 @@ export default class BattleScene extends SceneBase { } party.forEach((enemyPokemon: EnemyPokemon, i: number) => { - if ( - heldModifiersConfigs && - i < heldModifiersConfigs.length && - heldModifiersConfigs[i] - ) { - heldModifiersConfigs[i].forEach((mt) => { + if (heldModifiersConfigs && i < heldModifiersConfigs.length && heldModifiersConfigs[i]) { + for (const mt of heldModifiersConfigs[i]) { let modifier: PokemonHeldItemModifier; if (mt.modifier instanceof PokemonHeldItemModifierType) { modifier = mt.modifier.newModifier(enemyPokemon); @@ -3520,15 +3179,13 @@ export default class BattleScene extends SceneBase { modifier.pokemonId = enemyPokemon.id; } modifier.stackCount = mt.stackCount ?? 1; - modifier.isTransferable = - mt.isTransferable ?? modifier.isTransferable; + modifier.isTransferable = mt.isTransferable ?? modifier.isTransferable; this.addEnemyModifier(modifier, true); - }); + } } else { const isBoss = enemyPokemon.isBoss() || - (this.currentBattle.battleType === BattleType.TRAINER && - !!this.currentBattle.trainer?.config.isBoss); + (this.currentBattle.battleType === BattleType.TRAINER && !!this.currentBattle.trainer?.config.isBoss); let upgradeChance = 32; if (isBoss) { upgradeChance /= 2; @@ -3548,14 +3205,10 @@ export default class BattleScene extends SceneBase { getEnemyModifierTypesForWave( difficultyWaveIndex, count, - [ enemyPokemon ], - this.currentBattle.battleType === BattleType.TRAINER - ? ModifierPoolType.TRAINER - : ModifierPoolType.WILD, + [enemyPokemon], + this.currentBattle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD, upgradeChance, - ).map((mt) => - mt.newModifier(enemyPokemon).add(this.enemyModifiers, false), - ); + ).map(mt => mt.newModifier(enemyPokemon).add(this.enemyModifiers, false)); } return true; }); @@ -3568,9 +3221,7 @@ export default class BattleScene extends SceneBase { * Removes all modifiers from enemy pokemon of {@linkcode PersistentModifier} type */ clearEnemyModifiers(): void { - const modifiersToRemove = this.enemyModifiers.filter( - (m) => m instanceof PersistentModifier, - ); + const modifiersToRemove = this.enemyModifiers.filter(m => m instanceof PersistentModifier); for (const m of modifiersToRemove) { this.enemyModifiers.splice(this.enemyModifiers.indexOf(m), 1); } @@ -3584,9 +3235,7 @@ export default class BattleScene extends SceneBase { */ clearEnemyHeldItemModifiers(pokemon?: Pokemon): void { const modifiersToRemove = this.enemyModifiers.filter( - (m) => - m instanceof PokemonHeldItemModifier && - (!pokemon || m.getPokemon() === pokemon), + m => m instanceof PokemonHeldItemModifier && (!pokemon || m.getPokemon() === pokemon), ); for (const m of modifiersToRemove) { this.enemyModifiers.splice(this.enemyModifiers.indexOf(m), 1); @@ -3596,13 +3245,11 @@ export default class BattleScene extends SceneBase { } setModifiersVisible(visible: boolean) { - [ this.modifierBar, this.enemyModifierBar ].map((m) => m.setVisible(visible)); + [this.modifierBar, this.enemyModifierBar].map(m => m.setVisible(visible)); } - updateModifiers(player: boolean = true, instant?: boolean): void { - const modifiers = player - ? this.modifiers - : (this.enemyModifiers as PersistentModifier[]); + updateModifiers(player = true, instant?: boolean): void { + const modifiers = player ? this.modifiers : (this.enemyModifiers as PersistentModifier[]); for (let m = 0; m < modifiers.length; m++) { const modifier = modifiers[m]; if ( @@ -3625,22 +3272,17 @@ export default class BattleScene extends SceneBase { } } - this.updatePartyForModifiers( - player ? this.getPlayerParty() : this.getEnemyParty(), - instant, - ); - (player ? this.modifierBar : this.enemyModifierBar).updateModifiers( - modifiers, - ); + this.updatePartyForModifiers(player ? this.getPlayerParty() : this.getEnemyParty(), instant); + (player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers); if (!player) { this.updateUIPositions(); } } updatePartyForModifiers(party: Pokemon[], instant?: boolean): Promise { - return new Promise((resolve) => { + return new Promise(resolve => { Promise.allSettled( - party.map((p) => { + party.map(p => { p.calculateStats(); return p.updateInfo(instant); }), @@ -3656,10 +3298,7 @@ export default class BattleScene extends SceneBase { * @param enemy If `true`, remove an item owned by the enemy. If `false`, remove an item owned by the player. Default is `false`. * @returns `true` if the item exists and was successfully removed, `false` otherwise. */ - removeModifier( - modifier: PersistentModifier, - enemy: boolean = false, - ): boolean { + removeModifier(modifier: PersistentModifier, enemy = false): boolean { const modifiers = !enemy ? this.modifiers : this.enemyModifiers; const modifierIndex = modifiers.indexOf(modifier); if (modifierIndex > -1) { @@ -3682,13 +3321,8 @@ export default class BattleScene extends SceneBase { * @param player Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` * @returns the list of all modifiers that matched `modifierType`. */ - getModifiers( - modifierType: Constructor, - player: boolean = true, - ): T[] { - return (player ? this.modifiers : this.enemyModifiers).filter( - (m): m is T => m instanceof modifierType, - ); + getModifiers(modifierType: Constructor, player = true): T[] { + return (player ? this.modifiers : this.enemyModifiers).filter((m): m is T => m instanceof modifierType); } /** @@ -3697,13 +3331,8 @@ export default class BattleScene extends SceneBase { * @param isPlayer Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` * @returns the list of all modifiers that passed the `modifierFilter` function */ - findModifiers( - modifierFilter: ModifierPredicate, - isPlayer: boolean = true, - ): PersistentModifier[] { - return (isPlayer ? this.modifiers : this.enemyModifiers).filter( - modifierFilter, - ); + findModifiers(modifierFilter: ModifierPredicate, isPlayer = true): PersistentModifier[] { + return (isPlayer ? this.modifiers : this.enemyModifiers).filter(modifierFilter); } /** @@ -3712,10 +3341,7 @@ export default class BattleScene extends SceneBase { * @param player Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` * @returns the first modifier that passed the `modifierFilter` function; `undefined` if none passed */ - findModifier( - modifierFilter: ModifierPredicate, - player: boolean = true, - ): PersistentModifier | undefined { + findModifier(modifierFilter: ModifierPredicate, player = true): PersistentModifier | undefined { return (player ? this.modifiers : this.enemyModifiers).find(modifierFilter); } @@ -3728,7 +3354,7 @@ export default class BattleScene extends SceneBase { */ applyShuffledModifiers( modifierType: Constructor, - player: boolean = true, + player = true, ...args: Parameters ): T[] { let modifiers = (player ? this.modifiers : this.enemyModifiers).filter( @@ -3736,15 +3362,12 @@ export default class BattleScene extends SceneBase { ); this.executeWithSeedOffset( () => { - const shuffleModifiers = (mods) => { + const shuffleModifiers = mods => { if (mods.length < 1) { return mods; } const rand = Utils.randSeedInt(mods.length); - return [ - mods[rand], - ...shuffleModifiers(mods.filter((_, i) => i !== rand)), - ]; + return [mods[rand], ...shuffleModifiers(mods.filter((_, i) => i !== rand))]; }; modifiers = shuffleModifiers(modifiers); }, @@ -3763,7 +3386,7 @@ export default class BattleScene extends SceneBase { */ applyModifiers( modifierType: Constructor, - player: boolean = true, + player = true, ...args: Parameters ): T[] { const modifiers = (player ? this.modifiers : this.enemyModifiers).filter( @@ -3798,7 +3421,7 @@ export default class BattleScene extends SceneBase { */ applyModifier( modifierType: Constructor, - player: boolean = true, + player = true, ...args: Parameters ): T | null { const modifiers = (player ? this.modifiers : this.enemyModifiers).filter( @@ -3817,35 +3440,26 @@ export default class BattleScene extends SceneBase { triggerPokemonFormChange( pokemon: Pokemon, formChangeTriggerType: Constructor, - delayed: boolean = false, - modal: boolean = false, + delayed = false, + modal = false, ): boolean { if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId)) { // in case this is NECROZMA, determine which forms this - const matchingFormChangeOpts = pokemonFormChanges[ - pokemon.species.speciesId - ].filter( - (fc) => fc.findTrigger(formChangeTriggerType) && fc.canChange(pokemon), + const matchingFormChangeOpts = pokemonFormChanges[pokemon.species.speciesId].filter( + fc => fc.findTrigger(formChangeTriggerType) && fc.canChange(pokemon), ); let matchingFormChange: SpeciesFormChange | null; - if ( - pokemon.species.speciesId === Species.NECROZMA && - matchingFormChangeOpts.length > 1 - ) { + if (pokemon.species.speciesId === Species.NECROZMA && matchingFormChangeOpts.length > 1) { // Ultra Necrozma is changing its form back, so we need to figure out into which form it devolves. const formChangeItemModifiers = ( this.findModifiers( - (m) => - m instanceof PokemonFormChangeItemModifier && - m.pokemonId === pokemon.id, + m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === pokemon.id, ) as PokemonFormChangeItemModifier[] ) - .filter((m) => m.active) - .map((m) => m.formChangeItem); + .filter(m => m.active) + .map(m => m.formChangeItem); - matchingFormChange = formChangeItemModifiers.includes( - FormChangeItem.N_LUNARIZER, - ) + matchingFormChange = formChangeItemModifiers.includes(FormChangeItem.N_LUNARIZER) ? matchingFormChangeOpts[0] : formChangeItemModifiers.includes(FormChangeItem.N_SOLARIZER) ? matchingFormChangeOpts[1] @@ -3860,11 +3474,7 @@ export default class BattleScene extends SceneBase { } else { phase = new QuietFormChangePhase(pokemon, matchingFormChange); } - if ( - pokemon instanceof PlayerPokemon && - !matchingFormChange.quiet && - modal - ) { + if (pokemon instanceof PlayerPokemon && !matchingFormChange.quiet && modal) { this.overridePhase(phase); } else if (delayed) { this.pushPhase(phase); @@ -3882,13 +3492,9 @@ export default class BattleScene extends SceneBase { pokemon: Pokemon, battleAnimType: PokemonAnimType, fieldAssets?: Phaser.GameObjects.Sprite[], - delayed: boolean = false, + delayed = false, ): boolean { - const phase: Phase = new PokemonAnimPhase( - battleAnimType, - pokemon, - fieldAssets, - ); + const phase: Phase = new PokemonAnimPhase(battleAnimType, pokemon, fieldAssets); if (delayed) { this.pushPhase(phase); } else { @@ -3898,9 +3504,7 @@ export default class BattleScene extends SceneBase { } validateAchvs(achvType: Constructor, ...args: unknown[]): void { - const filteredAchvs = Object.values(achvs).filter( - (a) => a instanceof achvType, - ); + const filteredAchvs = Object.values(achvs).filter(a => a instanceof achvType); for (const achv of filteredAchvs) { this.validateAchv(achv, args); } @@ -3908,8 +3512,7 @@ export default class BattleScene extends SceneBase { validateAchv(achv: Achv, args?: unknown[]): boolean { if ( - (!this.gameData.achvUnlocks.hasOwnProperty(achv.id) || - Overrides.ACHIEVEMENTS_REUNLOCK_OVERRIDE) && + (!this.gameData.achvUnlocks.hasOwnProperty(achv.id) || Overrides.ACHIEVEMENTS_REUNLOCK_OVERRIDE) && achv.validate(args) ) { this.gameData.achvUnlocks[achv.id] = new Date().getTime(); @@ -3924,10 +3527,7 @@ export default class BattleScene extends SceneBase { } validateVoucher(voucher: Voucher, args?: unknown[]): boolean { - if ( - !this.gameData.voucherUnlocks.hasOwnProperty(voucher.id) && - voucher.validate(args) - ) { + if (!this.gameData.voucherUnlocks.hasOwnProperty(voucher.id) && voucher.validate(args)) { this.gameData.voucherUnlocks[voucher.id] = new Date().getTime(); this.ui.achvBar.showAchv(voucher); this.gameData.voucherCounts[voucher.voucherType]++; @@ -3944,19 +3544,19 @@ export default class BattleScene extends SceneBase { biome: this.currentBattle ? getBiomeName(this.arena.biomeType) : "", wave: this.currentBattle?.waveIndex ?? 0, party: this.party - ? this.party.map((p) => { - return { - name: p.name, - form: p.getFormKey(), - types: p.getTypes().map((type) => PokemonType[type]), - teraType: PokemonType[p.getTeraType()], - isTerastallized: p.isTerastallized, - level: p.level, - currentHP: p.hp, - maxHP: p.getMaxHp(), - status: p.status?.effect ? StatusEffect[p.status.effect] : "", - }; - }) + ? this.party.map(p => { + return { + name: p.name, + form: p.getFormKey(), + types: p.getTypes().map(type => PokemonType[type]), + teraType: PokemonType[p.getTeraType()], + isTerastallized: p.isTerastallized, + level: p.level, + currentHP: p.hp, + maxHP: p.getMaxHp(), + status: p.status?.effect ? StatusEffect[p.status.effect] : "", + }; + }) : [], modeChain: this.ui?.getModeChain() ?? [], }; @@ -3973,7 +3573,7 @@ export default class BattleScene extends SceneBase { const keys: string[] = []; let activePokemon: (PlayerPokemon | EnemyPokemon)[] = this.getPlayerParty(); activePokemon = activePokemon.concat(this.getEnemyParty()); - activePokemon.forEach((p) => { + for (const p of activePokemon) { keys.push(p.getSpriteKey(true)); if (p instanceof PlayerPokemon) { keys.push(p.getBattleSpriteKey(true, true)); @@ -3982,7 +3582,7 @@ export default class BattleScene extends SceneBase { if (p.fusionSpecies) { keys.push(p.fusionSpecies.getCryKey(p.fusionFormIndex)); } - }); + } return keys; } @@ -3991,34 +3591,23 @@ export default class BattleScene extends SceneBase { * @param pokemon The (enemy) pokemon */ initFinalBossPhaseTwo(pokemon: Pokemon): void { - if ( - pokemon instanceof EnemyPokemon && - pokemon.isBoss() && - !pokemon.formIndex && - pokemon.bossSegmentIndex < 1 - ) { + if (pokemon instanceof EnemyPokemon && pokemon.isBoss() && !pokemon.formIndex && pokemon.bossSegmentIndex < 1) { this.fadeOutBgm(Utils.fixedInt(2000), false); this.ui.showDialogue( battleSpecDialogue[BattleSpec.FINAL_BOSS].firstStageWin, pokemon.species.name, undefined, () => { - const finalBossMBH = getModifierType( - modifierTypes.MINI_BLACK_HOLE, - ).newModifier(pokemon) as TurnHeldItemTransferModifier; + const finalBossMBH = getModifierType(modifierTypes.MINI_BLACK_HOLE).newModifier( + pokemon, + ) as TurnHeldItemTransferModifier; finalBossMBH.setTransferrableFalse(); this.addEnemyModifier(finalBossMBH, false, true); pokemon.generateAndPopulateMoveset(1); this.setFieldScale(0.75); - this.triggerPokemonFormChange( - pokemon, - SpeciesFormChangeManualTrigger, - false, - ); + this.triggerPokemonFormChange(pokemon, SpeciesFormChangeManualTrigger, false); this.currentBattle.double = true; - const availablePartyMembers = this.getPlayerParty().filter((p) => - p.isAllowedInBattle(), - ); + const availablePartyMembers = this.getPlayerParty().filter(p => p.isAllowedInBattle()); if (availablePartyMembers.length > 1) { this.pushPhase(new ToggleDoublePositionPhase(true)); if (!availablePartyMembers[1].isOnField()) { @@ -4048,22 +3637,15 @@ export default class BattleScene extends SceneBase { useWaveIndexMultiplier?: boolean, pokemonParticipantIds?: Set, ): void { - const participantIds = - pokemonParticipantIds ?? this.currentBattle.playerParticipantIds; + const participantIds = pokemonParticipantIds ?? this.currentBattle.playerParticipantIds; const party = this.getPlayerParty(); - const expShareModifier = this.findModifier( - (m) => m instanceof ExpShareModifier, - ) as ExpShareModifier; - const expBalanceModifier = this.findModifier( - (m) => m instanceof ExpBalanceModifier, - ) as ExpBalanceModifier; + const expShareModifier = this.findModifier(m => m instanceof ExpShareModifier) as ExpShareModifier; + const expBalanceModifier = this.findModifier(m => m instanceof ExpBalanceModifier) as ExpBalanceModifier; const multipleParticipantExpBonusModifier = this.findModifier( - (m) => m instanceof MultipleParticipantExpBonusModifier, + m => m instanceof MultipleParticipantExpBonusModifier, ) as MultipleParticipantExpBonusModifier; - const nonFaintedPartyMembers = party.filter((p) => p.hp); - const expPartyMembers = nonFaintedPartyMembers.filter( - (p) => p.level < this.getMaxExpLevel(), - ); + const nonFaintedPartyMembers = party.filter(p => p.hp); + const expPartyMembers = nonFaintedPartyMembers.filter(p => p.level < this.getMaxExpLevel()); const partyMemberExp: number[] = []; // EXP value calculation is based off Pokemon.getExpValue if (useWaveIndexMultiplier) { @@ -4073,31 +3655,19 @@ export default class BattleScene extends SceneBase { if (participantIds.size > 0) { if ( this.currentBattle.battleType === BattleType.TRAINER || - this.currentBattle.mysteryEncounter?.encounterMode === - MysteryEncounterMode.TRAINER_BATTLE + this.currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE ) { expValue = Math.floor(expValue * 1.5); - } else if ( - this.currentBattle.isBattleMysteryEncounter() && - this.currentBattle.mysteryEncounter - ) { - expValue = Math.floor( - expValue * this.currentBattle.mysteryEncounter.expMultiplier, - ); + } else if (this.currentBattle.isBattleMysteryEncounter() && this.currentBattle.mysteryEncounter) { + expValue = Math.floor(expValue * this.currentBattle.mysteryEncounter.expMultiplier); } for (const partyMember of nonFaintedPartyMembers) { const pId = partyMember.id; const participated = participantIds.has(pId); if (participated && pokemonDefeated) { partyMember.addFriendship(FRIENDSHIP_GAIN_FROM_BATTLE); - const machoBraceModifier = partyMember - .getHeldItems() - .find((m) => m instanceof PokemonIncrementingStatModifier); - if ( - machoBraceModifier && - machoBraceModifier.stackCount < - machoBraceModifier.getMaxStackCount() - ) { + const machoBraceModifier = partyMember.getHeldItems().find(m => m instanceof PokemonIncrementingStatModifier); + if (machoBraceModifier && machoBraceModifier.stackCount < machoBraceModifier.getMaxStackCount()) { machoBraceModifier.stackCount++; this.updateModifiers(true, true); partyMember.updateInfo(); @@ -4114,12 +3684,10 @@ export default class BattleScene extends SceneBase { if (participated) { expMultiplier += 1 / participantIds.size; if (participantIds.size > 1 && multipleParticipantExpBonusModifier) { - expMultiplier += - multipleParticipantExpBonusModifier.getStackCount() * 0.2; + expMultiplier += multipleParticipantExpBonusModifier.getStackCount() * 0.2; } } else if (expShareModifier) { - expMultiplier += - (expShareModifier.getStackCount() * 0.2) / participantIds.size; + expMultiplier += (expShareModifier.getStackCount() * 0.2) / participantIds.size; } if (partyMember.pokerus) { expMultiplier *= 1.5; @@ -4128,12 +3696,7 @@ export default class BattleScene extends SceneBase { expMultiplier = Overrides.XP_MULTIPLIER_OVERRIDE; } const pokemonExp = new Utils.NumberHolder(expValue * expMultiplier); - this.applyModifiers( - PokemonExpBoosterModifier, - true, - partyMember, - pokemonExp, - ); + this.applyModifiers(PokemonExpBoosterModifier, true, partyMember, pokemonExp); partyMemberExp.push(Math.floor(pokemonExp.value)); } @@ -4154,9 +3717,7 @@ export default class BattleScene extends SceneBase { } }); - const splitExp = Math.floor( - totalExp / recipientExpPartyMemberIndexes.length, - ); + const splitExp = Math.floor(totalExp / recipientExpPartyMemberIndexes.length); expPartyMembers.forEach((_partyMember, pm) => { partyMemberExp[pm] = Phaser.Math.Linear( @@ -4187,12 +3748,8 @@ export default class BattleScene extends SceneBase { * Even if returns `true`, does not guarantee that a wave will actually be a ME. * That check is made in {@linkcode BattleScene.isWaveMysteryEncounter} instead. */ - isMysteryEncounterValidForWave( - battleType: BattleType, - waveIndex: number, - ): boolean { - const [ lowestMysteryEncounterWave, highestMysteryEncounterWave ] = - this.gameMode.getMysteryEncounterLegalWaves(); + isMysteryEncounterValidForWave(battleType: BattleType, waveIndex: number): boolean { + const [lowestMysteryEncounterWave, highestMysteryEncounterWave] = this.gameMode.getMysteryEncounterLegalWaves(); return ( this.gameMode.hasMysteryEncounters && battleType === BattleType.WILD && @@ -4209,45 +3766,32 @@ export default class BattleScene extends SceneBase { * @param newBattleType * @param waveIndex */ - private isWaveMysteryEncounter( - newBattleType: BattleType, - waveIndex: number, - ): boolean { - const [ lowestMysteryEncounterWave, highestMysteryEncounterWave ] = - this.gameMode.getMysteryEncounterLegalWaves(); + private isWaveMysteryEncounter(newBattleType: BattleType, waveIndex: number): boolean { + const [lowestMysteryEncounterWave, highestMysteryEncounterWave] = this.gameMode.getMysteryEncounterLegalWaves(); if (this.isMysteryEncounterValidForWave(newBattleType, waveIndex)) { // Base spawn weight is BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT/256, and increases by WEIGHT_INCREMENT_ON_SPAWN_MISS/256 for each missed attempt at spawning an encounter on a valid floor - const sessionEncounterRate = - this.mysteryEncounterSaveData.encounterSpawnChance; + const sessionEncounterRate = this.mysteryEncounterSaveData.encounterSpawnChance; const encounteredEvents = this.mysteryEncounterSaveData.encounteredEvents; // If total number of encounters is lower than expected for the run, slightly favor a new encounter spawn (reverse as well) // Reduces occurrence of runs with total encounters significantly different from AVERAGE_ENCOUNTERS_PER_RUN_TARGET // Favored rate changes can never exceed 50%. So if base rate is 15/256 and favored rate would add 200/256, result will be (15 + 128)/256 const expectedEncountersByFloor = - (AVERAGE_ENCOUNTERS_PER_RUN_TARGET / - (highestMysteryEncounterWave - lowestMysteryEncounterWave)) * + (AVERAGE_ENCOUNTERS_PER_RUN_TARGET / (highestMysteryEncounterWave - lowestMysteryEncounterWave)) * (waveIndex - lowestMysteryEncounterWave); - const currentRunDiffFromAvg = - expectedEncountersByFloor - encounteredEvents.length; + const currentRunDiffFromAvg = expectedEncountersByFloor - encounteredEvents.length; const favoredEncounterRate = sessionEncounterRate + - Math.min( - currentRunDiffFromAvg * ANTI_VARIANCE_WEIGHT_MODIFIER, - MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT / 2, - ); + Math.min(currentRunDiffFromAvg * ANTI_VARIANCE_WEIGHT_MODIFIER, MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT / 2); - const successRate = isNullOrUndefined( - Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE, - ) + const successRate = isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE) ? favoredEncounterRate : Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE!; // If the most recent ME was 3 or fewer waves ago, can never spawn a ME const canSpawn = encounteredEvents.length === 0 || - waveIndex - encounteredEvents[encounteredEvents.length - 1].waveIndex > - 3 || + waveIndex - encounteredEvents[encounteredEvents.length - 1].waveIndex > 3 || !isNullOrUndefined(Overrides.MYSTERY_ENCOUNTER_RATE_OVERRIDE); if (canSpawn) { @@ -4272,10 +3816,7 @@ export default class BattleScene extends SceneBase { * @param canBypass optional boolean to indicate that the request is coming from a function that needs to access a Mystery Encounter outside of gameplay requirements * @returns */ - getMysteryEncounter( - encounterType?: MysteryEncounterType, - canBypass?: boolean, - ): MysteryEncounter { + getMysteryEncounter(encounterType?: MysteryEncounterType, canBypass?: boolean): MysteryEncounter { // Loading override or session encounter let encounter: MysteryEncounter | null; if ( @@ -4290,9 +3831,7 @@ export default class BattleScene extends SceneBase { encounter = allMysteryEncounters[encounterType ?? -1]; return encounter; } else { - encounter = !isNullOrUndefined(encounterType) - ? allMysteryEncounters[encounterType] - : null; + encounter = !isNullOrUndefined(encounterType) ? allMysteryEncounters[encounterType] : null; } // Check for queued encounters first @@ -4302,10 +3841,7 @@ export default class BattleScene extends SceneBase { this.mysteryEncounterSaveData.queuedEncounters.length > 0 ) { let i = 0; - while ( - i < this.mysteryEncounterSaveData.queuedEncounters.length && - !!encounter - ) { + while (i < this.mysteryEncounterSaveData.queuedEncounters.length && !!encounter) { const candidate = this.mysteryEncounterSaveData.queuedEncounters[i]; const forcedChance = candidate.spawnPercent; if (Utils.randSeedInt(100) < forcedChance) { @@ -4331,22 +3867,20 @@ export default class BattleScene extends SceneBase { ]; // Adjust tier weights by previously encountered events to lower odds of only Common/Great in run - this.mysteryEncounterSaveData.encounteredEvents.forEach( - (seenEncounterData) => { - if (seenEncounterData.tier === MysteryEncounterTier.COMMON) { - tierWeights[0] = tierWeights[0] - 6; - } else if (seenEncounterData.tier === MysteryEncounterTier.GREAT) { - tierWeights[1] = tierWeights[1] - 4; - } - }, - ); + // biome-ignore format: biome sucks at formatting this line + for (const seenEncounterData of this.mysteryEncounterSaveData.encounteredEvents) { + if (seenEncounterData.tier === MysteryEncounterTier.COMMON) { + tierWeights[0] = tierWeights[0] - 6; + } else if (seenEncounterData.tier === MysteryEncounterTier.GREAT) { + tierWeights[1] = tierWeights[1] - 4; + } + } const totalWeight = tierWeights.reduce((a, b) => a + b); const tierValue = Utils.randSeedInt(totalWeight); const commonThreshold = totalWeight - tierWeights[0]; const greatThreshold = totalWeight - tierWeights[0] - tierWeights[1]; - const ultraThreshold = - totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2]; + const ultraThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2]; let tier: MysteryEncounterTier | null = tierValue > commonThreshold ? MysteryEncounterTier.COMMON @@ -4363,29 +3897,22 @@ export default class BattleScene extends SceneBase { let availableEncounters: MysteryEncounter[] = []; const previousEncounter = this.mysteryEncounterSaveData.encounteredEvents.length > 0 - ? this.mysteryEncounterSaveData.encounteredEvents[ - this.mysteryEncounterSaveData.encounteredEvents.length - 1 - ].type + ? this.mysteryEncounterSaveData.encounteredEvents[this.mysteryEncounterSaveData.encounteredEvents.length - 1] + .type : null; - const disabledEncounters = - this.eventManager.getEventMysteryEncountersDisabled(); + const disabledEncounters = this.eventManager.getEventMysteryEncountersDisabled(); const biomeMysteryEncounters = - mysteryEncountersByBiome - .get(this.arena.biomeType) - ?.filter((enc) => !disabledEncounters.includes(enc)) ?? []; + mysteryEncountersByBiome.get(this.arena.biomeType)?.filter(enc => !disabledEncounters.includes(enc)) ?? []; // If no valid encounters exist at tier, checks next tier down, continuing until there are some encounters available while (availableEncounters.length === 0 && tier !== null) { availableEncounters = biomeMysteryEncounters - .filter((encounterType) => { + .filter(encounterType => { const encounterCandidate = allMysteryEncounters[encounterType]; if (!encounterCandidate) { return false; } if ( - this.eventManager.getMysteryEncounterTierForEvent( - encounterType, - encounterCandidate.encounterTier, - ) !== tier + this.eventManager.getMysteryEncounterTierForEvent(encounterType, encounterCandidate.encounterTier) !== tier ) { return false; } @@ -4398,14 +3925,11 @@ export default class BattleScene extends SceneBase { return false; } if (this.gameMode.modeId === GameModes.CHALLENGE) { - const disallowedChallenges = - encounterCandidate.disallowedChallenges; + const disallowedChallenges = encounterCandidate.disallowedChallenges; if ( disallowedChallenges && disallowedChallenges.length > 0 && - this.gameMode.challenges.some((challenge) => - disallowedChallenges.includes(challenge.id), - ) + this.gameMode.challenges.some(challenge => disallowedChallenges.includes(challenge.id)) ) { return false; } @@ -4413,25 +3937,21 @@ export default class BattleScene extends SceneBase { if (!encounterCandidate.meetsRequirements()) { return false; } - if ( - previousEncounter !== null && - encounterType === previousEncounter - ) { + if (previousEncounter !== null && encounterType === previousEncounter) { return false; } if ( this.mysteryEncounterSaveData.encounteredEvents.length > 0 && encounterCandidate.maxAllowedEncounters && encounterCandidate.maxAllowedEncounters > 0 && - this.mysteryEncounterSaveData.encounteredEvents.filter( - (e) => e.type === encounterType, - ).length >= encounterCandidate.maxAllowedEncounters + this.mysteryEncounterSaveData.encounteredEvents.filter(e => e.type === encounterType).length >= + encounterCandidate.maxAllowedEncounters ) { return false; } return true; }) - .map((m) => allMysteryEncounters[m]); + .map(m => allMysteryEncounters[m]); // Decrement tier if (tier === MysteryEncounterTier.ROGUE) { tier = MysteryEncounterTier.ULTRA; @@ -4446,13 +3966,10 @@ export default class BattleScene extends SceneBase { // If absolutely no encounters are available, spawn 0th encounter if (availableEncounters.length === 0) { - console.log( - "No Mystery Encounters found, falling back to Mysterious Challengers.", - ); + console.log("No Mystery Encounters found, falling back to Mysterious Challengers."); return allMysteryEncounters[MysteryEncounterType.MYSTERIOUS_CHALLENGERS]; } - encounter = - availableEncounters[Utils.randSeedInt(availableEncounters.length)]; + encounter = availableEncounters[Utils.randSeedInt(availableEncounters.length)]; // New encounter object to not dirty flags encounter = new MysteryEncounter(encounter); encounter.populateDialogueTokensFromRequirements(); diff --git a/src/battle.ts b/src/battle.ts index 242954a3729..5ada921bf5a 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -50,7 +50,7 @@ export enum BattleType { WILD, TRAINER, CLEAR, - MYSTERY_ENCOUNTER + MYSTERY_ENCOUNTER, } export enum BattlerIndex { @@ -58,25 +58,25 @@ export enum BattlerIndex { PLAYER, PLAYER_2, ENEMY, - ENEMY_2 + ENEMY_2, } export interface TurnCommand { - command: Command; - cursor?: number; - move?: TurnMove; - targets?: BattlerIndex[]; - skip?: boolean; - args?: any[]; + command: Command; + cursor?: number; + move?: TurnMove; + targets?: BattlerIndex[]; + skip?: boolean; + args?: any[]; } export interface FaintLogEntry { - pokemon: Pokemon, - turn: number + pokemon: Pokemon; + turn: number; } interface TurnCommands { - [key: number]: TurnCommand | null + [key: number]: TurnCommand | null; } export default class Battle { @@ -89,19 +89,19 @@ export default class Battle { public enemyParty: EnemyPokemon[] = []; public seenEnemyPartyMemberIds: Set = new Set(); public double: boolean; - public started: boolean = false; - public enemySwitchCounter: number = 0; - public turn: number = 0; + public started = false; + public enemySwitchCounter = 0; + public turn = 0; public preTurnCommands: TurnCommands; public turnCommands: TurnCommands; public playerParticipantIds: Set = new Set(); - public battleScore: number = 0; + public battleScore = 0; public postBattleLoot: PokemonHeldItemModifier[] = []; - public escapeAttempts: number = 0; + public escapeAttempts = 0; public lastMove: Moves; public battleSeed: string = Utils.randomString(16, true); private battleSeedState: string | null = null; - public moneyScattered: number = 0; + public moneyScattered = 0; /** Primarily for double battles, keeps track of last enemy and player pokemon that triggered its ability or used a move */ public lastEnemyInvolved: number; public lastPlayerInvolved: number; @@ -111,7 +111,7 @@ export default class Battle { * This is saved here since we encounter a new enemy every wave. * {@linkcode globalScene.arena.playerFaints} is the corresponding faint counter for the player and needs to be save across waves (reset every arena encounter). */ - public enemyFaints: number = 0; + public enemyFaints = 0; public playerFaintsHistory: FaintLogEntry[] = []; public enemyFaintsHistory: FaintLogEntry[] = []; @@ -119,17 +119,18 @@ export default class Battle { /** If the current battle is a Mystery Encounter, this will always be defined */ public mysteryEncounter?: MysteryEncounter; - private rngCounter: number = 0; + private rngCounter = 0; - constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double: boolean = false) { + constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double = false) { this.gameMode = gameMode; this.waveIndex = waveIndex; this.battleType = battleType; this.trainer = trainer ?? null; this.initBattleSpec(); - this.enemyLevels = battleType !== BattleType.TRAINER - ? new Array(double ? 2 : 1).fill(null).map(() => this.getLevelForWave()) - : trainer?.getPartyLevels(this.waveIndex); + this.enemyLevels = + battleType !== BattleType.TRAINER + ? new Array(double ? 2 : 1).fill(null).map(() => this.getLevelForWave()) + : trainer?.getPartyLevels(this.waveIndex); this.double = double; } @@ -180,8 +181,8 @@ export default class Battle { incrementTurn(): void { this.turn++; - this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ])); - this.preTurnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [ bt, null ])); + this.turnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [bt, null])); + this.preTurnCommands = Object.fromEntries(Utils.getEnumValues(BattlerIndex).map(bt => [bt, null])); this.battleSeedState = null; } @@ -194,12 +195,19 @@ export default class Battle { } addPostBattleLoot(enemyPokemon: EnemyPokemon): void { - this.postBattleLoot.push(...globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.isTransferable, false).map(i => { - const ret = i as PokemonHeldItemModifier; - //@ts-ignore - this is awful to fix/change - ret.pokemonId = null; - return ret; - })); + this.postBattleLoot.push( + ...globalScene + .findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.isTransferable, + false, + ) + .map(i => { + const ret = i as PokemonHeldItemModifier; + //@ts-ignore - this is awful to fix/change + ret.pokemonId = null; + return ret; + }), + ); } pickUpScatteredMoney(): void { @@ -214,7 +222,9 @@ export default class Battle { const userLocale = navigator.language || "en-US"; const formattedMoneyAmount = moneyAmount.value.toLocaleString(userLocale); - const message = i18next.t("battle:moneyPickedUp", { moneyAmount: formattedMoneyAmount }); + const message = i18next.t("battle:moneyPickedUp", { + moneyAmount: formattedMoneyAmount, + }); globalScene.queueMessage(message, undefined, true); globalScene.currentBattle.moneyScattered = 0; @@ -227,13 +237,17 @@ export default class Battle { } for (const p of globalScene.getEnemyParty()) { if (p.isBoss()) { - partyMemberTurnMultiplier *= (p.bossSegments / 1.5) / globalScene.getEnemyParty().length; + partyMemberTurnMultiplier *= p.bossSegments / 1.5 / globalScene.getEnemyParty().length; } } - const turnMultiplier = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn")(1 - Math.min(this.turn - 2, 10 * partyMemberTurnMultiplier) / (10 * partyMemberTurnMultiplier)); + const turnMultiplier = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn")( + 1 - Math.min(this.turn - 2, 10 * partyMemberTurnMultiplier) / (10 * partyMemberTurnMultiplier), + ); const finalBattleScore = Math.ceil(this.battleScore * turnMultiplier); globalScene.score += finalBattleScore; - console.log(`Battle Score: ${finalBattleScore} (${this.turn - 1} Turns x${Math.floor(turnMultiplier * 100) / 100})`); + console.log( + `Battle Score: ${finalBattleScore} (${this.turn - 1} Turns x${Math.floor(turnMultiplier * 100) / 100})`, + ); console.log(`Total Score: ${globalScene.score}`); globalScene.updateScoreText(); } @@ -243,16 +257,20 @@ export default class Battle { // Music is overridden for MEs during ME onInit() // Should not use any BGM overrides before swapping from DEFAULT mode return null; - } else if (this.battleType === BattleType.TRAINER || this.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) { + } + if ( + this.battleType === BattleType.TRAINER || + this.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE + ) { if (!this.started && this.trainer?.config.encounterBgm && this.trainer?.getEncounterMessages()?.length) { return `encounter_${this.trainer?.getEncounterBgm()}`; } if (globalScene.musicPreference === MusicPreference.GENFIVE) { return this.trainer?.getBattleBgm() ?? null; - } else { - return this.trainer?.getMixedBattleBgm() ?? null; } - } else if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS) { + return this.trainer?.getMixedBattleBgm() ?? null; + } + if (this.gameMode.isClassic && this.waveIndex > 195 && this.battleSpec !== BattleSpec.FINAL_BOSS) { return "end_summit"; } const wildOpponents = globalScene.getEnemyParty(); @@ -281,7 +299,8 @@ export default class Battle { } return "battle_legendary_unova"; } - } else if (globalScene.musicPreference === MusicPreference.ALLGENS) { + } + if (globalScene.musicPreference === MusicPreference.ALLGENS) { switch (pokemon.species.speciesId) { case Species.ARTICUNO: case Species.ZAPDOS: @@ -434,7 +453,7 @@ export default class Battle { * @param min The minimum integer to pick, default `0` * @returns A random integer between {@linkcode min} and ({@linkcode min} + {@linkcode range} - 1) */ - randSeedInt(range: number, min: number = 0): number { + randSeedInt(range: number, min = 0): number { if (range <= 1) { return min; } @@ -444,7 +463,7 @@ export default class Battle { if (this.battleSeedState) { Phaser.Math.RND.state(this.battleSeedState); } else { - Phaser.Math.RND.sow([ Utils.shiftCharCodes(this.battleSeed, this.turn << 6) ]); + Phaser.Math.RND.sow([Utils.shiftCharCodes(this.battleSeed, this.turn << 6)]); console.log("Battle Seed:", this.battleSeed); } globalScene.rngCounter = this.rngCounter++; @@ -467,7 +486,13 @@ export default class Battle { export class FixedBattle extends Battle { constructor(waveIndex: number, config: FixedBattleConfig) { - super(globalScene.gameMode, waveIndex, config.battleType, config.battleType === BattleType.TRAINER ? config.getTrainer() : undefined, config.double); + super( + globalScene.gameMode, + waveIndex, + config.battleType, + config.battleType === BattleType.TRAINER ? config.getTrainer() : undefined, + config.double, + ); if (config.getEnemyParty) { this.enemyParty = config.getEnemyParty(); } @@ -516,7 +541,6 @@ export class FixedBattleConfig { } } - /** * Helper function to generate a random trainer for evil team trainers and the elite 4/champion * @param trainerPool The TrainerType or list of TrainerTypes that can possibly be generated @@ -524,31 +548,44 @@ export class FixedBattleConfig { * @param seedOffset the seed offset to use for the random generation of the trainer * @returns the generated trainer */ -export function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[], randomGender: boolean = false, seedOffset: number = 0): GetTrainerFunc { +export function getRandomTrainerFunc( + trainerPool: (TrainerType | TrainerType[])[], + randomGender = false, + seedOffset = 0, +): GetTrainerFunc { return () => { const rand = Utils.randSeedInt(trainerPool.length); const trainerTypes: TrainerType[] = []; globalScene.executeWithSeedOffset(() => { for (const trainerPoolEntry of trainerPool) { - const trainerType = Array.isArray(trainerPoolEntry) - ? Utils.randSeedItem(trainerPoolEntry) - : trainerPoolEntry; + const trainerType = Array.isArray(trainerPoolEntry) ? Utils.randSeedItem(trainerPoolEntry) : trainerPoolEntry; trainerTypes.push(trainerType); } }, seedOffset); let trainerGender = TrainerVariant.DEFAULT; if (randomGender) { - trainerGender = (Utils.randInt(2) === 0) ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT; + trainerGender = Utils.randInt(2) === 0 ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT; } /* 1/3 chance for evil team grunts to be double battles */ - const evilTeamGrunts = [ TrainerType.ROCKET_GRUNT, TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT, TrainerType.GALACTIC_GRUNT, TrainerType.PLASMA_GRUNT, TrainerType.FLARE_GRUNT, TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT, TrainerType.MACRO_GRUNT, TrainerType.STAR_GRUNT ]; + const evilTeamGrunts = [ + TrainerType.ROCKET_GRUNT, + TrainerType.MAGMA_GRUNT, + TrainerType.AQUA_GRUNT, + TrainerType.GALACTIC_GRUNT, + TrainerType.PLASMA_GRUNT, + TrainerType.FLARE_GRUNT, + TrainerType.AETHER_GRUNT, + TrainerType.SKULL_GRUNT, + TrainerType.MACRO_GRUNT, + TrainerType.STAR_GRUNT, + ]; const isEvilTeamGrunt = evilTeamGrunts.includes(trainerTypes[rand]); if (trainerConfigs[trainerTypes[rand]].hasDouble && isEvilTeamGrunt) { - return new Trainer(trainerTypes[rand], (Utils.randInt(3) === 0) ? TrainerVariant.DOUBLE : trainerGender); + return new Trainer(trainerTypes[rand], Utils.randInt(3) === 0 ? TrainerVariant.DOUBLE : trainerGender); } return new Trainer(trainerTypes[rand], trainerGender); @@ -556,7 +593,7 @@ export function getRandomTrainerFunc(trainerPool: (TrainerType | TrainerType[])[ } export interface FixedBattleConfigs { - [key: number]: FixedBattleConfig + [key: number]: FixedBattleConfig; } /** * Youngster/Lass on 5 @@ -568,51 +605,355 @@ export interface FixedBattleConfigs { * Champion on 190 */ export const classicFixedBattles: FixedBattleConfigs = { - [ClassicFixedBossWaves.TOWN_YOUNGSTER]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.YOUNGSTER, Utils.randSeedInt(2) ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)), - [ClassicFixedBossWaves.RIVAL_1]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)), - [ClassicFixedBossWaves.RIVAL_2]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL_2, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.EVIL_GRUNT_1]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_GRUNT, TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT, TrainerType.GALACTIC_GRUNT, TrainerType.PLASMA_GRUNT, TrainerType.FLARE_GRUNT, TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT, TrainerType.MACRO_GRUNT, TrainerType.STAR_GRUNT ], true)), - [ClassicFixedBossWaves.RIVAL_3]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL_3, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.EVIL_GRUNT_2]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_GRUNT, TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT, TrainerType.GALACTIC_GRUNT, TrainerType.PLASMA_GRUNT, TrainerType.FLARE_GRUNT, TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT, TrainerType.MACRO_GRUNT, TrainerType.STAR_GRUNT ], true)), - [ClassicFixedBossWaves.EVIL_GRUNT_3]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_GRUNT, TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT, TrainerType.GALACTIC_GRUNT, TrainerType.PLASMA_GRUNT, TrainerType.FLARE_GRUNT, TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT, TrainerType.MACRO_GRUNT, TrainerType.STAR_GRUNT ], true)), - [ClassicFixedBossWaves.EVIL_ADMIN_1]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([[ TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL ], [ TrainerType.TABITHA, TrainerType.COURTNEY ], [ TrainerType.MATT, TrainerType.SHELLY ], [ TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN ], [ TrainerType.ZINZOLIN, TrainerType.COLRESS ], [ TrainerType.XEROSIC, TrainerType.BRYONY ], TrainerType.FABA, TrainerType.PLUMERIA, TrainerType.OLEANA, [ TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI ]], true)), - [ClassicFixedBossWaves.RIVAL_4]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL_4, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.EVIL_GRUNT_4]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_GRUNT, TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT, TrainerType.GALACTIC_GRUNT, TrainerType.PLASMA_GRUNT, TrainerType.FLARE_GRUNT, TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT, TrainerType.MACRO_GRUNT, TrainerType.STAR_GRUNT ], true)), - [ClassicFixedBossWaves.EVIL_ADMIN_2]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([[ TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL ], [ TrainerType.TABITHA, TrainerType.COURTNEY ], [ TrainerType.MATT, TrainerType.SHELLY ], [ TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN ], [ TrainerType.ZINZOLIN, TrainerType.COLRESS ], [ TrainerType.XEROSIC, TrainerType.BRYONY ], TrainerType.FABA, TrainerType.PLUMERIA, TrainerType.OLEANA, [ TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI ]], true, 1)), - [ClassicFixedBossWaves.EVIL_BOSS_1]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_BOSS_GIOVANNI_1, TrainerType.MAXIE, TrainerType.ARCHIE, TrainerType.CYRUS, TrainerType.GHETSIS, TrainerType.LYSANDRE, TrainerType.LUSAMINE, TrainerType.GUZMA, TrainerType.ROSE, TrainerType.PENNY ])) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.RIVAL_5]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL_5, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.EVIL_BOSS_2]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.ROCKET_BOSS_GIOVANNI_2, TrainerType.MAXIE_2, TrainerType.ARCHIE_2, TrainerType.CYRUS_2, TrainerType.GHETSIS_2, TrainerType.LYSANDRE_2, TrainerType.LUSAMINE_2, TrainerType.GUZMA_2, TrainerType.ROSE_2, TrainerType.PENNY_2 ])) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }), - [ClassicFixedBossWaves.ELITE_FOUR_1]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.LORELEI, TrainerType.WILL, TrainerType.SIDNEY, TrainerType.AARON, TrainerType.SHAUNTAL, TrainerType.MALVA, [ TrainerType.HALA, TrainerType.MOLAYNE ], TrainerType.MARNIE_ELITE, TrainerType.RIKA, TrainerType.CRISPIN ])), - [ClassicFixedBossWaves.ELITE_FOUR_2]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.BRUNO, TrainerType.KOGA, TrainerType.PHOEBE, TrainerType.BERTHA, TrainerType.MARSHAL, TrainerType.SIEBOLD, TrainerType.OLIVIA, TrainerType.NESSA_ELITE, TrainerType.POPPY, TrainerType.AMARYS ])), - [ClassicFixedBossWaves.ELITE_FOUR_3]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.AGATHA, TrainerType.BRUNO, TrainerType.GLACIA, TrainerType.FLINT, TrainerType.GRIMSLEY, TrainerType.WIKSTROM, TrainerType.ACEROLA, [ TrainerType.BEA_ELITE, TrainerType.ALLISTER_ELITE ], TrainerType.LARRY_ELITE, TrainerType.LACEY ])), - [ClassicFixedBossWaves.ELITE_FOUR_4]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.LANCE, TrainerType.KAREN, TrainerType.DRAKE, TrainerType.LUCIAN, TrainerType.CAITLIN, TrainerType.DRASNA, TrainerType.KAHILI, TrainerType.RAIHAN_ELITE, TrainerType.HASSEL, TrainerType.DRAYTON ])), - [ClassicFixedBossWaves.CHAMPION]: new FixedBattleConfig().setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) - .setGetTrainerFunc(getRandomTrainerFunc([ TrainerType.BLUE, [ TrainerType.RED, TrainerType.LANCE_CHAMPION ], [ TrainerType.STEVEN, TrainerType.WALLACE ], TrainerType.CYNTHIA, [ TrainerType.ALDER, TrainerType.IRIS ], TrainerType.DIANTHA, [ TrainerType.KUKUI, TrainerType.HAU ], [ TrainerType.LEON, TrainerType.MUSTARD ], [ TrainerType.GEETA, TrainerType.NEMONA ], TrainerType.KIERAN ])), - [ClassicFixedBossWaves.RIVAL_6]: new FixedBattleConfig().setBattleType(BattleType.TRAINER) - .setGetTrainerFunc(() => new Trainer(TrainerType.RIVAL_6, globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], allowLuckUpgrades: false }) + [ClassicFixedBossWaves.TOWN_YOUNGSTER]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => new Trainer(TrainerType.YOUNGSTER, Utils.randSeedInt(2) ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT), + ), + [ClassicFixedBossWaves.RIVAL_1]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ), + [ClassicFixedBossWaves.RIVAL_2]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL_2, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.EVIL_GRUNT_1]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + TrainerType.ROCKET_GRUNT, + TrainerType.MAGMA_GRUNT, + TrainerType.AQUA_GRUNT, + TrainerType.GALACTIC_GRUNT, + TrainerType.PLASMA_GRUNT, + TrainerType.FLARE_GRUNT, + TrainerType.AETHER_GRUNT, + TrainerType.SKULL_GRUNT, + TrainerType.MACRO_GRUNT, + TrainerType.STAR_GRUNT, + ], + true, + ), + ), + [ClassicFixedBossWaves.RIVAL_3]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL_3, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.EVIL_GRUNT_2]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + TrainerType.ROCKET_GRUNT, + TrainerType.MAGMA_GRUNT, + TrainerType.AQUA_GRUNT, + TrainerType.GALACTIC_GRUNT, + TrainerType.PLASMA_GRUNT, + TrainerType.FLARE_GRUNT, + TrainerType.AETHER_GRUNT, + TrainerType.SKULL_GRUNT, + TrainerType.MACRO_GRUNT, + TrainerType.STAR_GRUNT, + ], + true, + ), + ), + [ClassicFixedBossWaves.EVIL_GRUNT_3]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + TrainerType.ROCKET_GRUNT, + TrainerType.MAGMA_GRUNT, + TrainerType.AQUA_GRUNT, + TrainerType.GALACTIC_GRUNT, + TrainerType.PLASMA_GRUNT, + TrainerType.FLARE_GRUNT, + TrainerType.AETHER_GRUNT, + TrainerType.SKULL_GRUNT, + TrainerType.MACRO_GRUNT, + TrainerType.STAR_GRUNT, + ], + true, + ), + ), + [ClassicFixedBossWaves.EVIL_ADMIN_1]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + [TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL], + [TrainerType.TABITHA, TrainerType.COURTNEY], + [TrainerType.MATT, TrainerType.SHELLY], + [TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN], + [TrainerType.ZINZOLIN, TrainerType.COLRESS], + [TrainerType.XEROSIC, TrainerType.BRYONY], + TrainerType.FABA, + TrainerType.PLUMERIA, + TrainerType.OLEANA, + [TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI], + ], + true, + ), + ), + [ClassicFixedBossWaves.RIVAL_4]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL_4, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.EVIL_GRUNT_4]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + TrainerType.ROCKET_GRUNT, + TrainerType.MAGMA_GRUNT, + TrainerType.AQUA_GRUNT, + TrainerType.GALACTIC_GRUNT, + TrainerType.PLASMA_GRUNT, + TrainerType.FLARE_GRUNT, + TrainerType.AETHER_GRUNT, + TrainerType.SKULL_GRUNT, + TrainerType.MACRO_GRUNT, + TrainerType.STAR_GRUNT, + ], + true, + ), + ), + [ClassicFixedBossWaves.EVIL_ADMIN_2]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc( + [ + [TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL], + [TrainerType.TABITHA, TrainerType.COURTNEY], + [TrainerType.MATT, TrainerType.SHELLY], + [TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN], + [TrainerType.ZINZOLIN, TrainerType.COLRESS], + [TrainerType.XEROSIC, TrainerType.BRYONY], + TrainerType.FABA, + TrainerType.PLUMERIA, + TrainerType.OLEANA, + [TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI], + ], + true, + 1, + ), + ), + [ClassicFixedBossWaves.EVIL_BOSS_1]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.ROCKET_BOSS_GIOVANNI_1, + TrainerType.MAXIE, + TrainerType.ARCHIE, + TrainerType.CYRUS, + TrainerType.GHETSIS, + TrainerType.LYSANDRE, + TrainerType.LUSAMINE, + TrainerType.GUZMA, + TrainerType.ROSE, + TrainerType.PENNY, + ]), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.RIVAL_5]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL_5, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.EVIL_BOSS_2]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.ROCKET_BOSS_GIOVANNI_2, + TrainerType.MAXIE_2, + TrainerType.ARCHIE_2, + TrainerType.CYRUS_2, + TrainerType.GHETSIS_2, + TrainerType.LYSANDRE_2, + TrainerType.LUSAMINE_2, + TrainerType.GUZMA_2, + TrainerType.ROSE_2, + TrainerType.PENNY_2, + ]), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ], + allowLuckUpgrades: false, + }), + [ClassicFixedBossWaves.ELITE_FOUR_1]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.LORELEI, + TrainerType.WILL, + TrainerType.SIDNEY, + TrainerType.AARON, + TrainerType.SHAUNTAL, + TrainerType.MALVA, + [TrainerType.HALA, TrainerType.MOLAYNE], + TrainerType.MARNIE_ELITE, + TrainerType.RIKA, + TrainerType.CRISPIN, + ]), + ), + [ClassicFixedBossWaves.ELITE_FOUR_2]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.BRUNO, + TrainerType.KOGA, + TrainerType.PHOEBE, + TrainerType.BERTHA, + TrainerType.MARSHAL, + TrainerType.SIEBOLD, + TrainerType.OLIVIA, + TrainerType.NESSA_ELITE, + TrainerType.POPPY, + TrainerType.AMARYS, + ]), + ), + [ClassicFixedBossWaves.ELITE_FOUR_3]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.AGATHA, + TrainerType.BRUNO, + TrainerType.GLACIA, + TrainerType.FLINT, + TrainerType.GRIMSLEY, + TrainerType.WIKSTROM, + TrainerType.ACEROLA, + [TrainerType.BEA_ELITE, TrainerType.ALLISTER_ELITE], + TrainerType.LARRY_ELITE, + TrainerType.LACEY, + ]), + ), + [ClassicFixedBossWaves.ELITE_FOUR_4]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.LANCE, + TrainerType.KAREN, + TrainerType.DRAKE, + TrainerType.LUCIAN, + TrainerType.CAITLIN, + TrainerType.DRASNA, + TrainerType.KAHILI, + TrainerType.RAIHAN_ELITE, + TrainerType.HASSEL, + TrainerType.DRAYTON, + ]), + ), + [ClassicFixedBossWaves.CHAMPION]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.ELITE_FOUR_1) + .setGetTrainerFunc( + getRandomTrainerFunc([ + TrainerType.BLUE, + [TrainerType.RED, TrainerType.LANCE_CHAMPION], + [TrainerType.STEVEN, TrainerType.WALLACE], + TrainerType.CYNTHIA, + [TrainerType.ALDER, TrainerType.IRIS], + TrainerType.DIANTHA, + [TrainerType.KUKUI, TrainerType.HAU], + [TrainerType.LEON, TrainerType.MUSTARD], + [TrainerType.GEETA, TrainerType.NEMONA], + TrainerType.KIERAN, + ]), + ), + [ClassicFixedBossWaves.RIVAL_6]: new FixedBattleConfig() + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc( + () => + new Trainer( + TrainerType.RIVAL_6, + globalScene.gameData.gender === PlayerGender.MALE ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + ), + ) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.GREAT, + ModifierTier.GREAT, + ], + allowLuckUpgrades: false, + }), }; diff --git a/src/configs/inputs/cfg_keyboard_qwerty.ts b/src/configs/inputs/cfg_keyboard_qwerty.ts index c1b00a833c0..2ad04ab418d 100644 --- a/src/configs/inputs/cfg_keyboard_qwerty.ts +++ b/src/configs/inputs/cfg_keyboard_qwerty.ts @@ -77,7 +77,7 @@ const cfg_keyboard_qwerty = { KEY_RIGHT_BRACKET: Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET, KEY_SEMICOLON: Phaser.Input.Keyboard.KeyCodes.SEMICOLON, KEY_BACKSPACE: Phaser.Input.Keyboard.KeyCodes.BACKSPACE, - KEY_ALT: Phaser.Input.Keyboard.KeyCodes.ALT + KEY_ALT: Phaser.Input.Keyboard.KeyCodes.ALT, }, icons: { KEY_A: "A.png", @@ -131,7 +131,6 @@ const cfg_keyboard_qwerty = { KEY_F11: "F11.png", KEY_F12: "F12.png", - KEY_PAGE_DOWN: "PAGE_DOWN.png", KEY_PAGE_UP: "PAGE_UP.png", @@ -163,7 +162,7 @@ const cfg_keyboard_qwerty = { KEY_SEMICOLON: "SEMICOLON.png", KEY_BACKSPACE: "BACK.png", - KEY_ALT: "ALT.png" + KEY_ALT: "ALT.png", }, settings: { [SettingKeyboard.Button_Up]: Button.UP, @@ -274,7 +273,7 @@ const cfg_keyboard_qwerty = { KEY_LEFT_BRACKET: -1, KEY_RIGHT_BRACKET: -1, KEY_SEMICOLON: -1, - KEY_ALT: -1 + KEY_ALT: -1, }, blacklist: [ "KEY_ENTER", @@ -287,7 +286,7 @@ const cfg_keyboard_qwerty = { "KEY_ARROW_RIGHT", "KEY_DEL", "KEY_HOME", - ] + ], }; export default cfg_keyboard_qwerty; diff --git a/src/configs/inputs/configHandler.ts b/src/configs/inputs/configHandler.ts index 50be692cbc3..b896f303cb3 100644 --- a/src/configs/inputs/configHandler.ts +++ b/src/configs/inputs/configHandler.ts @@ -93,7 +93,7 @@ export function getIconWithSettingName(config, settingName) { } export function getIconForLatestInput(configs, source, devices, settingName) { - let config; + let config: any; // TODO: refine type if (source === "gamepad") { config = configs[devices[Device.GAMEPAD]]; } else { @@ -102,7 +102,7 @@ export function getIconForLatestInput(configs, source, devices, settingName) { const icon = getIconWithSettingName(config, settingName); if (!icon) { const isAlt = settingName.includes("ALT_"); - let altSettingName; + let altSettingName: string; if (isAlt) { altSettingName = settingName.split("ALT_").splice(1)[0]; } else { @@ -115,7 +115,10 @@ export function getIconForLatestInput(configs, source, devices, settingName) { export function assign(config, settingNameTarget, keycode): boolean { // first, we need to check if this keycode is already used on another settingName - if (!canIAssignThisKey(config, getKeyWithKeycode(config, keycode)) || !canIOverrideThisSetting(config, settingNameTarget)) { + if ( + !canIAssignThisKey(config, getKeyWithKeycode(config, keycode)) || + !canIOverrideThisSetting(config, settingNameTarget) + ) { return false; } const previousSettingName = getSettingNameWithKeycode(config, keycode); diff --git a/src/configs/inputs/pad_dualshock.ts b/src/configs/inputs/pad_dualshock.ts index 265b39fdad5..51af1b2defd 100644 --- a/src/configs/inputs/pad_dualshock.ts +++ b/src/configs/inputs/pad_dualshock.ts @@ -24,7 +24,7 @@ const pad_dualshock = { LC_S: 13, LC_W: 14, LC_E: 15, - TOUCH: 17 + TOUCH: 17, }, icons: { RC_S: "CROSS.png", @@ -43,7 +43,7 @@ const pad_dualshock = { LC_S: "DOWN.png", LC_W: "LEFT.png", LC_E: "RIGHT.png", - TOUCH: "TOUCH.png" + TOUCH: "TOUCH.png", }, settings: { [SettingGamepad.Button_Up]: Button.UP, @@ -56,13 +56,13 @@ const pad_dualshock = { [SettingGamepad.Button_Cycle_Tera]: Button.CYCLE_TERA, [SettingGamepad.Button_Menu]: Button.MENU, [SettingGamepad.Button_Stats]: Button.STATS, - [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, + [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, [SettingGamepad.Button_Cycle_Shiny]: Button.CYCLE_SHINY, [SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER, [SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY, [SettingGamepad.Button_Speed_Up]: Button.SPEED_UP, [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN, - [SettingGamepad.Button_Submit]: Button.SUBMIT + [SettingGamepad.Button_Submit]: Button.SUBMIT, }, default: { LC_N: SettingGamepad.Button_Up, diff --git a/src/configs/inputs/pad_generic.ts b/src/configs/inputs/pad_generic.ts index cd91fcd8b17..e47b7ce1ace 100644 --- a/src/configs/inputs/pad_generic.ts +++ b/src/configs/inputs/pad_generic.ts @@ -23,7 +23,7 @@ const pad_generic = { LC_N: 12, LC_S: 13, LC_W: 14, - LC_E: 15 + LC_E: 15, }, icons: { RC_S: "XB_Letter_A_OL.png", @@ -54,12 +54,12 @@ const pad_generic = { [SettingGamepad.Button_Cycle_Tera]: Button.CYCLE_TERA, [SettingGamepad.Button_Menu]: Button.MENU, [SettingGamepad.Button_Stats]: Button.STATS, - [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, + [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, [SettingGamepad.Button_Cycle_Shiny]: Button.CYCLE_SHINY, [SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER, [SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY, [SettingGamepad.Button_Speed_Up]: Button.SPEED_UP, - [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN + [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN, }, default: { LC_N: SettingGamepad.Button_Up, @@ -77,14 +77,9 @@ const pad_generic = { LT: SettingGamepad.Button_Cycle_Gender, RT: SettingGamepad.Button_Cycle_Ability, LS: SettingGamepad.Button_Speed_Up, - RS: SettingGamepad.Button_Slow_Down + RS: SettingGamepad.Button_Slow_Down, }, - blacklist: [ - "LC_N", - "LC_S", - "LC_W", - "LC_E", - ] + blacklist: ["LC_N", "LC_S", "LC_W", "LC_E"], }; export default pad_generic; diff --git a/src/configs/inputs/pad_procon.ts b/src/configs/inputs/pad_procon.ts index a7ae5383fbe..61558c7365e 100644 --- a/src/configs/inputs/pad_procon.ts +++ b/src/configs/inputs/pad_procon.ts @@ -55,12 +55,12 @@ const pad_procon = { [SettingGamepad.Button_Cycle_Tera]: Button.CYCLE_TERA, [SettingGamepad.Button_Menu]: Button.MENU, [SettingGamepad.Button_Stats]: Button.STATS, - [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, + [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, [SettingGamepad.Button_Cycle_Shiny]: Button.CYCLE_SHINY, [SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER, [SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY, [SettingGamepad.Button_Speed_Up]: Button.SPEED_UP, - [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN + [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN, }, default: { LC_N: SettingGamepad.Button_Up, @@ -78,7 +78,7 @@ const pad_procon = { LT: SettingGamepad.Button_Cycle_Gender, RT: SettingGamepad.Button_Cycle_Ability, LS: SettingGamepad.Button_Speed_Up, - RS: SettingGamepad.Button_Slow_Down + RS: SettingGamepad.Button_Slow_Down, }, }; diff --git a/src/configs/inputs/pad_unlicensedSNES.ts b/src/configs/inputs/pad_unlicensedSNES.ts index fbde98b3fa2..d0c4f41c8f5 100644 --- a/src/configs/inputs/pad_unlicensedSNES.ts +++ b/src/configs/inputs/pad_unlicensedSNES.ts @@ -7,7 +7,7 @@ import { Button } from "#enums/buttons"; const pad_unlicensedSNES = { padID: "081f-e401", padType: "xbox", - deviceMapping : { + deviceMapping: { RC_S: 2, RC_E: 1, RC_W: 3, @@ -19,7 +19,7 @@ const pad_unlicensedSNES = { LC_N: 12, LC_S: 13, LC_W: 14, - LC_E: 15 + LC_E: 15, }, icons: { RC_S: "XB_Letter_A_OL.png", @@ -46,12 +46,12 @@ const pad_unlicensedSNES = { [SettingGamepad.Button_Cycle_Tera]: Button.CYCLE_TERA, [SettingGamepad.Button_Menu]: Button.MENU, [SettingGamepad.Button_Stats]: Button.STATS, - [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, + [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, [SettingGamepad.Button_Cycle_Shiny]: Button.CYCLE_SHINY, [SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER, [SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY, [SettingGamepad.Button_Speed_Up]: Button.SPEED_UP, - [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN + [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN, }, default: { LC_N: SettingGamepad.Button_Up, @@ -69,7 +69,7 @@ const pad_unlicensedSNES = { LT: -1, RT: -1, LS: -1, - RS: -1 + RS: -1, }, }; diff --git a/src/configs/inputs/pad_xbox360.ts b/src/configs/inputs/pad_xbox360.ts index 88fee731d1d..60cbd9ab181 100644 --- a/src/configs/inputs/pad_xbox360.ts +++ b/src/configs/inputs/pad_xbox360.ts @@ -23,7 +23,7 @@ const pad_xbox360 = { LC_N: 12, LC_S: 13, LC_W: 14, - LC_E: 15 + LC_E: 15, }, icons: { RC_S: "XB_Letter_A_OL.png", @@ -54,12 +54,12 @@ const pad_xbox360 = { [SettingGamepad.Button_Cycle_Tera]: Button.CYCLE_TERA, [SettingGamepad.Button_Menu]: Button.MENU, [SettingGamepad.Button_Stats]: Button.STATS, - [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, + [SettingGamepad.Button_Cycle_Form]: Button.CYCLE_FORM, [SettingGamepad.Button_Cycle_Shiny]: Button.CYCLE_SHINY, [SettingGamepad.Button_Cycle_Gender]: Button.CYCLE_GENDER, [SettingGamepad.Button_Cycle_Ability]: Button.CYCLE_ABILITY, [SettingGamepad.Button_Speed_Up]: Button.SPEED_UP, - [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN + [SettingGamepad.Button_Slow_Down]: Button.SLOW_DOWN, }, default: { LC_N: SettingGamepad.Button_Up, @@ -77,7 +77,7 @@ const pad_xbox360 = { LT: SettingGamepad.Button_Cycle_Gender, RT: SettingGamepad.Button_Cycle_Ability, LS: SettingGamepad.Button_Speed_Up, - RS: SettingGamepad.Button_Slow_Down + RS: SettingGamepad.Button_Slow_Down, }, }; diff --git a/src/data/ability.ts b/src/data/ability.ts index de3ec840805..0b4e5ddb2c4 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -159,7 +159,7 @@ export abstract class AbAttr { public showAbility: boolean; private extraCondition: AbAttrCondition; - constructor(showAbility: boolean = true) { + constructor(showAbility = true) { this.showAbility = showAbility; } @@ -775,7 +775,7 @@ export class PostDefendStatStageChangeAbAttr extends PostDefendAbAttr { private selfTarget: boolean; private allOthers: boolean; - constructor(condition: PokemonDefendCondition, stat: BattleStat, stages: number, selfTarget: boolean = true, allOthers: boolean = false) { + constructor(condition: PokemonDefendCondition, stat: BattleStat, stages: number, selfTarget = true, allOthers = false) { super(true); this.condition = condition; @@ -813,7 +813,7 @@ export class PostDefendHpGatedStatStageChangeAbAttr extends PostDefendAbAttr { private stages: number; private selfTarget: boolean; - constructor(condition: PokemonDefendCondition, hpGate: number, stats: BattleStat[], stages: number, selfTarget: boolean = true) { + constructor(condition: PokemonDefendCondition, hpGate: number, stats: BattleStat[], stages: number, selfTarget = true) { super(true); this.condition = condition; @@ -1320,7 +1320,7 @@ export class FieldMultiplyStatAbAttr extends AbAttr { private multiplier: number; private canStack: boolean; - constructor(stat: Stat, multiplier: number, canStack: boolean = false) { + constructor(stat: Stat, multiplier: number, canStack = false) { super(false); this.stat = stat; @@ -1510,7 +1510,7 @@ export class MovePowerBoostAbAttr extends VariableMovePowerAbAttr { private condition: PokemonAttackCondition; private powerMultiplier: number; - constructor(condition: PokemonAttackCondition, powerMultiplier: number, showAbility: boolean = true) { + constructor(condition: PokemonAttackCondition, powerMultiplier: number, showAbility = true) { super(showAbility); this.condition = condition; this.powerMultiplier = powerMultiplier; @@ -1555,7 +1555,7 @@ export class VariableMovePowerBoostAbAttr extends VariableMovePowerAbAttr { * @param mult A function which takes the user, target, and move, and returns the power multiplier. 1 means no multiplier. * @param {boolean} showAbility Whether to show the ability when it activates. */ - constructor(mult: (user: Pokemon, target: Pokemon, move: Move) => number, showAbility: boolean = true) { + constructor(mult: (user: Pokemon, target: Pokemon, move: Move) => number, showAbility = true) { super(showAbility); this.mult = mult; } @@ -1678,7 +1678,7 @@ export class PostAttackAbAttr extends AbAttr { private attackCondition: PokemonAttackCondition; /** The default attackCondition requires that the selected move is a damaging move */ - constructor(attackCondition: PokemonAttackCondition = (user, target, move) => (move.category !== MoveCategory.STATUS), showAbility: boolean = true) { + constructor(attackCondition: PokemonAttackCondition = (user, target, move) => (move.category !== MoveCategory.STATUS), showAbility = true) { super(showAbility); this.attackCondition = attackCondition; @@ -2151,7 +2151,7 @@ export class PostSummonAbAttr extends AbAttr { /** Should the ability activate when gained in battle? This will almost always be true */ private activateOnGain: boolean; - constructor(showAbility: boolean = true, activateOnGain: boolean = true) { + constructor(showAbility = true, activateOnGain = true) { super(showAbility); this.activateOnGain = activateOnGain; } @@ -2334,7 +2334,7 @@ export class PostSummonAllyHealAbAttr extends PostSummonAbAttr { private healRatio: number; private showAnim: boolean; - constructor(healRatio: number, showAnim: boolean = false) { + constructor(healRatio: number, showAnim = false) { super(); this.healRatio = healRatio || 4; @@ -3296,7 +3296,7 @@ export class MultCritAbAttr extends AbAttr { export class ConditionalCritAbAttr extends AbAttr { private condition: PokemonAttackCondition; - constructor(condition: PokemonAttackCondition, checkUser?: Boolean) { + constructor(condition: PokemonAttackCondition, checkUser?: boolean) { super(); this.condition = condition; @@ -3400,7 +3400,7 @@ export class IgnoreContactAbAttr extends AbAttr { } export class PreWeatherEffectAbAttr extends AbAttr { applyPreWeatherEffect( pokemon: Pokemon, - passive: Boolean, + passive: boolean, simulated: boolean, weather: Weather | null, cancelled: Utils.BooleanHolder, @@ -3837,7 +3837,7 @@ export class PostTurnResetStatusAbAttr extends PostTurnAbAttr { private allyTarget: boolean; private target: Pokemon; - constructor(allyTarget: boolean = false) { + constructor(allyTarget = false) { super(true); this.allyTarget = allyTarget; } @@ -4049,7 +4049,7 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { * @returns `true` if any opponents are sleeping */ override applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { - let hadEffect: boolean = false; + let hadEffect = false; for (const opp of pokemon.getOpponents()) { if ((opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) && !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) && !opp.switchOutStatus) { if (!simulated) { @@ -5150,9 +5150,9 @@ function applySingleAbAttrs( attrType: Constructor, applyFunc: AbAttrApplyFunc, args: any[], - gainedMidTurn: boolean = false, - simulated: boolean = false, - showAbilityInstant: boolean = false, + gainedMidTurn = false, + simulated = false, + showAbilityInstant = false, messages: string[] = [] ) { if (!pokemon?.canApplyAbility(passive) || (passive && (pokemon.getPassiveAbility().id === pokemon.getAbility().id))) { @@ -5362,7 +5362,7 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { private helper: ForceSwitchOutHelper = new ForceSwitchOutHelper(SwitchType.SWITCH); private hpRatio: number; - constructor(hpRatio: number = 0.5) { + constructor(hpRatio = 0.5) { super(); this.hpRatio = hpRatio; } @@ -5446,10 +5446,10 @@ function applyAbAttrsInternal( pokemon: Pokemon | null, applyFunc: AbAttrApplyFunc, args: any[], - showAbilityInstant: boolean = false, - simulated: boolean = false, + showAbilityInstant = false, + simulated = false, messages: string[] = [], - gainedMidTurn: boolean = false + gainedMidTurn = false ) { for (const passive of [ false, true ]) { if (pokemon) { @@ -5463,7 +5463,7 @@ export function applyAbAttrs( attrType: Constructor, pokemon: Pokemon, cancelled: Utils.BooleanHolder | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5479,7 +5479,7 @@ export function applyAbAttrs( export function applyPostBattleInitAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5498,7 +5498,7 @@ export function applyPreDefendAbAttrs( attacker: Pokemon, move: Move | null, cancelled: Utils.BooleanHolder | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5517,7 +5517,7 @@ export function applyPostDefendAbAttrs( attacker: Pokemon, move: Move, hitResult: HitResult | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5536,7 +5536,7 @@ export function applyPostMoveUsedAbAttrs( move: PokemonMove, source: Pokemon, targets: BattlerIndex[], - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5554,7 +5554,7 @@ export function applyStatMultiplierAbAttrs( pokemon: Pokemon, stat: BattleStat, statValue: Utils.NumberHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5569,7 +5569,7 @@ export function applyPostSetStatusAbAttrs( pokemon: Pokemon, effect: StatusEffect, sourcePokemon?: Pokemon | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5587,7 +5587,7 @@ export function applyPostDamageAbAttrs( pokemon: Pokemon, damage: number, passive: boolean, - simulated: boolean = false, + simulated = false, args: any[], source?: Pokemon, ): void { @@ -5616,7 +5616,7 @@ export function applyFieldStatMultiplierAbAttrs( statValue: Utils.NumberHolder, checkedPokemon: Pokemon, hasApplied: Utils.BooleanHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5633,7 +5633,7 @@ export function applyPreAttackAbAttrs( pokemon: Pokemon, defender: Pokemon | null, move: Move, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5652,7 +5652,7 @@ export function applyPostAttackAbAttrs( defender: Pokemon, move: Move, hitResult: HitResult | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5669,7 +5669,7 @@ export function applyPostKnockOutAbAttrs( attrType: Constructor, pokemon: Pokemon, knockedOut: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5685,7 +5685,7 @@ export function applyPostKnockOutAbAttrs( export function applyPostVictoryAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5701,7 +5701,7 @@ export function applyPostVictoryAbAttrs( export function applyPostSummonAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5717,7 +5717,7 @@ export function applyPostSummonAbAttrs( export function applyPreSwitchOutAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5733,7 +5733,7 @@ export function applyPreSwitchOutAbAttrs( export function applyPreLeaveFieldAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { return applyAbAttrsInternal( @@ -5752,7 +5752,7 @@ export function applyPreStatStageChangeAbAttrs( pokemon: Pokemon | null, stat: BattleStat, cancelled: Utils.BooleanHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5771,7 +5771,7 @@ export function applyPostStatStageChangeAbAttrs( stats: BattleStat[], stages: integer, selfTarget: boolean, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5789,7 +5789,7 @@ export function applyPreSetStatusAbAttrs( pokemon: Pokemon, effect: StatusEffect | undefined, cancelled: Utils.BooleanHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5807,7 +5807,7 @@ export function applyPreApplyBattlerTagAbAttrs( pokemon: Pokemon, tag: BattlerTag, cancelled: Utils.BooleanHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5825,7 +5825,7 @@ export function applyPreWeatherEffectAbAttrs( pokemon: Pokemon, weather: Weather | null, cancelled: Utils.BooleanHolder, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5841,7 +5841,7 @@ export function applyPreWeatherEffectAbAttrs( export function applyPostTurnAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5858,7 +5858,7 @@ export function applyPostWeatherChangeAbAttrs( attrType: Constructor, pokemon: Pokemon, weather: WeatherType, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5875,7 +5875,7 @@ export function applyPostWeatherLapseAbAttrs( attrType: Constructor, pokemon: Pokemon, weather: Weather | null, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5892,7 +5892,7 @@ export function applyPostTerrainChangeAbAttrs( attrType: Constructor, pokemon: Pokemon, terrain: TerrainType, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5911,7 +5911,7 @@ export function applyCheckTrappedAbAttrs( trapped: Utils.BooleanHolder, otherPokemon: Pokemon, messages: string[], - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5928,7 +5928,7 @@ export function applyCheckTrappedAbAttrs( export function applyPostBattleAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5947,7 +5947,7 @@ export function applyPostFaintAbAttrs( attacker?: Pokemon, move?: Move, hitResult?: HitResult, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5963,7 +5963,7 @@ export function applyPostFaintAbAttrs( export function applyPostItemLostAbAttrs( attrType: Constructor, pokemon: Pokemon, - simulated: boolean = false, + simulated = false, ...args: any[] ): void { applyAbAttrsInternal( @@ -5979,14 +5979,14 @@ export function applyPostItemLostAbAttrs( * * Ignores passives as they don't change and shouldn't be reapplied when main abilities change */ -export function applyOnGainAbAttrs(pokemon: Pokemon, passive: boolean = false, simulated: boolean = false, ...args: any[]): void { +export function applyOnGainAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { applySingleAbAttrs(pokemon, passive, PostSummonAbAttr, (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), args, true, simulated); } /** * Clears primal weather/neutralizing gas during the turn if {@linkcode pokemon}'s ability corresponds to one */ -export function applyOnLoseAbAttrs(pokemon: Pokemon, passive: boolean = false, simulated: boolean = false, ...args: any[]): void { +export function applyOnLoseAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { applySingleAbAttrs(pokemon, passive, PreLeaveFieldAbAttr, (attr, passive) => attr.applyPreLeaveField(pokemon, passive, simulated, [ ...args, true ]), args, true, simulated); } function queueShowAbility(pokemon: Pokemon, passive: boolean): void { diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 4e54c728f09..4219b9a3ba2 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -10,7 +10,15 @@ import type Pokemon from "#app/field/pokemon"; import { HitResult, PokemonMove } from "#app/field/pokemon"; import { StatusEffect } from "#enums/status-effect"; import type { BattlerIndex } from "#app/battle"; -import { BlockNonDirectDamageAbAttr, InfiltratorAbAttr, PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, ProtectStatAbAttr, applyAbAttrs, applyOnGainAbAttrs, applyOnLoseAbAttrs } from "#app/data/ability"; +import { + BlockNonDirectDamageAbAttr, + InfiltratorAbAttr, + PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, + ProtectStatAbAttr, + applyAbAttrs, + applyOnGainAbAttrs, + applyOnLoseAbAttrs, +} from "#app/data/ability"; import { Stat } from "#enums/stat"; import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims"; import i18next from "i18next"; @@ -27,7 +35,7 @@ import { CommonAnimPhase } from "#app/phases/common-anim-phase"; export enum ArenaTagSide { BOTH, PLAYER, - ENEMY + ENEMY, } export abstract class ArenaTag { @@ -36,31 +44,34 @@ export abstract class ArenaTag { public turnCount: number, public sourceMove?: Moves, public sourceId?: number, - public side: ArenaTagSide = ArenaTagSide.BOTH + public side: ArenaTagSide = ArenaTagSide.BOTH, ) {} - apply(arena: Arena, simulated: boolean, ...args: unknown[]): boolean { + apply(_arena: Arena, _simulated: boolean, ..._args: unknown[]): boolean { return true; } - onAdd(arena: Arena, quiet: boolean = false): void { } + onAdd(_arena: Arena, _quiet = false): void {} - onRemove(arena: Arena, quiet: boolean = false): void { + onRemove(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:arenaOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, { moveName: this.getMoveName() })); + globalScene.queueMessage( + i18next.t( + `arenaTag:arenaOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + { moveName: this.getMoveName() }, + ), + ); } } - onOverlap(arena: Arena): void { } + onOverlap(_arena: Arena): void {} - lapse(arena: Arena): boolean { - return this.turnCount < 1 || !!(--this.turnCount); + lapse(_arena: Arena): boolean { + return this.turnCount < 1 || !!--this.turnCount; } getMoveName(): string | null { - return this.sourceMove - ? allMoves[this.sourceMove].name - : null; + return this.sourceMove ? allMoves[this.sourceMove].name : null; } /** @@ -68,7 +79,7 @@ export abstract class ArenaTag { * This is meant to be inherited from by any arena tag with custom attributes * @param {ArenaTag | any} source An arena tag */ - loadTag(source : ArenaTag | any) : void { + loadTag(source: ArenaTag | any): void { this.turnCount = source.turnCount; this.sourceMove = source.sourceMove; this.sourceId = source.sourceId; @@ -109,14 +120,18 @@ export class MistTag extends ArenaTag { super(ArenaTagType.MIST, turnCount, Moves.MIST, sourceId, side); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(arena: Arena, quiet = false): void { super.onAdd(arena); if (this.sourceId) { const source = globalScene.getPokemonById(this.sourceId); if (!quiet && source) { - globalScene.queueMessage(i18next.t("arenaTag:mistOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(source) })); + globalScene.queueMessage( + i18next.t("arenaTag:mistOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(source), + }), + ); } else if (!quiet) { console.warn("Failed to get source for MistTag onAdd"); } @@ -125,14 +140,14 @@ export class MistTag extends ArenaTag { /** * Cancels the lowering of stats - * @param arena the {@linkcode Arena} containing this effect + * @param _arena the {@linkcode Arena} containing this effect * @param simulated `true` if the effect should be applied quietly * @param attacker the {@linkcode Pokemon} using a move into this effect. * @param cancelled a {@linkcode BooleanHolder} whose value is set to `true` * to flag the stat reduction as cancelled * @returns `true` if a stat reduction was cancelled; `false` otherwise */ - override apply(arena: Arena, simulated: boolean, attacker: Pokemon, cancelled: BooleanHolder): boolean { + override apply(_arena: Arena, simulated: boolean, attacker: Pokemon, cancelled: BooleanHolder): boolean { // `StatStageChangePhase` currently doesn't have a reference to the source of stat drops, // so this code currently has no effect on gameplay. if (attacker) { @@ -171,7 +186,14 @@ export class WeakenMoveScreenTag extends ArenaTag { * @param side - The side (player or enemy) the tag affects. * @param weakenedCategories - The categories of moves that are weakened by this tag. */ - constructor(tagType: ArenaTagType, turnCount: number, sourceMove: Moves, sourceId: number, side: ArenaTagSide, weakenedCategories: MoveCategory[]) { + constructor( + tagType: ArenaTagType, + turnCount: number, + sourceMove: Moves, + sourceId: number, + side: ArenaTagSide, + weakenedCategories: MoveCategory[], + ) { super(tagType, turnCount, sourceMove, sourceId, side); this.weakenedCategories = weakenedCategories; @@ -180,14 +202,20 @@ export class WeakenMoveScreenTag extends ArenaTag { /** * Applies the weakening effect to the move. * - * @param arena the {@linkcode Arena} where the move is applied. - * @param simulated n/a + * @param _arena the {@linkcode Arena} where the move is applied. + * @param _simulated n/a * @param attacker the attacking {@linkcode Pokemon} * @param moveCategory the attacking move's {@linkcode MoveCategory}. * @param damageMultiplier A {@linkcode NumberHolder} containing the damage multiplier * @returns `true` if the attacking move was weakened; `false` otherwise. */ - override apply(arena: Arena, simulated: boolean, attacker: Pokemon, moveCategory: MoveCategory, damageMultiplier: NumberHolder): boolean { + override apply( + _arena: Arena, + _simulated: boolean, + attacker: Pokemon, + moveCategory: MoveCategory, + damageMultiplier: NumberHolder, + ): boolean { if (this.weakenedCategories.includes(moveCategory)) { const bypassed = new BooleanHolder(false); applyAbAttrs(InfiltratorAbAttr, attacker, null, false, bypassed); @@ -207,12 +235,16 @@ export class WeakenMoveScreenTag extends ArenaTag { */ class ReflectTag extends WeakenMoveScreenTag { constructor(turnCount: number, sourceId: number, side: ArenaTagSide) { - super(ArenaTagType.REFLECT, turnCount, Moves.REFLECT, sourceId, side, [ MoveCategory.PHYSICAL ]); + super(ArenaTagType.REFLECT, turnCount, Moves.REFLECT, sourceId, side, [MoveCategory.PHYSICAL]); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:reflectOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:reflectOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } } @@ -223,12 +255,16 @@ class ReflectTag extends WeakenMoveScreenTag { */ class LightScreenTag extends WeakenMoveScreenTag { constructor(turnCount: number, sourceId: number, side: ArenaTagSide) { - super(ArenaTagType.LIGHT_SCREEN, turnCount, Moves.LIGHT_SCREEN, sourceId, side, [ MoveCategory.SPECIAL ]); + super(ArenaTagType.LIGHT_SCREEN, turnCount, Moves.LIGHT_SCREEN, sourceId, side, [MoveCategory.SPECIAL]); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:lightScreenOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:lightScreenOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } } @@ -239,12 +275,19 @@ class LightScreenTag extends WeakenMoveScreenTag { */ class AuroraVeilTag extends WeakenMoveScreenTag { constructor(turnCount: number, sourceId: number, side: ArenaTagSide) { - super(ArenaTagType.AURORA_VEIL, turnCount, Moves.AURORA_VEIL, sourceId, side, [ MoveCategory.SPECIAL, MoveCategory.PHYSICAL ]); + super(ArenaTagType.AURORA_VEIL, turnCount, Moves.AURORA_VEIL, sourceId, side, [ + MoveCategory.SPECIAL, + MoveCategory.PHYSICAL, + ]); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:auroraVeilOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:auroraVeilOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } } @@ -261,19 +304,31 @@ export class ConditionalProtectTag extends ArenaTag { /** Does this apply to all moves, including those that ignore other forms of protection? */ protected ignoresBypass: boolean; - constructor(tagType: ArenaTagType, sourceMove: Moves, sourceId: number, side: ArenaTagSide, condition: ProtectConditionFunc, ignoresBypass: boolean = false) { + constructor( + tagType: ArenaTagType, + sourceMove: Moves, + sourceId: number, + side: ArenaTagSide, + condition: ProtectConditionFunc, + ignoresBypass = false, + ) { super(tagType, 1, sourceMove, sourceId, side); this.protectConditionFunc = condition; this.ignoresBypass = ignoresBypass; } - onAdd(arena: Arena): void { - globalScene.queueMessage(i18next.t(`arenaTag:conditionalProtectOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, { moveName: super.getMoveName() })); + onAdd(_arena: Arena): void { + globalScene.queueMessage( + i18next.t( + `arenaTag:conditionalProtectOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + { moveName: super.getMoveName() }, + ), + ); } // Removes default message for effect removal - onRemove(arena: Arena): void { } + onRemove(_arena: Arena): void {} /** * Checks incoming moves against the condition function @@ -287,18 +342,28 @@ export class ConditionalProtectTag extends ArenaTag { * @param ignoresProtectBypass a {@linkcode BooleanHolder} used to flag if a protection effect supercedes effects that ignore protection * @returns `true` if this tag protected against the attack; `false` otherwise */ - override apply(arena: Arena, simulated: boolean, isProtected: BooleanHolder, attacker: Pokemon, defender: Pokemon, - moveId: Moves, ignoresProtectBypass: BooleanHolder): boolean { - - if ((this.side === ArenaTagSide.PLAYER) === defender.isPlayer() - && this.protectConditionFunc(arena, moveId)) { + override apply( + arena: Arena, + simulated: boolean, + isProtected: BooleanHolder, + attacker: Pokemon, + defender: Pokemon, + moveId: Moves, + ignoresProtectBypass: BooleanHolder, + ): boolean { + if ((this.side === ArenaTagSide.PLAYER) === defender.isPlayer() && this.protectConditionFunc(arena, moveId)) { if (!isProtected.value) { isProtected.value = true; if (!simulated) { attacker.stopMultiHit(defender); new CommonBattleAnim(CommonAnim.PROTECT, defender).play(); - globalScene.queueMessage(i18next.t("arenaTag:conditionalProtectApply", { moveName: super.getMoveName(), pokemonNameWithAffix: getPokemonNameWithAffix(defender) })); + globalScene.queueMessage( + i18next.t("arenaTag:conditionalProtectApply", { + moveName: super.getMoveName(), + pokemonNameWithAffix: getPokemonNameWithAffix(defender), + }), + ); } } @@ -312,12 +377,12 @@ export class ConditionalProtectTag extends ArenaTag { /** * Condition function for {@link https://bulbapedia.bulbagarden.net/wiki/Quick_Guard_(move) Quick Guard's} * protection effect. - * @param arena {@linkcode Arena} The arena containing the protection effect + * @param _arena {@linkcode Arena} The arena containing the protection effect * @param moveId {@linkcode Moves} The move to check against this condition * @returns `true` if the incoming move's priority is greater than 0. * This includes moves with modified priorities from abilities (e.g. Prankster) */ -const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => { +const QuickGuardConditionFunc: ProtectConditionFunc = (_arena, moveId) => { const move = allMoves[moveId]; const effectPhase = globalScene.getCurrentPhase(); @@ -343,11 +408,11 @@ class QuickGuardTag extends ConditionalProtectTag { /** * Condition function for {@link https://bulbapedia.bulbagarden.net/wiki/Wide_Guard_(move) Wide Guard's} * protection effect. - * @param arena {@linkcode Arena} The arena containing the protection effect + * @param _arena {@linkcode Arena} The arena containing the protection effect * @param moveId {@linkcode Moves} The move to check against this condition * @returns `true` if the incoming move is multi-targeted (even if it's only used against one Pokemon). */ -const WideGuardConditionFunc: ProtectConditionFunc = (arena, moveId) : boolean => { +const WideGuardConditionFunc: ProtectConditionFunc = (_arena, moveId): boolean => { const move = allMoves[moveId]; switch (move.moveTarget) { @@ -374,11 +439,11 @@ class WideGuardTag extends ConditionalProtectTag { /** * Condition function for {@link https://bulbapedia.bulbagarden.net/wiki/Mat_Block_(move) Mat Block's} * protection effect. - * @param arena {@linkcode Arena} The arena containing the protection effect. + * @param _arena {@linkcode Arena} The arena containing the protection effect. * @param moveId {@linkcode Moves} The move to check against this condition. * @returns `true` if the incoming move is not a Status move. */ -const MatBlockConditionFunc: ProtectConditionFunc = (arena, moveId) : boolean => { +const MatBlockConditionFunc: ProtectConditionFunc = (_arena, moveId): boolean => { const move = allMoves[moveId]; return move.category !== MoveCategory.STATUS; }; @@ -392,11 +457,15 @@ class MatBlockTag extends ConditionalProtectTag { super(ArenaTagType.MAT_BLOCK, Moves.MAT_BLOCK, sourceId, side, MatBlockConditionFunc); } - onAdd(arena: Arena) { + onAdd(_arena: Arena) { if (this.sourceId) { const source = globalScene.getPokemonById(this.sourceId); if (source) { - globalScene.queueMessage(i18next.t("arenaTag:matBlockOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(source) })); + globalScene.queueMessage( + i18next.t("arenaTag:matBlockOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(source), + }), + ); } else { console.warn("Failed to get source for MatBlockTag onAdd"); } @@ -407,24 +476,26 @@ class MatBlockTag extends ConditionalProtectTag { /** * Condition function for {@link https://bulbapedia.bulbagarden.net/wiki/Crafty_Shield_(move) Crafty Shield's} * protection effect. - * @param arena {@linkcode Arena} The arena containing the protection effect + * @param _arena {@linkcode Arena} The arena containing the protection effect * @param moveId {@linkcode Moves} The move to check against this condition * @returns `true` if the incoming move is a Status move, is not a hazard, and does not target all * Pokemon or sides of the field. */ -const CraftyShieldConditionFunc: ProtectConditionFunc = (arena, moveId) => { +const CraftyShieldConditionFunc: ProtectConditionFunc = (_arena, moveId) => { const move = allMoves[moveId]; - return move.category === MoveCategory.STATUS - && move.moveTarget !== MoveTarget.ENEMY_SIDE - && move.moveTarget !== MoveTarget.BOTH_SIDES - && move.moveTarget !== MoveTarget.ALL; + return ( + move.category === MoveCategory.STATUS && + move.moveTarget !== MoveTarget.ENEMY_SIDE && + move.moveTarget !== MoveTarget.BOTH_SIDES && + move.moveTarget !== MoveTarget.ALL + ); }; /** * Arena Tag class for {@link https://bulbapedia.bulbagarden.net/wiki/Crafty_Shield_(move) Crafty Shield} * Condition: The incoming move is a Status move, is not a hazard, and does * not target all Pokemon or sides of the field. -*/ + */ class CraftyShieldTag extends ConditionalProtectTag { constructor(sourceId: number, side: ArenaTagSide) { super(ArenaTagType.CRAFTY_SHIELD, Moves.CRAFTY_SHIELD, sourceId, side, CraftyShieldConditionFunc, true); @@ -448,19 +519,23 @@ export class NoCritTag extends ArenaTag { } /** Queues a message upon adding this effect to the field */ - onAdd(arena: Arena): void { - globalScene.queueMessage(i18next.t(`arenaTag:noCritOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : "Enemy"}`, { - moveName: this.getMoveName() - })); + onAdd(_arena: Arena): void { + globalScene.queueMessage( + i18next.t(`arenaTag:noCritOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : "Enemy"}`, { + moveName: this.getMoveName(), + }), + ); } /** Queues a message upon removing this effect from the field */ - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { const source = globalScene.getPokemonById(this.sourceId!); // TODO: is this bang correct? - globalScene.queueMessage(i18next.t("arenaTag:noCritOnRemove", { - pokemonNameWithAffix: getPokemonNameWithAffix(source ?? undefined), - moveName: this.getMoveName() - })); + globalScene.queueMessage( + i18next.t("arenaTag:noCritOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(source ?? undefined), + moveName: this.getMoveName(), + }), + ); } } @@ -477,12 +552,14 @@ class WishTag extends ArenaTag { super(ArenaTagType.WISH, turnCount, Moves.WISH, sourceId, side); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { if (this.sourceId) { const user = globalScene.getPokemonById(this.sourceId); if (user) { this.battlerIndex = user.getBattlerIndex(); - this.triggerMessage = i18next.t("arenaTag:wishTagOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(user) }); + this.triggerMessage = i18next.t("arenaTag:wishTagOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(user), + }); this.healHp = toDmgValue(user.getMaxHp() / 2); } else { console.warn("Failed to get source for WishTag onAdd"); @@ -490,7 +567,7 @@ class WishTag extends ArenaTag { } } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { const target = globalScene.getField()[this.battlerIndex]; if (target?.isActive(true)) { globalScene.queueMessage(this.triggerMessage); @@ -522,13 +599,13 @@ export class WeakenMoveTypeTag extends ArenaTag { /** * Reduces an attack's power by 0.33x if it matches this tag's weakened type. - * @param arena n/a - * @param simulated n/a + * @param _arena n/a + * @param _simulated n/a * @param type the attack's {@linkcode PokemonType} * @param power a {@linkcode NumberHolder} containing the attack's power * @returns `true` if the attack's power was reduced; `false` otherwise. */ - override apply(arena: Arena, simulated: boolean, type: PokemonType, power: NumberHolder): boolean { + override apply(_arena: Arena, _simulated: boolean, type: PokemonType, power: NumberHolder): boolean { if (type === this.weakenedType) { power.value *= 0.33; return true; @@ -546,11 +623,11 @@ class MudSportTag extends WeakenMoveTypeTag { super(ArenaTagType.MUD_SPORT, turnCount, PokemonType.ELECTRIC, Moves.MUD_SPORT, sourceId); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:mudSportOnAdd")); } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:mudSportOnRemove")); } } @@ -564,11 +641,11 @@ class WaterSportTag extends WeakenMoveTypeTag { super(ArenaTagType.WATER_SPORT, turnCount, PokemonType.FIRE, Moves.WATER_SPORT, sourceId); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:waterSportOnAdd")); } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:waterSportOnRemove")); } } @@ -584,20 +661,20 @@ export class IonDelugeTag extends ArenaTag { } /** Queues an on-add message */ - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:plasmaFistsOnAdd")); } - onRemove(arena: Arena): void { } // Removes default on-remove message + onRemove(_arena: Arena): void {} // Removes default on-remove message /** * Converts Normal-type moves to Electric type - * @param arena n/a - * @param simulated n/a + * @param _arena n/a + * @param _simulated n/a * @param moveType a {@linkcode NumberHolder} containing a move's {@linkcode PokemonType} * @returns `true` if the given move type changed; `false` otherwise. */ - override apply(arena: Arena, simulated: boolean, moveType: NumberHolder): boolean { + override apply(_arena: Arena, _simulated: boolean, moveType: NumberHolder): boolean { if (moveType.value === PokemonType.NORMAL) { moveType.value = PokemonType.ELECTRIC; return true; @@ -639,12 +716,12 @@ export class ArenaTrapTag extends ArenaTag { /** * Activates the hazard effect onto a Pokemon when it enters the field - * @param arena the {@linkcode Arena} containing this tag + * @param _arena the {@linkcode Arena} containing this tag * @param simulated if `true`, only checks if the hazard would activate. * @param pokemon the {@linkcode Pokemon} triggering this hazard * @returns `true` if this hazard affects the given Pokemon; `false` otherwise. */ - override apply(arena: Arena, simulated: boolean, pokemon: Pokemon): boolean { + override apply(_arena: Arena, simulated: boolean, pokemon: Pokemon): boolean { if ((this.side === ArenaTagSide.PLAYER) !== pokemon.isPlayer()) { return false; } @@ -652,12 +729,14 @@ export class ArenaTrapTag extends ArenaTag { return this.activateTrap(pokemon, simulated); } - activateTrap(pokemon: Pokemon, simulated: boolean): boolean { + activateTrap(_pokemon: Pokemon, _simulated: boolean): boolean { return false; } getMatchupScoreMultiplier(pokemon: Pokemon): number { - return pokemon.isGrounded() ? 1 : Phaser.Math.Linear(0, 1 / Math.pow(2, this.layers), Math.min(pokemon.getHpRatio(), 0.5) * 2); + return pokemon.isGrounded() + ? 1 + : Phaser.Math.Linear(0, 1 / Math.pow(2, this.layers), Math.min(pokemon.getHpRatio(), 0.5) * 2); } loadTag(source: any): void { @@ -677,12 +756,17 @@ class SpikesTag extends ArenaTrapTag { super(ArenaTagType.SPIKES, Moves.SPIKES, sourceId, side, 3); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(arena: Arena, quiet = false): void { super.onAdd(arena); const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null; if (!quiet && source) { - globalScene.queueMessage(i18next.t("arenaTag:spikesOnAdd", { moveName: this.getMoveName(), opponentDesc: source.getOpponentDescriptor() })); + globalScene.queueMessage( + i18next.t("arenaTag:spikesOnAdd", { + moveName: this.getMoveName(), + opponentDesc: source.getOpponentDescriptor(), + }), + ); } } @@ -699,7 +783,11 @@ class SpikesTag extends ArenaTrapTag { const damageHpRatio = 1 / (10 - 2 * this.layers); const damage = toDmgValue(pokemon.getMaxHp() * damageHpRatio); - globalScene.queueMessage(i18next.t("arenaTag:spikesActivateTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("arenaTag:spikesActivateTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); pokemon.damageAndUpdate(damage, HitResult.OTHER); if (pokemon.turnData) { pokemon.turnData.damageTaken += damage; @@ -726,12 +814,17 @@ class ToxicSpikesTag extends ArenaTrapTag { this.neutralized = false; } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(arena: Arena, quiet = false): void { super.onAdd(arena); const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null; if (!quiet && source) { - globalScene.queueMessage(i18next.t("arenaTag:toxicSpikesOnAdd", { moveName: this.getMoveName(), opponentDesc: source.getOpponentDescriptor() })); + globalScene.queueMessage( + i18next.t("arenaTag:toxicSpikesOnAdd", { + moveName: this.getMoveName(), + opponentDesc: source.getOpponentDescriptor(), + }), + ); } } @@ -749,12 +842,19 @@ class ToxicSpikesTag extends ArenaTrapTag { if (pokemon.isOfType(PokemonType.POISON)) { this.neutralized = true; if (globalScene.arena.removeTag(this.tagType)) { - globalScene.queueMessage(i18next.t("arenaTag:toxicSpikesActivateTrapPoison", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: this.getMoveName() })); + globalScene.queueMessage( + i18next.t("arenaTag:toxicSpikesActivateTrapPoison", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: this.getMoveName(), + }), + ); return true; } } else if (!pokemon.status) { const toxic = this.layers > 1; - if (pokemon.trySetStatus(!toxic ? StatusEffect.POISON : StatusEffect.TOXIC, true, null, 0, this.getMoveName())) { + if ( + pokemon.trySetStatus(!toxic ? StatusEffect.POISON : StatusEffect.TOXIC, true, null, 0, this.getMoveName()) + ) { return true; } } @@ -782,7 +882,13 @@ class ToxicSpikesTag extends ArenaTrapTag { export class DelayedAttackTag extends ArenaTag { public targetIndex: BattlerIndex; - constructor(tagType: ArenaTagType, sourceMove: Moves | undefined, sourceId: number, targetIndex: BattlerIndex, side: ArenaTagSide = ArenaTagSide.BOTH) { + constructor( + tagType: ArenaTagType, + sourceMove: Moves | undefined, + sourceId: number, + targetIndex: BattlerIndex, + side: ArenaTagSide = ArenaTagSide.BOTH, + ) { super(tagType, 3, sourceMove, sourceId, side); this.targetIndex = targetIndex; @@ -793,13 +899,15 @@ export class DelayedAttackTag extends ArenaTag { const ret = super.lapse(arena); if (!ret) { - globalScene.unshiftPhase(new MoveEffectPhase(this.sourceId!, [ this.targetIndex ], new PokemonMove(this.sourceMove!, 0, 0, true))); // TODO: are those bangs correct? + globalScene.unshiftPhase( + new MoveEffectPhase(this.sourceId!, [this.targetIndex], new PokemonMove(this.sourceMove!, 0, 0, true)), + ); // TODO: are those bangs correct? } return ret; } - onRemove(arena: Arena): void { } + onRemove(_arena: Arena): void {} } /** @@ -812,19 +920,23 @@ class StealthRockTag extends ArenaTrapTag { super(ArenaTagType.STEALTH_ROCK, Moves.STEALTH_ROCK, sourceId, side, 1); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(arena: Arena, quiet = false): void { super.onAdd(arena); const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null; if (!quiet && source) { - globalScene.queueMessage(i18next.t("arenaTag:stealthRockOnAdd", { opponentDesc: source.getOpponentDescriptor() })); + globalScene.queueMessage( + i18next.t("arenaTag:stealthRockOnAdd", { + opponentDesc: source.getOpponentDescriptor(), + }), + ); } } getDamageHpRatio(pokemon: Pokemon): number { const effectiveness = pokemon.getAttackTypeEffectiveness(PokemonType.ROCK, undefined, true); - let damageHpRatio: number = 0; + let damageHpRatio = 0; switch (effectiveness) { case 0: @@ -852,7 +964,7 @@ class StealthRockTag extends ArenaTrapTag { override activateTrap(pokemon: Pokemon, simulated: boolean): boolean { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (cancelled.value) { return false; @@ -865,7 +977,11 @@ class StealthRockTag extends ArenaTrapTag { return true; } const damage = toDmgValue(pokemon.getMaxHp() * damageHpRatio); - globalScene.queueMessage(i18next.t("arenaTag:stealthRockActivateTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("arenaTag:stealthRockActivateTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); pokemon.damageAndUpdate(damage, HitResult.OTHER); if (pokemon.turnData) { pokemon.turnData.damageTaken += damage; @@ -892,11 +1008,16 @@ class StickyWebTag extends ArenaTrapTag { super(ArenaTagType.STICKY_WEB, Moves.STICKY_WEB, sourceId, side, 1); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(arena: Arena, quiet = false): void { super.onAdd(arena); const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null; if (!quiet && source) { - globalScene.queueMessage(i18next.t("arenaTag:stickyWebOnAdd", { moveName: this.getMoveName(), opponentDesc: source.getOpponentDescriptor() })); + globalScene.queueMessage( + i18next.t("arenaTag:stickyWebOnAdd", { + moveName: this.getMoveName(), + opponentDesc: source.getOpponentDescriptor(), + }), + ); } } @@ -910,16 +1031,32 @@ class StickyWebTag extends ArenaTrapTag { } if (!cancelled.value) { - globalScene.queueMessage(i18next.t("arenaTag:stickyWebActivateTrap", { pokemonName: pokemon.getNameToRender() })); + globalScene.queueMessage( + i18next.t("arenaTag:stickyWebActivateTrap", { + pokemonName: pokemon.getNameToRender(), + }), + ); const stages = new NumberHolder(-1); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), false, [ Stat.SPD ], stages.value, true, false, true, null, false, true)); + globalScene.unshiftPhase( + new StatStageChangePhase( + pokemon.getBattlerIndex(), + false, + [Stat.SPD], + stages.value, + true, + false, + true, + null, + false, + true, + ), + ); return true; } } return false; } - } /** @@ -934,25 +1071,29 @@ export class TrickRoomTag extends ArenaTag { /** * Reverses Speed-based turn order for all Pokemon on the field - * @param arena n/a - * @param simulated n/a + * @param _arena n/a + * @param _simulated n/a * @param speedReversed a {@linkcode BooleanHolder} used to flag if Speed-based * turn order should be reversed. * @returns `true` if turn order is successfully reversed; `false` otherwise */ - override apply(arena: Arena, simulated: boolean, speedReversed: BooleanHolder): boolean { + override apply(_arena: Arena, _simulated: boolean, speedReversed: BooleanHolder): boolean { speedReversed.value = !speedReversed.value; return true; } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { const source = this.sourceId ? globalScene.getPokemonById(this.sourceId) : null; if (source) { - globalScene.queueMessage(i18next.t("arenaTag:trickRoomOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(source) })); + globalScene.queueMessage( + i18next.t("arenaTag:trickRoomOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(source), + }), + ); } } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:trickRoomOnRemove")); } } @@ -967,9 +1108,9 @@ export class GravityTag extends ArenaTag { super(ArenaTagType.GRAVITY, turnCount, Moves.GRAVITY); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:gravityOnAdd")); - globalScene.getField(true).forEach((pokemon) => { + globalScene.getField(true).forEach(pokemon => { if (pokemon !== null) { pokemon.removeTag(BattlerTagType.FLOATING); pokemon.removeTag(BattlerTagType.TELEKINESIS); @@ -980,7 +1121,7 @@ export class GravityTag extends ArenaTag { }); } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:gravityOnRemove")); } } @@ -995,9 +1136,13 @@ class TailwindTag extends ArenaTag { super(ArenaTagType.TAILWIND, turnCount, Moves.TAILWIND, sourceId, side); } - onAdd(arena: Arena, quiet: boolean = false): void { + onAdd(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:tailwindOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:tailwindOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } const source = globalScene.getPokemonById(this.sourceId!); //TODO: this bang is questionable! @@ -1007,19 +1152,28 @@ class TailwindTag extends ArenaTag { // Apply the CHARGED tag to party members with the WIND_POWER ability if (pokemon.hasAbility(Abilities.WIND_POWER) && !pokemon.getTag(BattlerTagType.CHARGED)) { pokemon.addTag(BattlerTagType.CHARGED); - globalScene.queueMessage(i18next.t("abilityTriggers:windPowerCharged", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: this.getMoveName() })); + globalScene.queueMessage( + i18next.t("abilityTriggers:windPowerCharged", { + pokemonName: getPokemonNameWithAffix(pokemon), + moveName: this.getMoveName(), + }), + ); } // Raise attack by one stage if party member has WIND_RIDER ability if (pokemon.hasAbility(Abilities.WIND_RIDER)) { globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.getBattlerIndex())); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.ATK ], 1, true)); + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.ATK], 1, true)); } } } - onRemove(arena: Arena, quiet: boolean = false): void { + onRemove(_arena: Arena, quiet = false): void { if (!quiet) { - globalScene.queueMessage(i18next.t(`arenaTag:tailwindOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:tailwindOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } } @@ -1033,11 +1187,11 @@ class HappyHourTag extends ArenaTag { super(ArenaTagType.HAPPY_HOUR, turnCount, Moves.HAPPY_HOUR, sourceId, side); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:happyHourOnAdd")); } - onRemove(arena: Arena): void { + onRemove(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:happyHourOnRemove")); } } @@ -1047,12 +1201,20 @@ class SafeguardTag extends ArenaTag { super(ArenaTagType.SAFEGUARD, turnCount, Moves.SAFEGUARD, sourceId, side); } - onAdd(arena: Arena): void { - globalScene.queueMessage(i18next.t(`arenaTag:safeguardOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + onAdd(_arena: Arena): void { + globalScene.queueMessage( + i18next.t( + `arenaTag:safeguardOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } - onRemove(arena: Arena): void { - globalScene.queueMessage(i18next.t(`arenaTag:safeguardOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + onRemove(_arena: Arena): void { + globalScene.queueMessage( + i18next.t( + `arenaTag:safeguardOnRemove${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } @@ -1079,12 +1241,16 @@ class ImprisonTag extends ArenaTrapTag { const source = this.getSourcePokemon(); if (source) { const party = this.getAffectedPokemon(); - party?.forEach((p: Pokemon ) => { + party?.forEach((p: Pokemon) => { if (p.isAllowedInBattle()) { p.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId); } }); - globalScene.queueMessage(i18next.t("battlerTags:imprisonOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(source) })); + globalScene.queueMessage( + i18next.t("battlerTags:imprisonOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(source), + }), + ); } } @@ -1105,7 +1271,7 @@ class ImprisonTag extends ArenaTrapTag { */ override activateTrap(pokemon: Pokemon): boolean { const source = this.getSourcePokemon(); - if (source && source.isActive(true) && pokemon.isAllowedInBattle()) { + if (source?.isActive(true) && pokemon.isAllowedInBattle()) { pokemon.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId); } return true; @@ -1135,23 +1301,34 @@ class FireGrassPledgeTag extends ArenaTag { super(ArenaTagType.FIRE_GRASS_PLEDGE, 4, Moves.FIRE_PLEDGE, sourceId, side); } - override onAdd(arena: Arena): void { + override onAdd(_arena: Arena): void { // "A sea of fire enveloped your/the opposing team!" - globalScene.queueMessage(i18next.t(`arenaTag:fireGrassPledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:fireGrassPledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } override lapse(arena: Arena): boolean { - const field: Pokemon[] = (this.side === ArenaTagSide.PLAYER) - ? globalScene.getPlayerField() - : globalScene.getEnemyField(); + const field: Pokemon[] = + this.side === ArenaTagSide.PLAYER ? globalScene.getPlayerField() : globalScene.getEnemyField(); - field.filter(pokemon => !pokemon.isOfType(PokemonType.FIRE) && !pokemon.switchOutStatus).forEach(pokemon => { - // "{pokemonNameWithAffix} was hurt by the sea of fire!" - globalScene.queueMessage(i18next.t("arenaTag:fireGrassPledgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); - // TODO: Replace this with a proper animation - globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.MAGMA_STORM)); - pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); - }); + field + .filter(pokemon => !pokemon.isOfType(PokemonType.FIRE) && !pokemon.switchOutStatus) + .forEach(pokemon => { + // "{pokemonNameWithAffix} was hurt by the sea of fire!" + globalScene.queueMessage( + i18next.t("arenaTag:fireGrassPledgeLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); + // TODO: Replace this with a proper animation + globalScene.unshiftPhase( + new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.MAGMA_STORM), + ); + pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); + }); return super.lapse(arena); } @@ -1169,20 +1346,24 @@ class WaterFirePledgeTag extends ArenaTag { super(ArenaTagType.WATER_FIRE_PLEDGE, 4, Moves.WATER_PLEDGE, sourceId, side); } - override onAdd(arena: Arena): void { + override onAdd(_arena: Arena): void { // "A rainbow appeared in the sky on your/the opposing team's side!" - globalScene.queueMessage(i18next.t(`arenaTag:waterFirePledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:waterFirePledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } /** * Doubles the chance for the given move's secondary effect(s) to trigger - * @param arena the {@linkcode Arena} containing this tag - * @param simulated n/a + * @param _arena the {@linkcode Arena} containing this tag + * @param _simulated n/a * @param moveChance a {@linkcode NumberHolder} containing * the move's current effect chance * @returns `true` if the move's effect chance was doubled (currently always `true`) */ - override apply(arena: Arena, simulated: boolean, moveChance: NumberHolder): boolean { + override apply(_arena: Arena, _simulated: boolean, moveChance: NumberHolder): boolean { moveChance.value *= 2; return true; } @@ -1199,9 +1380,13 @@ class GrassWaterPledgeTag extends ArenaTag { super(ArenaTagType.GRASS_WATER_PLEDGE, 4, Moves.GRASS_PLEDGE, sourceId, side); } - override onAdd(arena: Arena): void { + override onAdd(_arena: Arena): void { // "A swamp enveloped your/the opposing team!" - globalScene.queueMessage(i18next.t(`arenaTag:grassWaterPledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`)); + globalScene.queueMessage( + i18next.t( + `arenaTag:grassWaterPledgeOnAdd${this.side === ArenaTagSide.PLAYER ? "Player" : this.side === ArenaTagSide.ENEMY ? "Enemy" : ""}`, + ), + ); } } @@ -1217,10 +1402,9 @@ export class FairyLockTag extends ArenaTag { super(ArenaTagType.FAIRY_LOCK, turnCount, Moves.FAIRY_LOCK, sourceId); } - onAdd(arena: Arena): void { + onAdd(_arena: Arena): void { globalScene.queueMessage(i18next.t("arenaTag:fairyLockOnAdd")); } - } /** @@ -1240,20 +1424,24 @@ export class SuppressAbilitiesTag extends ArenaTag { this.beingRemoved = false; } - public override onAdd(arena: Arena): void { + public override onAdd(_arena: Arena): void { const pokemon = this.getSourcePokemon(); if (pokemon) { - globalScene.queueMessage(i18next.t("arenaTag:neutralizingGasOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("arenaTag:neutralizingGasOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); for (const fieldPokemon of globalScene.getField()) { if (fieldPokemon && fieldPokemon.id !== pokemon.id) { - [ true, false ].forEach((passive) => applyOnLoseAbAttrs(fieldPokemon, passive)); + [true, false].forEach(passive => applyOnLoseAbAttrs(fieldPokemon, passive)); } } } } - public override onOverlap(arena: Arena): void { + public override onOverlap(_arena: Arena): void { this.sourceCount++; } @@ -1265,12 +1453,14 @@ export class SuppressAbilitiesTag extends ArenaTag { // With 1 source left, that pokemon's other abilities should reactivate // This may be confusing for players but would be the most accurate gameplay-wise // Could have a custom message that plays when a specific pokemon's NG ends? This entire thing exists due to passives after all - const setter = globalScene.getField().filter((p) => p && p.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false))[0]; + const setter = globalScene + .getField() + .filter(p => p?.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false))[0]; applyOnGainAbAttrs(setter, setter.getAbility().hasAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr)); } } - public override onRemove(arena: Arena, quiet: boolean = false) { + public override onRemove(_arena: Arena, quiet = false) { this.beingRemoved = true; if (!quiet) { globalScene.queueMessage(i18next.t("arenaTag:neutralizingGasOnRemove")); @@ -1279,7 +1469,7 @@ export class SuppressAbilitiesTag extends ArenaTag { for (const pokemon of globalScene.getField()) { // There is only one pokemon with this attr on the field on removal, so its abilities are already active if (pokemon && !pokemon.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false)) { - [ true, false ].forEach((passive) => applyOnGainAbAttrs(pokemon, passive)); + [true, false].forEach(passive => applyOnGainAbAttrs(pokemon, passive)); } } } @@ -1294,7 +1484,14 @@ export class SuppressAbilitiesTag extends ArenaTag { } // TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter -export function getArenaTag(tagType: ArenaTagType, turnCount: number, sourceMove: Moves | undefined, sourceId: number, targetIndex?: BattlerIndex, side: ArenaTagSide = ArenaTagSide.BOTH): ArenaTag | null { +export function getArenaTag( + tagType: ArenaTagType, + turnCount: number, + sourceMove: Moves | undefined, + sourceId: number, + targetIndex?: BattlerIndex, + side: ArenaTagSide = ArenaTagSide.BOTH, +): ArenaTag | null { switch (tagType) { case ArenaTagType.MIST: return new MistTag(turnCount, sourceId, side); @@ -1366,9 +1563,15 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: number, sourceMove * @return {ArenaTag} The valid arena tag */ export function loadArenaTag(source: ArenaTag | any): ArenaTag { - const tag = getArenaTag(source.tagType, source.turnCount, source.sourceMove, source.sourceId, source.targetIndex, source.side) - ?? new NoneTag(); + const tag = + getArenaTag( + source.tagType, + source.turnCount, + source.sourceMove, + source.sourceId, + source.targetIndex, + source.side, + ) ?? new NoneTag(); tag.loadTag(source); return tag; } - diff --git a/src/data/balance/biomes.ts b/src/data/balance/biomes.ts index 8feaa5beb5e..71a48162e57 100644 --- a/src/data/balance/biomes.ts +++ b/src/data/balance/biomes.ts @@ -2022,6 +2022,7 @@ export const biomeTrainerPools: BiomeTrainerPools = { } }; +// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: init methods are expected to have many lines. export function initBiomes() { const pokemonBiomes = [ [ Species.BULBASAUR, PokemonType.GRASS, PokemonType.POISON, [ @@ -7677,7 +7678,7 @@ export function initBiomes() { const traverseBiome = (biome: Biome, depth: number) => { if (biome === Biome.END) { - const biomeList = Object.keys(Biome).filter(key => !isNaN(Number(key))); + const biomeList = Object.keys(Biome).filter(key => !Number.isNaN(Number(key))); biomeList.pop(); // Removes Biome.END from the list const randIndex = Utils.randSeedInt(biomeList.length, 1); // Will never be Biome.TOWN biome = Biome[biomeList[randIndex]]; @@ -7764,7 +7765,8 @@ export function initBiomes() { treeIndex = t; arrayIndex = es + 1; break; - } else if (speciesEvolutions && speciesEvolutions.find(se => se.speciesId === existingSpeciesId)) { + } + if (speciesEvolutions?.find(se => se.speciesId === existingSpeciesId)) { treeIndex = t; arrayIndex = es; break; @@ -7786,7 +7788,7 @@ export function initBiomes() { for (const b of Object.keys(biomePokemonPools)) { for (const t of Object.keys(biomePokemonPools[b])) { - const tier = parseInt(t) as BiomePoolTier; + const tier = Number.parseInt(t) as BiomePoolTier; for (const tod of Object.keys(biomePokemonPools[b][t])) { const biomeTierTimePool = biomePokemonPools[b][t][tod]; for (let e = 0; e < biomeTierTimePool.length; e++) { @@ -7799,7 +7801,7 @@ export function initBiomes() { }; for (let s = 1; s < entry.length; s++) { const speciesId = entry[s]; - const prevolution = entry.map(s => pokemonEvolutions[s]).flat().find(e => e && e.speciesId === speciesId); + const prevolution = entry.flatMap((s: string | number) => pokemonEvolutions[s]).find(e => e && e.speciesId === speciesId); const level = prevolution.level - (prevolution.level === 1 ? 1 : 0) + (prevolution.wildDelay * 10) - (tier >= BiomePoolTier.BOSS ? 10 : 0); if (!newEntry.hasOwnProperty(level)) { newEntry[level] = [ speciesId ]; diff --git a/src/data/balance/egg-moves.ts b/src/data/balance/egg-moves.ts index 1bac63e9560..5829e3e10aa 100644 --- a/src/data/balance/egg-moves.ts +++ b/src/data/balance/egg-moves.ts @@ -591,7 +591,7 @@ function parseEggMoves(content: string): void { const speciesValues = Utils.getEnumValues(Species); const lines = content.split(/\n/g); - lines.forEach((line, l) => { + for (const line of lines) { const cols = line.split(",").slice(0, 5); const moveNames = allMoves.map(m => m.name.replace(/ \([A-Z]\)$/, "").toLowerCase()); const enumSpeciesName = cols[0].toUpperCase().replace(/[ -]/g, "_"); @@ -612,7 +612,7 @@ function parseEggMoves(content: string): void { if (eggMoves.find(m => m !== Moves.NONE)) { output += `[Species.${Species[species]}]: [ ${eggMoves.map(m => `Moves.${Moves[m]}`).join(", ")} ],\n`; } - }); + } console.log(output); } diff --git a/src/data/balance/pokemon-evolutions.ts b/src/data/balance/pokemon-evolutions.ts index 6cf79bb45f1..c34bc229bd7 100644 --- a/src/data/balance/pokemon-evolutions.ts +++ b/src/data/balance/pokemon-evolutions.ts @@ -92,7 +92,7 @@ export class SpeciesFormEvolution { public item: EvolutionItem | null; public condition: SpeciesEvolutionCondition | null; public wildDelay: SpeciesWildEvolutionDelay; - public description: string = ""; + public description = ""; constructor(speciesId: Species, preFormKey: string | null, evoFormKey: string | null, level: number, item: EvolutionItem | null, condition: SpeciesEvolutionCondition | null, wildDelay?: SpeciesWildEvolutionDelay) { this.speciesId = speciesId; @@ -206,7 +206,7 @@ class FriendshipTimeOfDayEvolutionCondition extends SpeciesEvolutionCondition { super(p => p.friendship >= amount && (globalScene.arena.getTimeOfDay() === TimeOfDay.DUSK || globalScene.arena.getTimeOfDay() === TimeOfDay.NIGHT)); this.timesOfDay = [ TimeOfDay.DUSK, TimeOfDay.NIGHT ]; } else { - super(p => false); + super(_p => false); this.timesOfDay = []; } this.amount = amount; @@ -1898,7 +1898,7 @@ export function initPokemonPrevolutions(): void { if (ev.evoFormKey && megaFormKeys.indexOf(ev.evoFormKey) > -1) { continue; } - pokemonPrevolutions[ev.speciesId] = parseInt(pk) as Species; + pokemonPrevolutions[ev.speciesId] = Number.parseInt(pk) as Species; } }); } diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index d3c9f393209..86060ef4bfc 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -1,20 +1,8 @@ import { globalScene } from "#app/global-scene"; -import { - AttackMove, - BeakBlastHeaderAttr, - DelayedAttackAttr, - SelfStatusMove, - allMoves, -} from "./moves/move"; +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"; import type { BattlerIndex } from "../battle"; import type { Element } from "json-stable-stringify"; import { Moves } from "#enums/moves"; @@ -24,99 +12,99 @@ import Phaser from "phaser"; import { EncounterAnim } from "#enums/encounter-anims"; export enum AnimFrameTarget { - USER, - TARGET, - GRAPHIC + USER, + TARGET, + GRAPHIC, } enum AnimFocus { - TARGET = 1, - USER, - USER_TARGET, - SCREEN + TARGET = 1, + USER, + USER_TARGET, + SCREEN, } enum AnimBlendType { - NORMAL, - ADD, - SUBTRACT + NORMAL, + ADD, + SUBTRACT, } export enum ChargeAnim { - FLY_CHARGING = 1000, - BOUNCE_CHARGING, - DIG_CHARGING, - FUTURE_SIGHT_CHARGING, - DIVE_CHARGING, - SOLAR_BEAM_CHARGING, - SHADOW_FORCE_CHARGING, - SKULL_BASH_CHARGING, - FREEZE_SHOCK_CHARGING, - SKY_DROP_CHARGING, - SKY_ATTACK_CHARGING, - ICE_BURN_CHARGING, - DOOM_DESIRE_CHARGING, - RAZOR_WIND_CHARGING, - PHANTOM_FORCE_CHARGING, - GEOMANCY_CHARGING, - SHADOW_BLADE_CHARGING, - SOLAR_BLADE_CHARGING, - BEAK_BLAST_CHARGING, - METEOR_BEAM_CHARGING, - ELECTRO_SHOT_CHARGING + FLY_CHARGING = 1000, + BOUNCE_CHARGING, + DIG_CHARGING, + FUTURE_SIGHT_CHARGING, + DIVE_CHARGING, + SOLAR_BEAM_CHARGING, + SHADOW_FORCE_CHARGING, + SKULL_BASH_CHARGING, + FREEZE_SHOCK_CHARGING, + SKY_DROP_CHARGING, + SKY_ATTACK_CHARGING, + ICE_BURN_CHARGING, + DOOM_DESIRE_CHARGING, + RAZOR_WIND_CHARGING, + PHANTOM_FORCE_CHARGING, + GEOMANCY_CHARGING, + SHADOW_BLADE_CHARGING, + SOLAR_BLADE_CHARGING, + BEAK_BLAST_CHARGING, + METEOR_BEAM_CHARGING, + ELECTRO_SHOT_CHARGING, } export enum CommonAnim { - USE_ITEM = 2000, - HEALTH_UP, - TERASTALLIZE, - POISON = 2010, - TOXIC, - PARALYSIS, - SLEEP, - FROZEN, - BURN, - CONFUSION, - ATTRACT, - BIND, - WRAP, - CURSE_NO_GHOST, - LEECH_SEED, - FIRE_SPIN, - PROTECT, - COVET, - WHIRLPOOL, - BIDE, - SAND_TOMB, - QUICK_GUARD, - WIDE_GUARD, - CURSE, - MAGMA_STORM, - CLAMP, - SNAP_TRAP, - THUNDER_CAGE, - INFESTATION, - ORDER_UP_CURLY, - ORDER_UP_DROOPY, - ORDER_UP_STRETCHY, - RAGING_BULL_FIRE, - RAGING_BULL_WATER, - SALT_CURE, - POWDER, - SUNNY = 2100, - RAIN, - SANDSTORM, - HAIL, - SNOW, - WIND, - HEAVY_RAIN, - HARSH_SUN, - STRONG_WINDS, - MISTY_TERRAIN = 2110, - ELECTRIC_TERRAIN, - GRASSY_TERRAIN, - PSYCHIC_TERRAIN, - LOCK_ON = 2120 + USE_ITEM = 2000, + HEALTH_UP, + TERASTALLIZE, + POISON = 2010, + TOXIC, + PARALYSIS, + SLEEP, + FROZEN, + BURN, + CONFUSION, + ATTRACT, + BIND, + WRAP, + CURSE_NO_GHOST, + LEECH_SEED, + FIRE_SPIN, + PROTECT, + COVET, + WHIRLPOOL, + BIDE, + SAND_TOMB, + QUICK_GUARD, + WIDE_GUARD, + CURSE, + MAGMA_STORM, + CLAMP, + SNAP_TRAP, + THUNDER_CAGE, + INFESTATION, + ORDER_UP_CURLY, + ORDER_UP_DROOPY, + ORDER_UP_STRETCHY, + RAGING_BULL_FIRE, + RAGING_BULL_WATER, + SALT_CURE, + POWDER, + SUNNY = 2100, + RAIN, + SANDSTORM, + HAIL, + SNOW, + WIND, + HEAVY_RAIN, + HARSH_SUN, + STRONG_WINDS, + MISTY_TERRAIN = 2110, + ELECTRIC_TERRAIN, + GRASSY_TERRAIN, + PSYCHIC_TERRAIN, + LOCK_ON = 2120, } export class AnimConfig { @@ -128,7 +116,7 @@ export class AnimConfig { public hue: number; constructor(source?: any) { - this.frameTimedEvents = new Map; + this.frameTimedEvents = new Map(); if (source) { this.id = source.id; @@ -160,7 +148,7 @@ export class AnimConfig { timedEvent && timedEvents.push(timedEvent); } - this.frameTimedEvents.set(parseInt(fte), timedEvents); + this.frameTimedEvents.set(Number.parseInt(fte), timedEvents); } this.position = source.position; @@ -218,9 +206,34 @@ class AnimFrame { public priority: number; public focus: AnimFocus; - constructor(x: number, y: number, zoomX: number, zoomY: number, angle: number, mirror: boolean, visible: boolean, blendType: AnimBlendType, pattern: number, - opacity: number, colorR: number, colorG: number, colorB: number, colorA: number, toneR: number, toneG: number, toneB: number, toneA: number, - flashR: number, flashG: number, flashB: number, flashA: number, locked: boolean, priority: number, focus: AnimFocus, init?: boolean) { + constructor( + x: number, + y: number, + zoomX: number, + zoomY: number, + angle: number, + mirror: boolean, + visible: boolean, + blendType: AnimBlendType, + pattern: number, + opacity: number, + colorR: number, + colorG: number, + colorB: number, + colorA: number, + toneR: number, + toneG: number, + toneB: number, + toneA: number, + flashR: number, + flashG: number, + flashB: number, + flashA: number, + locked: boolean, + priority: number, + focus: AnimFocus, + init?: boolean, + ) { this.x = !init ? ((x || 0) - 128) * 0.5 : x; this.y = !init ? ((y || 0) - 224) * 0.5 : y; if (zoomX) { @@ -272,19 +285,19 @@ class AnimFrame { this.opacity = 0; } if (colorR || colorG || colorB || colorA) { - this.color = [ colorR || 0, colorG || 0, colorB || 0, colorA || 0 ]; + this.color = [colorR || 0, colorG || 0, colorB || 0, colorA || 0]; } else if (init) { - this.color = [ 0, 0, 0, 0 ]; + this.color = [0, 0, 0, 0]; } if (toneR || toneG || toneB || toneA) { - this.tone = [ toneR || 0, toneG || 0, toneB || 0, toneA || 0 ]; + this.tone = [toneR || 0, toneG || 0, toneB || 0, toneA || 0]; } else if (init) { - this.tone = [ 0, 0, 0, 0 ]; + this.tone = [0, 0, 0, 0]; } if (flashR || flashG || flashB || flashA) { - this.flash = [ flashR || 0, flashG || 0, flashB || 0, flashA || 0 ]; + this.flash = [flashR || 0, flashG || 0, flashB || 0, flashA || 0]; } else if (init) { - this.flash = [ 0, 0, 0, 0 ]; + this.flash = [0, 0, 0, 0]; } if (locked) { this.locked = locked; @@ -302,10 +315,37 @@ class AnimFrame { class ImportedAnimFrame extends AnimFrame { constructor(source: any) { - const color: number[] = source.color || [ 0, 0, 0, 0 ]; - const tone: number[] = source.tone || [ 0, 0, 0, 0 ]; - const flash: number[] = source.flash || [ 0, 0, 0, 0 ]; - super(source.x, source.y, source.zoomX, source.zoomY, source.angle, source.mirror, source.visible, source.blendType, source.graphicFrame, source.opacity, color[0], color[1], color[2], color[3], tone[0], tone[1], tone[2], tone[3], flash[0], flash[1], flash[2], flash[3], source.locked, source.priority, source.focus, true); + const color: number[] = source.color || [0, 0, 0, 0]; + const tone: number[] = source.tone || [0, 0, 0, 0]; + const flash: number[] = source.flash || [0, 0, 0, 0]; + super( + source.x, + source.y, + source.zoomX, + source.zoomY, + source.angle, + source.mirror, + source.visible, + source.blendType, + source.graphicFrame, + source.opacity, + color[0], + color[1], + color[2], + color[3], + tone[0], + tone[1], + tone[2], + tone[3], + flash[0], + flash[1], + flash[2], + flash[3], + source.locked, + source.priority, + source.focus, + true, + ); this.target = source.target; this.graphicFrame = source.graphicFrame; } @@ -320,14 +360,14 @@ abstract class AnimTimedEvent { this.resourceName = resourceName; } - abstract execute(battleAnim: BattleAnim, priority?: number): number; + abstract execute(battleAnim: BattleAnim, priority?: number): number; - abstract getEventType(): string; + abstract getEventType(): string; } class AnimTimedSoundEvent extends AnimTimedEvent { - public volume: number = 100; - public pitch: number = 100; + public volume = 100; + public pitch = 100; constructor(frameIndex: number, resourceName: string, source?: any) { super(frameIndex, resourceName); @@ -338,8 +378,8 @@ class AnimTimedSoundEvent extends AnimTimedEvent { } } - execute(battleAnim: BattleAnim, priority?: number): number { - const soundConfig = { rate: (this.pitch * 0.01), volume: (this.volume * 0.01) }; + execute(battleAnim: BattleAnim): number { + const soundConfig = { rate: this.pitch * 0.01, volume: this.volume * 0.01 }; if (this.resourceName) { try { globalScene.playSound(`battle_anims/${this.resourceName}`, soundConfig); @@ -347,9 +387,8 @@ class AnimTimedSoundEvent extends AnimTimedEvent { console.error(err); } return Math.ceil((globalScene.sound.get(`battle_anims/${this.resourceName}`).totalDuration * 1000) / 33.33); - } else { - return Math.ceil((battleAnim.user!.cry(soundConfig).totalDuration * 1000) / 33.33); // TODO: is the bang behind user correct? } + return Math.ceil((battleAnim.user!.cry(soundConfig).totalDuration * 1000) / 33.33); // TODO: is the bang behind user correct? } getEventType(): string { @@ -358,14 +397,14 @@ class AnimTimedSoundEvent extends AnimTimedEvent { } abstract class AnimTimedBgEvent extends AnimTimedEvent { - public bgX: number = 0; - public bgY: number = 0; - public opacity: number = 0; + public bgX = 0; + public bgY = 0; + public opacity = 0; /*public colorRed: number = 0; public colorGreen: number = 0; public colorBlue: number = 0; public colorAlpha: number = 0;*/ - public duration: number = 0; + public duration = 0; /*public flashScope: number = 0; public flashRed: number = 0; public flashGreen: number = 0; @@ -373,7 +412,7 @@ abstract class AnimTimedBgEvent extends AnimTimedEvent { public flashAlpha: number = 0; public flashDuration: number = 0;*/ - constructor(frameIndex: number, resourceName: string, source: any) { + constructor(frameIndex: number, resourceName: string, source?: any) { super(frameIndex, resourceName); if (source) { @@ -396,26 +435,28 @@ abstract class AnimTimedBgEvent extends AnimTimedEvent { } class AnimTimedUpdateBgEvent extends AnimTimedBgEvent { - constructor(frameIndex: number, resourceName: string, source?: any) { - super(frameIndex, resourceName, source); - } - + // biome-ignore lint/correctness/noUnusedVariables: seems intentional execute(moveAnim: MoveAnim, priority?: number): number { const tweenProps = {}; if (this.bgX !== undefined) { - tweenProps["x"] = (this.bgX * 0.5) - 320; + tweenProps["x"] = this.bgX * 0.5 - 320; } if (this.bgY !== undefined) { - tweenProps["y"] = (this.bgY * 0.5) - 284; + tweenProps["y"] = this.bgY * 0.5 - 284; } if (this.opacity !== undefined) { tweenProps["alpha"] = (this.opacity || 0) / 255; } if (Object.keys(tweenProps).length) { - globalScene.tweens.add(Object.assign({ - targets: moveAnim.bgSprite, - duration: getFrameMs(this.duration * 3) - }, tweenProps)); + globalScene.tweens.add( + Object.assign( + { + targets: moveAnim.bgSprite, + duration: getFrameMs(this.duration * 3), + }, + tweenProps, + ), + ); } return this.duration * 2; } @@ -426,10 +467,6 @@ class AnimTimedUpdateBgEvent extends AnimTimedBgEvent { } class AnimTimedAddBgEvent extends AnimTimedBgEvent { - constructor(frameIndex: number, resourceName: string, source?: any) { - super(frameIndex, resourceName, source); - } - execute(moveAnim: MoveAnim, priority?: number): number { if (moveAnim.bgSprite) { moveAnim.bgSprite.destroy(); @@ -450,7 +487,7 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent { globalScene.tweens.add({ targets: moveAnim.bgSprite, - duration: getFrameMs(this.duration * 3) + duration: getFrameMs(this.duration * 3), }); return this.duration * 2; @@ -473,9 +510,12 @@ export function initCommonAnims(): Promise { const commonAnimFetches: Promise>[] = []; for (let ca = 0; ca < commonAnimIds.length; ca++) { const commonAnimId = commonAnimIds[ca]; - commonAnimFetches.push(globalScene.cachedFetch(`./battle-anims/common-${commonAnimNames[ca].toLowerCase().replace(/\_/g, "-")}.json`) - .then(response => response.json()) - .then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas)))); + commonAnimFetches.push( + globalScene + .cachedFetch(`./battle-anims/common-${commonAnimNames[ca].toLowerCase().replace(/\_/g, "-")}.json`) + .then(response => response.json()) + .then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))), + ); } Promise.allSettled(commonAnimFetches).then(() => resolve()); }); @@ -489,10 +529,9 @@ export function initMoveAnim(move: Moves): Promise { } else { const loadedCheckTimer = setInterval(() => { if (moveAnims.get(move) !== null) { - const chargeAnimSource = (allMoves[move].isChargingMove()) + const chargeAnimSource = allMoves[move].isChargingMove() ? allMoves[move] - : (allMoves[move].getAttrs(DelayedAttackAttr)[0] - ?? allMoves[move].getAttrs(BeakBlastHeaderAttr)[0]); + : (allMoves[move].getAttrs(DelayedAttackAttr)[0] ?? allMoves[move].getAttrs(BeakBlastHeaderAttr)[0]); if (chargeAnimSource && chargeAnims.get(chargeAnimSource.chargeAnim) === null) { return; } @@ -503,10 +542,16 @@ export function initMoveAnim(move: Moves): Promise { } } else { moveAnims.set(move, null); - const defaultMoveAnim = allMoves[move] instanceof AttackMove ? Moves.TACKLE : allMoves[move] instanceof SelfStatusMove ? Moves.FOCUS_ENERGY : Moves.TAIL_WHIP; + const defaultMoveAnim = + allMoves[move] instanceof AttackMove + ? Moves.TACKLE + : allMoves[move] instanceof SelfStatusMove + ? Moves.FOCUS_ENERGY + : Moves.TAIL_WHIP; const fetchAnimAndResolve = (move: Moves) => { - globalScene.cachedFetch(`./battle-anims/${animationFileName(move)}.json`) + globalScene + .cachedFetch(`./battle-anims/${animationFileName(move)}.json`) .then(response => { const contentType = response.headers.get("content-type"); if (!response.ok || contentType?.indexOf("application/json") === -1) { @@ -523,10 +568,9 @@ export function initMoveAnim(move: Moves): Promise { } else { populateMoveAnim(move, ba); } - const chargeAnimSource = (allMoves[move].isChargingMove()) + const chargeAnimSource = allMoves[move].isChargingMove() ? allMoves[move] - : (allMoves[move].getAttrs(DelayedAttackAttr)[0] - ?? allMoves[move].getAttrs(BeakBlastHeaderAttr)[0]); + : (allMoves[move].getAttrs(DelayedAttackAttr)[0] ?? allMoves[move].getAttrs(BeakBlastHeaderAttr)[0]); if (chargeAnimSource) { initMoveChargeAnim(chargeAnimSource.chargeAnim).then(() => resolve()); } else { @@ -572,16 +616,19 @@ function logMissingMoveAnim(move: Moves, ...optionalParams: any[]) { * @param encounterAnim one or more animations to fetch */ export async function initEncounterAnims(encounterAnim: EncounterAnim | EncounterAnim[]): Promise { - const anims = Array.isArray(encounterAnim) ? encounterAnim : [ encounterAnim ]; + const anims = Array.isArray(encounterAnim) ? encounterAnim : [encounterAnim]; const encounterAnimNames = getEnumKeys(EncounterAnim); const encounterAnimFetches: Promise>[] = []; for (const anim of anims) { if (encounterAnims.has(anim) && !isNullOrUndefined(encounterAnims.get(anim))) { continue; } - encounterAnimFetches.push(globalScene.cachedFetch(`./battle-anims/encounter-${encounterAnimNames[anim].toLowerCase().replace(/\_/g, "-")}.json`) - .then(response => response.json()) - .then(cas => encounterAnims.set(anim, new AnimConfig(cas)))); + encounterAnimFetches.push( + globalScene + .cachedFetch(`./battle-anims/encounter-${encounterAnimNames[anim].toLowerCase().replace(/\_/g, "-")}.json`) + .then(response => response.json()) + .then(cas => encounterAnims.set(anim, new AnimConfig(cas))), + ); } await Promise.allSettled(encounterAnimFetches); } @@ -601,7 +648,8 @@ export function initMoveChargeAnim(chargeAnim: ChargeAnim): Promise { } } else { chargeAnims.set(chargeAnim, null); - globalScene.cachedFetch(`./battle-anims/${ChargeAnim[chargeAnim].toLowerCase().replace(/\_/g, "-")}.json`) + globalScene + .cachedFetch(`./battle-anims/${ChargeAnim[chargeAnim].toLowerCase().replace(/\_/g, "-")}.json`) .then(response => response.json()) .then(ca => { if (Array.isArray(ca)) { @@ -622,7 +670,7 @@ function populateMoveAnim(move: Moves, animSource: any): void { moveAnims.set(move, moveAnim); return; } - moveAnims.set(move, [ moveAnims.get(move) as AnimConfig, moveAnim ]); + moveAnims.set(move, [moveAnims.get(move) as AnimConfig, moveAnim]); } function populateMoveChargeAnim(chargeAnim: ChargeAnim, animSource: any) { @@ -631,7 +679,7 @@ function populateMoveChargeAnim(chargeAnim: ChargeAnim, animSource: any) { chargeAnims.set(chargeAnim, moveChargeAnim); return; } - chargeAnims.set(chargeAnim, [ chargeAnims.get(chargeAnim) as AnimConfig, moveChargeAnim ]); + chargeAnims.set(chargeAnim, [chargeAnims.get(chargeAnim) as AnimConfig, moveChargeAnim]); } export function loadCommonAnimAssets(startLoad?: boolean): Promise { @@ -651,12 +699,11 @@ export async function loadEncounterAnimAssets(startLoad?: boolean): Promise { return new Promise(resolve => { - const moveAnimations = moveIds.map(m => moveAnims.get(m) as AnimConfig).flat(); + const moveAnimations = moveIds.flatMap(m => moveAnims.get(m) as AnimConfig); for (const moveId of moveIds) { - const chargeAnimSource = (allMoves[moveId].isChargingMove()) + const chargeAnimSource = allMoves[moveId].isChargingMove() ? allMoves[moveId] - : (allMoves[moveId].getAttrs(DelayedAttackAttr)[0] - ?? allMoves[moveId].getAttrs(BeakBlastHeaderAttr)[0]); + : (allMoves[moveId].getAttrs(DelayedAttackAttr)[0] ?? allMoves[moveId].getAttrs(BeakBlastHeaderAttr)[0]); if (chargeAnimSource) { const moveChargeAnims = chargeAnims.get(chargeAnimSource.chargeAnim); moveAnimations.push(moveChargeAnims instanceof AnimConfig ? moveChargeAnims : moveChargeAnims![0]); // TODO: is the bang correct? @@ -707,11 +754,11 @@ function loadAnimAssets(anims: AnimConfig[], startLoad?: boolean): Promise } interface GraphicFrameData { - x: number, - y: number, - scaleX: number, - scaleY: number, - angle: number + x: number; + y: number; + scaleX: number; + scaleY: number; + angle: number; } const userFocusX = 106; @@ -719,25 +766,43 @@ const userFocusY = 148 - 32; const targetFocusX = 234; const targetFocusY = 84 - 32; -function transformPoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, px: number, py: number): [ x: number, y: number ] { +function transformPoint( + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number, + x4: number, + y4: number, + px: number, + py: number, +): [x: number, y: number] { const yIntersect = yAxisIntersect(x1, y1, x2, y2, px, py); return repositionY(x3, y3, x4, y4, yIntersect[0], yIntersect[1]); } -function yAxisIntersect(x1: number, y1: number, x2: number, y2: number, px: number, py: number): [ x: number, y: number ] { +function yAxisIntersect( + x1: number, + y1: number, + x2: number, + y2: number, + px: number, + py: number, +): [x: number, y: number] { const dx = x2 - x1; const dy = y2 - y1; const x = dx === 0 ? 0 : (px - x1) / dx; const y = dy === 0 ? 0 : (py - y1) / dy; - return [ x, y ]; + return [x, y]; } -function repositionY(x1: number, y1: number, x2: number, y2: number, tx: number, ty: number): [ x: number, y: number ] { +function repositionY(x1: number, y1: number, x2: number, y2: number, tx: number, ty: number): [x: number, y: number] { const dx = x2 - x1; const dy = y2 - y1; - const x = x1 + (tx * dx); - const y = y1 + (ty * dy); - return [ x, y ]; + const x = x1 + tx * dx; + const y = y1 + ty * dy; + return [x, y]; } function isReversed(src1: number, src2: number, dst1: number, dst2: number) { @@ -751,7 +816,7 @@ function isReversed(src1: number, src2: number, dst1: number, dst2: number) { } interface SpriteCache { - [key: number]: Phaser.GameObjects.Sprite[] + [key: number]: Phaser.GameObjects.Sprite[]; } export abstract class BattleAnim { @@ -769,511 +834,590 @@ export abstract class BattleAnim { private srcLine: number[]; private dstLine: number[]; - constructor(user?: Pokemon, target?: Pokemon, playRegardlessOfIssues: boolean = false) { + constructor(user?: Pokemon, target?: Pokemon, playRegardlessOfIssues = false) { this.user = user ?? null; this.target = target ?? null; this.sprites = []; this.playRegardlessOfIssues = playRegardlessOfIssues; } - abstract getAnim(): AnimConfig | null; + abstract getAnim(): AnimConfig | null; - abstract isOppAnim(): boolean; + abstract isOppAnim(): boolean; - protected isHideUser(): boolean { - return false; - } + protected isHideUser(): boolean { + return false; + } - protected isHideTarget(): boolean { - return false; - } + protected isHideTarget(): boolean { + return false; + } - private getGraphicFrameData(frames: AnimFrame[], onSubstitute?: boolean): Map> { - const ret: Map> = new Map([ - [ AnimFrameTarget.GRAPHIC, new Map() ], - [ AnimFrameTarget.USER, new Map() ], - [ AnimFrameTarget.TARGET, new Map() ] - ]); + private getGraphicFrameData( + frames: AnimFrame[], + onSubstitute?: boolean, + ): Map> { + const ret: Map> = new Map([ + [AnimFrameTarget.GRAPHIC, new Map()], + [AnimFrameTarget.USER, new Map()], + [AnimFrameTarget.TARGET, new Map()], + ]); - const isOppAnim = this.isOppAnim(); - const user = !isOppAnim ? this.user : this.target; - const target = !isOppAnim ? this.target : this.user; + const isOppAnim = this.isOppAnim(); + const user = !isOppAnim ? this.user : this.target; + const target = !isOppAnim ? this.target : this.user; - const targetSubstitute = (onSubstitute && user !== target) ? target!.getTag(SubstituteTag) : null; + const targetSubstitute = onSubstitute && user !== target ? target!.getTag(SubstituteTag) : null; - const userInitialX = user!.x; // TODO: is this bang correct? - const userInitialY = user!.y; // TODO: is this bang correct? - const userHalfHeight = user!.getSprite().displayHeight! / 2; // TODO: is this bang correct? + const userInitialX = user!.x; // TODO: is this bang correct? + const userInitialY = user!.y; // TODO: is this bang correct? + const userHalfHeight = user!.getSprite().displayHeight! / 2; // TODO: is this bang correct? - const targetInitialX = targetSubstitute?.sprite?.x ?? target!.x; // TODO: is this bang correct? - const targetInitialY = targetSubstitute?.sprite?.y ?? target!.y; // TODO: is this bang correct? - const targetHalfHeight = (targetSubstitute?.sprite ?? target!.getSprite()).displayHeight! / 2; // TODO: is this bang correct? + const targetInitialX = targetSubstitute?.sprite?.x ?? target!.x; // TODO: is this bang correct? + const targetInitialY = targetSubstitute?.sprite?.y ?? target!.y; // TODO: is this bang correct? + const targetHalfHeight = (targetSubstitute?.sprite ?? target!.getSprite()).displayHeight! / 2; // TODO: is this bang correct? - let g = 0; - let u = 0; - let t = 0; + let g = 0; + let u = 0; + let t = 0; - for (const frame of frames) { - let x = frame.x + 106; - let y = frame.y + 116; - let scaleX = (frame.zoomX / 100) * (!frame.mirror ? 1 : -1); - const scaleY = (frame.zoomY / 100); - switch (frame.focus) { - case AnimFocus.TARGET: - x += targetInitialX - targetFocusX; - y += (targetInitialY - targetHalfHeight) - targetFocusY; - break; - case AnimFocus.USER: - x += userInitialX - userFocusX; - y += (userInitialY - userHalfHeight) - userFocusY; - break; - case AnimFocus.USER_TARGET: - const point = transformPoint(this.srcLine[0], this.srcLine[1], this.srcLine[2], this.srcLine[3], - this.dstLine[0], this.dstLine[1] - userHalfHeight, this.dstLine[2], this.dstLine[3] - targetHalfHeight, x, y); + for (const frame of frames) { + let x = frame.x + 106; + let y = frame.y + 116; + let scaleX = (frame.zoomX / 100) * (!frame.mirror ? 1 : -1); + const scaleY = frame.zoomY / 100; + switch (frame.focus) { + case AnimFocus.TARGET: + x += targetInitialX - targetFocusX; + y += targetInitialY - targetHalfHeight - targetFocusY; + break; + case AnimFocus.USER: + x += userInitialX - userFocusX; + y += userInitialY - userHalfHeight - userFocusY; + break; + case AnimFocus.USER_TARGET: + { + const point = transformPoint( + this.srcLine[0], + this.srcLine[1], + this.srcLine[2], + this.srcLine[3], + this.dstLine[0], + this.dstLine[1] - userHalfHeight, + this.dstLine[2], + this.dstLine[3] - targetHalfHeight, + x, + y, + ); x = point[0]; y = point[1]; - if (frame.target === AnimFrameTarget.GRAPHIC && isReversed(this.srcLine[0], this.srcLine[2], this.dstLine[0], this.dstLine[2])) { + if ( + frame.target === AnimFrameTarget.GRAPHIC && + isReversed(this.srcLine[0], this.srcLine[2], this.dstLine[0], this.dstLine[2]) + ) { scaleX = scaleX * -1; } - break; - } - const angle = -frame.angle; - const key = frame.target === AnimFrameTarget.GRAPHIC ? g++ : frame.target === AnimFrameTarget.USER ? u++ : t++; - ret.get(frame.target)!.set(key, { x: x, y: y, scaleX: scaleX, scaleY: scaleY, angle: angle }); // TODO: is the bang correct? + } + break; } - - return ret; + const angle = -frame.angle; + const key = frame.target === AnimFrameTarget.GRAPHIC ? g++ : frame.target === AnimFrameTarget.USER ? u++ : t++; + ret.get(frame.target)!.set(key, { x: x, y: y, scaleX: scaleX, scaleY: scaleY, angle: angle }); // TODO: is the bang correct? } - play(onSubstitute?: boolean, callback?: Function) { - const isOppAnim = this.isOppAnim(); - const user = !isOppAnim ? this.user! : this.target!; // TODO: are those bangs correct? - const target = !isOppAnim ? this.target! : this.user!; + return ret; + } - if (!target?.isOnField() && !this.playRegardlessOfIssues) { - if (callback) { - callback(); - } - return; + // biome-ignore lint/complexity/noBannedTypes: callback is used liberally + play(onSubstitute?: boolean, callback?: Function) { + const isOppAnim = this.isOppAnim(); + const user = !isOppAnim ? this.user! : this.target!; // TODO: are those bangs correct? + const target = !isOppAnim ? this.target! : this.user!; + + if (!target?.isOnField() && !this.playRegardlessOfIssues) { + if (callback) { + callback(); } - - const targetSubstitute = (!!onSubstitute && user !== target) ? target.getTag(SubstituteTag) : null; - - const userSprite = user.getSprite(); - const targetSprite = targetSubstitute?.sprite ?? target.getSprite(); - - const spriteCache: SpriteCache = { - [AnimFrameTarget.GRAPHIC]: [], - [AnimFrameTarget.USER]: [], - [AnimFrameTarget.TARGET]: [] - }; - const spritePriorities: number[] = []; - - const cleanUpAndComplete = () => { - userSprite.setPosition(0, 0); - userSprite.setScale(1); - userSprite.setAlpha(1); - userSprite.pipelineData["tone"] = [ 0.0, 0.0, 0.0, 0.0 ]; - userSprite.setAngle(0); - if (!targetSubstitute) { - targetSprite.setPosition(0, 0); - targetSprite.setScale(1); - targetSprite.setAlpha(1); - } else { - targetSprite.setPosition( - target.x - target.getSubstituteOffset()[0], - target.y - target.getSubstituteOffset()[1] - ); - targetSprite.setScale(target.getSpriteScale() * (target.isPlayer() ? 0.5 : 1)); - targetSprite.setAlpha(1); - } - targetSprite.pipelineData["tone"] = [ 0.0, 0.0, 0.0, 0.0 ]; - targetSprite.setAngle(0); - - /** - * This and `targetSpriteToShow` are used to restore context lost - * from the `isOppAnim` swap. Using these references instead of `this.user` - * and `this.target` prevent the target's Substitute doll from disappearing - * after being the target of an animation. - */ - const userSpriteToShow = !isOppAnim ? userSprite : targetSprite; - const targetSpriteToShow = !isOppAnim ? targetSprite : userSprite; - if (!this.isHideUser() && userSpriteToShow) { - userSpriteToShow.setVisible(true); - } - if (!this.isHideTarget() && (targetSpriteToShow !== userSpriteToShow || !this.isHideUser())) { - targetSpriteToShow.setVisible(true); - } - for (const ms of Object.values(spriteCache).flat()) { - if (ms) { - ms.destroy(); - } - } - if (this.bgSprite) { - this.bgSprite.destroy(); - } - if (callback) { - callback(); - } - }; - - if (!globalScene.moveAnimations && !this.playRegardlessOfIssues) { - return cleanUpAndComplete(); - } - - const anim = this.getAnim(); - - const userInitialX = user.x; - const userInitialY = user.y; - const targetInitialX = targetSubstitute?.sprite?.x ?? target.x; - const targetInitialY = targetSubstitute?.sprite?.y ?? target.y; - - this.srcLine = [ userFocusX, userFocusY, targetFocusX, targetFocusY ]; - this.dstLine = [ userInitialX, userInitialY, targetInitialX, targetInitialY ]; - - let r = anim?.frames.length ?? 0; - let f = 0; - - globalScene.tweens.addCounter({ - duration: getFrameMs(3), - repeat: anim?.frames.length ?? 0, - onRepeat: () => { - if (!f) { - userSprite.setVisible(false); - targetSprite.setVisible(false); - } - - const spriteFrames = anim!.frames[f]; // TODO: is the bang correcT? - const frameData = this.getGraphicFrameData(anim!.frames[f], onSubstitute); // TODO: is the bang correct? - let u = 0; - let t = 0; - let g = 0; - for (const frame of spriteFrames) { - if (frame.target !== AnimFrameTarget.GRAPHIC) { - const isUser = frame.target === AnimFrameTarget.USER; - if (isUser && target === user) { - continue; - } else if (this.playRegardlessOfIssues && frame.target === AnimFrameTarget.TARGET && !target.isOnField()) { - continue; - } - const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET]; - const spriteSource = isUser ? userSprite : targetSprite; - if ((isUser ? u : t) === sprites.length) { - if (isUser || !targetSubstitute) { - const sprite = globalScene.addPokemonSprite(isUser ? user! : target, 0, 0, spriteSource!.texture, spriteSource!.frame.name, true); // TODO: are those bangs correct? - [ "spriteColors", "fusionSpriteColors" ].map(k => sprite.pipelineData[k] = (isUser ? user! : target).getSprite().pipelineData[k]); // TODO: are those bangs correct? - sprite.setPipelineData("spriteKey", (isUser ? user! : target).getBattleSpriteKey()); - sprite.setPipelineData("shiny", (isUser ? user : target).shiny); - sprite.setPipelineData("variant", (isUser ? user : target).variant); - sprite.setPipelineData("ignoreFieldPos", true); - spriteSource.on("animationupdate", (_anim, frame) => sprite.setFrame(frame.textureFrame)); - globalScene.field.add(sprite); - sprites.push(sprite); - } else { - const sprite = globalScene.addFieldSprite(spriteSource.x, spriteSource.y, spriteSource.texture); - spriteSource.on("animationupdate", (_anim, frame) => sprite.setFrame(frame.textureFrame)); - globalScene.field.add(sprite); - sprites.push(sprite); - } - } - - const spriteIndex = isUser ? u++ : t++; - const pokemonSprite = sprites[spriteIndex]; - const graphicFrameData = frameData.get(frame.target)!.get(spriteIndex)!; // TODO: are the bangs correct? - const spriteSourceScale = (isUser || !targetSubstitute) - ? spriteSource.parentContainer.scale - : target.getSpriteScale() * (target.isPlayer() ? 0.5 : 1); - pokemonSprite.setPosition(graphicFrameData.x, graphicFrameData.y - ((spriteSource.height / 2) * (spriteSourceScale - 1))); - - pokemonSprite.setAngle(graphicFrameData.angle); - pokemonSprite.setScale(graphicFrameData.scaleX * spriteSourceScale, graphicFrameData.scaleY * spriteSourceScale); - - pokemonSprite.setData("locked", frame.locked); - - pokemonSprite.setAlpha(frame.opacity / 255); - pokemonSprite.pipelineData["tone"] = frame.tone; - pokemonSprite.setVisible(frame.visible && (isUser ? user.visible : target.visible)); - pokemonSprite.setBlendMode(frame.blendType === AnimBlendType.NORMAL ? Phaser.BlendModes.NORMAL : frame.blendType === AnimBlendType.ADD ? Phaser.BlendModes.ADD : Phaser.BlendModes.DIFFERENCE); - } else { - const sprites = spriteCache[AnimFrameTarget.GRAPHIC]; - if (g === sprites.length) { - const newSprite: Phaser.GameObjects.Sprite = globalScene.addFieldSprite(0, 0, anim!.graphic, 1); // TODO: is the bang correct? - sprites.push(newSprite); - globalScene.field.add(newSprite); - spritePriorities.push(1); - } - - const graphicIndex = g++; - const moveSprite = sprites[graphicIndex]; - if (spritePriorities[graphicIndex] !== frame.priority) { - spritePriorities[graphicIndex] = frame.priority; - /** Move the position that the moveSprite is rendered in based on the priority. - * @param priority The priority level to draw the sprite. - * - 0: Draw the sprite in front of the pokemon on the field. - * - 1: Draw the sprite in front of the user pokemon. - * - 2: Draw the sprite in front of its `bgSprite` (if it has one), or its - * `AnimFocus` (if that is user/target), otherwise behind everything. - * - 3: Draw the sprite behind its `AnimFocus` (if that is user/target), otherwise in front of everything. - */ - const setSpritePriority = (priority: number) => { - /** The sprite we are moving the moveSprite in relation to */ - let targetSprite: Phaser.GameObjects.GameObject | nil; - /** The method that is being used to move the sprite.*/ - let moveFunc: ((sprite: Phaser.GameObjects.GameObject, target: Phaser.GameObjects.GameObject) => void) | - ((sprite: Phaser.GameObjects.GameObject) => void) = globalScene.field.bringToTop; - - if (priority === 0) { // Place the sprite in front of the pokemon on the field. - targetSprite = globalScene.getEnemyField().find(p => p) ?? globalScene.getPlayerField().find(p => p); - console.log(typeof targetSprite); - moveFunc = globalScene.field.moveBelow; - } else if (priority === 2 && this.bgSprite) { - moveFunc = globalScene.field.moveAbove; - targetSprite = this.bgSprite; - } else if (priority === 2 || priority === 3) { - moveFunc = priority === 2 ? globalScene.field.moveBelow : globalScene.field.moveAbove; - if (frame.focus === AnimFocus.USER) { - targetSprite = this.user; - } else if (frame.focus === AnimFocus.TARGET) { - targetSprite = this.target; - } - } - // If target sprite is not undefined and exists in the field container, then move the sprite using the moveFunc. - // Otherwise, default to just bringing it to the top. - targetSprite && globalScene.field.exists(targetSprite) ? moveFunc.bind(globalScene.field)(moveSprite as Phaser.GameObjects.GameObject, targetSprite) : globalScene.field.bringToTop(moveSprite as Phaser.GameObjects.GameObject); - }; - setSpritePriority(frame.priority); - } - moveSprite.setFrame(frame.graphicFrame); - //console.log(AnimFocus[frame.focus]); - - const graphicFrameData = frameData.get(frame.target)!.get(graphicIndex)!; // TODO: are those bangs correct? - moveSprite.setPosition(graphicFrameData.x, graphicFrameData.y); - moveSprite.setAngle(graphicFrameData.angle); - moveSprite.setScale(graphicFrameData.scaleX, graphicFrameData.scaleY); - - moveSprite.setAlpha(frame.opacity / 255); - moveSprite.setVisible(frame.visible); - moveSprite.setBlendMode(frame.blendType === AnimBlendType.NORMAL ? Phaser.BlendModes.NORMAL : frame.blendType === AnimBlendType.ADD ? Phaser.BlendModes.ADD : Phaser.BlendModes.DIFFERENCE); - } - } - if (anim?.frameTimedEvents.has(f)) { - const base = anim.frames.length - f; - // Bang is correct due to `has` check above, which cannot return true for an undefined / null `f` - for (const event of anim.frameTimedEvents.get(f)!) { - r = Math.max(base + event.execute(this), r); - } - } - const targets = getEnumValues(AnimFrameTarget); - for (const i of targets) { - const count = i === AnimFrameTarget.GRAPHIC ? g : i === AnimFrameTarget.USER ? u : t; - if (count < spriteCache[i].length) { - const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length); - for (const rs of spritesToRemove) { - if (!rs.getData("locked") as boolean) { - const spriteCacheIndex = spriteCache[i].indexOf(rs); - spriteCache[i].splice(spriteCacheIndex, 1); - if (i === AnimFrameTarget.GRAPHIC) { - spritePriorities.splice(spriteCacheIndex, 1); - } - rs.destroy(); - } - } - } - } - f++; - r--; - }, - onComplete: () => { - for (const ms of Object.values(spriteCache).flat()) { - if (ms && !ms.getData("locked")) { - ms.destroy(); - } - } - if (r) { - globalScene.tweens.addCounter({ - duration: getFrameMs(r), - onComplete: () => cleanUpAndComplete() - }); - } else { - cleanUpAndComplete(); - } - } - }); + return; } - private getGraphicFrameDataWithoutTarget(frames: AnimFrame[], targetInitialX: number, targetInitialY: number): Map> { - const ret: Map> = new Map([ - [ AnimFrameTarget.GRAPHIC, new Map() ], - [ AnimFrameTarget.USER, new Map() ], - [ AnimFrameTarget.TARGET, new Map() ] - ]); + const targetSubstitute = !!onSubstitute && user !== target ? target.getTag(SubstituteTag) : null; - let g = 0; - let u = 0; - let t = 0; + const userSprite = user.getSprite(); + const targetSprite = targetSubstitute?.sprite ?? target.getSprite(); - for (const frame of frames) { - let { x, y } = frame; - const scaleX = (frame.zoomX / 100) * (!frame.mirror ? 1 : -1); - const scaleY = (frame.zoomY / 100); - x += targetInitialX; - y += targetInitialY; - const angle = -frame.angle; - const key = frame.target === AnimFrameTarget.GRAPHIC ? g++ : frame.target === AnimFrameTarget.USER ? u++ : t++; - ret.get(frame.target)?.set(key, { x: x, y: y, scaleX: scaleX, scaleY: scaleY, angle: angle }); + const spriteCache: SpriteCache = { + [AnimFrameTarget.GRAPHIC]: [], + [AnimFrameTarget.USER]: [], + [AnimFrameTarget.TARGET]: [], + }; + const spritePriorities: number[] = []; + + const cleanUpAndComplete = () => { + userSprite.setPosition(0, 0); + userSprite.setScale(1); + userSprite.setAlpha(1); + userSprite.pipelineData["tone"] = [0.0, 0.0, 0.0, 0.0]; + userSprite.setAngle(0); + if (!targetSubstitute) { + targetSprite.setPosition(0, 0); + targetSprite.setScale(1); + targetSprite.setAlpha(1); + } else { + targetSprite.setPosition( + target.x - target.getSubstituteOffset()[0], + target.y - target.getSubstituteOffset()[1], + ); + targetSprite.setScale(target.getSpriteScale() * (target.isPlayer() ? 0.5 : 1)); + targetSprite.setAlpha(1); } + targetSprite.pipelineData["tone"] = [0.0, 0.0, 0.0, 0.0]; + targetSprite.setAngle(0); - return ret; + /** + * This and `targetSpriteToShow` are used to restore context lost + * from the `isOppAnim` swap. Using these references instead of `this.user` + * and `this.target` prevent the target's Substitute doll from disappearing + * after being the target of an animation. + */ + const userSpriteToShow = !isOppAnim ? userSprite : targetSprite; + const targetSpriteToShow = !isOppAnim ? targetSprite : userSprite; + if (!this.isHideUser() && userSpriteToShow) { + userSpriteToShow.setVisible(true); + } + if (!this.isHideTarget() && (targetSpriteToShow !== userSpriteToShow || !this.isHideUser())) { + targetSpriteToShow.setVisible(true); + } + for (const ms of Object.values(spriteCache).flat()) { + if (ms) { + ms.destroy(); + } + } + if (this.bgSprite) { + this.bgSprite.destroy(); + } + if (callback) { + callback(); + } + }; + + if (!globalScene.moveAnimations && !this.playRegardlessOfIssues) { + return cleanUpAndComplete(); } - /** - * @param targetInitialX - * @param targetInitialY - * @param frameTimeMult - * @param frameTimedEventPriority - * - 0 is behind all other sprites (except BG) - * - 1 on top of player field - * - 3 is on top of both fields - * - 5 is on top of player sprite - * @param callback - */ - playWithoutTargets(targetInitialX: number, targetInitialY: number, frameTimeMult: number, frameTimedEventPriority?: 0 | 1 | 3 | 5, callback?: Function) { - const spriteCache: SpriteCache = { - [AnimFrameTarget.GRAPHIC]: [], - [AnimFrameTarget.USER]: [], - [AnimFrameTarget.TARGET]: [] - }; + const anim = this.getAnim(); - const cleanUpAndComplete = () => { - for (const ms of Object.values(spriteCache).flat()) { - if (ms) { - ms.destroy(); - } + const userInitialX = user.x; + const userInitialY = user.y; + const targetInitialX = targetSubstitute?.sprite?.x ?? target.x; + const targetInitialY = targetSubstitute?.sprite?.y ?? target.y; + + this.srcLine = [userFocusX, userFocusY, targetFocusX, targetFocusY]; + this.dstLine = [userInitialX, userInitialY, targetInitialX, targetInitialY]; + + let r = anim?.frames.length ?? 0; + let f = 0; + + globalScene.tweens.addCounter({ + duration: getFrameMs(3), + repeat: anim?.frames.length ?? 0, + onRepeat: () => { + if (!f) { + userSprite.setVisible(false); + targetSprite.setVisible(false); } - if (this.bgSprite) { - this.bgSprite.destroy(); - } - if (callback) { - callback(); - } - }; - if (!globalScene.moveAnimations && !this.playRegardlessOfIssues) { - return cleanUpAndComplete(); - } - - const anim = this.getAnim(); - - this.srcLine = [ userFocusX, userFocusY, targetFocusX, targetFocusY ]; - this.dstLine = [ 150, 75, targetInitialX, targetInitialY ]; - - let totalFrames = anim!.frames.length; - let frameCount = 0; - - let existingFieldSprites = globalScene.field.getAll().slice(0); - - globalScene.tweens.addCounter({ - duration: getFrameMs(3) * frameTimeMult, - repeat: anim!.frames.length, - onRepeat: () => { - existingFieldSprites = globalScene.field.getAll().slice(0); - const spriteFrames = anim!.frames[frameCount]; - const frameData = this.getGraphicFrameDataWithoutTarget(anim!.frames[frameCount], targetInitialX, targetInitialY); - let graphicFrameCount = 0; - for (const frame of spriteFrames) { - if (frame.target !== AnimFrameTarget.GRAPHIC) { - console.log("Encounter animations do not support targets"); + const spriteFrames = anim!.frames[f]; // TODO: is the bang correcT? + const frameData = this.getGraphicFrameData(anim!.frames[f], onSubstitute); // TODO: is the bang correct? + let u = 0; + let t = 0; + let g = 0; + for (const frame of spriteFrames) { + if (frame.target !== AnimFrameTarget.GRAPHIC) { + const isUser = frame.target === AnimFrameTarget.USER; + if (isUser && target === user) { continue; } - - const sprites = spriteCache[AnimFrameTarget.GRAPHIC]; - if (graphicFrameCount === sprites.length) { - const newSprite: Phaser.GameObjects.Sprite = globalScene.addFieldSprite(0, 0, anim!.graphic, 1); - sprites.push(newSprite); - globalScene.field.add(newSprite); + if (this.playRegardlessOfIssues && frame.target === AnimFrameTarget.TARGET && !target.isOnField()) { + continue; + } + const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET]; + const spriteSource = isUser ? userSprite : targetSprite; + if ((isUser ? u : t) === sprites.length) { + if (isUser || !targetSubstitute) { + const sprite = globalScene.addPokemonSprite( + isUser ? user! : target, + 0, + 0, + spriteSource!.texture, + spriteSource!.frame.name, + true, + ); // TODO: are those bangs correct? + ["spriteColors", "fusionSpriteColors"].map( + k => (sprite.pipelineData[k] = (isUser ? user! : target).getSprite().pipelineData[k]), + ); // TODO: are those bangs correct? + sprite.setPipelineData("spriteKey", (isUser ? user! : target).getBattleSpriteKey()); + sprite.setPipelineData("shiny", (isUser ? user : target).shiny); + sprite.setPipelineData("variant", (isUser ? user : target).variant); + sprite.setPipelineData("ignoreFieldPos", true); + spriteSource.on("animationupdate", (_anim, frame) => sprite.setFrame(frame.textureFrame)); + globalScene.field.add(sprite); + sprites.push(sprite); + } else { + const sprite = globalScene.addFieldSprite(spriteSource.x, spriteSource.y, spriteSource.texture); + spriteSource.on("animationupdate", (_anim, frame) => sprite.setFrame(frame.textureFrame)); + globalScene.field.add(sprite); + sprites.push(sprite); + } } - const graphicIndex = graphicFrameCount++; + const spriteIndex = isUser ? u++ : t++; + const pokemonSprite = sprites[spriteIndex]; + const graphicFrameData = frameData.get(frame.target)!.get(spriteIndex)!; // TODO: are the bangs correct? + const spriteSourceScale = + isUser || !targetSubstitute + ? spriteSource.parentContainer.scale + : target.getSpriteScale() * (target.isPlayer() ? 0.5 : 1); + pokemonSprite.setPosition( + graphicFrameData.x, + graphicFrameData.y - (spriteSource.height / 2) * (spriteSourceScale - 1), + ); + + pokemonSprite.setAngle(graphicFrameData.angle); + pokemonSprite.setScale( + graphicFrameData.scaleX * spriteSourceScale, + graphicFrameData.scaleY * spriteSourceScale, + ); + + pokemonSprite.setData("locked", frame.locked); + + pokemonSprite.setAlpha(frame.opacity / 255); + pokemonSprite.pipelineData["tone"] = frame.tone; + pokemonSprite.setVisible(frame.visible && (isUser ? user.visible : target.visible)); + pokemonSprite.setBlendMode( + frame.blendType === AnimBlendType.NORMAL + ? Phaser.BlendModes.NORMAL + : frame.blendType === AnimBlendType.ADD + ? Phaser.BlendModes.ADD + : Phaser.BlendModes.DIFFERENCE, + ); + } else { + const sprites = spriteCache[AnimFrameTarget.GRAPHIC]; + if (g === sprites.length) { + const newSprite: Phaser.GameObjects.Sprite = globalScene.addFieldSprite(0, 0, anim!.graphic, 1); // TODO: is the bang correct? + sprites.push(newSprite); + globalScene.field.add(newSprite); + spritePriorities.push(1); + } + + const graphicIndex = g++; const moveSprite = sprites[graphicIndex]; - if (!isNullOrUndefined(frame.priority)) { + if (spritePriorities[graphicIndex] !== frame.priority) { + spritePriorities[graphicIndex] = frame.priority; + /** Move the position that the moveSprite is rendered in based on the priority. + * @param priority The priority level to draw the sprite. + * - 0: Draw the sprite in front of the pokemon on the field. + * - 1: Draw the sprite in front of the user pokemon. + * - 2: Draw the sprite in front of its `bgSprite` (if it has one), or its + * `AnimFocus` (if that is user/target), otherwise behind everything. + * - 3: Draw the sprite behind its `AnimFocus` (if that is user/target), otherwise in front of everything. + */ const setSpritePriority = (priority: number) => { - if (existingFieldSprites.length > priority) { - // Move to specified priority index - const index = globalScene.field.getIndex(existingFieldSprites[priority]); - globalScene.field.moveTo(moveSprite, index); - } else { - // Move to top of scene - globalScene.field.moveTo(moveSprite, globalScene.field.getAll().length - 1); + /** The sprite we are moving the moveSprite in relation to */ + let targetSprite: Phaser.GameObjects.GameObject | nil; + /** The method that is being used to move the sprite.*/ + let moveFunc: + | ((sprite: Phaser.GameObjects.GameObject, target: Phaser.GameObjects.GameObject) => void) + | ((sprite: Phaser.GameObjects.GameObject) => void) = globalScene.field.bringToTop; + + if (priority === 0) { + // Place the sprite in front of the pokemon on the field. + targetSprite = globalScene.getEnemyField().find(p => p) ?? globalScene.getPlayerField().find(p => p); + console.log(typeof targetSprite); + moveFunc = globalScene.field.moveBelow; + } else if (priority === 2 && this.bgSprite) { + moveFunc = globalScene.field.moveAbove; + targetSprite = this.bgSprite; + } else if (priority === 2 || priority === 3) { + moveFunc = priority === 2 ? globalScene.field.moveBelow : globalScene.field.moveAbove; + if (frame.focus === AnimFocus.USER) { + targetSprite = this.user; + } else if (frame.focus === AnimFocus.TARGET) { + targetSprite = this.target; + } } + // If target sprite is not undefined and exists in the field container, then move the sprite using the moveFunc. + // Otherwise, default to just bringing it to the top. + targetSprite && globalScene.field.exists(targetSprite) + ? moveFunc.bind(globalScene.field)(moveSprite as Phaser.GameObjects.GameObject, targetSprite) + : globalScene.field.bringToTop(moveSprite as Phaser.GameObjects.GameObject); }; setSpritePriority(frame.priority); } moveSprite.setFrame(frame.graphicFrame); + //console.log(AnimFocus[frame.focus]); - const graphicFrameData = frameData.get(frame.target)?.get(graphicIndex); - if (graphicFrameData) { - moveSprite.setPosition(graphicFrameData.x, graphicFrameData.y); - moveSprite.setAngle(graphicFrameData.angle); - moveSprite.setScale(graphicFrameData.scaleX, graphicFrameData.scaleY); + const graphicFrameData = frameData.get(frame.target)!.get(graphicIndex)!; // TODO: are those bangs correct? + moveSprite.setPosition(graphicFrameData.x, graphicFrameData.y); + moveSprite.setAngle(graphicFrameData.angle); + moveSprite.setScale(graphicFrameData.scaleX, graphicFrameData.scaleY); - moveSprite.setAlpha(frame.opacity / 255); - moveSprite.setVisible(frame.visible); - moveSprite.setBlendMode(frame.blendType === AnimBlendType.NORMAL ? Phaser.BlendModes.NORMAL : frame.blendType === AnimBlendType.ADD ? Phaser.BlendModes.ADD : Phaser.BlendModes.DIFFERENCE); - } + moveSprite.setAlpha(frame.opacity / 255); + moveSprite.setVisible(frame.visible); + moveSprite.setBlendMode( + frame.blendType === AnimBlendType.NORMAL + ? Phaser.BlendModes.NORMAL + : frame.blendType === AnimBlendType.ADD + ? Phaser.BlendModes.ADD + : Phaser.BlendModes.DIFFERENCE, + ); } - if (anim?.frameTimedEvents.get(frameCount)) { - const base = anim.frames.length - frameCount; - for (const event of anim.frameTimedEvents.get(frameCount)!) { - totalFrames = Math.max(base + event.execute(this, frameTimedEventPriority), totalFrames); - } + } + if (anim?.frameTimedEvents.has(f)) { + const base = anim.frames.length - f; + // Bang is correct due to `has` check above, which cannot return true for an undefined / null `f` + for (const event of anim.frameTimedEvents.get(f)!) { + r = Math.max(base + event.execute(this), r); } - const targets = getEnumValues(AnimFrameTarget); - for (const i of targets) { - const count = graphicFrameCount; - if (count < spriteCache[i].length) { - const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length); - for (const sprite of spritesToRemove) { - if (!sprite.getData("locked") as boolean) { - const spriteCacheIndex = spriteCache[i].indexOf(sprite); - spriteCache[i].splice(spriteCacheIndex, 1); - sprite.destroy(); + } + const targets = getEnumValues(AnimFrameTarget); + for (const i of targets) { + const count = i === AnimFrameTarget.GRAPHIC ? g : i === AnimFrameTarget.USER ? u : t; + if (count < spriteCache[i].length) { + const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length); + for (const rs of spritesToRemove) { + if (!rs.getData("locked") as boolean) { + const spriteCacheIndex = spriteCache[i].indexOf(rs); + spriteCache[i].splice(spriteCacheIndex, 1); + if (i === AnimFrameTarget.GRAPHIC) { + spritePriorities.splice(spriteCacheIndex, 1); } + rs.destroy(); } } } - frameCount++; - totalFrames--; - }, - onComplete: () => { - for (const sprite of Object.values(spriteCache).flat()) { - if (sprite && !sprite.getData("locked")) { - sprite.destroy(); - } - } - if (totalFrames) { - globalScene.tweens.addCounter({ - duration: getFrameMs(totalFrames), - onComplete: () => cleanUpAndComplete() - }); - } else { - cleanUpAndComplete(); + } + f++; + r--; + }, + onComplete: () => { + for (const ms of Object.values(spriteCache).flat()) { + if (ms && !ms.getData("locked")) { + ms.destroy(); } } + if (r) { + globalScene.tweens.addCounter({ + duration: getFrameMs(r), + onComplete: () => cleanUpAndComplete(), + }); + } else { + cleanUpAndComplete(); + } + }, + }); + } + + private getGraphicFrameDataWithoutTarget( + frames: AnimFrame[], + targetInitialX: number, + targetInitialY: number, + ): Map> { + const ret: Map> = new Map([ + [AnimFrameTarget.GRAPHIC, new Map()], + [AnimFrameTarget.USER, new Map()], + [AnimFrameTarget.TARGET, new Map()], + ]); + + let g = 0; + let u = 0; + let t = 0; + + for (const frame of frames) { + let { x, y } = frame; + const scaleX = (frame.zoomX / 100) * (!frame.mirror ? 1 : -1); + const scaleY = frame.zoomY / 100; + x += targetInitialX; + y += targetInitialY; + const angle = -frame.angle; + const key = frame.target === AnimFrameTarget.GRAPHIC ? g++ : frame.target === AnimFrameTarget.USER ? u++ : t++; + ret.get(frame.target)?.set(key, { + x: x, + y: y, + scaleX: scaleX, + scaleY: scaleY, + angle: angle, }); } + + return ret; + } + + /** + * @param targetInitialX + * @param targetInitialY + * @param frameTimeMult + * @param frameTimedEventPriority + * - 0 is behind all other sprites (except BG) + * - 1 on top of player field + * - 3 is on top of both fields + * - 5 is on top of player sprite + * @param callback + */ + playWithoutTargets( + targetInitialX: number, + targetInitialY: number, + frameTimeMult: number, + frameTimedEventPriority?: 0 | 1 | 3 | 5, + // biome-ignore lint/complexity/noBannedTypes: callback is used liberally + callback?: Function, + ) { + const spriteCache: SpriteCache = { + [AnimFrameTarget.GRAPHIC]: [], + [AnimFrameTarget.USER]: [], + [AnimFrameTarget.TARGET]: [], + }; + + const cleanUpAndComplete = () => { + for (const ms of Object.values(spriteCache).flat()) { + if (ms) { + ms.destroy(); + } + } + if (this.bgSprite) { + this.bgSprite.destroy(); + } + if (callback) { + callback(); + } + }; + + if (!globalScene.moveAnimations && !this.playRegardlessOfIssues) { + return cleanUpAndComplete(); + } + + const anim = this.getAnim(); + + this.srcLine = [userFocusX, userFocusY, targetFocusX, targetFocusY]; + this.dstLine = [150, 75, targetInitialX, targetInitialY]; + + let totalFrames = anim!.frames.length; + let frameCount = 0; + + let existingFieldSprites = globalScene.field.getAll().slice(0); + + globalScene.tweens.addCounter({ + duration: getFrameMs(3) * frameTimeMult, + repeat: anim!.frames.length, + onRepeat: () => { + existingFieldSprites = globalScene.field.getAll().slice(0); + const spriteFrames = anim!.frames[frameCount]; + const frameData = this.getGraphicFrameDataWithoutTarget( + anim!.frames[frameCount], + targetInitialX, + targetInitialY, + ); + let graphicFrameCount = 0; + for (const frame of spriteFrames) { + if (frame.target !== AnimFrameTarget.GRAPHIC) { + console.log("Encounter animations do not support targets"); + continue; + } + + const sprites = spriteCache[AnimFrameTarget.GRAPHIC]; + if (graphicFrameCount === sprites.length) { + const newSprite: Phaser.GameObjects.Sprite = globalScene.addFieldSprite(0, 0, anim!.graphic, 1); + sprites.push(newSprite); + globalScene.field.add(newSprite); + } + + const graphicIndex = graphicFrameCount++; + const moveSprite = sprites[graphicIndex]; + if (!isNullOrUndefined(frame.priority)) { + const setSpritePriority = (priority: number) => { + if (existingFieldSprites.length > priority) { + // Move to specified priority index + const index = globalScene.field.getIndex(existingFieldSprites[priority]); + globalScene.field.moveTo(moveSprite, index); + } else { + // Move to top of scene + globalScene.field.moveTo(moveSprite, globalScene.field.getAll().length - 1); + } + }; + setSpritePriority(frame.priority); + } + moveSprite.setFrame(frame.graphicFrame); + + const graphicFrameData = frameData.get(frame.target)?.get(graphicIndex); + if (graphicFrameData) { + moveSprite.setPosition(graphicFrameData.x, graphicFrameData.y); + moveSprite.setAngle(graphicFrameData.angle); + moveSprite.setScale(graphicFrameData.scaleX, graphicFrameData.scaleY); + + moveSprite.setAlpha(frame.opacity / 255); + moveSprite.setVisible(frame.visible); + moveSprite.setBlendMode( + frame.blendType === AnimBlendType.NORMAL + ? Phaser.BlendModes.NORMAL + : frame.blendType === AnimBlendType.ADD + ? Phaser.BlendModes.ADD + : Phaser.BlendModes.DIFFERENCE, + ); + } + } + if (anim?.frameTimedEvents.get(frameCount)) { + const base = anim.frames.length - frameCount; + for (const event of anim.frameTimedEvents.get(frameCount)!) { + totalFrames = Math.max(base + event.execute(this, frameTimedEventPriority), totalFrames); + } + } + const targets = getEnumValues(AnimFrameTarget); + for (const i of targets) { + const count = graphicFrameCount; + if (count < spriteCache[i].length) { + const spritesToRemove = spriteCache[i].slice(count, spriteCache[i].length); + for (const sprite of spritesToRemove) { + if (!sprite.getData("locked") as boolean) { + const spriteCacheIndex = spriteCache[i].indexOf(sprite); + spriteCache[i].splice(spriteCacheIndex, 1); + sprite.destroy(); + } + } + } + } + frameCount++; + totalFrames--; + }, + onComplete: () => { + for (const sprite of Object.values(spriteCache).flat()) { + if (sprite && !sprite.getData("locked")) { + sprite.destroy(); + } + } + if (totalFrames) { + globalScene.tweens.addCounter({ + duration: getFrameMs(totalFrames), + onComplete: () => cleanUpAndComplete(), + }); + } else { + cleanUpAndComplete(); + } + }, + }); + } } export class CommonBattleAnim extends BattleAnim { public commonAnim: CommonAnim | null; - constructor(commonAnim: CommonAnim | null, user: Pokemon, target?: Pokemon, playOnEmptyField: boolean = false) { + constructor(commonAnim: CommonAnim | null, user: Pokemon, target?: Pokemon, playOnEmptyField = false) { super(user, target || user, playOnEmptyField); this.commonAnim = commonAnim; } getAnim(): AnimConfig | null { - return this.commonAnim ? commonAnims.get(this.commonAnim) ?? null : null; + return this.commonAnim ? (commonAnims.get(this.commonAnim) ?? null) : null; } isOppAnim(): boolean { @@ -1284,7 +1428,7 @@ export class CommonBattleAnim extends BattleAnim { export class MoveAnim extends BattleAnim { public move: Moves; - constructor(move: Moves, user: Pokemon, target: BattlerIndex, playOnEmptyField: boolean = false) { + constructor(move: Moves, user: Pokemon, target: BattlerIndex, playOnEmptyField = false) { super(user, globalScene.getField()[target], playOnEmptyField); this.move = move; @@ -1292,8 +1436,8 @@ export class MoveAnim extends BattleAnim { getAnim(): AnimConfig { return moveAnims.get(this.move) instanceof AnimConfig - ? moveAnims.get(this.move) as AnimConfig - : moveAnims.get(this.move)?.[this.user?.isPlayer() ? 0 : 1] as AnimConfig; + ? (moveAnims.get(this.move) as AnimConfig) + : (moveAnims.get(this.move)?.[this.user?.isPlayer() ? 0 : 1] as AnimConfig); } isOppAnim(): boolean { @@ -1324,8 +1468,8 @@ export class MoveChargeAnim extends MoveAnim { getAnim(): AnimConfig { return chargeAnims.get(this.chargeAnim) instanceof AnimConfig - ? chargeAnims.get(this.chargeAnim) as AnimConfig - : chargeAnims.get(this.chargeAnim)?.[this.user?.isPlayer() ? 0 : 1] as AnimConfig; + ? (chargeAnims.get(this.chargeAnim) as AnimConfig) + : (chargeAnims.get(this.chargeAnim)?.[this.user?.isPlayer() ? 0 : 1] as AnimConfig); } } @@ -1363,9 +1507,9 @@ export async function populateAnims() { moveNameToId[moveName] = move; } - const seNames: string[] = [];//(await fs.readdir('./public/audio/se/battle_anims/')).map(se => se.toString()); + const seNames: string[] = []; //(await fs.readdir('./public/audio/se/battle_anims/')).map(se => se.toString()); - const animsData : any[] = [];//battleAnimRawData.split('!ruby/array:PBAnimation').slice(1); // TODO: add a proper type + const animsData: any[] = []; //battleAnimRawData.split('!ruby/array:PBAnimation').slice(1); // TODO: add a proper type for (let a = 0; a < animsData.length; a++) { const fields = animsData[a].split("@").slice(1); @@ -1396,51 +1540,84 @@ export async function populateAnims() { if (commonAnimId) { commonAnims.set(commonAnimId, anim); } else if (chargeAnimId) { - chargeAnims.set(chargeAnimId, !isOppMove ? anim : [ chargeAnims.get(chargeAnimId) as AnimConfig, anim ]); + chargeAnims.set(chargeAnimId, !isOppMove ? anim : [chargeAnims.get(chargeAnimId) as AnimConfig, anim]); } else { - moveAnims.set(moveNameToId[animName], !isOppMove ? anim as AnimConfig : [ moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig ]); + moveAnims.set( + moveNameToId[animName], + !isOppMove ? (anim as AnimConfig) : [moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig], + ); } for (let f = 0; f < fields.length; f++) { const field = fields[f]; const fieldName = field.slice(0, field.indexOf(":")); const fieldData = field.slice(fieldName.length + 1, field.lastIndexOf("\n")).trim(); switch (fieldName) { - case "array": + case "array": { const framesData = fieldData.split(" - - - ").slice(1); for (let fd = 0; fd < framesData.length; fd++) { anim.frames.push([]); const frameData = framesData[fd]; const focusFramesData = frameData.split(" - - "); for (let tf = 0; tf < focusFramesData.length; tf++) { - const values = focusFramesData[tf].replace(/ \- /g, "").split("\n"); - const targetFrame = new AnimFrame(parseFloat(values[0]), parseFloat(values[1]), parseFloat(values[2]), parseFloat(values[11]), parseFloat(values[3]), - parseInt(values[4]) === 1, parseInt(values[6]) === 1, parseInt(values[5]), parseInt(values[7]), parseInt(values[8]), parseInt(values[12]), parseInt(values[13]), - parseInt(values[14]), parseInt(values[15]), parseInt(values[16]), parseInt(values[17]), parseInt(values[18]), parseInt(values[19]), - parseInt(values[21]), parseInt(values[22]), parseInt(values[23]), parseInt(values[24]), parseInt(values[20]) === 1, parseInt(values[25]), parseInt(values[26]) as AnimFocus); + const values = focusFramesData[tf].replace(/ {6}\- /g, "").split("\n"); + const targetFrame = new AnimFrame( + Number.parseFloat(values[0]), + Number.parseFloat(values[1]), + Number.parseFloat(values[2]), + Number.parseFloat(values[11]), + Number.parseFloat(values[3]), + Number.parseInt(values[4]) === 1, + Number.parseInt(values[6]) === 1, + Number.parseInt(values[5]), + Number.parseInt(values[7]), + Number.parseInt(values[8]), + Number.parseInt(values[12]), + Number.parseInt(values[13]), + Number.parseInt(values[14]), + Number.parseInt(values[15]), + Number.parseInt(values[16]), + Number.parseInt(values[17]), + Number.parseInt(values[18]), + Number.parseInt(values[19]), + Number.parseInt(values[21]), + Number.parseInt(values[22]), + Number.parseInt(values[23]), + Number.parseInt(values[24]), + Number.parseInt(values[20]) === 1, + Number.parseInt(values[25]), + Number.parseInt(values[26]) as AnimFocus, + ); anim.frames[fd].push(targetFrame); } } break; - case "graphic": + } + case "graphic": { const graphic = fieldData !== "''" ? fieldData : ""; - anim.graphic = graphic.indexOf(".") > -1 - ? graphic.slice(0, fieldData.indexOf(".")) - : graphic; + anim.graphic = graphic.indexOf(".") > -1 ? graphic.slice(0, fieldData.indexOf(".")) : graphic; break; - case "timing": + } + case "timing": { const timingEntries = fieldData.split("- !ruby/object:PBAnimTiming ").slice(1); for (let t = 0; t < timingEntries.length; t++) { - const timingData = timingEntries[t].replace(/\n/g, " ").replace(/[ ]{2,}/g, " ").replace(/[a-z]+: ! '', /ig, "").replace(/name: (.*?),/, "name: \"$1\",") - .replace(/flashColor: !ruby\/object:Color { alpha: ([\d\.]+), blue: ([\d\.]+), green: ([\d\.]+), red: ([\d\.]+)}/, "flashRed: $4, flashGreen: $3, flashBlue: $2, flashAlpha: $1"); - const frameIndex = parseInt(/frame: (\d+)/.exec(timingData)![1]); // TODO: is the bang correct? + const timingData = timingEntries[t] + .replace(/\n/g, " ") + .replace(/[ ]{2,}/g, " ") + .replace(/[a-z]+: ! '', /gi, "") + .replace(/name: (.*?),/, 'name: "$1",') + .replace( + /flashColor: !ruby\/object:Color { alpha: ([\d\.]+), blue: ([\d\.]+), green: ([\d\.]+), red: ([\d\.]+)}/, + "flashRed: $4, flashGreen: $3, flashBlue: $2, flashAlpha: $1", + ); + const frameIndex = Number.parseInt(/frame: (\d+)/.exec(timingData)![1]); // TODO: is the bang correct? let resourceName = /name: "(.*?)"/.exec(timingData)![1].replace("''", ""); // TODO: is the bang correct? - const timingType = parseInt(/timingType: (\d)/.exec(timingData)![1]); // TODO: is the bang correct? + const timingType = Number.parseInt(/timingType: (\d)/.exec(timingData)![1]); // TODO: is the bang correct? let timedEvent: AnimTimedEvent | undefined; switch (timingType) { case 0: if (resourceName && resourceName.indexOf(".") === -1) { let ext: string | undefined; - [ "wav", "mp3", "m4a" ].every(e => { + ["wav", "mp3", "m4a"].every(e => { if (seNames.indexOf(`${resourceName}.${e}`) > -1) { ext = e; return false; @@ -1464,15 +1641,16 @@ export async function populateAnims() { if (!timedEvent) { continue; } - const propPattern = /([a-z]+): (.*?)(?:,|\})/ig; + const propPattern = /([a-z]+): (.*?)(?:,|\})/gi; let propMatch: RegExpExecArray; - while ((propMatch = propPattern.exec(timingData)!)) { // TODO: is this bang correct? + while ((propMatch = propPattern.exec(timingData)!)) { + // TODO: is this bang correct? const prop = propMatch[1]; let value: any = propMatch[2]; switch (prop) { case "bgX": case "bgY": - value = parseFloat(value); + value = Number.parseFloat(value); break; case "volume": case "pitch": @@ -1488,7 +1666,7 @@ export async function populateAnims() { case "flashBlue": case "flashAlpha": case "flashDuration": - value = parseInt(value); + value = Number.parseInt(value); break; } if (timedEvent.hasOwnProperty(prop)) { @@ -1498,21 +1676,21 @@ export async function populateAnims() { if (!anim.frameTimedEvents.has(frameIndex)) { anim.frameTimedEvents.set(frameIndex, []); } - anim.frameTimedEvents.get(frameIndex)!.push(timedEvent); // TODO: is this bang correct? + anim.frameTimedEvents.get(frameIndex)!.push(timedEvent); // TODO: is this bang correct? } break; + } case "position": - anim.position = parseInt(fieldData); + anim.position = Number.parseInt(fieldData); break; case "hue": - anim.hue = parseInt(fieldData); + anim.hue = Number.parseInt(fieldData); break; } } } - // used in commented code - // eslint-disable-next-line @typescript-eslint/no-unused-vars + // biome-ignore lint/correctness/noUnusedVariables: used in commented code const animReplacer = (k, v) => { if (k === "id" && !v) { return undefined; @@ -1526,12 +1704,29 @@ export async function populateAnims() { return v; }; - const animConfigProps = [ "id", "graphic", "frames", "frameTimedEvents", "position", "hue" ]; - const animFrameProps = [ "x", "y", "zoomX", "zoomY", "angle", "mirror", "visible", "blendType", "target", "graphicFrame", "opacity", "color", "tone", "flash", "locked", "priority", "focus" ]; - const propSets = [ animConfigProps, animFrameProps ]; + const animConfigProps = ["id", "graphic", "frames", "frameTimedEvents", "position", "hue"]; + const animFrameProps = [ + "x", + "y", + "zoomX", + "zoomY", + "angle", + "mirror", + "visible", + "blendType", + "target", + "graphicFrame", + "opacity", + "color", + "tone", + "flash", + "locked", + "priority", + "focus", + ]; + const propSets = [animConfigProps, animFrameProps]; - // used in commented code - // eslint-disable-next-line @typescript-eslint/no-unused-vars + // biome-ignore lint/correctness/noUnusedVariables: used in commented code const animComparator = (a: Element, b: Element) => { let props: string[]; for (let p = 0; p < propSets.length; p++) { diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 4a8c48d5e71..43a7072fd12 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -5,7 +5,7 @@ import { BlockNonDirectDamageAbAttr, FlinchEffectAbAttr, ProtectStatAbAttr, - ReverseDrainAbAttr + ReverseDrainAbAttr, } from "#app/data/ability"; import { ChargeAnim, CommonAnim, CommonBattleAnim, MoveChargeAnim } from "#app/data/battle-anims"; import type Move from "#app/data/moves/move"; @@ -14,7 +14,7 @@ import { applyMoveAttrs, ConsecutiveUseDoublePowerAttr, HealOnAllyAttr, - StatusCategoryOnAllyAttr + StatusCategoryOnAllyAttr, } from "#app/data/moves/move"; import { MoveFlags } from "#enums/MoveFlags"; import { MoveCategory } from "#enums/MoveCategory"; @@ -53,7 +53,7 @@ export enum BattlerTagLapseType { TURN_END, HIT, AFTER_HIT, - CUSTOM + CUSTOM, } export class BattlerTag { @@ -64,26 +64,33 @@ export class BattlerTag { public sourceId?: number; public isBatonPassable: boolean; - constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType | BattlerTagLapseType[], turnCount: number, sourceMove?: Moves, sourceId?: number, isBatonPassable: boolean = false) { + constructor( + tagType: BattlerTagType, + lapseType: BattlerTagLapseType | BattlerTagLapseType[], + turnCount: number, + sourceMove?: Moves, + sourceId?: number, + isBatonPassable = false, + ) { this.tagType = tagType; - this.lapseTypes = Array.isArray(lapseType) ? lapseType : [ lapseType ]; + this.lapseTypes = Array.isArray(lapseType) ? lapseType : [lapseType]; this.turnCount = turnCount; this.sourceMove = sourceMove!; // TODO: is this bang correct? this.sourceId = sourceId; this.isBatonPassable = isBatonPassable; } - canAdd(pokemon: Pokemon): boolean { + canAdd(_pokemon: Pokemon): boolean { return true; } - onAdd(pokemon: Pokemon): void { } + onAdd(_pokemon: Pokemon): void {} - onRemove(pokemon: Pokemon): void { } + onRemove(_pokemon: Pokemon): void {} - onOverlap(pokemon: Pokemon): void { } + onOverlap(_pokemon: Pokemon): void {} - lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { + lapse(_pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean { return --this.turnCount > 0; } @@ -96,16 +103,14 @@ export class BattlerTag { } getMoveName(): string | null { - return this.sourceMove - ? allMoves[this.sourceMove].name - : null; + return this.sourceMove ? allMoves[this.sourceMove].name : null; } /** - * When given a battler tag or json representing one, load the data for it. - * This is meant to be inherited from by any battler tag with custom attributes - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * This is meant to be inherited from by any battler tag with custom attributes + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { this.turnCount = source.turnCount; this.sourceMove = source.sourceMove; @@ -138,7 +143,13 @@ export interface TerrainBattlerTag { * to select restricted moves. */ export abstract class MoveRestrictionBattlerTag extends BattlerTag { - constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType | BattlerTagLapseType[], turnCount: number, sourceMove?: Moves, sourceId?: number) { + constructor( + tagType: BattlerTagType, + lapseType: BattlerTagLapseType | BattlerTagLapseType[], + turnCount: number, + sourceMove?: Moves, + sourceId?: number, + ) { super(tagType, lapseType, turnCount, sourceMove, sourceId); } @@ -174,12 +185,12 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag { /** * Checks if this tag is restricting a move based on a user's decisions during the target selection phase * - * @param {Moves} move {@linkcode Moves} move ID to check restriction for - * @param {Pokemon} user {@linkcode Pokemon} the user of the above move - * @param {Pokemon} target {@linkcode Pokemon} the target of the above move + * @param {Moves} _move {@linkcode Moves} move ID to check restriction for + * @param {Pokemon} _user {@linkcode Pokemon} the user of the above move + * @param {Pokemon} _target {@linkcode Pokemon} the target of the above move * @returns {boolean} `false` unless overridden by the child tag */ - isMoveTargetRestricted(move: Moves, user: Pokemon, target: Pokemon): boolean { + isMoveTargetRestricted(_move: Moves, _user: Pokemon, _target: Pokemon): boolean { return false; } @@ -197,11 +208,11 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag { * Because restriction effects also prevent selection of the move, this situation can only arise if a * pokemon first selects a move, then gets outsped by a pokemon using a move that restricts the selected move. * - * @param {Pokemon} pokemon {@linkcode Pokemon} attempting to use the restricted move - * @param {Moves} move {@linkcode Moves} ID of the move being interrupted + * @param {Pokemon} _pokemon {@linkcode Pokemon} attempting to use the restricted move + * @param {Moves} _move {@linkcode Moves} ID of the move being interrupted * @returns {string} text to display when the move is interrupted */ - interruptedText(pokemon: Pokemon, move: Moves): string { + interruptedText(_pokemon: Pokemon, _move: Moves): string { return ""; } } @@ -213,7 +224,12 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag { */ export class ThroatChoppedTag extends MoveRestrictionBattlerTag { constructor() { - super(BattlerTagType.THROAT_CHOPPED, [ BattlerTagLapseType.TURN_END, BattlerTagLapseType.PRE_MOVE ], 2, Moves.THROAT_CHOP); + super( + BattlerTagType.THROAT_CHOPPED, + [BattlerTagLapseType.TURN_END, BattlerTagLapseType.PRE_MOVE], + 2, + Moves.THROAT_CHOP, + ); } /** @@ -229,23 +245,27 @@ export class ThroatChoppedTag extends MoveRestrictionBattlerTag { /** * Shows a message when the player attempts to select a move that is restricted by Throat Chop. * @override - * @param {Pokemon} pokemon the {@linkcode Pokemon} that is attempting to select the restricted move + * @param {Pokemon} _pokemon the {@linkcode Pokemon} that is attempting to select the restricted move * @param {Moves} move the {@linkcode Moves | move} that is being restricted * @returns the message to display when the player attempts to select the restricted move */ - override selectionDeniedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveCannotBeSelected", { moveName: allMoves[move].name }); + override selectionDeniedText(_pokemon: Pokemon, move: Moves): string { + return i18next.t("battle:moveCannotBeSelected", { + moveName: allMoves[move].name, + }); } /** * Shows a message when a move is interrupted by Throat Chop. * @override * @param {Pokemon} pokemon the interrupted {@linkcode Pokemon} - * @param {Moves} move the {@linkcode Moves | move} that was interrupted + * @param {Moves} _move the {@linkcode Moves | move} that was interrupted * @returns the message to display when the move is interrupted */ - override interruptedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:throatChopInterruptedMove", { pokemonName: getPokemonNameWithAffix(pokemon) }); + override interruptedText(pokemon: Pokemon, _move: Moves): string { + return i18next.t("battle:throatChopInterruptedMove", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } } @@ -258,7 +278,13 @@ export class DisabledTag extends MoveRestrictionBattlerTag { private moveId: Moves = Moves.NONE; constructor(sourceId: number) { - super(BattlerTagType.DISABLED, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 4, Moves.DISABLE, sourceId); + super( + BattlerTagType.DISABLED, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END], + 4, + Moves.DISABLE, + sourceId, + ); } /** @override */ @@ -275,26 +301,35 @@ export class DisabledTag extends MoveRestrictionBattlerTag { override onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - const move = pokemon.getLastXMoves(-1) - .find(m => !m.virtual); + const move = pokemon.getLastXMoves(-1).find(m => !m.virtual); if (Utils.isNullOrUndefined(move) || move.move === Moves.STRUGGLE || move.move === Moves.NONE) { return; } this.moveId = move.move; - globalScene.queueMessage(i18next.t("battlerTags:disabledOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[this.moveId].name })); + globalScene.queueMessage( + i18next.t("battlerTags:disabledOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[this.moveId].name, + }), + ); } /** @override */ override onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:disabledLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[this.moveId].name })); + globalScene.queueMessage( + i18next.t("battlerTags:disabledLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[this.moveId].name, + }), + ); } /** @override */ - override selectionDeniedText(pokemon: Pokemon, move: Moves): string { + override selectionDeniedText(_pokemon: Pokemon, move: Moves): string { return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name }); } @@ -305,7 +340,10 @@ export class DisabledTag extends MoveRestrictionBattlerTag { * @returns {string} text to display when the move is interrupted */ override interruptedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:disableInterruptedMove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name }); + return i18next.t("battle:disableInterruptedMove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + }); } /** @override */ @@ -337,7 +375,7 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag { * @returns `true` if the pokemon has a valid move and no existing {@linkcode GorillaTacticsTag}; `false` otherwise */ override canAdd(pokemon: Pokemon): boolean { - return (this.getLastValidMove(pokemon) !== undefined) && !pokemon.getTag(GorillaTacticsTag); + return this.getLastValidMove(pokemon) !== undefined && !pokemon.getTag(GorillaTacticsTag); } /** @@ -371,11 +409,14 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag { * * @override * @param {Pokemon} pokemon n/a - * @param {Moves} move {@linkcode Moves} ID of the move being denied + * @param {Moves} _move {@linkcode Moves} ID of the move being denied * @returns {string} text to display when the move is denied - */ - override selectionDeniedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:canOnlyUseMove", { moveName: allMoves[this.moveId].name, pokemonName: getPokemonNameWithAffix(pokemon) }); + */ + override selectionDeniedText(pokemon: Pokemon, _move: Moves): string { + return i18next.t("battle:canOnlyUseMove", { + moveName: allMoves[this.moveId].name, + pokemonName: getPokemonNameWithAffix(pokemon), + }); } /** @@ -384,8 +425,7 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag { * @returns {Moves | undefined} the last valid move from the pokemon's move history */ getLastValidMove(pokemon: Pokemon): Moves | undefined { - const move = pokemon.getLastXMoves() - .find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual); + const move = pokemon.getLastXMoves().find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual); return move?.move; } @@ -396,20 +436,24 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag { */ export class RechargingTag extends BattlerTag { constructor(sourceMove: Moves) { - super(BattlerTagType.RECHARGING, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 2, sourceMove); + super(BattlerTagType.RECHARGING, [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END], 2, sourceMove); } onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); // Queue a placeholder move for the Pokemon to "use" next turn - pokemon.getMoveQueue().push({ move: Moves.NONE, targets: []}); + pokemon.getMoveQueue().push({ move: Moves.NONE, targets: [] }); } /** Cancels the source's move this turn and queues a "__ must recharge!" message */ lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.PRE_MOVE) { - globalScene.queueMessage(i18next.t("battlerTags:rechargingLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:rechargingLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); (globalScene.getCurrentPhase() as MovePhase).cancel(); pokemon.getMoveQueue().shift(); } @@ -424,7 +468,12 @@ export class RechargingTag extends BattlerTag { */ export class BeakBlastChargingTag extends BattlerTag { constructor() { - super(BattlerTagType.BEAK_BLAST_CHARGING, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT ], 1, Moves.BEAK_BLAST); + super( + BattlerTagType.BEAK_BLAST_CHARGING, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT], + 1, + Moves.BEAK_BLAST, + ); } onAdd(pokemon: Pokemon): void { @@ -432,7 +481,11 @@ export class BeakBlastChargingTag extends BattlerTag { new MoveChargeAnim(ChargeAnim.BEAK_BLAST_CHARGING, this.sourceMove, pokemon).play(); // Queue Beak Blast's header message - globalScene.queueMessage(i18next.t("moveTriggers:startedHeatingUpBeak", { pokemonName: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("moveTriggers:startedHeatingUpBeak", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -460,14 +513,18 @@ export class BeakBlastChargingTag extends BattlerTag { * @see {@link https://bulbapedia.bulbagarden.net/wiki/Shell_Trap_(move) | Shell Trap} */ export class ShellTrapTag extends BattlerTag { - public activated: boolean = false; + public activated = false; constructor() { - super(BattlerTagType.SHELL_TRAP, [ BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT ], 1); + super(BattlerTagType.SHELL_TRAP, [BattlerTagLapseType.TURN_END, BattlerTagLapseType.AFTER_HIT], 1); } onAdd(pokemon: Pokemon): void { - globalScene.queueMessage(i18next.t("moveTriggers:setUpShellTrap", { pokemonName: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("moveTriggers:setUpShellTrap", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -483,11 +540,9 @@ export class ShellTrapTag extends BattlerTag { // Trap should only be triggered by opponent's Physical moves if (phaseData?.move.category === MoveCategory.PHYSICAL && pokemon.isOpponent(phaseData.attacker)) { const shellTrapPhaseIndex = globalScene.phaseQueue.findIndex( - phase => phase instanceof MovePhase && phase.pokemon === pokemon - ); - const firstMovePhaseIndex = globalScene.phaseQueue.findIndex( - phase => phase instanceof MovePhase + phase => phase instanceof MovePhase && phase.pokemon === pokemon, ); + const firstMovePhaseIndex = globalScene.phaseQueue.findIndex(phase => phase instanceof MovePhase); // Only shift MovePhase timing if it's not already next up if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) { @@ -506,7 +561,13 @@ export class ShellTrapTag extends BattlerTag { } export class TrappedTag extends BattlerTag { - constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, turnCount: number, sourceMove: Moves, sourceId: number) { + constructor( + tagType: BattlerTagType, + lapseType: BattlerTagLapseType, + turnCount: number, + sourceMove: Moves, + sourceId: number, + ) { super(tagType, lapseType, turnCount, sourceMove, sourceId, true); } @@ -530,10 +591,12 @@ export class TrappedTag extends BattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:trappedOnRemove", { - pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - moveName: this.getMoveName() - })); + globalScene.queueMessage( + i18next.t("battlerTags:trappedOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: this.getMoveName(), + }), + ); } getDescriptor(): string { @@ -545,7 +608,9 @@ export class TrappedTag extends BattlerTag { } getTrapMessage(pokemon: Pokemon): string { - return i18next.t("battlerTags:trappedOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlerTags:trappedOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } } @@ -571,7 +636,7 @@ class NoRetreatTag extends TrappedTag { */ export class FlinchedTag extends BattlerTag { constructor(sourceMove: Moves) { - super(BattlerTagType.FLINCHED, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 0, sourceMove); + super(BattlerTagType.FLINCHED, [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END], 0, sourceMove); } onAdd(pokemon: Pokemon): void { @@ -589,7 +654,11 @@ export class FlinchedTag extends BattlerTag { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.PRE_MOVE) { (globalScene.getCurrentPhase() as MovePhase).cancel(); - globalScene.queueMessage(i18next.t("battlerTags:flinchedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:flinchedLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } return super.lapse(pokemon, lapseType); @@ -613,7 +682,11 @@ export class InterruptedTag extends BattlerTag { super.onAdd(pokemon); pokemon.getMoveQueue().shift(); - pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.OTHER, targets: []}); + pokemon.pushMoveHistory({ + move: Moves.NONE, + result: MoveResult.OTHER, + targets: [], + }); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -638,33 +711,51 @@ export class ConfusedTag extends BattlerTag { super.onAdd(pokemon); globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), undefined, CommonAnim.CONFUSION)); - globalScene.queueMessage(i18next.t("battlerTags:confusedOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:confusedOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:confusedOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:confusedOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } onOverlap(pokemon: Pokemon): void { super.onOverlap(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:confusedOnOverlap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:confusedOnOverlap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { const ret = lapseType !== BattlerTagLapseType.CUSTOM && super.lapse(pokemon, lapseType); if (ret) { - globalScene.queueMessage(i18next.t("battlerTags:confusedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:confusedLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), undefined, CommonAnim.CONFUSION)); // 1/3 chance of hitting self with a 40 base power move if (pokemon.randSeedInt(3) === 0) { const atk = pokemon.getEffectiveStat(Stat.ATK); const def = pokemon.getEffectiveStat(Stat.DEF); - const damage = toDmgValue(((((2 * pokemon.level / 5 + 2) * 40 * atk / def) / 50) + 2) * (pokemon.randSeedIntRange(85, 100) / 100)); + const damage = toDmgValue( + ((((2 * pokemon.level) / 5 + 2) * 40 * atk) / def / 50 + 2) * (pokemon.randSeedIntRange(85, 100) / 100), + ); globalScene.queueMessage(i18next.t("battlerTags:confusedLapseHurtItself")); pokemon.damageAndUpdate(damage); pokemon.battleData.hitCount++; @@ -713,15 +804,19 @@ export class DestinyBondTag extends BattlerTag { } if (pokemon.isBossImmune()) { - globalScene.queueMessage(i18next.t("battlerTags:destinyBondLapseIsBoss", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:destinyBondLapseIsBoss", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); return false; } globalScene.queueMessage( i18next.t("battlerTags:destinyBondLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(source), - pokemonNameWithAffix2: getPokemonNameWithAffix(pokemon) - }) + pokemonNameWithAffix2: getPokemonNameWithAffix(pokemon), + }), ); pokemon.damageAndUpdate(pokemon.hp, HitResult.ONE_HIT_KO, false, false, true); return false; @@ -739,14 +834,12 @@ export class InfatuatedTag extends BattlerTag { if (pkm) { return pokemon.isOppositeGender(pkm); - } else { - console.warn("canAdd: this.sourceId is not a valid pokemon id!", this.sourceId); - return false; } - } else { - console.warn("canAdd: this.sourceId is undefined"); + console.warn("canAdd: this.sourceId is not a valid pokemon id!", this.sourceId); return false; } + console.warn("canAdd: this.sourceId is undefined"); + return false; } onAdd(pokemon: Pokemon): void { @@ -755,15 +848,19 @@ export class InfatuatedTag extends BattlerTag { globalScene.queueMessage( i18next.t("battlerTags:infatuatedOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined) // TODO: is that bang correct? - }) + sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct? + }), ); } onOverlap(pokemon: Pokemon): void { super.onOverlap(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:infatuatedOnOverlap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:infatuatedOnOverlap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -773,13 +870,17 @@ export class InfatuatedTag extends BattlerTag { globalScene.queueMessage( i18next.t("battlerTags:infatuatedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined) // TODO: is that bang correct? - }) + sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct? + }), ); globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), undefined, CommonAnim.ATTRACT)); if (pokemon.randSeedInt(2)) { - globalScene.queueMessage(i18next.t("battlerTags:infatuatedLapseImmobilize", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:infatuatedLapseImmobilize", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); (globalScene.getCurrentPhase() as MovePhase).cancel(); } } @@ -790,7 +891,11 @@ export class InfatuatedTag extends BattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:infatuatedOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:infatuatedOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } isSourceLinked(): boolean { @@ -810,9 +915,9 @@ export class SeedTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.sourceIndex = source.sourceIndex; @@ -825,7 +930,11 @@ export class SeedTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:seededOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:seededOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); this.sourceIndex = globalScene.getPokemonById(this.sourceId!)!.getBattlerIndex(); // TODO: are those bangs correct? } @@ -839,14 +948,27 @@ export class SeedTag extends BattlerTag { applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - globalScene.unshiftPhase(new CommonAnimPhase(source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.LEECH_SEED)); + globalScene.unshiftPhase( + new CommonAnimPhase(source.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.LEECH_SEED), + ); const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8)); const reverseDrain = pokemon.hasAbilityWithAttr(ReverseDrainAbAttr, false); - globalScene.unshiftPhase(new PokemonHealPhase(source.getBattlerIndex(), - !reverseDrain ? damage : damage * -1, - !reverseDrain ? i18next.t("battlerTags:seededLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }) : i18next.t("battlerTags:seededLapseShed", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), - false, true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + source.getBattlerIndex(), + !reverseDrain ? damage : damage * -1, + !reverseDrain + ? i18next.t("battlerTags:seededLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }) + : i18next.t("battlerTags:seededLapseShed", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + false, + true, + ), + ); } } } @@ -866,14 +988,18 @@ export class SeedTag extends BattlerTag { */ export class PowderTag extends BattlerTag { constructor() { - super(BattlerTagType.POWDER, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], 1); + super(BattlerTagType.POWDER, [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END], 1); } onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); // "{Pokemon} is covered in powder!" - globalScene.queueMessage(i18next.t("battlerTags:powderOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:powderOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -889,11 +1015,16 @@ export class PowderTag extends BattlerTag { if (movePhase instanceof MovePhase) { const move = movePhase.move.getMove(); const weather = globalScene.arena.weather; - if (pokemon.getMoveType(move) === PokemonType.FIRE && !(weather && weather.weatherType === WeatherType.HEAVY_RAIN && !weather.isEffectSuppressed())) { + if ( + pokemon.getMoveType(move) === PokemonType.FIRE && + !(weather && weather.weatherType === WeatherType.HEAVY_RAIN && !weather.isEffectSuppressed()) + ) { movePhase.fail(); movePhase.showMoveText(); - globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER)); + globalScene.unshiftPhase( + new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER), + ); const cancelDamage = new BooleanHolder(false); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelDamage); @@ -906,9 +1037,8 @@ export class PowderTag extends BattlerTag { } } return true; - } else { - return super.lapse(pokemon, lapseType); } + return super.lapse(pokemon, lapseType); } } @@ -920,20 +1050,32 @@ export class NightmareTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:nightmareOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:nightmareOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } onOverlap(pokemon: Pokemon): void { super.onOverlap(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:nightmareOnOverlap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:nightmareOnOverlap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); if (ret) { - globalScene.queueMessage(i18next.t("battlerTags:nightmareLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:nightmareLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), undefined, CommonAnim.CURSE)); // TODO: Update animation type const cancelled = new BooleanHolder(false); @@ -960,7 +1102,8 @@ export class FrenzyTag extends BattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - if (this.turnCount < 2) { // Only add CONFUSED tag if a disruption occurs on the final confusion-inducing turn of FRENZY + if (this.turnCount < 2) { + // Only add CONFUSED tag if a disruption occurs on the final confusion-inducing turn of FRENZY pokemon.addTag(BattlerTagType.CONFUSED, pokemon.randSeedIntRange(2, 4)); } } @@ -974,13 +1117,19 @@ export class EncoreTag extends MoveRestrictionBattlerTag { public moveId: Moves; constructor(sourceId: number) { - super(BattlerTagType.ENCORE, [ BattlerTagLapseType.CUSTOM, BattlerTagLapseType.AFTER_MOVE ], 3, Moves.ENCORE, sourceId); + super( + BattlerTagType.ENCORE, + [BattlerTagLapseType.CUSTOM, BattlerTagLapseType.AFTER_MOVE], + 3, + Moves.ENCORE, + sourceId, + ); } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.moveId = source.moveId as Moves; @@ -1017,15 +1166,21 @@ export class EncoreTag extends MoveRestrictionBattlerTag { onAdd(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:encoreOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:encoreOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); const movePhase = globalScene.findPhase(m => m instanceof MovePhase && m.pokemon === pokemon); if (movePhase) { const movesetMove = pokemon.getMoveset().find(m => m!.moveId === this.moveId); // TODO: is this bang correct? if (movesetMove) { const lastMove = pokemon.getLastXMoves(1)[0]; - globalScene.tryReplacePhase((m => m instanceof MovePhase && m.pokemon === pokemon), - new MovePhase(pokemon, lastMove.targets!, movesetMove)); // TODO: is this bang correct? + globalScene.tryReplacePhase( + m => m instanceof MovePhase && m.pokemon === pokemon, + new MovePhase(pokemon, lastMove.targets!, movesetMove), + ); // TODO: is this bang correct? } } } @@ -1041,9 +1196,8 @@ export class EncoreTag extends MoveRestrictionBattlerTag { return true; } return false; - } else { - return super.lapse(pokemon, lapseType); } + return super.lapse(pokemon, lapseType); } /** @@ -1066,7 +1220,11 @@ export class EncoreTag extends MoveRestrictionBattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:encoreOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:encoreOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -1079,8 +1237,8 @@ export class HelpingHandTag extends BattlerTag { globalScene.queueMessage( i18next.t("battlerTags:helpingHandOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct? - pokemonName: getPokemonNameWithAffix(pokemon) - }) + pokemonName: getPokemonNameWithAffix(pokemon), + }), ); } } @@ -1113,9 +1271,11 @@ export class IngrainTag extends TrappedTag { new PokemonHealPhase( pokemon.getBattlerIndex(), toDmgValue(pokemon.getMaxHp() / 16), - i18next.t("battlerTags:ingrainLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), - true - ) + i18next.t("battlerTags:ingrainLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + true, + ), ); } @@ -1123,7 +1283,9 @@ export class IngrainTag extends TrappedTag { } getTrapMessage(pokemon: Pokemon): string { - return i18next.t("battlerTags:ingrainOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlerTags:ingrainOnTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } getDescriptor(): string { @@ -1144,7 +1306,7 @@ export class OctolockTag extends TrappedTag { const shouldLapse = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); if (shouldLapse) { - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), false, [ Stat.DEF, Stat.SPDEF ], -1)); + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), false, [Stat.DEF, Stat.SPDEF], -1)); return true; } @@ -1160,7 +1322,11 @@ export class AquaRingTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:aquaRingOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:aquaRingOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -1173,9 +1339,11 @@ export class AquaRingTag extends BattlerTag { toDmgValue(pokemon.getMaxHp() / 16), i18next.t("battlerTags:aquaRingLapse", { moveName: this.getMoveName(), - pokemonName: getPokemonNameWithAffix(pokemon) + pokemonName: getPokemonNameWithAffix(pokemon), }), - true)); + true, + ), + ); } return ret; @@ -1213,7 +1381,11 @@ export class DrowsyTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:drowsyOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:drowsyOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -1240,9 +1412,9 @@ export abstract class DamagingTrapTag extends TrappedTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.commonAnim = source.commonAnim as CommonAnim; @@ -1259,8 +1431,8 @@ export abstract class DamagingTrapTag extends TrappedTag { globalScene.queueMessage( i18next.t("battlerTags:damagingTrapLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - moveName: this.getMoveName() - }) + moveName: this.getMoveName(), + }), ); globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), undefined, this.commonAnim)); @@ -1285,7 +1457,7 @@ export class BindTag extends DamagingTrapTag { return i18next.t("battlerTags:bindOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), sourcePokemonName: getPokemonNameWithAffix(globalScene.getPokemonById(this.sourceId!) ?? undefined), // TODO: is that bang correct? - moveName: this.getMoveName() + moveName: this.getMoveName(), }); } } @@ -1309,7 +1481,9 @@ export abstract class VortexTrapTag extends DamagingTrapTag { } getTrapMessage(pokemon: Pokemon): string { - return i18next.t("battlerTags:vortexOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlerTags:vortexOnTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } } @@ -1346,7 +1520,7 @@ export class SandTombTag extends DamagingTrapTag { getTrapMessage(pokemon: Pokemon): string { return i18next.t("battlerTags:sandTombOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - moveName: this.getMoveName() + moveName: this.getMoveName(), }); } } @@ -1357,7 +1531,9 @@ export class MagmaStormTag extends DamagingTrapTag { } getTrapMessage(pokemon: Pokemon): string { - return i18next.t("battlerTags:magmaStormOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlerTags:magmaStormOnTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } } @@ -1367,7 +1543,9 @@ export class SnapTrapTag extends DamagingTrapTag { } getTrapMessage(pokemon: Pokemon): string { - return i18next.t("battlerTags:snapTrapOnTrap", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlerTags:snapTrapOnTrap", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } } @@ -1397,7 +1575,6 @@ export class InfestationTag extends DamagingTrapTag { } } - export class ProtectedTag extends BattlerTag { constructor(sourceMove: Moves, tagType: BattlerTagType = BattlerTagType.PROTECTED) { super(tagType, BattlerTagLapseType.TURN_END, 0, sourceMove); @@ -1406,13 +1583,21 @@ export class ProtectedTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:protectedOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:protectedOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.CUSTOM) { new CommonBattleAnim(CommonAnim.PROTECT, pokemon).play(); - globalScene.queueMessage(i18next.t("battlerTags:protectedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:protectedLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); // Stop multi-hit moves early const effectPhase = globalScene.getCurrentPhase(); @@ -1443,9 +1628,9 @@ export class ContactDamageProtectedTag extends ProtectedTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.damageRatio = source.damageRatio; @@ -1484,9 +1669,9 @@ export class ContactStatStageChangeProtectedTag extends DamageProtectedTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.stat = source.stat; @@ -1500,7 +1685,7 @@ export class ContactStatStageChangeProtectedTag extends DamageProtectedTag { const effectPhase = globalScene.getCurrentPhase(); if (effectPhase instanceof MoveEffectPhase && effectPhase.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT)) { const attacker = effectPhase.getPokemon(); - globalScene.unshiftPhase(new StatStageChangePhase(attacker.getBattlerIndex(), false, [ this.stat ], this.levels)); + globalScene.unshiftPhase(new StatStageChangePhase(attacker.getBattlerIndex(), false, [this.stat], this.levels)); } } @@ -1565,12 +1750,20 @@ export class EnduringTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:enduringOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:enduringOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.CUSTOM) { - globalScene.queueMessage(i18next.t("battlerTags:enduringLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:enduringLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); return true; } @@ -1585,7 +1778,11 @@ export class SturdyTag extends BattlerTag { lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.CUSTOM) { - globalScene.queueMessage(i18next.t("battlerTags:sturdyLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:sturdyLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); return true; } @@ -1609,8 +1806,8 @@ export class PerishSongTag extends BattlerTag { globalScene.queueMessage( i18next.t("battlerTags:perishSongLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - turnCount: this.turnCount - }) + turnCount: this.turnCount, + }), ); } else { pokemon.damageAndUpdate(pokemon.hp, HitResult.ONE_HIT_KO, false, true, true); @@ -1630,7 +1827,7 @@ export class CenterOfAttentionTag extends BattlerTag { constructor(sourceMove: Moves) { super(BattlerTagType.CENTER_OF_ATTENTION, BattlerTagLapseType.TURN_END, 1, sourceMove); - this.powder = (this.sourceMove === Moves.RAGE_POWDER); + this.powder = this.sourceMove === Moves.RAGE_POWDER; } /** "Center of Attention" can't be added if an ally is already the Center of Attention. */ @@ -1643,7 +1840,11 @@ export class CenterOfAttentionTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:centerOfAttentionOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:centerOfAttentionOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -1657,9 +1858,9 @@ export class AbilityBattlerTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.ability = source.ability as Abilities; @@ -1698,7 +1899,11 @@ export class TruantTag extends AbilityBattlerTag { if (lastMove && lastMove.move !== Moves.NONE) { (globalScene.getCurrentPhase() as MovePhase).cancel(); globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.id, passive)); - globalScene.queueMessage(i18next.t("battlerTags:truantLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:truantLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } return true; @@ -1713,7 +1918,15 @@ export class SlowStartTag extends AbilityBattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:slowStartOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, false, null, true); + globalScene.queueMessage( + i18next.t("battlerTags:slowStartOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + null, + false, + null, + true, + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -1727,7 +1940,14 @@ export class SlowStartTag extends AbilityBattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:slowStartOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, false, null); + globalScene.queueMessage( + i18next.t("battlerTags:slowStartOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + null, + false, + null, + ); } } @@ -1740,9 +1960,9 @@ export class HighestStatBoostTag extends AbilityBattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.stat = source.stat as Stat; @@ -1753,7 +1973,9 @@ export class HighestStatBoostTag extends AbilityBattlerTag { super.onAdd(pokemon); let highestStat: EffectiveStat; - EFFECTIVE_STATS.map(s => pokemon.getEffectiveStat(s, undefined, undefined, undefined, undefined, undefined, undefined, true)).reduce((highestValue: number, value: number, i: number) => { + EFFECTIVE_STATS.map(s => + pokemon.getEffectiveStat(s, undefined, undefined, undefined, undefined, undefined, undefined, true), + ).reduce((highestValue: number, value: number, i: number) => { if (value > highestValue) { highestStat = EFFECTIVE_STATS[i]; return value; @@ -1765,13 +1987,27 @@ export class HighestStatBoostTag extends AbilityBattlerTag { this.stat = highestStat; this.multiplier = this.stat === Stat.SPD ? 1.5 : 1.3; - globalScene.queueMessage(i18next.t("battlerTags:highestStatBoostOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), statName: i18next.t(getStatKey(highestStat)) }), null, false, null, true); + globalScene.queueMessage( + i18next.t("battlerTags:highestStatBoostOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + statName: i18next.t(getStatKey(highestStat)), + }), + null, + false, + null, + true, + ); } onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:highestStatBoostOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), abilityName: allAbilities[this.ability].name })); + globalScene.queueMessage( + i18next.t("battlerTags:highestStatBoostOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + abilityName: allAbilities[this.ability].name, + }), + ); } } @@ -1784,9 +2020,9 @@ export class WeatherHighestStatBoostTag extends HighestStatBoostTag implements W } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.weatherTypes = source.weatherTypes.map(w => w as WeatherType); @@ -1802,9 +2038,9 @@ export class TerrainHighestStatBoostTag extends HighestStatBoostTag implements T } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.terrainTypes = source.terrainTypes.map(w => w as TerrainType); @@ -1826,7 +2062,7 @@ export class SemiInvulnerableTag extends BattlerTag { // Wait 2 frames before setting visible for battle animations that don't immediately show the sprite invisible globalScene.tweens.addCounter({ duration: getFrameMs(2), - onComplete: () => pokemon.setVisible(true) + onComplete: () => pokemon.setVisible(true), }); } } @@ -1834,16 +2070,16 @@ export class SemiInvulnerableTag extends BattlerTag { export class TypeImmuneTag extends BattlerTag { public immuneType: PokemonType; - constructor(tagType: BattlerTagType, sourceMove: Moves, immuneType: PokemonType, length: number = 1) { + constructor(tagType: BattlerTagType, sourceMove: Moves, immuneType: PokemonType, length = 1) { super(tagType, BattlerTagLapseType.TURN_END, length, sourceMove, undefined, true); this.immuneType = immuneType; } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.immuneType = source.immuneType as PokemonType; @@ -1864,15 +2100,22 @@ export class FloatingTag extends TypeImmuneTag { super.onAdd(pokemon); if (this.sourceMove === Moves.MAGNET_RISE) { - globalScene.queueMessage(i18next.t("battlerTags:magnetRisenOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:magnetRisenOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } - } onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); if (this.sourceMove === Moves.MAGNET_RISE) { - globalScene.queueMessage(i18next.t("battlerTags:magnetRisenOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:magnetRisenOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } } @@ -1882,7 +2125,13 @@ export class TypeBoostTag extends BattlerTag { public boostValue: number; public oneUse: boolean; - constructor(tagType: BattlerTagType, sourceMove: Moves, boostedType: PokemonType, boostValue: number, oneUse: boolean) { + constructor( + tagType: BattlerTagType, + sourceMove: Moves, + boostedType: PokemonType, + boostValue: number, + oneUse: boolean, + ) { super(tagType, BattlerTagLapseType.TURN_END, 1, sourceMove); this.boostedType = boostedType; @@ -1891,9 +2140,9 @@ export class TypeBoostTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.boostedType = source.boostedType as PokemonType; @@ -1914,7 +2163,11 @@ export class CritBoostTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:critBoostOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:critBoostOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -1924,7 +2177,11 @@ export class CritBoostTag extends BattlerTag { onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:critBoostOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:critBoostOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -1955,9 +2212,9 @@ export class SaltCuredTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.sourceIndex = source.sourceIndex; @@ -1966,7 +2223,11 @@ export class SaltCuredTag extends BattlerTag { onAdd(pokemon: Pokemon): void { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:saltCuredOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:saltCuredOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); this.sourceIndex = globalScene.getPokemonById(this.sourceId!)!.getBattlerIndex(); // TODO: are those bangs correct? } @@ -1974,7 +2235,9 @@ export class SaltCuredTag extends BattlerTag { const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); if (ret) { - globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.SALT_CURE)); + globalScene.unshiftPhase( + new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.SALT_CURE), + ); const cancelled = new BooleanHolder(false); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); @@ -1986,8 +2249,8 @@ export class SaltCuredTag extends BattlerTag { globalScene.queueMessage( i18next.t("battlerTags:saltCuredLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - moveName: this.getMoveName() - }) + moveName: this.getMoveName(), + }), ); } } @@ -2004,9 +2267,9 @@ export class CursedTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.sourceIndex = source.sourceIndex; @@ -2021,14 +2284,20 @@ export class CursedTag extends BattlerTag { const ret = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); if (ret) { - globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.SALT_CURE)); + globalScene.unshiftPhase( + new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.SALT_CURE), + ); const cancelled = new BooleanHolder(false); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4)); - globalScene.queueMessage(i18next.t("battlerTags:cursedLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:cursedLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -2060,8 +2329,8 @@ export class GroundedTag extends BattlerTag { */ export class RoostedTag extends BattlerTag { - private isBaseFlying : boolean; - private isBasePureFlying : boolean; + private isBaseFlying: boolean; + private isBasePureFlying: boolean; constructor() { super(BattlerTagType.ROOSTED, BattlerTagLapseType.TURN_END, 1, Moves.ROOST); @@ -2071,8 +2340,10 @@ export class RoostedTag extends BattlerTag { const currentTypes = pokemon.getTypes(); const baseTypes = pokemon.getTypes(false, false, true); - const forestsCurseApplied: boolean = currentTypes.includes(PokemonType.GRASS) && !baseTypes.includes(PokemonType.GRASS); - const trickOrTreatApplied: boolean = currentTypes.includes(PokemonType.GHOST) && !baseTypes.includes(PokemonType.GHOST); + const forestsCurseApplied: boolean = + currentTypes.includes(PokemonType.GRASS) && !baseTypes.includes(PokemonType.GRASS); + const trickOrTreatApplied: boolean = + currentTypes.includes(PokemonType.GHOST) && !baseTypes.includes(PokemonType.GHOST); if (this.isBaseFlying) { let modifiedTypes: PokemonType[] = []; @@ -2081,10 +2352,10 @@ export class RoostedTag extends BattlerTag { modifiedTypes = currentTypes.filter(type => type !== PokemonType.NORMAL); modifiedTypes.push(PokemonType.FLYING); } else { - modifiedTypes = [ PokemonType.FLYING ]; + modifiedTypes = [PokemonType.FLYING]; } } else { - modifiedTypes = [ ...currentTypes ]; + modifiedTypes = [...currentTypes]; modifiedTypes.push(PokemonType.FLYING); } pokemon.summonData.types = modifiedTypes; @@ -2104,10 +2375,10 @@ export class RoostedTag extends BattlerTag { if (this.isBaseFlying) { let modifiedTypes: PokemonType[]; if (this.isBasePureFlying && !isCurrentlyDualType) { - modifiedTypes = [ PokemonType.NORMAL ]; + modifiedTypes = [PokemonType.NORMAL]; } else { if (!!pokemon.getTag(RemovedTypeTag) && isOriginallyDualType && !isCurrentlyDualType) { - modifiedTypes = [ PokemonType.UNKNOWN ]; + modifiedTypes = [PokemonType.UNKNOWN]; } else { modifiedTypes = currentTypes.filter(type => type !== PokemonType.FLYING); } @@ -2159,10 +2430,6 @@ export class FormBlockDamageTag extends BattlerTag { } /** Provides the additional weather-based effects of the Ice Face ability */ export class IceFaceBlockDamageTag extends FormBlockDamageTag { - constructor(tagType: BattlerTagType) { - super(tagType); - } - /** * Determines if the tag can be added to the Pokémon. * @param {Pokemon} pokemon The Pokémon to which the tag might be added. @@ -2194,7 +2461,14 @@ export class CommandedTag extends BattlerTag { /** Caches the Tatsugiri's form key and sharply boosts the tagged Pokemon's stats */ override onAdd(pokemon: Pokemon): void { this._tatsugiriFormKey = this.getSourcePokemon()?.getFormKey() ?? "curly"; - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ], 2)); + globalScene.unshiftPhase( + new StatStageChangePhase( + pokemon.getBattlerIndex(), + true, + [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD], + 2, + ), + ); } /** Triggers an {@linkcode PokemonAnimType | animation} of the tagged Pokemon "spitting out" Tatsugiri */ @@ -2221,10 +2495,10 @@ export class CommandedTag extends BattlerTag { * the stat when added. */ export class StockpilingTag extends BattlerTag { - public stockpiledCount: number = 0; + public stockpiledCount = 0; public statChangeCounts: { [Stat.DEF]: number; [Stat.SPDEF]: number } = { [Stat.DEF]: 0, - [Stat.SPDEF]: 0 + [Stat.SPDEF]: 0, }; constructor(sourceMove: Moves = Moves.NONE) { @@ -2262,16 +2536,26 @@ export class StockpilingTag extends BattlerTag { if (this.stockpiledCount < 3) { this.stockpiledCount++; - globalScene.queueMessage(i18next.t("battlerTags:stockpilingOnAdd", { - pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - stockpiledCount: this.stockpiledCount - })); + globalScene.queueMessage( + i18next.t("battlerTags:stockpilingOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + stockpiledCount: this.stockpiledCount, + }), + ); // Attempt to increase DEF and SPDEF by one stage, keeping track of successful changes. - globalScene.unshiftPhase(new StatStageChangePhase( - pokemon.getBattlerIndex(), true, - [ Stat.SPDEF, Stat.DEF ], 1, true, false, true, this.onStatStagesChanged - )); + globalScene.unshiftPhase( + new StatStageChangePhase( + pokemon.getBattlerIndex(), + true, + [Stat.SPDEF, Stat.DEF], + 1, + true, + false, + true, + this.onStatStagesChanged, + ), + ); } } @@ -2288,11 +2572,15 @@ export class StockpilingTag extends BattlerTag { const spDefChange = this.statChangeCounts[Stat.SPDEF]; if (defChange) { - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.DEF ], -defChange, true, false, true)); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.DEF], -defChange, true, false, true), + ); } if (spDefChange) { - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.SPDEF ], -spDefChange, true, false, true)); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.SPDEF], -spDefChange, true, false, true), + ); } } } @@ -2306,7 +2594,7 @@ export class GulpMissileTag extends BattlerTag { super(tagType, BattlerTagLapseType.HIT, 0, sourceMove); } - override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { + override lapse(pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean { if (pokemon.getTag(BattlerTagType.UNDERWATER)) { return true; } @@ -2331,7 +2619,7 @@ export class GulpMissileTag extends BattlerTag { } if (this.tagType === BattlerTagType.GULP_MISSILE_ARROKUDA) { - globalScene.unshiftPhase(new StatStageChangePhase(attacker.getBattlerIndex(), false, [ Stat.DEF ], -1)); + globalScene.unshiftPhase(new StatStageChangePhase(attacker.getBattlerIndex(), false, [Stat.DEF], -1)); } else { attacker.trySetStatus(StatusEffect.PARALYSIS, true, pokemon); } @@ -2345,8 +2633,11 @@ export class GulpMissileTag extends BattlerTag { * @returns Whether the BattlerTag can be added. */ canAdd(pokemon: Pokemon): boolean { - const isSurfOrDive = [ Moves.SURF, Moves.DIVE ].includes(this.sourceMove); - const isNormalForm = pokemon.formIndex === 0 && !pokemon.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA) && !pokemon.getTag(BattlerTagType.GULP_MISSILE_PIKACHU); + const isSurfOrDive = [Moves.SURF, Moves.DIVE].includes(this.sourceMove); + const isNormalForm = + pokemon.formIndex === 0 && + !pokemon.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA) && + !pokemon.getTag(BattlerTagType.GULP_MISSILE_PIKACHU); const isCramorant = pokemon.species.speciesId === Species.CRAMORANT; return isSurfOrDive && isNormalForm && isCramorant; @@ -2384,9 +2675,9 @@ export class ExposedTag extends BattlerTag { } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.defenderType = source.defenderType as PokemonType; @@ -2411,11 +2702,18 @@ export class ExposedTag extends BattlerTag { */ export class HealBlockTag extends MoveRestrictionBattlerTag { constructor(turnCount: number, sourceMove: Moves) { - super(BattlerTagType.HEAL_BLOCK, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], turnCount, sourceMove); + super( + BattlerTagType.HEAL_BLOCK, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END], + turnCount, + sourceMove, + ); } onActivation(pokemon: Pokemon): string { - return i18next.t("battle:battlerTagsHealBlock", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battle:battlerTagsHealBlock", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } /** @@ -2441,7 +2739,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag { override isMoveTargetRestricted(move: Moves, user: Pokemon, target: Pokemon) { const moveCategory = new NumberHolder(allMoves[move].category); applyMoveAttrs(StatusCategoryOnAllyAttr, user, target, allMoves[move], moveCategory); - if (allMoves[move].hasAttr(HealOnAllyAttr) && moveCategory.value === MoveCategory.STATUS ) { + if (allMoves[move].hasAttr(HealOnAllyAttr) && moveCategory.value === MoveCategory.STATUS) { return true; } return false; @@ -2451,7 +2749,11 @@ export class HealBlockTag extends MoveRestrictionBattlerTag { * Uses its own unique selectionDeniedText() message */ override selectionDeniedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledHealBlock", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name, healBlockName: allMoves[Moves.HEAL_BLOCK].name }); + return i18next.t("battle:moveDisabledHealBlock", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + healBlockName: allMoves[Moves.HEAL_BLOCK].name, + }); } /** @@ -2461,13 +2763,24 @@ export class HealBlockTag extends MoveRestrictionBattlerTag { * @returns {string} text to display when the move is interrupted */ override interruptedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledHealBlock", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name, healBlockName: allMoves[Moves.HEAL_BLOCK].name }); + return i18next.t("battle:moveDisabledHealBlock", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + healBlockName: allMoves[Moves.HEAL_BLOCK].name, + }); } override onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battle:battlerTagsHealBlockOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, false, null); + globalScene.queueMessage( + i18next.t("battle:battlerTagsHealBlockOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + null, + false, + null, + ); } } @@ -2490,7 +2803,11 @@ export class TarShotTag extends BattlerTag { } override onAdd(pokemon: Pokemon): void { - globalScene.queueMessage(i18next.t("battlerTags:tarShotOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:tarShotOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -2505,7 +2822,11 @@ export class ElectrifiedTag extends BattlerTag { override onAdd(pokemon: Pokemon): void { // "{pokemonNameWithAffix}'s moves have been electrified!" - globalScene.queueMessage(i18next.t("battlerTags:electrifiedOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:electrifiedOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -2514,7 +2835,7 @@ export class ElectrifiedTag extends BattlerTag { * Each count of Autotomization reduces the weight by 100kg */ export class AutotomizedTag extends BattlerTag { - public autotomizeCount: number = 0; + public autotomizeCount = 0; constructor(sourceMove: Moves = Moves.AUTOTOMIZE) { super(BattlerTagType.AUTOTOMIZED, BattlerTagLapseType.CUSTOM, 1, sourceMove); } @@ -2527,9 +2848,11 @@ export class AutotomizedTag extends BattlerTag { onAdd(pokemon: Pokemon): void { const minWeight = 0.1; if (pokemon.getWeight() > minWeight) { - globalScene.queueMessage(i18next.t("battlerTags:autotomizeOnAdd", { - pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) - })); + globalScene.queueMessage( + i18next.t("battlerTags:autotomizeOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } this.autotomizeCount += 1; } @@ -2553,7 +2876,14 @@ export class SubstituteTag extends BattlerTag { public sourceInFocus: boolean; constructor(sourceMove: Moves, sourceId: number) { - super(BattlerTagType.SUBSTITUTE, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE, BattlerTagLapseType.HIT ], 0, sourceMove, sourceId, true); + super( + BattlerTagType.SUBSTITUTE, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE, BattlerTagLapseType.HIT], + 0, + sourceMove, + sourceId, + true, + ); } /** Sets the Substitute's HP and queues an on-add battle animation that initializes the Substitute's sprite. */ @@ -2564,9 +2894,19 @@ export class SubstituteTag extends BattlerTag { // Queue battle animation and message globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_ADD); if (this.sourceMove === Moves.SHED_TAIL) { - globalScene.queueMessage(i18next.t("battlerTags:shedTailOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500); + globalScene.queueMessage( + i18next.t("battlerTags:shedTailOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + 1500, + ); } else { - globalScene.queueMessage(i18next.t("battlerTags:substituteOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500); + globalScene.queueMessage( + i18next.t("battlerTags:substituteOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + 1500, + ); } // Remove any binding effects from the user @@ -2577,11 +2917,15 @@ export class SubstituteTag extends BattlerTag { onRemove(pokemon: Pokemon): void { // Only play the animation if the cause of removal isn't from the source's own move if (!this.sourceInFocus) { - globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_REMOVE, [ this.sprite ]); + globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_REMOVE, [this.sprite]); } else { this.sprite.destroy(); } - globalScene.queueMessage(i18next.t("battlerTags:substituteOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:substituteOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { @@ -2601,13 +2945,13 @@ export class SubstituteTag extends BattlerTag { /** Triggers an animation that brings the Pokemon into focus before it uses a move */ onPreMove(pokemon: Pokemon): void { - globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_PRE_MOVE, [ this.sprite ]); + globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_PRE_MOVE, [this.sprite]); this.sourceInFocus = true; } /** Triggers an animation that brings the Pokemon out of focus after it uses a move */ onAfterMove(pokemon: Pokemon): void { - globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_POST_MOVE, [ this.sprite ]); + globalScene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.SUBSTITUTE_POST_MOVE, [this.sprite]); this.sourceInFocus = false; } @@ -2620,18 +2964,22 @@ export class SubstituteTag extends BattlerTag { return; } const move = moveEffectPhase.move.getMove(); - const firstHit = (attacker.turnData.hitCount === attacker.turnData.hitsLeft); + const firstHit = attacker.turnData.hitCount === attacker.turnData.hitsLeft; if (firstHit && move.hitsSubstitute(attacker, pokemon)) { - globalScene.queueMessage(i18next.t("battlerTags:substituteOnHit", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:substituteOnHit", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } } /** - * When given a battler tag or json representing one, load the data for it. - * @param {BattlerTag | any} source A battler tag - */ + * When given a battler tag or json representing one, load the data for it. + * @param {BattlerTag | any} source A battler tag + */ loadTag(source: BattlerTag | any): void { super.loadTag(source); this.hp = source.hp; @@ -2695,7 +3043,12 @@ export class TormentTag extends MoveRestrictionBattlerTag { */ override onAdd(pokemon: Pokemon) { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:tormentOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500); + globalScene.queueMessage( + i18next.t("battlerTags:tormentOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + 1500, + ); } /** @@ -2718,14 +3071,14 @@ export class TormentTag extends MoveRestrictionBattlerTag { return false; } const lastMove = user.getLastXMoves(1)[0]; - if ( !lastMove ) { + if (!lastMove) { return false; } // This checks for locking / momentum moves like Rollout and Hydro Cannon + if the user is under the influence of BattlerTagType.FRENZY // Because Uproar's unique behavior is not implemented, it does not check for Uproar. Torment has been marked as partial in moves.ts const moveObj = allMoves[lastMove.move]; const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || user.getTag(BattlerTagType.FRENZY); - const validLastMoveResult = (lastMove.result === MoveResult.SUCCESS) || (lastMove.result === MoveResult.MISS); + const validLastMoveResult = lastMove.result === MoveResult.SUCCESS || lastMove.result === MoveResult.MISS; if (lastMove.move === move && validLastMoveResult && lastMove.move !== Moves.STRUGGLE && !isUnaffected) { return true; } @@ -2733,7 +3086,9 @@ export class TormentTag extends MoveRestrictionBattlerTag { } override selectionDeniedText(pokemon: Pokemon, _move: Moves): string { - return i18next.t("battle:moveDisabledTorment", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battle:moveDisabledTorment", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } } @@ -2744,18 +3099,27 @@ export class TormentTag extends MoveRestrictionBattlerTag { */ export class TauntTag extends MoveRestrictionBattlerTag { constructor() { - super(BattlerTagType.TAUNT, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE ], 4, Moves.TAUNT); + super(BattlerTagType.TAUNT, [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE], 4, Moves.TAUNT); } override onAdd(pokemon: Pokemon) { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:tauntOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500); + globalScene.queueMessage( + i18next.t("battlerTags:tauntOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + 1500, + ); } public override onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:tauntOnRemove", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:tauntOnRemove", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -2768,11 +3132,17 @@ export class TauntTag extends MoveRestrictionBattlerTag { } override selectionDeniedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledTaunt", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name }); + return i18next.t("battle:moveDisabledTaunt", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + }); } override interruptedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledTaunt", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name }); + return i18next.t("battle:moveDisabledTaunt", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + }); } } @@ -2783,7 +3153,13 @@ export class TauntTag extends MoveRestrictionBattlerTag { */ export class ImprisonTag extends MoveRestrictionBattlerTag { constructor(sourceId: number) { - super(BattlerTagType.IMPRISON, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE ], 1, Moves.IMPRISON, sourceId); + super( + BattlerTagType.IMPRISON, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE], + 1, + Moves.IMPRISON, + sourceId, + ); } /** @@ -2797,9 +3173,8 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { if (source) { if (lapseType === BattlerTagLapseType.PRE_MOVE) { return super.lapse(pokemon, lapseType) && source.isActive(true); - } else { - return source.isActive(true); } + return source.isActive(true); } return false; } @@ -2810,7 +3185,7 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { * @param {Moves} move the move under investigation * @returns `false` if either condition is not met */ - public override isMoveRestricted(move: Moves, user: Pokemon): boolean { + public override isMoveRestricted(move: Moves, _user: Pokemon): boolean { const source = this.getSourcePokemon(); if (source) { const sourceMoveset = source.getMoveset().map(m => m!.moveId); @@ -2820,11 +3195,17 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { } override selectionDeniedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledImprison", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name }); + return i18next.t("battle:moveDisabledImprison", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + }); } override interruptedText(pokemon: Pokemon, move: Moves): string { - return i18next.t("battle:moveDisabledImprison", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name }); + return i18next.t("battle:moveDisabledImprison", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: allMoves[move].name, + }); } } @@ -2844,7 +3225,11 @@ export class SyrupBombTag extends BattlerTag { */ override onAdd(pokemon: Pokemon) { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:syrupBombOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:syrupBombOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -2858,11 +3243,14 @@ export class SyrupBombTag extends BattlerTag { return false; } // Custom message in lieu of an animation in mainline - globalScene.queueMessage(i18next.t("battlerTags:syrupBombLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); - globalScene.unshiftPhase(new StatStageChangePhase( - pokemon.getBattlerIndex(), true, - [ Stat.SPD ], -1, true, false, true - )); + globalScene.queueMessage( + i18next.t("battlerTags:syrupBombLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.SPD], -1, true, false, true), + ); return --this.turnCount > 0; } } @@ -2875,11 +3263,22 @@ export class SyrupBombTag extends BattlerTag { */ export class TelekinesisTag extends BattlerTag { constructor(sourceMove: Moves) { - super(BattlerTagType.TELEKINESIS, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE ], 3, sourceMove, undefined, true); + super( + BattlerTagType.TELEKINESIS, + [BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE], + 3, + sourceMove, + undefined, + true, + ); } - override onAdd(pokemon: Pokemon) { - globalScene.queueMessage(i18next.t("battlerTags:telekinesisOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + override onAdd(pokemon: Pokemon) { + globalScene.queueMessage( + i18next.t("battlerTags:telekinesisOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -2894,12 +3293,20 @@ export class PowerTrickTag extends BattlerTag { onAdd(pokemon: Pokemon): void { this.swapStat(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:powerTrickActive", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:powerTrickActive", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } onRemove(pokemon: Pokemon): void { this.swapStat(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:powerTrickActive", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:powerTrickActive", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -2928,12 +3335,16 @@ export class PowerTrickTag extends BattlerTag { */ export class GrudgeTag extends BattlerTag { constructor() { - super(BattlerTagType.GRUDGE, [ BattlerTagLapseType.CUSTOM, BattlerTagLapseType.PRE_MOVE ], 1, Moves.GRUDGE); + super(BattlerTagType.GRUDGE, [BattlerTagLapseType.CUSTOM, BattlerTagLapseType.PRE_MOVE], 1, Moves.GRUDGE); } onAdd(pokemon: Pokemon) { super.onAdd(pokemon); - globalScene.queueMessage(i18next.t("battlerTags:grudgeOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:grudgeOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -2950,13 +3361,17 @@ export class GrudgeTag extends BattlerTag { const lastMoveData = sourcePokemon.getMoveset().find(m => m?.moveId === lastMove.move); if (lastMoveData && lastMove.move !== Moves.STRUGGLE) { lastMoveData.ppUsed = lastMoveData.getMovePp(); - globalScene.queueMessage(i18next.t("battlerTags:grudgeLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: lastMoveData.getName() })); + globalScene.queueMessage( + i18next.t("battlerTags:grudgeLapse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: lastMoveData.getName(), + }), + ); } } return false; - } else { - return super.lapse(pokemon, lapseType); } + return super.lapse(pokemon, lapseType); } } @@ -2996,7 +3411,11 @@ export class MagicCoatTag extends BattlerTag { */ override onAdd(pokemon: Pokemon) { // "{pokemonNameWithAffix} shrouded itself with Magic Coat!" - globalScene.queueMessage(i18next.t("battlerTags:magicCoatOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("battlerTags:magicCoatOnAdd", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } } @@ -3005,7 +3424,12 @@ export class MagicCoatTag extends BattlerTag { * @param sourceId - The ID of the pokemon adding the tag * @returns The corresponding {@linkcode BattlerTag} object. */ -export function getBattlerTag(tagType: BattlerTagType, turnCount: number, sourceMove: Moves, sourceId: number): BattlerTag { +export function getBattlerTag( + tagType: BattlerTagType, + turnCount: number, + sourceMove: Moves, + sourceId: number, +): BattlerTag { switch (tagType) { case BattlerTagType.RECHARGING: return new RechargingTag(sourceMove); @@ -3094,7 +3518,12 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source case BattlerTagType.SLOW_START: return new SlowStartTag(); case BattlerTagType.PROTOSYNTHESIS: - return new WeatherHighestStatBoostTag(tagType, Abilities.PROTOSYNTHESIS, WeatherType.SUNNY, WeatherType.HARSH_SUN); + return new WeatherHighestStatBoostTag( + tagType, + Abilities.PROTOSYNTHESIS, + WeatherType.SUNNY, + WeatherType.HARSH_SUN, + ); case BattlerTagType.QUARK_DRIVE: return new TerrainHighestStatBoostTag(tagType, Abilities.QUARK_DRIVE, TerrainType.ELECTRIC); case BattlerTagType.FLYING: @@ -3149,9 +3578,9 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source case BattlerTagType.DISABLED: return new DisabledTag(sourceId); case BattlerTagType.IGNORE_GHOST: - return new ExposedTag(tagType, sourceMove, PokemonType.GHOST, [ PokemonType.NORMAL, PokemonType.FIGHTING ]); + return new ExposedTag(tagType, sourceMove, PokemonType.GHOST, [PokemonType.NORMAL, PokemonType.FIGHTING]); case BattlerTagType.IGNORE_DARK: - return new ExposedTag(tagType, sourceMove, PokemonType.DARK, [ PokemonType.PSYCHIC ]); + return new ExposedTag(tagType, sourceMove, PokemonType.DARK, [PokemonType.PSYCHIC]); case BattlerTagType.GULP_MISSILE_ARROKUDA: case BattlerTagType.GULP_MISSILE_PIKACHU: return new GulpMissileTag(tagType, sourceMove); @@ -3198,10 +3627,10 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source } /** -* When given a battler tag or json representing one, creates an actual BattlerTag object with the same data. -* @param {BattlerTag | any} source A battler tag -* @return {BattlerTag} The valid battler tag -*/ + * When given a battler tag or json representing one, creates an actual BattlerTag object with the same data. + * @param {BattlerTag | any} source A battler tag + * @return {BattlerTag} The valid battler tag + */ export function loadBattlerTag(source: BattlerTag | any): BattlerTag { const tag = getBattlerTag(source.tagType, source.turnCount, source.sourceMove, source.sourceId); tag.loadTag(source); @@ -3211,17 +3640,17 @@ export function loadBattlerTag(source: BattlerTag | any): BattlerTag { /** * Helper function to verify that the current phase is a MoveEffectPhase and provide quick access to commonly used fields * - * @param pokemon {@linkcode Pokemon} The Pokémon used to access the current phase + * @param _pokemon {@linkcode Pokemon} The Pokémon used to access the current phase * @returns null if current phase is not MoveEffectPhase, otherwise Object containing the {@linkcode MoveEffectPhase}, and its * corresponding {@linkcode Move} and user {@linkcode Pokemon} */ -function getMoveEffectPhaseData(pokemon: Pokemon): {phase: MoveEffectPhase, attacker: Pokemon, move: Move} | null { +function getMoveEffectPhaseData(_pokemon: Pokemon): { phase: MoveEffectPhase; attacker: Pokemon; move: Move } | null { const phase = globalScene.getCurrentPhase(); if (phase instanceof MoveEffectPhase) { return { - phase : phase, - attacker : phase.getPokemon(), - move : phase.move.getMove() + phase: phase, + attacker: phase.getPokemon(), + move: phase.move.getMove(), }; } return null; diff --git a/src/data/berry.ts b/src/data/berry.ts index 06f52b2f38b..ed8ae8d2b62 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -3,7 +3,13 @@ import type Pokemon from "../field/pokemon"; import { HitResult } from "../field/pokemon"; import { getStatusEffectHealText } from "./status-effect"; import * as Utils from "../utils"; -import { DoubleBerryEffectAbAttr, PostItemLostAbAttr, ReduceBerryUseThresholdAbAttr, applyAbAttrs, applyPostItemLostAbAttrs } from "./ability"; +import { + DoubleBerryEffectAbAttr, + PostItemLostAbAttr, + ReduceBerryUseThresholdAbAttr, + applyAbAttrs, + applyPostItemLostAbAttrs, +} from "./ability"; import i18next from "i18next"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; @@ -29,7 +35,8 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate { case BerryType.LUM: return (pokemon: Pokemon) => !!pokemon.status || !!pokemon.getTag(BattlerTagType.CONFUSED); case BerryType.ENIGMA: - return (pokemon: Pokemon) => !!pokemon.turnData.attacksReceived.filter(a => a.result === HitResult.SUPER_EFFECTIVE).length; + return (pokemon: Pokemon) => + !!pokemon.turnData.attacksReceived.filter(a => a.result === HitResult.SUPER_EFFECTIVE).length; case BerryType.LIECHI: case BerryType.GANLON: case BerryType.PETAYA: @@ -75,8 +82,17 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { } const hpHealed = new Utils.NumberHolder(Utils.toDmgValue(pokemon.getMaxHp() / 4)); applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, hpHealed); - globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), - hpHealed.value, i18next.t("battle:hpHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), berryName: getBerryName(berryType) }), true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + pokemon.getBattlerIndex(), + hpHealed.value, + i18next.t("battle:hpHealBerry", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + berryName: getBerryName(berryType), + }), + true, + ), + ); applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false); }; case BerryType.LUM: @@ -104,7 +120,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { const stat: BattleStat = berryType - BerryType.ENIGMA; const statStages = new Utils.NumberHolder(1); applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, statStages); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ stat ], statStages.value)); + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [stat], statStages.value)); applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false); }; case BerryType.LANSAT: @@ -123,7 +139,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { const randStat = Utils.randSeedInt(Stat.SPD, Stat.ATK); const stages = new Utils.NumberHolder(2); applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, false, stages); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ randStat ], stages.value)); + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [randStat], stages.value)); applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false); }; case BerryType.LEPPA: @@ -131,11 +147,19 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { if (pokemon.battleData) { pokemon.battleData.berriesEaten.push(berryType); } - const ppRestoreMove = pokemon.getMoveset().find(m => !m?.getPpRatio()) ? pokemon.getMoveset().find(m => !m?.getPpRatio()) : pokemon.getMoveset().find(m => m!.getPpRatio() < 1); // TODO: is this bang correct? + const ppRestoreMove = pokemon.getMoveset().find(m => !m?.getPpRatio()) + ? pokemon.getMoveset().find(m => !m?.getPpRatio()) + : pokemon.getMoveset().find(m => m!.getPpRatio() < 1); // TODO: is this bang correct? if (ppRestoreMove !== undefined) { - ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0); - globalScene.queueMessage(i18next.t("battle:ppHealBerry", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: ppRestoreMove!.getName(), berryName: getBerryName(berryType) })); - applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false); + ppRestoreMove!.ppUsed = Math.max(ppRestoreMove!.ppUsed - 10, 0); + globalScene.queueMessage( + i18next.t("battle:ppHealBerry", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + moveName: ppRestoreMove!.getName(), + berryName: getBerryName(berryType), + }), + ); + applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner ?? pokemon, false); } }; } diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 49af78292c3..b9d817836c3 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -33,37 +33,37 @@ export enum ChallengeType { /** * Challenges which modify what starters you can choose * @see {@link Challenge.applyStarterChoice} - */ + */ STARTER_CHOICE, /** * Challenges which modify how many starter points you have * @see {@link Challenge.applyStarterPoints} - */ + */ STARTER_POINTS, /** * Challenges which modify how many starter points you have * @see {@link Challenge.applyStarterPointCost} - */ + */ STARTER_COST, /** * Challenges which modify your starters in some way * @see {@link Challenge.applyStarterModify} - */ + */ STARTER_MODIFY, /** * Challenges which limit which pokemon you can have in battle. * @see {@link Challenge.applyPokemonInBattle} - */ + */ POKEMON_IN_BATTLE, /** * Adds or modifies the fixed battles in a run * @see {@link Challenge.applyFixedBattle} - */ + */ FIXED_BATTLES, /** * Modifies the effectiveness of Type matchups in battle * @see {@linkcode Challenge.applyTypeEffectiveness} - */ + */ TYPE_EFFECTIVENESS, /** * Modifies what level the AI pokemon are. UNIMPLEMENTED. @@ -93,7 +93,6 @@ export enum ChallengeType { * Modifies what the pokemon stats for Flip Stat Mode. */ FLIP_STAT, - } /** @@ -106,7 +105,7 @@ export enum MoveSourceType { GREAT_TM, ULTRA_TM, COMMON_EGG, - RARE_EGG + RARE_EGG, } /** @@ -148,7 +147,10 @@ export abstract class Challenge { * @returns {@link string} The i18n key for this challenge */ geti18nKey(): string { - return Challenges[this.id].split("_").map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join(""); + return Challenges[this.id] + .split("_") + .map((f, i) => (i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase())) + .join(""); } /** @@ -195,7 +197,7 @@ export abstract class Challenge { */ getDescription(overrideValue?: number): string { const value = overrideValue ?? this.value; - return `${i18next.t([ `challenges:${this.geti18nKey()}.desc.${value}`, `challenges:${this.geti18nKey()}.desc` ])}`; + return `${i18next.t([`challenges:${this.geti18nKey()}.desc.${value}`, `challenges:${this.geti18nKey()}.desc`])}`; } /** @@ -274,88 +276,93 @@ export abstract class Challenge { * @param source The source challenge or json. * @returns This challenge. */ - static loadChallenge(source: Challenge | any): Challenge { + static loadChallenge(_source: Challenge | any): Challenge { throw new Error("Method not implemented! Use derived class"); } /** * An apply function for STARTER_CHOICE challenges. Derived classes should alter this. - * @param pokemon {@link PokemonSpecies} The pokemon to check the validity of. - * @param valid {@link Utils.BooleanHolder} A BooleanHolder, the value gets set to false if the pokemon isn't allowed. - * @param dexAttr {@link DexAttrProps} The dex attributes of the pokemon. - * @param soft {@link boolean} If true, allow it if it could become a valid pokemon. + * @param _pokemon {@link PokemonSpecies} The pokemon to check the validity of. + * @param _valid {@link Utils.BooleanHolder} A BooleanHolder, the value gets set to false if the pokemon isn't allowed. + * @param _dexAttr {@link DexAttrProps} The dex attributes of the pokemon. + * @param _soft {@link boolean} If true, allow it if it could become a valid pokemon. * @returns {@link boolean} Whether this function did anything. */ - applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean { + applyStarterChoice( + _pokemon: PokemonSpecies, + _valid: Utils.BooleanHolder, + _dexAttr: DexAttrProps, + _soft = false, + ): boolean { return false; } /** * An apply function for STARTER_POINTS challenges. Derived classes should alter this. - * @param points {@link Utils.NumberHolder} The amount of points you have available. + * @param _points {@link Utils.NumberHolder} The amount of points you have available. * @returns {@link boolean} Whether this function did anything. */ - applyStarterPoints(points: Utils.NumberHolder): boolean { + applyStarterPoints(_points: Utils.NumberHolder): boolean { return false; } /** * An apply function for STARTER_COST challenges. Derived classes should alter this. - * @param species {@link Species} The pokemon to change the cost of. - * @param cost {@link Utils.NumberHolder} The cost of the starter. + * @param _species {@link Species} The pokemon to change the cost of. + * @param _cost {@link Utils.NumberHolder} The cost of the starter. * @returns {@link boolean} Whether this function did anything. */ - applyStarterCost(species: Species, cost: Utils.NumberHolder): boolean { + applyStarterCost(_species: Species, _cost: Utils.NumberHolder): boolean { return false; } /** * An apply function for STARTER_MODIFY challenges. Derived classes should alter this. - * @param pokemon {@link Pokemon} The starter pokemon to modify. + * @param _pokemon {@link Pokemon} The starter pokemon to modify. * @returns {@link boolean} Whether this function did anything. */ - applyStarterModify(pokemon: Pokemon): boolean { + applyStarterModify(_pokemon: Pokemon): boolean { return false; } /** * An apply function for POKEMON_IN_BATTLE challenges. Derived classes should alter this. - * @param pokemon {@link Pokemon} The pokemon to check the validity of. - * @param valid {@link Utils.BooleanHolder} A BooleanHolder, the value gets set to false if the pokemon isn't allowed. + * @param _pokemon {@link Pokemon} The pokemon to check the validity of. + * @param _valid {@link Utils.BooleanHolder} A BooleanHolder, the value gets set to false if the pokemon isn't allowed. * @returns {@link boolean} Whether this function did anything. */ - applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { + applyPokemonInBattle(_pokemon: Pokemon, _valid: Utils.BooleanHolder): boolean { return false; } /** * An apply function for FIXED_BATTLE challenges. Derived classes should alter this. - * @param waveIndex {@link Number} The current wave index. - * @param battleConfig {@link FixedBattleConfig} The battle config to modify. + * @param _waveIndex {@link Number} The current wave index. + * @param _battleConfig {@link FixedBattleConfig} The battle config to modify. * @returns {@link boolean} Whether this function did anything. */ - applyFixedBattle(waveIndex: Number, battleConfig: FixedBattleConfig): boolean { + applyFixedBattle(_waveIndex: number, _battleConfig: FixedBattleConfig): boolean { return false; } /** * An apply function for TYPE_EFFECTIVENESS challenges. Derived classes should alter this. - * @param effectiveness {@linkcode Utils.NumberHolder} The current effectiveness of the move. + * @param _effectiveness {@linkcode Utils.NumberHolder} The current effectiveness of the move. * @returns Whether this function did anything. */ - applyTypeEffectiveness(effectiveness: Utils.NumberHolder): boolean { + applyTypeEffectiveness(_effectiveness: Utils.NumberHolder): boolean { return false; } /** * An apply function for AI_LEVEL challenges. Derived classes should alter this. - * @param level {@link Utils.NumberHolder} The generated level. - * @param levelCap {@link Number} The current level cap. - * @param isTrainer {@link Boolean} Whether this is a trainer pokemon. - * @param isBoss {@link Boolean} Whether this is a non-trainer boss pokemon. + * @param _level {@link Utils.NumberHolder} The generated level. + * @param _levelCap {@link Number} The current level cap. + * @param _isTrainer {@link Boolean} Whether this is a trainer pokemon. + * @param _isBoss {@link Boolean} Whether this is a non-trainer boss pokemon. * @returns {@link boolean} Whether this function did anything. */ - applyLevelChange(level: Utils.NumberHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean { + applyLevelChange(_level: Utils.NumberHolder, _levelCap: number, _isTrainer: boolean, _isBoss: boolean): boolean { return false; } @@ -365,7 +372,7 @@ export abstract class Challenge { * @param moveSlots {@link Utils.NumberHolder} The amount of move slots. * @returns {@link boolean} Whether this function did anything. */ - applyMoveSlot(pokemon: Pokemon, moveSlots: Utils.NumberHolder): boolean { + applyMoveSlot(_pokemon: Pokemon, _moveSlots: Utils.NumberHolder): boolean { return false; } @@ -375,7 +382,7 @@ export abstract class Challenge { * @param hasPassive {@link Utils.BooleanHolder} Whether it should have its passive. * @returns {@link boolean} Whether this function did anything. */ - applyPassiveAccess(pokemon: Pokemon, hasPassive: Utils.BooleanHolder): boolean { + applyPassiveAccess(_pokemon: Pokemon, _hasPassive: Utils.BooleanHolder): boolean { return false; } @@ -384,41 +391,46 @@ export abstract class Challenge { * @param gameMode {@link GameMode} The current game mode. * @returns {@link boolean} Whether this function did anything. */ - applyGameModeModify(gameMode: GameMode): boolean { + applyGameModeModify(_gameMode: GameMode): boolean { return false; } /** * An apply function for MOVE_ACCESS. Derived classes should alter this. - * @param pokemon {@link Pokemon} What pokemon would learn the move. - * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. - * @param move {@link Moves} The move in question. - * @param level {@link Utils.NumberHolder} The level threshold for access. + * @param _pokemon {@link Pokemon} What pokemon would learn the move. + * @param _moveSource {@link MoveSourceType} What source the pokemon would get the move from. + * @param _move {@link Moves} The move in question. + * @param _level {@link Utils.NumberHolder} The level threshold for access. * @returns {@link boolean} Whether this function did anything. */ - applyMoveAccessLevel(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean { + applyMoveAccessLevel( + _pokemon: Pokemon, + _moveSource: MoveSourceType, + _move: Moves, + _level: Utils.NumberHolder, + ): boolean { return false; } /** * An apply function for MOVE_WEIGHT. Derived classes should alter this. - * @param pokemon {@link Pokemon} What pokemon would learn the move. - * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. - * @param move {@link Moves} The move in question. - * @param weight {@link Utils.NumberHolder} The base weight of the move + * @param _pokemon {@link Pokemon} What pokemon would learn the move. + * @param _moveSource {@link MoveSourceType} What source the pokemon would get the move from. + * @param _move {@link Moves} The move in question. + * @param _weight {@link Utils.NumberHolder} The base weight of the move * @returns {@link boolean} Whether this function did anything. */ - applyMoveWeight(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean { + applyMoveWeight(_pokemon: Pokemon, _moveSource: MoveSourceType, _move: Moves, _level: Utils.NumberHolder): boolean { return false; } /** * An apply function for FlipStats. Derived classes should alter this. - * @param pokemon {@link Pokemon} What pokemon would learn the move. - * @param baseStats What are the stats to flip. + * @param _pokemon {@link Pokemon} What pokemon would learn the move. + * @param _baseStats What are the stats to flip. * @returns {@link boolean} Whether this function did anything. */ - applyFlipStat(pokemon: Pokemon, baseStats: number[]) { + applyFlipStat(_pokemon: Pokemon, _baseStats: number[]) { return false; } } @@ -433,10 +445,15 @@ export class SingleGenerationChallenge extends Challenge { super(Challenges.SINGLE_GENERATION, 9); } - applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean { - const generations = [ pokemon.generation ]; + applyStarterChoice( + pokemon: PokemonSpecies, + valid: Utils.BooleanHolder, + _dexAttr: DexAttrProps, + soft = false, + ): boolean { + const generations = [pokemon.generation]; if (soft) { - const speciesToCheck = [ pokemon.speciesId ]; + const speciesToCheck = [pokemon.speciesId]; while (speciesToCheck.length) { const checking = speciesToCheck.pop(); if (checking && pokemonEvolutions.hasOwnProperty(checking)) { @@ -458,7 +475,10 @@ export class SingleGenerationChallenge extends Challenge { applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { const baseGeneration = getPokemonSpecies(pokemon.species.speciesId).generation; const fusionGeneration = pokemon.isFusion() ? getPokemonSpecies(pokemon.fusionSpecies!.speciesId).generation : 0; // TODO: is the bang on fusionSpecies correct? - if (pokemon.isPlayer() && (baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value))) { + if ( + pokemon.isPlayer() && + (baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value)) + ) { valid.value = false; return true; } @@ -467,11 +487,63 @@ export class SingleGenerationChallenge extends Challenge { applyFixedBattle(waveIndex: number, battleConfig: FixedBattleConfig): boolean { let trainerTypes: (TrainerType | TrainerType[])[] = []; - const evilTeamWaves: number[] = [ ClassicFixedBossWaves.EVIL_GRUNT_1, ClassicFixedBossWaves.EVIL_GRUNT_2, ClassicFixedBossWaves.EVIL_GRUNT_3, ClassicFixedBossWaves.EVIL_ADMIN_1, ClassicFixedBossWaves.EVIL_GRUNT_4, ClassicFixedBossWaves.EVIL_ADMIN_2, ClassicFixedBossWaves.EVIL_BOSS_1, ClassicFixedBossWaves.EVIL_BOSS_2 ]; - const evilTeamGrunts = [[ TrainerType.ROCKET_GRUNT ], [ TrainerType.ROCKET_GRUNT ], [ TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT ], [ TrainerType.GALACTIC_GRUNT ], [ TrainerType.PLASMA_GRUNT ], [ TrainerType.FLARE_GRUNT ], [ TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT ], [ TrainerType.MACRO_GRUNT ], [ TrainerType.STAR_GRUNT ]]; - const evilTeamAdmins = [[ TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL ], [ TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL ], [[ TrainerType.TABITHA, TrainerType.COURTNEY ], [ TrainerType.MATT, TrainerType.SHELLY ]], [ TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN ], [ TrainerType.ZINZOLIN, TrainerType.COLRESS ], [ TrainerType.XEROSIC, TrainerType.BRYONY ], [ TrainerType.FABA, TrainerType.PLUMERIA ], [ TrainerType.OLEANA ], [ TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI ]]; - const evilTeamBosses = [[ TrainerType.ROCKET_BOSS_GIOVANNI_1 ], [ TrainerType.ROCKET_BOSS_GIOVANNI_1 ], [ TrainerType.MAXIE, TrainerType.ARCHIE ], [ TrainerType.CYRUS ], [ TrainerType.GHETSIS ], [ TrainerType.LYSANDRE ], [ TrainerType.LUSAMINE, TrainerType.GUZMA ], [ TrainerType.ROSE ], [ TrainerType.PENNY ]]; - const evilTeamBossRematches = [[ TrainerType.ROCKET_BOSS_GIOVANNI_2 ], [ TrainerType.ROCKET_BOSS_GIOVANNI_2 ], [ TrainerType.MAXIE_2, TrainerType.ARCHIE_2 ], [ TrainerType.CYRUS_2 ], [ TrainerType.GHETSIS_2 ], [ TrainerType.LYSANDRE_2 ], [ TrainerType.LUSAMINE_2, TrainerType.GUZMA_2 ], [ TrainerType.ROSE_2 ], [ TrainerType.PENNY_2 ]]; + const evilTeamWaves: number[] = [ + ClassicFixedBossWaves.EVIL_GRUNT_1, + ClassicFixedBossWaves.EVIL_GRUNT_2, + ClassicFixedBossWaves.EVIL_GRUNT_3, + ClassicFixedBossWaves.EVIL_ADMIN_1, + ClassicFixedBossWaves.EVIL_GRUNT_4, + ClassicFixedBossWaves.EVIL_ADMIN_2, + ClassicFixedBossWaves.EVIL_BOSS_1, + ClassicFixedBossWaves.EVIL_BOSS_2, + ]; + const evilTeamGrunts = [ + [TrainerType.ROCKET_GRUNT], + [TrainerType.ROCKET_GRUNT], + [TrainerType.MAGMA_GRUNT, TrainerType.AQUA_GRUNT], + [TrainerType.GALACTIC_GRUNT], + [TrainerType.PLASMA_GRUNT], + [TrainerType.FLARE_GRUNT], + [TrainerType.AETHER_GRUNT, TrainerType.SKULL_GRUNT], + [TrainerType.MACRO_GRUNT], + [TrainerType.STAR_GRUNT], + ]; + const evilTeamAdmins = [ + [TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL], + [TrainerType.ARCHER, TrainerType.ARIANA, TrainerType.PROTON, TrainerType.PETREL], + [ + [TrainerType.TABITHA, TrainerType.COURTNEY], + [TrainerType.MATT, TrainerType.SHELLY], + ], + [TrainerType.JUPITER, TrainerType.MARS, TrainerType.SATURN], + [TrainerType.ZINZOLIN, TrainerType.COLRESS], + [TrainerType.XEROSIC, TrainerType.BRYONY], + [TrainerType.FABA, TrainerType.PLUMERIA], + [TrainerType.OLEANA], + [TrainerType.GIACOMO, TrainerType.MELA, TrainerType.ATTICUS, TrainerType.ORTEGA, TrainerType.ERI], + ]; + const evilTeamBosses = [ + [TrainerType.ROCKET_BOSS_GIOVANNI_1], + [TrainerType.ROCKET_BOSS_GIOVANNI_1], + [TrainerType.MAXIE, TrainerType.ARCHIE], + [TrainerType.CYRUS], + [TrainerType.GHETSIS], + [TrainerType.LYSANDRE], + [TrainerType.LUSAMINE, TrainerType.GUZMA], + [TrainerType.ROSE], + [TrainerType.PENNY], + ]; + const evilTeamBossRematches = [ + [TrainerType.ROCKET_BOSS_GIOVANNI_2], + [TrainerType.ROCKET_BOSS_GIOVANNI_2], + [TrainerType.MAXIE_2, TrainerType.ARCHIE_2], + [TrainerType.CYRUS_2], + [TrainerType.GHETSIS_2], + [TrainerType.LYSANDRE_2], + [TrainerType.LUSAMINE_2, TrainerType.GUZMA_2], + [TrainerType.ROSE_2], + [TrainerType.PENNY_2], + ]; switch (waveIndex) { case ClassicFixedBossWaves.EVIL_GRUNT_1: trainerTypes = evilTeamGrunts[this.value - 1]; @@ -488,42 +560,123 @@ export class SingleGenerationChallenge extends Challenge { break; case ClassicFixedBossWaves.EVIL_BOSS_1: trainerTypes = evilTeamBosses[this.value - 1]; - battleConfig.setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1).setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }); + battleConfig + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ], + allowLuckUpgrades: false, + }); return true; case ClassicFixedBossWaves.EVIL_BOSS_2: trainerTypes = evilTeamBossRematches[this.value - 1]; - battleConfig.setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1).setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)) - .setCustomModifierRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA ], allowLuckUpgrades: false }); + battleConfig + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)) + .setCustomModifierRewards({ + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ], + allowLuckUpgrades: false, + }); return true; case ClassicFixedBossWaves.ELITE_FOUR_1: - trainerTypes = [ TrainerType.LORELEI, TrainerType.WILL, TrainerType.SIDNEY, TrainerType.AARON, TrainerType.SHAUNTAL, TrainerType.MALVA, Utils.randSeedItem([ TrainerType.HALA, TrainerType.MOLAYNE ]), TrainerType.MARNIE_ELITE, TrainerType.RIKA ]; + trainerTypes = [ + TrainerType.LORELEI, + TrainerType.WILL, + TrainerType.SIDNEY, + TrainerType.AARON, + TrainerType.SHAUNTAL, + TrainerType.MALVA, + Utils.randSeedItem([TrainerType.HALA, TrainerType.MOLAYNE]), + TrainerType.MARNIE_ELITE, + TrainerType.RIKA, + ]; break; case ClassicFixedBossWaves.ELITE_FOUR_2: - trainerTypes = [ TrainerType.BRUNO, TrainerType.KOGA, TrainerType.PHOEBE, TrainerType.BERTHA, TrainerType.MARSHAL, TrainerType.SIEBOLD, TrainerType.OLIVIA, TrainerType.NESSA_ELITE, TrainerType.POPPY ]; + trainerTypes = [ + TrainerType.BRUNO, + TrainerType.KOGA, + TrainerType.PHOEBE, + TrainerType.BERTHA, + TrainerType.MARSHAL, + TrainerType.SIEBOLD, + TrainerType.OLIVIA, + TrainerType.NESSA_ELITE, + TrainerType.POPPY, + ]; break; case ClassicFixedBossWaves.ELITE_FOUR_3: - trainerTypes = [ TrainerType.AGATHA, TrainerType.BRUNO, TrainerType.GLACIA, TrainerType.FLINT, TrainerType.GRIMSLEY, TrainerType.WIKSTROM, TrainerType.ACEROLA, Utils.randSeedItem([ TrainerType.BEA_ELITE, TrainerType.ALLISTER_ELITE ]), TrainerType.LARRY_ELITE ]; + trainerTypes = [ + TrainerType.AGATHA, + TrainerType.BRUNO, + TrainerType.GLACIA, + TrainerType.FLINT, + TrainerType.GRIMSLEY, + TrainerType.WIKSTROM, + TrainerType.ACEROLA, + Utils.randSeedItem([TrainerType.BEA_ELITE, TrainerType.ALLISTER_ELITE]), + TrainerType.LARRY_ELITE, + ]; break; case ClassicFixedBossWaves.ELITE_FOUR_4: - trainerTypes = [ TrainerType.LANCE, TrainerType.KAREN, TrainerType.DRAKE, TrainerType.LUCIAN, TrainerType.CAITLIN, TrainerType.DRASNA, TrainerType.KAHILI, TrainerType.RAIHAN_ELITE, TrainerType.HASSEL ]; + trainerTypes = [ + TrainerType.LANCE, + TrainerType.KAREN, + TrainerType.DRAKE, + TrainerType.LUCIAN, + TrainerType.CAITLIN, + TrainerType.DRASNA, + TrainerType.KAHILI, + TrainerType.RAIHAN_ELITE, + TrainerType.HASSEL, + ]; break; case ClassicFixedBossWaves.CHAMPION: - trainerTypes = [ TrainerType.BLUE, Utils.randSeedItem([ TrainerType.RED, TrainerType.LANCE_CHAMPION ]), Utils.randSeedItem([ TrainerType.STEVEN, TrainerType.WALLACE ]), TrainerType.CYNTHIA, Utils.randSeedItem([ TrainerType.ALDER, TrainerType.IRIS ]), TrainerType.DIANTHA, Utils.randSeedItem([ TrainerType.KUKUI, TrainerType.HAU ]), Utils.randSeedItem([ TrainerType.LEON, TrainerType.MUSTARD ]), Utils.randSeedItem([ TrainerType.GEETA, TrainerType.NEMONA ]) ]; + trainerTypes = [ + TrainerType.BLUE, + Utils.randSeedItem([TrainerType.RED, TrainerType.LANCE_CHAMPION]), + Utils.randSeedItem([TrainerType.STEVEN, TrainerType.WALLACE]), + TrainerType.CYNTHIA, + Utils.randSeedItem([TrainerType.ALDER, TrainerType.IRIS]), + TrainerType.DIANTHA, + Utils.randSeedItem([TrainerType.KUKUI, TrainerType.HAU]), + Utils.randSeedItem([TrainerType.LEON, TrainerType.MUSTARD]), + Utils.randSeedItem([TrainerType.GEETA, TrainerType.NEMONA]), + ]; break; } if (trainerTypes.length === 0) { return false; - } else if (evilTeamWaves.includes(waveIndex)) { - battleConfig.setBattleType(BattleType.TRAINER).setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1).setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)); - return true; - } else if (waveIndex >= ClassicFixedBossWaves.ELITE_FOUR_1 && waveIndex <= ClassicFixedBossWaves.CHAMPION) { - const ttypes = trainerTypes as TrainerType[]; - battleConfig.setBattleType(BattleType.TRAINER).setGetTrainerFunc(() => new Trainer(ttypes[this.value - 1], TrainerVariant.DEFAULT)); - return true; - } else { - return false; } + if (evilTeamWaves.includes(waveIndex)) { + battleConfig + .setBattleType(BattleType.TRAINER) + .setSeedOffsetWave(ClassicFixedBossWaves.EVIL_GRUNT_1) + .setGetTrainerFunc(getRandomTrainerFunc(trainerTypes, true)); + return true; + } + if (waveIndex >= ClassicFixedBossWaves.ELITE_FOUR_1 && waveIndex <= ClassicFixedBossWaves.CHAMPION) { + const ttypes = trainerTypes as TrainerType[]; + battleConfig + .setBattleType(BattleType.TRAINER) + .setGetTrainerFunc(() => new Trainer(ttypes[this.value - 1], TrainerVariant.DEFAULT)); + return true; + } + return false; } /** @@ -556,10 +709,11 @@ export class SingleGenerationChallenge extends Challenge { if (value === 0) { return i18next.t("challenges:singleGeneration.desc_default"); } - return i18next.t("challenges:singleGeneration.desc", { gen: i18next.t(`challenges:singleGeneration.gen_${value}`) }); + return i18next.t("challenges:singleGeneration.desc", { + gen: i18next.t(`challenges:singleGeneration.gen_${value}`), + }); } - static loadChallenge(source: SingleGenerationChallenge | any): SingleGenerationChallenge { const newChallenge = new SingleGenerationChallenge(); newChallenge.value = source.value; @@ -585,17 +739,22 @@ export class SingleTypeChallenge extends Challenge { { species: Species.CASTFORM, type: PokemonType.NORMAL, fusion: false }, ]; // TODO: Find a solution for all Pokemon with this ssui issue, including Basculin and Burmy - private static SPECIES_OVERRIDES: Species[] = [ Species.MELOETTA ]; + private static SPECIES_OVERRIDES: Species[] = [Species.MELOETTA]; constructor() { super(Challenges.SINGLE_TYPE, 18); } - override applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean { + override applyStarterChoice( + pokemon: PokemonSpecies, + valid: Utils.BooleanHolder, + dexAttr: DexAttrProps, + soft = false, + ): boolean { const speciesForm = getPokemonSpeciesForm(pokemon.speciesId, dexAttr.formIndex); - const types = [ speciesForm.type1, speciesForm.type2 ]; + const types = [speciesForm.type1, speciesForm.type2]; if (soft && !SingleTypeChallenge.SPECIES_OVERRIDES.includes(pokemon.speciesId)) { - const speciesToCheck = [ pokemon.speciesId ]; + const speciesToCheck = [pokemon.speciesId]; while (speciesToCheck.length) { const checking = speciesToCheck.pop(); if (checking && pokemonEvolutions.hasOwnProperty(checking)) { @@ -623,8 +782,16 @@ export class SingleTypeChallenge extends Challenge { } applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { - if (pokemon.isPlayer() && !pokemon.isOfType(this.value - 1, false, false, true) - && !SingleTypeChallenge.TYPE_OVERRIDES.some(o => o.type === (this.value - 1) && (pokemon.isFusion() && o.fusion ? pokemon.fusionSpecies! : pokemon.species).speciesId === o.species)) { // TODO: is the bang on fusionSpecies correct? + if ( + pokemon.isPlayer() && + !pokemon.isOfType(this.value - 1, false, false, true) && + !SingleTypeChallenge.TYPE_OVERRIDES.some( + o => + o.type === this.value - 1 && + (pokemon.isFusion() && o.fusion ? pokemon.fusionSpecies! : pokemon.species).speciesId === o.species, + ) + ) { + // TODO: is the bang on fusionSpecies correct? valid.value = false; return true; } @@ -662,7 +829,9 @@ export class SingleTypeChallenge extends Challenge { const type = i18next.t(`pokemonInfo:Type.${PokemonType[this.value - 1]}`); const typeColor = `[color=${TypeColor[PokemonType[this.value - 1]]}][shadow=${TypeShadow[PokemonType[this.value - 1]]}]${type}[/shadow][/color]`; const defaultDesc = i18next.t("challenges:singleType.desc_default"); - const typeDesc = i18next.t("challenges:singleType.desc", { type: typeColor }); + const typeDesc = i18next.t("challenges:singleType.desc", { + type: typeColor, + }); return this.value === 0 ? defaultDesc : typeDesc; } @@ -702,12 +871,17 @@ export class FreshStartChallenge extends Challenge { pokemon.abilityIndex = 0; // Always base ability, not hidden ability pokemon.passive = false; // Passive isn't unlocked pokemon.nature = Nature.HARDY; // Neutral nature - pokemon.moveset = pokemon.species.getLevelMoves().filter(m => m[0] <= 5).map(lm => lm[1]).slice(0, 4).map(m => new PokemonMove(m)); // No egg moves + pokemon.moveset = pokemon.species + .getLevelMoves() + .filter(m => m[0] <= 5) + .map(lm => lm[1]) + .slice(0, 4) + .map(m => new PokemonMove(m)); // No egg moves pokemon.luck = 0; // No luck pokemon.shiny = false; // Not shiny pokemon.variant = 0; // Not shiny pokemon.formIndex = 0; // Froakie should be base form - pokemon.ivs = [ 15, 15, 15, 15, 15, 15 ]; // Default IVs of 15 for all stats (Updated to 15 from 10 in 1.2.0) + pokemon.ivs = [15, 15, 15, 15, 15, 15]; // Default IVs of 15 for all stats (Updated to 15 from 10 in 1.2.0) pokemon.teraType = pokemon.species.type1; // Always primary tera type return true; } @@ -747,7 +921,8 @@ export class InverseBattleChallenge extends Challenge { if (effectiveness.value < 1) { effectiveness.value = 2; return true; - } else if (effectiveness.value > 1) { + } + if (effectiveness.value > 1) { effectiveness.value = 0.5; return true; } @@ -764,7 +939,7 @@ export class FlipStatChallenge extends Challenge { super(Challenges.FLIP_STAT, 1); } - override applyFlipStat(pokemon: Pokemon, baseStats: number[]) { + override applyFlipStat(_pokemon: Pokemon, baseStats: number[]) { const origStats = Utils.deepCopy(baseStats); baseStats[0] = origStats[5]; baseStats[1] = origStats[4]; @@ -858,7 +1033,14 @@ export class LowerStarterPointsChallenge extends Challenge { * @param soft {@link boolean} If true, allow it if it could become a valid pokemon. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.STARTER_CHOICE, pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.STARTER_CHOICE, + pokemon: PokemonSpecies, + valid: Utils.BooleanHolder, + dexAttr: DexAttrProps, + soft: boolean, +): boolean; /** * Apply all challenges that modify available total starter points. * @param gameMode {@link GameMode} The current gameMode @@ -866,7 +1048,11 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param points {@link Utils.NumberHolder} The amount of points you have available. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.STARTER_POINTS, points: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.STARTER_POINTS, + points: Utils.NumberHolder, +): boolean; /** * Apply all challenges that modify the cost of a starter. * @param gameMode {@link GameMode} The current gameMode @@ -875,7 +1061,12 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param points {@link Utils.NumberHolder} The cost of the pokemon. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.STARTER_COST, species: Species, cost: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.STARTER_COST, + species: Species, + cost: Utils.NumberHolder, +): boolean; /** * Apply all challenges that modify a starter after selection. * @param gameMode {@link GameMode} The current gameMode @@ -883,7 +1074,11 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param pokemon {@link Pokemon} The starter pokemon to modify. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.STARTER_MODIFY, pokemon: Pokemon): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.STARTER_MODIFY, + pokemon: Pokemon, +): boolean; /** * Apply all challenges that what pokemon you can have in battle. * @param gameMode {@link GameMode} The current gameMode @@ -892,7 +1087,12 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param valid {@link Utils.BooleanHolder} A BooleanHolder, the value gets set to false if the pokemon isn't allowed. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.POKEMON_IN_BATTLE, pokemon: Pokemon, valid: Utils.BooleanHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.POKEMON_IN_BATTLE, + pokemon: Pokemon, + valid: Utils.BooleanHolder, +): boolean; /** * Apply all challenges that modify what fixed battles there are. * @param gameMode {@link GameMode} The current gameMode @@ -901,7 +1101,12 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param battleConfig {@link FixedBattleConfig} The battle config to modify. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.FIXED_BATTLES, waveIndex: Number, battleConfig: FixedBattleConfig): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.FIXED_BATTLES, + waveIndex: number, + battleConfig: FixedBattleConfig, +): boolean; /** * Apply all challenges that modify type effectiveness. * @param gameMode {@linkcode GameMode} The current gameMode @@ -909,7 +1114,11 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param effectiveness {@linkcode Utils.NumberHolder} The current effectiveness of the move. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.TYPE_EFFECTIVENESS, effectiveness: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.TYPE_EFFECTIVENESS, + effectiveness: Utils.NumberHolder, +): boolean; /** * Apply all challenges that modify what level AI are. * @param gameMode {@link GameMode} The current gameMode @@ -920,7 +1129,14 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param isBoss {@link Boolean} Whether this is a non-trainer boss pokemon. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_LEVEL, level: Utils.NumberHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.AI_LEVEL, + level: Utils.NumberHolder, + levelCap: number, + isTrainer: boolean, + isBoss: boolean, +): boolean; /** * Apply all challenges that modify how many move slots the AI has. * @param gameMode {@link GameMode} The current gameMode @@ -929,7 +1145,12 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param moveSlots {@link Utils.NumberHolder} The amount of move slots. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_MOVE_SLOTS, pokemon: Pokemon, moveSlots: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.AI_MOVE_SLOTS, + pokemon: Pokemon, + moveSlots: Utils.NumberHolder, +): boolean; /** * Apply all challenges that modify whether a pokemon has its passive. * @param gameMode {@link GameMode} The current gameMode @@ -938,7 +1159,12 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param hasPassive {@link Utils.BooleanHolder} Whether it has its passive. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.PASSIVE_ACCESS, pokemon: Pokemon, hasPassive: Utils.BooleanHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.PASSIVE_ACCESS, + pokemon: Pokemon, + hasPassive: Utils.BooleanHolder, +): boolean; /** * Apply all challenges that modify the game modes settings. * @param gameMode {@link GameMode} The current gameMode @@ -956,7 +1182,14 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param level {@link Utils.NumberHolder} The level threshold for access. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_ACCESS, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.MOVE_ACCESS, + pokemon: Pokemon, + moveSource: MoveSourceType, + move: Moves, + level: Utils.NumberHolder, +): boolean; /** * Apply all challenges that modify what weight a pokemon gives to move generation * @param gameMode {@link GameMode} The current gameMode @@ -967,9 +1200,21 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param weight {@link Utils.NumberHolder} The weight of the move. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_WEIGHT, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, weight: Utils.NumberHolder): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.MOVE_WEIGHT, + pokemon: Pokemon, + moveSource: MoveSourceType, + move: Moves, + weight: Utils.NumberHolder, +): boolean; -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.FLIP_STAT, pokemon: Pokemon, baseStats: number[]): boolean; +export function applyChallenges( + gameMode: GameMode, + challengeType: ChallengeType.FLIP_STAT, + pokemon: Pokemon, + baseStats: number[], +): boolean; export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType, ...args: any[]): boolean { let ret = false; @@ -1057,6 +1302,6 @@ export function initChallenges() { new SingleTypeChallenge(), new FreshStartChallenge(), new InverseBattleChallenge(), - new FlipStatChallenge() + new FlipStatChallenge(), ); } diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index df6c08fc0f0..22fb7db10ae 100644 --- a/src/data/daily-run.ts +++ b/src/data/daily-run.ts @@ -16,7 +16,7 @@ export interface DailyRunConfig { } export function fetchDailyRunSeed(): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { pokerogueApi.daily.getSeed().then(dailySeed => { resolve(dailySeed); }); @@ -26,55 +26,76 @@ export function fetchDailyRunSeed(): Promise { export function getDailyRunStarters(seed: string): Starter[] { const starters: Starter[] = []; - globalScene.executeWithSeedOffset(() => { - const startingLevel = globalScene.gameMode.getStartingLevel(); + globalScene.executeWithSeedOffset( + () => { + const startingLevel = globalScene.gameMode.getStartingLevel(); - if (/\d{18}$/.test(seed)) { - for (let s = 0; s < 3; s++) { - const offset = 6 + s * 6; - const starterSpeciesForm = getPokemonSpeciesForm(parseInt(seed.slice(offset, offset + 4)) as Species, parseInt(seed.slice(offset + 4, offset + 6))); - starters.push(getDailyRunStarter(starterSpeciesForm, startingLevel)); + if (/\d{18}$/.test(seed)) { + for (let s = 0; s < 3; s++) { + const offset = 6 + s * 6; + const starterSpeciesForm = getPokemonSpeciesForm( + Number.parseInt(seed.slice(offset, offset + 4)) as Species, + Number.parseInt(seed.slice(offset + 4, offset + 6)), + ); + starters.push(getDailyRunStarter(starterSpeciesForm, startingLevel)); + } + return; } - return; - } - const starterCosts: number[] = []; - starterCosts.push(Math.min(Math.round(3.5 + Math.abs(Utils.randSeedGauss(1))), 8)); - starterCosts.push(Utils.randSeedInt(9 - starterCosts[0], 1)); - starterCosts.push(10 - (starterCosts[0] + starterCosts[1])); + const starterCosts: number[] = []; + starterCosts.push(Math.min(Math.round(3.5 + Math.abs(Utils.randSeedGauss(1))), 8)); + starterCosts.push(Utils.randSeedInt(9 - starterCosts[0], 1)); + starterCosts.push(10 - (starterCosts[0] + starterCosts[1])); - for (let c = 0; c < starterCosts.length; c++) { - const cost = starterCosts[c]; - const costSpecies = Object.keys(speciesStarterCosts) - .map(s => parseInt(s) as Species) - .filter(s => speciesStarterCosts[s] === cost); - const randPkmSpecies = getPokemonSpecies(Utils.randSeedItem(costSpecies)); - const starterSpecies = getPokemonSpecies(randPkmSpecies.getTrainerSpeciesForLevel(startingLevel, true, PartyMemberStrength.STRONGER)); - starters.push(getDailyRunStarter(starterSpecies, startingLevel)); - } - }, 0, seed); + for (let c = 0; c < starterCosts.length; c++) { + const cost = starterCosts[c]; + const costSpecies = Object.keys(speciesStarterCosts) + .map(s => Number.parseInt(s) as Species) + .filter(s => speciesStarterCosts[s] === cost); + const randPkmSpecies = getPokemonSpecies(Utils.randSeedItem(costSpecies)); + const starterSpecies = getPokemonSpecies( + randPkmSpecies.getTrainerSpeciesForLevel(startingLevel, true, PartyMemberStrength.STRONGER), + ); + starters.push(getDailyRunStarter(starterSpecies, startingLevel)); + } + }, + 0, + seed, + ); return starters; } function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLevel: number): Starter { - const starterSpecies = starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId); + const starterSpecies = + starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId); const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex; - const pokemon = new PlayerPokemon(starterSpecies, startingLevel, undefined, formIndex, undefined, undefined, undefined, undefined, undefined, undefined); + const pokemon = new PlayerPokemon( + starterSpecies, + startingLevel, + undefined, + formIndex, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + ); const starter: Starter = { species: starterSpecies, dexAttr: pokemon.getDexAttr(), abilityIndex: pokemon.abilityIndex, passive: false, nature: pokemon.getNature(), - pokerus: pokemon.pokerus + pokerus: pokemon.pokerus, }; pokemon.destroy(); return starter; } interface BiomeWeights { - [key: number]: number + [key: number]: number; } // Initially weighted by amount of exits each biome has diff --git a/src/data/dialogue.ts b/src/data/dialogue.ts index f4933a070fd..208e269bd9c 100644 --- a/src/data/dialogue.ts +++ b/src/data/dialogue.ts @@ -3,13 +3,13 @@ import { TrainerType } from "#enums/trainer-type"; import { trainerConfigs } from "./trainer-config"; export interface TrainerTypeMessages { - encounter?: string | string[], - victory?: string | string[], - defeat?: string | string[] + encounter?: string | string[]; + victory?: string | string[]; + defeat?: string | string[]; } export interface TrainerTypeDialogue { - [key: number]: TrainerTypeMessages | Array + [key: number]: TrainerTypeMessages | Array; } export function getTrainerTypeDialogue(): TrainerTypeDialogue { @@ -32,7 +32,7 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:youngster.encounter.10", "dialogue:youngster.encounter.11", "dialogue:youngster.encounter.12", - "dialogue:youngster.encounter.13" + "dialogue:youngster.encounter.13", ], victory: [ "dialogue:youngster.victory.1", @@ -48,7 +48,7 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:youngster.victory.11", "dialogue:youngster.victory.12", "dialogue:youngster.victory.13", - ] + ], }, //LASS { @@ -61,7 +61,7 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:lass.encounter.6", "dialogue:lass.encounter.7", "dialogue:lass.encounter.8", - "dialogue:lass.encounter.9" + "dialogue:lass.encounter.9", ], victory: [ "dialogue:lass.victory.1", @@ -72,27 +72,15 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:lass.victory.6", "dialogue:lass.victory.7", "dialogue:lass.victory.8", - "dialogue:lass.victory.9" - ] - } + "dialogue:lass.victory.9", + ], + }, ], [TrainerType.BREEDER]: [ { - encounter: [ - "dialogue:breeder.encounter.1", - "dialogue:breeder.encounter.2", - "dialogue:breeder.encounter.3", - ], - victory: [ - "dialogue:breeder.victory.1", - "dialogue:breeder.victory.2", - "dialogue:breeder.victory.3", - ], - defeat: [ - "dialogue:breeder.defeat.1", - "dialogue:breeder.defeat.2", - "dialogue:breeder.defeat.3", - ] + encounter: ["dialogue:breeder.encounter.1", "dialogue:breeder.encounter.2", "dialogue:breeder.encounter.3"], + victory: ["dialogue:breeder.victory.1", "dialogue:breeder.victory.2", "dialogue:breeder.victory.3"], + defeat: ["dialogue:breeder.defeat.1", "dialogue:breeder.defeat.2", "dialogue:breeder.defeat.3"], }, { encounter: [ @@ -109,21 +97,13 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:breeder_female.defeat.1", "dialogue:breeder_female.defeat.2", "dialogue:breeder_female.defeat.3", - ] - } + ], + }, ], [TrainerType.FISHERMAN]: [ { - encounter: [ - "dialogue:fisherman.encounter.1", - "dialogue:fisherman.encounter.2", - "dialogue:fisherman.encounter.3", - ], - victory: [ - "dialogue:fisherman.victory.1", - "dialogue:fisherman.victory.2", - "dialogue:fisherman.victory.3", - ] + encounter: ["dialogue:fisherman.encounter.1", "dialogue:fisherman.encounter.2", "dialogue:fisherman.encounter.3"], + victory: ["dialogue:fisherman.victory.1", "dialogue:fisherman.victory.2", "dialogue:fisherman.victory.3"], }, { encounter: [ @@ -135,22 +115,14 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:fisherman_female.victory.1", "dialogue:fisherman_female.victory.2", "dialogue:fisherman_female.victory.3", - ] - } + ], + }, ], [TrainerType.SWIMMER]: [ { - encounter: [ - "dialogue:swimmer.encounter.1", - "dialogue:swimmer.encounter.2", - "dialogue:swimmer.encounter.3", - ], - victory: [ - "dialogue:swimmer.victory.1", - "dialogue:swimmer.victory.2", - "dialogue:swimmer.victory.3", - ] - } + encounter: ["dialogue:swimmer.encounter.1", "dialogue:swimmer.encounter.2", "dialogue:swimmer.encounter.3"], + victory: ["dialogue:swimmer.victory.1", "dialogue:swimmer.victory.2", "dialogue:swimmer.victory.3"], + }, ], [TrainerType.BACKPACKER]: [ { @@ -165,8 +137,8 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:backpacker.victory.2", "dialogue:backpacker.victory.3", "dialogue:backpacker.victory.4", - ] - } + ], + }, ], [TrainerType.ACE_TRAINER]: [ { @@ -187,258 +159,138 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:ace_trainer.defeat.2", "dialogue:ace_trainer.defeat.3", "dialogue:ace_trainer.defeat.4", - ] - } + ], + }, ], [TrainerType.PARASOL_LADY]: [ { - encounter: [ - "dialogue:parasol_lady.encounter.1", - ], - victory: [ - "dialogue:parasol_lady.victory.1", - ] - } + encounter: ["dialogue:parasol_lady.encounter.1"], + victory: ["dialogue:parasol_lady.victory.1"], + }, ], [TrainerType.TWINS]: [ { - encounter: [ - "dialogue:twins.encounter.1", - "dialogue:twins.encounter.2", - "dialogue:twins.encounter.3", - ], - victory: [ - "dialogue:twins.victory.1", - "dialogue:twins.victory.2", - "dialogue:twins.victory.3", - ], - defeat: [ - "dialogue:twins.defeat.1", - "dialogue:twins.defeat.2", - "dialogue:twins.defeat.3", - ], - } + encounter: ["dialogue:twins.encounter.1", "dialogue:twins.encounter.2", "dialogue:twins.encounter.3"], + victory: ["dialogue:twins.victory.1", "dialogue:twins.victory.2", "dialogue:twins.victory.3"], + defeat: ["dialogue:twins.defeat.1", "dialogue:twins.defeat.2", "dialogue:twins.defeat.3"], + }, ], [TrainerType.CYCLIST]: [ { - encounter: [ - "dialogue:cyclist.encounter.1", - "dialogue:cyclist.encounter.2", - "dialogue:cyclist.encounter.3", - ], - victory: [ - "dialogue:cyclist.victory.1", - "dialogue:cyclist.victory.2", - "dialogue:cyclist.victory.3", - ] - } + encounter: ["dialogue:cyclist.encounter.1", "dialogue:cyclist.encounter.2", "dialogue:cyclist.encounter.3"], + victory: ["dialogue:cyclist.victory.1", "dialogue:cyclist.victory.2", "dialogue:cyclist.victory.3"], + }, ], [TrainerType.BLACK_BELT]: [ { - encounter: [ - "dialogue:black_belt.encounter.1", - "dialogue:black_belt.encounter.2", - ], - victory: [ - "dialogue:black_belt.victory.1", - "dialogue:black_belt.victory.2", - ] + encounter: ["dialogue:black_belt.encounter.1", "dialogue:black_belt.encounter.2"], + victory: ["dialogue:black_belt.victory.1", "dialogue:black_belt.victory.2"], }, //BATTLE GIRL { - encounter: [ - "dialogue:battle_girl.encounter.1", - ], - victory: [ - "dialogue:battle_girl.victory.1", - ] - } + encounter: ["dialogue:battle_girl.encounter.1"], + victory: ["dialogue:battle_girl.victory.1"], + }, ], [TrainerType.HIKER]: [ { - encounter: [ - "dialogue:hiker.encounter.1", - "dialogue:hiker.encounter.2", - ], - victory: [ - "dialogue:hiker.victory.1", - "dialogue:hiker.victory.2", - ] - } + encounter: ["dialogue:hiker.encounter.1", "dialogue:hiker.encounter.2"], + victory: ["dialogue:hiker.victory.1", "dialogue:hiker.victory.2"], + }, ], [TrainerType.RANGER]: [ { - encounter: [ - "dialogue:ranger.encounter.1", - "dialogue:ranger.encounter.2", - ], - victory: [ - "dialogue:ranger.victory.1", - "dialogue:ranger.victory.2", - ], - defeat: [ - "dialogue:ranger.defeat.1", - "dialogue:ranger.defeat.2", - ] - } + encounter: ["dialogue:ranger.encounter.1", "dialogue:ranger.encounter.2"], + victory: ["dialogue:ranger.victory.1", "dialogue:ranger.victory.2"], + defeat: ["dialogue:ranger.defeat.1", "dialogue:ranger.defeat.2"], + }, ], [TrainerType.SCIENTIST]: [ { - encounter: [ - "dialogue:scientist.encounter.1", - ], - victory: [ - "dialogue:scientist.victory.1", - ] - } + encounter: ["dialogue:scientist.encounter.1"], + victory: ["dialogue:scientist.victory.1"], + }, ], [TrainerType.SCHOOL_KID]: [ { - encounter: [ - "dialogue:school_kid.encounter.1", - "dialogue:school_kid.encounter.2", - ], - victory: [ - "dialogue:school_kid.victory.1", - "dialogue:school_kid.victory.2", - ] - } + encounter: ["dialogue:school_kid.encounter.1", "dialogue:school_kid.encounter.2"], + victory: ["dialogue:school_kid.victory.1", "dialogue:school_kid.victory.2"], + }, ], [TrainerType.ARTIST]: [ { - encounter: [ - "dialogue:artist.encounter.1", - ], - victory: [ - "dialogue:artist.victory.1", - ] - } + encounter: ["dialogue:artist.encounter.1"], + victory: ["dialogue:artist.victory.1"], + }, ], [TrainerType.GUITARIST]: [ { - encounter: [ - "dialogue:guitarist.encounter.1", - ], - victory: [ - "dialogue:guitarist.victory.1", - ] - } + encounter: ["dialogue:guitarist.encounter.1"], + victory: ["dialogue:guitarist.victory.1"], + }, ], [TrainerType.WORKER]: [ { - encounter: [ - "dialogue:worker.encounter.1", - ], - victory: [ - "dialogue:worker.victory.1", - ] + encounter: ["dialogue:worker.encounter.1"], + victory: ["dialogue:worker.victory.1"], }, { - encounter: [ - "dialogue:worker_female.encounter.1", - ], - victory: [ - "dialogue:worker_female.victory.1", - ], - defeat: [ - "dialogue:worker_female.defeat.1", - ] + encounter: ["dialogue:worker_female.encounter.1"], + victory: ["dialogue:worker_female.victory.1"], + defeat: ["dialogue:worker_female.defeat.1"], }, { - encounter: [ - "dialogue:worker_double.encounter.1", - ], - victory: [ - "dialogue:worker_double.victory.1", - ] + encounter: ["dialogue:worker_double.encounter.1"], + victory: ["dialogue:worker_double.victory.1"], }, ], // Defeat dialogue in the language .JSONS exist as translated or placeholders; (en, fr, it, es, de, ja, ko, zh_cn, zh_tw, pt_br) [TrainerType.SNOW_WORKER]: [ { - encounter: [ - "dialogue:snow_worker.encounter.1", - ], - victory: [ - "dialogue:snow_worker.victory.1", - ] + encounter: ["dialogue:snow_worker.encounter.1"], + victory: ["dialogue:snow_worker.victory.1"], }, { - encounter: [ - "dialogue:snow_worker_double.encounter.1", - ], - victory: [ - "dialogue:snow_worker_double.victory.1", - ] + encounter: ["dialogue:snow_worker_double.encounter.1"], + victory: ["dialogue:snow_worker_double.victory.1"], }, ], [TrainerType.HEX_MANIAC]: [ { - encounter: [ - "dialogue:hex_maniac.encounter.1", - "dialogue:hex_maniac.encounter.2", - ], - victory: [ - "dialogue:hex_maniac.victory.1", - "dialogue:hex_maniac.victory.2", - ], - defeat: [ - "dialogue:hex_maniac.defeat.1", - "dialogue:hex_maniac.defeat.2", - ] - } + encounter: ["dialogue:hex_maniac.encounter.1", "dialogue:hex_maniac.encounter.2"], + victory: ["dialogue:hex_maniac.victory.1", "dialogue:hex_maniac.victory.2"], + defeat: ["dialogue:hex_maniac.defeat.1", "dialogue:hex_maniac.defeat.2"], + }, ], [TrainerType.PSYCHIC]: [ { - encounter: [ - "dialogue:psychic.encounter.1", - ], - victory: [ - "dialogue:psychic.victory.1", - ] - } + encounter: ["dialogue:psychic.encounter.1"], + victory: ["dialogue:psychic.victory.1"], + }, ], [TrainerType.OFFICER]: [ { - encounter: [ - "dialogue:officer.encounter.1", - "dialogue:officer.encounter.2", - ], - victory: [ - "dialogue:officer.victory.1", - "dialogue:officer.victory.2", - ], - } + encounter: ["dialogue:officer.encounter.1", "dialogue:officer.encounter.2"], + victory: ["dialogue:officer.victory.1", "dialogue:officer.victory.2"], + }, ], [TrainerType.BEAUTY]: [ { - encounter: [ - "dialogue:beauty.encounter.1", - ], - victory: [ - "dialogue:beauty.victory.1", - ] - } + encounter: ["dialogue:beauty.encounter.1"], + victory: ["dialogue:beauty.victory.1"], + }, ], [TrainerType.BAKER]: [ { - encounter: [ - "dialogue:baker.encounter.1", - ], - victory: [ - "dialogue:baker.victory.1", - ] - } + encounter: ["dialogue:baker.encounter.1"], + victory: ["dialogue:baker.victory.1"], + }, ], [TrainerType.BIKER]: [ { - encounter: [ - "dialogue:biker.encounter.1", - ], - victory: [ - "dialogue:biker.victory.1", - ] - } + encounter: ["dialogue:biker.encounter.1"], + victory: ["dialogue:biker.victory.1"], + }, ], [TrainerType.FIREBREATHER]: [ { @@ -451,22 +303,14 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:firebreather.victory.1", "dialogue:firebreather.victory.2", "dialogue:firebreather.victory.3", - ] - } + ], + }, ], [TrainerType.SAILOR]: [ { - encounter: [ - "dialogue:sailor.encounter.1", - "dialogue:sailor.encounter.2", - "dialogue:sailor.encounter.3", - ], - victory: [ - "dialogue:sailor.victory.1", - "dialogue:sailor.victory.2", - "dialogue:sailor.victory.3", - ] - } + encounter: ["dialogue:sailor.encounter.1", "dialogue:sailor.encounter.2", "dialogue:sailor.encounter.3"], + victory: ["dialogue:sailor.victory.1", "dialogue:sailor.victory.2", "dialogue:sailor.victory.3"], + }, ], [TrainerType.ROCKET_GRUNT]: [ { @@ -483,64 +327,32 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:rocket_grunt.victory.3", "dialogue:rocket_grunt.victory.4", "dialogue:rocket_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.ARCHER]: [ { - encounter: [ - "dialogue:archer.encounter.1", - "dialogue:archer.encounter.2", - "dialogue:archer.encounter.3", - ], - victory: [ - "dialogue:archer.victory.1", - "dialogue:archer.victory.2", - "dialogue:archer.victory.3", - ] - } + encounter: ["dialogue:archer.encounter.1", "dialogue:archer.encounter.2", "dialogue:archer.encounter.3"], + victory: ["dialogue:archer.victory.1", "dialogue:archer.victory.2", "dialogue:archer.victory.3"], + }, ], [TrainerType.ARIANA]: [ { - encounter: [ - "dialogue:ariana.encounter.1", - "dialogue:ariana.encounter.2", - "dialogue:ariana.encounter.3", - ], - victory: [ - "dialogue:ariana.victory.1", - "dialogue:ariana.victory.2", - "dialogue:ariana.victory.3", - ] - } + encounter: ["dialogue:ariana.encounter.1", "dialogue:ariana.encounter.2", "dialogue:ariana.encounter.3"], + victory: ["dialogue:ariana.victory.1", "dialogue:ariana.victory.2", "dialogue:ariana.victory.3"], + }, ], [TrainerType.PROTON]: [ { - encounter: [ - "dialogue:proton.encounter.1", - "dialogue:proton.encounter.2", - "dialogue:proton.encounter.3", - ], - victory: [ - "dialogue:proton.victory.1", - "dialogue:proton.victory.2", - "dialogue:proton.victory.3", - ] - } + encounter: ["dialogue:proton.encounter.1", "dialogue:proton.encounter.2", "dialogue:proton.encounter.3"], + victory: ["dialogue:proton.victory.1", "dialogue:proton.victory.2", "dialogue:proton.victory.3"], + }, ], [TrainerType.PETREL]: [ { - encounter: [ - "dialogue:petrel.encounter.1", - "dialogue:petrel.encounter.2", - "dialogue:petrel.encounter.3", - ], - victory: [ - "dialogue:petrel.victory.1", - "dialogue:petrel.victory.2", - "dialogue:petrel.victory.3", - ] - } + encounter: ["dialogue:petrel.encounter.1", "dialogue:petrel.encounter.2", "dialogue:petrel.encounter.3"], + victory: ["dialogue:petrel.victory.1", "dialogue:petrel.victory.2", "dialogue:petrel.victory.3"], + }, ], [TrainerType.MAGMA_GRUNT]: [ { @@ -557,36 +369,20 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:magma_grunt.victory.3", "dialogue:magma_grunt.victory.4", "dialogue:magma_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.TABITHA]: [ { - encounter: [ - "dialogue:tabitha.encounter.1", - "dialogue:tabitha.encounter.2", - "dialogue:tabitha.encounter.3", - ], - victory: [ - "dialogue:tabitha.victory.1", - "dialogue:tabitha.victory.2", - "dialogue:tabitha.victory.3", - ] - } + encounter: ["dialogue:tabitha.encounter.1", "dialogue:tabitha.encounter.2", "dialogue:tabitha.encounter.3"], + victory: ["dialogue:tabitha.victory.1", "dialogue:tabitha.victory.2", "dialogue:tabitha.victory.3"], + }, ], [TrainerType.COURTNEY]: [ { - encounter: [ - "dialogue:courtney.encounter.1", - "dialogue:courtney.encounter.2", - "dialogue:courtney.encounter.3", - ], - victory: [ - "dialogue:courtney.victory.1", - "dialogue:courtney.victory.2", - "dialogue:courtney.victory.3", - ] - } + encounter: ["dialogue:courtney.encounter.1", "dialogue:courtney.encounter.2", "dialogue:courtney.encounter.3"], + victory: ["dialogue:courtney.victory.1", "dialogue:courtney.victory.2", "dialogue:courtney.victory.3"], + }, ], [TrainerType.AQUA_GRUNT]: [ { @@ -603,36 +399,20 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:aqua_grunt.victory.3", "dialogue:aqua_grunt.victory.4", "dialogue:aqua_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.MATT]: [ { - encounter: [ - "dialogue:matt.encounter.1", - "dialogue:matt.encounter.2", - "dialogue:matt.encounter.3", - ], - victory: [ - "dialogue:matt.victory.1", - "dialogue:matt.victory.2", - "dialogue:matt.victory.3", - ] - } + encounter: ["dialogue:matt.encounter.1", "dialogue:matt.encounter.2", "dialogue:matt.encounter.3"], + victory: ["dialogue:matt.victory.1", "dialogue:matt.victory.2", "dialogue:matt.victory.3"], + }, ], [TrainerType.SHELLY]: [ { - encounter: [ - "dialogue:shelly.encounter.1", - "dialogue:shelly.encounter.2", - "dialogue:shelly.encounter.3", - ], - victory: [ - "dialogue:shelly.victory.1", - "dialogue:shelly.victory.2", - "dialogue:shelly.victory.3", - ] - } + encounter: ["dialogue:shelly.encounter.1", "dialogue:shelly.encounter.2", "dialogue:shelly.encounter.3"], + victory: ["dialogue:shelly.victory.1", "dialogue:shelly.victory.2", "dialogue:shelly.victory.3"], + }, ], [TrainerType.GALACTIC_GRUNT]: [ { @@ -649,50 +429,26 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:galactic_grunt.victory.3", "dialogue:galactic_grunt.victory.4", "dialogue:galactic_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.JUPITER]: [ { - encounter: [ - "dialogue:jupiter.encounter.1", - "dialogue:jupiter.encounter.2", - "dialogue:jupiter.encounter.3", - ], - victory: [ - "dialogue:jupiter.victory.1", - "dialogue:jupiter.victory.2", - "dialogue:jupiter.victory.3", - ] - } + encounter: ["dialogue:jupiter.encounter.1", "dialogue:jupiter.encounter.2", "dialogue:jupiter.encounter.3"], + victory: ["dialogue:jupiter.victory.1", "dialogue:jupiter.victory.2", "dialogue:jupiter.victory.3"], + }, ], [TrainerType.MARS]: [ { - encounter: [ - "dialogue:mars.encounter.1", - "dialogue:mars.encounter.2", - "dialogue:mars.encounter.3", - ], - victory: [ - "dialogue:mars.victory.1", - "dialogue:mars.victory.2", - "dialogue:mars.victory.3", - ] - } + encounter: ["dialogue:mars.encounter.1", "dialogue:mars.encounter.2", "dialogue:mars.encounter.3"], + victory: ["dialogue:mars.victory.1", "dialogue:mars.victory.2", "dialogue:mars.victory.3"], + }, ], [TrainerType.SATURN]: [ { - encounter: [ - "dialogue:saturn.encounter.1", - "dialogue:saturn.encounter.2", - "dialogue:saturn.encounter.3", - ], - victory: [ - "dialogue:saturn.victory.1", - "dialogue:saturn.victory.2", - "dialogue:saturn.victory.3", - ] - } + encounter: ["dialogue:saturn.encounter.1", "dialogue:saturn.encounter.2", "dialogue:saturn.encounter.3"], + victory: ["dialogue:saturn.victory.1", "dialogue:saturn.victory.2", "dialogue:saturn.victory.3"], + }, ], [TrainerType.PLASMA_GRUNT]: [ { @@ -709,36 +465,20 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:plasma_grunt.victory.3", "dialogue:plasma_grunt.victory.4", "dialogue:plasma_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.ZINZOLIN]: [ { - encounter: [ - "dialogue:zinzolin.encounter.1", - "dialogue:zinzolin.encounter.2", - "dialogue:zinzolin.encounter.3", - ], - victory: [ - "dialogue:zinzolin.victory.1", - "dialogue:zinzolin.victory.2", - "dialogue:zinzolin.victory.3", - ] - } + encounter: ["dialogue:zinzolin.encounter.1", "dialogue:zinzolin.encounter.2", "dialogue:zinzolin.encounter.3"], + victory: ["dialogue:zinzolin.victory.1", "dialogue:zinzolin.victory.2", "dialogue:zinzolin.victory.3"], + }, ], [TrainerType.COLRESS]: [ { - encounter: [ - "dialogue:colress.encounter.1", - "dialogue:colress.encounter.2", - "dialogue:colress.encounter.3", - ], - victory: [ - "dialogue:colress.victory.1", - "dialogue:colress.victory.2", - "dialogue:colress.victory.3", - ] - } + encounter: ["dialogue:colress.encounter.1", "dialogue:colress.encounter.2", "dialogue:colress.encounter.3"], + victory: ["dialogue:colress.victory.1", "dialogue:colress.victory.2", "dialogue:colress.victory.3"], + }, ], [TrainerType.FLARE_GRUNT]: [ { @@ -755,36 +495,20 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:flare_grunt.victory.3", "dialogue:flare_grunt.victory.4", "dialogue:flare_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.BRYONY]: [ { - encounter: [ - "dialogue:bryony.encounter.1", - "dialogue:bryony.encounter.2", - "dialogue:bryony.encounter.3", - ], - victory: [ - "dialogue:bryony.victory.1", - "dialogue:bryony.victory.2", - "dialogue:bryony.victory.3", - ] - } + encounter: ["dialogue:bryony.encounter.1", "dialogue:bryony.encounter.2", "dialogue:bryony.encounter.3"], + victory: ["dialogue:bryony.victory.1", "dialogue:bryony.victory.2", "dialogue:bryony.victory.3"], + }, ], [TrainerType.XEROSIC]: [ { - encounter: [ - "dialogue:xerosic.encounter.1", - "dialogue:xerosic.encounter.2", - "dialogue:xerosic.encounter.3", - ], - victory: [ - "dialogue:xerosic.victory.1", - "dialogue:xerosic.victory.2", - "dialogue:xerosic.victory.3", - ] - } + encounter: ["dialogue:xerosic.encounter.1", "dialogue:xerosic.encounter.2", "dialogue:xerosic.encounter.3"], + victory: ["dialogue:xerosic.victory.1", "dialogue:xerosic.victory.2", "dialogue:xerosic.victory.3"], + }, ], [TrainerType.AETHER_GRUNT]: [ { @@ -801,22 +525,14 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:aether_grunt.victory.3", "dialogue:aether_grunt.victory.4", "dialogue:aether_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.FABA]: [ { - encounter: [ - "dialogue:faba.encounter.1", - "dialogue:faba.encounter.2", - "dialogue:faba.encounter.3", - ], - victory: [ - "dialogue:faba.victory.1", - "dialogue:faba.victory.2", - "dialogue:faba.victory.3", - ] - } + encounter: ["dialogue:faba.encounter.1", "dialogue:faba.encounter.2", "dialogue:faba.encounter.3"], + victory: ["dialogue:faba.victory.1", "dialogue:faba.victory.2", "dialogue:faba.victory.3"], + }, ], [TrainerType.SKULL_GRUNT]: [ { @@ -833,22 +549,14 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:skull_grunt.victory.3", "dialogue:skull_grunt.victory.4", "dialogue:skull_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.PLUMERIA]: [ { - encounter: [ - "dialogue:plumeria.encounter.1", - "dialogue:plumeria.encounter.2", - "dialogue:plumeria.encounter.3", - ], - victory: [ - "dialogue:plumeria.victory.1", - "dialogue:plumeria.victory.2", - "dialogue:plumeria.victory.3", - ] - } + encounter: ["dialogue:plumeria.encounter.1", "dialogue:plumeria.encounter.2", "dialogue:plumeria.encounter.3"], + victory: ["dialogue:plumeria.victory.1", "dialogue:plumeria.victory.2", "dialogue:plumeria.victory.3"], + }, ], [TrainerType.MACRO_GRUNT]: [ { @@ -865,22 +573,14 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:macro_grunt.victory.3", "dialogue:macro_grunt.victory.4", "dialogue:macro_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.OLEANA]: [ { - encounter: [ - "dialogue:oleana.encounter.1", - "dialogue:oleana.encounter.2", - "dialogue:oleana.encounter.3", - ], - victory: [ - "dialogue:oleana.victory.1", - "dialogue:oleana.victory.2", - "dialogue:oleana.victory.3", - ] - } + encounter: ["dialogue:oleana.encounter.1", "dialogue:oleana.encounter.2", "dialogue:oleana.encounter.3"], + victory: ["dialogue:oleana.victory.1", "dialogue:oleana.victory.2", "dialogue:oleana.victory.3"], + }, ], [TrainerType.STAR_GRUNT]: [ { @@ -897,509 +597,258 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:star_grunt.victory.3", "dialogue:star_grunt.victory.4", "dialogue:star_grunt.victory.5", - ] - } + ], + }, ], [TrainerType.GIACOMO]: [ { - encounter: [ - "dialogue:giacomo.encounter.1", - "dialogue:giacomo.encounter.2", - ], - victory: [ - "dialogue:giacomo.victory.1", - "dialogue:giacomo.victory.2", - ] - } + encounter: ["dialogue:giacomo.encounter.1", "dialogue:giacomo.encounter.2"], + victory: ["dialogue:giacomo.victory.1", "dialogue:giacomo.victory.2"], + }, ], [TrainerType.MELA]: [ { - encounter: [ - "dialogue:mela.encounter.1", - "dialogue:mela.encounter.2", - ], - victory: [ - "dialogue:mela.victory.1", - "dialogue:mela.victory.2", - ] - } + encounter: ["dialogue:mela.encounter.1", "dialogue:mela.encounter.2"], + victory: ["dialogue:mela.victory.1", "dialogue:mela.victory.2"], + }, ], [TrainerType.ATTICUS]: [ { - encounter: [ - "dialogue:atticus.encounter.1", - "dialogue:atticus.encounter.2", - ], - victory: [ - "dialogue:atticus.victory.1", - "dialogue:atticus.victory.2", - ] - } + encounter: ["dialogue:atticus.encounter.1", "dialogue:atticus.encounter.2"], + victory: ["dialogue:atticus.victory.1", "dialogue:atticus.victory.2"], + }, ], [TrainerType.ORTEGA]: [ { - encounter: [ - "dialogue:ortega.encounter.1", - "dialogue:ortega.encounter.2", - ], - victory: [ - "dialogue:ortega.victory.1", - "dialogue:ortega.victory.2", - ] - } + encounter: ["dialogue:ortega.encounter.1", "dialogue:ortega.encounter.2"], + victory: ["dialogue:ortega.victory.1", "dialogue:ortega.victory.2"], + }, ], [TrainerType.ERI]: [ { - encounter: [ - "dialogue:eri.encounter.1", - "dialogue:eri.encounter.2", - ], - victory: [ - "dialogue:eri.victory.1", - "dialogue:eri.victory.2", - ] - } + encounter: ["dialogue:eri.encounter.1", "dialogue:eri.encounter.2"], + victory: ["dialogue:eri.victory.1", "dialogue:eri.victory.2"], + }, ], [TrainerType.ROCKET_BOSS_GIOVANNI_1]: [ { - encounter: [ - "dialogue:rocket_boss_giovanni_1.encounter.1" - ], - victory: [ - "dialogue:rocket_boss_giovanni_1.victory.1" - ], - defeat: [ - "dialogue:rocket_boss_giovanni_1.defeat.1" - ] - } + encounter: ["dialogue:rocket_boss_giovanni_1.encounter.1"], + victory: ["dialogue:rocket_boss_giovanni_1.victory.1"], + defeat: ["dialogue:rocket_boss_giovanni_1.defeat.1"], + }, ], [TrainerType.ROCKET_BOSS_GIOVANNI_2]: [ { - encounter: [ - "dialogue:rocket_boss_giovanni_2.encounter.1" - ], - victory: [ - "dialogue:rocket_boss_giovanni_2.victory.1" - ], - defeat: [ - "dialogue:rocket_boss_giovanni_2.defeat.1" - ] - } + encounter: ["dialogue:rocket_boss_giovanni_2.encounter.1"], + victory: ["dialogue:rocket_boss_giovanni_2.victory.1"], + defeat: ["dialogue:rocket_boss_giovanni_2.defeat.1"], + }, ], [TrainerType.MAXIE]: [ { - encounter: [ - "dialogue:magma_boss_maxie_1.encounter.1" - ], - victory: [ - "dialogue:magma_boss_maxie_1.victory.1" - ], - defeat: [ - "dialogue:magma_boss_maxie_1.defeat.1" - ] - } + encounter: ["dialogue:magma_boss_maxie_1.encounter.1"], + victory: ["dialogue:magma_boss_maxie_1.victory.1"], + defeat: ["dialogue:magma_boss_maxie_1.defeat.1"], + }, ], [TrainerType.MAXIE_2]: [ { - encounter: [ - "dialogue:magma_boss_maxie_2.encounter.1" - ], - victory: [ - "dialogue:magma_boss_maxie_2.victory.1" - ], - defeat: [ - "dialogue:magma_boss_maxie_2.defeat.1" - ] - } + encounter: ["dialogue:magma_boss_maxie_2.encounter.1"], + victory: ["dialogue:magma_boss_maxie_2.victory.1"], + defeat: ["dialogue:magma_boss_maxie_2.defeat.1"], + }, ], [TrainerType.ARCHIE]: [ { - encounter: [ - "dialogue:aqua_boss_archie_1.encounter.1" - ], - victory: [ - "dialogue:aqua_boss_archie_1.victory.1" - ], - defeat: [ - "dialogue:aqua_boss_archie_1.defeat.1" - ] - } + encounter: ["dialogue:aqua_boss_archie_1.encounter.1"], + victory: ["dialogue:aqua_boss_archie_1.victory.1"], + defeat: ["dialogue:aqua_boss_archie_1.defeat.1"], + }, ], [TrainerType.ARCHIE_2]: [ { - encounter: [ - "dialogue:aqua_boss_archie_2.encounter.1" - ], - victory: [ - "dialogue:aqua_boss_archie_2.victory.1" - ], - defeat: [ - "dialogue:aqua_boss_archie_2.defeat.1" - ] - } + encounter: ["dialogue:aqua_boss_archie_2.encounter.1"], + victory: ["dialogue:aqua_boss_archie_2.victory.1"], + defeat: ["dialogue:aqua_boss_archie_2.defeat.1"], + }, ], [TrainerType.CYRUS]: [ { - encounter: [ - "dialogue:galactic_boss_cyrus_1.encounter.1" - ], - victory: [ - "dialogue:galactic_boss_cyrus_1.victory.1" - ], - defeat: [ - "dialogue:galactic_boss_cyrus_1.defeat.1" - ] - } + encounter: ["dialogue:galactic_boss_cyrus_1.encounter.1"], + victory: ["dialogue:galactic_boss_cyrus_1.victory.1"], + defeat: ["dialogue:galactic_boss_cyrus_1.defeat.1"], + }, ], [TrainerType.CYRUS_2]: [ { - encounter: [ - "dialogue:galactic_boss_cyrus_2.encounter.1" - ], - victory: [ - "dialogue:galactic_boss_cyrus_2.victory.1" - ], - defeat: [ - "dialogue:galactic_boss_cyrus_2.defeat.1" - ] - } + encounter: ["dialogue:galactic_boss_cyrus_2.encounter.1"], + victory: ["dialogue:galactic_boss_cyrus_2.victory.1"], + defeat: ["dialogue:galactic_boss_cyrus_2.defeat.1"], + }, ], [TrainerType.GHETSIS]: [ { - encounter: [ - "dialogue:plasma_boss_ghetsis_1.encounter.1" - ], - victory: [ - "dialogue:plasma_boss_ghetsis_1.victory.1" - ], - defeat: [ - "dialogue:plasma_boss_ghetsis_1.defeat.1" - ] - } + encounter: ["dialogue:plasma_boss_ghetsis_1.encounter.1"], + victory: ["dialogue:plasma_boss_ghetsis_1.victory.1"], + defeat: ["dialogue:plasma_boss_ghetsis_1.defeat.1"], + }, ], [TrainerType.GHETSIS_2]: [ { - encounter: [ - "dialogue:plasma_boss_ghetsis_2.encounter.1" - ], - victory: [ - "dialogue:plasma_boss_ghetsis_2.victory.1" - ], - defeat: [ - "dialogue:plasma_boss_ghetsis_2.defeat.1" - ] - } + encounter: ["dialogue:plasma_boss_ghetsis_2.encounter.1"], + victory: ["dialogue:plasma_boss_ghetsis_2.victory.1"], + defeat: ["dialogue:plasma_boss_ghetsis_2.defeat.1"], + }, ], [TrainerType.LYSANDRE]: [ { - encounter: [ - "dialogue:flare_boss_lysandre_1.encounter.1" - ], - victory: [ - "dialogue:flare_boss_lysandre_1.victory.1" - ], - defeat: [ - "dialogue:flare_boss_lysandre_1.defeat.1" - ] - } + encounter: ["dialogue:flare_boss_lysandre_1.encounter.1"], + victory: ["dialogue:flare_boss_lysandre_1.victory.1"], + defeat: ["dialogue:flare_boss_lysandre_1.defeat.1"], + }, ], [TrainerType.LYSANDRE_2]: [ { - encounter: [ - "dialogue:flare_boss_lysandre_2.encounter.1" - ], - victory: [ - "dialogue:flare_boss_lysandre_2.victory.1" - ], - defeat: [ - "dialogue:flare_boss_lysandre_2.defeat.1" - ] - } + encounter: ["dialogue:flare_boss_lysandre_2.encounter.1"], + victory: ["dialogue:flare_boss_lysandre_2.victory.1"], + defeat: ["dialogue:flare_boss_lysandre_2.defeat.1"], + }, ], [TrainerType.LUSAMINE]: [ { - encounter: [ - "dialogue:aether_boss_lusamine_1.encounter.1" - ], - victory: [ - "dialogue:aether_boss_lusamine_1.victory.1" - ], - defeat: [ - "dialogue:aether_boss_lusamine_1.defeat.1" - ] - } + encounter: ["dialogue:aether_boss_lusamine_1.encounter.1"], + victory: ["dialogue:aether_boss_lusamine_1.victory.1"], + defeat: ["dialogue:aether_boss_lusamine_1.defeat.1"], + }, ], [TrainerType.LUSAMINE_2]: [ { - encounter: [ - "dialogue:aether_boss_lusamine_2.encounter.1" - ], - victory: [ - "dialogue:aether_boss_lusamine_2.victory.1" - ], - defeat: [ - "dialogue:aether_boss_lusamine_2.defeat.1" - ] - } + encounter: ["dialogue:aether_boss_lusamine_2.encounter.1"], + victory: ["dialogue:aether_boss_lusamine_2.victory.1"], + defeat: ["dialogue:aether_boss_lusamine_2.defeat.1"], + }, ], [TrainerType.GUZMA]: [ { - encounter: [ - "dialogue:skull_boss_guzma_1.encounter.1" - ], - victory: [ - "dialogue:skull_boss_guzma_1.victory.1" - ], - defeat: [ - "dialogue:skull_boss_guzma_1.defeat.1" - ] - } + encounter: ["dialogue:skull_boss_guzma_1.encounter.1"], + victory: ["dialogue:skull_boss_guzma_1.victory.1"], + defeat: ["dialogue:skull_boss_guzma_1.defeat.1"], + }, ], [TrainerType.GUZMA_2]: [ { - encounter: [ - "dialogue:skull_boss_guzma_2.encounter.1" - ], - victory: [ - "dialogue:skull_boss_guzma_2.victory.1" - ], - defeat: [ - "dialogue:skull_boss_guzma_2.defeat.1" - ] - } + encounter: ["dialogue:skull_boss_guzma_2.encounter.1"], + victory: ["dialogue:skull_boss_guzma_2.victory.1"], + defeat: ["dialogue:skull_boss_guzma_2.defeat.1"], + }, ], [TrainerType.ROSE]: [ { - encounter: [ - "dialogue:macro_boss_rose_1.encounter.1" - ], - victory: [ - "dialogue:macro_boss_rose_1.victory.1" - ], - defeat: [ - "dialogue:macro_boss_rose_1.defeat.1" - ] - } + encounter: ["dialogue:macro_boss_rose_1.encounter.1"], + victory: ["dialogue:macro_boss_rose_1.victory.1"], + defeat: ["dialogue:macro_boss_rose_1.defeat.1"], + }, ], [TrainerType.ROSE_2]: [ { - encounter: [ - "dialogue:macro_boss_rose_2.encounter.1" - ], - victory: [ - "dialogue:macro_boss_rose_2.victory.1" - ], - defeat: [ - "dialogue:macro_boss_rose_2.defeat.1" - ] - } + encounter: ["dialogue:macro_boss_rose_2.encounter.1"], + victory: ["dialogue:macro_boss_rose_2.victory.1"], + defeat: ["dialogue:macro_boss_rose_2.defeat.1"], + }, ], [TrainerType.PENNY]: [ { - encounter: [ - "dialogue:star_boss_penny_1.encounter.1" - ], - victory: [ - "dialogue:star_boss_penny_1.victory.1" - ], - defeat: [ - "dialogue:star_boss_penny_1.defeat.1" - ] - } + encounter: ["dialogue:star_boss_penny_1.encounter.1"], + victory: ["dialogue:star_boss_penny_1.victory.1"], + defeat: ["dialogue:star_boss_penny_1.defeat.1"], + }, ], [TrainerType.PENNY_2]: [ { - encounter: [ - "dialogue:star_boss_penny_2.encounter.1" - ], - victory: [ - "dialogue:star_boss_penny_2.victory.1" - ], - defeat: [ - "dialogue:star_boss_penny_2.defeat.1" - ] - } + encounter: ["dialogue:star_boss_penny_2.encounter.1"], + victory: ["dialogue:star_boss_penny_2.victory.1"], + defeat: ["dialogue:star_boss_penny_2.defeat.1"], + }, ], [TrainerType.BUCK]: [ { - encounter: [ - "dialogue:stat_trainer_buck.encounter.1", - "dialogue:stat_trainer_buck.encounter.2" - ], - victory: [ - "dialogue:stat_trainer_buck.victory.1", - "dialogue:stat_trainer_buck.victory.2" - ], - defeat: [ - "dialogue:stat_trainer_buck.defeat.1", - "dialogue:stat_trainer_buck.defeat.2" - ] - } + encounter: ["dialogue:stat_trainer_buck.encounter.1", "dialogue:stat_trainer_buck.encounter.2"], + victory: ["dialogue:stat_trainer_buck.victory.1", "dialogue:stat_trainer_buck.victory.2"], + defeat: ["dialogue:stat_trainer_buck.defeat.1", "dialogue:stat_trainer_buck.defeat.2"], + }, ], [TrainerType.CHERYL]: [ { - encounter: [ - "dialogue:stat_trainer_cheryl.encounter.1", - "dialogue:stat_trainer_cheryl.encounter.2" - ], - victory: [ - "dialogue:stat_trainer_cheryl.victory.1", - "dialogue:stat_trainer_cheryl.victory.2" - ], - defeat: [ - "dialogue:stat_trainer_cheryl.defeat.1", - "dialogue:stat_trainer_cheryl.defeat.2" - ] - } + encounter: ["dialogue:stat_trainer_cheryl.encounter.1", "dialogue:stat_trainer_cheryl.encounter.2"], + victory: ["dialogue:stat_trainer_cheryl.victory.1", "dialogue:stat_trainer_cheryl.victory.2"], + defeat: ["dialogue:stat_trainer_cheryl.defeat.1", "dialogue:stat_trainer_cheryl.defeat.2"], + }, ], [TrainerType.MARLEY]: [ { - encounter: [ - "dialogue:stat_trainer_marley.encounter.1", - "dialogue:stat_trainer_marley.encounter.2" - ], - victory: [ - "dialogue:stat_trainer_marley.victory.1", - "dialogue:stat_trainer_marley.victory.2" - ], - defeat: [ - "dialogue:stat_trainer_marley.defeat.1", - "dialogue:stat_trainer_marley.defeat.2" - ] - } + encounter: ["dialogue:stat_trainer_marley.encounter.1", "dialogue:stat_trainer_marley.encounter.2"], + victory: ["dialogue:stat_trainer_marley.victory.1", "dialogue:stat_trainer_marley.victory.2"], + defeat: ["dialogue:stat_trainer_marley.defeat.1", "dialogue:stat_trainer_marley.defeat.2"], + }, ], [TrainerType.MIRA]: [ { - encounter: [ - "dialogue:stat_trainer_mira.encounter.1", - "dialogue:stat_trainer_mira.encounter.2" - ], - victory: [ - "dialogue:stat_trainer_mira.victory.1", - "dialogue:stat_trainer_mira.victory.2" - ], - defeat: [ - "dialogue:stat_trainer_mira.defeat.1", - "dialogue:stat_trainer_mira.defeat.2" - ] - } + encounter: ["dialogue:stat_trainer_mira.encounter.1", "dialogue:stat_trainer_mira.encounter.2"], + victory: ["dialogue:stat_trainer_mira.victory.1", "dialogue:stat_trainer_mira.victory.2"], + defeat: ["dialogue:stat_trainer_mira.defeat.1", "dialogue:stat_trainer_mira.defeat.2"], + }, ], [TrainerType.RILEY]: [ { - encounter: [ - "dialogue:stat_trainer_riley.encounter.1", - "dialogue:stat_trainer_riley.encounter.2" - ], - victory: [ - "dialogue:stat_trainer_riley.victory.1", - "dialogue:stat_trainer_riley.victory.2" - ], - defeat: [ - "dialogue:stat_trainer_riley.defeat.1", - "dialogue:stat_trainer_riley.defeat.2" - ] - } + encounter: ["dialogue:stat_trainer_riley.encounter.1", "dialogue:stat_trainer_riley.encounter.2"], + victory: ["dialogue:stat_trainer_riley.victory.1", "dialogue:stat_trainer_riley.victory.2"], + defeat: ["dialogue:stat_trainer_riley.defeat.1", "dialogue:stat_trainer_riley.defeat.2"], + }, ], [TrainerType.VICTOR]: [ { - encounter: [ - "dialogue:winstrates_victor.encounter.1", - ], - victory: [ - "dialogue:winstrates_victor.victory.1" - ], - } + encounter: ["dialogue:winstrates_victor.encounter.1"], + victory: ["dialogue:winstrates_victor.victory.1"], + }, ], [TrainerType.VICTORIA]: [ { - encounter: [ - "dialogue:winstrates_victoria.encounter.1", - ], - victory: [ - "dialogue:winstrates_victoria.victory.1" - ], - } + encounter: ["dialogue:winstrates_victoria.encounter.1"], + victory: ["dialogue:winstrates_victoria.victory.1"], + }, ], [TrainerType.VIVI]: [ { - encounter: [ - "dialogue:winstrates_vivi.encounter.1", - ], - victory: [ - "dialogue:winstrates_vivi.victory.1" - ], - } + encounter: ["dialogue:winstrates_vivi.encounter.1"], + victory: ["dialogue:winstrates_vivi.victory.1"], + }, ], [TrainerType.VICKY]: [ { - encounter: [ - "dialogue:winstrates_vicky.encounter.1", - ], - victory: [ - "dialogue:winstrates_vicky.victory.1" - ], - } + encounter: ["dialogue:winstrates_vicky.encounter.1"], + victory: ["dialogue:winstrates_vicky.victory.1"], + }, ], [TrainerType.VITO]: [ { - encounter: [ - "dialogue:winstrates_vito.encounter.1", - ], - victory: [ - "dialogue:winstrates_vito.victory.1" - ], - } + encounter: ["dialogue:winstrates_vito.encounter.1"], + victory: ["dialogue:winstrates_vito.victory.1"], + }, ], [TrainerType.BROCK]: { - encounter: [ - "dialogue:brock.encounter.1", - "dialogue:brock.encounter.2", - "dialogue:brock.encounter.3", - ], - victory: [ - "dialogue:brock.victory.1", - "dialogue:brock.victory.2", - "dialogue:brock.victory.3", - ], - defeat: [ - "dialogue:brock.defeat.1", - "dialogue:brock.defeat.2", - "dialogue:brock.defeat.3", - ] + encounter: ["dialogue:brock.encounter.1", "dialogue:brock.encounter.2", "dialogue:brock.encounter.3"], + victory: ["dialogue:brock.victory.1", "dialogue:brock.victory.2", "dialogue:brock.victory.3"], + defeat: ["dialogue:brock.defeat.1", "dialogue:brock.defeat.2", "dialogue:brock.defeat.3"], }, [TrainerType.MISTY]: { - encounter: [ - "dialogue:misty.encounter.1", - "dialogue:misty.encounter.2", - "dialogue:misty.encounter.3", - ], - victory: [ - "dialogue:misty.victory.1", - "dialogue:misty.victory.2", - "dialogue:misty.victory.3", - ], - defeat: [ - "dialogue:misty.defeat.1", - "dialogue:misty.defeat.2", - "dialogue:misty.defeat.3", - ] + encounter: ["dialogue:misty.encounter.1", "dialogue:misty.encounter.2", "dialogue:misty.encounter.3"], + victory: ["dialogue:misty.victory.1", "dialogue:misty.victory.2", "dialogue:misty.victory.3"], + defeat: ["dialogue:misty.defeat.1", "dialogue:misty.defeat.2", "dialogue:misty.defeat.3"], }, [TrainerType.LT_SURGE]: { - encounter: [ - "dialogue:lt_surge.encounter.1", - "dialogue:lt_surge.encounter.2", - "dialogue:lt_surge.encounter.3", - ], - victory: [ - "dialogue:lt_surge.victory.1", - "dialogue:lt_surge.victory.2", - "dialogue:lt_surge.victory.3", - ], - defeat: [ - "dialogue:lt_surge.defeat.1", - "dialogue:lt_surge.defeat.2", - "dialogue:lt_surge.defeat.3", - ] + encounter: ["dialogue:lt_surge.encounter.1", "dialogue:lt_surge.encounter.2", "dialogue:lt_surge.encounter.3"], + victory: ["dialogue:lt_surge.victory.1", "dialogue:lt_surge.victory.2", "dialogue:lt_surge.victory.3"], + defeat: ["dialogue:lt_surge.defeat.1", "dialogue:lt_surge.defeat.2", "dialogue:lt_surge.defeat.3"], }, [TrainerType.ERIKA]: { encounter: [ @@ -1419,420 +868,151 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:erika.defeat.2", "dialogue:erika.defeat.3", "dialogue:erika.defeat.4", - ] + ], }, [TrainerType.JANINE]: { - encounter: [ - "dialogue:janine.encounter.1", - "dialogue:janine.encounter.2", - "dialogue:janine.encounter.3", - ], - victory: [ - "dialogue:janine.victory.1", - "dialogue:janine.victory.2", - "dialogue:janine.victory.3", - ], - defeat: [ - "dialogue:janine.defeat.1", - "dialogue:janine.defeat.2", - "dialogue:janine.defeat.3", - ] + encounter: ["dialogue:janine.encounter.1", "dialogue:janine.encounter.2", "dialogue:janine.encounter.3"], + victory: ["dialogue:janine.victory.1", "dialogue:janine.victory.2", "dialogue:janine.victory.3"], + defeat: ["dialogue:janine.defeat.1", "dialogue:janine.defeat.2", "dialogue:janine.defeat.3"], }, [TrainerType.SABRINA]: { - encounter: [ - "dialogue:sabrina.encounter.1", - "dialogue:sabrina.encounter.2", - "dialogue:sabrina.encounter.3", - ], - victory: [ - "dialogue:sabrina.victory.1", - "dialogue:sabrina.victory.2", - "dialogue:sabrina.victory.3", - ], - defeat: [ - "dialogue:sabrina.defeat.1", - "dialogue:sabrina.defeat.2", - "dialogue:sabrina.defeat.3", - ] + encounter: ["dialogue:sabrina.encounter.1", "dialogue:sabrina.encounter.2", "dialogue:sabrina.encounter.3"], + victory: ["dialogue:sabrina.victory.1", "dialogue:sabrina.victory.2", "dialogue:sabrina.victory.3"], + defeat: ["dialogue:sabrina.defeat.1", "dialogue:sabrina.defeat.2", "dialogue:sabrina.defeat.3"], }, [TrainerType.BLAINE]: { - encounter: [ - "dialogue:blaine.encounter.1", - "dialogue:blaine.encounter.2", - "dialogue:blaine.encounter.3", - ], - victory: [ - "dialogue:blaine.victory.1", - "dialogue:blaine.victory.2", - "dialogue:blaine.victory.3", - ], - defeat: [ - "dialogue:blaine.defeat.1", - "dialogue:blaine.defeat.2", - "dialogue:blaine.defeat.3", - ] + encounter: ["dialogue:blaine.encounter.1", "dialogue:blaine.encounter.2", "dialogue:blaine.encounter.3"], + victory: ["dialogue:blaine.victory.1", "dialogue:blaine.victory.2", "dialogue:blaine.victory.3"], + defeat: ["dialogue:blaine.defeat.1", "dialogue:blaine.defeat.2", "dialogue:blaine.defeat.3"], }, [TrainerType.GIOVANNI]: { - encounter: [ - "dialogue:giovanni.encounter.1", - "dialogue:giovanni.encounter.2", - "dialogue:giovanni.encounter.3", - ], - victory: [ - "dialogue:giovanni.victory.1", - "dialogue:giovanni.victory.2", - "dialogue:giovanni.victory.3", - ], - defeat: [ - "dialogue:giovanni.defeat.1", - "dialogue:giovanni.defeat.2", - "dialogue:giovanni.defeat.3", - ] + encounter: ["dialogue:giovanni.encounter.1", "dialogue:giovanni.encounter.2", "dialogue:giovanni.encounter.3"], + victory: ["dialogue:giovanni.victory.1", "dialogue:giovanni.victory.2", "dialogue:giovanni.victory.3"], + defeat: ["dialogue:giovanni.defeat.1", "dialogue:giovanni.defeat.2", "dialogue:giovanni.defeat.3"], }, [TrainerType.ROXANNE]: { - encounter: [ - "dialogue:roxanne.encounter.1", - "dialogue:roxanne.encounter.2", - "dialogue:roxanne.encounter.3" - ], - victory: [ - "dialogue:roxanne.victory.1", - "dialogue:roxanne.victory.2", - "dialogue:roxanne.victory.3" - ], - defeat: [ - "dialogue:roxanne.defeat.1", - "dialogue:roxanne.defeat.2", - "dialogue:roxanne.defeat.3" - ] + encounter: ["dialogue:roxanne.encounter.1", "dialogue:roxanne.encounter.2", "dialogue:roxanne.encounter.3"], + victory: ["dialogue:roxanne.victory.1", "dialogue:roxanne.victory.2", "dialogue:roxanne.victory.3"], + defeat: ["dialogue:roxanne.defeat.1", "dialogue:roxanne.defeat.2", "dialogue:roxanne.defeat.3"], }, [TrainerType.BRAWLY]: { - encounter: [ - "dialogue:brawly.encounter.1", - "dialogue:brawly.encounter.2", - "dialogue:brawly.encounter.3" - ], - victory: [ - "dialogue:brawly.victory.1", - "dialogue:brawly.victory.2", - "dialogue:brawly.victory.3" - ], - defeat: [ - "dialogue:brawly.defeat.1", - "dialogue:brawly.defeat.2", - "dialogue:brawly.defeat.3" - ] + encounter: ["dialogue:brawly.encounter.1", "dialogue:brawly.encounter.2", "dialogue:brawly.encounter.3"], + victory: ["dialogue:brawly.victory.1", "dialogue:brawly.victory.2", "dialogue:brawly.victory.3"], + defeat: ["dialogue:brawly.defeat.1", "dialogue:brawly.defeat.2", "dialogue:brawly.defeat.3"], }, [TrainerType.WATTSON]: { - encounter: [ - "dialogue:wattson.encounter.1", - "dialogue:wattson.encounter.2", - "dialogue:wattson.encounter.3" - ], - victory: [ - "dialogue:wattson.victory.1", - "dialogue:wattson.victory.2", - "dialogue:wattson.victory.3" - ], - defeat: [ - "dialogue:wattson.defeat.1", - "dialogue:wattson.defeat.2", - "dialogue:wattson.defeat.3" - ] + encounter: ["dialogue:wattson.encounter.1", "dialogue:wattson.encounter.2", "dialogue:wattson.encounter.3"], + victory: ["dialogue:wattson.victory.1", "dialogue:wattson.victory.2", "dialogue:wattson.victory.3"], + defeat: ["dialogue:wattson.defeat.1", "dialogue:wattson.defeat.2", "dialogue:wattson.defeat.3"], }, [TrainerType.FLANNERY]: { - encounter: [ - "dialogue:flannery.encounter.1", - "dialogue:flannery.encounter.2", - "dialogue:flannery.encounter.3" - ], - victory: [ - "dialogue:flannery.victory.1", - "dialogue:flannery.victory.2", - "dialogue:flannery.victory.3" - ], - defeat: [ - "dialogue:flannery.defeat.1", - "dialogue:flannery.defeat.2", - "dialogue:flannery.defeat.3" - ] + encounter: ["dialogue:flannery.encounter.1", "dialogue:flannery.encounter.2", "dialogue:flannery.encounter.3"], + victory: ["dialogue:flannery.victory.1", "dialogue:flannery.victory.2", "dialogue:flannery.victory.3"], + defeat: ["dialogue:flannery.defeat.1", "dialogue:flannery.defeat.2", "dialogue:flannery.defeat.3"], }, [TrainerType.NORMAN]: { - encounter: [ - "dialogue:norman.encounter.1", - "dialogue:norman.encounter.2", - "dialogue:norman.encounter.3" - ], - victory: [ - "dialogue:norman.victory.1", - "dialogue:norman.victory.2", - "dialogue:norman.victory.3" - ], - defeat: [ - "dialogue:norman.defeat.1", - "dialogue:norman.defeat.2", - "dialogue:norman.defeat.3" - ] + encounter: ["dialogue:norman.encounter.1", "dialogue:norman.encounter.2", "dialogue:norman.encounter.3"], + victory: ["dialogue:norman.victory.1", "dialogue:norman.victory.2", "dialogue:norman.victory.3"], + defeat: ["dialogue:norman.defeat.1", "dialogue:norman.defeat.2", "dialogue:norman.defeat.3"], }, [TrainerType.WINONA]: { - encounter: [ - "dialogue:winona.encounter.1", - "dialogue:winona.encounter.2", - "dialogue:winona.encounter.3" - ], - victory: [ - "dialogue:winona.victory.1", - "dialogue:winona.victory.2", - "dialogue:winona.victory.3" - ], - defeat: [ - "dialogue:winona.defeat.1", - "dialogue:winona.defeat.2", - "dialogue:winona.defeat.3" - ] + encounter: ["dialogue:winona.encounter.1", "dialogue:winona.encounter.2", "dialogue:winona.encounter.3"], + victory: ["dialogue:winona.victory.1", "dialogue:winona.victory.2", "dialogue:winona.victory.3"], + defeat: ["dialogue:winona.defeat.1", "dialogue:winona.defeat.2", "dialogue:winona.defeat.3"], }, [TrainerType.TATE]: { - encounter: [ - "dialogue:tate.encounter.1", - "dialogue:tate.encounter.2", - "dialogue:tate.encounter.3" - ], - victory: [ - "dialogue:tate.victory.1", - "dialogue:tate.victory.2", - "dialogue:tate.victory.3" - ], - defeat: [ - "dialogue:tate.defeat.1", - "dialogue:tate.defeat.2", - "dialogue:tate.defeat.3" - ] + encounter: ["dialogue:tate.encounter.1", "dialogue:tate.encounter.2", "dialogue:tate.encounter.3"], + victory: ["dialogue:tate.victory.1", "dialogue:tate.victory.2", "dialogue:tate.victory.3"], + defeat: ["dialogue:tate.defeat.1", "dialogue:tate.defeat.2", "dialogue:tate.defeat.3"], }, [TrainerType.LIZA]: { - encounter: [ - "dialogue:liza.encounter.1", - "dialogue:liza.encounter.2", - "dialogue:liza.encounter.3" - ], - victory: [ - "dialogue:liza.victory.1", - "dialogue:liza.victory.2", - "dialogue:liza.victory.3" - ], - defeat: [ - "dialogue:liza.defeat.1", - "dialogue:liza.defeat.2", - "dialogue:liza.defeat.3" - ] + encounter: ["dialogue:liza.encounter.1", "dialogue:liza.encounter.2", "dialogue:liza.encounter.3"], + victory: ["dialogue:liza.victory.1", "dialogue:liza.victory.2", "dialogue:liza.victory.3"], + defeat: ["dialogue:liza.defeat.1", "dialogue:liza.defeat.2", "dialogue:liza.defeat.3"], }, [TrainerType.JUAN]: { encounter: [ "dialogue:juan.encounter.1", "dialogue:juan.encounter.2", "dialogue:juan.encounter.3", - "dialogue:juan.encounter.4" + "dialogue:juan.encounter.4", ], victory: [ "dialogue:juan.victory.1", "dialogue:juan.victory.2", "dialogue:juan.victory.3", - "dialogue:juan.victory.4" + "dialogue:juan.victory.4", ], - defeat: [ - "dialogue:juan.defeat.1", - "dialogue:juan.defeat.2", - "dialogue:juan.defeat.3", - "dialogue:juan.defeat.4" - ] + defeat: ["dialogue:juan.defeat.1", "dialogue:juan.defeat.2", "dialogue:juan.defeat.3", "dialogue:juan.defeat.4"], }, [TrainerType.CRASHER_WAKE]: { encounter: [ "dialogue:crasher_wake.encounter.1", "dialogue:crasher_wake.encounter.2", - "dialogue:crasher_wake.encounter.3" + "dialogue:crasher_wake.encounter.3", ], - victory: [ - "dialogue:crasher_wake.victory.1", - "dialogue:crasher_wake.victory.2", - "dialogue:crasher_wake.victory.3" - ], - defeat: [ - "dialogue:crasher_wake.defeat.1", - "dialogue:crasher_wake.defeat.2", - "dialogue:crasher_wake.defeat.3" - ] + victory: ["dialogue:crasher_wake.victory.1", "dialogue:crasher_wake.victory.2", "dialogue:crasher_wake.victory.3"], + defeat: ["dialogue:crasher_wake.defeat.1", "dialogue:crasher_wake.defeat.2", "dialogue:crasher_wake.defeat.3"], }, [TrainerType.FALKNER]: { - encounter: [ - "dialogue:falkner.encounter.1", - "dialogue:falkner.encounter.2", - "dialogue:falkner.encounter.3" - ], - victory: [ - "dialogue:falkner.victory.1", - "dialogue:falkner.victory.2", - "dialogue:falkner.victory.3" - ], - defeat: [ - "dialogue:falkner.defeat.1", - "dialogue:falkner.defeat.2", - "dialogue:falkner.defeat.3" - ] + encounter: ["dialogue:falkner.encounter.1", "dialogue:falkner.encounter.2", "dialogue:falkner.encounter.3"], + victory: ["dialogue:falkner.victory.1", "dialogue:falkner.victory.2", "dialogue:falkner.victory.3"], + defeat: ["dialogue:falkner.defeat.1", "dialogue:falkner.defeat.2", "dialogue:falkner.defeat.3"], }, [TrainerType.NESSA]: { - encounter: [ - "dialogue:nessa.encounter.1", - "dialogue:nessa.encounter.2", - "dialogue:nessa.encounter.3" - ], - victory: [ - "dialogue:nessa.victory.1", - "dialogue:nessa.victory.2", - "dialogue:nessa.victory.3" - ], - defeat: [ - "dialogue:nessa.defeat.1", - "dialogue:nessa.defeat.2", - "dialogue:nessa.defeat.3" - ] + encounter: ["dialogue:nessa.encounter.1", "dialogue:nessa.encounter.2", "dialogue:nessa.encounter.3"], + victory: ["dialogue:nessa.victory.1", "dialogue:nessa.victory.2", "dialogue:nessa.victory.3"], + defeat: ["dialogue:nessa.defeat.1", "dialogue:nessa.defeat.2", "dialogue:nessa.defeat.3"], }, [TrainerType.MELONY]: { - encounter: [ - "dialogue:melony.encounter.1", - "dialogue:melony.encounter.2", - "dialogue:melony.encounter.3" - ], - victory: [ - "dialogue:melony.victory.1", - "dialogue:melony.victory.2", - "dialogue:melony.victory.3" - ], - defeat: [ - "dialogue:melony.defeat.1", - "dialogue:melony.defeat.2", - "dialogue:melony.defeat.3" - ] + encounter: ["dialogue:melony.encounter.1", "dialogue:melony.encounter.2", "dialogue:melony.encounter.3"], + victory: ["dialogue:melony.victory.1", "dialogue:melony.victory.2", "dialogue:melony.victory.3"], + defeat: ["dialogue:melony.defeat.1", "dialogue:melony.defeat.2", "dialogue:melony.defeat.3"], }, [TrainerType.MARLON]: { - encounter: [ - "dialogue:marlon.encounter.1", - "dialogue:marlon.encounter.2", - "dialogue:marlon.encounter.3" - ], - victory: [ - "dialogue:marlon.victory.1", - "dialogue:marlon.victory.2", - "dialogue:marlon.victory.3" - ], - defeat: [ - "dialogue:marlon.defeat.1", - "dialogue:marlon.defeat.2", - "dialogue:marlon.defeat.3" - ] + encounter: ["dialogue:marlon.encounter.1", "dialogue:marlon.encounter.2", "dialogue:marlon.encounter.3"], + victory: ["dialogue:marlon.victory.1", "dialogue:marlon.victory.2", "dialogue:marlon.victory.3"], + defeat: ["dialogue:marlon.defeat.1", "dialogue:marlon.defeat.2", "dialogue:marlon.defeat.3"], }, [TrainerType.SHAUNTAL]: { - encounter: [ - "dialogue:shauntal.encounter.1", - "dialogue:shauntal.encounter.2", - "dialogue:shauntal.encounter.3" - ], - victory: [ - "dialogue:shauntal.victory.1", - "dialogue:shauntal.victory.2", - "dialogue:shauntal.victory.3" - ], - defeat: [ - "dialogue:shauntal.defeat.1", - "dialogue:shauntal.defeat.2", - "dialogue:shauntal.defeat.3" - ] + encounter: ["dialogue:shauntal.encounter.1", "dialogue:shauntal.encounter.2", "dialogue:shauntal.encounter.3"], + victory: ["dialogue:shauntal.victory.1", "dialogue:shauntal.victory.2", "dialogue:shauntal.victory.3"], + defeat: ["dialogue:shauntal.defeat.1", "dialogue:shauntal.defeat.2", "dialogue:shauntal.defeat.3"], }, [TrainerType.MARSHAL]: { - encounter: [ - "dialogue:marshal.encounter.1", - "dialogue:marshal.encounter.2", - "dialogue:marshal.encounter.3" - ], - victory: [ - "dialogue:marshal.victory.1", - "dialogue:marshal.victory.2", - "dialogue:marshal.victory.3" - ], - defeat: [ - "dialogue:marshal.defeat.1", - "dialogue:marshal.defeat.2", - "dialogue:marshal.defeat.3" - ] + encounter: ["dialogue:marshal.encounter.1", "dialogue:marshal.encounter.2", "dialogue:marshal.encounter.3"], + victory: ["dialogue:marshal.victory.1", "dialogue:marshal.victory.2", "dialogue:marshal.victory.3"], + defeat: ["dialogue:marshal.defeat.1", "dialogue:marshal.defeat.2", "dialogue:marshal.defeat.3"], }, [TrainerType.CHEREN]: { - encounter: [ - "dialogue:cheren.encounter.1", - "dialogue:cheren.encounter.2", - "dialogue:cheren.encounter.3" - ], - victory: [ - "dialogue:cheren.victory.1", - "dialogue:cheren.victory.2", - "dialogue:cheren.victory.3" - ], - defeat: [ - "dialogue:cheren.defeat.1", - "dialogue:cheren.defeat.2", - "dialogue:cheren.defeat.3" - ] + encounter: ["dialogue:cheren.encounter.1", "dialogue:cheren.encounter.2", "dialogue:cheren.encounter.3"], + victory: ["dialogue:cheren.victory.1", "dialogue:cheren.victory.2", "dialogue:cheren.victory.3"], + defeat: ["dialogue:cheren.defeat.1", "dialogue:cheren.defeat.2", "dialogue:cheren.defeat.3"], }, [TrainerType.CHILI]: { - encounter: [ - "dialogue:chili.encounter.1", - "dialogue:chili.encounter.2", - "dialogue:chili.encounter.3" - ], - victory: [ - "dialogue:chili.victory.1", - "dialogue:chili.victory.2", - "dialogue:chili.victory.3" - ], - defeat: [ - "dialogue:chili.defeat.1", - "dialogue:chili.defeat.2", - "dialogue:chili.defeat.3" - ] + encounter: ["dialogue:chili.encounter.1", "dialogue:chili.encounter.2", "dialogue:chili.encounter.3"], + victory: ["dialogue:chili.victory.1", "dialogue:chili.victory.2", "dialogue:chili.victory.3"], + defeat: ["dialogue:chili.defeat.1", "dialogue:chili.defeat.2", "dialogue:chili.defeat.3"], }, [TrainerType.CILAN]: { - encounter: [ - "dialogue:cilan.encounter.1", - "dialogue:cilan.encounter.2", - "dialogue:cilan.encounter.3" - ], - victory: [ - "dialogue:cilan.victory.1", - "dialogue:cilan.victory.2", - "dialogue:cilan.victory.3" - ], - defeat: [ - "dialogue:cilan.defeat.1", - "dialogue:cilan.defeat.2", - "dialogue:cilan.defeat.3" - ] + encounter: ["dialogue:cilan.encounter.1", "dialogue:cilan.encounter.2", "dialogue:cilan.encounter.3"], + victory: ["dialogue:cilan.victory.1", "dialogue:cilan.victory.2", "dialogue:cilan.victory.3"], + defeat: ["dialogue:cilan.defeat.1", "dialogue:cilan.defeat.2", "dialogue:cilan.defeat.3"], }, [TrainerType.ROARK]: { encounter: [ "dialogue:roark.encounter.1", "dialogue:roark.encounter.2", "dialogue:roark.encounter.3", - "dialogue:roark.encounter.4" + "dialogue:roark.encounter.4", ], victory: [ "dialogue:roark.victory.1", "dialogue:roark.victory.2", "dialogue:roark.victory.3", - "dialogue:roark.victory.4" + "dialogue:roark.victory.4", ], - defeat: [ - "dialogue:roark.defeat.1", - "dialogue:roark.defeat.2", - "dialogue:roark.defeat.3" - ] + defeat: ["dialogue:roark.defeat.1", "dialogue:roark.defeat.2", "dialogue:roark.defeat.3"], }, [TrainerType.MORTY]: { encounter: [ @@ -1841,7 +1021,7 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:morty.encounter.3", "dialogue:morty.encounter.4", "dialogue:morty.encounter.5", - "dialogue:morty.encounter.6" + "dialogue:morty.encounter.6", ], victory: [ "dialogue:morty.victory.1", @@ -1849,7 +1029,7 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:morty.victory.3", "dialogue:morty.victory.4", "dialogue:morty.victory.5", - "dialogue:morty.victory.6" + "dialogue:morty.victory.6", ], defeat: [ "dialogue:morty.defeat.1", @@ -1857,1335 +1037,626 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { "dialogue:morty.defeat.3", "dialogue:morty.defeat.4", "dialogue:morty.defeat.5", - "dialogue:morty.defeat.6" - ] + "dialogue:morty.defeat.6", + ], }, [TrainerType.CRISPIN]: { - encounter: [ - "dialogue:crispin.encounter.1", - "dialogue:crispin.encounter.2" - ], - victory: [ - "dialogue:crispin.victory.1", - "dialogue:crispin.victory.2" - ], - defeat: [ - "dialogue:crispin.defeat.1", - "dialogue:crispin.defeat.2" - ] + encounter: ["dialogue:crispin.encounter.1", "dialogue:crispin.encounter.2"], + victory: ["dialogue:crispin.victory.1", "dialogue:crispin.victory.2"], + defeat: ["dialogue:crispin.defeat.1", "dialogue:crispin.defeat.2"], }, [TrainerType.AMARYS]: { - encounter: [ - "dialogue:amarys.encounter.1" - ], - victory: [ - "dialogue:amarys.victory.1" - ], - defeat: [ - "dialogue:amarys.defeat.1" - ] + encounter: ["dialogue:amarys.encounter.1"], + victory: ["dialogue:amarys.victory.1"], + defeat: ["dialogue:amarys.defeat.1"], }, [TrainerType.LACEY]: { - encounter: [ - "dialogue:lacey.encounter.1" - ], - victory: [ - "dialogue:lacey.victory.1" - ], - defeat: [ - "dialogue:lacey.defeat.1" - ] + encounter: ["dialogue:lacey.encounter.1"], + victory: ["dialogue:lacey.victory.1"], + defeat: ["dialogue:lacey.defeat.1"], }, [TrainerType.DRAYTON]: { - encounter: [ - "dialogue:drayton.encounter.1" - ], - victory: [ - "dialogue:drayton.victory.1" - ], - defeat: [ - "dialogue:drayton.defeat.1" - ] + encounter: ["dialogue:drayton.encounter.1"], + victory: ["dialogue:drayton.victory.1"], + defeat: ["dialogue:drayton.defeat.1"], }, [TrainerType.RAMOS]: { - encounter: [ - "dialogue:ramos.encounter.1" - ], - victory: [ - "dialogue:ramos.victory.1" - ], - defeat: [ - "dialogue:ramos.defeat.1" - ] + encounter: ["dialogue:ramos.encounter.1"], + victory: ["dialogue:ramos.victory.1"], + defeat: ["dialogue:ramos.defeat.1"], }, [TrainerType.VIOLA]: { - encounter: [ - "dialogue:viola.encounter.1", - "dialogue:viola.encounter.2" - ], - victory: [ - "dialogue:viola.victory.1", - "dialogue:viola.victory.2" - ], - defeat: [ - "dialogue:viola.defeat.1", - "dialogue:viola.defeat.2" - ] + encounter: ["dialogue:viola.encounter.1", "dialogue:viola.encounter.2"], + victory: ["dialogue:viola.victory.1", "dialogue:viola.victory.2"], + defeat: ["dialogue:viola.defeat.1", "dialogue:viola.defeat.2"], }, [TrainerType.CANDICE]: { - encounter: [ - "dialogue:candice.encounter.1", - "dialogue:candice.encounter.2" - ], - victory: [ - "dialogue:candice.victory.1", - "dialogue:candice.victory.2" - ], - defeat: [ - "dialogue:candice.defeat.1", - "dialogue:candice.defeat.2" - ] + encounter: ["dialogue:candice.encounter.1", "dialogue:candice.encounter.2"], + victory: ["dialogue:candice.victory.1", "dialogue:candice.victory.2"], + defeat: ["dialogue:candice.defeat.1", "dialogue:candice.defeat.2"], }, [TrainerType.GARDENIA]: { - encounter: [ - "dialogue:gardenia.encounter.1" - ], - victory: [ - "dialogue:gardenia.victory.1" - ], - defeat: [ - "dialogue:gardenia.defeat.1" - ] + encounter: ["dialogue:gardenia.encounter.1"], + victory: ["dialogue:gardenia.victory.1"], + defeat: ["dialogue:gardenia.defeat.1"], }, [TrainerType.AARON]: { - encounter: [ - "dialogue:aaron.encounter.1" - ], - victory: [ - "dialogue:aaron.victory.1" - ], - defeat: [ - "dialogue:aaron.defeat.1" - ] + encounter: ["dialogue:aaron.encounter.1"], + victory: ["dialogue:aaron.victory.1"], + defeat: ["dialogue:aaron.defeat.1"], }, [TrainerType.CRESS]: { - encounter: [ - "dialogue:cress.encounter.1" - ], - victory: [ - "dialogue:cress.victory.1" - ], - defeat: [ - "dialogue:cress.defeat.1" - ] + encounter: ["dialogue:cress.encounter.1"], + victory: ["dialogue:cress.victory.1"], + defeat: ["dialogue:cress.defeat.1"], }, [TrainerType.ALLISTER]: { - encounter: [ - "dialogue:allister.encounter.1" - ], - victory: [ - "dialogue:allister.victory.1" - ], - defeat: [ - "dialogue:allister.defeat.1" - ] + encounter: ["dialogue:allister.encounter.1"], + victory: ["dialogue:allister.victory.1"], + defeat: ["dialogue:allister.defeat.1"], }, [TrainerType.CLAY]: { - encounter: [ - "dialogue:clay.encounter.1" - ], - victory: [ - "dialogue:clay.victory.1" - ], - defeat: [ - "dialogue:clay.defeat.1" - ] + encounter: ["dialogue:clay.encounter.1"], + victory: ["dialogue:clay.victory.1"], + defeat: ["dialogue:clay.defeat.1"], }, [TrainerType.KOFU]: { - encounter: [ - "dialogue:kofu.encounter.1" - ], - victory: [ - "dialogue:kofu.victory.1" - ], - defeat: [ - "dialogue:kofu.defeat.1" - ] + encounter: ["dialogue:kofu.encounter.1"], + victory: ["dialogue:kofu.victory.1"], + defeat: ["dialogue:kofu.defeat.1"], }, [TrainerType.TULIP]: { - encounter: [ - "dialogue:tulip.encounter.1" - ], - victory: [ - "dialogue:tulip.victory.1" - ], - defeat: [ - "dialogue:tulip.defeat.1" - ] + encounter: ["dialogue:tulip.encounter.1"], + victory: ["dialogue:tulip.victory.1"], + defeat: ["dialogue:tulip.defeat.1"], }, [TrainerType.SIDNEY]: { - encounter: [ - "dialogue:sidney.encounter.1" - ], - victory: [ - "dialogue:sidney.victory.1" - ], - defeat: [ - "dialogue:sidney.defeat.1" - ] + encounter: ["dialogue:sidney.encounter.1"], + victory: ["dialogue:sidney.victory.1"], + defeat: ["dialogue:sidney.defeat.1"], }, [TrainerType.PHOEBE]: { - encounter: [ - "dialogue:phoebe.encounter.1" - ], - victory: [ - "dialogue:phoebe.victory.1" - ], - defeat: [ - "dialogue:phoebe.defeat.1" - ] + encounter: ["dialogue:phoebe.encounter.1"], + victory: ["dialogue:phoebe.victory.1"], + defeat: ["dialogue:phoebe.defeat.1"], }, [TrainerType.GLACIA]: { - encounter: [ - "dialogue:glacia.encounter.1" - ], - victory: [ - "dialogue:glacia.victory.1" - ], - defeat: [ - "dialogue:glacia.defeat.1" - ] + encounter: ["dialogue:glacia.encounter.1"], + victory: ["dialogue:glacia.victory.1"], + defeat: ["dialogue:glacia.defeat.1"], }, [TrainerType.DRAKE]: { - encounter: [ - "dialogue:drake.encounter.1" - ], - victory: [ - "dialogue:drake.victory.1" - ], - defeat: [ - "dialogue:drake.defeat.1" - ] + encounter: ["dialogue:drake.encounter.1"], + victory: ["dialogue:drake.victory.1"], + defeat: ["dialogue:drake.defeat.1"], }, [TrainerType.WALLACE]: { - encounter: [ - "dialogue:wallace.encounter.1" - ], - victory: [ - "dialogue:wallace.victory.1" - ], - defeat: [ - "dialogue:wallace.defeat.1" - ] + encounter: ["dialogue:wallace.encounter.1"], + victory: ["dialogue:wallace.victory.1"], + defeat: ["dialogue:wallace.defeat.1"], }, [TrainerType.LORELEI]: { - encounter: [ - "dialogue:lorelei.encounter.1" - ], - victory: [ - "dialogue:lorelei.victory.1" - ], - defeat: [ - "dialogue:lorelei.defeat.1" - ] + encounter: ["dialogue:lorelei.encounter.1"], + victory: ["dialogue:lorelei.victory.1"], + defeat: ["dialogue:lorelei.defeat.1"], }, [TrainerType.WILL]: { - encounter: [ - "dialogue:will.encounter.1" - ], - victory: [ - "dialogue:will.victory.1" - ], - defeat: [ - "dialogue:will.defeat.1" - ] + encounter: ["dialogue:will.encounter.1"], + victory: ["dialogue:will.victory.1"], + defeat: ["dialogue:will.defeat.1"], }, [TrainerType.MALVA]: { - encounter: [ - "dialogue:malva.encounter.1" - ], - victory: [ - "dialogue:malva.victory.1" - ], - defeat: [ - "dialogue:malva.defeat.1" - ] + encounter: ["dialogue:malva.encounter.1"], + victory: ["dialogue:malva.victory.1"], + defeat: ["dialogue:malva.defeat.1"], }, [TrainerType.HALA]: { - encounter: [ - "dialogue:hala.encounter.1" - ], - victory: [ - "dialogue:hala.victory.1" - ], - defeat: [ - "dialogue:hala.defeat.1" - ] + encounter: ["dialogue:hala.encounter.1"], + victory: ["dialogue:hala.victory.1"], + defeat: ["dialogue:hala.defeat.1"], }, [TrainerType.MOLAYNE]: { - encounter: [ - "dialogue:molayne.encounter.1" - ], - victory: [ - "dialogue:molayne.victory.1" - ], - defeat: [ - "dialogue:molayne.defeat.1" - ] + encounter: ["dialogue:molayne.encounter.1"], + victory: ["dialogue:molayne.victory.1"], + defeat: ["dialogue:molayne.defeat.1"], }, [TrainerType.RIKA]: { - encounter: [ - "dialogue:rika.encounter.1" - ], - victory: [ - "dialogue:rika.victory.1" - ], - defeat: [ - "dialogue:rika.defeat.1" - ] + encounter: ["dialogue:rika.encounter.1"], + victory: ["dialogue:rika.victory.1"], + defeat: ["dialogue:rika.defeat.1"], }, [TrainerType.BRUNO]: { - encounter: [ - "dialogue:bruno.encounter.1" - ], - victory: [ - "dialogue:bruno.victory.1" - ], - defeat: [ - "dialogue:bruno.defeat.1" - ] + encounter: ["dialogue:bruno.encounter.1"], + victory: ["dialogue:bruno.victory.1"], + defeat: ["dialogue:bruno.defeat.1"], }, [TrainerType.BUGSY]: { - encounter: [ - "dialogue:bugsy.encounter.1" - ], - victory: [ - "dialogue:bugsy.victory.1" - ], - defeat: [ - "dialogue:bugsy.defeat.1" - ] + encounter: ["dialogue:bugsy.encounter.1"], + victory: ["dialogue:bugsy.victory.1"], + defeat: ["dialogue:bugsy.defeat.1"], }, [TrainerType.KOGA]: { - encounter: [ - "dialogue:koga.encounter.1" - ], - victory: [ - "dialogue:koga.victory.1" - ], - defeat: [ - "dialogue:koga.defeat.1" - ] + encounter: ["dialogue:koga.encounter.1"], + victory: ["dialogue:koga.victory.1"], + defeat: ["dialogue:koga.defeat.1"], }, [TrainerType.BERTHA]: { - encounter: [ - "dialogue:bertha.encounter.1" - ], - victory: [ - "dialogue:bertha.victory.1" - ], - defeat: [ - "dialogue:bertha.defeat.1" - ] + encounter: ["dialogue:bertha.encounter.1"], + victory: ["dialogue:bertha.victory.1"], + defeat: ["dialogue:bertha.defeat.1"], }, [TrainerType.LENORA]: { - encounter: [ - "dialogue:lenora.encounter.1" - ], - victory: [ - "dialogue:lenora.victory.1" - ], - defeat: [ - "dialogue:lenora.defeat.1" - ] + encounter: ["dialogue:lenora.encounter.1"], + victory: ["dialogue:lenora.victory.1"], + defeat: ["dialogue:lenora.defeat.1"], }, [TrainerType.SIEBOLD]: { - encounter: [ - "dialogue:siebold.encounter.1" - ], - victory: [ - "dialogue:siebold.victory.1" - ], - defeat: [ - "dialogue:siebold.defeat.1" - ] + encounter: ["dialogue:siebold.encounter.1"], + victory: ["dialogue:siebold.victory.1"], + defeat: ["dialogue:siebold.defeat.1"], }, [TrainerType.ROXIE]: { - encounter: [ - "dialogue:roxie.encounter.1" - ], - victory: [ - "dialogue:roxie.victory.1" - ], - defeat: [ - "dialogue:roxie.defeat.1" - ] + encounter: ["dialogue:roxie.encounter.1"], + victory: ["dialogue:roxie.victory.1"], + defeat: ["dialogue:roxie.defeat.1"], }, [TrainerType.OLIVIA]: { - encounter: [ - "dialogue:olivia.encounter.1" - ], - victory: [ - "dialogue:olivia.victory.1" - ], - defeat: [ - "dialogue:olivia.defeat.1" - ] + encounter: ["dialogue:olivia.encounter.1"], + victory: ["dialogue:olivia.victory.1"], + defeat: ["dialogue:olivia.defeat.1"], }, [TrainerType.POPPY]: { - encounter: [ - "dialogue:poppy.encounter.1" - ], - victory: [ - "dialogue:poppy.victory.1" - ], - defeat: [ - "dialogue:poppy.defeat.1" - ] + encounter: ["dialogue:poppy.encounter.1"], + victory: ["dialogue:poppy.victory.1"], + defeat: ["dialogue:poppy.defeat.1"], }, [TrainerType.AGATHA]: { - encounter: [ - "dialogue:agatha.encounter.1" - ], - victory: [ - "dialogue:agatha.victory.1" - ], - defeat: [ - "dialogue:agatha.defeat.1" - ] + encounter: ["dialogue:agatha.encounter.1"], + victory: ["dialogue:agatha.victory.1"], + defeat: ["dialogue:agatha.defeat.1"], }, [TrainerType.FLINT]: { - encounter: [ - "dialogue:flint.encounter.1" - ], - victory: [ - "dialogue:flint.victory.1" - ], - defeat: [ - "dialogue:flint.defeat.1" - ] + encounter: ["dialogue:flint.encounter.1"], + victory: ["dialogue:flint.victory.1"], + defeat: ["dialogue:flint.defeat.1"], }, [TrainerType.GRIMSLEY]: { - encounter: [ - "dialogue:grimsley.encounter.1" - ], - victory: [ - "dialogue:grimsley.victory.1" - ], - defeat: [ - "dialogue:grimsley.defeat.1" - ] + encounter: ["dialogue:grimsley.encounter.1"], + victory: ["dialogue:grimsley.victory.1"], + defeat: ["dialogue:grimsley.defeat.1"], }, [TrainerType.CAITLIN]: { - encounter: [ - "dialogue:caitlin.encounter.1" - ], - victory: [ - "dialogue:caitlin.victory.1" - ], - defeat: [ - "dialogue:caitlin.defeat.1" - ] + encounter: ["dialogue:caitlin.encounter.1"], + victory: ["dialogue:caitlin.victory.1"], + defeat: ["dialogue:caitlin.defeat.1"], }, [TrainerType.DIANTHA]: { - encounter: [ - "dialogue:diantha.encounter.1" - ], - victory: [ - "dialogue:diantha.victory.1" - ], - defeat: [ - "dialogue:diantha.defeat.1" - ] + encounter: ["dialogue:diantha.encounter.1"], + victory: ["dialogue:diantha.victory.1"], + defeat: ["dialogue:diantha.defeat.1"], }, [TrainerType.WIKSTROM]: { - encounter: [ - "dialogue:wikstrom.encounter.1" - ], - victory: [ - "dialogue:wikstrom.victory.1" - ], - defeat: [ - "dialogue:wikstrom.defeat.1" - ] + encounter: ["dialogue:wikstrom.encounter.1"], + victory: ["dialogue:wikstrom.victory.1"], + defeat: ["dialogue:wikstrom.defeat.1"], }, [TrainerType.ACEROLA]: { - encounter: [ - "dialogue:acerola.encounter.1" - ], - victory: [ - "dialogue:acerola.victory.1" - ], - defeat: [ - "dialogue:acerola.defeat.1" - ] + encounter: ["dialogue:acerola.encounter.1"], + victory: ["dialogue:acerola.victory.1"], + defeat: ["dialogue:acerola.defeat.1"], }, [TrainerType.LARRY_ELITE]: { - encounter: [ - "dialogue:larry_elite.encounter.1" - ], - victory: [ - "dialogue:larry_elite.victory.1" - ], - defeat: [ - "dialogue:larry_elite.defeat.1" - ] + encounter: ["dialogue:larry_elite.encounter.1"], + victory: ["dialogue:larry_elite.victory.1"], + defeat: ["dialogue:larry_elite.defeat.1"], }, [TrainerType.LANCE]: { - encounter: [ - "dialogue:lance.encounter.1", - "dialogue:lance.encounter.2" - ], - victory: [ - "dialogue:lance.victory.1", - "dialogue:lance.victory.2" - ], - defeat: [ - "dialogue:lance.defeat.1", - "dialogue:lance.defeat.2" - ] + encounter: ["dialogue:lance.encounter.1", "dialogue:lance.encounter.2"], + victory: ["dialogue:lance.victory.1", "dialogue:lance.victory.2"], + defeat: ["dialogue:lance.defeat.1", "dialogue:lance.defeat.2"], }, [TrainerType.KAREN]: { - encounter: [ - "dialogue:karen.encounter.1", - "dialogue:karen.encounter.2", - "dialogue:karen.encounter.3" - ], - victory: [ - "dialogue:karen.victory.1", - "dialogue:karen.victory.2", - "dialogue:karen.victory.3" - ], - defeat: [ - "dialogue:karen.defeat.1", - "dialogue:karen.defeat.2", - "dialogue:karen.defeat.3" - ] + encounter: ["dialogue:karen.encounter.1", "dialogue:karen.encounter.2", "dialogue:karen.encounter.3"], + victory: ["dialogue:karen.victory.1", "dialogue:karen.victory.2", "dialogue:karen.victory.3"], + defeat: ["dialogue:karen.defeat.1", "dialogue:karen.defeat.2", "dialogue:karen.defeat.3"], }, [TrainerType.MILO]: { - encounter: [ - "dialogue:milo.encounter.1" - ], - victory: [ - "dialogue:milo.victory.1" - ], - defeat: [ - "dialogue:milo.defeat.1" - ] + encounter: ["dialogue:milo.encounter.1"], + victory: ["dialogue:milo.victory.1"], + defeat: ["dialogue:milo.defeat.1"], }, [TrainerType.LUCIAN]: { - encounter: [ - "dialogue:lucian.encounter.1" - ], - victory: [ - "dialogue:lucian.victory.1" - ], - defeat: [ - "dialogue:lucian.defeat.1" - ] + encounter: ["dialogue:lucian.encounter.1"], + victory: ["dialogue:lucian.victory.1"], + defeat: ["dialogue:lucian.defeat.1"], }, [TrainerType.DRASNA]: { - encounter: [ - "dialogue:drasna.encounter.1" - ], - victory: [ - "dialogue:drasna.victory.1" - ], - defeat: [ - "dialogue:drasna.defeat.1" - ] + encounter: ["dialogue:drasna.encounter.1"], + victory: ["dialogue:drasna.victory.1"], + defeat: ["dialogue:drasna.defeat.1"], }, [TrainerType.KAHILI]: { - encounter: [ - "dialogue:kahili.encounter.1" - ], - victory: [ - "dialogue:kahili.victory.1" - ], - defeat: [ - "dialogue:kahili.defeat.1" - ] + encounter: ["dialogue:kahili.encounter.1"], + victory: ["dialogue:kahili.victory.1"], + defeat: ["dialogue:kahili.defeat.1"], }, [TrainerType.HASSEL]: { - encounter: [ - "dialogue:hassel.encounter.1" - ], - victory: [ - "dialogue:hassel.victory.1" - ], - defeat: [ - "dialogue:hassel.defeat.1" - ] + encounter: ["dialogue:hassel.encounter.1"], + victory: ["dialogue:hassel.victory.1"], + defeat: ["dialogue:hassel.defeat.1"], }, [TrainerType.BLUE]: { - encounter: [ - "dialogue:blue.encounter.1" - ], - victory: [ - "dialogue:blue.victory.1" - ], - defeat: [ - "dialogue:blue.defeat.1" - ] + encounter: ["dialogue:blue.encounter.1"], + victory: ["dialogue:blue.victory.1"], + defeat: ["dialogue:blue.defeat.1"], }, [TrainerType.PIERS]: { - encounter: [ - "dialogue:piers.encounter.1" - ], - victory: [ - "dialogue:piers.victory.1" - ], - defeat: [ - "dialogue:piers.defeat.1" - ] + encounter: ["dialogue:piers.encounter.1"], + victory: ["dialogue:piers.victory.1"], + defeat: ["dialogue:piers.defeat.1"], }, [TrainerType.RED]: { - encounter: [ - "dialogue:red.encounter.1" - ], - victory: [ - "dialogue:red.victory.1" - ], - defeat: [ - "dialogue:red.defeat.1" - ] + encounter: ["dialogue:red.encounter.1"], + victory: ["dialogue:red.victory.1"], + defeat: ["dialogue:red.defeat.1"], }, [TrainerType.JASMINE]: { - encounter: [ - "dialogue:jasmine.encounter.1" - ], - victory: [ - "dialogue:jasmine.victory.1" - ], - defeat: [ - "dialogue:jasmine.defeat.1" - ] + encounter: ["dialogue:jasmine.encounter.1"], + victory: ["dialogue:jasmine.victory.1"], + defeat: ["dialogue:jasmine.defeat.1"], }, [TrainerType.LANCE_CHAMPION]: { - encounter: [ - "dialogue:lance_champion.encounter.1" - ], - victory: [ - "dialogue:lance_champion.victory.1" - ], - defeat: [ - "dialogue:lance_champion.defeat.1" - ] + encounter: ["dialogue:lance_champion.encounter.1"], + victory: ["dialogue:lance_champion.victory.1"], + defeat: ["dialogue:lance_champion.defeat.1"], }, [TrainerType.STEVEN]: { - encounter: [ - "dialogue:steven.encounter.1" - ], - victory: [ - "dialogue:steven.victory.1" - ], - defeat: [ - "dialogue:steven.defeat.1" - ] + encounter: ["dialogue:steven.encounter.1"], + victory: ["dialogue:steven.victory.1"], + defeat: ["dialogue:steven.defeat.1"], }, [TrainerType.CYNTHIA]: { - encounter: [ - "dialogue:cynthia.encounter.1" - ], - victory: [ - "dialogue:cynthia.victory.1" - ], - defeat: [ - "dialogue:cynthia.defeat.1" - ] + encounter: ["dialogue:cynthia.encounter.1"], + victory: ["dialogue:cynthia.victory.1"], + defeat: ["dialogue:cynthia.defeat.1"], }, [TrainerType.IRIS]: { - encounter: [ - "dialogue:iris.encounter.1" - ], - victory: [ - "dialogue:iris.victory.1" - ], - defeat: [ - "dialogue:iris.defeat.1" - ] + encounter: ["dialogue:iris.encounter.1"], + victory: ["dialogue:iris.victory.1"], + defeat: ["dialogue:iris.defeat.1"], }, [TrainerType.KUKUI]: { - encounter: [ - "dialogue:kukui.encounter.1" - ], - victory: [ - "dialogue:kukui.victory.1" - ], - defeat: [ - "dialogue:kukui.defeat.1" - ] + encounter: ["dialogue:kukui.encounter.1"], + victory: ["dialogue:kukui.victory.1"], + defeat: ["dialogue:kukui.defeat.1"], }, [TrainerType.HAU]: { - encounter: [ - "dialogue:hau.encounter.1" - ], - victory: [ - "dialogue:hau.victory.1" - ], - defeat: [ - "dialogue:hau.defeat.1" - ] + encounter: ["dialogue:hau.encounter.1"], + victory: ["dialogue:hau.victory.1"], + defeat: ["dialogue:hau.defeat.1"], }, [TrainerType.GEETA]: { - encounter: [ - "dialogue:geeta.encounter.1" - ], - victory: [ - "dialogue:geeta.victory.1" - ], - defeat: [ - "dialogue:geeta.defeat.1" - ] + encounter: ["dialogue:geeta.encounter.1"], + victory: ["dialogue:geeta.victory.1"], + defeat: ["dialogue:geeta.defeat.1"], }, [TrainerType.NEMONA]: { - encounter: [ - "dialogue:nemona.encounter.1" - ], - victory: [ - "dialogue:nemona.victory.1" - ], - defeat: [ - "dialogue:nemona.defeat.1" - ] + encounter: ["dialogue:nemona.encounter.1"], + victory: ["dialogue:nemona.victory.1"], + defeat: ["dialogue:nemona.defeat.1"], }, [TrainerType.LEON]: { - encounter: [ - "dialogue:leon.encounter.1" - ], - victory: [ - "dialogue:leon.victory.1" - ], - defeat: [ - "dialogue:leon.defeat.1" - ] + encounter: ["dialogue:leon.encounter.1"], + victory: ["dialogue:leon.victory.1"], + defeat: ["dialogue:leon.defeat.1"], }, [TrainerType.MUSTARD]: { - encounter: [ - "dialogue:mustard.encounter.1" - ], - victory: [ - "dialogue:mustard.victory.1" - ], - defeat: [ - "dialogue:mustard.defeat.1" - ] + encounter: ["dialogue:mustard.encounter.1"], + victory: ["dialogue:mustard.victory.1"], + defeat: ["dialogue:mustard.defeat.1"], }, [TrainerType.WHITNEY]: { - encounter: [ - "dialogue:whitney.encounter.1" - ], - victory: [ - "dialogue:whitney.victory.1" - ], - defeat: [ - "dialogue:whitney.defeat.1" - ] + encounter: ["dialogue:whitney.encounter.1"], + victory: ["dialogue:whitney.victory.1"], + defeat: ["dialogue:whitney.defeat.1"], }, [TrainerType.CHUCK]: { - encounter: [ - "dialogue:chuck.encounter.1" - ], - victory: [ - "dialogue:chuck.victory.1" - ], - defeat: [ - "dialogue:chuck.defeat.1" - ] + encounter: ["dialogue:chuck.encounter.1"], + victory: ["dialogue:chuck.victory.1"], + defeat: ["dialogue:chuck.defeat.1"], }, [TrainerType.KATY]: { - encounter: [ - "dialogue:katy.encounter.1" - ], - victory: [ - "dialogue:katy.victory.1" - ], - defeat: [ - "dialogue:katy.defeat.1" - ] + encounter: ["dialogue:katy.encounter.1"], + victory: ["dialogue:katy.victory.1"], + defeat: ["dialogue:katy.defeat.1"], }, [TrainerType.PRYCE]: { - encounter: [ - "dialogue:pryce.encounter.1" - ], - victory: [ - "dialogue:pryce.victory.1" - ], - defeat: [ - "dialogue:pryce.defeat.1" - ] + encounter: ["dialogue:pryce.encounter.1"], + victory: ["dialogue:pryce.victory.1"], + defeat: ["dialogue:pryce.defeat.1"], }, [TrainerType.CLAIR]: { - encounter: [ - "dialogue:clair.encounter.1" - ], - victory: [ - "dialogue:clair.victory.1" - ], - defeat: [ - "dialogue:clair.defeat.1" - ] + encounter: ["dialogue:clair.encounter.1"], + victory: ["dialogue:clair.victory.1"], + defeat: ["dialogue:clair.defeat.1"], }, [TrainerType.MAYLENE]: { - encounter: [ - "dialogue:maylene.encounter.1" - ], - victory: [ - "dialogue:maylene.victory.1" - ], - defeat: [ - "dialogue:maylene.defeat.1" - ] + encounter: ["dialogue:maylene.encounter.1"], + victory: ["dialogue:maylene.victory.1"], + defeat: ["dialogue:maylene.defeat.1"], }, [TrainerType.FANTINA]: { - encounter: [ - "dialogue:fantina.encounter.1" - ], - victory: [ - "dialogue:fantina.victory.1" - ], - defeat: [ - "dialogue:fantina.defeat.1" - ] + encounter: ["dialogue:fantina.encounter.1"], + victory: ["dialogue:fantina.victory.1"], + defeat: ["dialogue:fantina.defeat.1"], }, [TrainerType.BYRON]: { - encounter: [ - "dialogue:byron.encounter.1" - ], - victory: [ - "dialogue:byron.victory.1" - ], - defeat: [ - "dialogue:byron.defeat.1" - ] + encounter: ["dialogue:byron.encounter.1"], + victory: ["dialogue:byron.victory.1"], + defeat: ["dialogue:byron.defeat.1"], }, [TrainerType.OLYMPIA]: { - encounter: [ - "dialogue:olympia.encounter.1" - ], - victory: [ - "dialogue:olympia.victory.1" - ], - defeat: [ - "dialogue:olympia.defeat.1" - ] + encounter: ["dialogue:olympia.encounter.1"], + victory: ["dialogue:olympia.victory.1"], + defeat: ["dialogue:olympia.defeat.1"], }, [TrainerType.VOLKNER]: { - encounter: [ - "dialogue:volkner.encounter.1" - ], - victory: [ - "dialogue:volkner.victory.1" - ], - defeat: [ - "dialogue:volkner.defeat.1" - ] + encounter: ["dialogue:volkner.encounter.1"], + victory: ["dialogue:volkner.victory.1"], + defeat: ["dialogue:volkner.defeat.1"], }, [TrainerType.BURGH]: { - encounter: [ - "dialogue:burgh.encounter.1", - "dialogue:burgh.encounter.2" - ], - victory: [ - "dialogue:burgh.victory.1", - "dialogue:burgh.victory.2" - ], - defeat: [ - "dialogue:burgh.defeat.1", - "dialogue:burgh.defeat.2" - ] + encounter: ["dialogue:burgh.encounter.1", "dialogue:burgh.encounter.2"], + victory: ["dialogue:burgh.victory.1", "dialogue:burgh.victory.2"], + defeat: ["dialogue:burgh.defeat.1", "dialogue:burgh.defeat.2"], }, [TrainerType.ELESA]: { - encounter: [ - "dialogue:elesa.encounter.1" - ], - victory: [ - "dialogue:elesa.victory.1" - ], - defeat: [ - "dialogue:elesa.defeat.1" - ] + encounter: ["dialogue:elesa.encounter.1"], + victory: ["dialogue:elesa.victory.1"], + defeat: ["dialogue:elesa.defeat.1"], }, [TrainerType.SKYLA]: { - encounter: [ - "dialogue:skyla.encounter.1" - ], - victory: [ - "dialogue:skyla.victory.1" - ], - defeat: [ - "dialogue:skyla.defeat.1" - ] + encounter: ["dialogue:skyla.encounter.1"], + victory: ["dialogue:skyla.victory.1"], + defeat: ["dialogue:skyla.defeat.1"], }, [TrainerType.BRYCEN]: { - encounter: [ - "dialogue:brycen.encounter.1" - ], - victory: [ - "dialogue:brycen.victory.1" - ], - defeat: [ - "dialogue:brycen.defeat.1" - ] + encounter: ["dialogue:brycen.encounter.1"], + victory: ["dialogue:brycen.victory.1"], + defeat: ["dialogue:brycen.defeat.1"], }, [TrainerType.DRAYDEN]: { - encounter: [ - "dialogue:drayden.encounter.1" - ], - victory: [ - "dialogue:drayden.victory.1" - ], - defeat: [ - "dialogue:drayden.defeat.1" - ] + encounter: ["dialogue:drayden.encounter.1"], + victory: ["dialogue:drayden.victory.1"], + defeat: ["dialogue:drayden.defeat.1"], }, [TrainerType.GRANT]: { - encounter: [ - "dialogue:grant.encounter.1" - ], - victory: [ - "dialogue:grant.victory.1" - ], - defeat: [ - "dialogue:grant.defeat.1" - ] + encounter: ["dialogue:grant.encounter.1"], + victory: ["dialogue:grant.victory.1"], + defeat: ["dialogue:grant.defeat.1"], }, [TrainerType.KORRINA]: { - encounter: [ - "dialogue:korrina.encounter.1" - ], - victory: [ - "dialogue:korrina.victory.1" - ], - defeat: [ - "dialogue:korrina.defeat.1" - ] + encounter: ["dialogue:korrina.encounter.1"], + victory: ["dialogue:korrina.victory.1"], + defeat: ["dialogue:korrina.defeat.1"], }, [TrainerType.CLEMONT]: { - encounter: [ - "dialogue:clemont.encounter.1" - ], - victory: [ - "dialogue:clemont.victory.1" - ], - defeat: [ - "dialogue:clemont.defeat.1" - ] + encounter: ["dialogue:clemont.encounter.1"], + victory: ["dialogue:clemont.victory.1"], + defeat: ["dialogue:clemont.defeat.1"], }, [TrainerType.VALERIE]: { - encounter: [ - "dialogue:valerie.encounter.1" - ], - victory: [ - "dialogue:valerie.victory.1" - ], - defeat: [ - "dialogue:valerie.defeat.1" - ] + encounter: ["dialogue:valerie.encounter.1"], + victory: ["dialogue:valerie.victory.1"], + defeat: ["dialogue:valerie.defeat.1"], }, [TrainerType.WULFRIC]: { - encounter: [ - "dialogue:wulfric.encounter.1" - ], - victory: [ - "dialogue:wulfric.victory.1" - ], - defeat: [ - "dialogue:wulfric.defeat.1" - ] + encounter: ["dialogue:wulfric.encounter.1"], + victory: ["dialogue:wulfric.victory.1"], + defeat: ["dialogue:wulfric.defeat.1"], }, [TrainerType.KABU]: { - encounter: [ - "dialogue:kabu.encounter.1" - ], - victory: [ - "dialogue:kabu.victory.1" - ], - defeat: [ - "dialogue:kabu.defeat.1" - ] + encounter: ["dialogue:kabu.encounter.1"], + victory: ["dialogue:kabu.victory.1"], + defeat: ["dialogue:kabu.defeat.1"], }, [TrainerType.BEA]: { - encounter: [ - "dialogue:bea.encounter.1" - ], - victory: [ - "dialogue:bea.victory.1" - ], - defeat: [ - "dialogue:bea.defeat.1" - ] + encounter: ["dialogue:bea.encounter.1"], + victory: ["dialogue:bea.victory.1"], + defeat: ["dialogue:bea.defeat.1"], }, [TrainerType.OPAL]: { - encounter: [ - "dialogue:opal.encounter.1" - ], - victory: [ - "dialogue:opal.victory.1" - ], - defeat: [ - "dialogue:opal.defeat.1" - ] + encounter: ["dialogue:opal.encounter.1"], + victory: ["dialogue:opal.victory.1"], + defeat: ["dialogue:opal.defeat.1"], }, [TrainerType.BEDE]: { - encounter: [ - "dialogue:bede.encounter.1" - ], - victory: [ - "dialogue:bede.victory.1" - ], - defeat: [ - "dialogue:bede.defeat.1" - ] + encounter: ["dialogue:bede.encounter.1"], + victory: ["dialogue:bede.victory.1"], + defeat: ["dialogue:bede.defeat.1"], }, [TrainerType.GORDIE]: { - encounter: [ - "dialogue:gordie.encounter.1" - ], - victory: [ - "dialogue:gordie.victory.1" - ], - defeat: [ - "dialogue:gordie.defeat.1" - ] + encounter: ["dialogue:gordie.encounter.1"], + victory: ["dialogue:gordie.victory.1"], + defeat: ["dialogue:gordie.defeat.1"], }, [TrainerType.MARNIE]: { - encounter: [ - "dialogue:marnie.encounter.1" - ], - victory: [ - "dialogue:marnie.victory.1" - ], - defeat: [ - "dialogue:marnie.defeat.1" - ] + encounter: ["dialogue:marnie.encounter.1"], + victory: ["dialogue:marnie.victory.1"], + defeat: ["dialogue:marnie.defeat.1"], }, [TrainerType.RAIHAN]: { - encounter: [ - "dialogue:raihan.encounter.1" - ], - victory: [ - "dialogue:raihan.victory.1" - ], - defeat: [ - "dialogue:raihan.defeat.1" - ] + encounter: ["dialogue:raihan.encounter.1"], + victory: ["dialogue:raihan.victory.1"], + defeat: ["dialogue:raihan.defeat.1"], }, [TrainerType.BRASSIUS]: { - encounter: [ - "dialogue:brassius.encounter.1" - ], - victory: [ - "dialogue:brassius.victory.1" - ], - defeat: [ - "dialogue:brassius.defeat.1" - ] + encounter: ["dialogue:brassius.encounter.1"], + victory: ["dialogue:brassius.victory.1"], + defeat: ["dialogue:brassius.defeat.1"], }, [TrainerType.IONO]: { - encounter: [ - "dialogue:iono.encounter.1" - ], - victory: [ - "dialogue:iono.victory.1" - ], - defeat: [ - "dialogue:iono.defeat.1" - ] + encounter: ["dialogue:iono.encounter.1"], + victory: ["dialogue:iono.victory.1"], + defeat: ["dialogue:iono.defeat.1"], }, [TrainerType.LARRY]: { - encounter: [ - "dialogue:larry.encounter.1" - ], - victory: [ - "dialogue:larry.victory.1" - ], - defeat: [ - "dialogue:larry.defeat.1" - ] + encounter: ["dialogue:larry.encounter.1"], + victory: ["dialogue:larry.victory.1"], + defeat: ["dialogue:larry.defeat.1"], }, [TrainerType.RYME]: { - encounter: [ - "dialogue:ryme.encounter.1" - ], - victory: [ - "dialogue:ryme.victory.1" - ], - defeat: [ - "dialogue:ryme.defeat.1" - ] + encounter: ["dialogue:ryme.encounter.1"], + victory: ["dialogue:ryme.victory.1"], + defeat: ["dialogue:ryme.defeat.1"], }, [TrainerType.GRUSHA]: { - encounter: [ - "dialogue:grusha.encounter.1" - ], - victory: [ - "dialogue:grusha.victory.1" - ], - defeat: [ - "dialogue:grusha.defeat.1" - ] + encounter: ["dialogue:grusha.encounter.1"], + victory: ["dialogue:grusha.victory.1"], + defeat: ["dialogue:grusha.defeat.1"], }, [TrainerType.MARNIE_ELITE]: { - encounter: [ - "dialogue:marnie_elite.encounter.1", - "dialogue:marnie_elite.encounter.2" - ], - victory: [ - "dialogue:marnie_elite.victory.1", - "dialogue:marnie_elite.victory.2" - ], - defeat: [ - "dialogue:marnie_elite.defeat.1", - "dialogue:marnie_elite.defeat.2" - ] + encounter: ["dialogue:marnie_elite.encounter.1", "dialogue:marnie_elite.encounter.2"], + victory: ["dialogue:marnie_elite.victory.1", "dialogue:marnie_elite.victory.2"], + defeat: ["dialogue:marnie_elite.defeat.1", "dialogue:marnie_elite.defeat.2"], }, [TrainerType.NESSA_ELITE]: { - encounter: [ - "dialogue:nessa_elite.encounter.1", - "dialogue:nessa_elite.encounter.2" - ], - victory: [ - "dialogue:nessa_elite.victory.1", - "dialogue:nessa_elite.victory.2" - ], - defeat: [ - "dialogue:nessa_elite.defeat.1", - "dialogue:nessa_elite.defeat.2" - ] + encounter: ["dialogue:nessa_elite.encounter.1", "dialogue:nessa_elite.encounter.2"], + victory: ["dialogue:nessa_elite.victory.1", "dialogue:nessa_elite.victory.2"], + defeat: ["dialogue:nessa_elite.defeat.1", "dialogue:nessa_elite.defeat.2"], }, [TrainerType.BEA_ELITE]: { - encounter: [ - "dialogue:bea_elite.encounter.1", - "dialogue:bea_elite.encounter.2" - ], - victory: [ - "dialogue:bea_elite.victory.1", - "dialogue:bea_elite.victory.2" - ], - defeat: [ - "dialogue:bea_elite.defeat.1", - "dialogue:bea_elite.defeat.2" - ] + encounter: ["dialogue:bea_elite.encounter.1", "dialogue:bea_elite.encounter.2"], + victory: ["dialogue:bea_elite.victory.1", "dialogue:bea_elite.victory.2"], + defeat: ["dialogue:bea_elite.defeat.1", "dialogue:bea_elite.defeat.2"], }, [TrainerType.ALLISTER_ELITE]: { - encounter: [ - "dialogue:allister_elite.encounter.1", - "dialogue:allister_elite.encounter.2" - ], - victory: [ - "dialogue:allister_elite.victory.1", - "dialogue:allister_elite.victory.2" - ], - defeat: [ - "dialogue:allister_elite.defeat.1", - "dialogue:allister_elite.defeat.2" - ] + encounter: ["dialogue:allister_elite.encounter.1", "dialogue:allister_elite.encounter.2"], + victory: ["dialogue:allister_elite.victory.1", "dialogue:allister_elite.victory.2"], + defeat: ["dialogue:allister_elite.defeat.1", "dialogue:allister_elite.defeat.2"], }, [TrainerType.RAIHAN_ELITE]: { - encounter: [ - "dialogue:raihan_elite.encounter.1", - "dialogue:raihan_elite.encounter.2" - ], - victory: [ - "dialogue:raihan_elite.victory.1", - "dialogue:raihan_elite.victory.2" - ], - defeat: [ - "dialogue:raihan_elite.defeat.1", - "dialogue:raihan_elite.defeat.2" - ] + encounter: ["dialogue:raihan_elite.encounter.1", "dialogue:raihan_elite.encounter.2"], + victory: ["dialogue:raihan_elite.victory.1", "dialogue:raihan_elite.victory.2"], + defeat: ["dialogue:raihan_elite.defeat.1", "dialogue:raihan_elite.defeat.2"], }, [TrainerType.ALDER]: { - encounter: [ - "dialogue:alder.encounter.1" - ], - victory: [ - "dialogue:alder.victory.1" - ], - defeat: [ - "dialogue:alder.defeat.1" - ] + encounter: ["dialogue:alder.encounter.1"], + victory: ["dialogue:alder.victory.1"], + defeat: ["dialogue:alder.defeat.1"], }, [TrainerType.KIERAN]: { - encounter: [ - "dialogue:kieran.encounter.1" - ], - victory: [ - "dialogue:kieran.victory.1" - ], - defeat: [ - "dialogue:kieran.defeat.1" - ] + encounter: ["dialogue:kieran.encounter.1"], + victory: ["dialogue:kieran.victory.1"], + defeat: ["dialogue:kieran.defeat.1"], }, [TrainerType.RIVAL]: [ { - encounter: [ - "dialogue:rival.encounter.1", - ], - victory: [ - "dialogue:rival.victory.1", - ], - + encounter: ["dialogue:rival.encounter.1"], + victory: ["dialogue:rival.victory.1"], }, { - encounter: [ - "dialogue:rival_female.encounter.1", - ], - victory: [ - "dialogue:rival_female.victory.1", - ] - } + encounter: ["dialogue:rival_female.encounter.1"], + victory: ["dialogue:rival_female.victory.1"], + }, ], [TrainerType.RIVAL_2]: [ { - encounter: [ - "dialogue:rival_2.encounter.1", - ], - victory: [ - "dialogue:rival_2.victory.1", - ], - + encounter: ["dialogue:rival_2.encounter.1"], + victory: ["dialogue:rival_2.victory.1"], }, { - encounter: [ - "dialogue:rival_2_female.encounter.1", - ], - victory: [ - "dialogue:rival_2_female.victory.1", - ], - defeat: [ - "dialogue:rival_2_female.defeat.1", - ] + encounter: ["dialogue:rival_2_female.encounter.1"], + victory: ["dialogue:rival_2_female.victory.1"], + defeat: ["dialogue:rival_2_female.defeat.1"], }, ], [TrainerType.RIVAL_3]: [ { - encounter: [ - "dialogue:rival_3.encounter.1", - ], - victory: [ - "dialogue:rival_3.victory.1", - ] + encounter: ["dialogue:rival_3.encounter.1"], + victory: ["dialogue:rival_3.victory.1"], }, { - encounter: [ - "dialogue:rival_3_female.encounter.1", - ], - victory: [ - "dialogue:rival_3_female.victory.1", - ], - defeat: [ - "dialogue:rival_3_female.defeat.1", - ] - } + encounter: ["dialogue:rival_3_female.encounter.1"], + victory: ["dialogue:rival_3_female.victory.1"], + defeat: ["dialogue:rival_3_female.defeat.1"], + }, ], [TrainerType.RIVAL_4]: [ { - encounter: [ - "dialogue:rival_4.encounter.1", - ], - victory: [ - "dialogue:rival_4.victory.1", - ] + encounter: ["dialogue:rival_4.encounter.1"], + victory: ["dialogue:rival_4.victory.1"], }, { - encounter: [ - "dialogue:rival_4_female.encounter.1", - ], - victory: [ - "dialogue:rival_4_female.victory.1", - ], - defeat: [ - "dialogue:rival_4_female.defeat.1", - ] - } + encounter: ["dialogue:rival_4_female.encounter.1"], + victory: ["dialogue:rival_4_female.victory.1"], + defeat: ["dialogue:rival_4_female.defeat.1"], + }, ], [TrainerType.RIVAL_5]: [ { - encounter: [ - "dialogue:rival_5.encounter.1", - ], - victory: [ - "dialogue:rival_5.victory.1", - ] + encounter: ["dialogue:rival_5.encounter.1"], + victory: ["dialogue:rival_5.victory.1"], }, { - encounter: [ - "dialogue:rival_5_female.encounter.1", - ], - victory: [ - "dialogue:rival_5_female.victory.1", - ], - defeat: [ - "dialogue:rival_5_female.defeat.1", - ] - } + encounter: ["dialogue:rival_5_female.encounter.1"], + victory: ["dialogue:rival_5_female.victory.1"], + defeat: ["dialogue:rival_5_female.defeat.1"], + }, ], [TrainerType.RIVAL_6]: [ { - encounter: [ - "dialogue:rival_6.encounter.1", - ], - victory: [ - "dialogue:rival_6.victory.1", - ] + encounter: ["dialogue:rival_6.encounter.1"], + victory: ["dialogue:rival_6.victory.1"], }, { - encounter: [ - "dialogue:rival_6_female.encounter.1", - ], - victory: [ - "dialogue:rival_6_female.victory.1", - ], - } - ] + encounter: ["dialogue:rival_6_female.encounter.1"], + victory: ["dialogue:rival_6_female.victory.1"], + }, + ], }; - export const doubleBattleDialogue = { - "blue_red_double": { - encounter: [ "doubleBattleDialogue:blue_red_double.encounter.1" ], - victory: [ "doubleBattleDialogue:blue_red_double.victory.1" ] + blue_red_double: { + encounter: ["doubleBattleDialogue:blue_red_double.encounter.1"], + victory: ["doubleBattleDialogue:blue_red_double.victory.1"], }, - "red_blue_double": { - encounter: [ "doubleBattleDialogue:red_blue_double.encounter.1" ], - victory: [ "doubleBattleDialogue:red_blue_double.victory.1" ] + red_blue_double: { + encounter: ["doubleBattleDialogue:red_blue_double.encounter.1"], + victory: ["doubleBattleDialogue:red_blue_double.victory.1"], }, - "tate_liza_double": { - encounter: [ "doubleBattleDialogue:tate_liza_double.encounter.1" ], - victory: [ "doubleBattleDialogue:tate_liza_double.victory.1" ] + tate_liza_double: { + encounter: ["doubleBattleDialogue:tate_liza_double.encounter.1"], + victory: ["doubleBattleDialogue:tate_liza_double.victory.1"], }, - "liza_tate_double": { - encounter: [ "doubleBattleDialogue:liza_tate_double.encounter.1" ], - victory: [ "doubleBattleDialogue:liza_tate_double.victory.1" ] + liza_tate_double: { + encounter: ["doubleBattleDialogue:liza_tate_double.encounter.1"], + victory: ["doubleBattleDialogue:liza_tate_double.victory.1"], }, - "wallace_steven_double": { - encounter: [ "doubleBattleDialogue:wallace_steven_double.encounter.1" ], - victory: [ "doubleBattleDialogue:wallace_steven_double.victory.1" ] + wallace_steven_double: { + encounter: ["doubleBattleDialogue:wallace_steven_double.encounter.1"], + victory: ["doubleBattleDialogue:wallace_steven_double.victory.1"], }, - "steven_wallace_double": { - encounter: [ "doubleBattleDialogue:steven_wallace_double.encounter.1" ], - victory: [ "doubleBattleDialogue:steven_wallace_double.victory.1" ] + steven_wallace_double: { + encounter: ["doubleBattleDialogue:steven_wallace_double.encounter.1"], + victory: ["doubleBattleDialogue:steven_wallace_double.victory.1"], }, - "alder_iris_double": { - encounter: [ "doubleBattleDialogue:alder_iris_double.encounter.1" ], - victory: [ "doubleBattleDialogue:alder_iris_double.victory.1" ] + alder_iris_double: { + encounter: ["doubleBattleDialogue:alder_iris_double.encounter.1"], + victory: ["doubleBattleDialogue:alder_iris_double.victory.1"], }, - "iris_alder_double": { - encounter: [ "doubleBattleDialogue:iris_alder_double.encounter.1" ], - victory: [ "doubleBattleDialogue:iris_alder_double.victory.1" ] + iris_alder_double: { + encounter: ["doubleBattleDialogue:iris_alder_double.encounter.1"], + victory: ["doubleBattleDialogue:iris_alder_double.victory.1"], }, - "marnie_piers_double": { - encounter: [ "doubleBattleDialogue:marnie_piers_double.encounter.1" ], - victory: [ "doubleBattleDialogue:marnie_piers_double.victory.1" ] + marnie_piers_double: { + encounter: ["doubleBattleDialogue:marnie_piers_double.encounter.1"], + victory: ["doubleBattleDialogue:marnie_piers_double.victory.1"], }, - "piers_marnie_double": { - encounter: [ "doubleBattleDialogue:piers_marnie_double.encounter.1" ], - victory: [ "doubleBattleDialogue:piers_marnie_double.victory.1" ] + piers_marnie_double: { + encounter: ["doubleBattleDialogue:piers_marnie_double.encounter.1"], + victory: ["doubleBattleDialogue:piers_marnie_double.victory.1"], }, - - }; export const battleSpecDialogue = { @@ -3193,14 +1664,11 @@ export const battleSpecDialogue = { encounter: "battleSpecDialogue:encounter", firstStageWin: "battleSpecDialogue:firstStageWin", secondStageWin: "battleSpecDialogue:secondStageWin", - } + }, }; export const miscDialogue = { - ending: [ - "miscDialogue:ending", - "miscDialogue:ending_female" - ] + ending: ["miscDialogue:ending", "miscDialogue:ending_female"], }; export function getCharVariantFromDialogue(message: string): string { @@ -3212,17 +1680,18 @@ export function getCharVariantFromDialogue(message: string): string { } export function initTrainerTypeDialogue(): void { - const trainerTypes = Object.keys(trainerTypeDialogue).map(t => parseInt(t) as TrainerType); + const trainerTypes = Object.keys(trainerTypeDialogue).map(t => Number.parseInt(t) as TrainerType); for (const trainerType of trainerTypes) { const messages = trainerTypeDialogue[trainerType]; - const messageTypes = [ "encounter", "victory", "defeat" ]; + const messageTypes = ["encounter", "victory", "defeat"]; for (const messageType of messageTypes) { if (Array.isArray(messages)) { if (messages[0][messageType]) { trainerConfigs[trainerType][`${messageType}Messages`] = messages[0][messageType]; } if (messages.length > 1) { - trainerConfigs[trainerType][`female${messageType.slice(0, 1).toUpperCase()}${messageType.slice(1)}Messages`] = messages[1][messageType]; + trainerConfigs[trainerType][`female${messageType.slice(0, 1).toUpperCase()}${messageType.slice(1)}Messages`] = + messages[1][messageType]; } } else { trainerConfigs[trainerType][`${messageType}Messages`] = messages[messageType]; diff --git a/src/data/egg-hatch-data.ts b/src/data/egg-hatch-data.ts index 37ee9bede09..949ed1af063 100644 --- a/src/data/egg-hatch-data.ts +++ b/src/data/egg-hatch-data.ts @@ -24,17 +24,17 @@ export class EggHatchData { } /** - * Sets the boolean for if the egg move for the hatch is a new unlock - * @param unlocked True if the EM is new - */ + * Sets the boolean for if the egg move for the hatch is a new unlock + * @param unlocked True if the EM is new + */ setEggMoveUnlocked(unlocked: boolean) { - this.eggMoveUnlocked = unlocked; + this.eggMoveUnlocked = unlocked; } /** - * Stores a copy of the current DexEntry of the pokemon and StarterDataEntry of its starter - * Used before updating the dex, so comparing the pokemon to these entries will show the new attributes - */ + * Stores a copy of the current DexEntry of the pokemon and StarterDataEntry of its starter + * Used before updating the dex, so comparing the pokemon to these entries will show the new attributes + */ setDex() { const currDexEntry = globalScene.gameData.dexData[this.pokemon.species.speciesId]; const currStarterDataEntry = globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId()]; @@ -45,7 +45,7 @@ export class EggHatchData { seenCount: currDexEntry.seenCount, caughtCount: currDexEntry.caughtCount, hatchedCount: currDexEntry.hatchedCount, - ivs: [ ...currDexEntry.ivs ] + ivs: [...currDexEntry.ivs], }; this.starterDataEntryBeforeUpdate = { moveset: currStarterDataEntry.moveset, @@ -55,37 +55,37 @@ export class EggHatchData { abilityAttr: currStarterDataEntry.abilityAttr, passiveAttr: currStarterDataEntry.passiveAttr, valueReduction: currStarterDataEntry.valueReduction, - classicWinCount: currStarterDataEntry.classicWinCount + classicWinCount: currStarterDataEntry.classicWinCount, }; } /** - * Gets the dex entry before update - * @returns Dex Entry corresponding to this pokemon before the pokemon was added / updated to dex - */ + * Gets the dex entry before update + * @returns Dex Entry corresponding to this pokemon before the pokemon was added / updated to dex + */ getDex(): DexEntry { return this.dexEntryBeforeUpdate; } /** - * Gets the starter dex entry before update - * @returns Starter Dex Entry corresponding to this pokemon before the pokemon was added / updated to dex - */ + * Gets the starter dex entry before update + * @returns Starter Dex Entry corresponding to this pokemon before the pokemon was added / updated to dex + */ getStarterEntry(): StarterDataEntry { return this.starterDataEntryBeforeUpdate; } /** - * Update the pokedex data corresponding with the new hatch's pokemon data - * Also sets whether the egg move is a new unlock or not - * @param showMessage boolean to show messages for the new catches and egg moves (false by default) - * @returns - */ - updatePokemon(showMessage : boolean = false) { + * Update the pokedex data corresponding with the new hatch's pokemon data + * Also sets whether the egg move is a new unlock or not + * @param showMessage boolean to show messages for the new catches and egg moves (false by default) + * @returns + */ + updatePokemon(showMessage = false) { return new Promise(resolve => { globalScene.gameData.setPokemonCaught(this.pokemon, true, true, showMessage).then(() => { globalScene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs); - globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex, showMessage).then((value) => { + globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex, showMessage).then(value => { this.setEggMoveUnlocked(value); resolve(); }); diff --git a/src/data/egg.ts b/src/data/egg.ts index 380b5ddabfe..0dabf8f1119 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -12,7 +12,31 @@ import i18next from "i18next"; import { EggTier } from "#enums/egg-type"; import { Species } from "#enums/species"; import { EggSourceType } from "#enums/egg-source-types"; -import { MANAPHY_EGG_MANAPHY_RATE, SAME_SPECIES_EGG_HA_RATE, GACHA_EGG_HA_RATE, GACHA_DEFAULT_RARE_EGGMOVE_RATE, SAME_SPECIES_EGG_RARE_EGGMOVE_RATE, GACHA_MOVE_UP_RARE_EGGMOVE_RATE, GACHA_DEFAULT_SHINY_RATE, GACHA_SHINY_UP_SHINY_RATE, SAME_SPECIES_EGG_SHINY_RATE, EGG_PITY_LEGENDARY_THRESHOLD, EGG_PITY_EPIC_THRESHOLD, EGG_PITY_RARE_THRESHOLD, SHINY_VARIANT_CHANCE, SHINY_EPIC_CHANCE, GACHA_DEFAULT_COMMON_EGG_THRESHOLD, GACHA_DEFAULT_RARE_EGG_THRESHOLD, GACHA_DEFAULT_EPIC_EGG_THRESHOLD, GACHA_LEGENDARY_UP_THRESHOLD_OFFSET, HATCH_WAVES_MANAPHY_EGG, HATCH_WAVES_COMMON_EGG, HATCH_WAVES_RARE_EGG, HATCH_WAVES_EPIC_EGG, HATCH_WAVES_LEGENDARY_EGG } from "#app/data/balance/rates"; +import { + MANAPHY_EGG_MANAPHY_RATE, + SAME_SPECIES_EGG_HA_RATE, + GACHA_EGG_HA_RATE, + GACHA_DEFAULT_RARE_EGGMOVE_RATE, + SAME_SPECIES_EGG_RARE_EGGMOVE_RATE, + GACHA_MOVE_UP_RARE_EGGMOVE_RATE, + GACHA_DEFAULT_SHINY_RATE, + GACHA_SHINY_UP_SHINY_RATE, + SAME_SPECIES_EGG_SHINY_RATE, + EGG_PITY_LEGENDARY_THRESHOLD, + EGG_PITY_EPIC_THRESHOLD, + EGG_PITY_RARE_THRESHOLD, + SHINY_VARIANT_CHANCE, + SHINY_EPIC_CHANCE, + GACHA_DEFAULT_COMMON_EGG_THRESHOLD, + GACHA_DEFAULT_RARE_EGG_THRESHOLD, + GACHA_DEFAULT_EPIC_EGG_THRESHOLD, + GACHA_LEGENDARY_UP_THRESHOLD_OFFSET, + HATCH_WAVES_MANAPHY_EGG, + HATCH_WAVES_COMMON_EGG, + HATCH_WAVES_RARE_EGG, + HATCH_WAVES_EPIC_EGG, + HATCH_WAVES_LEGENDARY_EGG, +} from "#app/data/balance/rates"; import { speciesEggTiers } from "#app/data/balance/species-egg-tiers"; export const EGG_SEED = 1073741824; @@ -60,7 +84,6 @@ export interface IEggOptions { } export class Egg { - //// // #region Private properties //// @@ -141,7 +164,7 @@ export class Egg { this._sourceType = eggOptions?.sourceType!; // TODO: is this bang correct? // Ensure _sourceType is defined before invoking rollEggTier(), as it is referenced - this._tier = eggOptions?.tier ?? (Overrides.EGG_TIER_OVERRIDE ?? this.rollEggTier()); + this._tier = eggOptions?.tier ?? Overrides.EGG_TIER_OVERRIDE ?? this.rollEggTier(); // If egg was pulled, check if egg pity needs to override the egg tier if (eggOptions?.pulled) { // Needs this._tier and this._sourceType to work @@ -156,7 +179,7 @@ export class Egg { // First roll shiny and variant so we can filter if species with an variant exist this._isShiny = eggOptions?.isShiny ?? (Overrides.EGG_SHINY_OVERRIDE || this.rollShiny()); - this._variantTier = eggOptions?.variantTier ?? (Overrides.EGG_VARIANT_OVERRIDE ?? this.rollVariant()); + this._variantTier = eggOptions?.variantTier ?? Overrides.EGG_VARIANT_OVERRIDE ?? this.rollVariant(); this._species = eggOptions?.species ?? this.rollSpecies()!; // TODO: Is this bang correct? this._overrideHiddenAbility = eggOptions?.overrideHiddenAbility ?? false; @@ -181,9 +204,13 @@ export class Egg { }; const seedOverride = Utils.randomString(24); - globalScene.executeWithSeedOffset(() => { - generateEggProperties(eggOptions); - }, 0, seedOverride); + globalScene.executeWithSeedOffset( + () => { + generateEggProperties(eggOptions); + }, + 0, + seedOverride, + ); this._eggDescriptor = eggOptions?.eggDescriptor; } @@ -193,8 +220,11 @@ export class Egg { //// public isManaphyEgg(): boolean { - return (this._species === Species.PHIONE || this._species === Species.MANAPHY) || - this._tier === EggTier.COMMON && !(this._id % 204) && !this._species; + return ( + this._species === Species.PHIONE || + this._species === Species.MANAPHY || + (this._tier === EggTier.COMMON && !(this._id % 204) && !this._species) + ); } public getKey(): string { @@ -218,14 +248,18 @@ export class Egg { let pokemonSpecies = getPokemonSpecies(this._species); // Special condition to have Phione eggs also have a chance of generating Manaphy if (this._species === Species.PHIONE && this._sourceType === EggSourceType.SAME_SPECIES_EGG) { - pokemonSpecies = getPokemonSpecies(Utils.randSeedInt(MANAPHY_EGG_MANAPHY_RATE) ? Species.PHIONE : Species.MANAPHY); + pokemonSpecies = getPokemonSpecies( + Utils.randSeedInt(MANAPHY_EGG_MANAPHY_RATE) ? Species.PHIONE : Species.MANAPHY, + ); } // Sets the hidden ability if a hidden ability exists and // the override is set or the egg hits the chance let abilityIndex: number | undefined = undefined; - const sameSpeciesEggHACheck = (this._sourceType === EggSourceType.SAME_SPECIES_EGG && !Utils.randSeedInt(SAME_SPECIES_EGG_HA_RATE)); - const gachaEggHACheck = (!(this._sourceType === EggSourceType.SAME_SPECIES_EGG) && !Utils.randSeedInt(GACHA_EGG_HA_RATE)); + const sameSpeciesEggHACheck = + this._sourceType === EggSourceType.SAME_SPECIES_EGG && !Utils.randSeedInt(SAME_SPECIES_EGG_HA_RATE); + const gachaEggHACheck = + !(this._sourceType === EggSourceType.SAME_SPECIES_EGG) && !Utils.randSeedInt(GACHA_EGG_HA_RATE); if (pokemonSpecies.abilityHidden && (this._overrideHiddenAbility || sameSpeciesEggHACheck || gachaEggHACheck)) { abilityIndex = 2; } @@ -242,10 +276,14 @@ export class Egg { } }; - ret = ret!; // Tell TS compiler it's defined now - globalScene.executeWithSeedOffset(() => { - generatePlayerPokemonHelper(); - }, this._id, EGG_SEED.toString()); + ret = ret!; // Tell TS compiler it's defined now + globalScene.executeWithSeedOffset( + () => { + generatePlayerPokemonHelper(); + }, + this._id, + EGG_SEED.toString(), + ); return ret; } @@ -287,9 +325,17 @@ export class Egg { public getEggTypeDescriptor(): string { switch (this.sourceType) { case EggSourceType.SAME_SPECIES_EGG: - return this._eggDescriptor ?? i18next.t("egg:sameSpeciesEgg", { species: getPokemonSpecies(this._species).getName() }); + return ( + this._eggDescriptor ?? + i18next.t("egg:sameSpeciesEgg", { + species: getPokemonSpecies(this._species).getName(), + }) + ); case EggSourceType.GACHA_LEGENDARY: - return this._eggDescriptor ?? `${i18next.t("egg:gachaTypeLegendary")} (${getPokemonSpecies(getLegendaryGachaSpeciesForTimestamp(this.timestamp)).getName()})`; + return ( + this._eggDescriptor ?? + `${i18next.t("egg:gachaTypeLegendary")} (${getPokemonSpecies(getLegendaryGachaSpeciesForTimestamp(this.timestamp)).getName()})` + ); case EggSourceType.GACHA_SHINY: return this._eggDescriptor ?? i18next.t("egg:gachaTypeShiny"); case EggSourceType.GACHA_MOVE: @@ -344,9 +390,16 @@ export class Egg { } private rollEggTier(): EggTier { - const tierValueOffset = this._sourceType === EggSourceType.GACHA_LEGENDARY ? GACHA_LEGENDARY_UP_THRESHOLD_OFFSET : 0; + const tierValueOffset = + this._sourceType === EggSourceType.GACHA_LEGENDARY ? GACHA_LEGENDARY_UP_THRESHOLD_OFFSET : 0; const tierValue = Utils.randInt(256); - return tierValue >= GACHA_DEFAULT_COMMON_EGG_THRESHOLD + tierValueOffset ? EggTier.COMMON : tierValue >= GACHA_DEFAULT_RARE_EGG_THRESHOLD + tierValueOffset ? EggTier.RARE : tierValue >= GACHA_DEFAULT_EPIC_EGG_THRESHOLD + tierValueOffset ? EggTier.EPIC : EggTier.LEGENDARY; + return tierValue >= GACHA_DEFAULT_COMMON_EGG_THRESHOLD + tierValueOffset + ? EggTier.COMMON + : tierValue >= GACHA_DEFAULT_RARE_EGG_THRESHOLD + tierValueOffset + ? EggTier.RARE + : tierValue >= GACHA_DEFAULT_EPIC_EGG_THRESHOLD + tierValueOffset + ? EggTier.EPIC + : EggTier.LEGENDARY; } private rollSpecies(): Species | null { @@ -364,10 +417,10 @@ export class Egg { * when Utils.randSeedInt(8) = 1, and by making the generatePlayerPokemon() species * check pass when Utils.randSeedInt(8) = 0, we can tell them apart during tests. */ - const rand = (Utils.randSeedInt(MANAPHY_EGG_MANAPHY_RATE) !== 1); + const rand = Utils.randSeedInt(MANAPHY_EGG_MANAPHY_RATE) !== 1; return rand ? Species.PHIONE : Species.MANAPHY; - } else if (this.tier === EggTier.LEGENDARY - && this._sourceType === EggSourceType.GACHA_LEGENDARY) { + } + if (this.tier === EggTier.LEGENDARY && this._sourceType === EggSourceType.GACHA_LEGENDARY) { if (!Utils.randSeedInt(2)) { return getLegendaryGachaSpeciesForTimestamp(this.timestamp); } @@ -395,17 +448,25 @@ export class Egg { break; } - const ignoredSpecies = [ Species.PHIONE, Species.MANAPHY, Species.ETERNATUS ]; + const ignoredSpecies = [Species.PHIONE, Species.MANAPHY, Species.ETERNATUS]; let speciesPool = Object.keys(speciesEggTiers) .filter(s => speciesEggTiers[s] === this.tier) - .map(s => parseInt(s) as Species) - .filter(s => !pokemonPrevolutions.hasOwnProperty(s) && getPokemonSpecies(s).isObtainable() && ignoredSpecies.indexOf(s) === -1); + .map(s => Number.parseInt(s) as Species) + .filter( + s => + !pokemonPrevolutions.hasOwnProperty(s) && + getPokemonSpecies(s).isObtainable() && + ignoredSpecies.indexOf(s) === -1, + ); // If this is the 10th egg without unlocking something new, attempt to force it. if (globalScene.gameData.unlockPity[this.tier] >= 9) { - const lockedPool = speciesPool.filter(s => !globalScene.gameData.dexData[s].caughtAttr && !globalScene.gameData.eggs.some(e => e.species === s)); - if (lockedPool.length) { // Skip this if everything is unlocked + const lockedPool = speciesPool.filter( + s => !globalScene.gameData.dexData[s].caughtAttr && !globalScene.gameData.eggs.some(e => e.species === s), + ); + if (lockedPool.length) { + // Skip this if everything is unlocked speciesPool = lockedPool; } } @@ -427,11 +488,13 @@ export class Egg { * and being the same each time */ let totalWeight = 0; - const speciesWeights : number[] = []; + const speciesWeights: number[] = []; for (const speciesId of speciesPool) { // Accounts for species that have starter costs outside of the normal range for their EggTier const speciesCostClamped = Phaser.Math.Clamp(speciesStarterCosts[speciesId], minStarterValue, maxStarterValue); - const weight = Math.floor((((maxStarterValue - speciesCostClamped) / ((maxStarterValue - minStarterValue) + 1)) * 1.5 + 1) * 100); + const weight = Math.floor( + (((maxStarterValue - speciesCostClamped) / (maxStarterValue - minStarterValue + 1)) * 1.5 + 1) * 100, + ); speciesWeights.push(totalWeight + weight); totalWeight += weight; } @@ -447,7 +510,10 @@ export class Egg { } species = species!; // tell TS compiled it's defined now! - if (globalScene.gameData.dexData[species].caughtAttr || globalScene.gameData.eggs.some(e => e.species === species)) { + if ( + globalScene.gameData.dexData[species].caughtAttr || + globalScene.gameData.eggs.some(e => e.species === species) + ) { globalScene.gameData.unlockPity[this.tier] = Math.min(globalScene.gameData.unlockPity[this.tier] + 1, 10); } else { globalScene.gameData.unlockPity[this.tier] = 0; @@ -457,9 +523,9 @@ export class Egg { } /** - * Rolls whether the egg is shiny or not. - * @returns `true` if the egg is shiny - **/ + * Rolls whether the egg is shiny or not. + * @returns `true` if the egg is shiny + **/ private rollShiny(): boolean { let shinyChance = GACHA_DEFAULT_SHINY_RATE; switch (this._sourceType) { @@ -487,20 +553,24 @@ export class Egg { const rand = Utils.randSeedInt(10); if (rand >= SHINY_VARIANT_CHANCE) { return VariantTier.STANDARD; // 6/10 - } else if (rand >= SHINY_EPIC_CHANCE) { - return VariantTier.RARE; // 3/10 - } else { - return VariantTier.EPIC; // 1/10 } + if (rand >= SHINY_EPIC_CHANCE) { + return VariantTier.RARE; // 3/10 + } + return VariantTier.EPIC; // 1/10 } private checkForPityTierOverrides(): void { - const tierValueOffset = this._sourceType === EggSourceType.GACHA_LEGENDARY ? GACHA_LEGENDARY_UP_THRESHOLD_OFFSET : 0; + const tierValueOffset = + this._sourceType === EggSourceType.GACHA_LEGENDARY ? GACHA_LEGENDARY_UP_THRESHOLD_OFFSET : 0; globalScene.gameData.eggPity[EggTier.RARE] += 1; globalScene.gameData.eggPity[EggTier.EPIC] += 1; globalScene.gameData.eggPity[EggTier.LEGENDARY] += 1 + tierValueOffset; // These numbers are roughly the 80% mark. That is, 80% of the time you'll get an egg before this gets triggered. - if (globalScene.gameData.eggPity[EggTier.LEGENDARY] >= EGG_PITY_LEGENDARY_THRESHOLD && this._tier === EggTier.COMMON) { + if ( + globalScene.gameData.eggPity[EggTier.LEGENDARY] >= EGG_PITY_LEGENDARY_THRESHOLD && + this._tier === EggTier.COMMON + ) { this._tier = EggTier.LEGENDARY; } else if (globalScene.gameData.eggPity[EggTier.EPIC] >= EGG_PITY_EPIC_THRESHOLD && this._tier === EggTier.COMMON) { this._tier = EggTier.EPIC; @@ -539,10 +609,10 @@ export class Egg { //// } -export function getValidLegendaryGachaSpecies() : Species[] { +export function getValidLegendaryGachaSpecies(): Species[] { return Object.entries(speciesEggTiers) .filter(s => s[1] === EggTier.LEGENDARY) - .map(s => parseInt(s[0])) + .map(s => Number.parseInt(s[0])) .filter(s => getPokemonSpecies(s).isObtainable() && s !== Species.ETERNATUS); } @@ -557,9 +627,13 @@ export function getLegendaryGachaSpeciesForTimestamp(timestamp: number): Species const offset = Math.floor(Math.floor(dayTimestamp / 86400000) / legendarySpecies.length); // Cycle number const index = Math.floor(dayTimestamp / 86400000) % legendarySpecies.length; // Index within cycle - globalScene.executeWithSeedOffset(() => { - ret = Phaser.Math.RND.shuffle(legendarySpecies)[index]; - }, offset, EGG_SEED.toString()); + globalScene.executeWithSeedOffset( + () => { + ret = Phaser.Math.RND.shuffle(legendarySpecies)[index]; + }, + offset, + EGG_SEED.toString(), + ); ret = ret!; // tell TS compiler it's return ret; @@ -570,6 +644,6 @@ export function getLegendaryGachaSpeciesForTimestamp(timestamp: number): Species * @param pokemonSpecies - Species for wich we will check the egg tier it belongs to * @returns The egg tier of a given pokemon species */ -export function getEggTierForSpecies(pokemonSpecies :PokemonSpecies): EggTier { +export function getEggTierForSpecies(pokemonSpecies: PokemonSpecies): EggTier { return speciesEggTiers[pokemonSpecies.getRootSpeciesId()]; } diff --git a/src/data/exp.ts b/src/data/exp.ts index 0f5d3e62cef..9f8ccce6d88 100644 --- a/src/data/exp.ts +++ b/src/data/exp.ts @@ -4,16 +4,64 @@ export enum GrowthRate { MEDIUM_FAST, MEDIUM_SLOW, SLOW, - FLUCTUATING + FLUCTUATING, } const expLevels = [ - [ 0, 15, 52, 122, 237, 406, 637, 942, 1326, 1800, 2369, 3041, 3822, 4719, 5737, 6881, 8155, 9564, 11111, 12800, 14632, 16610, 18737, 21012, 23437, 26012, 28737, 31610, 34632, 37800, 41111, 44564, 48155, 51881, 55737, 59719, 63822, 68041, 72369, 76800, 81326, 85942, 90637, 95406, 100237, 105122, 110052, 115015, 120001, 125000, 131324, 137795, 144410, 151165, 158056, 165079, 172229, 179503, 186894, 194400, 202013, 209728, 217540, 225443, 233431, 241496, 249633, 257834, 267406, 276458, 286328, 296358, 305767, 316074, 326531, 336255, 346965, 357812, 367807, 378880, 390077, 400293, 411686, 423190, 433572, 445239, 457001, 467489, 479378, 491346, 501878, 513934, 526049, 536557, 548720, 560922, 571333, 583539, 591882, 600000 ], - [ 0, 6, 21, 51, 100, 172, 274, 409, 583, 800, 1064, 1382, 1757, 2195, 2700, 3276, 3930, 4665, 5487, 6400, 7408, 8518, 9733, 11059, 12500, 14060, 15746, 17561, 19511, 21600, 23832, 26214, 28749, 31443, 34300, 37324, 40522, 43897, 47455, 51200, 55136, 59270, 63605, 68147, 72900, 77868, 83058, 88473, 94119, 100000, 106120, 112486, 119101, 125971, 133100, 140492, 148154, 156089, 164303, 172800, 181584, 190662, 200037, 209715, 219700, 229996, 240610, 251545, 262807, 274400, 286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600, 425152, 441094, 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200, 602856, 622950, 643485, 664467, 685900, 707788, 730138, 752953, 776239, 800000 ], - [ 0, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, 10648, 12167, 13824, 15625, 17576, 19683, 21952, 24389, 27000, 29791, 32768, 35937, 39304, 42875, 46656, 50653, 54872, 59319, 64000, 68921, 74088, 79507, 85184, 91125, 97336, 103823, 110592, 117649, 125000, 132651, 140608, 148877, 157464, 166375, 175616, 185193, 195112, 205379, 216000, 226981, 238328, 250047, 262144, 274625, 287496, 300763, 314432, 328509, 343000, 357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000, 531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000, 753571, 778688, 804357, 830584, 857375, 884736, 912673, 941192, 970299, 1000000 ], - [ 0, 9, 57, 96, 135, 179, 236, 314, 419, 560, 742, 973, 1261, 1612, 2035, 2535, 3120, 3798, 4575, 5460, 6458, 7577, 8825, 10208, 11735, 13411, 15244, 17242, 19411, 21760, 24294, 27021, 29949, 33084, 36435, 40007, 43808, 47846, 52127, 56660, 61450, 66505, 71833, 77440, 83335, 89523, 96012, 102810, 109923, 117360, 125126, 133229, 141677, 150476, 159635, 169159, 179056, 189334, 199999, 211060, 222522, 234393, 246681, 259392, 272535, 286115, 300140, 314618, 329555, 344960, 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860 ], - [ 0, 10, 33, 80, 156, 270, 428, 640, 911, 1250, 1663, 2160, 2746, 3430, 4218, 5120, 6141, 7290, 8573, 10000, 11576, 13310, 15208, 17280, 19531, 21970, 24603, 27440, 30486, 33750, 37238, 40960, 44921, 49130, 53593, 58320, 63316, 68590, 74148, 80000, 86151, 92610, 99383, 106480, 113906, 121670, 129778, 138240, 147061, 156250, 165813, 175760, 186096, 196830, 207968, 219520, 231491, 243890, 256723, 270000, 283726, 297910, 312558, 327680, 343281, 359370, 375953, 393040, 410636, 428750, 447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000, 664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250, 941963, 973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000 ], - [ 0, 4, 13, 32, 65, 112, 178, 276, 393, 540, 745, 967, 1230, 1591, 1957, 2457, 3046, 3732, 4526, 5440, 6482, 7666, 9003, 10506, 12187, 14060, 16140, 18439, 20974, 23760, 26811, 30146, 33780, 37731, 42017, 46656, 50653, 55969, 60505, 66560, 71677, 78533, 84277, 91998, 98415, 107069, 114205, 123863, 131766, 142500, 151222, 163105, 172697, 185807, 196322, 210739, 222231, 238036, 250562, 267840, 281456, 300293, 315059, 335544, 351520, 373744, 390991, 415050, 433631, 459620, 479600, 507617, 529063, 559209, 582187, 614566, 639146, 673863, 700115, 737280, 765275, 804997, 834809, 877201, 908905, 954084, 987754, 1035837, 1071552, 1122660, 1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000 ] + [ + 0, 15, 52, 122, 237, 406, 637, 942, 1326, 1800, 2369, 3041, 3822, 4719, 5737, 6881, 8155, 9564, 11111, 12800, 14632, + 16610, 18737, 21012, 23437, 26012, 28737, 31610, 34632, 37800, 41111, 44564, 48155, 51881, 55737, 59719, 63822, + 68041, 72369, 76800, 81326, 85942, 90637, 95406, 100237, 105122, 110052, 115015, 120001, 125000, 131324, 137795, + 144410, 151165, 158056, 165079, 172229, 179503, 186894, 194400, 202013, 209728, 217540, 225443, 233431, 241496, + 249633, 257834, 267406, 276458, 286328, 296358, 305767, 316074, 326531, 336255, 346965, 357812, 367807, 378880, + 390077, 400293, 411686, 423190, 433572, 445239, 457001, 467489, 479378, 491346, 501878, 513934, 526049, 536557, + 548720, 560922, 571333, 583539, 591882, 600000, + ], + [ + 0, 6, 21, 51, 100, 172, 274, 409, 583, 800, 1064, 1382, 1757, 2195, 2700, 3276, 3930, 4665, 5487, 6400, 7408, 8518, + 9733, 11059, 12500, 14060, 15746, 17561, 19511, 21600, 23832, 26214, 28749, 31443, 34300, 37324, 40522, 43897, + 47455, 51200, 55136, 59270, 63605, 68147, 72900, 77868, 83058, 88473, 94119, 100000, 106120, 112486, 119101, 125971, + 133100, 140492, 148154, 156089, 164303, 172800, 181584, 190662, 200037, 209715, 219700, 229996, 240610, 251545, + 262807, 274400, 286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600, 425152, 441094, + 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200, 602856, 622950, 643485, 664467, 685900, 707788, + 730138, 752953, 776239, 800000, + ], + [ + 0, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, + 10648, 12167, 13824, 15625, 17576, 19683, 21952, 24389, 27000, 29791, 32768, 35937, 39304, 42875, 46656, 50653, + 54872, 59319, 64000, 68921, 74088, 79507, 85184, 91125, 97336, 103823, 110592, 117649, 125000, 132651, 140608, + 148877, 157464, 166375, 175616, 185193, 195112, 205379, 216000, 226981, 238328, 250047, 262144, 274625, 287496, + 300763, 314432, 328509, 343000, 357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000, + 531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000, 753571, 778688, 804357, 830584, + 857375, 884736, 912673, 941192, 970299, 1000000, + ], + [ + 0, 9, 57, 96, 135, 179, 236, 314, 419, 560, 742, 973, 1261, 1612, 2035, 2535, 3120, 3798, 4575, 5460, 6458, 7577, + 8825, 10208, 11735, 13411, 15244, 17242, 19411, 21760, 24294, 27021, 29949, 33084, 36435, 40007, 43808, 47846, + 52127, 56660, 61450, 66505, 71833, 77440, 83335, 89523, 96012, 102810, 109923, 117360, 125126, 133229, 141677, + 150476, 159635, 169159, 179056, 189334, 199999, 211060, 222522, 234393, 246681, 259392, 272535, 286115, 300140, + 314618, 329555, 344960, 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 547274, + 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 789030, 816525, 844653, 873420, 902835, + 932903, 963632, 995030, 1027103, 1059860, + ], + [ + 0, 10, 33, 80, 156, 270, 428, 640, 911, 1250, 1663, 2160, 2746, 3430, 4218, 5120, 6141, 7290, 8573, 10000, 11576, + 13310, 15208, 17280, 19531, 21970, 24603, 27440, 30486, 33750, 37238, 40960, 44921, 49130, 53593, 58320, 63316, + 68590, 74148, 80000, 86151, 92610, 99383, 106480, 113906, 121670, 129778, 138240, 147061, 156250, 165813, 175760, + 186096, 196830, 207968, 219520, 231491, 243890, 256723, 270000, 283726, 297910, 312558, 327680, 343281, 359370, + 375953, 393040, 410636, 428750, 447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000, + 664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250, 941963, 973360, 1005446, 1038230, + 1071718, 1105920, 1140841, 1176490, 1212873, 1250000, + ], + [ + 0, 4, 13, 32, 65, 112, 178, 276, 393, 540, 745, 967, 1230, 1591, 1957, 2457, 3046, 3732, 4526, 5440, 6482, 7666, + 9003, 10506, 12187, 14060, 16140, 18439, 20974, 23760, 26811, 30146, 33780, 37731, 42017, 46656, 50653, 55969, + 60505, 66560, 71677, 78533, 84277, 91998, 98415, 107069, 114205, 123863, 131766, 142500, 151222, 163105, 172697, + 185807, 196322, 210739, 222231, 238036, 250562, 267840, 281456, 300293, 315059, 335544, 351520, 373744, 390991, + 415050, 433631, 459620, 479600, 507617, 529063, 559209, 582187, 614566, 639146, 673863, 700115, 737280, 765275, + 804997, 834809, 877201, 908905, 954084, 987754, 1035837, 1071552, 1122660, 1160499, 1214753, 1254796, 1312322, + 1354652, 1415577, 1460276, 1524731, 1571884, 1640000, + ], ]; export function getLevelTotalExp(level: number, growthRate: GrowthRate): number { @@ -29,22 +77,22 @@ export function getLevelTotalExp(level: number, growthRate: GrowthRate): number switch (growthRate) { case GrowthRate.ERRATIC: - ret = (Math.pow(level, 4) + (Math.pow(level, 3) * 2000)) / 3500; + ret = (Math.pow(level, 4) + Math.pow(level, 3) * 2000) / 3500; break; case GrowthRate.FAST: - ret = Math.pow(level, 3) * 4 / 5; + ret = (Math.pow(level, 3) * 4) / 5; break; case GrowthRate.MEDIUM_FAST: ret = Math.pow(level, 3); break; case GrowthRate.MEDIUM_SLOW: - ret = (Math.pow(level, 3) * 6 / 5) - (15 * Math.pow(level, 2)) + (100 * level) - 140; + ret = (Math.pow(level, 3) * 6) / 5 - 15 * Math.pow(level, 2) + 100 * level - 140; break; case GrowthRate.SLOW: - ret = Math.pow(level, 3) * 5 / 4; + ret = (Math.pow(level, 3) * 5) / 4; break; case GrowthRate.FLUCTUATING: - ret = (Math.pow(level, 3) * ((level / 2) + 8)) * 4 / (100 + level); + ret = (Math.pow(level, 3) * (level / 2 + 8) * 4) / (100 + level); break; } diff --git a/src/data/gender.ts b/src/data/gender.ts index dae7723dd85..5a835c2e786 100644 --- a/src/data/gender.ts +++ b/src/data/gender.ts @@ -1,7 +1,7 @@ export enum Gender { - GENDERLESS = -1, - MALE, - FEMALE + GENDERLESS = -1, + MALE, + FEMALE, } export function getGenderSymbol(gender: Gender) { 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 407644ee939..6cea85346b3 100644 --- a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts +++ b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts @@ -1,7 +1,12 @@ import { globalScene } from "#app/global-scene"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { trainerConfigs, } from "#app/data/trainer-config"; +import { + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { trainerConfigs } from "#app/data/trainer-config"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; @@ -27,161 +32,172 @@ const namespace = "mysteryEncounters/aTrainersTest"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3816 | GitHub Issue #3816} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const ATrainersTestEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.A_TRAINERS_TEST) - .withEncounterTier(MysteryEncounterTier.ROGUE) - .withSceneWaveRangeRequirement(100, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withIntroSpriteConfigs([]) // These are set in onInit() - .withIntroDialogue([ +export const ATrainersTestEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.A_TRAINERS_TEST, +) + .withEncounterTier(MysteryEncounterTier.ROGUE) + .withSceneWaveRangeRequirement(100, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withIntroSpriteConfigs([]) // These are set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withAutoHideIntroVisuals(false) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + + // Randomly pick from 1 of the 5 stat trainers to spawn + let trainerType: TrainerType; + let spriteKeys: { spriteKey: any; fileRoot: any }; + let trainerNameKey: string; + switch (randSeedInt(5)) { + case 1: + trainerType = TrainerType.CHERYL; + spriteKeys = getSpriteKeysFromSpecies(Species.BLISSEY); + trainerNameKey = "cheryl"; + break; + case 2: + trainerType = TrainerType.MARLEY; + spriteKeys = getSpriteKeysFromSpecies(Species.ARCANINE); + trainerNameKey = "marley"; + break; + case 3: + trainerType = TrainerType.MIRA; + spriteKeys = getSpriteKeysFromSpecies(Species.ALAKAZAM, false, 1); + trainerNameKey = "mira"; + break; + case 4: + trainerType = TrainerType.RILEY; + spriteKeys = getSpriteKeysFromSpecies(Species.LUCARIO, false, 1); + trainerNameKey = "riley"; + break; + default: + trainerType = TrainerType.BUCK; + spriteKeys = getSpriteKeysFromSpecies(Species.CLAYDOL); + trainerNameKey = "buck"; + break; + } + + // Dialogue and tokens for trainer + encounter.dialogue.intro = [ { - text: `${namespace}:intro`, + speaker: `trainerNames:${trainerNameKey}`, + text: `${namespace}:${trainerNameKey}.intro_dialogue`, }, - ]) - .withAutoHideIntroVisuals(false) - .withOnInit(() => { + ]; + encounter.options[0].dialogue!.selected = [ + { + speaker: `trainerNames:${trainerNameKey}`, + text: `${namespace}:${trainerNameKey}.accept`, + }, + ]; + encounter.options[1].dialogue!.selected = [ + { + speaker: `trainerNames:${trainerNameKey}`, + text: `${namespace}:${trainerNameKey}.decline`, + }, + ]; + + encounter.setDialogueToken("statTrainerName", i18next.t(`trainerNames:${trainerNameKey}`)); + const eggDescription = `${i18next.t(`${namespace}:title`)}:\n${i18next.t(`trainerNames:${trainerNameKey}`)}`; + encounter.misc = { + trainerType, + trainerNameKey, + trainerEggDescription: eggDescription, + }; + + // Trainer config + const trainerConfig = trainerConfigs[trainerType].clone(); + const trainerSpriteKey = trainerConfig.getSpriteKey(); + encounter.enemyPartyConfigs.push({ + levelAdditiveModifier: 1, + trainerConfig: trainerConfig, + }); + + encounter.spriteConfigs = [ + { + spriteKey: spriteKeys.spriteKey, + fileRoot: spriteKeys.fileRoot, + hasShadow: true, + repeat: true, + isPokemon: true, + x: 22, + y: -2, + yShadow: -2, + }, + { + spriteKey: trainerSpriteKey, + fileRoot: "trainer", + hasShadow: true, + disableAnimation: true, + x: -24, + y: 4, + yShadow: 4, + }, + ]; + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withIntroDialogue() + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + }, + async () => { const encounter = globalScene.currentBattle.mysteryEncounter!; + // Battle the stat trainer for an Egg and great rewards + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Randomly pick from 1 of the 5 stat trainers to spawn - let trainerType: TrainerType; - let spriteKeys; - let trainerNameKey: string; - switch (randSeedInt(5)) { - default: - case 0: - trainerType = TrainerType.BUCK; - spriteKeys = getSpriteKeysFromSpecies(Species.CLAYDOL); - trainerNameKey = "buck"; - break; - case 1: - trainerType = TrainerType.CHERYL; - spriteKeys = getSpriteKeysFromSpecies(Species.BLISSEY); - trainerNameKey = "cheryl"; - break; - case 2: - trainerType = TrainerType.MARLEY; - spriteKeys = getSpriteKeysFromSpecies(Species.ARCANINE); - trainerNameKey = "marley"; - break; - case 3: - trainerType = TrainerType.MIRA; - spriteKeys = getSpriteKeysFromSpecies(Species.ALAKAZAM, false, 1); - trainerNameKey = "mira"; - break; - case 4: - trainerType = TrainerType.RILEY; - spriteKeys = getSpriteKeysFromSpecies(Species.LUCARIO, false, 1); - trainerNameKey = "riley"; - break; - } + await transitionMysteryEncounterIntroVisuals(); - // Dialogue and tokens for trainer - encounter.dialogue.intro = [ + const eggOptions: IEggOptions = { + pulled: false, + sourceType: EggSourceType.EVENT, + eggDescriptor: encounter.misc.trainerEggDescription, + tier: EggTier.EPIC, + }; + encounter.setDialogueToken("eggType", i18next.t(`${namespace}:eggTypes.epic`)); + setEncounterRewards( { - speaker: `trainerNames:${trainerNameKey}`, - text: `${namespace}:${trainerNameKey}.intro_dialogue` - } - ]; - encounter.options[0].dialogue!.selected = [ - { - speaker: `trainerNames:${trainerNameKey}`, - text: `${namespace}:${trainerNameKey}.accept` - } - ]; - encounter.options[1].dialogue!.selected = [ - { - speaker: `trainerNames:${trainerNameKey}`, - text: `${namespace}:${trainerNameKey}.decline` - } - ]; - - encounter.setDialogueToken("statTrainerName", i18next.t(`trainerNames:${trainerNameKey}`)); - const eggDescription = i18next.t(`${namespace}:title`) + ":\n" + i18next.t(`trainerNames:${trainerNameKey}`); - encounter.misc = { trainerType, trainerNameKey, trainerEggDescription: eggDescription }; - - // Trainer config - const trainerConfig = trainerConfigs[trainerType].clone(); - const trainerSpriteKey = trainerConfig.getSpriteKey(); - encounter.enemyPartyConfigs.push({ - levelAdditiveModifier: 1, - trainerConfig: trainerConfig - }); - - encounter.spriteConfigs = [ - { - spriteKey: spriteKeys.spriteKey, - fileRoot: spriteKeys.fileRoot, - hasShadow: true, - repeat: true, - isPokemon: true, - x: 22, - y: -2, - yShadow: -2 + guaranteedModifierTypeFuncs: [modifierTypes.SACRED_ASH], + guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ULTRA], + fillRemaining: true, }, - { - spriteKey: trainerSpriteKey, - fileRoot: "trainer", - hasShadow: true, - disableAnimation: true, - x: -24, - y: 4, - yShadow: 4 - } - ]; + [eggOptions], + ); + await initBattleWithEnemyConfig(config); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + }, + async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Full heal party + globalScene.unshiftPhase(new PartyHealPhase(true)); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withIntroDialogue() - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip` - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Battle the stat trainer for an Egg and great rewards - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - - await transitionMysteryEncounterIntroVisuals(); - - const eggOptions: IEggOptions = { - pulled: false, - sourceType: EggSourceType.EVENT, - eggDescriptor: encounter.misc.trainerEggDescription, - tier: EggTier.EPIC - }; - encounter.setDialogueToken("eggType", i18next.t(`${namespace}:eggTypes.epic`)); - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.SACRED_ASH ], guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ULTRA ], fillRemaining: true }, [ eggOptions ]); - await initBattleWithEnemyConfig(config); - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip` - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Full heal party - globalScene.unshiftPhase(new PartyHealPhase(true)); - - const eggOptions: IEggOptions = { - pulled: false, - sourceType: EggSourceType.EVENT, - eggDescriptor: encounter.misc.trainerEggDescription, - tier: EggTier.RARE - }; - encounter.setDialogueToken("eggType", i18next.t(`${namespace}:eggTypes.rare`)); - setEncounterRewards({ fillRemaining: false, rerollMultiplier: -1 }, [ eggOptions ]); - leaveEncounterWithoutBattle(); - } - ) - .withOutroDialogue([ - { - text: `${namespace}:outro` - } - ]) - .build(); + const eggOptions: IEggOptions = { + pulled: false, + sourceType: EggSourceType.EVENT, + eggDescriptor: encounter.misc.trainerEggDescription, + tier: EggTier.RARE, + }; + encounter.setDialogueToken("eggType", i18next.t(`${namespace}:eggTypes.rare`)); + setEncounterRewards({ fillRemaining: false, rerollMultiplier: -1 }, [eggOptions]); + leaveEncounterWithoutBattle(); + }, + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); diff --git a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts index 1499d953941..ca44782691d 100644 --- a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts +++ b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts @@ -1,5 +1,11 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon, PokemonMove } from "#app/field/pokemon"; import type { BerryModifierType, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; @@ -20,7 +26,11 @@ import { Moves } from "#enums/moves"; import { BattlerTagType } from "#enums/battler-tag-type"; import { randInt } from "#app/utils"; import { BattlerIndex } from "#app/battle"; -import { applyModifierTypeToPlayerPokemon, catchPokemon, getHighestLevelPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + applyModifierTypeToPlayerPokemon, + catchPokemon, + getHighestLevelPlayerPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { TrainerSlot } from "#app/data/trainer-config"; import { PokeballType } from "#enums/pokeball"; import type HeldModifierConfig from "#app/interfaces/held-modifier-config"; @@ -38,339 +48,348 @@ const namespace = "mysteryEncounters/absoluteAvarice"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3805 | GitHub Issue #3805} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const AbsoluteAvariceEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.ABSOLUTE_AVARICE) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new PersistentModifierRequirement("BerryModifier", 4)) // Must have at least 4 berries to spawn - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - // This sprite has the shadow - spriteKey: "", - fileRoot: "", - species: Species.GREEDENT, - hasShadow: true, - alpha: 0.001, - repeat: true, - x: -5 - }, - { - spriteKey: "", - fileRoot: "", - species: Species.GREEDENT, - hasShadow: false, - repeat: true, - x: -5 - }, - { - spriteKey: "lum_berry", - fileRoot: "items", - isItem: true, - x: 7, - y: -14, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "salac_berry", - fileRoot: "items", - isItem: true, - x: 2, - y: 4, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "lansat_berry", - fileRoot: "items", - isItem: true, - x: 32, - y: 5, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "liechi_berry", - fileRoot: "items", - isItem: true, - x: 6, - y: -5, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "sitrus_berry", - fileRoot: "items", - isItem: true, - x: 7, - y: 8, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "enigma_berry", - fileRoot: "items", - isItem: true, - x: 26, - y: -4, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "leppa_berry", - fileRoot: "items", - isItem: true, - x: 16, - y: -27, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "petaya_berry", - fileRoot: "items", - isItem: true, - x: 30, - y: -17, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "ganlon_berry", - fileRoot: "items", - isItem: true, - x: 16, - y: -11, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "apicot_berry", - fileRoot: "items", - isItem: true, - x: 14, - y: -2, - hidden: true, - disableAnimation: true - }, - { - spriteKey: "starf_berry", - fileRoot: "items", - isItem: true, - x: 18, - y: 9, - hidden: true, - disableAnimation: true - }, - ]) - .withHideWildIntroMessage(true) - .withAutoHideIntroVisuals(false) - .withIntroDialogue([ - { - text: `${namespace}:intro`, +export const AbsoluteAvariceEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.ABSOLUTE_AVARICE, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new PersistentModifierRequirement("BerryModifier", 4)) // Must have at least 4 berries to spawn + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + // This sprite has the shadow + spriteKey: "", + fileRoot: "", + species: Species.GREEDENT, + hasShadow: true, + alpha: 0.001, + repeat: true, + x: -5, + }, + { + spriteKey: "", + fileRoot: "", + species: Species.GREEDENT, + hasShadow: false, + repeat: true, + x: -5, + }, + { + spriteKey: "lum_berry", + fileRoot: "items", + isItem: true, + x: 7, + y: -14, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "salac_berry", + fileRoot: "items", + isItem: true, + x: 2, + y: 4, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "lansat_berry", + fileRoot: "items", + isItem: true, + x: 32, + y: 5, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "liechi_berry", + fileRoot: "items", + isItem: true, + x: 6, + y: -5, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "sitrus_berry", + fileRoot: "items", + isItem: true, + x: 7, + y: 8, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "enigma_berry", + fileRoot: "items", + isItem: true, + x: 26, + y: -4, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "leppa_berry", + fileRoot: "items", + isItem: true, + x: 16, + y: -27, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "petaya_berry", + fileRoot: "items", + isItem: true, + x: 30, + y: -17, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "ganlon_berry", + fileRoot: "items", + isItem: true, + x: 16, + y: -11, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "apicot_berry", + fileRoot: "items", + isItem: true, + x: 14, + y: -2, + hidden: true, + disableAnimation: true, + }, + { + spriteKey: "starf_berry", + fileRoot: "items", + isItem: true, + x: 18, + y: 9, + hidden: true, + disableAnimation: true, + }, + ]) + .withHideWildIntroMessage(true) + .withAutoHideIntroVisuals(false) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + + globalScene.loadSe("PRSFX- Bug Bite", "battle_anims", "PRSFX- Bug Bite.wav"); + globalScene.loadSe("Follow Me", "battle_anims", "Follow Me.mp3"); + + // Get all player berry items, remove from party, and store reference + const berryItems = globalScene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; + + // Sort berries by party member ID to more easily re-add later if necessary + const berryItemsMap = new Map(); + globalScene.getPlayerParty().forEach(pokemon => { + const pokemonBerries = berryItems.filter(b => b.pokemonId === pokemon.id); + if (pokemonBerries?.length > 0) { + berryItemsMap.set(pokemon.id, pokemonBerries); } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; + }); - globalScene.loadSe("PRSFX- Bug Bite", "battle_anims", "PRSFX- Bug Bite.wav"); - globalScene.loadSe("Follow Me", "battle_anims", "Follow Me.mp3"); + encounter.misc = { berryItemsMap }; - // Get all player berry items, remove from party, and store reference - const berryItems = globalScene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; + // Generates copies of the stolen berries to put on the Greedent + const bossModifierConfigs: HeldModifierConfig[] = []; + berryItems.forEach(berryMod => { + // Can't define stack count on a ModifierType, have to just create separate instances for each stack + // Overflow berries will be "lost" on the boss, but it's un-catchable anyway + for (let i = 0; i < berryMod.stackCount; i++) { + const modifierType = generateModifierType(modifierTypes.BERRY, [ + berryMod.berryType, + ]) as PokemonHeldItemModifierType; + bossModifierConfigs.push({ modifier: modifierType }); + } + }); - // Sort berries by party member ID to more easily re-add later if necessary - const berryItemsMap = new Map(); - globalScene.getPlayerParty().forEach(pokemon => { - const pokemonBerries = berryItems.filter(b => b.pokemonId === pokemon.id); - if (pokemonBerries?.length > 0) { - berryItemsMap.set(pokemon.id, pokemonBerries); - } - }); + // Do NOT remove the real berries yet or else it will be persisted in the session data - encounter.misc = { berryItemsMap }; + // SpDef buff below wave 50, +1 to all stats otherwise + const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = + globalScene.currentBattle.waveIndex < 50 ? [Stat.SPDEF] : [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; - // Generates copies of the stolen berries to put on the Greedent - const bossModifierConfigs: HeldModifierConfig[] = []; - berryItems.forEach(berryMod => { - // Can't define stack count on a ModifierType, have to just create separate instances for each stack - // Overflow berries will be "lost" on the boss, but it's un-catchable anyway - for (let i = 0; i < berryMod.stackCount; i++) { - const modifierType = generateModifierType(modifierTypes.BERRY, [ berryMod.berryType ]) as PokemonHeldItemModifierType; - bossModifierConfigs.push({ modifier: modifierType }); - } - }); + // Calculate boss mon + const config: EnemyPartyConfig = { + levelAdditiveModifier: 1, + pokemonConfigs: [ + { + species: getPokemonSpecies(Species.GREEDENT), + isBoss: true, + bossSegments: 3, + shiny: false, // Shiny lock because of consistency issues between the different options + moveSet: [Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH], + modifierConfigs: bossModifierConfigs, + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: (pokemon: Pokemon) => { + queueEncounterMessage(`${namespace}:option.1.boss_enraged`); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1), + ); + }, + }, + ], + }; - // Do NOT remove the real berries yet or else it will be persisted in the session data + encounter.enemyPartyConfigs = [config]; + encounter.setDialogueToken("greedentName", getPokemonSpecies(Species.GREEDENT).getName()); - // SpDef buff below wave 50, +1 to all stats otherwise - const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = globalScene.currentBattle.waveIndex < 50 ? - [ Stat.SPDEF ] : - [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + return true; + }) + .withOnVisualsStart(() => { + doGreedentSpriteSteal(); + doBerrySpritePile(); - // Calculate boss mon - const config: EnemyPartyConfig = { - levelAdditiveModifier: 1, - pokemonConfigs: [ + // Remove the berries from the party + // Session has been safely saved at this point, so data won't be lost + const berryItems = globalScene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; + berryItems.forEach(berryMod => { + globalScene.removeModifier(berryMod); + }); + + globalScene.updateModifiers(true); + + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ { - species: getPokemonSpecies(Species.GREEDENT), - isBoss: true, - bossSegments: 3, - shiny: false, // Shiny lock because of consistency issues between the different options - moveSet: [ Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH ], - modifierConfigs: bossModifierConfigs, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: (pokemon: Pokemon) => { - queueEncounterMessage(`${namespace}:option.1.boss_enraged`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1)); + text: `${namespace}:option.1.selected`, + }, + ], + }) + .withOptionPhase(async () => { + // Pick battle + const encounter = globalScene.currentBattle.mysteryEncounter!; + + // Provides 1x Reviver Seed to each party member at end of battle + const revSeed = generateModifierType(modifierTypes.REVIVER_SEED); + encounter.setDialogueToken( + "foodReward", + revSeed?.name ?? i18next.t("modifierType:ModifierType.REVIVER_SEED.name"), + ); + const givePartyPokemonReviverSeeds = () => { + const party = globalScene.getPlayerParty(); + party.forEach(p => { + const heldItems = p.getHeldItems(); + if (revSeed && !heldItems.some(item => item instanceof PokemonInstantReviveModifier)) { + const seedModifier = revSeed.newModifier(p); + globalScene.addModifier(seedModifier, false, false, false, true); + } + }); + queueEncounterMessage(`${namespace}:option.1.food_stash`); + }; + + setEncounterRewards({ fillRemaining: true }, undefined, givePartyPokemonReviverSeeds); + encounter.startOfBattleEffects.push({ + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.ENEMY], + move: new PokemonMove(Moves.STUFF_CHEEKS), + ignorePp: true, + }); + + await transitionMysteryEncounterIntroVisuals(true, true, 500); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const berryMap = encounter.misc.berryItemsMap; + + // Returns 2/5 of the berries stolen to each Pokemon + const party = globalScene.getPlayerParty(); + party.forEach(pokemon => { + const stolenBerries: BerryModifier[] = berryMap.get(pokemon.id); + const berryTypesAsArray: BerryType[] = []; + stolenBerries?.forEach(bMod => berryTypesAsArray.push(...new Array(bMod.stackCount).fill(bMod.berryType))); + const returnedBerryCount = Math.floor(((berryTypesAsArray.length ?? 0) * 2) / 5); + + if (returnedBerryCount > 0) { + for (let i = 0; i < returnedBerryCount; i++) { + // Shuffle remaining berry types and pop + Phaser.Math.RND.shuffle(berryTypesAsArray); + const randBerryType = berryTypesAsArray.pop(); + + const berryModType = generateModifierType(modifierTypes.BERRY, [randBerryType]) as BerryModifierType; + applyModifierTypeToPlayerPokemon(pokemon, berryModType); } } + }); + await globalScene.updateModifiers(true); + + await transitionMysteryEncounterIntroVisuals(true, true, 500); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, ], - }; + }) + .withPreOptionPhase(async () => { + // Animate berries being eaten + doGreedentEatBerries(); + doBerrySpritePile(true); + return true; + }) + .withOptionPhase(async () => { + // Let it have the food + // Greedent joins the team, level equal to 2 below highest party member (shiny locked) + const level = getHighestLevelPlayerPokemon(false, true).level - 2; + const greedent = new EnemyPokemon(getPokemonSpecies(Species.GREEDENT), level, TrainerSlot.NONE, false, true); + greedent.moveset = [ + new PokemonMove(Moves.THRASH), + new PokemonMove(Moves.BODY_PRESS), + new PokemonMove(Moves.STUFF_CHEEKS), + new PokemonMove(Moves.SLACK_OFF), + ]; + greedent.passive = true; - encounter.enemyPartyConfigs = [ config ]; - encounter.setDialogueToken("greedentName", getPokemonSpecies(Species.GREEDENT).getName()); - - return true; - }) - .withOnVisualsStart(() => { - doGreedentSpriteSteal(); - doBerrySpritePile(); - - // Remove the berries from the party - // Session has been safely saved at this point, so data won't be lost - const berryItems = globalScene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; - berryItems.forEach(berryMod => { - globalScene.removeModifier(berryMod); - }); - - globalScene.updateModifiers(true); - - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], - }) - .withOptionPhase(async () => { - // Pick battle - const encounter = globalScene.currentBattle.mysteryEncounter!; - - // Provides 1x Reviver Seed to each party member at end of battle - const revSeed = generateModifierType(modifierTypes.REVIVER_SEED); - encounter.setDialogueToken("foodReward", revSeed?.name ?? i18next.t("modifierType:ModifierType.REVIVER_SEED.name")); - const givePartyPokemonReviverSeeds = () => { - const party = globalScene.getPlayerParty(); - party.forEach(p => { - const heldItems = p.getHeldItems(); - if (revSeed && !heldItems.some(item => item instanceof PokemonInstantReviveModifier)) { - const seedModifier = revSeed.newModifier(p); - globalScene.addModifier(seedModifier, false, false, false, true); - } - }); - queueEncounterMessage(`${namespace}:option.1.food_stash`); - }; - - setEncounterRewards({ fillRemaining: true }, undefined, givePartyPokemonReviverSeeds); - encounter.startOfBattleEffects.push({ - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.ENEMY ], - move: new PokemonMove(Moves.STUFF_CHEEKS), - ignorePp: true - }); - - await transitionMysteryEncounterIntroVisuals(true, true, 500); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const berryMap = encounter.misc.berryItemsMap; - - // Returns 2/5 of the berries stolen to each Pokemon - const party = globalScene.getPlayerParty(); - party.forEach(pokemon => { - const stolenBerries: BerryModifier[] = berryMap.get(pokemon.id); - const berryTypesAsArray: BerryType[] = []; - stolenBerries?.forEach(bMod => berryTypesAsArray.push(...new Array(bMod.stackCount).fill(bMod.berryType))); - const returnedBerryCount = Math.floor((berryTypesAsArray.length ?? 0) * 2 / 5); - - if (returnedBerryCount > 0) { - for (let i = 0; i < returnedBerryCount; i++) { - // Shuffle remaining berry types and pop - Phaser.Math.RND.shuffle(berryTypesAsArray); - const randBerryType = berryTypesAsArray.pop(); - - const berryModType = generateModifierType(modifierTypes.BERRY, [ randBerryType ]) as BerryModifierType; - applyModifierTypeToPlayerPokemon(pokemon, berryModType); - } - } - }); - await globalScene.updateModifiers(true); - - await transitionMysteryEncounterIntroVisuals(true, true, 500); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Animate berries being eaten - doGreedentEatBerries(); - doBerrySpritePile(true); - return true; - }) - .withOptionPhase(async () => { - // Let it have the food - // Greedent joins the team, level equal to 2 below highest party member (shiny locked) - const level = getHighestLevelPlayerPokemon(false, true).level - 2; - const greedent = new EnemyPokemon(getPokemonSpecies(Species.GREEDENT), level, TrainerSlot.NONE, false, true); - greedent.moveset = [ new PokemonMove(Moves.THRASH), new PokemonMove(Moves.BODY_PRESS), new PokemonMove(Moves.STUFF_CHEEKS), new PokemonMove(Moves.SLACK_OFF) ]; - greedent.passive = true; - - await transitionMysteryEncounterIntroVisuals(true, true, 500); - await catchPokemon(greedent, null, PokeballType.POKEBALL, false); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .build(); + await transitionMysteryEncounterIntroVisuals(true, true, 500); + await catchPokemon(greedent, null, PokeballType.POKEBALL, false); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .build(); function doGreedentSpriteSteal() { const shakeDelay = 50; @@ -382,70 +401,79 @@ function doGreedentSpriteSteal() { globalScene.tweens.chain({ targets: greedentSprites, tweens: [ - { // Slide Greedent diagonally + { + // Slide Greedent diagonally duration: slideDelay, ease: "Cubic.easeOut", y: "+=75", x: "-=65", - scale: 1.1 + scale: 1.1, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Shake + { + // Shake duration: shakeDelay, ease: "Cubic.easeOut", yoyo: true, x: (randInt(2) > 0 ? "-=" : "+=") + 5, y: (randInt(2) > 0 ? "-=" : "+=") + 5, }, - { // Slide Greedent diagonally + { + // Slide Greedent diagonally duration: slideDelay, ease: "Cubic.easeOut", y: "-=75", x: "+=65", - scale: 1 + scale: 1, }, - { // Bounce at the end + { + // Bounce at the end duration: 300, ease: "Cubic.easeOut", yoyo: true, y: "-=20", loop: 1, - } - ] + }, + ], }); } @@ -467,16 +495,28 @@ function doGreedentEatBerries() { globalScene.playSound("battle_anims/PRSFX- Bug Bite"); } index++; - } + }, }); } /** * @param isEat Default false. Will "create" pile when false, and remove pile when true. */ -function doBerrySpritePile(isEat: boolean = false) { +function doBerrySpritePile(isEat = false) { const berryAddDelay = 150; - let animationOrder = [ "starf", "sitrus", "lansat", "salac", "apicot", "enigma", "liechi", "ganlon", "lum", "petaya", "leppa" ]; + let animationOrder = [ + "starf", + "sitrus", + "lansat", + "salac", + "apicot", + "enigma", + "liechi", + "ganlon", + "lum", + "petaya", + "leppa", + ]; if (isEat) { animationOrder = animationOrder.reverse(); } @@ -500,7 +540,7 @@ function doBerrySpritePile(isEat: boolean = false) { // Animate Petaya berry falling off the pile if (berry === "petaya" && sprite && tintSprite && !isEat) { globalScene.time.delayedCall(200, () => { - doBerryBounce([ sprite, tintSprite ], 30, 500); + doBerryBounce([sprite, tintSprite], 30, 500); }); } }); @@ -515,7 +555,7 @@ function doBerryBounce(berrySprites: Phaser.GameObjects.Sprite[], yd: number, ba globalScene.tweens.add({ targets: berrySprites, y: "+=" + bounceYOffset, - x: { value: "+=" + (bouncePower * bouncePower * 10), ease: "Linear" }, + x: { value: "+=" + bouncePower * bouncePower * 10, ease: "Linear" }, duration: bouncePower * baseBounceDuration, ease: "Cubic.easeIn", onComplete: () => { @@ -527,13 +567,13 @@ function doBerryBounce(berrySprites: Phaser.GameObjects.Sprite[], yd: number, ba globalScene.tweens.add({ targets: berrySprites, y: "-=" + bounceYOffset, - x: { value: "+=" + (bouncePower * bouncePower * 10), ease: "Linear" }, + x: { value: "+=" + bouncePower * bouncePower * 10, ease: "Linear" }, duration: bouncePower * baseBounceDuration, ease: "Cubic.easeOut", - onComplete: () => doBounce() + onComplete: () => doBounce(), }); } - } + }, }); }; diff --git a/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts b/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts index 671eb3d3ab8..b66052cfd16 100644 --- a/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts +++ b/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts @@ -1,4 +1,9 @@ -import { generateModifierType, leaveEncounterWithoutBattle, setEncounterExp, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + leaveEncounterWithoutBattle, + setEncounterExp, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; @@ -6,7 +11,11 @@ import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import { AbilityRequirement, CombinationPokemonRequirement, MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; +import { + AbilityRequirement, + CombinationPokemonRequirement, + MoveRequirement, +} from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { getHighestStatTotalPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { EXTORTION_ABILITIES, EXTORTION_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import { getPokemonSpecies } from "#app/data/pokemon-species"; @@ -33,153 +42,152 @@ const MONEY_MAXIMUM_MULTIPLIER = 30; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3808 | GitHub Issue #3808} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const AnOfferYouCantRefuseEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 pokemon in party - .withIntroSpriteConfigs([ - { - spriteKey: Species.LIEPARD.toString(), - fileRoot: "pokemon", - hasShadow: true, - repeat: true, - x: 0, - y: -4, - yShadow: -4 - }, - { - spriteKey: "rich_kid_m", - fileRoot: "trainer", - hasShadow: true, - x: 2, - y: 5, - yShadow: 5 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const pokemon = getHighestStatTotalPlayerPokemon(true, true); +export const AnOfferYouCantRefuseEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 pokemon in party + .withIntroSpriteConfigs([ + { + spriteKey: Species.LIEPARD.toString(), + fileRoot: "pokemon", + hasShadow: true, + repeat: true, + x: 0, + y: -4, + yShadow: -4, + }, + { + spriteKey: "rich_kid_m", + fileRoot: "trainer", + hasShadow: true, + x: 2, + y: 5, + yShadow: 5, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const pokemon = getHighestStatTotalPlayerPokemon(true, true); - const baseSpecies = pokemon.getSpeciesForm().getRootSpeciesId(); - const starterValue: number = speciesStarterCosts[baseSpecies] ?? 1; - const multiplier = Math.max(MONEY_MAXIMUM_MULTIPLIER / 10 * starterValue, MONEY_MINIMUM_MULTIPLIER); - const price = globalScene.getWaveMoneyAmount(multiplier); + const baseSpecies = pokemon.getSpeciesForm().getRootSpeciesId(); + const starterValue: number = speciesStarterCosts[baseSpecies] ?? 1; + const multiplier = Math.max((MONEY_MAXIMUM_MULTIPLIER / 10) * starterValue, MONEY_MINIMUM_MULTIPLIER); + const price = globalScene.getWaveMoneyAmount(multiplier); - encounter.setDialogueToken("strongestPokemon", pokemon.getNameToRender()); - encounter.setDialogueToken("price", price.toString()); + encounter.setDialogueToken("strongestPokemon", pokemon.getNameToRender()); + encounter.setDialogueToken("price", price.toString()); - // Store pokemon and price - encounter.misc = { - pokemon: pokemon, - price: price - }; + // Store pokemon and price + encounter.misc = { + pokemon: pokemon, + price: price, + }; - // If player meets the combo OR requirements for option 2, populate the token - const opt2Req = encounter.options[1].primaryPokemonRequirements[0]; - if (opt2Req.meetsRequirement()) { - const abilityToken = encounter.dialogueTokens["option2PrimaryAbility"]; - const moveToken = encounter.dialogueTokens["option2PrimaryMove"]; - if (abilityToken) { - encounter.setDialogueToken("moveOrAbility", abilityToken); - } else if (moveToken) { - encounter.setDialogueToken("moveOrAbility", moveToken); - } + // If player meets the combo OR requirements for option 2, populate the token + const opt2Req = encounter.options[1].primaryPokemonRequirements[0]; + if (opt2Req.meetsRequirement()) { + const abilityToken = encounter.dialogueTokens["option2PrimaryAbility"]; + const moveToken = encounter.dialogueTokens["option2PrimaryMove"]; + if (abilityToken) { + encounter.setDialogueToken("moveOrAbility", abilityToken); + } else if (moveToken) { + encounter.setDialogueToken("moveOrAbility", moveToken); } + } - const shinyCharm = generateModifierType(modifierTypes.SHINY_CHARM); - encounter.setDialogueToken("itemName", shinyCharm?.name ?? i18next.t("modifierType:ModifierType.SHINY_CHARM.name")); - encounter.setDialogueToken("liepardName", getPokemonSpecies(Species.LIEPARD).getName()); + const shinyCharm = generateModifierType(modifierTypes.SHINY_CHARM); + encounter.setDialogueToken("itemName", shinyCharm?.name ?? i18next.t("modifierType:ModifierType.SHINY_CHARM.name")); + encounter.setDialogueToken("liepardName", getPokemonSpecies(Species.LIEPARD).getName()); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - speaker: `${namespace}:speaker`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Update money and remove pokemon from party - updatePlayerMoney(encounter.misc.price); - globalScene.removePokemonFromPlayerParty(encounter.misc.pokemon); - return true; - }) - .withOptionPhase(async () => { - // Give the player a Shiny Charm - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.SHINY_CHARM)); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement( - CombinationPokemonRequirement.Some( - new MoveRequirement(EXTORTION_MOVES, true), - new AbilityRequirement(EXTORTION_ABILITIES, true) - ) - ) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.tooltip_disabled`, - selected: [ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:option.2.selected`, - }, - ], - }) - .withOptionPhase(async () => { - // Extort the rich kid for money - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Update money and remove pokemon from party - updatePlayerMoney(encounter.misc.price); - - setEncounterExp(encounter.options[1].primaryPokemon!.id, getPokemonSpecies(Species.LIEPARD).baseExp, true); - - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + speaker: `${namespace}:speaker`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Update money and remove pokemon from party + updatePlayerMoney(encounter.misc.price); + globalScene.removePokemonFromPlayerParty(encounter.misc.pokemon); + return true; + }) + .withOptionPhase(async () => { + // Give the player a Shiny Charm + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.SHINY_CHARM)); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement( + CombinationPokemonRequirement.Some( + new MoveRequirement(EXTORTION_MOVES, true), + new AbilityRequirement(EXTORTION_ABILITIES, true), + ), + ) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + disabledButtonTooltip: `${namespace}:option.2.tooltip_disabled`, selected: [ { speaker: `${namespace}:speaker`, - text: `${namespace}:option.3.selected`, + text: `${namespace}:option.2.selected`, }, ], - }, - async () => { - // Leave encounter with no rewards or exp + }) + .withOptionPhase(async () => { + // Extort the rich kid for money + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Update money and remove pokemon from party + updatePlayerMoney(encounter.misc.price); + + setEncounterExp(encounter.options[1].primaryPokemon!.id, getPokemonSpecies(Species.LIEPARD).baseExp, true); + leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:option.3.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts index 550d9bd4f13..94e27e32773 100644 --- a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts +++ b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts @@ -1,6 +1,5 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import type { - EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { generateModifierType, generateModifierTypeOption, @@ -8,18 +7,12 @@ import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterExp, - setEncounterRewards + setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; 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 type { BerryModifierType, ModifierTypeOption } from "#app/modifier/modifier-type"; +import { ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; import { randSeedInt } from "#app/utils"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -30,7 +23,13 @@ import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-enco import { getPokemonNameWithAffix } from "#app/messages"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { applyModifierTypeToPlayerPokemon, getEncounterPokemonLevelForWave, getHighestStatPlayerPokemon, getSpriteKeysFromPokemon, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + applyModifierTypeToPlayerPokemon, + getEncounterPokemonLevelForWave, + getHighestStatPlayerPokemon, + getSpriteKeysFromPokemon, + STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import PokemonData from "#app/system/pokemon-data"; import { BerryModifier } from "#app/modifier/modifier"; import i18next from "#app/plugins/i18n"; @@ -47,107 +46,150 @@ const namespace = "mysteryEncounters/berriesAbound"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3810 | GitHub Issue #3810} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const BerriesAboundEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.BERRIES_ABOUND) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withCatchAllowed(true) - .withHideWildIntroMessage(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([]) // Set in onInit() - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const BerriesAboundEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.BERRIES_ABOUND, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withCatchAllowed(true) + .withHideWildIntroMessage(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([]) // Set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculate boss mon - const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); - const bossPokemon = getRandomEncounterSpecies(level, true); - encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); - const config: EnemyPartyConfig = { - pokemonConfigs: [{ + // Calculate boss mon + const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); + const bossPokemon = getRandomEncounterSpecies(level, true); + encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { level: level, species: bossPokemon.species, dataSource: new PokemonData(bossPokemon), - isBoss: true - }], - }; - encounter.enemyPartyConfigs = [ config ]; - - // Calculate the number of extra berries that player receives - // 10-40: 2, 40-120: 4, 120-160: 5, 160-180: 7 - const numBerries = - globalScene.currentBattle.waveIndex > 160 ? 7 - : globalScene.currentBattle.waveIndex > 120 ? 5 - : globalScene.currentBattle.waveIndex > 40 ? 4 : 2; - regenerateModifierPoolThresholds(globalScene.getPlayerParty(), ModifierPoolType.PLAYER, 0); - encounter.misc = { numBerries }; - - const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon); - encounter.spriteConfigs = [ - { - spriteKey: "berries_abound_bush", - fileRoot: "mystery-encounters", - x: 25, - y: -6, - yShadow: -7, - disableAnimation: true, - hasShadow: true + isBoss: true, }, - { - spriteKey: spriteKey, - fileRoot: fileRoot, - hasShadow: true, - tint: 0.25, - x: -5, - repeat: true, - isPokemon: true, - isShiny: bossPokemon.shiny, - variant: bossPokemon.variant - } - ]; + ], + }; + encounter.enemyPartyConfigs = [config]; - // Get fastest party pokemon for option 2 - const fastestPokemon = getHighestStatPlayerPokemon(PERMANENT_STATS[Stat.SPD], true, false); - encounter.misc.fastestPokemon = fastestPokemon; - encounter.misc.enemySpeed = bossPokemon.getStat(Stat.SPD); - encounter.setDialogueToken("fastestPokemon", fastestPokemon.getNameToRender()); + // Calculate the number of extra berries that player receives + // 10-40: 2, 40-120: 4, 120-160: 5, 160-180: 7 + const numBerries = + globalScene.currentBattle.waveIndex > 160 + ? 7 + : globalScene.currentBattle.waveIndex > 120 + ? 5 + : globalScene.currentBattle.waveIndex > 40 + ? 4 + : 2; + regenerateModifierPoolThresholds(globalScene.getPlayerParty(), ModifierPoolType.PLAYER, 0); + encounter.misc = { numBerries }; - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( + const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon); + encounter.spriteConfigs = [ { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], + spriteKey: "berries_abound_bush", + fileRoot: "mystery-encounters", + x: 25, + y: -6, + yShadow: -7, + disableAnimation: true, + hasShadow: true, }, - async () => { - // Pick battle + { + spriteKey: spriteKey, + fileRoot: fileRoot, + hasShadow: true, + tint: 0.25, + x: -5, + repeat: true, + isPokemon: true, + isShiny: bossPokemon.shiny, + variant: bossPokemon.variant, + }, + ]; + + // Get fastest party pokemon for option 2 + const fastestPokemon = getHighestStatPlayerPokemon(PERMANENT_STATS[Stat.SPD], true, false); + encounter.misc.fastestPokemon = fastestPokemon; + encounter.misc.enemySpeed = bossPokemon.getStat(Stat.SPD); + encounter.setDialogueToken("fastestPokemon", fastestPokemon.getNameToRender()); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Pick battle + const encounter = globalScene.currentBattle.mysteryEncounter!; + const numBerries = encounter.misc.numBerries; + + const doBerryRewards = () => { + const berryText = i18next.t(`${namespace}:berries`); + + globalScene.playSound("item_fanfare"); + queueEncounterMessage( + i18next.t("battle:rewardGainCount", { + modifierName: berryText, + count: numBerries, + }), + ); + + // Generate a random berry and give it to the first Pokemon with room for it + for (let i = 0; i < numBerries; i++) { + tryGiveBerry(); + } + }; + + const shopOptions: ModifierTypeOption[] = []; + for (let i = 0; i < 5; i++) { + // Generate shop berries + const mod = generateModifierTypeOption(modifierTypes.BERRY); + if (mod) { + shopOptions.push(mod); + } + } + + setEncounterRewards( + { guaranteedModifierTypeOptions: shopOptions, fillRemaining: false }, + undefined, + doBerryRewards, + ); + await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + }) + .withOptionPhase(async () => { + // Pick race for berries const encounter = globalScene.currentBattle.mysteryEncounter!; - const numBerries = encounter.misc.numBerries; - - const doBerryRewards = () => { - const berryText = i18next.t(`${namespace}:berries`); - - globalScene.playSound("item_fanfare"); - queueEncounterMessage(i18next.t("battle:rewardGainCount", { modifierName: berryText, count: numBerries })); - - // Generate a random berry and give it to the first Pokemon with room for it - for (let i = 0; i < numBerries; i++) { - tryGiveBerry(); - } - }; + const fastestPokemon: PlayerPokemon = encounter.misc.fastestPokemon; + const enemySpeed: number = encounter.misc.enemySpeed; + const speedDiff = fastestPokemon.getStat(Stat.SPD) / (enemySpeed * 1.1); + const numBerries: number = encounter.misc.numBerries; const shopOptions: ModifierTypeOption[] = []; for (let i = 0; i < 5; i++) { @@ -158,115 +200,126 @@ export const BerriesAboundEncounter: MysteryEncounter = } } - setEncounterRewards({ guaranteedModifierTypeOptions: shopOptions, fillRemaining: false }, undefined, doBerryRewards); - await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); - } - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip` - }) - .withOptionPhase(async () => { - // Pick race for berries - const encounter = globalScene.currentBattle.mysteryEncounter!; - const fastestPokemon: PlayerPokemon = encounter.misc.fastestPokemon; - const enemySpeed: number = encounter.misc.enemySpeed; - const speedDiff = fastestPokemon.getStat(Stat.SPD) / (enemySpeed * 1.1); - const numBerries: number = encounter.misc.numBerries; + if (speedDiff < 1) { + // Caught and attacked by boss, gets +1 to all stats at start of fight + const doBerryRewards = () => { + const berryText = i18next.t(`${namespace}:berries`); - const shopOptions: ModifierTypeOption[] = []; - for (let i = 0; i < 5; i++) { - // Generate shop berries - const mod = generateModifierTypeOption(modifierTypes.BERRY); - if (mod) { - shopOptions.push(mod); + globalScene.playSound("item_fanfare"); + queueEncounterMessage( + i18next.t("battle:rewardGainCount", { + modifierName: berryText, + count: numBerries, + }), + ); + + // Generate a random berry and give it to the first Pokemon with room for it + for (let i = 0; i < numBerries; i++) { + tryGiveBerry(); } + }; + + // Defense/Spd buffs below wave 50, +1 to all stats otherwise + const statChangesForBattle: ( + | Stat.ATK + | Stat.DEF + | Stat.SPATK + | Stat.SPDEF + | Stat.SPD + | Stat.ACC + | Stat.EVA + )[] = + globalScene.currentBattle.waveIndex < 50 + ? [Stat.DEF, Stat.SPDEF, Stat.SPD] + : [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; + + const config = globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]; + config.pokemonConfigs![0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON]; + config.pokemonConfigs![0].mysteryEncounterBattleEffects = (pokemon: Pokemon) => { + queueEncounterMessage(`${namespace}:option.2.boss_enraged`); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1), + ); + }; + setEncounterRewards( + { + guaranteedModifierTypeOptions: shopOptions, + fillRemaining: false, + }, + undefined, + doBerryRewards, + ); + await showEncounterText(`${namespace}:option.2.selected_bad`); + await initBattleWithEnemyConfig(config); + return; + } + // Gains 1 berry for every 10% faster the player's pokemon is than the enemy, up to a max of numBerries, minimum of 2 + const numBerriesGrabbed = Math.max(Math.min(Math.round((speedDiff - 1) / 0.08), numBerries), 2); + encounter.setDialogueToken("numBerries", String(numBerriesGrabbed)); + const doFasterBerryRewards = () => { + const berryText = i18next.t(`${namespace}:berries`); + + globalScene.playSound("item_fanfare"); + queueEncounterMessage( + i18next.t("battle:rewardGainCount", { + modifierName: berryText, + count: numBerriesGrabbed, + }), + ); + + // Generate a random berry and give it to the first Pokemon with room for it (trying to give to fastest first) + for (let i = 0; i < numBerriesGrabbed; i++) { + tryGiveBerry(fastestPokemon); } + }; - if (speedDiff < 1) { - // Caught and attacked by boss, gets +1 to all stats at start of fight - const doBerryRewards = () => { - const berryText = i18next.t(`${namespace}:berries`); - - globalScene.playSound("item_fanfare"); - queueEncounterMessage(i18next.t("battle:rewardGainCount", { modifierName: berryText, count: numBerries })); - - // Generate a random berry and give it to the first Pokemon with room for it - for (let i = 0; i < numBerries; i++) { - tryGiveBerry(); - } - }; - - // Defense/Spd buffs below wave 50, +1 to all stats otherwise - const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = globalScene.currentBattle.waveIndex < 50 ? - [ Stat.DEF, Stat.SPDEF, Stat.SPD ] : - [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; - - const config = globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]; - config.pokemonConfigs![0].tags = [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ]; - config.pokemonConfigs![0].mysteryEncounterBattleEffects = (pokemon: Pokemon) => { - queueEncounterMessage(`${namespace}:option.2.boss_enraged`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1)); - }; - setEncounterRewards({ guaranteedModifierTypeOptions: shopOptions, fillRemaining: false }, undefined, doBerryRewards); - await showEncounterText(`${namespace}:option.2.selected_bad`); - await initBattleWithEnemyConfig(config); - return; - } else { - // Gains 1 berry for every 10% faster the player's pokemon is than the enemy, up to a max of numBerries, minimum of 2 - const numBerriesGrabbed = Math.max(Math.min(Math.round((speedDiff - 1) / 0.08), numBerries), 2); - encounter.setDialogueToken("numBerries", String(numBerriesGrabbed)); - const doFasterBerryRewards = () => { - const berryText = i18next.t(`${namespace}:berries`); - - globalScene.playSound("item_fanfare"); - queueEncounterMessage(i18next.t("battle:rewardGainCount", { modifierName: berryText, count: numBerriesGrabbed })); - - // Generate a random berry and give it to the first Pokemon with room for it (trying to give to fastest first) - for (let i = 0; i < numBerriesGrabbed; i++) { - tryGiveBerry(fastestPokemon); - } - }; - - setEncounterExp(fastestPokemon.id, encounter.enemyPartyConfigs[0].pokemonConfigs![0].species.baseExp); - setEncounterRewards({ guaranteedModifierTypeOptions: shopOptions, fillRemaining: false }, undefined, doFasterBerryRewards); - await showEncounterText(`${namespace}:option.2.selected`); - leaveEncounterWithoutBattle(); - } - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ + setEncounterExp(fastestPokemon.id, encounter.enemyPartyConfigs[0].pokemonConfigs![0].species.baseExp); + setEncounterRewards( { - text: `${namespace}:option.3.selected`, + guaranteedModifierTypeOptions: shopOptions, + fillRemaining: false, }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + undefined, + doFasterBerryRewards, + ); + await showEncounterText(`${namespace}:option.2.selected`); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); function tryGiveBerry(prioritizedPokemon?: PlayerPokemon) { - const berryType = randSeedInt(Object.keys(BerryType).filter(s => !isNaN(Number(s))).length) as BerryType; - const berry = generateModifierType(modifierTypes.BERRY, [ berryType ]) as BerryModifierType; + const berryType = randSeedInt(Object.keys(BerryType).filter(s => !Number.isNaN(Number(s))).length) as BerryType; + const berry = generateModifierType(modifierTypes.BERRY, [berryType]) as BerryModifierType; const party = globalScene.getPlayerParty(); // Will try to apply to prioritized pokemon first, then do normal application method if it fails if (prioritizedPokemon) { - const heldBerriesOfType = globalScene.findModifier(m => m instanceof BerryModifier - && m.pokemonId === prioritizedPokemon.id && (m as BerryModifier).berryType === berryType, true) as BerryModifier; + const heldBerriesOfType = globalScene.findModifier( + m => + m instanceof BerryModifier && + m.pokemonId === prioritizedPokemon.id && + (m as BerryModifier).berryType === berryType, + true, + ) as BerryModifier; if (!heldBerriesOfType || heldBerriesOfType.getStackCount() < heldBerriesOfType.getMaxStackCount()) { applyModifierTypeToPlayerPokemon(prioritizedPokemon, berry); @@ -276,8 +329,10 @@ function tryGiveBerry(prioritizedPokemon?: PlayerPokemon) { // Iterate over the party until berry was successfully given for (const pokemon of party) { - const heldBerriesOfType = globalScene.findModifier(m => m instanceof BerryModifier - && m.pokemonId === pokemon.id && (m as BerryModifier).berryType === berryType, true) as BerryModifier; + const heldBerriesOfType = globalScene.findModifier( + m => m instanceof BerryModifier && m.pokemonId === pokemon.id && (m as BerryModifier).berryType === berryType, + true, + ) as BerryModifier; if (!heldBerriesOfType || heldBerriesOfType.getStackCount() < heldBerriesOfType.getMaxStackCount()) { applyModifierTypeToPlayerPokemon(pokemon, berry); 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 9a95cf305be..15cba1fa103 100644 --- a/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts +++ b/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts @@ -1,5 +1,4 @@ -import type { - EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { generateModifierType, generateModifierTypeOption, @@ -39,20 +38,18 @@ import { AttackTypeBoosterHeldItemTypeRequirement, CombinationPokemonRequirement, HeldItemRequirement, - TypeRequirement + TypeRequirement, } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { PokemonType } from "#enums/pokemon-type"; import type { AttackTypeBoosterModifierType, ModifierTypeOption } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; -import type { - PokemonHeldItemModifier -} from "#app/modifier/modifier"; +import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; import { AttackTypeBoosterModifier, BypassSpeedChanceModifier, ContactHeldItemTransferChanceModifier, GigantamaxAccessModifier, - MegaEvolutionAccessModifier + MegaEvolutionAccessModifier, } from "#app/modifier/modifier"; import i18next from "i18next"; import MoveInfoOverlay from "#app/ui/move-info-overlay"; @@ -87,7 +84,7 @@ const POOL_1_POKEMON = [ Species.CHARJABUG, Species.RIBOMBEE, Species.SPIDOPS, - Species.LOKIX + Species.LOKIX, ]; const POOL_2_POKEMON = [ @@ -116,26 +113,26 @@ const POOL_2_POKEMON = [ Species.KLEAVOR, ]; -const POOL_3_POKEMON: { species: Species, formIndex?: number }[] = [ +const POOL_3_POKEMON: { species: Species; formIndex?: number }[] = [ { species: Species.PINSIR, - formIndex: 1 + formIndex: 1, }, { species: Species.SCIZOR, - formIndex: 1 + formIndex: 1, }, { species: Species.HERACROSS, - formIndex: 1 + formIndex: 1, }, { species: Species.ORBEETLE, - formIndex: 1 + formIndex: 1, }, { species: Species.CENTISKORCH, - formIndex: 1 + formIndex: 1, }, { species: Species.DURANT, @@ -148,35 +145,19 @@ const POOL_3_POKEMON: { species: Species, formIndex?: number }[] = [ }, ]; -const POOL_4_POKEMON = [ - Species.GENESECT, - Species.SLITHER_WING, - Species.BUZZWOLE, - Species.PHEROMOSA -]; +const POOL_4_POKEMON = [Species.GENESECT, Species.SLITHER_WING, Species.BUZZWOLE, Species.PHEROMOSA]; const PHYSICAL_TUTOR_MOVES = [ Moves.MEGAHORN, Moves.X_SCISSOR, Moves.ATTACK_ORDER, Moves.PIN_MISSILE, - Moves.FIRST_IMPRESSION + Moves.FIRST_IMPRESSION, ]; -const SPECIAL_TUTOR_MOVES = [ - Moves.SILVER_WIND, - Moves.BUG_BUZZ, - Moves.SIGNAL_BEAM, - Moves.POLLEN_PUFF -]; +const SPECIAL_TUTOR_MOVES = [Moves.SILVER_WIND, Moves.BUG_BUZZ, Moves.SIGNAL_BEAM, Moves.POLLEN_PUFF]; -const STATUS_TUTOR_MOVES = [ - Moves.STRING_SHOT, - Moves.STICKY_WEB, - Moves.SILK_TRAP, - Moves.RAGE_POWDER, - Moves.HEAL_ORDER -]; +const STATUS_TUTOR_MOVES = [Moves.STRING_SHOT, Moves.STICKY_WEB, Moves.SILK_TRAP, Moves.RAGE_POWDER, Moves.HEAL_ORDER]; const MISC_TUTOR_MOVES = [ Moves.BUG_BITE, @@ -185,154 +166,155 @@ const MISC_TUTOR_MOVES = [ Moves.QUIVER_DANCE, Moves.TAIL_GLOW, Moves.INFESTATION, - Moves.U_TURN + Moves.U_TURN, ]; /** * Wave breakpoints that determine how strong to make the Bug-Type Superfan's team */ -const WAVE_LEVEL_BREAKPOINTS = [ 30, 50, 70, 100, 120, 140, 160 ]; +const WAVE_LEVEL_BREAKPOINTS = [30, 50, 70, 100, 120, 140, 160]; /** * Bug Type Superfan encounter. * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3820 | GitHub Issue #3820} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const BugTypeSuperfanEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.BUG_TYPE_SUPERFAN) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withPrimaryPokemonRequirement( - CombinationPokemonRequirement.Some( - // Must have at least 1 Bug type on team, OR have a bug item somewhere on the team - new HeldItemRequirement([ "BypassSpeedChanceModifier", "ContactHeldItemTransferChanceModifier" ], 1), - new AttackTypeBoosterHeldItemTypeRequirement(PokemonType.BUG, 1), - new TypeRequirement(PokemonType.BUG, false, 1) - ) - ) - .withMaxAllowedEncounters(1) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withIntroSpriteConfigs([]) // These are set in onInit() - .withAutoHideIntroVisuals(false) - .withIntroDialogue([ +export const BugTypeSuperfanEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.BUG_TYPE_SUPERFAN, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withPrimaryPokemonRequirement( + CombinationPokemonRequirement.Some( + // Must have at least 1 Bug type on team, OR have a bug item somewhere on the team + new HeldItemRequirement(["BypassSpeedChanceModifier", "ContactHeldItemTransferChanceModifier"], 1), + new AttackTypeBoosterHeldItemTypeRequirement(PokemonType.BUG, 1), + new TypeRequirement(PokemonType.BUG, false, 1), + ), + ) + .withMaxAllowedEncounters(1) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withIntroSpriteConfigs([]) // These are set in onInit() + .withAutoHideIntroVisuals(false) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Calculates what trainers are available for battle in the encounter + + // Bug type superfan trainer config + const config = getTrainerConfigForWave(globalScene.currentBattle.waveIndex); + const spriteKey = config.getSpriteKey(); + encounter.enemyPartyConfigs.push({ + trainerConfig: config, + female: true, + }); + + let beedrillKeys: { spriteKey: string; fileRoot: string }, butterfreeKeys: { spriteKey: string; fileRoot: string }; + if (globalScene.currentBattle.waveIndex < WAVE_LEVEL_BREAKPOINTS[3]) { + beedrillKeys = getSpriteKeysFromSpecies(Species.BEEDRILL, false); + butterfreeKeys = getSpriteKeysFromSpecies(Species.BUTTERFREE, false); + } else { + // Mega Beedrill/Gmax Butterfree + beedrillKeys = getSpriteKeysFromSpecies(Species.BEEDRILL, false, 1); + butterfreeKeys = getSpriteKeysFromSpecies(Species.BUTTERFREE, false, 1); + } + + encounter.spriteConfigs = [ { - text: `${namespace}:intro`, + spriteKey: beedrillKeys.spriteKey, + fileRoot: beedrillKeys.fileRoot, + hasShadow: true, + repeat: true, + isPokemon: true, + x: -30, + tint: 0.15, + y: -4, + yShadow: -4, }, { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, + spriteKey: butterfreeKeys.spriteKey, + fileRoot: butterfreeKeys.fileRoot, + hasShadow: true, + repeat: true, + isPokemon: true, + x: 30, + tint: 0.15, + y: -4, + yShadow: -4, }, - ]) - .withOnInit(() => { + { + spriteKey: spriteKey, + fileRoot: "trainer", + hasShadow: true, + x: 4, + y: 7, + yShadow: 7, + }, + ]; + + const requiredItems = [ + generateModifierType(modifierTypes.QUICK_CLAW), + generateModifierType(modifierTypes.GRIP_CLAW), + generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [PokemonType.BUG]), + ]; + + const requiredItemString = requiredItems.map(m => m?.name ?? "unknown").join("/"); + encounter.setDialogueToken("requiredBugItems", requiredItemString); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Select battle the bug trainer const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculates what trainers are available for battle in the encounter + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Bug type superfan trainer config - const config = getTrainerConfigForWave(globalScene.currentBattle.waveIndex); - const spriteKey = config.getSpriteKey(); - encounter.enemyPartyConfigs.push({ - trainerConfig: config, - female: true, - }); + // Init the moves available for tutor + const moveTutorOptions: PokemonMove[] = []; + moveTutorOptions.push(new PokemonMove(PHYSICAL_TUTOR_MOVES[randSeedInt(PHYSICAL_TUTOR_MOVES.length)])); + moveTutorOptions.push(new PokemonMove(SPECIAL_TUTOR_MOVES[randSeedInt(SPECIAL_TUTOR_MOVES.length)])); + moveTutorOptions.push(new PokemonMove(STATUS_TUTOR_MOVES[randSeedInt(STATUS_TUTOR_MOVES.length)])); + moveTutorOptions.push(new PokemonMove(MISC_TUTOR_MOVES[randSeedInt(MISC_TUTOR_MOVES.length)])); + encounter.misc = { + moveTutorOptions, + }; - let beedrillKeys: { spriteKey: string, fileRoot: string }, butterfreeKeys: { spriteKey: string, fileRoot: string }; - if (globalScene.currentBattle.waveIndex < WAVE_LEVEL_BREAKPOINTS[3]) { - beedrillKeys = getSpriteKeysFromSpecies(Species.BEEDRILL, false); - butterfreeKeys = getSpriteKeysFromSpecies(Species.BUTTERFREE, false); - } else { - // Mega Beedrill/Gmax Butterfree - beedrillKeys = getSpriteKeysFromSpecies(Species.BEEDRILL, false, 1); - butterfreeKeys = getSpriteKeysFromSpecies(Species.BUTTERFREE, false, 1); - } + // Assigns callback that teaches move before continuing to rewards + encounter.onRewards = doBugTypeMoveTutor; - encounter.spriteConfigs = [ - { - spriteKey: beedrillKeys.spriteKey, - fileRoot: beedrillKeys.fileRoot, - hasShadow: true, - repeat: true, - isPokemon: true, - x: -30, - tint: 0.15, - y: -4, - yShadow: -4 - }, - { - spriteKey: butterfreeKeys.spriteKey, - fileRoot: butterfreeKeys.fileRoot, - hasShadow: true, - repeat: true, - isPokemon: true, - x: 30, - tint: 0.15, - y: -4, - yShadow: -4 - }, - { - spriteKey: spriteKey, - fileRoot: "trainer", - hasShadow: true, - x: 4, - y: 7, - yShadow: 7 - }, - ]; - - const requiredItems = [ - generateModifierType(modifierTypes.QUICK_CLAW), - generateModifierType(modifierTypes.GRIP_CLAW), - generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.BUG ]), - ]; - - const requiredItemString = requiredItems.map(m => m?.name ?? "unknown").join("/"); - encounter.setDialogueToken("requiredBugItems", requiredItemString); - - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:option.1.selected`, - }, - ], - }, - async () => { - // Select battle the bug trainer - const encounter = globalScene.currentBattle.mysteryEncounter!; - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - - // Init the moves available for tutor - const moveTutorOptions: PokemonMove[] = []; - moveTutorOptions.push(new PokemonMove(PHYSICAL_TUTOR_MOVES[randSeedInt(PHYSICAL_TUTOR_MOVES.length)])); - moveTutorOptions.push(new PokemonMove(SPECIAL_TUTOR_MOVES[randSeedInt(SPECIAL_TUTOR_MOVES.length)])); - moveTutorOptions.push(new PokemonMove(STATUS_TUTOR_MOVES[randSeedInt(STATUS_TUTOR_MOVES.length)])); - moveTutorOptions.push(new PokemonMove(MISC_TUTOR_MOVES[randSeedInt(MISC_TUTOR_MOVES.length)])); - encounter.misc = { - moveTutorOptions - }; - - // Assigns callback that teaches move before continuing to rewards - encounter.onRewards = doBugTypeMoveTutor; - - setEncounterRewards({ fillRemaining: true }); - await transitionMysteryEncounterIntroVisuals(true, true); - await initBattleWithEnemyConfig(config); - } - ) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + setEncounterRewards({ fillRemaining: true }); + await transitionMysteryEncounterIntroVisuals(true, true); + await initBattleWithEnemyConfig(config); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withPrimaryPokemonRequirement(new TypeRequirement(PokemonType.BUG, false, 1)) // Must have 1 Bug type on team .withDialogue({ buttonLabel: `${namespace}:option.2.label`, buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip` + disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, }) .withPreOptionPhase(async () => { // Player shows off their bug types @@ -340,11 +322,16 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = // Player gets different rewards depending on the number of bug types they have const numBugTypes = globalScene.getPlayerParty().filter(p => p.isOfType(PokemonType.BUG, true)).length; - const numBugTypesText = i18next.t(`${namespace}:numBugTypes`, { count: numBugTypes }); + const numBugTypesText = i18next.t(`${namespace}:numBugTypes`, { + count: numBugTypes, + }); encounter.setDialogueToken("numBugTypes", numBugTypesText); if (numBugTypes < 2) { - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.SUPER_LURE, modifierTypes.GREAT_BALL ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.SUPER_LURE, modifierTypes.GREAT_BALL], + fillRemaining: false, + }); encounter.selectedOption!.dialogue!.selected = [ { speaker: `${namespace}:speaker`, @@ -352,7 +339,10 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = }, ]; } else if (numBugTypes < 4) { - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.QUICK_CLAW, modifierTypes.MAX_LURE, modifierTypes.ULTRA_BALL ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.QUICK_CLAW, modifierTypes.MAX_LURE, modifierTypes.ULTRA_BALL], + fillRemaining: false, + }); encounter.selectedOption!.dialogue!.selected = [ { speaker: `${namespace}:speaker`, @@ -360,7 +350,10 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = }, ]; } else if (numBugTypes < 6) { - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.GRIP_CLAW, modifierTypes.MAX_LURE, modifierTypes.ROGUE_BALL ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.GRIP_CLAW, modifierTypes.MAX_LURE, modifierTypes.ROGUE_BALL], + fillRemaining: false, + }); encounter.selectedOption!.dialogue!.selected = [ { speaker: `${namespace}:speaker`, @@ -370,7 +363,7 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = } else { // If the player has any evolution/form change items that are valid for their party, // spawn one of those items in addition to Dynamax Band, Mega Band, and Master Ball - const modifierOptions: ModifierTypeOption[] = [ generateModifierTypeOption(modifierTypes.MASTER_BALL)! ]; + const modifierOptions: ModifierTypeOption[] = [generateModifierTypeOption(modifierTypes.MASTER_BALL)!]; const specialOptions: ModifierTypeOption[] = []; if (!globalScene.findModifier(m => m instanceof MegaEvolutionAccessModifier)) { @@ -399,7 +392,10 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = modifierOptions.push(specialOptions[randSeedInt(specialOptions.length)]); } - setEncounterRewards({ guaranteedModifierTypeOptions: modifierOptions, fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeOptions: modifierOptions, + fillRemaining: false, + }); encounter.selectedOption!.dialogue!.selected = [ { speaker: `${namespace}:speaker`, @@ -412,15 +408,16 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = // Player shows off their bug types leaveEncounterWithoutBattle(); }) - .build()) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withPrimaryPokemonRequirement( CombinationPokemonRequirement.Some( // Meets one or both of the below reqs - new HeldItemRequirement([ "BypassSpeedChanceModifier", "ContactHeldItemTransferChanceModifier" ], 1), - new AttackTypeBoosterHeldItemTypeRequirement(PokemonType.BUG, 1) - ) + new HeldItemRequirement(["BypassSpeedChanceModifier", "ContactHeldItemTransferChanceModifier"], 1), + new AttackTypeBoosterHeldItemTypeRequirement(PokemonType.BUG, 1), + ), ) .withDialogue({ buttonLabel: `${namespace}:option.3.label`, @@ -443,10 +440,13 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = const onPokemonSelected = (pokemon: PlayerPokemon) => { // Get Pokemon held items and filter for valid ones const validItems = pokemon.getHeldItems().filter(item => { - return (item instanceof BypassSpeedChanceModifier || - item instanceof ContactHeldItemTransferChanceModifier || - (item instanceof AttackTypeBoosterModifier && (item.type as AttackTypeBoosterModifierType).moveType === PokemonType.BUG)) && - item.isTransferable; + return ( + (item instanceof BypassSpeedChanceModifier || + item instanceof ContactHeldItemTransferChanceModifier || + (item instanceof AttackTypeBoosterModifier && + (item.type as AttackTypeBoosterModifierType).moveType === PokemonType.BUG)) && + item.isTransferable + ); }); return validItems.map((modifier: PokemonHeldItemModifier) => { @@ -469,9 +469,12 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = const selectableFilter = (pokemon: Pokemon) => { // If pokemon has valid item, it can be selected const hasValidItem = pokemon.getHeldItems().some(item => { - return item instanceof BypassSpeedChanceModifier || + return ( + item instanceof BypassSpeedChanceModifier || item instanceof ContactHeldItemTransferChanceModifier || - (item instanceof AttackTypeBoosterModifier && (item.type as AttackTypeBoosterModifierType).moveType === PokemonType.BUG); + (item instanceof AttackTypeBoosterModifier && + (item.type as AttackTypeBoosterModifierType).moveType === PokemonType.BUG) + ); }); if (!hasValidItem) { return getEncounterText(`${namespace}:option.3.invalid_selection`) ?? null; @@ -493,16 +496,21 @@ export const BugTypeSuperfanEncounter: MysteryEncounter = const bugNet = generateModifierTypeOption(modifierTypes.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET)!; bugNet.type.tier = ModifierTier.ROGUE; - setEncounterRewards({ guaranteedModifierTypeOptions: [ bugNet ], guaranteedModifierTypeFuncs: [ modifierTypes.REVIVER_SEED ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeOptions: [bugNet], + guaranteedModifierTypeFuncs: [modifierTypes.REVIVER_SEED], + fillRemaining: false, + }); leaveEncounterWithoutBattle(true); }) - .build()) - .withOutroDialogue([ - { - text: `${namespace}:outro`, - }, - ]) - .build(); + .build(), + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); function getTrainerConfigForWave(waveIndex: number) { // Bug type superfan trainer config @@ -516,134 +524,186 @@ function getTrainerConfigForWave(waveIndex: number) { if (waveIndex < WAVE_LEVEL_BREAKPOINTS[0]) { // Use default template (2 AVG) config - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true)); + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true)); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[1]) { config .setPartyTemplates(new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_1_POKEMON, TrainerSlot.TRAINER, true)); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[2]) { config .setPartyTemplates(new TrainerPartyTemplate(4, PartyMemberStrength.AVERAGE)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_1_POKEMON, TrainerSlot.TRAINER, true)) .setPartyMemberFunc(3, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[3]) { config .setPartyTemplates(new TrainerPartyTemplate(5, PartyMemberStrength.AVERAGE)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true)) .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_1_POKEMON, TrainerSlot.TRAINER, true)) .setPartyMemberFunc(3, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) .setPartyMemberFunc(4, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[4]) { config .setPartyTemplates(new TrainerPartyTemplate(5, PartyMemberStrength.AVERAGE)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(3, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ pool3Mon.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon.formIndex)) { - p.formIndex = pool3Mon.formIndex; + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; p.generateAndPopulateMoveset(); p.generateName(); - } - })); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(3, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([pool3Mon.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon.formIndex)) { + p.formIndex = pool3Mon.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[5]) { pool3Copy = randSeedShuffle(pool3Copy); const pool3Mon2 = pool3Copy.pop()!; config .setPartyTemplates(new TrainerPartyTemplate(5, PartyMemberStrength.AVERAGE)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ pool3Mon.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon.formIndex)) { - p.formIndex = pool3Mon.formIndex; - p.generateAndPopulateMoveset(); - p.generateName(); - } - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ pool3Mon2.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon2.formIndex)) { - p.formIndex = pool3Mon2.formIndex; - p.generateAndPopulateMoveset(); - p.generateName(); - } - })); + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([pool3Mon.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon.formIndex)) { + p.formIndex = pool3Mon.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([pool3Mon2.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon2.formIndex)) { + p.formIndex = pool3Mon2.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ); } else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[6]) { config - .setPartyTemplates(new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(4, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG))) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ pool3Mon.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon.formIndex)) { - p.formIndex = pool3Mon.formIndex; + .setPartyTemplates( + new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(4, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + ) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; p.generateAndPopulateMoveset(); p.generateName(); - } - })) + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc(POOL_2_POKEMON, TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([pool3Mon.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon.formIndex)) { + p.formIndex = pool3Mon.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ) .setPartyMemberFunc(4, getRandomPartyMemberFunc(POOL_4_POKEMON, TrainerSlot.TRAINER, true)); } else { pool3Copy = randSeedShuffle(pool3Copy); const pool3Mon2 = pool3Copy.pop()!; config - .setPartyTemplates(new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(4, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG))) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BEEDRILL ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUTTERFREE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.formIndex = 1; - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ pool3Mon.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon.formIndex)) { - p.formIndex = pool3Mon.formIndex; + .setPartyTemplates( + new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(4, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + ) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.BEEDRILL], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.formIndex = 1; p.generateAndPopulateMoveset(); p.generateName(); - } - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ pool3Mon2.species ], TrainerSlot.TRAINER, true, p => { - if (!isNullOrUndefined(pool3Mon2.formIndex)) { - p.formIndex = pool3Mon2.formIndex; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.BUTTERFREE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.formIndex = 1; p.generateAndPopulateMoveset(); p.generateName(); - } - })) + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([pool3Mon.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon.formIndex)) { + p.formIndex = pool3Mon.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([pool3Mon2.species], TrainerSlot.TRAINER, true, p => { + if (!isNullOrUndefined(pool3Mon2.formIndex)) { + p.formIndex = pool3Mon2.formIndex; + p.generateAndPopulateMoveset(); + p.generateName(); + } + }), + ) .setPartyMemberFunc(4, getRandomPartyMemberFunc(POOL_4_POKEMON, TrainerSlot.TRAINER, true)); } @@ -651,6 +711,7 @@ function getTrainerConfigForWave(waveIndex: number) { } function doBugTypeMoveTutor(): Promise { + // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO explain return new Promise(async resolve => { const moveOptions = globalScene.currentBattle.mysteryEncounter!.misc.moveTutorOptions; await showEncounterDialogue(`${namespace}:battle_won`, `${namespace}:speaker`); @@ -663,7 +724,7 @@ function doBugTypeMoveTutor(): Promise { right: true, x: 1, y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1, - width: (globalScene.game.canvas.width / 6) - 2, + width: globalScene.game.canvas.width / 6 - 2, }); globalScene.ui.add(moveInfoOverlay); @@ -688,7 +749,12 @@ function doBugTypeMoveTutor(): Promise { moveInfoOverlay.setVisible(false); }; - const result = await selectOptionThenPokemon(optionSelectItems, `${namespace}:teach_move_prompt`, undefined, onHoverOverCancel); + const result = await selectOptionThenPokemon( + optionSelectItems, + `${namespace}:teach_move_prompt`, + undefined, + onHoverOverCancel, + ); // let forceExit = !!result; if (!result) { moveInfoOverlay.active = false; @@ -699,7 +765,9 @@ function doBugTypeMoveTutor(): Promise { // Option select complete, handle if they are learning a move if (result && result.selectedOptionIndex < moveOptions.length) { - globalScene.unshiftPhase(new LearnMovePhase(result.selectedPokemonIndex, moveOptions[result.selectedOptionIndex].moveId)); + globalScene.unshiftPhase( + new LearnMovePhase(result.selectedPokemonIndex, moveOptions[result.selectedOptionIndex].moveId), + ); } // Complete battle and go to rewards diff --git a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts index c9fc7975a3f..2b499d938cd 100644 --- a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts +++ b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts @@ -1,6 +1,14 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, loadCustomMovesForEncounter, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { trainerConfigs, TrainerPartyCompoundTemplate, TrainerPartyTemplate, } from "#app/data/trainer-config"; +import { + generateModifierType, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + loadCustomMovesForEncounter, + selectPokemonForOption, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { trainerConfigs, TrainerPartyCompoundTemplate, TrainerPartyTemplate } from "#app/data/trainer-config"; import { ModifierTier } from "#app/modifier/modifier-tier"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { ModifierPoolType, modifierTypes } from "#app/modifier/modifier-type"; @@ -14,7 +22,10 @@ import { Species } from "#enums/species"; import { TrainerType } from "#enums/trainer-type"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { Abilities } from "#enums/abilities"; -import { applyAbilityOverrideToPokemon, applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + applyAbilityOverrideToPokemon, + applyModifierTypeToPlayerPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { PokemonType } from "#enums/pokemon-type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -55,7 +66,7 @@ const RANDOM_ABILITY_POOL = [ Abilities.MISTY_SURGE, Abilities.MAGICIAN, Abilities.SHEER_FORCE, - Abilities.PRANKSTER + Abilities.PRANKSTER, ]; /** @@ -63,340 +74,363 @@ const RANDOM_ABILITY_POOL = [ * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3807 | GitHub Issue #3807} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const ClowningAroundEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.CLOWNING_AROUND) - .withEncounterTier(MysteryEncounterTier.ULTRA) - .withDisallowedChallenges(Challenges.SINGLE_TYPE) - .withSceneWaveRangeRequirement(80, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withAnimations(EncounterAnim.SMOKESCREEN) - .withAutoHideIntroVisuals(false) - .withIntroSpriteConfigs([ - { - spriteKey: Species.MR_MIME.toString(), - fileRoot: "pokemon", - hasShadow: true, - repeat: true, - x: -25, - tint: 0.3, - y: -3, - yShadow: -3 - }, - { - spriteKey: Species.BLACEPHALON.toString(), - fileRoot: "pokemon/exp", - hasShadow: true, - repeat: true, - x: 25, - tint: 0.3, - y: -3, - yShadow: -3 - }, - { - spriteKey: "harlequin", - fileRoot: "trainer", - hasShadow: true, - x: 0, - y: 2, - yShadow: 2 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker` - }, - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const ClowningAroundEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.CLOWNING_AROUND, +) + .withEncounterTier(MysteryEncounterTier.ULTRA) + .withDisallowedChallenges(Challenges.SINGLE_TYPE) + .withSceneWaveRangeRequirement(80, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withAnimations(EncounterAnim.SMOKESCREEN) + .withAutoHideIntroVisuals(false) + .withIntroSpriteConfigs([ + { + spriteKey: Species.MR_MIME.toString(), + fileRoot: "pokemon", + hasShadow: true, + repeat: true, + x: -25, + tint: 0.3, + y: -3, + yShadow: -3, + }, + { + spriteKey: Species.BLACEPHALON.toString(), + fileRoot: "pokemon/exp", + hasShadow: true, + repeat: true, + x: 25, + tint: 0.3, + y: -3, + yShadow: -3, + }, + { + spriteKey: "harlequin", + fileRoot: "trainer", + hasShadow: true, + x: 0, + y: 2, + yShadow: 2, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - const clownTrainerType = TrainerType.HARLEQUIN; - const clownConfig = trainerConfigs[clownTrainerType].clone(); - const clownPartyTemplate = new TrainerPartyCompoundTemplate( - new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), - new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)); - clownConfig.setPartyTemplates(clownPartyTemplate); - clownConfig.setDoubleOnly(); - // @ts-ignore - clownConfig.partyTemplateFunc = null; // Overrides party template func if it exists + const clownTrainerType = TrainerType.HARLEQUIN; + const clownConfig = trainerConfigs[clownTrainerType].clone(); + const clownPartyTemplate = new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ); + clownConfig.setPartyTemplates(clownPartyTemplate); + clownConfig.setDoubleOnly(); + // @ts-ignore + clownConfig.partyTemplateFunc = null; // Overrides party template func if it exists - // Generate random ability for Blacephalon from pool - const ability = RANDOM_ABILITY_POOL[randSeedInt(RANDOM_ABILITY_POOL.length)]; - encounter.setDialogueToken("ability", new Ability(ability, 3).name); - encounter.misc = { ability }; + // Generate random ability for Blacephalon from pool + const ability = RANDOM_ABILITY_POOL[randSeedInt(RANDOM_ABILITY_POOL.length)]; + encounter.setDialogueToken("ability", new Ability(ability, 3).name); + encounter.misc = { ability }; - // Decide the random types for Blacephalon. They should not be the same. - const firstType: number = randSeedInt(18); - let secondType: number = randSeedInt(17); - if ( secondType >= firstType ) { - secondType++; - } + // Decide the random types for Blacephalon. They should not be the same. + const firstType: number = randSeedInt(18); + let secondType: number = randSeedInt(17); + if (secondType >= firstType) { + secondType++; + } - encounter.enemyPartyConfigs.push({ - trainerConfig: clownConfig, - pokemonConfigs: [ // Overrides first 2 pokemon to be Mr. Mime and Blacephalon + encounter.enemyPartyConfigs.push({ + trainerConfig: clownConfig, + pokemonConfigs: [ + // Overrides first 2 pokemon to be Mr. Mime and Blacephalon + { + species: getPokemonSpecies(Species.MR_MIME), + isBoss: true, + moveSet: [Moves.TEETER_DANCE, Moves.ALLY_SWITCH, Moves.DAZZLING_GLEAM, Moves.PSYCHIC], + }, + { + // Blacephalon has the random ability from pool, and 2 entirely random types to fit with the theme of the encounter + species: getPokemonSpecies(Species.BLACEPHALON), + customPokemonData: new CustomPokemonData({ + ability: ability, + types: [firstType, secondType], + }), + isBoss: true, + moveSet: [Moves.TRICK, Moves.HYPNOSIS, Moves.SHADOW_BALL, Moves.MIND_BLOWN], + }, + ], + doubleBattle: true, + }); + + // Load animations/sfx for start of fight moves + loadCustomMovesForEncounter([Moves.ROLE_PLAY, Moves.TAUNT]); + + encounter.setDialogueToken("blacephalonName", getPokemonSpecies(Species.BLACEPHALON).getName()); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ { - species: getPokemonSpecies(Species.MR_MIME), - isBoss: true, - moveSet: [ Moves.TEETER_DANCE, Moves.ALLY_SWITCH, Moves.DAZZLING_GLEAM, Moves.PSYCHIC ] - }, - { // Blacephalon has the random ability from pool, and 2 entirely random types to fit with the theme of the encounter - species: getPokemonSpecies(Species.BLACEPHALON), - customPokemonData: new CustomPokemonData({ ability: ability, types: [ firstType, secondType ]}), - isBoss: true, - moveSet: [ Moves.TRICK, Moves.HYPNOSIS, Moves.SHADOW_BALL, Moves.MIND_BLOWN ] + text: `${namespace}:option.1.selected`, + speaker: `${namespace}:speaker`, }, ], - doubleBattle: true - }); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn battle + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Load animations/sfx for start of fight moves - loadCustomMovesForEncounter([ Moves.ROLE_PLAY, Moves.TAUNT ]); + setEncounterRewards({ fillRemaining: true }); - encounter.setDialogueToken("blacephalonName", getPokemonSpecies(Species.BLACEPHALON).getName()); + // TODO: when Magic Room and Wonder Room are implemented, add those to start of battle + encounter.startOfBattleEffects.push( + { + // Mr. Mime copies the Blacephalon's random ability + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.ENEMY_2], + move: new PokemonMove(Moves.ROLE_PLAY), + ignorePp: true, + }, + { + sourceBattlerIndex: BattlerIndex.ENEMY_2, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.TAUNT), + ignorePp: true, + }, + { + sourceBattlerIndex: BattlerIndex.ENEMY_2, + targets: [BattlerIndex.PLAYER_2], + move: new PokemonMove(Moves.TAUNT), + ignorePp: true, + }, + ); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - speaker: `${namespace}:speaker` - }, - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn battle - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; + await transitionMysteryEncounterIntroVisuals(); + await initBattleWithEnemyConfig(config); + }) + .withPostOptionPhase(async (): Promise => { + // After the battle, offer the player the opportunity to permanently swap ability + const abilityWasSwapped = await handleSwapAbility(); + if (abilityWasSwapped) { + await showEncounterText(`${namespace}:option.1.ability_gained`); + } - setEncounterRewards({ fillRemaining: true }); + // Play animations once ability swap is complete + // Trainer sprite that is shown at end of battle is not the same as mystery encounter intro visuals + globalScene.tweens.add({ + targets: globalScene.currentBattle.trainer, + x: "+=16", + y: "-=16", + alpha: 0, + ease: "Sine.easeInOut", + duration: 250, + }); + const background = new EncounterBattleAnim( + EncounterAnim.SMOKESCREEN, + globalScene.getPlayerPokemon()!, + globalScene.getPlayerPokemon(), + ); + background.playWithoutTargets(230, 40, 2); + return true; + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + speaker: `${namespace}:speaker`, + }, + { + text: `${namespace}:option.2.selected_2`, + }, + { + text: `${namespace}:option.2.selected_3`, + speaker: `${namespace}:speaker`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Swap player's items on pokemon with the most items + // Item comparisons look at whichever Pokemon has the greatest number of TRANSFERABLE, non-berry items + // So Vitamins, form change items, etc. are not included + const encounter = globalScene.currentBattle.mysteryEncounter!; - // TODO: when Magic Room and Wonder Room are implemented, add those to start of battle - encounter.startOfBattleEffects.push( - { // Mr. Mime copies the Blacephalon's random ability - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.ENEMY_2 ], - move: new PokemonMove(Moves.ROLE_PLAY), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY_2, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.TAUNT), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY_2, - targets: [ BattlerIndex.PLAYER_2 ], - move: new PokemonMove(Moves.TAUNT), - ignorePp: true - }); + const party = globalScene.getPlayerParty(); + let mostHeldItemsPokemon = party[0]; + let count = mostHeldItemsPokemon + .getHeldItems() + .filter(m => m.isTransferable && !(m instanceof BerryModifier)) + .reduce((v, m) => v + m.stackCount, 0); - await transitionMysteryEncounterIntroVisuals(); - await initBattleWithEnemyConfig(config); - }) - .withPostOptionPhase(async (): Promise => { - // After the battle, offer the player the opportunity to permanently swap ability - const abilityWasSwapped = await handleSwapAbility(); - if (abilityWasSwapped) { - await showEncounterText(`${namespace}:option.1.ability_gained`); - } - - // Play animations once ability swap is complete - // Trainer sprite that is shown at end of battle is not the same as mystery encounter intro visuals - globalScene.tweens.add({ - targets: globalScene.currentBattle.trainer, - x: "+=16", - y: "-=16", - alpha: 0, - ease: "Sine.easeInOut", - duration: 250 - }); - const background = new EncounterBattleAnim(EncounterAnim.SMOKESCREEN, globalScene.getPlayerPokemon()!, globalScene.getPlayerPokemon()); - background.playWithoutTargets(230, 40, 2); - return true; - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - speaker: `${namespace}:speaker` - }, - { - text: `${namespace}:option.2.selected_2`, - }, - { - text: `${namespace}:option.2.selected_3`, - speaker: `${namespace}:speaker` - }, - ], - }) - .withPreOptionPhase(async () => { - // Swap player's items on pokemon with the most items - // Item comparisons look at whichever Pokemon has the greatest number of TRANSFERABLE, non-berry items - // So Vitamins, form change items, etc. are not included - const encounter = globalScene.currentBattle.mysteryEncounter!; - - const party = globalScene.getPlayerParty(); - let mostHeldItemsPokemon = party[0]; - let count = mostHeldItemsPokemon.getHeldItems() + for (const pokemon of party) { + const nextCount = pokemon + .getHeldItems() .filter(m => m.isTransferable && !(m instanceof BerryModifier)) .reduce((v, m) => v + m.stackCount, 0); + if (nextCount > count) { + mostHeldItemsPokemon = pokemon; + count = nextCount; + } + } - party.forEach(pokemon => { - const nextCount = pokemon.getHeldItems() - .filter(m => m.isTransferable && !(m instanceof BerryModifier)) - .reduce((v, m) => v + m.stackCount, 0); - if (nextCount > count) { - mostHeldItemsPokemon = pokemon; - count = nextCount; - } - }); + encounter.setDialogueToken("switchPokemon", mostHeldItemsPokemon.getNameToRender()); - encounter.setDialogueToken("switchPokemon", mostHeldItemsPokemon.getNameToRender()); + const items = mostHeldItemsPokemon.getHeldItems(); - const items = mostHeldItemsPokemon.getHeldItems(); + // Shuffles Berries (if they have any) + let numBerries = 0; + for (const m of items.filter(m => m instanceof BerryModifier)) { + numBerries += m.stackCount; + globalScene.removeModifier(m); + } - // Shuffles Berries (if they have any) - let numBerries = 0; - items.filter(m => m instanceof BerryModifier) - .forEach(m => { - numBerries += m.stackCount; - globalScene.removeModifier(m); - }); + generateItemsOfTier(mostHeldItemsPokemon, numBerries, "Berries"); - generateItemsOfTier(mostHeldItemsPokemon, numBerries, "Berries"); + // Shuffle Transferable held items in the same tier (only shuffles Ultra and Rogue atm) + // For the purpose of this ME, Soothe Bells and Lucky Eggs are counted as Ultra tier + // And Golden Eggs as Rogue tier + let numUltra = 0; + let numRogue = 0; - // Shuffle Transferable held items in the same tier (only shuffles Ultra and Rogue atm) - // For the purpose of this ME, Soothe Bells and Lucky Eggs are counted as Ultra tier - // And Golden Eggs as Rogue tier - let numUltra = 0; - let numRogue = 0; - items.filter(m => m.isTransferable && !(m instanceof BerryModifier)) - .forEach(m => { - const type = m.type.withTierFromPool(ModifierPoolType.PLAYER, party); - const tier = type.tier ?? ModifierTier.ULTRA; - if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) { - numRogue += m.stackCount; - globalScene.removeModifier(m); - } else if (type.id === "LUCKY_EGG" || type.id === "SOOTHE_BELL" || tier === ModifierTier.ULTRA) { - numUltra += m.stackCount; - globalScene.removeModifier(m); - } - }); + for (const m of items.filter(m => m.isTransferable && !(m instanceof BerryModifier))) { + const type = m.type.withTierFromPool(ModifierPoolType.PLAYER, party); + const tier = type.tier ?? ModifierTier.ULTRA; + if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) { + numRogue += m.stackCount; + globalScene.removeModifier(m); + } else if (type.id === "LUCKY_EGG" || type.id === "SOOTHE_BELL" || tier === ModifierTier.ULTRA) { + numUltra += m.stackCount; + globalScene.removeModifier(m); + } + } - generateItemsOfTier(mostHeldItemsPokemon, numUltra, ModifierTier.ULTRA); - generateItemsOfTier(mostHeldItemsPokemon, numRogue, ModifierTier.ROGUE); - }) - .withOptionPhase(async () => { - leaveEncounterWithoutBattle(true); - }) - .withPostOptionPhase(async () => { - // Play animations - const background = new EncounterBattleAnim(EncounterAnim.SMOKESCREEN, globalScene.getPlayerPokemon()!, globalScene.getPlayerPokemon()); - background.playWithoutTargets(230, 40, 2); - await transitionMysteryEncounterIntroVisuals(true, true, 200); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - speaker: `${namespace}:speaker` - }, - { - text: `${namespace}:option.3.selected_2`, - }, - { - text: `${namespace}:option.3.selected_3`, - speaker: `${namespace}:speaker` - }, - ], - }) - .withPreOptionPhase(async () => { - // Randomize the second type of all player's pokemon - // If the pokemon does not normally have a second type, it will gain 1 - for (const pokemon of globalScene.getPlayerParty()) { - const originalTypes = pokemon.getTypes(false, false, true); + generateItemsOfTier(mostHeldItemsPokemon, numUltra, ModifierTier.ULTRA); + generateItemsOfTier(mostHeldItemsPokemon, numRogue, ModifierTier.ROGUE); + }) + .withOptionPhase(async () => { + leaveEncounterWithoutBattle(true); + }) + .withPostOptionPhase(async () => { + // Play animations + const background = new EncounterBattleAnim( + EncounterAnim.SMOKESCREEN, + globalScene.getPlayerPokemon()!, + globalScene.getPlayerPokemon(), + ); + background.playWithoutTargets(230, 40, 2); + await transitionMysteryEncounterIntroVisuals(true, true, 200); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + speaker: `${namespace}:speaker`, + }, + { + text: `${namespace}:option.3.selected_2`, + }, + { + text: `${namespace}:option.3.selected_3`, + speaker: `${namespace}:speaker`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Randomize the second type of all player's pokemon + // If the pokemon does not normally have a second type, it will gain 1 + for (const pokemon of globalScene.getPlayerParty()) { + const originalTypes = pokemon.getTypes(false, false, true); - // If the Pokemon has non-status moves that don't match the Pokemon's type, prioritizes those as the new type - // Makes the "randomness" of the shuffle slightly less punishing - let priorityTypes = pokemon.moveset - .filter(move => move && !originalTypes.includes(move.getMove().type) && move.getMove().category !== MoveCategory.STATUS) - .map(move => move!.getMove().type); - if (priorityTypes?.length > 0) { - priorityTypes = [ ...new Set(priorityTypes) ].sort(); - priorityTypes = randSeedShuffle(priorityTypes); - } + // If the Pokemon has non-status moves that don't match the Pokemon's type, prioritizes those as the new type + // Makes the "randomness" of the shuffle slightly less punishing + let priorityTypes = pokemon.moveset + .filter( + move => + move && !originalTypes.includes(move.getMove().type) && move.getMove().category !== MoveCategory.STATUS, + ) + .map(move => move!.getMove().type); + if (priorityTypes?.length > 0) { + priorityTypes = [...new Set(priorityTypes)].sort(); + priorityTypes = randSeedShuffle(priorityTypes); + } - const newTypes = [ PokemonType.UNKNOWN ]; - let secondType: PokemonType | null = null; - while (secondType === null || secondType === newTypes[0] || originalTypes.includes(secondType)) { - if (priorityTypes.length > 0) { - secondType = priorityTypes.pop() ?? null; - } else { - secondType = randSeedInt(18) as PokemonType; - } - } - newTypes.push(secondType); - - // Apply the type changes (to both base and fusion, if pokemon is fused) - if (!pokemon.customPokemonData) { - pokemon.customPokemonData = new CustomPokemonData(); - } - pokemon.customPokemonData.types = newTypes; - if (pokemon.isFusion()) { - if (!pokemon.fusionCustomPokemonData) { - pokemon.fusionCustomPokemonData = new CustomPokemonData(); - } - pokemon.fusionCustomPokemonData.types = newTypes; + const newTypes = [PokemonType.UNKNOWN]; + let secondType: PokemonType | null = null; + while (secondType === null || secondType === newTypes[0] || originalTypes.includes(secondType)) { + if (priorityTypes.length > 0) { + secondType = priorityTypes.pop() ?? null; + } else { + secondType = randSeedInt(18) as PokemonType; } } - }) - .withOptionPhase(async () => { - leaveEncounterWithoutBattle(true); - }) - .withPostOptionPhase(async () => { - // Play animations - const background = new EncounterBattleAnim(EncounterAnim.SMOKESCREEN, globalScene.getPlayerPokemon()!, globalScene.getPlayerPokemon()); - background.playWithoutTargets(230, 40, 2); - await transitionMysteryEncounterIntroVisuals(true, true, 200); - }) - .build() - ) - .withOutroDialogue([ - { - text: `${namespace}:outro`, - }, - ]) - .build(); + newTypes.push(secondType); + + // Apply the type changes (to both base and fusion, if pokemon is fused) + if (!pokemon.customPokemonData) { + pokemon.customPokemonData = new CustomPokemonData(); + } + pokemon.customPokemonData.types = newTypes; + if (pokemon.isFusion()) { + if (!pokemon.fusionCustomPokemonData) { + pokemon.fusionCustomPokemonData = new CustomPokemonData(); + } + pokemon.fusionCustomPokemonData.types = newTypes; + } + } + }) + .withOptionPhase(async () => { + leaveEncounterWithoutBattle(true); + }) + .withPostOptionPhase(async () => { + // Play animations + const background = new EncounterBattleAnim( + EncounterAnim.SMOKESCREEN, + globalScene.getPlayerPokemon()!, + globalScene.getPlayerPokemon(), + ); + background.playWithoutTargets(230, 40, 2); + await transitionMysteryEncounterIntroVisuals(true, true, 200); + }) + .build(), + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); async function handleSwapAbility() { + // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO: Consider refactoring to avoid async promise executor return new Promise(async resolve => { await showEncounterDialogue(`${namespace}:option.1.apply_ability_dialogue`, `${namespace}:speaker`); await showEncounterText(`${namespace}:option.1.apply_ability_message`); @@ -415,21 +449,21 @@ function displayYesNoOptions(resolve) { handler: () => { onYesAbilitySwap(resolve); return true; - } + }, }, { label: i18next.t("menu:no"), handler: () => { resolve(false); return true; - } - } + }, + }, ]; const config: OptionSelectConfig = { options: fullOptions, maxOptions: 7, - yOffset: 0 + yOffset: 0, }; globalScene.ui.setModeWithoutClear(Mode.OPTION_SELECT, config, null, true); } @@ -458,36 +492,36 @@ function generateItemsOfTier(pokemon: PlayerPokemon, numItems: number, tier: Mod // Pools have instances of the modifier type equal to the max stacks that modifier can be applied to any one pokemon // This is to prevent "over-generating" a random item of a certain type during item swaps const ultraPool = [ - [ modifierTypes.REVIVER_SEED, 1 ], - [ modifierTypes.GOLDEN_PUNCH, 5 ], - [ modifierTypes.ATTACK_TYPE_BOOSTER, 99 ], - [ modifierTypes.QUICK_CLAW, 3 ], - [ modifierTypes.WIDE_LENS, 3 ] + [modifierTypes.REVIVER_SEED, 1], + [modifierTypes.GOLDEN_PUNCH, 5], + [modifierTypes.ATTACK_TYPE_BOOSTER, 99], + [modifierTypes.QUICK_CLAW, 3], + [modifierTypes.WIDE_LENS, 3], ]; const roguePool = [ - [ modifierTypes.LEFTOVERS, 4 ], - [ modifierTypes.SHELL_BELL, 4 ], - [ modifierTypes.SOUL_DEW, 10 ], - [ modifierTypes.SCOPE_LENS, 1 ], - [ modifierTypes.BATON, 1 ], - [ modifierTypes.FOCUS_BAND, 5 ], - [ modifierTypes.KINGS_ROCK, 3 ], - [ modifierTypes.GRIP_CLAW, 5 ] + [modifierTypes.LEFTOVERS, 4], + [modifierTypes.SHELL_BELL, 4], + [modifierTypes.SOUL_DEW, 10], + [modifierTypes.SCOPE_LENS, 1], + [modifierTypes.BATON, 1], + [modifierTypes.FOCUS_BAND, 5], + [modifierTypes.KINGS_ROCK, 3], + [modifierTypes.GRIP_CLAW, 5], ]; const berryPool = [ - [ BerryType.APICOT, 3 ], - [ BerryType.ENIGMA, 2 ], - [ BerryType.GANLON, 3 ], - [ BerryType.LANSAT, 3 ], - [ BerryType.LEPPA, 2 ], - [ BerryType.LIECHI, 3 ], - [ BerryType.LUM, 2 ], - [ BerryType.PETAYA, 3 ], - [ BerryType.SALAC, 2 ], - [ BerryType.SITRUS, 2 ], - [ BerryType.STARF, 3 ] + [BerryType.APICOT, 3], + [BerryType.ENIGMA, 2], + [BerryType.GANLON, 3], + [BerryType.LANSAT, 3], + [BerryType.LEPPA, 2], + [BerryType.LIECHI, 3], + [BerryType.LUM, 2], + [BerryType.PETAYA, 3], + [BerryType.SALAC, 2], + [BerryType.SITRUS, 2], + [BerryType.STARF, 3], ]; let pool: any[]; @@ -506,7 +540,7 @@ function generateItemsOfTier(pokemon: PlayerPokemon, numItems: number, tier: Mod const newItemType = pool[randIndex]; let newMod: PokemonHeldItemModifierType; if (tier === "Berries") { - newMod = generateModifierType(modifierTypes.BERRY, [ newItemType[0] ]) as PokemonHeldItemModifierType; + newMod = generateModifierType(modifierTypes.BERRY, [newItemType[0]]) as PokemonHeldItemModifierType; } else { newMod = generateModifierType(newItemType[0]) as PokemonHeldItemModifierType; } diff --git a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts index 88e5794e816..91f168371cf 100644 --- a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts +++ b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts @@ -8,8 +8,17 @@ import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter- import { DANCING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { catchPokemon, getEncounterPokemonLevelForWave, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + catchPokemon, + getEncounterPokemonLevelForWave, + STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { TrainerSlot } from "#app/data/trainer-config"; import type { PlayerPokemon } from "#app/field/pokemon"; @@ -44,7 +53,7 @@ const BAILE_STYLE_BIOMES = [ Biome.WASTELAND, Biome.MOUNTAIN, Biome.BADLANDS, - Biome.DESERT + Biome.DESERT, ]; // Electric form @@ -55,7 +64,7 @@ const POM_POM_STYLE_BIOMES = [ Biome.LABORATORY, Biome.SLUM, Biome.METROPOLIS, - Biome.DOJO + Biome.DOJO, ]; // Psychic form @@ -66,7 +75,7 @@ const PAU_STYLE_BIOMES = [ Biome.PLAINS, Biome.GRASS, Biome.TALL_GRASS, - Biome.FOREST + Biome.FOREST, ]; // Ghost form @@ -77,7 +86,7 @@ const SENSU_STYLE_BIOMES = [ Biome.ABYSS, Biome.GRAVEYARD, Biome.LAKE, - Biome.TEMPLE + Biome.TEMPLE, ]; /** @@ -85,239 +94,259 @@ const SENSU_STYLE_BIOMES = [ * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3823 | GitHub Issue #3823} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const DancingLessonsEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.DANCING_LESSONS) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withIntroSpriteConfigs([]) // Uses a real Pokemon sprite instead of ME Intro Visuals - .withAnimations(EncounterAnim.DANCE) - .withHideWildIntroMessage(true) - .withAutoHideIntroVisuals(false) - .withCatchAllowed(true) - .withFleeAllowed(false) - .withOnVisualsStart(() => { - const oricorio = globalScene.getEnemyPokemon()!; - const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, oricorio, globalScene.getPlayerPokemon()!); - danceAnim.play(false, () => { - if (oricorio.shiny) { - oricorio.sparkle(); - } - }); - return true; - }) - .withIntroDialogue([ - { - text: `${namespace}:intro`, +export const DancingLessonsEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.DANCING_LESSONS, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withIntroSpriteConfigs([]) // Uses a real Pokemon sprite instead of ME Intro Visuals + .withAnimations(EncounterAnim.DANCE) + .withHideWildIntroMessage(true) + .withAutoHideIntroVisuals(false) + .withCatchAllowed(true) + .withFleeAllowed(false) + .withOnVisualsStart(() => { + const oricorio = globalScene.getEnemyPokemon()!; + const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, oricorio, globalScene.getPlayerPokemon()!); + danceAnim.play(false, () => { + if (oricorio.shiny) { + oricorio.sparkle(); } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; + }); + return true; + }) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - const species = getPokemonSpecies(Species.ORICORIO); - const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); - const enemyPokemon = new EnemyPokemon(species, level, TrainerSlot.NONE, false); - if (!enemyPokemon.moveset.some(m => m && m.getMove().id === Moves.REVELATION_DANCE)) { - if (enemyPokemon.moveset.length < 4) { - enemyPokemon.moveset.push(new PokemonMove(Moves.REVELATION_DANCE)); - } else { - enemyPokemon.moveset[0] = new PokemonMove(Moves.REVELATION_DANCE); - } - } - - // Set the form index based on the biome - // Defaults to Baile style if somehow nothing matches - const currentBiome = globalScene.arena.biomeType; - if (BAILE_STYLE_BIOMES.includes(currentBiome)) { - enemyPokemon.formIndex = 0; - } else if (POM_POM_STYLE_BIOMES.includes(currentBiome)) { - enemyPokemon.formIndex = 1; - } else if (PAU_STYLE_BIOMES.includes(currentBiome)) { - enemyPokemon.formIndex = 2; - } else if (SENSU_STYLE_BIOMES.includes(currentBiome)) { - enemyPokemon.formIndex = 3; + const species = getPokemonSpecies(Species.ORICORIO); + const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); + const enemyPokemon = new EnemyPokemon(species, level, TrainerSlot.NONE, false); + if (!enemyPokemon.moveset.some(m => m && m.getMove().id === Moves.REVELATION_DANCE)) { + if (enemyPokemon.moveset.length < 4) { + enemyPokemon.moveset.push(new PokemonMove(Moves.REVELATION_DANCE)); } else { - enemyPokemon.formIndex = 0; + enemyPokemon.moveset[0] = new PokemonMove(Moves.REVELATION_DANCE); } + } - const oricorioData = new PokemonData(enemyPokemon); - const oricorio = globalScene.addEnemyPokemon(species, level, TrainerSlot.NONE, false, false, oricorioData); + // Set the form index based on the biome + // Defaults to Baile style if somehow nothing matches + const currentBiome = globalScene.arena.biomeType; + if (BAILE_STYLE_BIOMES.includes(currentBiome)) { + enemyPokemon.formIndex = 0; + } else if (POM_POM_STYLE_BIOMES.includes(currentBiome)) { + enemyPokemon.formIndex = 1; + } else if (PAU_STYLE_BIOMES.includes(currentBiome)) { + enemyPokemon.formIndex = 2; + } else if (SENSU_STYLE_BIOMES.includes(currentBiome)) { + enemyPokemon.formIndex = 3; + } else { + enemyPokemon.formIndex = 0; + } - // Adds a real Pokemon sprite to the field (required for the animation) - globalScene.getEnemyParty().forEach(enemyPokemon => { - enemyPokemon.leaveField(true, true, true); - }); - globalScene.currentBattle.enemyParty = [ oricorio ]; - globalScene.field.add(oricorio); - // Spawns on offscreen field - oricorio.x -= 300; - encounter.loadAssets.push(oricorio.loadAssets()); + const oricorioData = new PokemonData(enemyPokemon); + const oricorio = globalScene.addEnemyPokemon(species, level, TrainerSlot.NONE, false, false, oricorioData); - const config: EnemyPartyConfig = { - pokemonConfigs: [{ + // Adds a real Pokemon sprite to the field (required for the animation) + for (const enemyPokemon of globalScene.getEnemyParty()) { + enemyPokemon.leaveField(true, true, true); + } + globalScene.currentBattle.enemyParty = [oricorio]; + globalScene.field.add(oricorio); + // Spawns on offscreen field + oricorio.x -= 300; + encounter.loadAssets.push(oricorio.loadAssets()); + + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { species: species, dataSource: oricorioData, isBoss: true, // Gets +1 to all stats except SPD on battle start - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], mysteryEncounterBattleEffects: (pokemon: Pokemon) => { queueEncounterMessage(`${namespace}:option.1.boss_enraged`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF ], 1)); + globalScene.unshiftPhase( + new StatStageChangePhase( + pokemon.getBattlerIndex(), + true, + [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF], + 1, + ), + ); + }, + }, + ], + }; + encounter.enemyPartyConfigs = [config]; + encounter.misc = { + oricorioData, + }; + + encounter.setDialogueToken("oricorioName", getPokemonSpecies(Species.ORICORIO).getName()); + + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }) + .withOptionPhase(async () => { + // Pick battle + const encounter = globalScene.currentBattle.mysteryEncounter!; + + encounter.startOfBattleEffects.push({ + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.REVELATION_DANCE), + ignorePp: true, + }); + + await hideOricorioPokemon(); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.BATON], + fillRemaining: true, + }); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Learn its Dance + const encounter = globalScene.currentBattle.mysteryEncounter!; + + const onPokemonSelected = (pokemon: PlayerPokemon) => { + encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); + globalScene.unshiftPhase( + new LearnMovePhase(globalScene.getPlayerParty().indexOf(pokemon), Moves.REVELATION_DANCE), + ); + + // Play animation again to "learn" the dance + const danceAnim = new EncounterBattleAnim( + EncounterAnim.DANCE, + globalScene.getEnemyPokemon()!, + globalScene.getPlayerPokemon(), + ); + danceAnim.play(); + }; + + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + // Learn its Dance + await hideOricorioPokemon(); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement(new MoveRequirement(DANCING_MOVES, true)) // Will set option3PrimaryName and option3PrimaryMove dialogue tokens automatically + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, + secondOptionPrompt: `${namespace}:option.3.select_prompt`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Open menu for selecting pokemon with a Dancing move + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for nature selection + return pokemon.moveset + .filter(move => move && DANCING_MOVES.includes(move.getMove().id)) + .map((move: PokemonMove) => { + const option: OptionSelectItem = { + label: move.getName(), + handler: () => { + // Pokemon and second option selected + encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); + encounter.setDialogueToken("selectedMove", move.getName()); + encounter.misc.selectedMove = move; + + return true; + }, + }; + return option; + }); + }; + + // Only challenge legal/unfainted Pokemon that have a Dancing move can be selected + const selectableFilter = (pokemon: Pokemon) => { + // If pokemon meets primary pokemon reqs, it can be selected + if (!pokemon.isAllowedInBattle()) { + return ( + i18next.t("partyUiHandler:cantBeUsed", { + pokemonName: pokemon.getNameToRender(), + }) ?? null + ); } - }], - }; - encounter.enemyPartyConfigs = [ config ]; - encounter.misc = { - oricorioData - }; - - encounter.setDialogueToken("oricorioName", getPokemonSpecies(Species.ORICORIO).getName()); - - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], - }) - .withOptionPhase(async () => { - // Pick battle - const encounter = globalScene.currentBattle.mysteryEncounter!; - - encounter.startOfBattleEffects.push({ - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.REVELATION_DANCE), - ignorePp: true - }); - - await hideOricorioPokemon(); - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.BATON ], fillRemaining: true }); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Learn its Dance - const encounter = globalScene.currentBattle.mysteryEncounter!; - - const onPokemonSelected = (pokemon: PlayerPokemon) => { - encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); - globalScene.unshiftPhase(new LearnMovePhase(globalScene.getPlayerParty().indexOf(pokemon), Moves.REVELATION_DANCE)); - - // Play animation again to "learn" the dance - const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, globalScene.getEnemyPokemon()!, globalScene.getPlayerPokemon()); - danceAnim.play(); - }; - - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - // Learn its Dance - await hideOricorioPokemon(); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement(new MoveRequirement(DANCING_MOVES, true)) // Will set option3PrimaryName and option3PrimaryMove dialogue tokens automatically - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, - secondOptionPrompt: `${namespace}:option.3.select_prompt`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Open menu for selecting pokemon with a Dancing move - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for nature selection - return pokemon.moveset - .filter(move => move && DANCING_MOVES.includes(move.getMove().id)) - .map((move: PokemonMove) => { - const option: OptionSelectItem = { - label: move.getName(), - handler: () => { - // Pokemon and second option selected - encounter.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); - encounter.setDialogueToken("selectedMove", move.getName()); - encounter.misc.selectedMove = move; - - return true; - }, - }; - return option; - }); - }; - - // Only challenge legal/unfainted Pokemon that have a Dancing move can be selected - const selectableFilter = (pokemon: Pokemon) => { - // If pokemon meets primary pokemon reqs, it can be selected - if (!pokemon.isAllowedInBattle()) { - return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null; - } - const meetsReqs = encounter.options[2].pokemonMeetsPrimaryRequirements(pokemon); - if (!meetsReqs) { - return getEncounterText(`${namespace}:invalid_selection`) ?? null; - } - - return null; - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - // Show the Oricorio a dance, and recruit it - const encounter = globalScene.currentBattle.mysteryEncounter!; - const oricorio = encounter.misc.oricorioData.toPokemon(); - oricorio.passive = true; - - // Ensure the Oricorio's moveset gains the Dance move the player used - const move = encounter.misc.selectedMove?.getMove().id; - if (!oricorio.moveset.some(m => m.getMove().id === move)) { - if (oricorio.moveset.length < 4) { - oricorio.moveset.push(new PokemonMove(move)); - } else { - oricorio.moveset[3] = new PokemonMove(move); - } + const meetsReqs = encounter.options[2].pokemonMeetsPrimaryRequirements(pokemon); + if (!meetsReqs) { + return getEncounterText(`${namespace}:invalid_selection`) ?? null; } - await hideOricorioPokemon(); - await catchPokemon(oricorio, null, PokeballType.POKEBALL, false); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .build(); + return null; + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + // Show the Oricorio a dance, and recruit it + const encounter = globalScene.currentBattle.mysteryEncounter!; + const oricorio = encounter.misc.oricorioData.toPokemon(); + oricorio.passive = true; + + // Ensure the Oricorio's moveset gains the Dance move the player used + const move = encounter.misc.selectedMove?.getMove().id; + if (!oricorio.moveset.some(m => m.getMove().id === move)) { + if (oricorio.moveset.length < 4) { + oricorio.moveset.push(new PokemonMove(move)); + } else { + oricorio.moveset[3] = new PokemonMove(move); + } + } + + await hideOricorioPokemon(); + await catchPokemon(oricorio, null, PokeballType.POKEBALL, false); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .build(); function hideOricorioPokemon() { return new Promise(resolve => { @@ -332,7 +361,7 @@ function hideOricorioPokemon() { onComplete: () => { globalScene.field.remove(oricorioSprite, true); resolve(); - } + }, }); }); } diff --git a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts index 6e55566fe8a..6c4c8f26deb 100644 --- a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts +++ b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts @@ -9,8 +9,11 @@ import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounte import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import type { EnemyPartyConfig, EnemyPokemonConfig } from "../utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, } from "../utils/encounter-phase-utils"; -import { getRandomPlayerPokemon, getRandomSpeciesByStarterCost } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle } from "../utils/encounter-phase-utils"; +import { + getRandomPlayerPokemon, + getRandomSpeciesByStarterCost, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; @@ -93,131 +96,132 @@ const excludedBosses = [ * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3806 | GitHub Issue #3806} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const DarkDealEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.DARK_DEAL) - .withEncounterTier(MysteryEncounterTier.ROGUE) - .withIntroSpriteConfigs([ - { - spriteKey: "dark_deal_scientist", - fileRoot: "mystery-encounters", - hasShadow: true, - }, - { - spriteKey: "dark_deal_porygon", - fileRoot: "mystery-encounters", - hasShadow: true, - repeat: true, - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, - }, - ]) - .withSceneWaveRangeRequirement(30, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 pokemon in party - .withCatchAllowed(true) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:option.1.selected_dialogue`, - }, - { - text: `${namespace}:option.1.selected_message`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Removes random pokemon (including fainted) from party and adds name to dialogue data tokens - // Will never return last battle able mon and instead pick fainted/unable to battle - const removedPokemon = getRandomPlayerPokemon(true, false, true); - - // Get all the pokemon's held items - const modifiers = removedPokemon.getHeldItems().filter(m => !(m instanceof PokemonFormChangeItemModifier)); - globalScene.removePokemonFromPlayerParty(removedPokemon); - - const encounter = globalScene.currentBattle.mysteryEncounter!; - encounter.setDialogueToken("pokeName", removedPokemon.getNameToRender()); - - // Store removed pokemon types - encounter.misc = { - removedTypes: removedPokemon.getTypes(), - modifiers - }; - }) - .withOptionPhase(async () => { - // Give the player 5 Rogue Balls - const encounter = globalScene.currentBattle.mysteryEncounter!; - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.ROGUE_BALL)); - - // Start encounter with random legendary (7-10 starter strength) that has level additive - // If this is a mono-type challenge, always ensure the required type is filtered for - let bossTypes: PokemonType[] = encounter.misc.removedTypes; - const singleTypeChallenges = globalScene.gameMode.challenges.filter(c => c.value && c.id === Challenges.SINGLE_TYPE); - if (globalScene.gameMode.isChallenge && singleTypeChallenges.length > 0) { - bossTypes = singleTypeChallenges.map(c => (c.value - 1) as PokemonType); - } - - const bossModifiers: PokemonHeldItemModifier[] = encounter.misc.modifiers; - // Starter egg tier, 35/50/10/5 %odds for tiers 6/7/8/9+ - const roll = randSeedInt(100); - const starterTier: number | [number, number] = - roll >= 65 ? 6 : roll >= 15 ? 7 : roll >= 5 ? 8 : [ 9, 10 ]; - const bossSpecies = getPokemonSpecies(getRandomSpeciesByStarterCost(starterTier, excludedBosses, bossTypes)); - const pokemonConfig: EnemyPokemonConfig = { - species: bossSpecies, - isBoss: true, - modifierConfigs: bossModifiers.map(m => { - return { - modifier: m, - stackCount: m.getStackCount(), - }; - }) - }; - if (!isNullOrUndefined(bossSpecies.forms) && bossSpecies.forms.length > 0) { - pokemonConfig.formIndex = 0; - } - const config: EnemyPartyConfig = { - pokemonConfigs: [ pokemonConfig ], - }; - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, +export const DarkDealEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.DARK_DEAL, +) + .withEncounterTier(MysteryEncounterTier.ROGUE) + .withIntroSpriteConfigs([ + { + spriteKey: "dark_deal_scientist", + fileRoot: "mystery-encounters", + hasShadow: true, + }, + { + spriteKey: "dark_deal_porygon", + fileRoot: "mystery-encounters", + hasShadow: true, + repeat: true, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .withSceneWaveRangeRequirement(30, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 pokemon in party + .withCatchAllowed(true) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { speaker: `${namespace}:speaker`, - text: `${namespace}:option.2.selected`, + text: `${namespace}:option.1.selected_dialogue`, + }, + { + text: `${namespace}:option.1.selected_message`, }, ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .withOutroDialogue([ - { - text: `${namespace}:outro` - } - ]) - .build(); + }) + .withPreOptionPhase(async () => { + // Removes random pokemon (including fainted) from party and adds name to dialogue data tokens + // Will never return last battle able mon and instead pick fainted/unable to battle + const removedPokemon = getRandomPlayerPokemon(true, false, true); + + // Get all the pokemon's held items + const modifiers = removedPokemon.getHeldItems().filter(m => !(m instanceof PokemonFormChangeItemModifier)); + globalScene.removePokemonFromPlayerParty(removedPokemon); + + const encounter = globalScene.currentBattle.mysteryEncounter!; + encounter.setDialogueToken("pokeName", removedPokemon.getNameToRender()); + + // Store removed pokemon types + encounter.misc = { + removedTypes: removedPokemon.getTypes(), + modifiers, + }; + }) + .withOptionPhase(async () => { + // Give the player 5 Rogue Balls + const encounter = globalScene.currentBattle.mysteryEncounter!; + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.ROGUE_BALL)); + + // Start encounter with random legendary (7-10 starter strength) that has level additive + // If this is a mono-type challenge, always ensure the required type is filtered for + let bossTypes: PokemonType[] = encounter.misc.removedTypes; + const singleTypeChallenges = globalScene.gameMode.challenges.filter( + c => c.value && c.id === Challenges.SINGLE_TYPE, + ); + if (globalScene.gameMode.isChallenge && singleTypeChallenges.length > 0) { + bossTypes = singleTypeChallenges.map(c => (c.value - 1) as PokemonType); + } + + const bossModifiers: PokemonHeldItemModifier[] = encounter.misc.modifiers; + // Starter egg tier, 35/50/10/5 %odds for tiers 6/7/8/9+ + const roll = randSeedInt(100); + const starterTier: number | [number, number] = roll >= 65 ? 6 : roll >= 15 ? 7 : roll >= 5 ? 8 : [9, 10]; + const bossSpecies = getPokemonSpecies(getRandomSpeciesByStarterCost(starterTier, excludedBosses, bossTypes)); + const pokemonConfig: EnemyPokemonConfig = { + species: bossSpecies, + isBoss: true, + modifierConfigs: bossModifiers.map(m => { + return { + modifier: m, + stackCount: m.getStackCount(), + }; + }), + }; + if (!isNullOrUndefined(bossSpecies.forms) && bossSpecies.forms.length > 0) { + pokemonConfig.formIndex = 0; + } + const config: EnemyPartyConfig = { + pokemonConfigs: [pokemonConfig], + }; + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); diff --git a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts index f382f130540..c1486ff100b 100644 --- a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts +++ b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts @@ -2,16 +2,31 @@ import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import { CombinationPokemonRequirement, HeldItemRequirement, MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; +import { + CombinationPokemonRequirement, + HeldItemRequirement, + MoneyRequirement, +} from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + leaveEncounterWithoutBattle, + selectPokemonForOption, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import type { PokemonHeldItemModifier, PokemonInstantReviveModifier } from "#app/modifier/modifier"; -import { BerryModifier, HealingBoosterModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PreserveBerryModifier } from "#app/modifier/modifier"; +import { + BerryModifier, + HealingBoosterModifier, + LevelIncrementBoosterModifier, + MoneyMultiplierModifier, + PreserveBerryModifier, +} from "#app/modifier/modifier"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; @@ -27,7 +42,7 @@ import { Species } from "#enums/species"; const namespace = "mysteryEncounters/delibirdy"; /** Berries only */ -const OPTION_2_ALLOWED_MODIFIERS = [ "BerryModifier", "PokemonInstantReviveModifier" ]; +const OPTION_2_ALLOWED_MODIFIERS = ["BerryModifier", "PokemonInstantReviveModifier"]; /** Disallowed items are berries, Reviver Seeds, and Vitamins (form change items and fusion items are not PokemonHeldItemModifiers) */ const OPTION_3_DISALLOWED_MODIFIERS = [ @@ -35,7 +50,7 @@ const OPTION_3_DISALLOWED_MODIFIERS = [ "PokemonInstantReviveModifier", "TerastallizeModifier", "PokemonBaseStatModifier", - "PokemonBaseStatTotalModifier" + "PokemonBaseStatTotalModifier", ]; const DELIBIRDY_MONEY_PRICE_MULTIPLIER = 2; @@ -43,11 +58,11 @@ const DELIBIRDY_MONEY_PRICE_MULTIPLIER = 2; const doEventReward = () => { const event_buff = globalScene.eventManager.getDelibirdyBuff(); if (event_buff.length > 0) { - const candidates = event_buff.filter((c => { + const candidates = event_buff.filter(c => { const mtype = generateModifierType(modifierTypes[c]); const existingCharm = globalScene.findModifier(m => m.type.id === mtype?.id); return !(existingCharm && existingCharm.getStackCount() >= existingCharm.getMaxStackCount()); - })); + }); if (candidates.length > 0) { globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes[randSeedItem(candidates)])); } else { @@ -62,282 +77,308 @@ const doEventReward = () => { * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3804 | GitHub Issue #3804} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const DelibirdyEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.DELIBIRDY) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new MoneyRequirement(0, DELIBIRDY_MONEY_PRICE_MULTIPLIER)) // Must have enough money for it to spawn at the very least - .withPrimaryPokemonRequirement( - CombinationPokemonRequirement.Some( - // Must also have either option 2 or 3 available to spawn - new HeldItemRequirement(OPTION_2_ALLOWED_MODIFIERS), - new HeldItemRequirement(OPTION_3_DISALLOWED_MODIFIERS, 1, true) - ) - ) - .withIntroSpriteConfigs([ - { - spriteKey: "", - fileRoot: "", - species: Species.DELIBIRD, - hasShadow: true, - repeat: true, - startFrame: 38, - scale: 0.94 - }, - { - spriteKey: "", - fileRoot: "", - species: Species.DELIBIRD, - hasShadow: true, - repeat: true, - scale: 1.06 - }, - { - spriteKey: "", - fileRoot: "", - species: Species.DELIBIRD, - hasShadow: true, - repeat: true, - startFrame: 65, - x: 1, - y: 5, - yShadow: 5 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOutroDialogue([ - { - text: `${namespace}:outro`, - } - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - encounter.setDialogueToken("delibirdName", getPokemonSpecies(Species.DELIBIRD).getName()); +export const DelibirdyEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.DELIBIRDY, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new MoneyRequirement(0, DELIBIRDY_MONEY_PRICE_MULTIPLIER)) // Must have enough money for it to spawn at the very least + .withPrimaryPokemonRequirement( + CombinationPokemonRequirement.Some( + // Must also have either option 2 or 3 available to spawn + new HeldItemRequirement(OPTION_2_ALLOWED_MODIFIERS), + new HeldItemRequirement(OPTION_3_DISALLOWED_MODIFIERS, 1, true), + ), + ) + .withIntroSpriteConfigs([ + { + spriteKey: "", + fileRoot: "", + species: Species.DELIBIRD, + hasShadow: true, + repeat: true, + startFrame: 38, + scale: 0.94, + }, + { + spriteKey: "", + fileRoot: "", + species: Species.DELIBIRD, + hasShadow: true, + repeat: true, + scale: 1.06, + }, + { + spriteKey: "", + fileRoot: "", + species: Species.DELIBIRD, + hasShadow: true, + repeat: true, + startFrame: 65, + x: 1, + y: 5, + yShadow: 5, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + encounter.setDialogueToken("delibirdName", getPokemonSpecies(Species.DELIBIRD).getName()); - globalScene.loadBgm("mystery_encounter_delibirdy", "mystery_encounter_delibirdy.mp3"); - return true; - }) - .withOnVisualsStart(() => { - globalScene.fadeAndSwitchBgm("mystery_encounter_delibirdy"); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withSceneMoneyRequirement(0, DELIBIRDY_MONEY_PRICE_MULTIPLIER) // Must have money to spawn - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - updatePlayerMoney(-(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney, true, false); - return true; - }) - .withOptionPhase(async () => { - // Give the player an Amulet Coin - // Check if the player has max stacks of that item already - const existing = globalScene.findModifier(m => m instanceof MoneyMultiplierModifier) as MoneyMultiplierModifier; + globalScene.loadBgm("mystery_encounter_delibirdy", "mystery_encounter_delibirdy.mp3"); + return true; + }) + .withOnVisualsStart(() => { + globalScene.fadeAndSwitchBgm("mystery_encounter_delibirdy"); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withSceneMoneyRequirement(0, DELIBIRDY_MONEY_PRICE_MULTIPLIER) // Must have money to spawn + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + updatePlayerMoney(-(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney, true, false); + return true; + }) + .withOptionPhase(async () => { + // Give the player an Amulet Coin + // Check if the player has max stacks of that item already + const existing = globalScene.findModifier(m => m instanceof MoneyMultiplierModifier) as MoneyMultiplierModifier; + + if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { + // At max stacks, give the first party pokemon a Shell Bell instead + const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; + await applyModifierTypeToPlayerPokemon(globalScene.getPlayerPokemon()!, shellBell); + globalScene.playSound("item_fanfare"); + await showEncounterText( + i18next.t("battle:rewardGain", { modifierName: shellBell.name }), + null, + undefined, + true, + ); + doEventReward(); + } else { + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.AMULET_COIN)); + doEventReward(); + } + + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withPrimaryPokemonRequirement(new HeldItemRequirement(OPTION_2_ALLOWED_MODIFIERS)) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + secondOptionPrompt: `${namespace}:option.2.select_prompt`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Get Pokemon held items and filter for valid ones + const validItems = pokemon.getHeldItems().filter(it => { + return OPTION_2_ALLOWED_MODIFIERS.some(heldItem => it.constructor.name === heldItem) && it.isTransferable; + }); + + return validItems.map((modifier: PokemonHeldItemModifier) => { + const option: OptionSelectItem = { + label: modifier.type.name, + handler: () => { + // Pokemon and item selected + encounter.setDialogueToken("chosenItem", modifier.type.name); + encounter.misc = { + chosenPokemon: pokemon, + chosenModifier: modifier, + }; + return true; + }, + }; + return option; + }); + }; + + const selectableFilter = (pokemon: Pokemon) => { + // If pokemon has valid item, it can be selected + const meetsReqs = encounter.options[1].pokemonMeetsPrimaryRequirements(pokemon); + if (!meetsReqs) { + return getEncounterText(`${namespace}:invalid_selection`) ?? null; + } + + return null; + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const modifier: BerryModifier | PokemonInstantReviveModifier = encounter.misc.chosenModifier; + const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; + + // Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed + if (modifier instanceof BerryModifier) { + // Check if the player has max stacks of that Candy Jar already + const existing = globalScene.findModifier( + m => m instanceof LevelIncrementBoosterModifier, + ) as LevelIncrementBoosterModifier; if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { // At max stacks, give the first party pokemon a Shell Bell instead const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; await applyModifierTypeToPlayerPokemon(globalScene.getPlayerPokemon()!, shellBell); globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); + await showEncounterText( + i18next.t("battle:rewardGain", { + modifierName: shellBell.name, + }), + null, + undefined, + true, + ); doEventReward(); } else { - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.AMULET_COIN)); + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.CANDY_JAR)); doEventReward(); } - - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withPrimaryPokemonRequirement(new HeldItemRequirement(OPTION_2_ALLOWED_MODIFIERS)) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - secondOptionPrompt: `${namespace}:option.2.select_prompt`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Get Pokemon held items and filter for valid ones - const validItems = pokemon.getHeldItems().filter((it) => { - return OPTION_2_ALLOWED_MODIFIERS.some(heldItem => it.constructor.name === heldItem) && it.isTransferable; - }); - - return validItems.map((modifier: PokemonHeldItemModifier) => { - const option: OptionSelectItem = { - label: modifier.type.name, - handler: () => { - // Pokemon and item selected - encounter.setDialogueToken("chosenItem", modifier.type.name); - encounter.misc = { - chosenPokemon: pokemon, - chosenModifier: modifier, - }; - return true; - }, - }; - return option; - }); - }; - - const selectableFilter = (pokemon: Pokemon) => { - // If pokemon has valid item, it can be selected - const meetsReqs = encounter.options[1].pokemonMeetsPrimaryRequirements(pokemon); - if (!meetsReqs) { - return getEncounterText(`${namespace}:invalid_selection`) ?? null; - } - - return null; - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const modifier: BerryModifier | PokemonInstantReviveModifier = encounter.misc.chosenModifier; - const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; - - // Give the player a Candy Jar if they gave a Berry, and a Berry Pouch for Reviver Seed - if (modifier instanceof BerryModifier) { - // Check if the player has max stacks of that Candy Jar already - const existing = globalScene.findModifier(m => m instanceof LevelIncrementBoosterModifier) as LevelIncrementBoosterModifier; - - if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { - // At max stacks, give the first party pokemon a Shell Bell instead - const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; - await applyModifierTypeToPlayerPokemon(globalScene.getPlayerPokemon()!, shellBell); - globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); - doEventReward(); - } else { - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.CANDY_JAR)); - doEventReward(); - } - } else { - // Check if the player has max stacks of that Berry Pouch already - const existing = globalScene.findModifier(m => m instanceof PreserveBerryModifier) as PreserveBerryModifier; - - if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { - // At max stacks, give the first party pokemon a Shell Bell instead - const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; - await applyModifierTypeToPlayerPokemon(globalScene.getPlayerPokemon()!, shellBell); - globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); - doEventReward(); - } else { - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.BERRY_POUCH)); - doEventReward(); - } - } - - chosenPokemon.loseHeldItem(modifier, false); - - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withPrimaryPokemonRequirement(new HeldItemRequirement(OPTION_3_DISALLOWED_MODIFIERS, 1, true)) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - secondOptionPrompt: `${namespace}:option.3.select_prompt`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Get Pokemon held items and filter for valid ones - const validItems = pokemon.getHeldItems().filter((it) => { - return !OPTION_3_DISALLOWED_MODIFIERS.some(heldItem => it.constructor.name === heldItem) && it.isTransferable; - }); - - return validItems.map((modifier: PokemonHeldItemModifier) => { - const option: OptionSelectItem = { - label: modifier.type.name, - handler: () => { - // Pokemon and item selected - encounter.setDialogueToken("chosenItem", modifier.type.name); - encounter.misc = { - chosenPokemon: pokemon, - chosenModifier: modifier, - }; - return true; - }, - }; - return option; - }); - }; - - const selectableFilter = (pokemon: Pokemon) => { - // If pokemon has valid item, it can be selected - const meetsReqs = encounter.options[2].pokemonMeetsPrimaryRequirements(pokemon); - if (!meetsReqs) { - return getEncounterText(`${namespace}:invalid_selection`) ?? null; - } - - return null; - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const modifier = encounter.misc.chosenModifier; - const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; - - // Check if the player has max stacks of Healing Charm already - const existing = globalScene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier; + } else { + // Check if the player has max stacks of that Berry Pouch already + const existing = globalScene.findModifier(m => m instanceof PreserveBerryModifier) as PreserveBerryModifier; if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { // At max stacks, give the first party pokemon a Shell Bell instead const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; - await applyModifierTypeToPlayerPokemon(globalScene.getPlayerParty()[0], shellBell); + await applyModifierTypeToPlayerPokemon(globalScene.getPlayerPokemon()!, shellBell); globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGain", { modifierName: shellBell.name }), null, undefined, true); + await showEncounterText( + i18next.t("battle:rewardGain", { + modifierName: shellBell.name, + }), + null, + undefined, + true, + ); doEventReward(); } else { - globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.HEALING_CHARM)); + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.BERRY_POUCH)); doEventReward(); } + } - chosenPokemon.loseHeldItem(modifier, false); + chosenPokemon.loseHeldItem(modifier, false); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .build(); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withPrimaryPokemonRequirement(new HeldItemRequirement(OPTION_3_DISALLOWED_MODIFIERS, 1, true)) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + secondOptionPrompt: `${namespace}:option.3.select_prompt`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Get Pokemon held items and filter for valid ones + const validItems = pokemon.getHeldItems().filter(it => { + return ( + !OPTION_3_DISALLOWED_MODIFIERS.some(heldItem => it.constructor.name === heldItem) && it.isTransferable + ); + }); + + return validItems.map((modifier: PokemonHeldItemModifier) => { + const option: OptionSelectItem = { + label: modifier.type.name, + handler: () => { + // Pokemon and item selected + encounter.setDialogueToken("chosenItem", modifier.type.name); + encounter.misc = { + chosenPokemon: pokemon, + chosenModifier: modifier, + }; + return true; + }, + }; + return option; + }); + }; + + const selectableFilter = (pokemon: Pokemon) => { + // If pokemon has valid item, it can be selected + const meetsReqs = encounter.options[2].pokemonMeetsPrimaryRequirements(pokemon); + if (!meetsReqs) { + return getEncounterText(`${namespace}:invalid_selection`) ?? null; + } + + return null; + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const modifier = encounter.misc.chosenModifier; + const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; + + // Check if the player has max stacks of Healing Charm already + const existing = globalScene.findModifier(m => m instanceof HealingBoosterModifier) as HealingBoosterModifier; + + if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { + // At max stacks, give the first party pokemon a Shell Bell instead + const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; + await applyModifierTypeToPlayerPokemon(globalScene.getPlayerParty()[0], shellBell); + globalScene.playSound("item_fanfare"); + await showEncounterText( + i18next.t("battle:rewardGain", { modifierName: shellBell.name }), + null, + undefined, + true, + ); + doEventReward(); + } else { + globalScene.unshiftPhase(new ModifierRewardPhase(modifierTypes.HEALING_CHARM)); + doEventReward(); + } + + chosenPokemon.loseHeldItem(modifier, false); + + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .build(); 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 b2bc13ca744..9b8e2e24d12 100644 --- a/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts +++ b/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts @@ -8,9 +8,7 @@ import { randSeedInt } from "#app/utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; -import { - MysteryEncounterBuilder, -} from "#app/data/mystery-encounters/mystery-encounter"; +import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; @@ -22,145 +20,158 @@ const namespace = "mysteryEncounters/departmentStoreSale"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3797 | GitHub Issue #3797} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const DepartmentStoreSaleEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.DEPARTMENT_STORE_SALE) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[0], 100) - .withIntroSpriteConfigs([ - { - spriteKey: "department_store_sale_lady", - fileRoot: "mystery-encounters", - hasShadow: true, - x: -20, - }, - { - spriteKey: "", - fileRoot: "", - species: Species.FURFROU, - hasShadow: true, - repeat: true, - x: 30, - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker`, - }, - ]) - .withAutoHideIntroVisuals(false) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - }, - async () => { - // Choose TMs - const modifiers: ModifierTypeFunc[] = []; - let i = 0; - while (i < 5) { - // 2/2/1 weight on TM rarity - const roll = randSeedInt(5); - if (roll < 2) { - modifiers.push(modifierTypes.TM_COMMON); - } else if (roll < 4) { - modifiers.push(modifierTypes.TM_GREAT); - } else { - modifiers.push(modifierTypes.TM_ULTRA); - } - i++; +export const DepartmentStoreSaleEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.DEPARTMENT_STORE_SALE, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[0], 100) + .withIntroSpriteConfigs([ + { + spriteKey: "department_store_sale_lady", + fileRoot: "mystery-encounters", + hasShadow: true, + x: -20, + }, + { + spriteKey: "", + fileRoot: "", + species: Species.FURFROU, + hasShadow: true, + repeat: true, + x: 30, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .withAutoHideIntroVisuals(false) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + }, + async () => { + // Choose TMs + const modifiers: ModifierTypeFunc[] = []; + let i = 0; + while (i < 5) { + // 2/2/1 weight on TM rarity + const roll = randSeedInt(5); + if (roll < 2) { + modifiers.push(modifierTypes.TM_COMMON); + } else if (roll < 4) { + modifiers.push(modifierTypes.TM_GREAT); + } else { + modifiers.push(modifierTypes.TM_ULTRA); } - - setEncounterRewards({ guaranteedModifierTypeFuncs: modifiers, fillRemaining: false, }); - leaveEncounterWithoutBattle(); + i++; } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - }, - async () => { - // Choose Vitamins - const modifiers: ModifierTypeFunc[] = []; - let i = 0; - while (i < 3) { - // 2/1 weight on base stat booster vs PP Up - const roll = randSeedInt(3); - if (roll === 0) { - modifiers.push(modifierTypes.PP_UP); - } else { - modifiers.push(modifierTypes.BASE_STAT_BOOSTER); - } - i++; + + setEncounterRewards({ + guaranteedModifierTypeFuncs: modifiers, + fillRemaining: false, + }); + leaveEncounterWithoutBattle(); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + }, + async () => { + // Choose Vitamins + const modifiers: ModifierTypeFunc[] = []; + let i = 0; + while (i < 3) { + // 2/1 weight on base stat booster vs PP Up + const roll = randSeedInt(3); + if (roll === 0) { + modifiers.push(modifierTypes.PP_UP); + } else { + modifiers.push(modifierTypes.BASE_STAT_BOOSTER); } - - setEncounterRewards({ guaranteedModifierTypeFuncs: modifiers, fillRemaining: false, }); - leaveEncounterWithoutBattle(); + i++; } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - }, - async () => { - // Choose X Items - const modifiers: ModifierTypeFunc[] = []; - let i = 0; - while (i < 5) { - // 4/1 weight on base stat booster vs Dire Hit - const roll = randSeedInt(5); - if (roll === 0) { - modifiers.push(modifierTypes.DIRE_HIT); - } else { - modifiers.push(modifierTypes.TEMP_STAT_STAGE_BOOSTER); - } - i++; + + setEncounterRewards({ + guaranteedModifierTypeFuncs: modifiers, + fillRemaining: false, + }); + leaveEncounterWithoutBattle(); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + }, + async () => { + // Choose X Items + const modifiers: ModifierTypeFunc[] = []; + let i = 0; + while (i < 5) { + // 4/1 weight on base stat booster vs Dire Hit + const roll = randSeedInt(5); + if (roll === 0) { + modifiers.push(modifierTypes.DIRE_HIT); + } else { + modifiers.push(modifierTypes.TEMP_STAT_STAGE_BOOSTER); } - - setEncounterRewards({ guaranteedModifierTypeFuncs: modifiers, fillRemaining: false, }); - leaveEncounterWithoutBattle(); + i++; } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.4.label`, - buttonTooltip: `${namespace}:option.4.tooltip`, - }, - async () => { - // Choose Pokeballs - const modifiers: ModifierTypeFunc[] = []; - let i = 0; - while (i < 4) { - // 10/30/20/5 weight on pokeballs - const roll = randSeedInt(65); - if (roll < 10) { - modifiers.push(modifierTypes.POKEBALL); - } else if (roll < 40) { - modifiers.push(modifierTypes.GREAT_BALL); - } else if (roll < 60) { - modifiers.push(modifierTypes.ULTRA_BALL); - } else { - modifiers.push(modifierTypes.ROGUE_BALL); - } - i++; + + setEncounterRewards({ + guaranteedModifierTypeFuncs: modifiers, + fillRemaining: false, + }); + leaveEncounterWithoutBattle(); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.4.label`, + buttonTooltip: `${namespace}:option.4.tooltip`, + }, + async () => { + // Choose Pokeballs + const modifiers: ModifierTypeFunc[] = []; + let i = 0; + while (i < 4) { + // 10/30/20/5 weight on pokeballs + const roll = randSeedInt(65); + if (roll < 10) { + modifiers.push(modifierTypes.POKEBALL); + } else if (roll < 40) { + modifiers.push(modifierTypes.GREAT_BALL); + } else if (roll < 60) { + modifiers.push(modifierTypes.ULTRA_BALL); + } else { + modifiers.push(modifierTypes.ROGUE_BALL); } + i++; + } - setEncounterRewards({ guaranteedModifierTypeFuncs: modifiers, fillRemaining: false, }); - leaveEncounterWithoutBattle(); - } - ) - .withOutroDialogue([ - { - text: `${namespace}:outro`, - } - ]) - .build(); + setEncounterRewards({ + guaranteedModifierTypeFuncs: modifiers, + fillRemaining: false, + }); + leaveEncounterWithoutBattle(); + }, + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); diff --git a/src/data/mystery-encounters/encounters/field-trip-encounter.ts b/src/data/mystery-encounters/encounters/field-trip-encounter.ts index 0e5d6ff87bc..a1964aa5ab4 100644 --- a/src/data/mystery-encounters/encounters/field-trip-encounter.ts +++ b/src/data/mystery-encounters/encounters/field-trip-encounter.ts @@ -1,6 +1,12 @@ import { MoveCategory } from "#enums/MoveCategory"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import { generateModifierTypeOption, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterExp, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierTypeOption, + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterExp, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PlayerPokemon, PokemonMove } from "#app/field/pokemon"; import { modifierTypes } from "#app/modifier/modifier-type"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; @@ -22,180 +28,187 @@ const namespace = "mysteryEncounters/fieldTrip"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3794 | GitHub Issue #3794} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const FieldTripEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.FIELD_TRIP) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[0], 100) - .withIntroSpriteConfigs([ - { - spriteKey: "preschooler_m", - fileRoot: "trainer", - hasShadow: true, - }, - { - spriteKey: "field_trip_teacher", - fileRoot: "mystery-encounters", - hasShadow: true, - }, - { - spriteKey: "preschooler_f", - fileRoot: "trainer", - hasShadow: true, - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker`, - }, - ]) - .withAutoHideIntroVisuals(false) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - secondOptionPrompt: `${namespace}:second_option_prompt`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for Pokemon move valid for this option - return pokemon.moveset.map((move: PokemonMove) => { - const option: OptionSelectItem = { - label: move.getName(), - handler: () => { - // Pokemon and move selected - encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:physical`)); - pokemonAndMoveChosen(pokemon, move, MoveCategory.PHYSICAL); - return true; - }, - }; - return option; - }); - }; +export const FieldTripEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.FIELD_TRIP, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[0], 100) + .withIntroSpriteConfigs([ + { + spriteKey: "preschooler_m", + fileRoot: "trainer", + hasShadow: true, + }, + { + spriteKey: "field_trip_teacher", + fileRoot: "mystery-encounters", + hasShadow: true, + }, + { + spriteKey: "preschooler_f", + fileRoot: "trainer", + hasShadow: true, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .withAutoHideIntroVisuals(false) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + secondOptionPrompt: `${namespace}:second_option_prompt`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for Pokemon move valid for this option + return pokemon.moveset.map((move: PokemonMove) => { + const option: OptionSelectItem = { + label: move.getName(), + handler: () => { + // Pokemon and move selected + encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:physical`)); + pokemonAndMoveChosen(pokemon, move, MoveCategory.PHYSICAL); + return true; + }, + }; + return option; + }); + }; - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - if (encounter.misc.correctMove) { - const modifiers = [ - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.ATK ])!, - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.DEF ])!, - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.SPD ])!, - generateModifierTypeOption(modifierTypes.DIRE_HIT)!, - generateModifierTypeOption(modifierTypes.RARER_CANDY)!, - ]; + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + if (encounter.misc.correctMove) { + const modifiers = [ + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.ATK])!, + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.DEF])!, + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.SPD])!, + generateModifierTypeOption(modifierTypes.DIRE_HIT)!, + generateModifierTypeOption(modifierTypes.RARER_CANDY)!, + ]; - setEncounterRewards({ guaranteedModifierTypeOptions: modifiers, fillRemaining: false }); - } + setEncounterRewards({ + guaranteedModifierTypeOptions: modifiers, + fillRemaining: false, + }); + } - leaveEncounterWithoutBattle(!encounter.misc.correctMove); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - secondOptionPrompt: `${namespace}:second_option_prompt`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for Pokemon move valid for this option - return pokemon.moveset.map((move: PokemonMove) => { - const option: OptionSelectItem = { - label: move.getName(), - handler: () => { - // Pokemon and move selected - encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:special`)); - pokemonAndMoveChosen(pokemon, move, MoveCategory.SPECIAL); - return true; - }, - }; - return option; - }); - }; + leaveEncounterWithoutBattle(!encounter.misc.correctMove); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + secondOptionPrompt: `${namespace}:second_option_prompt`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for Pokemon move valid for this option + return pokemon.moveset.map((move: PokemonMove) => { + const option: OptionSelectItem = { + label: move.getName(), + handler: () => { + // Pokemon and move selected + encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:special`)); + pokemonAndMoveChosen(pokemon, move, MoveCategory.SPECIAL); + return true; + }, + }; + return option; + }); + }; - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - if (encounter.misc.correctMove) { - const modifiers = [ - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.SPATK ])!, - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.SPDEF ])!, - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.SPD ])!, - generateModifierTypeOption(modifierTypes.DIRE_HIT)!, - generateModifierTypeOption(modifierTypes.RARER_CANDY)!, - ]; + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + if (encounter.misc.correctMove) { + const modifiers = [ + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.SPATK])!, + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.SPDEF])!, + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.SPD])!, + generateModifierTypeOption(modifierTypes.DIRE_HIT)!, + generateModifierTypeOption(modifierTypes.RARER_CANDY)!, + ]; - setEncounterRewards({ guaranteedModifierTypeOptions: modifiers, fillRemaining: false }); - } + setEncounterRewards({ + guaranteedModifierTypeOptions: modifiers, + fillRemaining: false, + }); + } - leaveEncounterWithoutBattle(!encounter.misc.correctMove); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - secondOptionPrompt: `${namespace}:second_option_prompt`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for Pokemon move valid for this option - return pokemon.moveset.map((move: PokemonMove) => { - const option: OptionSelectItem = { - label: move.getName(), - handler: () => { - // Pokemon and move selected - encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:status`)); - pokemonAndMoveChosen(pokemon, move, MoveCategory.STATUS); - return true; - }, - }; - return option; - }); - }; + leaveEncounterWithoutBattle(!encounter.misc.correctMove); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + secondOptionPrompt: `${namespace}:second_option_prompt`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for Pokemon move valid for this option + return pokemon.moveset.map((move: PokemonMove) => { + const option: OptionSelectItem = { + label: move.getName(), + handler: () => { + // Pokemon and move selected + encounter.setDialogueToken("moveCategory", i18next.t(`${namespace}:status`)); + pokemonAndMoveChosen(pokemon, move, MoveCategory.STATUS); + return true; + }, + }; + return option; + }); + }; - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - if (encounter.misc.correctMove) { - const modifiers = [ - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.ACC ])!, - generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [ Stat.SPD ])!, - generateModifierTypeOption(modifierTypes.GREAT_BALL)!, - generateModifierTypeOption(modifierTypes.IV_SCANNER)!, - generateModifierTypeOption(modifierTypes.RARER_CANDY)!, - ]; + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + if (encounter.misc.correctMove) { + const modifiers = [ + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.ACC])!, + generateModifierTypeOption(modifierTypes.TEMP_STAT_STAGE_BOOSTER, [Stat.SPD])!, + generateModifierTypeOption(modifierTypes.GREAT_BALL)!, + generateModifierTypeOption(modifierTypes.IV_SCANNER)!, + generateModifierTypeOption(modifierTypes.RARER_CANDY)!, + ]; - setEncounterRewards({ guaranteedModifierTypeOptions: modifiers, fillRemaining: false }); - } + setEncounterRewards({ + guaranteedModifierTypeOptions: modifiers, + fillRemaining: false, + }); + } - leaveEncounterWithoutBattle(!encounter.misc.correctMove); - }) - .build() - ) - .build(); + leaveEncounterWithoutBattle(!encounter.misc.correctMove); + }) + .build(), + ) + .build(); function pokemonAndMoveChosen(pokemon: PlayerPokemon, move: PokemonMove, correctMoveCategory: MoveCategory) { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -215,7 +228,10 @@ function pokemonAndMoveChosen(pokemon: PlayerPokemon, move: PokemonMove, correct text: `${namespace}:incorrect_exp`, }, ]; - setEncounterExp(globalScene.getPlayerParty().map((p) => p.id), 50); + setEncounterExp( + globalScene.getPlayerParty().map(p => p.id), + 50, + ); } else { encounter.selectedOption!.dialogue!.selected = [ { @@ -229,7 +245,7 @@ function pokemonAndMoveChosen(pokemon: PlayerPokemon, move: PokemonMove, correct text: `${namespace}:correct_exp`, }, ]; - setEncounterExp([ pokemon.id ], 100); + setEncounterExp([pokemon.id], 100); } encounter.misc = { correctMove: correctMove, diff --git a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts index 1f425dc9ea9..d9bd6983d97 100644 --- a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts +++ b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts @@ -1,13 +1,25 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, loadCustomMovesForEncounter, leaveEncounterWithoutBattle, setEncounterExp, setEncounterRewards, transitionMysteryEncounterIntroVisuals, generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + initBattleWithEnemyConfig, + loadCustomMovesForEncounter, + leaveEncounterWithoutBattle, + setEncounterExp, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, + generateModifierType, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes, } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; -import { AbilityRequirement, CombinationPokemonRequirement, TypeRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; +import { + AbilityRequirement, + CombinationPokemonRequirement, + TypeRequirement, +} from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { Species } from "#enums/species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { Gender } from "#app/data/gender"; @@ -21,7 +33,11 @@ import { WeatherType } from "#enums/weather-type"; import { isNullOrUndefined, randSeedInt } from "#app/utils"; import { StatusEffect } from "#enums/status-effect"; import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { applyAbilityOverrideToPokemon, applyDamageToPokemon, applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + applyAbilityOverrideToPokemon, + applyDamageToPokemon, + applyModifierTypeToPlayerPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { EncounterAnim } from "#enums/encounter-anims"; @@ -48,216 +64,230 @@ const DAMAGE_PERCENTAGE: number = 20; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3814 | GitHub Issue #3814} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const FieryFalloutEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.FIERY_FALLOUT) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(40, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withCatchAllowed(true) - .withIntroSpriteConfigs([]) // Set in onInit() - .withAnimations(EncounterAnim.MAGMA_BG, EncounterAnim.MAGMA_SPOUT) - .withAutoHideIntroVisuals(false) - .withFleeAllowed(false) - .withIntroDialogue([ +export const FieryFalloutEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.FIERY_FALLOUT, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(40, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withCatchAllowed(true) + .withIntroSpriteConfigs([]) // Set in onInit() + .withAnimations(EncounterAnim.MAGMA_BG, EncounterAnim.MAGMA_SPOUT) + .withAutoHideIntroVisuals(false) + .withFleeAllowed(false) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + + // Calculate boss mons + const volcaronaSpecies = getPokemonSpecies(Species.VOLCARONA); + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { + species: volcaronaSpecies, + isBoss: false, + gender: Gender.MALE, + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: (pokemon: Pokemon) => { + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.SPDEF, Stat.SPD], 1), + ); + }, + }, + { + species: volcaronaSpecies, + isBoss: false, + gender: Gender.FEMALE, + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: (pokemon: Pokemon) => { + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.SPDEF, Stat.SPD], 1), + ); + }, + }, + ], + doubleBattle: true, + disableSwitch: true, + }; + encounter.enemyPartyConfigs = [config]; + + // Load hidden Volcarona sprites + encounter.spriteConfigs = [ { - text: `${namespace}:intro`, + spriteKey: "", + fileRoot: "", + species: Species.VOLCARONA, + repeat: true, + hidden: true, + hasShadow: true, + x: -20, + startFrame: 20, }, - ]) - .withOnInit(() => { + { + spriteKey: "", + fileRoot: "", + species: Species.VOLCARONA, + repeat: true, + hidden: true, + hasShadow: true, + x: 20, + }, + ]; + + // Load animations/sfx for Volcarona moves + loadCustomMovesForEncounter([Moves.FIRE_SPIN, Moves.QUIVER_DANCE]); + + globalScene.arena.trySetWeather(WeatherType.SUNNY, true); + + encounter.setDialogueToken("volcaronaName", getPokemonSpecies(Species.VOLCARONA).getName()); + + return true; + }) + .withOnVisualsStart(() => { + // Play animations + const background = new EncounterBattleAnim( + EncounterAnim.MAGMA_BG, + globalScene.getPlayerPokemon()!, + globalScene.getPlayerPokemon(), + ); + background.playWithoutTargets(200, 70, 2, 3); + const animation = new EncounterBattleAnim( + EncounterAnim.MAGMA_SPOUT, + globalScene.getPlayerPokemon()!, + globalScene.getPlayerPokemon(), + ); + animation.playWithoutTargets(80, 100, 2); + globalScene.time.delayedCall(600, () => { + animation.playWithoutTargets(-20, 100, 2); + }); + globalScene.time.delayedCall(1200, () => { + animation.playWithoutTargets(140, 150, 2); + }); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Pick battle const encounter = globalScene.currentBattle.mysteryEncounter!; + setEncounterRewards({ fillRemaining: true }, undefined, () => giveLeadPokemonAttackTypeBoostItem()); - // Calculate boss mons - const volcaronaSpecies = getPokemonSpecies(Species.VOLCARONA); - const config: EnemyPartyConfig = { - pokemonConfigs: [ - { - species: volcaronaSpecies, - isBoss: false, - gender: Gender.MALE, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: (pokemon: Pokemon) => { - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.SPDEF, Stat.SPD ], 1)); - } - }, - { - species: volcaronaSpecies, - isBoss: false, - gender: Gender.FEMALE, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: (pokemon: Pokemon) => { - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.SPDEF, Stat.SPD ], 1)); - } - } - ], - doubleBattle: true, - disableSwitch: true, - }; - encounter.enemyPartyConfigs = [ config ]; - - // Load hidden Volcarona sprites - encounter.spriteConfigs = [ + encounter.startOfBattleEffects.push( { - spriteKey: "", - fileRoot: "", - species: Species.VOLCARONA, - repeat: true, - hidden: true, - hasShadow: true, - x: -20, - startFrame: 20 + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.FIRE_SPIN), + ignorePp: true, }, { - spriteKey: "", - fileRoot: "", - species: Species.VOLCARONA, - repeat: true, - hidden: true, - hasShadow: true, - x: 20 + sourceBattlerIndex: BattlerIndex.ENEMY_2, + targets: [BattlerIndex.PLAYER_2], + move: new PokemonMove(Moves.FIRE_SPIN), + ignorePp: true, }, - ]; + ); + await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Damage non-fire types and burn 1 random non-fire type member + give it Heatproof + const encounter = globalScene.currentBattle.mysteryEncounter!; + const nonFireTypes = globalScene + .getPlayerParty() + .filter(p => p.isAllowedInBattle() && !p.getTypes().includes(PokemonType.FIRE)); - // Load animations/sfx for Volcarona moves - loadCustomMovesForEncounter([ Moves.FIRE_SPIN, Moves.QUIVER_DANCE ]); + for (const pkm of nonFireTypes) { + const percentage = DAMAGE_PERCENTAGE / 100; + const damage = Math.floor(pkm.getMaxHp() * percentage); + applyDamageToPokemon(pkm, damage); + } - globalScene.arena.trySetWeather(WeatherType.SUNNY, true); + // Burn random member + const burnable = nonFireTypes.filter( + p => isNullOrUndefined(p.status) || isNullOrUndefined(p.status.effect) || p.status.effect === StatusEffect.NONE, + ); + if (burnable?.length > 0) { + const roll = randSeedInt(burnable.length); + const chosenPokemon = burnable[roll]; + if (chosenPokemon.trySetStatus(StatusEffect.BURN)) { + // Burn applied + encounter.setDialogueToken("burnedPokemon", chosenPokemon.getNameToRender()); + encounter.setDialogueToken("abilityName", new Ability(Abilities.HEATPROOF, 3).name); + queueEncounterMessage(`${namespace}:option.2.target_burned`); - encounter.setDialogueToken("volcaronaName", getPokemonSpecies(Species.VOLCARONA).getName()); + // Also permanently change the burned Pokemon's ability to Heatproof + applyAbilityOverrideToPokemon(chosenPokemon, Abilities.HEATPROOF); + } + } - return true; - }) - .withOnVisualsStart(() => { - // Play animations - const background = new EncounterBattleAnim(EncounterAnim.MAGMA_BG, globalScene.getPlayerPokemon()!, globalScene.getPlayerPokemon()); - background.playWithoutTargets(200, 70, 2, 3); - const animation = new EncounterBattleAnim(EncounterAnim.MAGMA_SPOUT, globalScene.getPlayerPokemon()!, globalScene.getPlayerPokemon()); - animation.playWithoutTargets(80, 100, 2); - globalScene.time.delayedCall(600, () => { - animation.playWithoutTargets(-20, 100, 2); - }); - globalScene.time.delayedCall(1200, () => { - animation.playWithoutTargets(140, 150, 2); - }); - - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, + // No rewards + leaveEncounterWithoutBattle(true); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement( + CombinationPokemonRequirement.Some( + new TypeRequirement(PokemonType.FIRE, true, 1), + new AbilityRequirement(FIRE_RESISTANT_ABILITIES, true), + ), + ) // Will set option3PrimaryName dialogue token automatically + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, selected: [ { - text: `${namespace}:option.1.selected`, + text: `${namespace}:option.3.selected`, }, ], - }, - async () => { - // Pick battle + }) + .withPreOptionPhase(async () => { + // Do NOT await this, to prevent player from repeatedly pressing options + transitionMysteryEncounterIntroVisuals(false, false, 2000); + }) + .withOptionPhase(async () => { + // Fire types help calm the Volcarona const encounter = globalScene.currentBattle.mysteryEncounter!; - setEncounterRewards({ fillRemaining: true }, undefined, () => giveLeadPokemonAttackTypeBoostItem()); + await transitionMysteryEncounterIntroVisuals(); + setEncounterRewards({ fillRemaining: true }, undefined, () => { + giveLeadPokemonAttackTypeBoostItem(); + }); - encounter.startOfBattleEffects.push( - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.FIRE_SPIN), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY_2, - targets: [ BattlerIndex.PLAYER_2 ], - move: new PokemonMove(Moves.FIRE_SPIN), - ignorePp: true - }); - await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Damage non-fire types and burn 1 random non-fire type member + give it Heatproof - const encounter = globalScene.currentBattle.mysteryEncounter!; - const nonFireTypes = globalScene.getPlayerParty().filter((p) => p.isAllowedInBattle() && !p.getTypes().includes(PokemonType.FIRE)); + const primary = encounter.options[2].primaryPokemon!; - for (const pkm of nonFireTypes) { - const percentage = DAMAGE_PERCENTAGE / 100; - const damage = Math.floor(pkm.getMaxHp() * percentage); - applyDamageToPokemon(pkm, damage); - } - - // Burn random member - const burnable = nonFireTypes.filter(p => isNullOrUndefined(p.status) || isNullOrUndefined(p.status.effect) || p.status.effect === StatusEffect.NONE); - if (burnable?.length > 0) { - const roll = randSeedInt(burnable.length); - const chosenPokemon = burnable[roll]; - if (chosenPokemon.trySetStatus(StatusEffect.BURN)) { - // Burn applied - encounter.setDialogueToken("burnedPokemon", chosenPokemon.getNameToRender()); - encounter.setDialogueToken("abilityName", new Ability(Abilities.HEATPROOF, 3).name); - queueEncounterMessage(`${namespace}:option.2.target_burned`); - - // Also permanently change the burned Pokemon's ability to Heatproof - applyAbilityOverrideToPokemon(chosenPokemon, Abilities.HEATPROOF); - } - } - - // No rewards - leaveEncounterWithoutBattle(true); - } - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement( - CombinationPokemonRequirement.Some( - new TypeRequirement(PokemonType.FIRE, true, 1), - new AbilityRequirement(FIRE_RESISTANT_ABILITIES, true) - ) - ) // Will set option3PrimaryName dialogue token automatically - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Do NOT await this, to prevent player from repeatedly pressing options - transitionMysteryEncounterIntroVisuals(false, false, 2000); - }) - .withOptionPhase(async () => { - // Fire types help calm the Volcarona - const encounter = globalScene.currentBattle.mysteryEncounter!; - await transitionMysteryEncounterIntroVisuals(); - setEncounterRewards( - { fillRemaining: true }, - undefined, - () => { - giveLeadPokemonAttackTypeBoostItem(); - }); - - const primary = encounter.options[2].primaryPokemon!; - - setEncounterExp([ primary.id ], getPokemonSpecies(Species.VOLCARONA).baseExp * 2); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .build(); + setEncounterExp([primary.id], getPokemonSpecies(Species.VOLCARONA).baseExp * 2); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .build(); function giveLeadPokemonAttackTypeBoostItem() { // Give first party pokemon attack type boost item for free at end of battle @@ -266,7 +296,9 @@ function giveLeadPokemonAttackTypeBoostItem() { // Generate type booster held item, default to Charcoal if item fails to generate let boosterModifierType = generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER) as AttackTypeBoosterModifierType; if (!boosterModifierType) { - boosterModifierType = generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.FIRE ]) as AttackTypeBoosterModifierType; + boosterModifierType = generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ + PokemonType.FIRE, + ]) as AttackTypeBoosterModifierType; } applyModifierTypeToPlayerPokemon(leadPokemon, boosterModifierType); 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 1667a15e7c9..595d13cf727 100644 --- a/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts +++ b/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts @@ -1,18 +1,16 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import type { - EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { getRandomEncounterSpecies, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterExp, - setEncounterRewards + setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { STEALING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import type Pokemon from "#app/field/pokemon"; import { ModifierTier } from "#app/modifier/modifier-tier"; -import type { - ModifierTypeOption } from "#app/modifier/modifier-type"; +import type { ModifierTypeOption } from "#app/modifier/modifier-type"; import { getPlayerModifierTypeOptions, ModifierPoolType, @@ -25,7 +23,11 @@ import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-en import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { getEncounterPokemonLevelForWave, getSpriteKeysFromPokemon, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + getEncounterPokemonLevelForWave, + getSpriteKeysFromPokemon, + STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; 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"; @@ -41,152 +43,163 @@ const namespace = "mysteryEncounters/fightOrFlight"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3795 | GitHub Issue #3795} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const FightOrFlightEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.FIGHT_OR_FLIGHT) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withCatchAllowed(true) - .withHideWildIntroMessage(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([]) // Set in onInit() - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const FightOrFlightEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.FIGHT_OR_FLIGHT, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withCatchAllowed(true) + .withHideWildIntroMessage(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([]) // Set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculate boss mon - const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); - const bossPokemon = getRandomEncounterSpecies(level, true); - encounter.setDialogueToken("enemyPokemon", bossPokemon.getNameToRender()); - const config: EnemyPartyConfig = { - pokemonConfigs: [{ + // Calculate boss mon + const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); + const bossPokemon = getRandomEncounterSpecies(level, true); + encounter.setDialogueToken("enemyPokemon", bossPokemon.getNameToRender()); + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { level: level, species: bossPokemon.species, dataSource: new PokemonData(bossPokemon), isBoss: true, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], mysteryEncounterBattleEffects: (pokemon: Pokemon) => { queueEncounterMessage(`${namespace}:option.1.stat_boost`); // Randomly boost 1 stat 2 stages // Cannot boost Spd, Acc, or Evasion - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ randSeedInt(4, 1) ], 2)); - } - }], - }; - encounter.enemyPartyConfigs = [ config ]; - - // Calculate item - // Waves 10-40 GREAT, 60-120 ULTRA, 120-160 ROGUE, 160-180 MASTER - const tier = - globalScene.currentBattle.waveIndex > 160 - ? ModifierTier.MASTER - : globalScene.currentBattle.waveIndex > 120 - ? ModifierTier.ROGUE - : globalScene.currentBattle.waveIndex > 40 - ? ModifierTier.ULTRA - : ModifierTier.GREAT; - regenerateModifierPoolThresholds(globalScene.getPlayerParty(), ModifierPoolType.PLAYER, 0); - let item: ModifierTypeOption | null = null; - // TMs and Candy Jar excluded from possible rewards as they're too swingy in value for a singular item reward - while (!item || item.type.id.includes("TM_") || item.type.id === "CANDY_JAR") { - item = getPlayerModifierTypeOptions(1, globalScene.getPlayerParty(), [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0]; - } - encounter.setDialogueToken("itemName", item.type.name); - encounter.misc = item; - - const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon); - encounter.spriteConfigs = [ - { - spriteKey: item.type.iconImage, - fileRoot: "items", - hasShadow: false, - x: 35, - y: -5, - scale: 0.75, - isItem: true, - disableAnimation: true + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [randSeedInt(4, 1)], 2)); + }, }, - { - spriteKey: spriteKey, - fileRoot: fileRoot, - hasShadow: true, - tint: 0.25, - x: -5, - repeat: true, - isPokemon: true, - isShiny: bossPokemon.shiny, - variant: bossPokemon.variant - }, - ]; + ], + }; + encounter.enemyPartyConfigs = [config]; - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( + // Calculate item + // Waves 10-40 GREAT, 60-120 ULTRA, 120-160 ROGUE, 160-180 MASTER + const tier = + globalScene.currentBattle.waveIndex > 160 + ? ModifierTier.MASTER + : globalScene.currentBattle.waveIndex > 120 + ? ModifierTier.ROGUE + : globalScene.currentBattle.waveIndex > 40 + ? ModifierTier.ULTRA + : ModifierTier.GREAT; + regenerateModifierPoolThresholds(globalScene.getPlayerParty(), ModifierPoolType.PLAYER, 0); + let item: ModifierTypeOption | null = null; + // TMs and Candy Jar excluded from possible rewards as they're too swingy in value for a singular item reward + while (!item || item.type.id.includes("TM_") || item.type.id === "CANDY_JAR") { + item = getPlayerModifierTypeOptions(1, globalScene.getPlayerParty(), [], { + guaranteedModifierTiers: [tier], + allowLuckUpgrades: false, + })[0]; + } + encounter.setDialogueToken("itemName", item.type.name); + encounter.misc = item; + + const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon); + encounter.spriteConfigs = [ { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, + spriteKey: item.type.iconImage, + fileRoot: "items", + hasShadow: false, + x: 35, + y: -5, + scale: 0.75, + isItem: true, + disableAnimation: true, + }, + { + spriteKey: spriteKey, + fileRoot: fileRoot, + hasShadow: true, + tint: 0.25, + x: -5, + repeat: true, + isPokemon: true, + isShiny: bossPokemon.shiny, + variant: bossPokemon.variant, + }, + ]; + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Pick battle + // Pokemon will randomly boost 1 stat by 2 stages + const item = globalScene.currentBattle.mysteryEncounter!.misc as ModifierTypeOption; + setEncounterRewards({ + guaranteedModifierTypeOptions: [item], + fillRemaining: false, + }); + await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement(new MoveRequirement(STEALING_MOVES, true)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, selected: [ { - text: `${namespace}:option.1.selected`, + text: `${namespace}:option.2.selected`, }, ], - }, - async () => { - // Pick battle - // Pokemon will randomly boost 1 stat by 2 stages + }) + .withOptionPhase(async () => { + // Pick steal + const encounter = globalScene.currentBattle.mysteryEncounter!; const item = globalScene.currentBattle.mysteryEncounter!.misc as ModifierTypeOption; - setEncounterRewards({ guaranteedModifierTypeOptions: [ item ], fillRemaining: false }); - await initBattleWithEnemyConfig(globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0]); - } - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement(new MoveRequirement(STEALING_MOVES, true)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected` - } - ] - }) - .withOptionPhase(async () => { - // Pick steal - const encounter = globalScene.currentBattle.mysteryEncounter!; - const item = globalScene.currentBattle.mysteryEncounter!.misc as ModifierTypeOption; - setEncounterRewards({ guaranteedModifierTypeOptions: [ item ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeOptions: [item], + fillRemaining: false, + }); - // Use primaryPokemon to execute the thievery - const primaryPokemon = encounter.options[1].primaryPokemon!; - setEncounterExp(primaryPokemon.id, encounter.enemyPartyConfigs[0].pokemonConfigs![0].species.baseExp); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + // Use primaryPokemon to execute the thievery + const primaryPokemon = encounter.options[1].primaryPokemon!; + setEncounterExp(primaryPokemon.id, encounter.enemyPartyConfigs[0].pokemonConfigs![0].species.baseExp); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts b/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts index 287376f8bd0..c95810b94d0 100644 --- a/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts +++ b/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts @@ -1,4 +1,10 @@ -import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards, transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -35,64 +41,65 @@ const namespace = "mysteryEncounters/funAndGames"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3819 | GitHub Issue #3819} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const FunAndGamesEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.FUN_AND_GAMES) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new MoneyRequirement(0, 1.5)) // Cost equal to 1 Max Potion to play - .withAutoHideIntroVisuals(false) - // The Wobbuffet won't use moves - .withSkipEnemyBattleTurns(true) - // Will skip COMMAND selection menu and go straight to FIGHT (move select) menu - .withSkipToFightInput(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - spriteKey: "fun_and_games_game", - fileRoot: "mystery-encounters", - hasShadow: false, - x: 0, - y: 6, - }, - { - spriteKey: "fun_and_games_wobbuffet", - fileRoot: "mystery-encounters", - hasShadow: true, - x: -28, - y: 6, - yShadow: 6 - }, - { - spriteKey: "fun_and_games_man", - fileRoot: "mystery-encounters", - hasShadow: true, - x: 40, - y: 6, - yShadow: 6 - }, - ]) - .withIntroDialogue([ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - globalScene.loadBgm("mystery_encounter_fun_and_games", "mystery_encounter_fun_and_games.mp3"); - encounter.setDialogueToken("wobbuffetName", getPokemonSpecies(Species.WOBBUFFET).getName()); - return true; - }) - .withOnVisualsStart(() => { - globalScene.fadeAndSwitchBgm("mystery_encounter_fun_and_games"); - return true; - }) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) +export const FunAndGamesEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.FUN_AND_GAMES, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new MoneyRequirement(0, 1.5)) // Cost equal to 1 Max Potion to play + .withAutoHideIntroVisuals(false) + // The Wobbuffet won't use moves + .withSkipEnemyBattleTurns(true) + // Will skip COMMAND selection menu and go straight to FIGHT (move select) menu + .withSkipToFightInput(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + spriteKey: "fun_and_games_game", + fileRoot: "mystery-encounters", + hasShadow: false, + x: 0, + y: 6, + }, + { + spriteKey: "fun_and_games_wobbuffet", + fileRoot: "mystery-encounters", + hasShadow: true, + x: -28, + y: 6, + yShadow: 6, + }, + { + spriteKey: "fun_and_games_man", + fileRoot: "mystery-encounters", + hasShadow: true, + x: 40, + y: 6, + yShadow: 6, + }, + ]) + .withIntroDialogue([ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + globalScene.loadBgm("mystery_encounter_fun_and_games", "mystery_encounter_fun_and_games.mp3"); + encounter.setDialogueToken("wobbuffetName", getPokemonSpecies(Species.WOBBUFFET).getName()); + return true; + }) + .withOnVisualsStart(() => { + globalScene.fadeAndSwitchBgm("mystery_encounter_fun_and_games"); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withSceneRequirement(new MoneyRequirement(0, 1.5)) // Cost equal to 1 Max Potion .withDialogue({ buttonLabel: `${namespace}:option.1.label`, @@ -127,7 +134,11 @@ export const FunAndGamesEncounter: MysteryEncounter = // Update money const moneyCost = (encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney; updatePlayerMoney(-moneyCost, true, false); - await showEncounterText(i18next.t("mysteryEncounterMessages:paid_money", { amount: moneyCost })); + await showEncounterText( + i18next.t("mysteryEncounterMessages:paid_money", { + amount: moneyCost, + }), + ); // Handlers for battle events encounter.onTurnStart = handleNextTurn; // triggered during TurnInitPhase @@ -139,28 +150,29 @@ export const FunAndGamesEncounter: MysteryEncounter = return true; }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - await transitionMysteryEncounterIntroVisuals(true, true); - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + await transitionMysteryEncounterIntroVisuals(true, true); + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); async function summonPlayerPokemon() { + // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO: Consider refactoring to avoid async promise executor return new Promise(async resolve => { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -176,9 +188,15 @@ async function summonPlayerPokemon() { // Do trainer summon animation let playerAnimationPromise: Promise | undefined; - globalScene.ui.showText(i18next.t("battle:playerGo", { pokemonName: getPokemonNameWithAffix(playerPokemon) })); + globalScene.ui.showText( + i18next.t("battle:playerGo", { + pokemonName: getPokemonNameWithAffix(playerPokemon), + }), + ); globalScene.pbTray.hide(); - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`, + ); globalScene.time.delayedCall(562, () => { globalScene.trainer.setFrame("2"); globalScene.time.delayedCall(64, () => { @@ -189,7 +207,7 @@ async function summonPlayerPokemon() { targets: globalScene.trainer, x: -36, duration: 1000, - onComplete: () => globalScene.trainer.setVisible(false) + onComplete: () => globalScene.trainer.setVisible(false), }); globalScene.time.delayedCall(750, () => { playerAnimationPromise = summonPlayerPokemonAnimation(playerPokemon); @@ -198,8 +216,14 @@ async function summonPlayerPokemon() { // Also loads Wobbuffet data (cannot be shiny) const enemySpecies = getPokemonSpecies(Species.WOBBUFFET); globalScene.currentBattle.enemyParty = []; - const wobbuffet = globalScene.addEnemyPokemon(enemySpecies, encounter.misc.playerPokemon.level, TrainerSlot.NONE, false, true); - wobbuffet.ivs = [ 0, 0, 0, 0, 0, 0 ]; + const wobbuffet = globalScene.addEnemyPokemon( + enemySpecies, + encounter.misc.playerPokemon.level, + TrainerSlot.NONE, + false, + true, + ); + wobbuffet.ivs = [0, 0, 0, 0, 0, 0]; wobbuffet.setNature(Nature.MILD); wobbuffet.setAlpha(0); wobbuffet.setVisible(false); @@ -219,6 +243,7 @@ async function summonPlayerPokemon() { } function handleLoseMinigame() { + // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO: Consider refactoring to avoid async promise executor return new Promise(async resolve => { // Check Wobbuffet is still alive const wobbuffet = globalScene.getEnemyPokemon(); @@ -258,15 +283,24 @@ function handleNextTurn() { let isHealPhase = false; if (healthRatio < 0.03) { // Grand prize - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.MULTI_LENS ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.MULTI_LENS], + fillRemaining: false, + }); resultMessageKey = `${namespace}:best_result`; } else if (healthRatio < 0.15) { // 2nd prize - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.SCOPE_LENS ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.SCOPE_LENS], + fillRemaining: false, + }); resultMessageKey = `${namespace}:great_result`; } else if (healthRatio < 0.33) { // 3rd prize - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.WIDE_LENS ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.WIDE_LENS], + fillRemaining: false, + }); resultMessageKey = `${namespace}:good_result`; } else { // No prize @@ -286,14 +320,13 @@ function handleNextTurn() { // Skip remainder of TurnInitPhase return true; - } else { - if (encounter.misc.turnsRemaining < 3) { - // Display charging messages on turns that aren't the initial turn - queueEncounterMessage(`${namespace}:charging_continue`); - } - queueEncounterMessage(`${namespace}:turn_remaining_${encounter.misc.turnsRemaining}`); - encounter.misc.turnsRemaining--; } + if (encounter.misc.turnsRemaining < 3) { + // Display charging messages on turns that aren't the initial turn + queueEncounterMessage(`${namespace}:charging_continue`); + } + queueEncounterMessage(`${namespace}:turn_remaining_${encounter.misc.turnsRemaining}`); + encounter.misc.turnsRemaining--; // Don't skip remainder of TurnInitPhase return false; @@ -336,7 +369,7 @@ function summonPlayerPokemonAnimation(pokemon: PlayerPokemon): Promise { globalScene.tweens.add({ targets: pokeball, duration: 650, - x: 100 + fpOffset[0] + x: 100 + fpOffset[0], }); globalScene.tweens.add({ @@ -387,11 +420,11 @@ function summonPlayerPokemonAnimation(pokemon: PlayerPokemon): Promise { globalScene.pushPhase(new PostSummonPhase(pokemon.getBattlerIndex())); resolve(); }); - } + }, }); - } + }, }); - } + }, }); }); } @@ -408,14 +441,14 @@ function hideShowmanIntroSprite() { y: "-=16", alpha: 0, ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); // Slide the Wobbuffet and Game over slightly globalScene.tweens.add({ - targets: [ wobbuffet, carnivalGame ], + targets: [wobbuffet, carnivalGame], x: "+=16", ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); } 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 f494aaf2c28..a81392941ba 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -1,9 +1,17 @@ -import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { TrainerSlot, } from "#app/data/trainer-config"; +import { + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { TrainerSlot } from "#app/data/trainer-config"; import { ModifierTier } from "#app/modifier/modifier-tier"; import { MusicPreference } from "#app/system/settings/settings"; import type { ModifierTypeOption } from "#app/modifier/modifier-type"; -import { getPlayerModifierTypeOptions, ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { + getPlayerModifierTypeOptions, + ModifierPoolType, + regenerateModifierPoolThresholds, +} from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -20,7 +28,12 @@ import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon, PokemonMove } from "#app/field/pokemon"; import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; -import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier, ShinyRateBoosterModifier, SpeciesStatBoosterModifier } from "#app/modifier/modifier"; +import { + HiddenAbilityRateBoosterModifier, + PokemonFormChangeItemModifier, + ShinyRateBoosterModifier, + SpeciesStatBoosterModifier, +} from "#app/modifier/modifier"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import PokemonData from "#app/system/pokemon-data"; import i18next from "i18next"; @@ -43,15 +56,15 @@ const WONDER_TRADE_SHINY_CHANCE = 512; const MAX_WONDER_TRADE_SHINY_CHANCE = 4096; const LEGENDARY_TRADE_POOLS = { - 1: [ Species.RATTATA, Species.PIDGEY, Species.WEEDLE ], - 2: [ Species.SENTRET, Species.HOOTHOOT, Species.LEDYBA ], - 3: [ Species.POOCHYENA, Species.ZIGZAGOON, Species.TAILLOW ], - 4: [ Species.BIDOOF, Species.STARLY, Species.KRICKETOT ], - 5: [ Species.PATRAT, Species.PURRLOIN, Species.PIDOVE ], - 6: [ Species.BUNNELBY, Species.LITLEO, Species.SCATTERBUG ], - 7: [ Species.PIKIPEK, Species.YUNGOOS, Species.ROCKRUFF ], - 8: [ Species.SKWOVET, Species.WOOLOO, Species.ROOKIDEE ], - 9: [ Species.LECHONK, Species.FIDOUGH, Species.TAROUNTULA ] + 1: [Species.RATTATA, Species.PIDGEY, Species.WEEDLE], + 2: [Species.SENTRET, Species.HOOTHOOT, Species.LEDYBA], + 3: [Species.POOCHYENA, Species.ZIGZAGOON, Species.TAILLOW], + 4: [Species.BIDOOF, Species.STARLY, Species.KRICKETOT], + 5: [Species.PATRAT, Species.PURRLOIN, Species.PIDOVE], + 6: [Species.BUNNELBY, Species.LITLEO, Species.SCATTERBUG], + 7: [Species.PIKIPEK, Species.YUNGOOS, Species.ROCKRUFF], + 8: [Species.SKWOVET, Species.WOOLOO, Species.ROOKIDEE], + 9: [Species.LECHONK, Species.FIDOUGH, Species.TAROUNTULA], }; /** Exclude Paradox mons as they aren't considered legendary/mythical */ @@ -75,7 +88,7 @@ const EXCLUDED_TRADE_SPECIES = [ Species.IRON_VALIANT, Species.IRON_LEAVES, Species.IRON_BOULDER, - Species.IRON_CROWN + Species.IRON_CROWN, ]; /** @@ -83,363 +96,405 @@ const EXCLUDED_TRADE_SPECIES = [ * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3812 | GitHub Issue #3812} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const GlobalTradeSystemEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.GLOBAL_TRADE_SYSTEM) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withAutoHideIntroVisuals(false) - .withIntroSpriteConfigs([ - { - spriteKey: "global_trade_system", - fileRoot: "mystery-encounters", - hasShadow: true, - disableAnimation: true, - x: 3, - y: 5, - yShadow: 1 - } - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const GlobalTradeSystemEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.GLOBAL_TRADE_SYSTEM, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withAutoHideIntroVisuals(false) + .withIntroSpriteConfigs([ + { + spriteKey: "global_trade_system", + fileRoot: "mystery-encounters", + hasShadow: true, + disableAnimation: true, + x: 3, + y: 5, + yShadow: 1, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Load bgm - let bgmKey: string; - if (globalScene.musicPreference === MusicPreference.GENFIVE) { - bgmKey = "mystery_encounter_gen_5_gts"; - globalScene.loadBgm(bgmKey, `${bgmKey}.mp3`); - } else { - // Mixed option - bgmKey = "mystery_encounter_gen_6_gts"; - globalScene.loadBgm(bgmKey, `${bgmKey}.mp3`); - } + // Load bgm + let bgmKey: string; + if (globalScene.musicPreference === MusicPreference.GENFIVE) { + bgmKey = "mystery_encounter_gen_5_gts"; + globalScene.loadBgm(bgmKey, `${bgmKey}.mp3`); + } else { + // Mixed option + bgmKey = "mystery_encounter_gen_6_gts"; + globalScene.loadBgm(bgmKey, `${bgmKey}.mp3`); + } - // Load possible trade options - // Maps current party member's id to 3 EnemyPokemon objects - // None of the trade options can be the same species - const tradeOptionsMap: Map = getPokemonTradeOptions(); - encounter.misc = { - tradeOptionsMap, - bgmKey - }; + // Load possible trade options + // Maps current party member's id to 3 EnemyPokemon objects + // None of the trade options can be the same species + const tradeOptionsMap: Map = getPokemonTradeOptions(); + encounter.misc = { + tradeOptionsMap, + bgmKey, + }; - return true; - }) - .withOnVisualsStart(() => { - globalScene.fadeAndSwitchBgm(globalScene.currentBattle.mysteryEncounter!.misc.bgmKey); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - secondOptionPrompt: `${namespace}:option.1.trade_options_prompt`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Get the trade species options for the selected pokemon - const tradeOptionsMap: Map = encounter.misc.tradeOptionsMap; - const tradeOptions = tradeOptionsMap.get(pokemon.id); - if (!tradeOptions) { - return []; - } - - return tradeOptions.map((tradePokemon: EnemyPokemon) => { - const option: OptionSelectItem = { - label: tradePokemon.getNameToRender(), - handler: () => { - // Pokemon trade selected - encounter.setDialogueToken("tradedPokemon", pokemon.getNameToRender()); - encounter.setDialogueToken("received", tradePokemon.getNameToRender()); - encounter.misc.tradedPokemon = pokemon; - encounter.misc.receivedPokemon = tradePokemon; - return true; - }, - onHover: () => { - const formName = tradePokemon.species.forms && tradePokemon.species.forms.length > tradePokemon.formIndex ? tradePokemon.species.forms[tradePokemon.formIndex].formName : null; - const line1 = i18next.t("pokemonInfoContainer:ability") + " " + tradePokemon.getAbility().name + (tradePokemon.getGender() !== Gender.GENDERLESS ? " | " + i18next.t("pokemonInfoContainer:gender") + " " + getGenderSymbol(tradePokemon.getGender()) : ""); - const line2 = i18next.t("pokemonInfoContainer:nature") + " " + getNatureName(tradePokemon.getNature()) + (formName ? " | " + i18next.t("pokemonInfoContainer:form") + " " + formName : ""); - showEncounterText(`${line1}\n${line2}`, 0, 0, false); - }, - }; - return option; - }); - }; - - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const tradedPokemon: PlayerPokemon = encounter.misc.tradedPokemon; - const receivedPokemonData: EnemyPokemon = encounter.misc.receivedPokemon; - const modifiers = tradedPokemon.getHeldItems().filter(m => !(m instanceof PokemonFormChangeItemModifier) && !(m instanceof SpeciesStatBoosterModifier)); - - // Generate a trainer name - const traderName = generateRandomTraderName(); - encounter.setDialogueToken("tradeTrainerName", traderName.trim()); - - // Remove the original party member from party - globalScene.removePokemonFromPlayerParty(tradedPokemon, false); - - // Set data properly, then generate the new Pokemon's assets - receivedPokemonData.passive = tradedPokemon.passive; - // Pokeball to Ultra ball, randomly - receivedPokemonData.pokeball = randInt(4) as PokeballType; - const dataSource = new PokemonData(receivedPokemonData); - const newPlayerPokemon = globalScene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource); - globalScene.getPlayerParty().push(newPlayerPokemon); - await newPlayerPokemon.loadAssets(); - - for (const mod of modifiers) { - mod.pokemonId = newPlayerPokemon.id; - globalScene.addModifier(mod, true, false, false, true); + return true; + }) + .withOnVisualsStart(() => { + globalScene.fadeAndSwitchBgm(globalScene.currentBattle.mysteryEncounter!.misc.bgmKey); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + secondOptionPrompt: `${namespace}:option.1.trade_options_prompt`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Get the trade species options for the selected pokemon + const tradeOptionsMap: Map = encounter.misc.tradeOptionsMap; + const tradeOptions = tradeOptionsMap.get(pokemon.id); + if (!tradeOptions) { + return []; } - // Show the trade animation - await showTradeBackground(); - await doPokemonTradeSequence(tradedPokemon, newPlayerPokemon); - await showEncounterText(`${namespace}:trade_received`, null, 0, true, 4000); - globalScene.playBgm(encounter.misc.bgmKey); - await addPokemonDataToDexAndValidateAchievements(newPlayerPokemon); - await hideTradeBackground(); - tradedPokemon.destroy(); + return tradeOptions.map((tradePokemon: EnemyPokemon) => { + const option: OptionSelectItem = { + label: tradePokemon.getNameToRender(), + handler: () => { + // Pokemon trade selected + encounter.setDialogueToken("tradedPokemon", pokemon.getNameToRender()); + encounter.setDialogueToken("received", tradePokemon.getNameToRender()); + encounter.misc.tradedPokemon = pokemon; + encounter.misc.receivedPokemon = tradePokemon; + return true; + }, + onHover: () => { + const formName = + tradePokemon.species.forms && tradePokemon.species.forms.length > tradePokemon.formIndex + ? tradePokemon.species.forms[tradePokemon.formIndex].formName + : null; + const line1 = `${i18next.t("pokemonInfoContainer:ability")} ${tradePokemon.getAbility().name}${ + tradePokemon.getGender() !== Gender.GENDERLESS + ? ` | ${i18next.t("pokemonInfoContainer:gender")} ${getGenderSymbol(tradePokemon.getGender())}` + : "" + }`; + const line2 = + i18next.t("pokemonInfoContainer:nature") + + " " + + getNatureName(tradePokemon.getNature()) + + (formName ? ` | ${i18next.t("pokemonInfoContainer:form")} ${formName}` : ""); + showEncounterText(`${line1}\n${line2}`, 0, 0, false); + }, + }; + return option; + }); + }; - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Randomly generate a Wonder Trade pokemon - const randomTradeOption = generateTradeOption(globalScene.getPlayerParty().map(p => p.species)); - const tradePokemon = new EnemyPokemon(randomTradeOption, pokemon.level, TrainerSlot.NONE, false); - // Extra shiny roll at 1/128 odds (boosted by events and charms) - if (!tradePokemon.shiny) { - const shinyThreshold = new NumberHolder(WONDER_TRADE_SHINY_CHANCE); - if (globalScene.eventManager.isEventActive()) { - shinyThreshold.value *= globalScene.eventManager.getShinyMultiplier(); - } - globalScene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold); + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const tradedPokemon: PlayerPokemon = encounter.misc.tradedPokemon; + const receivedPokemonData: EnemyPokemon = encounter.misc.receivedPokemon; + const modifiers = tradedPokemon + .getHeldItems() + .filter(m => !(m instanceof PokemonFormChangeItemModifier) && !(m instanceof SpeciesStatBoosterModifier)); - // Base shiny chance of 512/65536 -> 1/128, affected by events and Shiny Charms - // Maximum shiny chance of 4096/65536 -> 1/16, cannot improve further after that - const shinyChance = Math.min(shinyThreshold.value, MAX_WONDER_TRADE_SHINY_CHANCE); + // Generate a trainer name + const traderName = generateRandomTraderName(); + encounter.setDialogueToken("tradeTrainerName", traderName.trim()); - tradePokemon.trySetShinySeed(shinyChance, false); + // Remove the original party member from party + globalScene.removePokemonFromPlayerParty(tradedPokemon, false); + + // Set data properly, then generate the new Pokemon's assets + receivedPokemonData.passive = tradedPokemon.passive; + // Pokeball to Ultra ball, randomly + receivedPokemonData.pokeball = randInt(4) as PokeballType; + const dataSource = new PokemonData(receivedPokemonData); + const newPlayerPokemon = globalScene.addPlayerPokemon( + receivedPokemonData.species, + receivedPokemonData.level, + dataSource.abilityIndex, + dataSource.formIndex, + dataSource.gender, + dataSource.shiny, + dataSource.variant, + dataSource.ivs, + dataSource.nature, + dataSource, + ); + globalScene.getPlayerParty().push(newPlayerPokemon); + await newPlayerPokemon.loadAssets(); + + for (const mod of modifiers) { + mod.pokemonId = newPlayerPokemon.id; + globalScene.addModifier(mod, true, false, false, true); + } + + // Show the trade animation + await showTradeBackground(); + await doPokemonTradeSequence(tradedPokemon, newPlayerPokemon); + await showEncounterText(`${namespace}:trade_received`, null, 0, true, 4000); + globalScene.playBgm(encounter.misc.bgmKey); + await addPokemonDataToDexAndValidateAchievements(newPlayerPokemon); + await hideTradeBackground(); + tradedPokemon.destroy(); + + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Randomly generate a Wonder Trade pokemon + const randomTradeOption = generateTradeOption(globalScene.getPlayerParty().map(p => p.species)); + const tradePokemon = new EnemyPokemon(randomTradeOption, pokemon.level, TrainerSlot.NONE, false); + // Extra shiny roll at 1/128 odds (boosted by events and charms) + if (!tradePokemon.shiny) { + const shinyThreshold = new NumberHolder(WONDER_TRADE_SHINY_CHANCE); + if (globalScene.eventManager.isEventActive()) { + shinyThreshold.value *= globalScene.eventManager.getShinyMultiplier(); } + globalScene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold); - // Extra HA roll at base 1/64 odds (boosted by events and charms) - const hiddenIndex = tradePokemon.species.ability2 ? 2 : 1; - if (tradePokemon.species.abilityHidden) { - if (tradePokemon.abilityIndex < hiddenIndex) { - const hiddenAbilityChance = new NumberHolder(64); - globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); + // Base shiny chance of 512/65536 -> 1/128, affected by events and Shiny Charms + // Maximum shiny chance of 4096/65536 -> 1/16, cannot improve further after that + const shinyChance = Math.min(shinyThreshold.value, MAX_WONDER_TRADE_SHINY_CHANCE); - const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); + tradePokemon.trySetShinySeed(shinyChance, false); + } - if (hasHiddenAbility) { - tradePokemon.abilityIndex = hiddenIndex; + // Extra HA roll at base 1/64 odds (boosted by events and charms) + const hiddenIndex = tradePokemon.species.ability2 ? 2 : 1; + if (tradePokemon.species.abilityHidden) { + if (tradePokemon.abilityIndex < hiddenIndex) { + const hiddenAbilityChance = new NumberHolder(64); + globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); + + const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); + + if (hasHiddenAbility) { + tradePokemon.abilityIndex = hiddenIndex; + } + } + } + + // If Pokemon is still not shiny or with HA, give the Pokemon a random Common egg move in its moveset + if (!tradePokemon.shiny && (!tradePokemon.species.abilityHidden || tradePokemon.abilityIndex < hiddenIndex)) { + const eggMoves = tradePokemon.getEggMoves(); + if (eggMoves) { + // Cannot gen the rare egg move, only 1 of the first 3 common moves + const eggMove = eggMoves[randSeedInt(3)]; + if (!tradePokemon.moveset.some(m => m?.moveId === eggMove)) { + if (tradePokemon.moveset.length < 4) { + tradePokemon.moveset.push(new PokemonMove(eggMove)); + } else { + const eggMoveIndex = randSeedInt(4); + tradePokemon.moveset[eggMoveIndex] = new PokemonMove(eggMove); } } } - - // If Pokemon is still not shiny or with HA, give the Pokemon a random Common egg move in its moveset - if (!tradePokemon.shiny && (!tradePokemon.species.abilityHidden || tradePokemon.abilityIndex < hiddenIndex)) { - const eggMoves = tradePokemon.getEggMoves(); - if (eggMoves) { - // Cannot gen the rare egg move, only 1 of the first 3 common moves - const eggMove = eggMoves[randSeedInt(3)]; - if (!tradePokemon.moveset.some(m => m?.moveId === eggMove)) { - if (tradePokemon.moveset.length < 4) { - tradePokemon.moveset.push(new PokemonMove(eggMove)); - } else { - const eggMoveIndex = randSeedInt(4); - tradePokemon.moveset[eggMoveIndex] = new PokemonMove(eggMove); - } - } - } - } - - encounter.setDialogueToken("tradedPokemon", pokemon.getNameToRender()); - encounter.setDialogueToken("received", tradePokemon.getNameToRender()); - encounter.misc.tradedPokemon = pokemon; - encounter.misc.receivedPokemon = tradePokemon; - }; - - return selectPokemonForOption(onPokemonSelected); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const tradedPokemon: PlayerPokemon = encounter.misc.tradedPokemon; - const receivedPokemonData: EnemyPokemon = encounter.misc.receivedPokemon; - const modifiers = tradedPokemon.getHeldItems().filter(m => !(m instanceof PokemonFormChangeItemModifier) && !(m instanceof SpeciesStatBoosterModifier)); - - // Generate a trainer name - const traderName = generateRandomTraderName(); - encounter.setDialogueToken("tradeTrainerName", traderName.trim()); - - // Remove the original party member from party - globalScene.removePokemonFromPlayerParty(tradedPokemon, false); - - // Set data properly, then generate the new Pokemon's assets - receivedPokemonData.passive = tradedPokemon.passive; - receivedPokemonData.pokeball = randInt(4) as PokeballType; - const dataSource = new PokemonData(receivedPokemonData); - const newPlayerPokemon = globalScene.addPlayerPokemon(receivedPokemonData.species, receivedPokemonData.level, dataSource.abilityIndex, dataSource.formIndex, dataSource.gender, dataSource.shiny, dataSource.variant, dataSource.ivs, dataSource.nature, dataSource); - globalScene.getPlayerParty().push(newPlayerPokemon); - await newPlayerPokemon.loadAssets(); - - for (const mod of modifiers) { - mod.pokemonId = newPlayerPokemon.id; - globalScene.addModifier(mod, true, false, false, true); } - // Show the trade animation - await showTradeBackground(); - await doPokemonTradeSequence(tradedPokemon, newPlayerPokemon); - await showEncounterText(`${namespace}:trade_received`, null, 0, true, 4000); - globalScene.playBgm(encounter.misc.bgmKey); - await addPokemonDataToDexAndValidateAchievements(newPlayerPokemon); - await hideTradeBackground(); - tradedPokemon.destroy(); + encounter.setDialogueToken("tradedPokemon", pokemon.getNameToRender()); + encounter.setDialogueToken("received", tradePokemon.getNameToRender()); + encounter.misc.tradedPokemon = pokemon; + encounter.misc.receivedPokemon = tradePokemon; + }; - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - secondOptionPrompt: `${namespace}:option.3.trade_options_prompt`, - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Get Pokemon held items and filter for valid ones - const validItems = pokemon.getHeldItems().filter((it) => { - return it.isTransferable; - }); + return selectPokemonForOption(onPokemonSelected); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const tradedPokemon: PlayerPokemon = encounter.misc.tradedPokemon; + const receivedPokemonData: EnemyPokemon = encounter.misc.receivedPokemon; + const modifiers = tradedPokemon + .getHeldItems() + .filter(m => !(m instanceof PokemonFormChangeItemModifier) && !(m instanceof SpeciesStatBoosterModifier)); - return validItems.map((modifier: PokemonHeldItemModifier) => { - const option: OptionSelectItem = { - label: modifier.type.name, - handler: () => { - // Pokemon and item selected - encounter.setDialogueToken("chosenItem", modifier.type.name); - encounter.misc.chosenModifier = modifier; - encounter.misc.chosenPokemon = pokemon; - return true; - }, - }; - return option; - }); - }; + // Generate a trainer name + const traderName = generateRandomTraderName(); + encounter.setDialogueToken("tradeTrainerName", traderName.trim()); - const selectableFilter = (pokemon: Pokemon) => { - // If pokemon has items to trade - const meetsReqs = pokemon.getHeldItems().filter((it) => { + // Remove the original party member from party + globalScene.removePokemonFromPlayerParty(tradedPokemon, false); + + // Set data properly, then generate the new Pokemon's assets + receivedPokemonData.passive = tradedPokemon.passive; + receivedPokemonData.pokeball = randInt(4) as PokeballType; + const dataSource = new PokemonData(receivedPokemonData); + const newPlayerPokemon = globalScene.addPlayerPokemon( + receivedPokemonData.species, + receivedPokemonData.level, + dataSource.abilityIndex, + dataSource.formIndex, + dataSource.gender, + dataSource.shiny, + dataSource.variant, + dataSource.ivs, + dataSource.nature, + dataSource, + ); + globalScene.getPlayerParty().push(newPlayerPokemon); + await newPlayerPokemon.loadAssets(); + + for (const mod of modifiers) { + mod.pokemonId = newPlayerPokemon.id; + globalScene.addModifier(mod, true, false, false, true); + } + + // Show the trade animation + await showTradeBackground(); + await doPokemonTradeSequence(tradedPokemon, newPlayerPokemon); + await showEncounterText(`${namespace}:trade_received`, null, 0, true, 4000); + globalScene.playBgm(encounter.misc.bgmKey); + await addPokemonDataToDexAndValidateAchievements(newPlayerPokemon); + await hideTradeBackground(); + tradedPokemon.destroy(); + + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + secondOptionPrompt: `${namespace}:option.3.trade_options_prompt`, + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Get Pokemon held items and filter for valid ones + const validItems = pokemon.getHeldItems().filter(it => { + return it.isTransferable; + }); + + return validItems.map((modifier: PokemonHeldItemModifier) => { + const option: OptionSelectItem = { + label: modifier.type.name, + handler: () => { + // Pokemon and item selected + encounter.setDialogueToken("chosenItem", modifier.type.name); + encounter.misc.chosenModifier = modifier; + encounter.misc.chosenPokemon = pokemon; + return true; + }, + }; + return option; + }); + }; + + const selectableFilter = (pokemon: Pokemon) => { + // If pokemon has items to trade + const meetsReqs = + pokemon.getHeldItems().filter(it => { return it.isTransferable; }).length > 0; - if (!meetsReqs) { - return getEncounterText(`${namespace}:option.3.invalid_selection`) ?? null; - } - - return null; - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier; - const party = globalScene.getPlayerParty(); - const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; - - // Check tier of the traded item, the received item will be one tier up - const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party); - let tier = type.tier ?? ModifierTier.GREAT; - // Eggs and White Herb are not in the pool - if (type.id === "WHITE_HERB") { - tier = ModifierTier.GREAT; - } else if (type.id === "LUCKY_EGG") { - tier = ModifierTier.ULTRA; - } else if (type.id === "GOLDEN_EGG") { - tier = ModifierTier.ROGUE; - } - // Increment tier by 1 - if (tier < ModifierTier.MASTER) { - tier++; + if (!meetsReqs) { + return getEncounterText(`${namespace}:option.3.invalid_selection`) ?? null; } - regenerateModifierPoolThresholds(party, ModifierPoolType.PLAYER, 0); - let item: ModifierTypeOption | null = null; - // TMs excluded from possible rewards - while (!item || item.type.id.includes("TM_")) { - item = getPlayerModifierTypeOptions(1, party, [], { guaranteedModifierTiers: [ tier ], allowLuckUpgrades: false })[0]; - } + return null; + }; - encounter.setDialogueToken("itemName", item.type.name); - setEncounterRewards({ guaranteedModifierTypeOptions: [ item ], fillRemaining: false }); + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const modifier = encounter.misc.chosenModifier as PokemonHeldItemModifier; + const party = globalScene.getPlayerParty(); + const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon; - chosenPokemon.loseHeldItem(modifier, false); - await globalScene.updateModifiers(true, true); + // Check tier of the traded item, the received item will be one tier up + const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party); + let tier = type.tier ?? ModifierTier.GREAT; + // Eggs and White Herb are not in the pool + if (type.id === "WHITE_HERB") { + tier = ModifierTier.GREAT; + } else if (type.id === "LUCKY_EGG") { + tier = ModifierTier.ULTRA; + } else if (type.id === "GOLDEN_EGG") { + tier = ModifierTier.ROGUE; + } + // Increment tier by 1 + if (tier < ModifierTier.MASTER) { + tier++; + } - // Generate a trainer name - const traderName = generateRandomTraderName(); - encounter.setDialogueToken("tradeTrainerName", traderName.trim()); - await showEncounterText(`${namespace}:item_trade_selected`); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.4.label`, - buttonTooltip: `${namespace}:option.4.tooltip`, - selected: [ - { - text: `${namespace}:option.4.selected`, - }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + regenerateModifierPoolThresholds(party, ModifierPoolType.PLAYER, 0); + let item: ModifierTypeOption | null = null; + // TMs excluded from possible rewards + while (!item || item.type.id.includes("TM_")) { + item = getPlayerModifierTypeOptions(1, party, [], { + guaranteedModifierTiers: [tier], + allowLuckUpgrades: false, + })[0]; + } + + encounter.setDialogueToken("itemName", item.type.name); + setEncounterRewards({ + guaranteedModifierTypeOptions: [item], + fillRemaining: false, + }); + + chosenPokemon.loseHeldItem(modifier, false); + await globalScene.updateModifiers(true, true); + + // Generate a trainer name + const traderName = generateRandomTraderName(); + encounter.setDialogueToken("tradeTrainerName", traderName.trim()); + await showEncounterText(`${namespace}:item_trade_selected`); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.4.label`, + buttonTooltip: `${namespace}:option.4.tooltip`, + selected: [ + { + text: `${namespace}:option.4.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); function getPokemonTradeOptions(): Map { const tradeOptionsMap: Map = new Map(); // Starts by filtering out any current party members as valid resulting species const alreadyUsedSpecies: PokemonSpecies[] = globalScene.getPlayerParty().map(p => p.species); - globalScene.getPlayerParty().forEach(pokemon => { + for (const pokemon of globalScene.getPlayerParty()) { // If the party member is legendary/mythical, the only trade options available are always pulled from generation-specific legendary trade pools if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) { const generation = pokemon.species.generation; @@ -459,11 +514,14 @@ function getPokemonTradeOptions(): Map { } // Add trade options to map - tradeOptionsMap.set(pokemon.id, tradeOptions.map(s => { - return new EnemyPokemon(s, pokemon.level, TrainerSlot.NONE, false); - })); + tradeOptionsMap.set( + pokemon.id, + tradeOptions.map(s => { + return new EnemyPokemon(s, pokemon.level, TrainerSlot.NONE, false); + }), + ); } - }); + } return tradeOptionsMap; } @@ -478,13 +536,12 @@ function generateTradeOption(alreadyUsedSpecies: PokemonSpecies[], originalBst?: } while (isNullOrUndefined(newSpecies)) { // Get all non-legendary species that fall within the Bst range requirements - let validSpecies = allSpecies - .filter(s => { - const isLegendaryOrMythical = s.legendary || s.subLegendary || s.mythical; - const speciesBst = s.getBaseStatTotal(); - const bstInRange = speciesBst >= bstMin && speciesBst <= bstCap; - return !isLegendaryOrMythical && bstInRange && !EXCLUDED_TRADE_SPECIES.includes(s.speciesId); - }); + let validSpecies = allSpecies.filter(s => { + const isLegendaryOrMythical = s.legendary || s.subLegendary || s.mythical; + const speciesBst = s.getBaseStatTotal(); + const bstInRange = speciesBst >= bstMin && speciesBst <= bstCap; + return !isLegendaryOrMythical && bstInRange && !EXCLUDED_TRADE_SPECIES.includes(s.speciesId); + }); // There must be at least 20 species available before it will choose one if (validSpecies?.length > 20) { @@ -508,7 +565,13 @@ function showTradeBackground() { const tradeContainer = globalScene.add.container(0, -globalScene.game.canvas.height / 6); tradeContainer.setName("Trade Background"); - const flyByStaticBg = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0); + const flyByStaticBg = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0, + ); flyByStaticBg.setName("Black Background"); flyByStaticBg.setOrigin(0, 0); flyByStaticBg.setVisible(false); @@ -531,7 +594,7 @@ function showTradeBackground() { ease: "Sine.easeInOut", onComplete: () => { resolve(); - } + }, }); }); } @@ -548,7 +611,7 @@ function hideTradeBackground() { onComplete: () => { globalScene.fieldUI.remove(transformationContainer, true); resolve(); - } + }, }); }); } @@ -569,8 +632,16 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P let receivedPokemonTintSprite: Phaser.GameObjects.Sprite; const getPokemonSprite = () => { - const ret = globalScene.addPokemonSprite(tradedPokemon, tradeBaseBg.displayWidth / 2, tradeBaseBg.displayHeight / 2, "pkmn__sub"); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + const ret = globalScene.addPokemonSprite( + tradedPokemon, + tradeBaseBg.displayWidth / 2, + tradeBaseBg.displayHeight / 2, + "pkmn__sub", + ); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); return ret; }; @@ -586,7 +657,7 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P receivedPokemonTintSprite.setVisible(false); receivedPokemonTintSprite.setTintFill(getPokeballTintColor(receivedPokemon.pokeball)); - [ tradedPokemonSprite, tradedPokemonTintSprite ].map(sprite => { + [tradedPokemonSprite, tradedPokemonTintSprite].map(sprite => { const spriteKey = tradedPokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -594,12 +665,17 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(tradedPokemon.getTeraType()), isTerastallized: tradedPokemon.isTerastallized }); + sprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: false, + teraColor: getTypeRgb(tradedPokemon.getTeraType()), + isTerastallized: tradedPokemon.isTerastallized, + }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", tradedPokemon.getSpriteKey()); sprite.setPipelineData("shiny", tradedPokemon.shiny); sprite.setPipelineData("variant", tradedPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (tradedPokemon.summonData?.speciesForm) { k += "Base"; } @@ -607,7 +683,7 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P }); }); - [ receivedPokemonSprite, receivedPokemonTintSprite ].map(sprite => { + [receivedPokemonSprite, receivedPokemonTintSprite].map(sprite => { const spriteKey = receivedPokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -615,12 +691,17 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(tradedPokemon.getTeraType()), isTerastallized: tradedPokemon.isTerastallized }); + sprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: false, + teraColor: getTypeRgb(tradedPokemon.getTeraType()), + isTerastallized: tradedPokemon.isTerastallized, + }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", receivedPokemon.getSpriteKey()); sprite.setPipelineData("shiny", receivedPokemon.shiny); sprite.setPipelineData("variant", receivedPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (receivedPokemon.summonData?.speciesForm) { k += "Base"; } @@ -630,13 +711,23 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P // Traded pokemon pokeball const tradedPbAtlasKey = getPokeballAtlasKey(tradedPokemon.pokeball); - const tradedPokeball: Phaser.GameObjects.Sprite = globalScene.add.sprite(tradeBaseBg.displayWidth / 2, tradeBaseBg.displayHeight / 2, "pb", tradedPbAtlasKey); + const tradedPokeball: Phaser.GameObjects.Sprite = globalScene.add.sprite( + tradeBaseBg.displayWidth / 2, + tradeBaseBg.displayHeight / 2, + "pb", + tradedPbAtlasKey, + ); tradedPokeball.setVisible(false); tradeContainer.add(tradedPokeball); // Received pokemon pokeball const receivedPbAtlasKey = getPokeballAtlasKey(receivedPokemon.pokeball); - const receivedPokeball: Phaser.GameObjects.Sprite = globalScene.add.sprite(tradeBaseBg.displayWidth / 2, tradeBaseBg.displayHeight / 2, "pb", receivedPbAtlasKey); + const receivedPokeball: Phaser.GameObjects.Sprite = globalScene.add.sprite( + tradeBaseBg.displayWidth / 2, + tradeBaseBg.displayHeight / 2, + "pb", + receivedPbAtlasKey, + ); receivedPokeball.setVisible(false); tradeContainer.add(receivedPokeball); @@ -669,7 +760,7 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P // addPokeballOpenParticles(tradedPokemon.x, tradedPokemon.y, tradedPokemon.pokeball); globalScene.tweens.add({ - targets: [ tradedPokemonTintSprite, tradedPokemonSprite ], + targets: [tradedPokemonTintSprite, tradedPokemonSprite], duration: 500, ease: "Sine.easeIn", scale: 0.25, @@ -700,22 +791,31 @@ function doPokemonTradeSequence(tradedPokemon: PlayerPokemon, receivedPokemon: P }, onComplete: async () => { await doPokemonTradeFlyBySequence(tradedPokemonSprite, receivedPokemonSprite); - await doTradeReceivedSequence(receivedPokemon, receivedPokemonSprite, receivedPokemonTintSprite, receivedPokeball, receivedPbAtlasKey); + await doTradeReceivedSequence( + receivedPokemon, + receivedPokemonSprite, + receivedPokemonTintSprite, + receivedPokeball, + receivedPbAtlasKey, + ); resolve(); - } + }, }); - } + }, }); - } + }, }); - } + }, }); - } + }, }); }); } -function doPokemonTradeFlyBySequence(tradedPokemonSprite: Phaser.GameObjects.Sprite, receivedPokemonSprite: Phaser.GameObjects.Sprite) { +function doPokemonTradeFlyBySequence( + tradedPokemonSprite: Phaser.GameObjects.Sprite, + receivedPokemonSprite: Phaser.GameObjects.Sprite, +) { return new Promise(resolve => { const tradeContainer = globalScene.fieldUI.getByName("Trade Background") as Phaser.GameObjects.Container; const tradeBaseBg = tradeContainer.getByName("Trade Background Image") as Phaser.GameObjects.Image; @@ -728,7 +828,7 @@ function doPokemonTradeFlyBySequence(tradedPokemonSprite: Phaser.GameObjects.Spr tradedPokemonSprite.y = 200; tradedPokemonSprite.scale = 1; tradedPokemonSprite.setVisible(true); - receivedPokemonSprite.x = tradeBaseBg.displayWidth * 3 / 4; + receivedPokemonSprite.x = (tradeBaseBg.displayWidth * 3) / 4; receivedPokemonSprite.y = -200; receivedPokemonSprite.scale = 1; receivedPokemonSprite.setVisible(true); @@ -745,7 +845,7 @@ function doPokemonTradeFlyBySequence(tradedPokemonSprite: Phaser.GameObjects.Spr duration: FADE_DELAY, onComplete: () => { globalScene.tweens.add({ - targets: [ receivedPokemonSprite, tradedPokemonSprite ], + targets: [receivedPokemonSprite, tradedPokemonSprite], y: tradeBaseBg.displayWidth / 2 - 100, ease: "Cubic.easeInOut", duration: BASE_ANIM_DURATION * 3, @@ -755,11 +855,11 @@ function doPokemonTradeFlyBySequence(tradedPokemonSprite: Phaser.GameObjects.Spr x: tradeBaseBg.displayWidth / 4, ease: "Cubic.easeInOut", duration: BASE_ANIM_DURATION / 2, - delay: ANIM_DELAY + delay: ANIM_DELAY, }); globalScene.tweens.add({ targets: tradedPokemonSprite, - x: tradeBaseBg.displayWidth * 3 / 4, + x: (tradeBaseBg.displayWidth * 3) / 4, ease: "Cubic.easeInOut", duration: BASE_ANIM_DURATION / 2, delay: ANIM_DELAY, @@ -785,20 +885,26 @@ function doPokemonTradeFlyBySequence(tradedPokemonSprite: Phaser.GameObjects.Spr duration: FADE_DELAY, onComplete: () => { resolve(); - } + }, }); - } + }, }); - } + }, }); - } + }, }); - } + }, }); }); } -function doTradeReceivedSequence(receivedPokemon: PlayerPokemon, receivedPokemonSprite: Phaser.GameObjects.Sprite, receivedPokemonTintSprite: Phaser.GameObjects.Sprite, receivedPokeballSprite: Phaser.GameObjects.Sprite, receivedPbAtlasKey: string) { +function doTradeReceivedSequence( + receivedPokemon: PlayerPokemon, + receivedPokemonSprite: Phaser.GameObjects.Sprite, + receivedPokemonTintSprite: Phaser.GameObjects.Sprite, + receivedPokeballSprite: Phaser.GameObjects.Sprite, + receivedPbAtlasKey: string, +) { return new Promise(resolve => { const tradeContainer = globalScene.fieldUI.getByName("Trade Background") as Phaser.GameObjects.Container; const tradeBaseBg = tradeContainer.getByName("Trade Background Image") as Phaser.GameObjects.Image; @@ -851,7 +957,7 @@ function doTradeReceivedSequence(receivedPokemon: PlayerPokemon, receivedPokemon targets: receivedPokemonSprite, duration: 250, ease: "Sine.easeOut", - scale: 1 + scale: 1, }); globalScene.tweens.add({ targets: receivedPokemonTintSprite, @@ -867,10 +973,10 @@ function doTradeReceivedSequence(receivedPokemon: PlayerPokemon, receivedPokemon } receivedPokeballSprite.destroy(); globalScene.time.delayedCall(2000, () => resolve()); - } + }, }); }); - } + }, }); }); } @@ -884,7 +990,7 @@ function generateRandomTraderName() { } // Some trainers have 2 gendered pools, some do not const genderedPool = trainerTypePool[randInt(trainerTypePool.length)]; - const trainerNameString = genderedPool instanceof Array ? genderedPool[randInt(genderedPool.length)] : genderedPool; + const trainerNameString = Array.isArray(genderedPool) ? genderedPool[randInt(genderedPool.length)] : genderedPool; // Some names have an '&' symbol and need to be trimmed to a single name instead of a double name const trainerNames = trainerNameString.split(" & "); return trainerNames[randInt(trainerNames.length)]; diff --git a/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts b/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts index 34c808359b7..97fd5783ebb 100644 --- a/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts +++ b/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts @@ -29,7 +29,9 @@ const namespace = "mysteryEncounters/lostAtSea"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3793 | GitHub Issue #3793} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.LOST_AT_SEA) +export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.LOST_AT_SEA, +) .withEncounterTier(MysteryEncounterTier.COMMON) .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) .withIntroSpriteConfigs([ @@ -57,8 +59,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with .withQuery(`${namespace}:query`) .withOption( // Option 1: Use a (non fainted) pokemon that can learn Surf to guide you back/ - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withPokemonCanLearnMoveRequirement(OPTION_1_REQUIRED_MOVE) .withDialogue({ buttonLabel: `${namespace}:option.1.label`, @@ -72,12 +73,11 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with ], }) .withOptionPhase(async () => handlePokemonGuidingYouPhase()) - .build() + .build(), ) .withOption( //Option 2: Use a (non fainted) pokemon that can learn fly to guide you back. - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withPokemonCanLearnMoveRequirement(OPTION_2_REQUIRED_MOVE) .withDialogue({ buttonLabel: `${namespace}:option.2.label`, @@ -91,7 +91,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with ], }) .withOptionPhase(async () => handlePokemonGuidingYouPhase()) - .build() + .build(), ) .withSimpleOption( // Option 3: Wander aimlessly @@ -105,7 +105,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with ], }, async () => { - const allowedPokemon = globalScene.getPlayerParty().filter((p) => p.isAllowedInBattle()); + const allowedPokemon = globalScene.getPlayerParty().filter(p => p.isAllowedInBattle()); for (const pkm of allowedPokemon) { const percentage = DAMAGE_PERCENTAGE / 100; @@ -116,7 +116,7 @@ export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.with leaveEncounterWithoutBattle(); return true; - } + }, ) .withOutroDialogue([ { diff --git a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts index 36e12b34e10..bf60e982b15 100644 --- a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts @@ -1,5 +1,4 @@ -import type { - EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { initBattleWithEnemyConfig, setEncounterRewards, @@ -29,195 +28,202 @@ const namespace = "mysteryEncounters/mysteriousChallengers"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3801 | GitHub Issue #3801} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const MysteriousChallengersEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHALLENGERS) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withIntroSpriteConfigs([]) // These are set in onInit() - .withIntroDialogue([ +export const MysteriousChallengersEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.MYSTERIOUS_CHALLENGERS, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withIntroSpriteConfigs([]) // These are set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Calculates what trainers are available for battle in the encounter + + // Normal difficulty trainer is randomly pulled from biome + const normalTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); + const normalConfig = trainerConfigs[normalTrainerType].clone(); + let female = false; + if (normalConfig.hasGenders) { + female = !!Utils.randSeedInt(2); + } + const normalSpriteKey = normalConfig.getSpriteKey(female, normalConfig.doubleOnly); + encounter.enemyPartyConfigs.push({ + trainerConfig: normalConfig, + female: female, + }); + + // Hard difficulty trainer is another random trainer, but with AVERAGE_BALANCED config + // Number of mons is based off wave: 1-20 is 2, 20-40 is 3, etc. capping at 6 after wave 100 + let retries = 0; + let hardTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); + while (retries < 5 && hardTrainerType === normalTrainerType) { + // Will try to use a different trainer from the normal trainer type + hardTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); + retries++; + } + const hardTemplate = new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER, false, true), + new TrainerPartyTemplate( + Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 20), 5), + PartyMemberStrength.AVERAGE, + false, + true, + ), + ); + const hardConfig = trainerConfigs[hardTrainerType].clone(); + hardConfig.setPartyTemplates(hardTemplate); + female = false; + if (hardConfig.hasGenders) { + female = !!Utils.randSeedInt(2); + } + const hardSpriteKey = hardConfig.getSpriteKey(female, hardConfig.doubleOnly); + encounter.enemyPartyConfigs.push({ + trainerConfig: hardConfig, + levelAdditiveModifier: 1, + female: female, + }); + + // Brutal trainer is pulled from pool of boss trainers (gym leaders) for the biome + // They are given an E4 template team, so will be stronger than usual boss encounter and always have 6 mons + const brutalTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex, true); + const e4Template = trainerPartyTemplates.ELITE_FOUR; + const brutalConfig = trainerConfigs[brutalTrainerType].clone(); + brutalConfig.title = trainerConfigs[brutalTrainerType].title; + brutalConfig.setPartyTemplates(e4Template); + // @ts-ignore + brutalConfig.partyTemplateFunc = null; // Overrides gym leader party template func + female = false; + if (brutalConfig.hasGenders) { + female = !!Utils.randSeedInt(2); + } + const brutalSpriteKey = brutalConfig.getSpriteKey(female, brutalConfig.doubleOnly); + encounter.enemyPartyConfigs.push({ + trainerConfig: brutalConfig, + levelAdditiveModifier: 1.5, + female: female, + }); + + encounter.spriteConfigs = [ { - text: `${namespace}:intro`, + spriteKey: normalSpriteKey, + fileRoot: "trainer", + hasShadow: true, + tint: 1, }, - ]) - .withOnInit(() => { + { + spriteKey: hardSpriteKey, + fileRoot: "trainer", + hasShadow: true, + tint: 1, + }, + { + spriteKey: brutalSpriteKey, + fileRoot: "trainer", + hasShadow: true, + tint: 1, + }, + ]; + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }, + async () => { const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculates what trainers are available for battle in the encounter + // Spawn standard trainer battle with memory mushroom reward + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Normal difficulty trainer is randomly pulled from biome - const normalTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); - const normalConfig = trainerConfigs[normalTrainerType].clone(); - let female = false; - if (normalConfig.hasGenders) { - female = !!Utils.randSeedInt(2); - } - const normalSpriteKey = normalConfig.getSpriteKey(female, normalConfig.doubleOnly); - encounter.enemyPartyConfigs.push({ - trainerConfig: normalConfig, - female: female, + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.TM_COMMON, modifierTypes.TM_GREAT, modifierTypes.MEMORY_MUSHROOM], + fillRemaining: true, }); - // Hard difficulty trainer is another random trainer, but with AVERAGE_BALANCED config - // Number of mons is based off wave: 1-20 is 2, 20-40 is 3, etc. capping at 6 after wave 100 - let retries = 0; - let hardTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); - while (retries < 5 && hardTrainerType === normalTrainerType) { - // Will try to use a different trainer from the normal trainer type - hardTrainerType = globalScene.arena.randomTrainerType(globalScene.currentBattle.waveIndex); - retries++; - } - const hardTemplate = new TrainerPartyCompoundTemplate( - new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER, false, true), - new TrainerPartyTemplate( - Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 20), 5), - PartyMemberStrength.AVERAGE, - false, - true - ) - ); - const hardConfig = trainerConfigs[hardTrainerType].clone(); - hardConfig.setPartyTemplates(hardTemplate); - female = false; - if (hardConfig.hasGenders) { - female = !!Utils.randSeedInt(2); - } - const hardSpriteKey = hardConfig.getSpriteKey(female, hardConfig.doubleOnly); - encounter.enemyPartyConfigs.push({ - trainerConfig: hardConfig, - levelAdditiveModifier: 1, - female: female, + // Seed offsets to remove possibility of different trainers having exact same teams + let initBattlePromise: Promise; + globalScene.executeWithSeedOffset(() => { + initBattlePromise = initBattleWithEnemyConfig(config); + }, globalScene.currentBattle.waveIndex * 10); + await initBattlePromise!; + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }, + async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn hard fight + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[1]; + + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT], + fillRemaining: true, }); - // Brutal trainer is pulled from pool of boss trainers (gym leaders) for the biome - // They are given an E4 template team, so will be stronger than usual boss encounter and always have 6 mons - const brutalTrainerType = globalScene.arena.randomTrainerType( - globalScene.currentBattle.waveIndex, - true - ); - const e4Template = trainerPartyTemplates.ELITE_FOUR; - const brutalConfig = trainerConfigs[brutalTrainerType].clone(); - brutalConfig.title = trainerConfigs[brutalTrainerType].title; - brutalConfig.setPartyTemplates(e4Template); - // @ts-ignore - brutalConfig.partyTemplateFunc = null; // Overrides gym leader party template func - female = false; - if (brutalConfig.hasGenders) { - female = !!Utils.randSeedInt(2); - } - const brutalSpriteKey = brutalConfig.getSpriteKey(female, brutalConfig.doubleOnly); - encounter.enemyPartyConfigs.push({ - trainerConfig: brutalConfig, - levelAdditiveModifier: 1.5, - female: female, + // Seed offsets to remove possibility of different trainers having exact same teams + let initBattlePromise: Promise; + globalScene.executeWithSeedOffset(() => { + initBattlePromise = initBattleWithEnemyConfig(config); + }, globalScene.currentBattle.waveIndex * 100); + await initBattlePromise!; + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }, + async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn brutal fight + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[2]; + + // To avoid player level snowballing from picking this option + encounter.expMultiplier = 0.9; + + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.GREAT], + fillRemaining: true, }); - encounter.spriteConfigs = [ - { - spriteKey: normalSpriteKey, - fileRoot: "trainer", - hasShadow: true, - tint: 1, - }, - { - spriteKey: hardSpriteKey, - fileRoot: "trainer", - hasShadow: true, - tint: 1, - }, - { - spriteKey: brutalSpriteKey, - fileRoot: "trainer", - hasShadow: true, - tint: 1, - }, - ]; - - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn standard trainer battle with memory mushroom reward - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.TM_COMMON, modifierTypes.TM_GREAT, modifierTypes.MEMORY_MUSHROOM ], fillRemaining: true }); - - // Seed offsets to remove possibility of different trainers having exact same teams - let initBattlePromise: Promise; - globalScene.executeWithSeedOffset(() => { - initBattlePromise = initBattleWithEnemyConfig(config); - }, globalScene.currentBattle.waveIndex * 10); - await initBattlePromise!; - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn hard fight - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[1]; - - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], fillRemaining: true }); - - // Seed offsets to remove possibility of different trainers having exact same teams - let initBattlePromise: Promise; - globalScene.executeWithSeedOffset(() => { - initBattlePromise = initBattleWithEnemyConfig(config); - }, globalScene.currentBattle.waveIndex * 100); - await initBattlePromise!; - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn brutal fight - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[2]; - - // To avoid player level snowballing from picking this option - encounter.expMultiplier = 0.9; - - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.GREAT ], fillRemaining: true }); - - // Seed offsets to remove possibility of different trainers having exact same teams - let initBattlePromise: Promise; - globalScene.executeWithSeedOffset(() => { - initBattlePromise = initBattleWithEnemyConfig(config); - }, globalScene.currentBattle.waveIndex * 1000); - await initBattlePromise!; - } - ) - .withOutroDialogue([ - { - text: `${namespace}:outro`, - }, - ]) - .build(); + // Seed offsets to remove possibility of different trainers having exact same teams + let initBattlePromise: Promise; + globalScene.executeWithSeedOffset(() => { + initBattlePromise = initBattleWithEnemyConfig(config); + }, globalScene.currentBattle.waveIndex * 1000); + await initBattlePromise!; + }, + ) + .withOutroDialogue([ + { + text: `${namespace}:outro`, + }, + ]) + .build(); diff --git a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts index 9b4999020d0..c295e36749a 100644 --- a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts @@ -4,8 +4,16 @@ import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-en import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { getHighestLevelPlayerPokemon, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + getHighestLevelPlayerPokemon, + koPlayerPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; import { ModifierTier } from "#app/modifier/modifier-tier"; @@ -32,183 +40,181 @@ const MASTER_REWARDS_PERCENT = 5; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3796 | GitHub Issue #3796} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const MysteriousChestEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHEST) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withScenePartySizeRequirement(2, 6, true) - .withAutoHideIntroVisuals(false) - .withCatchAllowed(true) - .withIntroSpriteConfigs([ - { - spriteKey: "mysterious_chest_blue", - fileRoot: "mystery-encounters", - hasShadow: true, - y: 8, - yShadow: 6, - alpha: 1, - disableAnimation: true, // Re-enabled after option select - }, - { - spriteKey: "mysterious_chest_red", - fileRoot: "mystery-encounters", - hasShadow: false, - y: 8, - yShadow: 6, - alpha: 0, - disableAnimation: true, // Re-enabled after option select - } - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const MysteriousChestEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.MYSTERIOUS_CHEST, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withScenePartySizeRequirement(2, 6, true) + .withAutoHideIntroVisuals(false) + .withCatchAllowed(true) + .withIntroSpriteConfigs([ + { + spriteKey: "mysterious_chest_blue", + fileRoot: "mystery-encounters", + hasShadow: true, + y: 8, + yShadow: 6, + alpha: 1, + disableAnimation: true, // Re-enabled after option select + }, + { + spriteKey: "mysterious_chest_red", + fileRoot: "mystery-encounters", + hasShadow: false, + y: 8, + yShadow: 6, + alpha: 0, + disableAnimation: true, // Re-enabled after option select + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculate boss mon - const config: EnemyPartyConfig = { - levelAdditiveModifier: 0.5, - disableSwitch: true, - pokemonConfigs: [ - { - species: getPokemonSpecies(Species.GIMMIGHOUL), - formIndex: 0, - isBoss: true, - moveSet: [ Moves.NASTY_PLOT, Moves.SHADOW_BALL, Moves.POWER_GEM, Moves.THIEF ] - } - ], - }; + // Calculate boss mon + const config: EnemyPartyConfig = { + levelAdditiveModifier: 0.5, + disableSwitch: true, + pokemonConfigs: [ + { + species: getPokemonSpecies(Species.GIMMIGHOUL), + formIndex: 0, + isBoss: true, + moveSet: [Moves.NASTY_PLOT, Moves.SHADOW_BALL, Moves.POWER_GEM, Moves.THIEF], + }, + ], + }; - encounter.enemyPartyConfigs = [ config ]; + encounter.enemyPartyConfigs = [config]; - encounter.setDialogueToken("gimmighoulName", getPokemonSpecies(Species.GIMMIGHOUL).getName()); - encounter.setDialogueToken("trapPercent", TRAP_PERCENT.toString()); - encounter.setDialogueToken("commonPercent", COMMON_REWARDS_PERCENT.toString()); - encounter.setDialogueToken("ultraPercent", ULTRA_REWARDS_PERCENT.toString()); - encounter.setDialogueToken("roguePercent", ROGUE_REWARDS_PERCENT.toString()); - encounter.setDialogueToken("masterPercent", MASTER_REWARDS_PERCENT.toString()); + encounter.setDialogueToken("gimmighoulName", getPokemonSpecies(Species.GIMMIGHOUL).getName()); + encounter.setDialogueToken("trapPercent", TRAP_PERCENT.toString()); + encounter.setDialogueToken("commonPercent", COMMON_REWARDS_PERCENT.toString()); + encounter.setDialogueToken("ultraPercent", ULTRA_REWARDS_PERCENT.toString()); + encounter.setDialogueToken("roguePercent", ROGUE_REWARDS_PERCENT.toString()); + encounter.setDialogueToken("masterPercent", MASTER_REWARDS_PERCENT.toString()); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Play animation - const encounter = globalScene.currentBattle.mysteryEncounter!; - const introVisuals = encounter.introVisuals!; - - // Determine roll first - const roll = randSeedInt(RAND_LENGTH); - encounter.misc = { - roll - }; - - if (roll < TRAP_PERCENT) { - // Chest is springing trap, change to red chest sprite - const blueChestSprites = introVisuals.getSpriteAtIndex(0); - const redChestSprites = introVisuals.getSpriteAtIndex(1); - redChestSprites[0].setAlpha(1); - blueChestSprites[0].setAlpha(0.001); - } - introVisuals.spriteConfigs[0].disableAnimation = false; - introVisuals.spriteConfigs[1].disableAnimation = false; - introVisuals.playAnim(); - }) - .withOptionPhase(async () => { - // Open the chest - const encounter = globalScene.currentBattle.mysteryEncounter!; - const roll = encounter.misc.roll; - if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT) { - // Choose between 2 COMMON / 2 GREAT tier items (20%) - setEncounterRewards({ - guaranteedModifierTiers: [ - ModifierTier.COMMON, - ModifierTier.COMMON, - ModifierTier.GREAT, - ModifierTier.GREAT, - ], - }); - // Display result message then proceed to rewards - queueEncounterMessage(`${namespace}:option.1.normal`); - leaveEncounterWithoutBattle(); - } else if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT) { - // Choose between 3 ULTRA tier items (30%) - setEncounterRewards({ - guaranteedModifierTiers: [ - ModifierTier.ULTRA, - ModifierTier.ULTRA, - ModifierTier.ULTRA, - ], - }); - // Display result message then proceed to rewards - queueEncounterMessage(`${namespace}:option.1.good`); - leaveEncounterWithoutBattle(); - } else if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT - ROGUE_REWARDS_PERCENT) { - // Choose between 2 ROGUE tier items (10%) - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE ]}); - // Display result message then proceed to rewards - queueEncounterMessage(`${namespace}:option.1.great`); - leaveEncounterWithoutBattle(); - } else if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT - ROGUE_REWARDS_PERCENT - MASTER_REWARDS_PERCENT) { - // Choose 1 MASTER tier item (5%) - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.MASTER ]}); - // Display result message then proceed to rewards - queueEncounterMessage(`${namespace}:option.1.amazing`); - leaveEncounterWithoutBattle(); - } else { - // Your highest level unfainted Pokemon gets OHKO. Start battle against a Gimmighoul (35%) - const highestLevelPokemon = getHighestLevelPlayerPokemon(true, false); - koPlayerPokemon(highestLevelPokemon); - - encounter.setDialogueToken("pokeName", highestLevelPokemon.getNameToRender()); - await showEncounterText(`${namespace}:option.1.bad`); - - // Handle game over edge case - const allowedPokemon = globalScene.getPokemonAllowedInBattle(); - if (allowedPokemon.length === 0) { - // If there are no longer any legal pokemon in the party, game over. - globalScene.clearPhaseQueue(); - globalScene.unshiftPhase(new GameOverPhase()); - } else { - // Show which Pokemon was KOed, then start battle against Gimmighoul - await transitionMysteryEncounterIntroVisuals(true, true, 500); - setEncounterRewards({ fillRemaining: true }); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - } - } - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.2.selected`, + text: `${namespace}:option.1.selected`, }, ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + }) + .withPreOptionPhase(async () => { + // Play animation + const encounter = globalScene.currentBattle.mysteryEncounter!; + const introVisuals = encounter.introVisuals!; + + // Determine roll first + const roll = randSeedInt(RAND_LENGTH); + encounter.misc = { + roll, + }; + + if (roll < TRAP_PERCENT) { + // Chest is springing trap, change to red chest sprite + const blueChestSprites = introVisuals.getSpriteAtIndex(0); + const redChestSprites = introVisuals.getSpriteAtIndex(1); + redChestSprites[0].setAlpha(1); + blueChestSprites[0].setAlpha(0.001); + } + introVisuals.spriteConfigs[0].disableAnimation = false; + introVisuals.spriteConfigs[1].disableAnimation = false; + introVisuals.playAnim(); + }) + .withOptionPhase(async () => { + // Open the chest + const encounter = globalScene.currentBattle.mysteryEncounter!; + const roll = encounter.misc.roll; + if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT) { + // Choose between 2 COMMON / 2 GREAT tier items (20%) + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.GREAT, ModifierTier.GREAT], + }); + // Display result message then proceed to rewards + queueEncounterMessage(`${namespace}:option.1.normal`); + leaveEncounterWithoutBattle(); + } else if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT) { + // Choose between 3 ULTRA tier items (30%) + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.ULTRA], + }); + // Display result message then proceed to rewards + queueEncounterMessage(`${namespace}:option.1.good`); + leaveEncounterWithoutBattle(); + } else if (roll >= RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT - ROGUE_REWARDS_PERCENT) { + // Choose between 2 ROGUE tier items (10%) + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ROGUE], + }); + // Display result message then proceed to rewards + queueEncounterMessage(`${namespace}:option.1.great`); + leaveEncounterWithoutBattle(); + } else if ( + roll >= + RAND_LENGTH - COMMON_REWARDS_PERCENT - ULTRA_REWARDS_PERCENT - ROGUE_REWARDS_PERCENT - MASTER_REWARDS_PERCENT + ) { + // Choose 1 MASTER tier item (5%) + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.MASTER], + }); + // Display result message then proceed to rewards + queueEncounterMessage(`${namespace}:option.1.amazing`); + leaveEncounterWithoutBattle(); + } else { + // Your highest level unfainted Pokemon gets OHKO. Start battle against a Gimmighoul (35%) + const highestLevelPokemon = getHighestLevelPlayerPokemon(true, false); + koPlayerPokemon(highestLevelPokemon); + + encounter.setDialogueToken("pokeName", highestLevelPokemon.getNameToRender()); + await showEncounterText(`${namespace}:option.1.bad`); + + // Handle game over edge case + const allowedPokemon = globalScene.getPokemonAllowedInBattle(); + if (allowedPokemon.length === 0) { + // If there are no longer any legal pokemon in the party, game over. + globalScene.clearPhaseQueue(); + globalScene.unshiftPhase(new GameOverPhase()); + } else { + // Show which Pokemon was KOed, then start battle against Gimmighoul + await transitionMysteryEncounterIntroVisuals(true, true, 500); + setEncounterRewards({ fillRemaining: true }); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + } + } + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/part-timer-encounter.ts b/src/data/mystery-encounters/encounters/part-timer-encounter.ts index 4db8e2eb6e8..61b48353997 100644 --- a/src/data/mystery-encounters/encounters/part-timer-encounter.ts +++ b/src/data/mystery-encounters/encounters/part-timer-encounter.ts @@ -1,5 +1,12 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; -import { leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterExp, setEncounterRewards, transitionMysteryEncounterIntroVisuals, updatePlayerMoney } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterExp, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -24,67 +31,68 @@ const namespace = "mysteryEncounters/partTimer"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3813 | GitHub Issue #3813} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const PartTimerEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.PART_TIMER) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withIntroSpriteConfigs([ - { - spriteKey: "part_timer_crate", - fileRoot: "mystery-encounters", - hasShadow: false, - y: 6, - x: 15 - }, - { - spriteKey: "worker_f", - fileRoot: "trainer", - hasShadow: true, - x: -18, - y: 4 - } - ]) - .withAutoHideIntroVisuals(false) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, - }, - ]) - .withOnInit(() => { - // Load sfx - globalScene.loadSe("PRSFX- Horn Drill1", "battle_anims", "PRSFX- Horn Drill1.wav"); - globalScene.loadSe("PRSFX- Horn Drill3", "battle_anims", "PRSFX- Horn Drill3.wav"); - globalScene.loadSe("PRSFX- Guillotine2", "battle_anims", "PRSFX- Guillotine2.wav"); - globalScene.loadSe("PRSFX- Heavy Slam2", "battle_anims", "PRSFX- Heavy Slam2.wav"); +export const PartTimerEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.PART_TIMER, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withIntroSpriteConfigs([ + { + spriteKey: "part_timer_crate", + fileRoot: "mystery-encounters", + hasShadow: false, + y: 6, + x: 15, + }, + { + spriteKey: "worker_f", + fileRoot: "trainer", + hasShadow: true, + x: -18, + y: 4, + }, + ]) + .withAutoHideIntroVisuals(false) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .withOnInit(() => { + // Load sfx + globalScene.loadSe("PRSFX- Horn Drill1", "battle_anims", "PRSFX- Horn Drill1.wav"); + globalScene.loadSe("PRSFX- Horn Drill3", "battle_anims", "PRSFX- Horn Drill3.wav"); + globalScene.loadSe("PRSFX- Guillotine2", "battle_anims", "PRSFX- Guillotine2.wav"); + globalScene.loadSe("PRSFX- Heavy Slam2", "battle_anims", "PRSFX- Heavy Slam2.wav"); - globalScene.loadSe("PRSFX- Agility", "battle_anims", "PRSFX- Agility.wav"); - globalScene.loadSe("PRSFX- Extremespeed1", "battle_anims", "PRSFX- Extremespeed1.wav"); - globalScene.loadSe("PRSFX- Accelerock1", "battle_anims", "PRSFX- Accelerock1.wav"); + globalScene.loadSe("PRSFX- Agility", "battle_anims", "PRSFX- Agility.wav"); + globalScene.loadSe("PRSFX- Extremespeed1", "battle_anims", "PRSFX- Extremespeed1.wav"); + globalScene.loadSe("PRSFX- Accelerock1", "battle_anims", "PRSFX- Accelerock1.wav"); - globalScene.loadSe("PRSFX- Captivate", "battle_anims", "PRSFX- Captivate.wav"); - globalScene.loadSe("PRSFX- Attract2", "battle_anims", "PRSFX- Attract2.wav"); - globalScene.loadSe("PRSFX- Aurora Veil2", "battle_anims", "PRSFX- Aurora Veil2.wav"); + globalScene.loadSe("PRSFX- Captivate", "battle_anims", "PRSFX- Captivate.wav"); + globalScene.loadSe("PRSFX- Attract2", "battle_anims", "PRSFX- Attract2.wav"); + globalScene.loadSe("PRSFX- Aurora Veil2", "battle_anims", "PRSFX- Aurora Veil2.wav"); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:option.1.label`, buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.1.selected` - } - ] + text: `${namespace}:option.1.selected`, + }, + ], }) .withPreOptionPhase(async () => { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -95,21 +103,21 @@ export const PartTimerEncounter: MysteryEncounter = // Calculate the "baseline" stat value (90 base stat, 16 IVs, neutral nature, same level as pokemon) to compare // Resulting money is 2.5 * (% difference from baseline), with minimum of 1 and maximum of 4. // Calculation from Pokemon.calculateStats - const baselineValue = Math.floor(((2 * 90 + 16) * pokemon.level) * 0.01) + 5; + const baselineValue = Math.floor((2 * 90 + 16) * pokemon.level * 0.01) + 5; const percentDiff = (pokemon.getStat(Stat.SPD) - baselineValue) / baselineValue; const moneyMultiplier = Math.min(Math.max(2.5 * (1 + percentDiff), 1), 4); encounter.misc = { - moneyMultiplier + moneyMultiplier, }; // Reduce all PP to 2 (if they started at greater than 2) - pokemon.moveset.forEach(move => { + for (const move of pokemon.moveset) { if (move) { const newPpUsed = move.getMovePp() - 2; move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed; } - }); + } setEncounterExp(pokemon.id, 100); @@ -141,24 +149,28 @@ export const PartTimerEncounter: MysteryEncounter = } const moneyChange = globalScene.getWaveMoneyAmount(moneyMultiplier); updatePlayerMoney(moneyChange, true, false); - await showEncounterText(i18next.t("mysteryEncounterMessages:receive_money", { amount: moneyChange })); + await showEncounterText( + i18next.t("mysteryEncounterMessages:receive_money", { + amount: moneyChange, + }), + ); await showEncounterText(`${namespace}:pokemon_tired`); setEncounterRewards({ fillRemaining: true }); leaveEncounterWithoutBattle(); }) - .build() - ) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:option.2.label`, buttonTooltip: `${namespace}:option.2.tooltip`, selected: [ { - text: `${namespace}:option.2.selected` - } - ] + text: `${namespace}:option.2.selected`, + }, + ], }) .withPreOptionPhase(async () => { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -169,24 +181,25 @@ export const PartTimerEncounter: MysteryEncounter = // Calculate the "baseline" stat value (75 base stat, 16 IVs, neutral nature, same level as pokemon) to compare // Resulting money is 2.5 * (% difference from baseline), with minimum of 1 and maximum of 4. // Calculation from Pokemon.calculateStats - const baselineHp = Math.floor(((2 * 75 + 16) * pokemon.level) * 0.01) + pokemon.level + 10; - const baselineAtkDef = Math.floor(((2 * 75 + 16) * pokemon.level) * 0.01) + 5; + const baselineHp = Math.floor((2 * 75 + 16) * pokemon.level * 0.01) + pokemon.level + 10; + const baselineAtkDef = Math.floor((2 * 75 + 16) * pokemon.level * 0.01) + 5; const baselineValue = baselineHp + 1.5 * (baselineAtkDef * 2); - const strongestValue = pokemon.getStat(Stat.HP) + 1.5 * (pokemon.getStat(Stat.ATK) + pokemon.getStat(Stat.DEF)); + const strongestValue = + pokemon.getStat(Stat.HP) + 1.5 * (pokemon.getStat(Stat.ATK) + pokemon.getStat(Stat.DEF)); const percentDiff = (strongestValue - baselineValue) / baselineValue; const moneyMultiplier = Math.min(Math.max(2.5 * (1 + percentDiff), 1), 4); encounter.misc = { - moneyMultiplier + moneyMultiplier, }; // Reduce all PP to 2 (if they started at greater than 2) - pokemon.moveset.forEach(move => { + for (const move of pokemon.moveset) { if (move) { const newPpUsed = move.getMovePp() - 2; move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed; } - }); + } setEncounterExp(pokemon.id, 100); @@ -218,73 +231,80 @@ export const PartTimerEncounter: MysteryEncounter = } const moneyChange = globalScene.getWaveMoneyAmount(moneyMultiplier); updatePlayerMoney(moneyChange, true, false); - await showEncounterText(i18next.t("mysteryEncounterMessages:receive_money", { amount: moneyChange })); + await showEncounterText( + i18next.t("mysteryEncounterMessages:receive_money", { + amount: moneyChange, + }), + ); await showEncounterText(`${namespace}:pokemon_tired`); setEncounterRewards({ fillRemaining: true }); leaveEncounterWithoutBattle(); }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement(new MoveRequirement(CHARMING_MOVES, true)) // Will set option3PrimaryName and option3PrimaryMove dialogue tokens automatically - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const selectedPokemon = encounter.selectedOption?.primaryPokemon!; - encounter.setDialogueToken("selectedPokemon", selectedPokemon.getNameToRender()); + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement(new MoveRequirement(CHARMING_MOVES, true)) // Will set option3PrimaryName and option3PrimaryMove dialogue tokens automatically + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }) + .withPreOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const selectedPokemon = encounter.selectedOption?.primaryPokemon!; + encounter.setDialogueToken("selectedPokemon", selectedPokemon.getNameToRender()); - // Reduce all PP to 2 (if they started at greater than 2) - selectedPokemon.moveset.forEach(move => { - if (move) { - const newPpUsed = move.getMovePp() - 2; - move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed; - } - }); + // Reduce all PP to 2 (if they started at greater than 2) + for (const move of selectedPokemon.moveset) { + if (move) { + const newPpUsed = move.getMovePp() - 2; + move.ppUsed = move.ppUsed < newPpUsed ? newPpUsed : move.ppUsed; + } + } - setEncounterExp(selectedPokemon.id, 100); + setEncounterExp(selectedPokemon.id, 100); - // Hide intro visuals - transitionMysteryEncounterIntroVisuals(true, false); - // Play sfx for "working" - doSalesSfx(); - return true; - }) - .withOptionPhase(async () => { - // Assist with Sales - // Bring visuals back in - await transitionMysteryEncounterIntroVisuals(false, false); + // Hide intro visuals + transitionMysteryEncounterIntroVisuals(true, false); + // Play sfx for "working" + doSalesSfx(); + return true; + }) + .withOptionPhase(async () => { + // Assist with Sales + // Bring visuals back in + await transitionMysteryEncounterIntroVisuals(false, false); - // Give money and do dialogue - await showEncounterDialogue(`${namespace}:job_complete_good`, `${namespace}:speaker`); - const moneyChange = globalScene.getWaveMoneyAmount(2.5); - updatePlayerMoney(moneyChange, true, false); - await showEncounterText(i18next.t("mysteryEncounterMessages:receive_money", { amount: moneyChange })); - await showEncounterText(`${namespace}:pokemon_tired`); + // Give money and do dialogue + await showEncounterDialogue(`${namespace}:job_complete_good`, `${namespace}:speaker`); + const moneyChange = globalScene.getWaveMoneyAmount(2.5); + updatePlayerMoney(moneyChange, true, false); + await showEncounterText( + i18next.t("mysteryEncounterMessages:receive_money", { + amount: moneyChange, + }), + ); + await showEncounterText(`${namespace}:pokemon_tired`); - setEncounterRewards({ fillRemaining: true }); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .withOutroDialogue([ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:outro`, - } - ]) - .build(); + setEncounterRewards({ fillRemaining: true }); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .withOutroDialogue([ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:outro`, + }, + ]) + .build(); function doStrongWorkSfx() { globalScene.playSound("battle_anims/PRSFX- Horn Drill1"); diff --git a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts index 130c55c361e..f231e4abdb8 100644 --- a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts +++ b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts @@ -1,4 +1,9 @@ -import { initSubsequentOptionSelect, leaveEncounterWithoutBattle, transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + initSubsequentOptionSelect, + leaveEncounterWithoutBattle, + transitionMysteryEncounterIntroVisuals, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -14,7 +19,12 @@ import { NumberHolder, randSeedInt } from "#app/utils"; 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"; -import { doPlayerFlee, doPokemonFlee, getRandomSpeciesByStarterCost, trainerThrowPokeball } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + doPlayerFlee, + doPokemonFlee, + getRandomSpeciesByStarterCost, + trainerThrowPokeball, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { getPokemonNameWithAffix } from "#app/messages"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -27,7 +37,7 @@ import { NON_LEGEND_PARADOX_POKEMON } from "#app/data/balance/special-species-gr /** the i18n namespace for the encounter */ const namespace = "mysteryEncounters/safariZone"; -const TRAINER_THROW_ANIMATION_TIMES = [ 512, 184, 768 ]; +const TRAINER_THROW_ANIMATION_TIMES = [512, 184, 768]; const SAFARI_MONEY_MULTIPLIER = 2; @@ -38,36 +48,37 @@ const NUM_SAFARI_ENCOUNTERS = 3; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3800 | GitHub Issue #3800} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const SafariZoneEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.SAFARI_ZONE) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new MoneyRequirement(0, SAFARI_MONEY_MULTIPLIER)) // Cost equal to 1 Max Revive - .withAutoHideIntroVisuals(false) - .withIntroSpriteConfigs([ - { - spriteKey: "safari_zone", - fileRoot: "mystery-encounters", - hasShadow: false, - x: 4, - y: 6 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - globalScene.currentBattle.mysteryEncounter?.setDialogueToken("numEncounters", NUM_SAFARI_ENCOUNTERS.toString()); - return true; - }) - .withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) +export const SafariZoneEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.SAFARI_ZONE, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new MoneyRequirement(0, SAFARI_MONEY_MULTIPLIER)) // Cost equal to 1 Max Revive + .withAutoHideIntroVisuals(false) + .withIntroSpriteConfigs([ + { + spriteKey: "safari_zone", + fileRoot: "mystery-encounters", + hasShadow: false, + x: 4, + y: 6, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + globalScene.currentBattle.mysteryEncounter?.setDialogueToken("numEncounters", NUM_SAFARI_ENCOUNTERS.toString()); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) .withSceneRequirement(new MoneyRequirement(0, SAFARI_MONEY_MULTIPLIER)) // Cost equal to 1 Max Revive .withDialogue({ buttonLabel: `${namespace}:option.1.label`, @@ -83,7 +94,7 @@ export const SafariZoneEncounter: MysteryEncounter = const encounter = globalScene.currentBattle.mysteryEncounter!; encounter.continuousEncounter = true; encounter.misc = { - safariPokemonRemaining: NUM_SAFARI_ENCOUNTERS + safariPokemonRemaining: NUM_SAFARI_ENCOUNTERS, }; updatePlayerMoney(-(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney); // Load bait/mud assets @@ -96,28 +107,31 @@ export const SafariZoneEncounter: MysteryEncounter = globalScene.currentBattle.enemyParty = []; await transitionMysteryEncounterIntroVisuals(); await summonSafariPokemon(); - initSubsequentOptionSelect({ overrideOptions: safariZoneGameOptions, hideDescription: true }); + initSubsequentOptionSelect({ + overrideOptions: safariZoneGameOptions, + hideDescription: true, + }); return true; }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); /** * SAFARI ZONE MINIGAME OPTIONS @@ -135,15 +149,14 @@ export const SafariZoneEncounter: MysteryEncounter = * Flee chance = fleeRate / 255 */ const safariZoneGameOptions: MysteryEncounterOption[] = [ - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:safari.1.label`, buttonTooltip: `${namespace}:safari.1.tooltip`, selected: [ { text: `${namespace}:safari.1.selected`, - } + }, ], }) .withOptionPhase(async () => { @@ -157,7 +170,11 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ // Check how many safari pokemon left if (encounter.misc.safariPokemonRemaining > 0) { await summonSafariPokemon(); - initSubsequentOptionSelect({ overrideOptions: safariZoneGameOptions, startingCursorIndex: 0, hideDescription: true }); + initSubsequentOptionSelect({ + overrideOptions: safariZoneGameOptions, + startingCursorIndex: 0, + hideDescription: true, + }); } else { // End safari mode encounter.continuousEncounter = false; @@ -170,8 +187,7 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ return true; }) .build(), - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:safari.2.label`, buttonTooltip: `${namespace}:safari.2.tooltip`, @@ -191,7 +207,7 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ // 80% chance to increase flee stage +1 const fleeChangeResult = tryChangeFleeStage(1, 8); if (!fleeChangeResult) { - await showEncounterText(getEncounterText(`${namespace}:safari.busy_eating`) ?? "", null, 1000, false ); + await showEncounterText(getEncounterText(`${namespace}:safari.busy_eating`) ?? "", null, 1000, false); } else { await showEncounterText(getEncounterText(`${namespace}:safari.eating`) ?? "", null, 1000, false); } @@ -200,8 +216,7 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ return true; }) .build(), - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:safari.3.label`, buttonTooltip: `${namespace}:safari.3.tooltip`, @@ -220,17 +235,16 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ // 80% chance to decrease catch stage -1 const catchChangeResult = tryChangeCatchStage(-1, 8); if (!catchChangeResult) { - await showEncounterText(getEncounterText(`${namespace}:safari.beside_itself_angry`) ?? "", null, 1000, false ); + await showEncounterText(getEncounterText(`${namespace}:safari.beside_itself_angry`) ?? "", null, 1000, false); } else { - await showEncounterText(getEncounterText(`${namespace}:safari.angry`) ?? "", null, 1000, false ); + await showEncounterText(getEncounterText(`${namespace}:safari.angry`) ?? "", null, 1000, false); } await doEndTurn(2); return true; }) .build(), - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) .withDialogue({ buttonLabel: `${namespace}:safari.4.label`, buttonTooltip: `${namespace}:safari.4.tooltip`, @@ -243,7 +257,11 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ // Check how many safari pokemon left if (encounter.misc.safariPokemonRemaining > 0) { await summonSafariPokemon(); - initSubsequentOptionSelect({ overrideOptions: safariZoneGameOptions, startingCursorIndex: 3, hideDescription: true }); + initSubsequentOptionSelect({ + overrideOptions: safariZoneGameOptions, + startingCursorIndex: 3, + hideDescription: true, + }); } else { // End safari mode encounter.continuousEncounter = false; @@ -251,7 +269,7 @@ const safariZoneGameOptions: MysteryEncounterOption[] = [ } return true; }) - .build() + .build(), ]; async function summonSafariPokemon() { @@ -262,38 +280,41 @@ async function summonSafariPokemon() { // Generate pokemon using safariPokemonRemaining so they are always the same pokemon no matter how many turns are taken // Safari pokemon roll twice on shiny and HA chances, but are otherwise normal - let enemySpecies; - let pokemon; - globalScene.executeWithSeedOffset(() => { - enemySpecies = getSafariSpeciesSpawn(); - const level = globalScene.currentBattle.getLevelForWave(); - enemySpecies = getPokemonSpecies(enemySpecies.getWildSpeciesForLevel(level, true, false, globalScene.gameMode)); - pokemon = globalScene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, false); + let enemySpecies: PokemonSpecies; + let pokemon: any; + globalScene.executeWithSeedOffset( + () => { + enemySpecies = getSafariSpeciesSpawn(); + const level = globalScene.currentBattle.getLevelForWave(); + enemySpecies = getPokemonSpecies(enemySpecies.getWildSpeciesForLevel(level, true, false, globalScene.gameMode)); + pokemon = globalScene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, false); - // Roll shiny twice - if (!pokemon.shiny) { - pokemon.trySetShinySeed(); - } + // Roll shiny twice + if (!pokemon.shiny) { + pokemon.trySetShinySeed(); + } - // Roll HA twice - if (pokemon.species.abilityHidden) { - const hiddenIndex = pokemon.species.ability2 ? 2 : 1; - if (pokemon.abilityIndex < hiddenIndex) { - const hiddenAbilityChance = new NumberHolder(256); - globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); + // Roll HA twice + if (pokemon.species.abilityHidden) { + const hiddenIndex = pokemon.species.ability2 ? 2 : 1; + if (pokemon.abilityIndex < hiddenIndex) { + const hiddenAbilityChance = new NumberHolder(256); + globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); - const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); + const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); - if (hasHiddenAbility) { - pokemon.abilityIndex = hiddenIndex; + if (hasHiddenAbility) { + pokemon.abilityIndex = hiddenIndex; + } } } - } - pokemon.calculateStats(); + pokemon.calculateStats(); - globalScene.currentBattle.enemyParty.unshift(pokemon); - }, globalScene.currentBattle.waveIndex * 1000 * encounter.misc.safariPokemonRemaining); + globalScene.currentBattle.enemyParty.unshift(pokemon); + }, + globalScene.currentBattle.waveIndex * 1000 * encounter.misc.safariPokemonRemaining, + ); globalScene.gameData.setPokemonSeen(pokemon, true); await pokemon.loadAssets(); @@ -324,7 +345,8 @@ function throwPokeball(pokemon: EnemyPokemon): Promise { // Catch stage ranges from -6 to +6 (like stat boost stages) const safariCatchStage = globalScene.currentBattle.mysteryEncounter!.misc.catchStage; // Catch modifier ranges from 2/8 (-6 stage) to 8/2 (+6) - const safariModifier = (2 + Math.min(Math.max(safariCatchStage, 0), 6)) / (2 - Math.max(Math.min(safariCatchStage, 0), -6)); + const safariModifier = + (2 + Math.min(Math.max(safariCatchStage, 0), 6)) / (2 - Math.max(Math.min(safariCatchStage, 0), -6)); // Catch rate same as safari ball const pokeballMultiplier = 1.5; const catchRate = Math.round(baseCatchRate * pokeballMultiplier * safariModifier); @@ -341,7 +363,9 @@ async function throwBait(pokemon: EnemyPokemon): Promise { globalScene.field.add(bait); return new Promise(resolve => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`, + ); globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[0], () => { globalScene.playSound("se/pb_throw"); @@ -350,7 +374,9 @@ async function throwBait(pokemon: EnemyPokemon): Promise { globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[1], () => { globalScene.trainer.setFrame("3"); globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[2], () => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`, + ); }); }); @@ -361,7 +387,6 @@ async function throwBait(pokemon: EnemyPokemon): Promise { y: { value: 55 + fpOffset[1], ease: "Cubic.easeOut" }, duration: 500, onComplete: () => { - let index = 1; globalScene.time.delayedCall(768, () => { globalScene.tweens.add({ @@ -389,10 +414,10 @@ async function throwBait(pokemon: EnemyPokemon): Promise { bait.destroy(); resolve(true); }); - } + }, }); }); - } + }, }); }); }); @@ -407,7 +432,9 @@ async function throwMud(pokemon: EnemyPokemon): Promise { globalScene.field.add(mud); return new Promise(resolve => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`, + ); globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[0], () => { globalScene.playSound("se/pb_throw"); @@ -416,7 +443,9 @@ async function throwMud(pokemon: EnemyPokemon): Promise { globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[1], () => { globalScene.trainer.setFrame("3"); globalScene.time.delayedCall(TRAINER_THROW_ANIMATION_TIMES[2], () => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`, + ); }); }); @@ -461,11 +490,11 @@ async function throwMud(pokemon: EnemyPokemon): Promise { }, onComplete: () => { resolve(true); - } + }, }); - } + }, }); - } + }, }); }); }); @@ -474,7 +503,7 @@ async function throwMud(pokemon: EnemyPokemon): Promise { function isPokemonFlee(pokemon: EnemyPokemon, fleeStage: number): boolean { const speciesCatchRate = pokemon.species.catchRate; const fleeModifier = (2 + Math.min(Math.max(fleeStage, 0), 6)) / (2 - Math.max(Math.min(fleeStage, 0), -6)); - const fleeRate = (255 * 255 - speciesCatchRate * speciesCatchRate) / 255 / 2 * fleeModifier; + const fleeRate = ((255 * 255 - speciesCatchRate * speciesCatchRate) / 255 / 2) * fleeModifier; console.log("Flee rate: " + fleeRate); const roll = randSeedInt(256); console.log("Roll: " + roll); @@ -519,7 +548,11 @@ async function doEndTurn(cursorIndex: number) { // Check how many safari pokemon left if (encounter.misc.safariPokemonRemaining > 0) { await summonSafariPokemon(); - initSubsequentOptionSelect({ overrideOptions: safariZoneGameOptions, startingCursorIndex: cursorIndex, hideDescription: true }); + initSubsequentOptionSelect({ + overrideOptions: safariZoneGameOptions, + startingCursorIndex: cursorIndex, + hideDescription: true, + }); } else { // End safari mode encounter.continuousEncounter = false; @@ -527,7 +560,11 @@ async function doEndTurn(cursorIndex: number) { } } else { globalScene.queueMessage(getEncounterText(`${namespace}:safari.watching`) ?? "", 0, null, 1000); - initSubsequentOptionSelect({ overrideOptions: safariZoneGameOptions, startingCursorIndex: cursorIndex, hideDescription: true }); + initSubsequentOptionSelect({ + overrideOptions: safariZoneGameOptions, + startingCursorIndex: cursorIndex, + hideDescription: true, + }); } } @@ -535,5 +572,7 @@ async function doEndTurn(cursorIndex: number) { * @returns A random species that has at most 5 starter cost and is not Mythical, Paradox, etc. */ export function getSafariSpeciesSpawn(): PokemonSpecies { - return getPokemonSpecies(getRandomSpeciesByStarterCost([ 0, 5 ], NON_LEGEND_PARADOX_POKEMON, undefined, false, false, false)); + return getPokemonSpecies( + getRandomSpeciesByStarterCost([0, 5], NON_LEGEND_PARADOX_POKEMON, undefined, false, false, false), + ); } 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 d5362df28e7..b9476d49fec 100644 --- a/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts +++ b/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts @@ -1,4 +1,10 @@ -import { generateModifierType, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterExp, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterExp, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { modifierTypes } from "#app/modifier/modifier-type"; @@ -11,7 +17,11 @@ import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-en import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { getEncounterText, queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { applyDamageToPokemon, applyModifierTypeToPlayerPokemon, isPokemonValidForEncounterOptionSelection } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + applyDamageToPokemon, + applyModifierTypeToPlayerPokemon, + isPokemonValidForEncounterOptionSelection, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import type { Nature } from "#enums/nature"; @@ -30,201 +40,204 @@ const VITAMIN_DEALER_EXPENSIVE_PRICE_MULTIPLIER = 5; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3798 | GitHub Issue #3798} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const ShadyVitaminDealerEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.SHADY_VITAMIN_DEALER) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new MoneyRequirement(0, VITAMIN_DEALER_CHEAP_PRICE_MULTIPLIER)) // Must have the money for at least the cheap deal - .withPrimaryPokemonHealthRatioRequirement([ 0.51, 1 ]) // At least 1 Pokemon must have above half HP - .withIntroSpriteConfigs([ - { - spriteKey: Species.KROOKODILE.toString(), - fileRoot: "pokemon", - hasShadow: true, - repeat: true, - x: 12, - y: -5, - yShadow: -5 - }, - { - spriteKey: "shady_vitamin_dealer", - fileRoot: "mystery-encounters", - hasShadow: true, - x: -12, - y: 3, - yShadow: 3 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withSceneMoneyRequirement(0, VITAMIN_DEALER_CHEAP_PRICE_MULTIPLIER) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Update money - updatePlayerMoney(-(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney); - // Calculate modifiers and dialogue tokens - const modifiers = [ - generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, - generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, - ]; - encounter.setDialogueToken("boost1", modifiers[0].name); - encounter.setDialogueToken("boost2", modifiers[1].name); - encounter.misc = { - chosenPokemon: pokemon, - modifiers: modifiers, - }; - }; - - // Only Pokemon that can gain benefits are above half HP with no status - const selectableFilter = (pokemon: Pokemon) => { - // If pokemon meets primary pokemon reqs, it can be selected - if (!pokemon.isAllowedInChallenge()) { - return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null; - } - if (!encounter.pokemonMeetsPrimaryRequirements(pokemon)) { - return getEncounterText(`${namespace}:invalid_selection`) ?? null; - } - - return null; - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - // Choose Cheap Option - const encounter = globalScene.currentBattle.mysteryEncounter!; - const chosenPokemon = encounter.misc.chosenPokemon; - const modifiers = encounter.misc.modifiers; - - for (const modType of modifiers) { - await applyModifierTypeToPlayerPokemon(chosenPokemon, modType); - } - - leaveEncounterWithoutBattle(true); - }) - .withPostOptionPhase(async () => { - // Damage and status applied after dealer leaves (to make thematic sense) - const encounter = globalScene.currentBattle.mysteryEncounter!; - const chosenPokemon = encounter.misc.chosenPokemon as PlayerPokemon; - - // Pokemon takes half max HP damage and nature is randomized (does not update dex) - applyDamageToPokemon(chosenPokemon, Math.floor(chosenPokemon.getMaxHp() / 2)); - - const currentNature = chosenPokemon.nature; - let newNature = randSeedInt(25) as Nature; - while (newNature === currentNature) { - newNature = randSeedInt(25) as Nature; - } - - chosenPokemon.setCustomNature(newNature); - encounter.setDialogueToken("newNature", getNatureName(newNature)); - queueEncounterMessage(`${namespace}:cheap_side_effects`); - setEncounterExp([ chosenPokemon.id ], 100); - await chosenPokemon.updateInfo(); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withSceneMoneyRequirement(0, VITAMIN_DEALER_EXPENSIVE_PRICE_MULTIPLIER) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Update money - updatePlayerMoney(-(encounter.options[1].requirements[0] as MoneyRequirement).requiredMoney); - // Calculate modifiers and dialogue tokens - const modifiers = [ - generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, - generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, - ]; - encounter.setDialogueToken("boost1", modifiers[0].name); - encounter.setDialogueToken("boost2", modifiers[1].name); - encounter.misc = { - chosenPokemon: pokemon, - modifiers: modifiers, - }; - }; - - // Only Pokemon that can gain benefits are unfainted - const selectableFilter = (pokemon: Pokemon) => { - return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - // Choose Expensive Option - const encounter = globalScene.currentBattle.mysteryEncounter!; - const chosenPokemon = encounter.misc.chosenPokemon; - const modifiers = encounter.misc.modifiers; - - for (const modType of modifiers) { - await applyModifierTypeToPlayerPokemon(chosenPokemon, modType); - } - - leaveEncounterWithoutBattle(true); - }) - .withPostOptionPhase(async () => { - // Status applied after dealer leaves (to make thematic sense) - const encounter = globalScene.currentBattle.mysteryEncounter!; - const chosenPokemon = encounter.misc.chosenPokemon; - - queueEncounterMessage(`${namespace}:no_bad_effects`); - setEncounterExp([ chosenPokemon.id ], 100); - - await chosenPokemon.updateInfo(); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, +export const ShadyVitaminDealerEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.SHADY_VITAMIN_DEALER, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new MoneyRequirement(0, VITAMIN_DEALER_CHEAP_PRICE_MULTIPLIER)) // Must have the money for at least the cheap deal + .withPrimaryPokemonHealthRatioRequirement([0.51, 1]) // At least 1 Pokemon must have above half HP + .withIntroSpriteConfigs([ + { + spriteKey: Species.KROOKODILE.toString(), + fileRoot: "pokemon", + hasShadow: true, + repeat: true, + x: 12, + y: -5, + yShadow: -5, + }, + { + spriteKey: "shady_vitamin_dealer", + fileRoot: "mystery-encounters", + hasShadow: true, + x: -12, + y: 3, + yShadow: 3, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withSceneMoneyRequirement(0, VITAMIN_DEALER_CHEAP_PRICE_MULTIPLIER) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.3.selected`, - speaker: `${namespace}:speaker` + text: `${namespace}:option.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Update money + updatePlayerMoney(-(encounter.options[0].requirements[0] as MoneyRequirement).requiredMoney); + // Calculate modifiers and dialogue tokens + const modifiers = [ + generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, + generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, + ]; + encounter.setDialogueToken("boost1", modifiers[0].name); + encounter.setDialogueToken("boost2", modifiers[1].name); + encounter.misc = { + chosenPokemon: pokemon, + modifiers: modifiers, + }; + }; + + // Only Pokemon that can gain benefits are above half HP with no status + const selectableFilter = (pokemon: Pokemon) => { + // If pokemon meets primary pokemon reqs, it can be selected + if (!pokemon.isAllowedInChallenge()) { + return ( + i18next.t("partyUiHandler:cantBeUsed", { + pokemonName: pokemon.getNameToRender(), + }) ?? null + ); } - ] - }, - async () => { - // Leave encounter with no rewards or exp + if (!encounter.pokemonMeetsPrimaryRequirements(pokemon)) { + return getEncounterText(`${namespace}:invalid_selection`) ?? null; + } + + return null; + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + // Choose Cheap Option + const encounter = globalScene.currentBattle.mysteryEncounter!; + const chosenPokemon = encounter.misc.chosenPokemon; + const modifiers = encounter.misc.modifiers; + + for (const modType of modifiers) { + await applyModifierTypeToPlayerPokemon(chosenPokemon, modType); + } + leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + }) + .withPostOptionPhase(async () => { + // Damage and status applied after dealer leaves (to make thematic sense) + const encounter = globalScene.currentBattle.mysteryEncounter!; + const chosenPokemon = encounter.misc.chosenPokemon as PlayerPokemon; + + // Pokemon takes half max HP damage and nature is randomized (does not update dex) + applyDamageToPokemon(chosenPokemon, Math.floor(chosenPokemon.getMaxHp() / 2)); + + const currentNature = chosenPokemon.nature; + let newNature = randSeedInt(25) as Nature; + while (newNature === currentNature) { + newNature = randSeedInt(25) as Nature; + } + + chosenPokemon.setCustomNature(newNature); + encounter.setDialogueToken("newNature", getNatureName(newNature)); + queueEncounterMessage(`${namespace}:cheap_side_effects`); + setEncounterExp([chosenPokemon.id], 100); + await chosenPokemon.updateInfo(); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withSceneMoneyRequirement(0, VITAMIN_DEALER_EXPENSIVE_PRICE_MULTIPLIER) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Update money + updatePlayerMoney(-(encounter.options[1].requirements[0] as MoneyRequirement).requiredMoney); + // Calculate modifiers and dialogue tokens + const modifiers = [ + generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, + generateModifierType(modifierTypes.BASE_STAT_BOOSTER)!, + ]; + encounter.setDialogueToken("boost1", modifiers[0].name); + encounter.setDialogueToken("boost2", modifiers[1].name); + encounter.misc = { + chosenPokemon: pokemon, + modifiers: modifiers, + }; + }; + + // Only Pokemon that can gain benefits are unfainted + const selectableFilter = (pokemon: Pokemon) => { + return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + // Choose Expensive Option + const encounter = globalScene.currentBattle.mysteryEncounter!; + const chosenPokemon = encounter.misc.chosenPokemon; + const modifiers = encounter.misc.modifiers; + + for (const modType of modifiers) { + await applyModifierTypeToPlayerPokemon(chosenPokemon, modType); + } + + leaveEncounterWithoutBattle(true); + }) + .withPostOptionPhase(async () => { + // Status applied after dealer leaves (to make thematic sense) + const encounter = globalScene.currentBattle.mysteryEncounter!; + const chosenPokemon = encounter.misc.chosenPokemon; + + queueEncounterMessage(`${namespace}:no_bad_effects`); + setEncounterExp([chosenPokemon.id], 100); + + await chosenPokemon.updateInfo(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + speaker: `${namespace}:speaker`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts b/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts index 923d8f06c23..bfa1204a8ba 100644 --- a/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts +++ b/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts @@ -10,7 +10,14 @@ import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-en import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MoveRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import type { EnemyPartyConfig, EnemyPokemonConfig } from "../utils/encounter-phase-utils"; -import { generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, loadCustomMovesForEncounter, setEncounterExp, setEncounterRewards, } from "../utils/encounter-phase-utils"; +import { + generateModifierType, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + loadCustomMovesForEncounter, + setEncounterExp, + setEncounterRewards, +} from "../utils/encounter-phase-utils"; import { queueEncounterMessage } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { Moves } from "#enums/moves"; import { BattlerIndex } from "#app/battle"; @@ -31,141 +38,148 @@ const namespace = "mysteryEncounters/slumberingSnorlax"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3815 | GitHub Issue #3815} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const SlumberingSnorlaxEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.SLUMBERING_SNORLAX) - .withEncounterTier(MysteryEncounterTier.GREAT) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withCatchAllowed(true) - .withHideWildIntroMessage(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - spriteKey: Species.SNORLAX.toString(), - fileRoot: "pokemon", - hasShadow: true, - tint: 0.25, - scale: 1.25, - repeat: true, - y: 5, - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .withOnInit(() => { +export const SlumberingSnorlaxEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.SLUMBERING_SNORLAX, +) + .withEncounterTier(MysteryEncounterTier.GREAT) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withCatchAllowed(true) + .withHideWildIntroMessage(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + spriteKey: Species.SNORLAX.toString(), + fileRoot: "pokemon", + hasShadow: true, + tint: 0.25, + scale: 1.25, + repeat: true, + y: 5, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + console.log(encounter); + + // Calculate boss mon + const bossSpecies = getPokemonSpecies(Species.SNORLAX); + const pokemonConfig: EnemyPokemonConfig = { + species: bossSpecies, + isBoss: true, + shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked + status: [StatusEffect.SLEEP, 5], // Extra turns on timer for Snorlax's start of fight moves + moveSet: [Moves.REST, Moves.SLEEP_TALK, Moves.CRUNCH, Moves.GIGA_IMPACT], + modifierConfigs: [ + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType, + stackCount: 2, + }, + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.ENIGMA]) as PokemonHeldItemModifierType, + stackCount: 2, + }, + ], + customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), + aiType: AiType.SMART, // Required to ensure Snorlax uses Sleep Talk while it is asleep + }; + const config: EnemyPartyConfig = { + levelAdditiveModifier: 0.5, + pokemonConfigs: [pokemonConfig], + }; + encounter.enemyPartyConfigs = [config]; + + // Load animations/sfx for Snorlax fight start moves + loadCustomMovesForEncounter([Moves.SNORE]); + + encounter.setDialogueToken("snorlaxName", getPokemonSpecies(Species.SNORLAX).getName()); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Pick battle const encounter = globalScene.currentBattle.mysteryEncounter!; - console.log(encounter); - - // Calculate boss mon - const bossSpecies = getPokemonSpecies(Species.SNORLAX); - const pokemonConfig: EnemyPokemonConfig = { - species: bossSpecies, - isBoss: true, - shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked - status: [ StatusEffect.SLEEP, 5 ], // Extra turns on timer for Snorlax's start of fight moves - moveSet: [ Moves.REST, Moves.SLEEP_TALK, Moves.CRUNCH, Moves.GIGA_IMPACT ], - modifierConfigs: [ - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ]) as PokemonHeldItemModifierType, - stackCount: 2 - }, - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.ENIGMA ]) as PokemonHeldItemModifierType, - stackCount: 2 - }, - ], - customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), - aiType: AiType.SMART // Required to ensure Snorlax uses Sleep Talk while it is asleep - }; - const config: EnemyPartyConfig = { - levelAdditiveModifier: 0.5, - pokemonConfigs: [ pokemonConfig ], - }; - encounter.enemyPartyConfigs = [ config ]; - - // Load animations/sfx for Snorlax fight start moves - loadCustomMovesForEncounter([ Moves.SNORE ]); - - encounter.setDialogueToken("snorlaxName", getPokemonSpecies(Species.SNORLAX).getName()); - - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.LEFTOVERS], + fillRemaining: true, + }); + encounter.startOfBattleEffects.push( + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.SNORE), + ignorePp: true, + }, + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.SNORE), + ignorePp: true, + }, + ); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Fall asleep waiting for Snorlax + // Full heal party + globalScene.unshiftPhase(new PartyHealPhase(true)); + queueEncounterMessage(`${namespace}:option.2.rest_result`); + leaveEncounterWithoutBattle(); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement(new MoveRequirement(STEALING_MOVES, true)) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, selected: [ { - text: `${namespace}:option.1.selected`, + text: `${namespace}:option.3.selected`, }, ], - }, - async () => { - // Pick battle - const encounter = globalScene.currentBattle.mysteryEncounter!; - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.LEFTOVERS ], fillRemaining: true }); - encounter.startOfBattleEffects.push( - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.SNORE), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.SNORE), - ignorePp: true - }); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Fall asleep waiting for Snorlax - // Full heal party - globalScene.unshiftPhase(new PartyHealPhase(true)); - queueEncounterMessage(`${namespace}:option.2.rest_result`); + }) + .withOptionPhase(async () => { + // Steal the Snorlax's Leftovers + const instance = globalScene.currentBattle.mysteryEncounter!; + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.LEFTOVERS], + fillRemaining: false, + }); + // Snorlax exp to Pokemon that did the stealing + setEncounterExp(instance.primaryPokemon!.id, getPokemonSpecies(Species.SNORLAX).baseExp); leaveEncounterWithoutBattle(); - } - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement(new MoveRequirement(STEALING_MOVES, true)) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected` - } - ] - }) - .withOptionPhase(async () => { - // Steal the Snorlax's Leftovers - const instance = globalScene.currentBattle.mysteryEncounter!; - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.LEFTOVERS ], fillRemaining: false }); - // Snorlax exp to Pokemon that did the stealing - setEncounterExp(instance.primaryPokemon!.id, getPokemonSpecies(Species.SNORLAX).baseExp); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .build(); + }) + .build(), + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts index 57e6fec91bb..c7220192caa 100644 --- a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts +++ b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts @@ -1,5 +1,12 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { generateModifierTypeOption, initBattleWithEnemyConfig, setEncounterExp, setEncounterRewards, transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierTypeOption, + initBattleWithEnemyConfig, + setEncounterExp, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { randSeedInt } from "#app/utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; @@ -23,140 +30,153 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { Stat } from "#enums/stat"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode"; -import { getEncounterPokemonLevelForWave, STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + getEncounterPokemonLevelForWave, + STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; /** the i18n namespace for this encounter */ const namespace = "mysteryEncounters/teleportingHijinks"; const MONEY_COST_MULTIPLIER = 1.75; -const BIOME_CANDIDATES = [ Biome.SPACE, Biome.FAIRY_CAVE, Biome.LABORATORY, Biome.ISLAND, Biome.WASTELAND, Biome.DOJO ]; -const MACHINE_INTERFACING_TYPES = [ PokemonType.ELECTRIC, PokemonType.STEEL ]; +const BIOME_CANDIDATES = [Biome.SPACE, Biome.FAIRY_CAVE, Biome.LABORATORY, Biome.ISLAND, Biome.WASTELAND, Biome.DOJO]; +const MACHINE_INTERFACING_TYPES = [PokemonType.ELECTRIC, PokemonType.STEEL]; /** * Teleporting Hijinks encounter. * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3817 | GitHub Issue #3817} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TeleportingHijinksEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.TELEPORTING_HIJINKS) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new WaveModulusRequirement([ 1, 2, 3 ], 10)) // Must be in first 3 waves after boss wave - .withSceneRequirement(new MoneyRequirement(0, MONEY_COST_MULTIPLIER)) // Must be able to pay teleport cost - .withAutoHideIntroVisuals(false) - .withCatchAllowed(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - spriteKey: "teleporting_hijinks_teleporter", - fileRoot: "mystery-encounters", - hasShadow: true, - x: 4, - y: 4, - yShadow: 1 - } - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const price = globalScene.getWaveMoneyAmount(MONEY_COST_MULTIPLIER); - encounter.setDialogueToken("price", price.toString()); - encounter.misc = { - price - }; +export const TeleportingHijinksEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.TELEPORTING_HIJINKS, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new WaveModulusRequirement([1, 2, 3], 10)) // Must be in first 3 waves after boss wave + .withSceneRequirement(new MoneyRequirement(0, MONEY_COST_MULTIPLIER)) // Must be able to pay teleport cost + .withAutoHideIntroVisuals(false) + .withCatchAllowed(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + spriteKey: "teleporting_hijinks_teleporter", + fileRoot: "mystery-encounters", + hasShadow: true, + x: 4, + y: 4, + yShadow: 1, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const price = globalScene.getWaveMoneyAmount(MONEY_COST_MULTIPLIER); + encounter.setDialogueToken("price", price.toString()); + encounter.misc = { + price, + }; - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withSceneMoneyRequirement(0, MONEY_COST_MULTIPLIER) // Must be able to pay teleport cost - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - } - ], - }) - .withPreOptionPhase(async () => { - // Update money - updatePlayerMoney(-globalScene.currentBattle.mysteryEncounter!.misc.price, true, false); - }) - .withOptionPhase(async () => { - const config: EnemyPartyConfig = await doBiomeTransitionDialogueAndBattleInit(); - setEncounterRewards({ fillRemaining: true }); - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPokemonTypeRequirement(MACHINE_INTERFACING_TYPES, true, 1) // Must have Steel or Electric type - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - } - ], - }) - .withOptionPhase(async () => { - const config: EnemyPartyConfig = await doBiomeTransitionDialogueAndBattleInit(); - setEncounterRewards({ fillRemaining: true }); - setEncounterExp(globalScene.currentBattle.mysteryEncounter!.selectedOption!.primaryPokemon!.id, 100); - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withSceneMoneyRequirement(0, MONEY_COST_MULTIPLIER) // Must be able to pay teleport cost + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.3.selected`, + text: `${namespace}:option.1.selected`, }, ], - }, - async () => { - // Inspect the Machine - const encounter = globalScene.currentBattle.mysteryEncounter!; + }) + .withPreOptionPhase(async () => { + // Update money + updatePlayerMoney(-globalScene.currentBattle.mysteryEncounter!.misc.price, true, false); + }) + .withOptionPhase(async () => { + const config: EnemyPartyConfig = await doBiomeTransitionDialogueAndBattleInit(); + setEncounterRewards({ fillRemaining: true }); + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPokemonTypeRequirement(MACHINE_INTERFACING_TYPES, true, 1) // Must have Steel or Electric type + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }) + .withOptionPhase(async () => { + const config: EnemyPartyConfig = await doBiomeTransitionDialogueAndBattleInit(); + setEncounterRewards({ fillRemaining: true }); + setEncounterExp(globalScene.currentBattle.mysteryEncounter!.selectedOption!.primaryPokemon!.id, 100); + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }, + async () => { + // Inspect the Machine + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Init enemy - const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); - const bossSpecies = globalScene.arena.randomSpecies(globalScene.currentBattle.waveIndex, level, 0, getPartyLuckValue(globalScene.getPlayerParty()), true); - const bossPokemon = new EnemyPokemon(bossSpecies, level, TrainerSlot.NONE, true); - encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); - const config: EnemyPartyConfig = { - pokemonConfigs: [{ + // Init enemy + const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); + const bossSpecies = globalScene.arena.randomSpecies( + globalScene.currentBattle.waveIndex, + level, + 0, + getPartyLuckValue(globalScene.getPlayerParty()), + true, + ); + const bossPokemon = new EnemyPokemon(bossSpecies, level, TrainerSlot.NONE, true); + encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { level: level, species: bossSpecies, dataSource: new PokemonData(bossPokemon), isBoss: true, - }], - }; + }, + ], + }; - const magnet = generateModifierTypeOption(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.STEEL ])!; - const metalCoat = generateModifierTypeOption(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.ELECTRIC ])!; - setEncounterRewards({ guaranteedModifierTypeOptions: [ magnet, metalCoat ], fillRemaining: true }); - await transitionMysteryEncounterIntroVisuals(true, true); - await initBattleWithEnemyConfig(config); - } - ) - .build(); + const magnet = generateModifierTypeOption(modifierTypes.ATTACK_TYPE_BOOSTER, [PokemonType.STEEL])!; + const metalCoat = generateModifierTypeOption(modifierTypes.ATTACK_TYPE_BOOSTER, [PokemonType.ELECTRIC])!; + setEncounterRewards({ + guaranteedModifierTypeOptions: [magnet, metalCoat], + fillRemaining: true, + }); + await transitionMysteryEncounterIntroVisuals(true, true); + await initBattleWithEnemyConfig(config); + }, + ) + .build(); async function doBiomeTransitionDialogueAndBattleInit() { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -167,34 +187,43 @@ async function doBiomeTransitionDialogueAndBattleInit() { // Show dialogue and transition biome await showEncounterText(`${namespace}:transport`); - await Promise.all([ animateBiomeChange(newBiome), transitionMysteryEncounterIntroVisuals() ]); + await Promise.all([animateBiomeChange(newBiome), transitionMysteryEncounterIntroVisuals()]); globalScene.updateBiomeWaveText(); globalScene.playBgm(); await showEncounterText(`${namespace}:attacked`); // Init enemy const level = getEncounterPokemonLevelForWave(STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER); - const bossSpecies = globalScene.arena.randomSpecies(globalScene.currentBattle.waveIndex, level, 0, getPartyLuckValue(globalScene.getPlayerParty()), true); + const bossSpecies = globalScene.arena.randomSpecies( + globalScene.currentBattle.waveIndex, + level, + 0, + getPartyLuckValue(globalScene.getPlayerParty()), + true, + ); const bossPokemon = new EnemyPokemon(bossSpecies, level, TrainerSlot.NONE, true); encounter.setDialogueToken("enemyPokemon", getPokemonNameWithAffix(bossPokemon)); // Defense/Spd buffs below wave 50, +1 to all stats otherwise - const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = globalScene.currentBattle.waveIndex < 50 ? - [ Stat.DEF, Stat.SPDEF, Stat.SPD ] : - [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = + globalScene.currentBattle.waveIndex < 50 + ? [Stat.DEF, Stat.SPDEF, Stat.SPD] + : [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; const config: EnemyPartyConfig = { - pokemonConfigs: [{ - level: level, - species: bossSpecies, - dataSource: new PokemonData(bossPokemon), - isBoss: true, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: (pokemon: Pokemon) => { - queueEncounterMessage(`${namespace}:boss_enraged`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1)); - } - }], + pokemonConfigs: [ + { + level: level, + species: bossSpecies, + dataSource: new PokemonData(bossPokemon), + isBoss: true, + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: (pokemon: Pokemon) => { + queueEncounterMessage(`${namespace}:boss_enraged`); + globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1)); + }, + }, + ], }; return config; @@ -203,7 +232,7 @@ async function doBiomeTransitionDialogueAndBattleInit() { async function animateBiomeChange(nextBiome: Biome) { return new Promise(resolve => { globalScene.tweens.add({ - targets: [ globalScene.arenaEnemy, globalScene.lastEnemyTrainer ], + targets: [globalScene.arenaEnemy, globalScene.lastEnemyTrainer], x: "+=300", duration: 2000, onComplete: () => { @@ -219,10 +248,10 @@ async function animateBiomeChange(nextBiome: Biome) { globalScene.arenaPlayerTransition.setVisible(true); globalScene.tweens.add({ - targets: [ globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition ], + targets: [globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition], duration: 1000, ease: "Sine.easeInOut", - alpha: (target: any) => target === globalScene.arenaPlayer ? 0 : 1, + alpha: (target: any) => (target === globalScene.arenaPlayer ? 0 : 1), onComplete: () => { globalScene.arenaBg.setTexture(bgTexture); globalScene.arenaPlayer.setBiome(nextBiome); @@ -242,9 +271,9 @@ async function animateBiomeChange(nextBiome: Biome) { targets: globalScene.arenaEnemy, x: "-=300", }); - } + }, }); - } + }, }); }); } 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 802296bfd98..2b29046f738 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 @@ -1,5 +1,9 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { handleMysteryEncounterBattleFailed, initBattleWithEnemyConfig, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + handleMysteryEncounterBattleFailed, + initBattleWithEnemyConfig, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { trainerConfigs } from "#app/data/trainer-config"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; @@ -39,7 +43,7 @@ const FINAL_STAGE_EVOLUTION_WAVE = 75; const FRIENDSHIP_ADDED = 20; -class BreederSpeciesEvolution { +class BreederSpeciesEvolution { species: Species; evolution: number; @@ -50,29 +54,65 @@ class BreederSpeciesEvolution { } const POOL_1_POKEMON: (Species | BreederSpeciesEvolution)[][] = [ - [ Species.MUNCHLAX, new BreederSpeciesEvolution(Species.SNORLAX, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.HAPPINY, new BreederSpeciesEvolution(Species.CHANSEY, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.BLISSEY, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.MAGBY, new BreederSpeciesEvolution(Species.MAGMAR, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.MAGMORTAR, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.ELEKID, new BreederSpeciesEvolution(Species.ELECTABUZZ, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.ELECTIVIRE, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.RIOLU, new BreederSpeciesEvolution(Species.LUCARIO, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.BUDEW, new BreederSpeciesEvolution(Species.ROSELIA, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.ROSERADE, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.TOXEL, new BreederSpeciesEvolution(Species.TOXTRICITY, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.MIME_JR, new BreederSpeciesEvolution(Species.GALAR_MR_MIME, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.MR_RIME, FINAL_STAGE_EVOLUTION_WAVE) ] + [Species.MUNCHLAX, new BreederSpeciesEvolution(Species.SNORLAX, SECOND_STAGE_EVOLUTION_WAVE)], + [ + Species.HAPPINY, + new BreederSpeciesEvolution(Species.CHANSEY, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.BLISSEY, FINAL_STAGE_EVOLUTION_WAVE), + ], + [ + Species.MAGBY, + new BreederSpeciesEvolution(Species.MAGMAR, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.MAGMORTAR, FINAL_STAGE_EVOLUTION_WAVE), + ], + [ + Species.ELEKID, + new BreederSpeciesEvolution(Species.ELECTABUZZ, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.ELECTIVIRE, FINAL_STAGE_EVOLUTION_WAVE), + ], + [Species.RIOLU, new BreederSpeciesEvolution(Species.LUCARIO, SECOND_STAGE_EVOLUTION_WAVE)], + [ + Species.BUDEW, + new BreederSpeciesEvolution(Species.ROSELIA, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.ROSERADE, FINAL_STAGE_EVOLUTION_WAVE), + ], + [Species.TOXEL, new BreederSpeciesEvolution(Species.TOXTRICITY, SECOND_STAGE_EVOLUTION_WAVE)], + [ + Species.MIME_JR, + new BreederSpeciesEvolution(Species.GALAR_MR_MIME, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.MR_RIME, FINAL_STAGE_EVOLUTION_WAVE), + ], ]; const POOL_2_POKEMON: (Species | BreederSpeciesEvolution)[][] = [ - [ Species.PICHU, new BreederSpeciesEvolution(Species.PIKACHU, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.RAICHU, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.PICHU, new BreederSpeciesEvolution(Species.PIKACHU, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.ALOLA_RAICHU, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.SMOOCHUM, new BreederSpeciesEvolution(Species.JYNX, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONLEE, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONCHAN, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONTOP, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.IGGLYBUFF, new BreederSpeciesEvolution(Species.JIGGLYPUFF, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.WIGGLYTUFF, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.AZURILL, new BreederSpeciesEvolution(Species.MARILL, FIRST_STAGE_EVOLUTION_WAVE), new BreederSpeciesEvolution(Species.AZUMARILL, FINAL_STAGE_EVOLUTION_WAVE) ], - [ Species.WYNAUT, new BreederSpeciesEvolution(Species.WOBBUFFET, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.CHINGLING, new BreederSpeciesEvolution(Species.CHIMECHO, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.BONSLY, new BreederSpeciesEvolution(Species.SUDOWOODO, SECOND_STAGE_EVOLUTION_WAVE) ], - [ Species.MANTYKE, new BreederSpeciesEvolution(Species.MANTINE, SECOND_STAGE_EVOLUTION_WAVE) ] + [ + Species.PICHU, + new BreederSpeciesEvolution(Species.PIKACHU, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.RAICHU, FINAL_STAGE_EVOLUTION_WAVE), + ], + [ + Species.PICHU, + new BreederSpeciesEvolution(Species.PIKACHU, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.ALOLA_RAICHU, FINAL_STAGE_EVOLUTION_WAVE), + ], + [Species.SMOOCHUM, new BreederSpeciesEvolution(Species.JYNX, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONLEE, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONCHAN, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.TYROGUE, new BreederSpeciesEvolution(Species.HITMONTOP, SECOND_STAGE_EVOLUTION_WAVE)], + [ + Species.IGGLYBUFF, + new BreederSpeciesEvolution(Species.JIGGLYPUFF, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.WIGGLYTUFF, FINAL_STAGE_EVOLUTION_WAVE), + ], + [ + Species.AZURILL, + new BreederSpeciesEvolution(Species.MARILL, FIRST_STAGE_EVOLUTION_WAVE), + new BreederSpeciesEvolution(Species.AZUMARILL, FINAL_STAGE_EVOLUTION_WAVE), + ], + [Species.WYNAUT, new BreederSpeciesEvolution(Species.WOBBUFFET, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.CHINGLING, new BreederSpeciesEvolution(Species.CHIMECHO, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.BONSLY, new BreederSpeciesEvolution(Species.SUDOWOODO, SECOND_STAGE_EVOLUTION_WAVE)], + [Species.MANTYKE, new BreederSpeciesEvolution(Species.MANTINE, SECOND_STAGE_EVOLUTION_WAVE)], ]; /** @@ -80,291 +120,344 @@ const POOL_2_POKEMON: (Species | BreederSpeciesEvolution)[][] = [ * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3818 | GitHub Issue #3818} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TheExpertPokemonBreederEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER) - .withEncounterTier(MysteryEncounterTier.ULTRA) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withScenePartySizeRequirement(4, 6, true) // Must have at least 4 legal pokemon in party - .withIntroSpriteConfigs([]) // These are set in onInit() - .withIntroDialogue([ +export const TheExpertPokemonBreederEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER, +) + .withEncounterTier(MysteryEncounterTier.ULTRA) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withScenePartySizeRequirement(4, 6, true) // Must have at least 4 legal pokemon in party + .withIntroSpriteConfigs([]) // These are set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: trainerNameKey, + text: `${namespace}:intro_dialogue`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const waveIndex = globalScene.currentBattle.waveIndex; + // Calculates what trainers are available for battle in the encounter + + // If player is in space biome, uses special "Space" version of the trainer + encounter.enemyPartyConfigs = [getPartyConfig()]; + + const cleffaSpecies = + waveIndex < FIRST_STAGE_EVOLUTION_WAVE + ? Species.CLEFFA + : waveIndex < FINAL_STAGE_EVOLUTION_WAVE + ? Species.CLEFAIRY + : Species.CLEFABLE; + encounter.spriteConfigs = [ { - text: `${namespace}:intro`, + spriteKey: cleffaSpecies.toString(), + fileRoot: "pokemon", + hasShadow: true, + repeat: true, + x: 14, + y: -2, + yShadow: -2, }, { - speaker: trainerNameKey, - text: `${namespace}:intro_dialogue`, + spriteKey: "expert_pokemon_breeder", + fileRoot: "trainer", + hasShadow: true, + x: -14, + y: 4, + yShadow: 2, }, - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const waveIndex = globalScene.currentBattle.waveIndex; - // Calculates what trainers are available for battle in the encounter + ]; - // If player is in space biome, uses special "Space" version of the trainer - encounter.enemyPartyConfigs = [ - getPartyConfig() - ]; + // Determine the 3 pokemon the player can battle with + let partyCopy = globalScene.getPlayerParty().slice(0); + partyCopy = partyCopy.filter(p => p.isAllowedInBattle()).sort((a, b) => a.friendship - b.friendship); - const cleffaSpecies = waveIndex < FIRST_STAGE_EVOLUTION_WAVE ? Species.CLEFFA : waveIndex < FINAL_STAGE_EVOLUTION_WAVE ? Species.CLEFAIRY : Species.CLEFABLE; - encounter.spriteConfigs = [ - { - spriteKey: cleffaSpecies.toString(), - fileRoot: "pokemon", - hasShadow: true, - repeat: true, - x: 14, - y: -2, - yShadow: -2 - }, - { - spriteKey: "expert_pokemon_breeder", - fileRoot: "trainer", - hasShadow: true, - x: -14, - y: 4, - yShadow: 2 - }, - ]; + const pokemon1 = partyCopy[0]; + const pokemon2 = partyCopy[1]; + const pokemon3 = partyCopy[2]; + encounter.setDialogueToken("pokemon1Name", pokemon1.getNameToRender()); + encounter.setDialogueToken("pokemon2Name", pokemon2.getNameToRender()); + encounter.setDialogueToken("pokemon3Name", pokemon3.getNameToRender()); - // Determine the 3 pokemon the player can battle with - let partyCopy = globalScene.getPlayerParty().slice(0); - partyCopy = partyCopy - .filter(p => p.isAllowedInBattle()) - .sort((a, b) => a.friendship - b.friendship); + // Dialogue and egg calcs for Pokemon 1 + const [pokemon1CommonEggs, pokemon1RareEggs] = calculateEggRewardsForPokemon(pokemon1); + let pokemon1Tooltip = getEncounterText(`${namespace}:option.1.tooltip_base`)!; + if (pokemon1RareEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon1RareEggs, + rarity: i18next.t("egg:greatTier"), + }); + pokemon1Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon1RareEggs", eggsText); + } + if (pokemon1CommonEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon1CommonEggs, + rarity: i18next.t("egg:defaultTier"), + }); + pokemon1Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon1CommonEggs", eggsText); + } + encounter.options[0].dialogue!.buttonTooltip = pokemon1Tooltip; - const pokemon1 = partyCopy[0]; - const pokemon2 = partyCopy[1]; - const pokemon3 = partyCopy[2]; - encounter.setDialogueToken("pokemon1Name", pokemon1.getNameToRender()); - encounter.setDialogueToken("pokemon2Name", pokemon2.getNameToRender()); - encounter.setDialogueToken("pokemon3Name", pokemon3.getNameToRender()); + // Dialogue and egg calcs for Pokemon 2 + const [pokemon2CommonEggs, pokemon2RareEggs] = calculateEggRewardsForPokemon(pokemon2); + let pokemon2Tooltip = getEncounterText(`${namespace}:option.2.tooltip_base`)!; + if (pokemon2RareEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon2RareEggs, + rarity: i18next.t("egg:greatTier"), + }); + pokemon2Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon2RareEggs", eggsText); + } + if (pokemon2CommonEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon2CommonEggs, + rarity: i18next.t("egg:defaultTier"), + }); + pokemon2Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon2CommonEggs", eggsText); + } + encounter.options[1].dialogue!.buttonTooltip = pokemon2Tooltip; - // Dialogue and egg calcs for Pokemon 1 - const [ pokemon1CommonEggs, pokemon1RareEggs ] = calculateEggRewardsForPokemon(pokemon1); - let pokemon1Tooltip = getEncounterText(`${namespace}:option.1.tooltip_base`)!; - if (pokemon1RareEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon1RareEggs, rarity: i18next.t("egg:greatTier") }); - pokemon1Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon1RareEggs", eggsText); - } - if (pokemon1CommonEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon1CommonEggs, rarity: i18next.t("egg:defaultTier") }); - pokemon1Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon1CommonEggs", eggsText); - } - encounter.options[0].dialogue!.buttonTooltip = pokemon1Tooltip; + // Dialogue and egg calcs for Pokemon 3 + const [pokemon3CommonEggs, pokemon3RareEggs] = calculateEggRewardsForPokemon(pokemon3); + let pokemon3Tooltip = getEncounterText(`${namespace}:option.3.tooltip_base`)!; + if (pokemon3RareEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon3RareEggs, + rarity: i18next.t("egg:greatTier"), + }); + pokemon3Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon3RareEggs", eggsText); + } + if (pokemon3CommonEggs > 0) { + const eggsText = i18next.t(`${namespace}:numEggs`, { + count: pokemon3CommonEggs, + rarity: i18next.t("egg:defaultTier"), + }); + pokemon3Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { + eggs: eggsText, + }); + encounter.setDialogueToken("pokemon3CommonEggs", eggsText); + } + encounter.options[2].dialogue!.buttonTooltip = pokemon3Tooltip; - // Dialogue and egg calcs for Pokemon 2 - const [ pokemon2CommonEggs, pokemon2RareEggs ] = calculateEggRewardsForPokemon(pokemon2); - let pokemon2Tooltip = getEncounterText(`${namespace}:option.2.tooltip_base`)!; - if (pokemon2RareEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon2RareEggs, rarity: i18next.t("egg:greatTier") }); - pokemon2Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon2RareEggs", eggsText); - } - if (pokemon2CommonEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon2CommonEggs, rarity: i18next.t("egg:defaultTier") }); - pokemon2Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon2CommonEggs", eggsText); - } - encounter.options[1].dialogue!.buttonTooltip = pokemon2Tooltip; + encounter.misc = { + pokemon1, + pokemon1CommonEggs, + pokemon1RareEggs, + pokemon2, + pokemon2CommonEggs, + pokemon2RareEggs, + pokemon3, + pokemon3CommonEggs, + pokemon3RareEggs, + }; - // Dialogue and egg calcs for Pokemon 3 - const [ pokemon3CommonEggs, pokemon3RareEggs ] = calculateEggRewardsForPokemon(pokemon3); - let pokemon3Tooltip = getEncounterText(`${namespace}:option.3.tooltip_base`)!; - if (pokemon3RareEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon3RareEggs, rarity: i18next.t("egg:greatTier") }); - pokemon3Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon3RareEggs", eggsText); - } - if (pokemon3CommonEggs > 0) { - const eggsText = i18next.t(`${namespace}:numEggs`, { count: pokemon3CommonEggs, rarity: i18next.t("egg:defaultTier") }); - pokemon3Tooltip += i18next.t(`${namespace}:eggs_tooltip`, { eggs: eggsText }); - encounter.setDialogueToken("pokemon3CommonEggs", eggsText); - } - encounter.options[2].dialogue!.buttonTooltip = pokemon3Tooltip; + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + selected: [ + { + speaker: trainerNameKey, + text: `${namespace}:option.selected`, + }, + ], + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn battle with first pokemon + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - encounter.misc = { - pokemon1, - pokemon1CommonEggs, - pokemon1RareEggs, - pokemon2, - pokemon2CommonEggs, - pokemon2RareEggs, - pokemon3, - pokemon3CommonEggs, - pokemon3RareEggs - }; + const { pokemon1, pokemon1CommonEggs, pokemon1RareEggs } = encounter.misc; + encounter.misc.chosenPokemon = pokemon1; + encounter.setDialogueToken("chosenPokemon", pokemon1.getNameToRender()); + const eggOptions = getEggOptions(pokemon1CommonEggs, pokemon1RareEggs); + setEncounterRewards( + { + guaranteedModifierTypeFuncs: [modifierTypes.SOOTHE_BELL], + fillRemaining: true, + }, + eggOptions, + () => doPostEncounterCleanup(), + ); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - selected: [ - { - speaker: trainerNameKey, - text: `${namespace}:option.selected`, - }, - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn battle with first pokemon - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; + // Remove all Pokemon from the party except the chosen Pokemon + removePokemonFromPartyAndStoreHeldItems(encounter, pokemon1); - const { pokemon1, pokemon1CommonEggs, pokemon1RareEggs } = encounter.misc; - encounter.misc.chosenPokemon = pokemon1; - encounter.setDialogueToken("chosenPokemon", pokemon1.getNameToRender()); - const eggOptions = getEggOptions(pokemon1CommonEggs, pokemon1RareEggs); - setEncounterRewards( - { guaranteedModifierTypeFuncs: [ modifierTypes.SOOTHE_BELL ], fillRemaining: true }, - eggOptions, - () => doPostEncounterCleanup()); + // Configure outro dialogue for egg rewards + encounter.dialogue.outro = [ + { + speaker: trainerNameKey, + text: `${namespace}:outro`, + }, + ]; + if (encounter.dialogueTokens.hasOwnProperty("pokemon1CommonEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon1CommonEggs"], + }), + }); + } + if (encounter.dialogueTokens.hasOwnProperty("pokemon1RareEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon1RareEggs"], + }), + }); + } - // Remove all Pokemon from the party except the chosen Pokemon - removePokemonFromPartyAndStoreHeldItems(encounter, pokemon1); + encounter.onGameOver = onGameOver; + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + selected: [ + { + speaker: trainerNameKey, + text: `${namespace}:option.selected`, + }, + ], + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn battle with second pokemon + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Configure outro dialogue for egg rewards - encounter.dialogue.outro = [ - { - speaker: trainerNameKey, - text: `${namespace}:outro`, - }, - ]; - if (encounter.dialogueTokens.hasOwnProperty("pokemon1CommonEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon1CommonEggs"] }), - }); - } - if (encounter.dialogueTokens.hasOwnProperty("pokemon1RareEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon1RareEggs"] }), - }); - } + const { pokemon2, pokemon2CommonEggs, pokemon2RareEggs } = encounter.misc; + encounter.misc.chosenPokemon = pokemon2; + encounter.setDialogueToken("chosenPokemon", pokemon2.getNameToRender()); + const eggOptions = getEggOptions(pokemon2CommonEggs, pokemon2RareEggs); + setEncounterRewards( + { + guaranteedModifierTypeFuncs: [modifierTypes.SOOTHE_BELL], + fillRemaining: true, + }, + eggOptions, + () => doPostEncounterCleanup(), + ); - encounter.onGameOver = onGameOver; - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - selected: [ - { - speaker: trainerNameKey, - text: `${namespace}:option.selected`, - }, - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn battle with second pokemon - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; + // Remove all Pokemon from the party except the chosen Pokemon + removePokemonFromPartyAndStoreHeldItems(encounter, pokemon2); - const { pokemon2, pokemon2CommonEggs, pokemon2RareEggs } = encounter.misc; - encounter.misc.chosenPokemon = pokemon2; - encounter.setDialogueToken("chosenPokemon", pokemon2.getNameToRender()); - const eggOptions = getEggOptions(pokemon2CommonEggs, pokemon2RareEggs); - setEncounterRewards( - { guaranteedModifierTypeFuncs: [ modifierTypes.SOOTHE_BELL ], fillRemaining: true }, - eggOptions, - () => doPostEncounterCleanup()); + // Configure outro dialogue for egg rewards + encounter.dialogue.outro = [ + { + speaker: trainerNameKey, + text: `${namespace}:outro`, + }, + ]; + if (encounter.dialogueTokens.hasOwnProperty("pokemon2CommonEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon2CommonEggs"], + }), + }); + } + if (encounter.dialogueTokens.hasOwnProperty("pokemon2RareEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon2RareEggs"], + }), + }); + } - // Remove all Pokemon from the party except the chosen Pokemon - removePokemonFromPartyAndStoreHeldItems(encounter, pokemon2); + encounter.onGameOver = onGameOver; + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + selected: [ + { + speaker: trainerNameKey, + text: `${namespace}:option.selected`, + }, + ], + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + // Spawn battle with third pokemon + const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; - // Configure outro dialogue for egg rewards - encounter.dialogue.outro = [ - { - speaker: trainerNameKey, - text: `${namespace}:outro`, - }, - ]; - if (encounter.dialogueTokens.hasOwnProperty("pokemon2CommonEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon2CommonEggs"] }), - }); - } - if (encounter.dialogueTokens.hasOwnProperty("pokemon2RareEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon2RareEggs"] }), - }); - } + const { pokemon3, pokemon3CommonEggs, pokemon3RareEggs } = encounter.misc; + encounter.misc.chosenPokemon = pokemon3; + encounter.setDialogueToken("chosenPokemon", pokemon3.getNameToRender()); + const eggOptions = getEggOptions(pokemon3CommonEggs, pokemon3RareEggs); + setEncounterRewards( + { + guaranteedModifierTypeFuncs: [modifierTypes.SOOTHE_BELL], + fillRemaining: true, + }, + eggOptions, + () => doPostEncounterCleanup(), + ); - encounter.onGameOver = onGameOver; - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - selected: [ - { - speaker: trainerNameKey, - text: `${namespace}:option.selected`, - }, - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Spawn battle with third pokemon - const config: EnemyPartyConfig = encounter.enemyPartyConfigs[0]; + // Remove all Pokemon from the party except the chosen Pokemon + removePokemonFromPartyAndStoreHeldItems(encounter, pokemon3); - const { pokemon3, pokemon3CommonEggs, pokemon3RareEggs } = encounter.misc; - encounter.misc.chosenPokemon = pokemon3; - encounter.setDialogueToken("chosenPokemon", pokemon3.getNameToRender()); - const eggOptions = getEggOptions(pokemon3CommonEggs, pokemon3RareEggs); - setEncounterRewards( - { guaranteedModifierTypeFuncs: [ modifierTypes.SOOTHE_BELL ], fillRemaining: true }, - eggOptions, - () => doPostEncounterCleanup()); + // Configure outro dialogue for egg rewards + encounter.dialogue.outro = [ + { + speaker: trainerNameKey, + text: `${namespace}:outro`, + }, + ]; + if (encounter.dialogueTokens.hasOwnProperty("pokemon3CommonEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon3CommonEggs"], + }), + }); + } + if (encounter.dialogueTokens.hasOwnProperty("pokemon3RareEggs")) { + encounter.dialogue.outro.push({ + text: i18next.t(`${namespace}:gained_eggs`, { + numEggs: encounter.dialogueTokens["pokemon3RareEggs"], + }), + }); + } - // Remove all Pokemon from the party except the chosen Pokemon - removePokemonFromPartyAndStoreHeldItems(encounter, pokemon3); - - // Configure outro dialogue for egg rewards - encounter.dialogue.outro = [ - { - speaker: trainerNameKey, - text: `${namespace}:outro`, - }, - ]; - if (encounter.dialogueTokens.hasOwnProperty("pokemon3CommonEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon3CommonEggs"] }), - }); - } - if (encounter.dialogueTokens.hasOwnProperty("pokemon3RareEggs")) { - encounter.dialogue.outro.push({ - text: i18next.t(`${namespace}:gained_eggs`, { numEggs: encounter.dialogueTokens["pokemon3RareEggs"] }), - }); - } - - encounter.onGameOver = onGameOver; - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOutroDialogue([ - { - speaker: trainerNameKey, - text: `${namespace}:outro`, - }, - ]) - .build(); + encounter.onGameOver = onGameOver; + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOutroDialogue([ + { + speaker: trainerNameKey, + text: `${namespace}:outro`, + }, + ]) + .build(); function getPartyConfig(): EnemyPartyConfig { // Bug type superfan trainer config @@ -373,64 +466,79 @@ function getPartyConfig(): EnemyPartyConfig { breederConfig.name = i18next.t(trainerNameKey); // First mon is *always* this special cleffa - const cleffaSpecies = waveIndex < FIRST_STAGE_EVOLUTION_WAVE ? Species.CLEFFA : waveIndex < FINAL_STAGE_EVOLUTION_WAVE ? Species.CLEFAIRY : Species.CLEFABLE; + const cleffaSpecies = + waveIndex < FIRST_STAGE_EVOLUTION_WAVE + ? Species.CLEFFA + : waveIndex < FINAL_STAGE_EVOLUTION_WAVE + ? Species.CLEFAIRY + : Species.CLEFABLE; const baseConfig: EnemyPartyConfig = { trainerType: TrainerType.EXPERT_POKEMON_BREEDER, pokemonConfigs: [ { - nickname: i18next.t(`${namespace}:cleffa_1_nickname`, { speciesName: getPokemonSpecies(cleffaSpecies).getName() }), + nickname: i18next.t(`${namespace}:cleffa_1_nickname`, { + speciesName: getPokemonSpecies(cleffaSpecies).getName(), + }), species: getPokemonSpecies(cleffaSpecies), isBoss: false, abilityIndex: 1, // Magic Guard shiny: false, nature: Nature.ADAMANT, - moveSet: [ Moves.METEOR_MASH, Moves.FIRE_PUNCH, Moves.ICE_PUNCH, Moves.THUNDER_PUNCH ], - ivs: [ 31, 31, 31, 31, 31, 31 ], + moveSet: [Moves.METEOR_MASH, Moves.FIRE_PUNCH, Moves.ICE_PUNCH, Moves.THUNDER_PUNCH], + ivs: [31, 31, 31, 31, 31, 31], tera: PokemonType.STEEL, - } - ] + }, + ], }; if (globalScene.arena.biomeType === Biome.SPACE) { // All 3 members always Cleffa line, but different configs - baseConfig.pokemonConfigs!.push({ - nickname: i18next.t(`${namespace}:cleffa_2_nickname`, { speciesName: getPokemonSpecies(cleffaSpecies).getName() }), - species: getPokemonSpecies(cleffaSpecies), - isBoss: false, - abilityIndex: 1, // Magic Guard - shiny: true, - variant: 1, - nature: Nature.MODEST, - moveSet: [ Moves.MOONBLAST, Moves.MYSTICAL_FIRE, Moves.ICE_BEAM, Moves.THUNDERBOLT ], - ivs: [ 31, 31, 31, 31, 31, 31 ] - }, - { - nickname: i18next.t(`${namespace}:cleffa_3_nickname`, { speciesName: getPokemonSpecies(cleffaSpecies).getName() }), - species: getPokemonSpecies(cleffaSpecies), - isBoss: false, - abilityIndex: 2, // Friend Guard / Unaware - shiny: true, - variant: 2, - nature: Nature.BOLD, - moveSet: [ Moves.TRI_ATTACK, Moves.STORED_POWER, Moves.TAKE_HEART, Moves.MOONLIGHT ], - ivs: [ 31, 31, 31, 31, 31, 31 ] - }); + baseConfig.pokemonConfigs!.push( + { + nickname: i18next.t(`${namespace}:cleffa_2_nickname`, { + speciesName: getPokemonSpecies(cleffaSpecies).getName(), + }), + species: getPokemonSpecies(cleffaSpecies), + isBoss: false, + abilityIndex: 1, // Magic Guard + shiny: true, + variant: 1, + nature: Nature.MODEST, + moveSet: [Moves.MOONBLAST, Moves.MYSTICAL_FIRE, Moves.ICE_BEAM, Moves.THUNDERBOLT], + ivs: [31, 31, 31, 31, 31, 31], + }, + { + nickname: i18next.t(`${namespace}:cleffa_3_nickname`, { + speciesName: getPokemonSpecies(cleffaSpecies).getName(), + }), + species: getPokemonSpecies(cleffaSpecies), + isBoss: false, + abilityIndex: 2, // Friend Guard / Unaware + shiny: true, + variant: 2, + nature: Nature.BOLD, + moveSet: [Moves.TRI_ATTACK, Moves.STORED_POWER, Moves.TAKE_HEART, Moves.MOONLIGHT], + ivs: [31, 31, 31, 31, 31, 31], + }, + ); } else { // Second member from pool 1 const pool1Species = getSpeciesFromPool(POOL_1_POKEMON, waveIndex); // Third member from pool 2 const pool2Species = getSpeciesFromPool(POOL_2_POKEMON, waveIndex); - baseConfig.pokemonConfigs!.push({ - species: getPokemonSpecies(pool1Species), - isBoss: false, - ivs: [ 31, 31, 31, 31, 31, 31 ] - }, - { - species: getPokemonSpecies(pool2Species), - isBoss: false, - ivs: [ 31, 31, 31, 31, 31, 31 ] - }); + baseConfig.pokemonConfigs!.push( + { + species: getPokemonSpecies(pool1Species), + isBoss: false, + ivs: [31, 31, 31, 31, 31, 31], + }, + { + species: getPokemonSpecies(pool2Species), + isBoss: false, + ivs: [31, 31, 31, 31, 31, 31], + }, + ); } return baseConfig; @@ -471,7 +579,7 @@ function calculateEggRewardsForPokemon(pokemon: PlayerPokemon): [number, number] // 1 Common egg for every point leftover numCommons += totalPoints % 4; - return [ numCommons, numRares ]; + return [numCommons, numRares]; } function getEggOptions(commonEggs: number, rareEggs: number) { @@ -484,7 +592,7 @@ function getEggOptions(commonEggs: number, rareEggs: number) { pulled: false, sourceType: EggSourceType.EVENT, eggDescriptor: eggDescription, - tier: EggTier.COMMON + tier: EggTier.COMMON, }); } } @@ -494,7 +602,7 @@ function getEggOptions(commonEggs: number, rareEggs: number) { pulled: false, sourceType: EggSourceType.EVENT, eggDescriptor: eggDescription, - tier: EggTier.RARE + tier: EggTier.RARE, }); } } @@ -508,11 +616,8 @@ function removePokemonFromPartyAndStoreHeldItems(encounter: MysteryEncounter, ch party[chosenIndex] = party[0]; party[0] = chosenPokemon; encounter.misc.originalParty = globalScene.getPlayerParty().slice(1); - encounter.misc.originalPartyHeldItems = encounter.misc.originalParty - .map(p => p.getHeldItems()); - globalScene["party"] = [ - chosenPokemon - ]; + encounter.misc.originalPartyHeldItems = encounter.misc.originalParty.map(p => p.getHeldItems()); + globalScene["party"] = [chosenPokemon]; } function restorePartyAndHeldItems() { @@ -522,11 +627,11 @@ function restorePartyAndHeldItems() { // Restore held items const originalHeldItems = encounter.misc.originalPartyHeldItems; - originalHeldItems.forEach((pokemonHeldItemsList: PokemonHeldItemModifier[]) => { - pokemonHeldItemsList.forEach(heldItem => { + for (const pokemonHeldItemsList of originalHeldItems) { + for (const heldItem of pokemonHeldItemsList) { globalScene.addModifier(heldItem, true, false, false, true); - }); - }); + } + } globalScene.updateModifiers(true); } @@ -542,7 +647,7 @@ function onGameOver() { // Restore original party, player loses all friendship with chosen mon (it remains fainted) restorePartyAndHeldItems(); - const chosenPokemon = encounter.misc.chosenPokemon; + const chosenPokemon = encounter.misc.chosenPokemon; chosenPokemon.friendship = 0; // Clear all rewards that would have been earned @@ -571,7 +676,7 @@ function onGameOver() { scale: 0.5, onComplete: () => { pokemon.leaveField(true, true, true); - } + }, }); } @@ -593,11 +698,10 @@ function onGameOver() { y: "+=16", alpha: 1, ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); }); - handleMysteryEncounterBattleFailed(true); return false; 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 ff4dd9750c9..fb55c55a1a3 100644 --- a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts @@ -1,11 +1,19 @@ -import { leaveEncounterWithoutBattle, transitionMysteryEncounterIntroVisuals, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + leaveEncounterWithoutBattle, + transitionMysteryEncounterIntroVisuals, + updatePlayerMoney, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { isNullOrUndefined, randSeedInt } from "#app/utils"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; -import { catchPokemon, getRandomSpeciesByStarterCost, getSpriteKeysFromPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + catchPokemon, + getRandomSpeciesByStarterCost, + getSpriteKeysFromPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; @@ -35,143 +43,149 @@ const SHINY_MAGIKARP_WEIGHT = 100; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3799 | GitHub Issue #3799} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const ThePokemonSalesmanEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.THE_POKEMON_SALESMAN) - .withEncounterTier(MysteryEncounterTier.ULTRA) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withSceneRequirement(new MoneyRequirement(0, MAX_POKEMON_PRICE_MULTIPLIER)) // Some costs may not be as significant, this is the max you'd pay - .withAutoHideIntroVisuals(false) - .withIntroSpriteConfigs([ - { - spriteKey: "pokemon_salesman", - fileRoot: "mystery-encounters", - hasShadow: true - } - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - text: `${namespace}:intro_dialogue`, - speaker: `${namespace}:speaker`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const ThePokemonSalesmanEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.THE_POKEMON_SALESMAN, +) + .withEncounterTier(MysteryEncounterTier.ULTRA) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withSceneRequirement(new MoneyRequirement(0, MAX_POKEMON_PRICE_MULTIPLIER)) // Some costs may not be as significant, this is the max you'd pay + .withAutoHideIntroVisuals(false) + .withIntroSpriteConfigs([ + { + spriteKey: "pokemon_salesman", + fileRoot: "mystery-encounters", + hasShadow: true, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + text: `${namespace}:intro_dialogue`, + speaker: `${namespace}:speaker`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - let species = getSalesmanSpeciesOffer(); - let tries = 0; + let species = getSalesmanSpeciesOffer(); + let tries = 0; - // Reroll any species that don't have HAs - while ((isNullOrUndefined(species.abilityHidden) || species.abilityHidden === Abilities.NONE) && tries < 5) { - species = getSalesmanSpeciesOffer(); - tries++; - } + // Reroll any species that don't have HAs + while ((isNullOrUndefined(species.abilityHidden) || species.abilityHidden === Abilities.NONE) && tries < 5) { + species = getSalesmanSpeciesOffer(); + tries++; + } - let pokemon: PlayerPokemon; - if (randSeedInt(SHINY_MAGIKARP_WEIGHT) === 0 || isNullOrUndefined(species.abilityHidden) || species.abilityHidden === Abilities.NONE) { - // If no HA mon found or you roll 1%, give shiny Magikarp with random variant - species = getPokemonSpecies(Species.MAGIKARP); - pokemon = new PlayerPokemon(species, 5, 2, species.formIndex, undefined, true); - } else { - pokemon = new PlayerPokemon(species, 5, 2, species.formIndex); - } - pokemon.generateAndPopulateMoveset(); + let pokemon: PlayerPokemon; + if ( + randSeedInt(SHINY_MAGIKARP_WEIGHT) === 0 || + isNullOrUndefined(species.abilityHidden) || + species.abilityHidden === Abilities.NONE + ) { + // If no HA mon found or you roll 1%, give shiny Magikarp with random variant + species = getPokemonSpecies(Species.MAGIKARP); + pokemon = new PlayerPokemon(species, 5, 2, species.formIndex, undefined, true); + } else { + pokemon = new PlayerPokemon(species, 5, 2, species.formIndex); + } + pokemon.generateAndPopulateMoveset(); - const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(pokemon); - encounter.spriteConfigs.push({ - spriteKey: spriteKey, - fileRoot: fileRoot, - hasShadow: true, - repeat: true, - isPokemon: true, - isShiny: pokemon.shiny, - variant: pokemon.variant - }); + const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(pokemon); + encounter.spriteConfigs.push({ + spriteKey: spriteKey, + fileRoot: fileRoot, + hasShadow: true, + repeat: true, + isPokemon: true, + isShiny: pokemon.shiny, + variant: pokemon.variant, + }); - const starterTier = speciesStarterCosts[species.speciesId]; - // Prices decrease by starter tier less than 5, but only reduces cost by half at max - let priceMultiplier = MAX_POKEMON_PRICE_MULTIPLIER * (Math.max(starterTier, 2.5) / 5); - if (pokemon.shiny) { - // Always max price for shiny (flip HA back to normal), and add special messaging - priceMultiplier = MAX_POKEMON_PRICE_MULTIPLIER; - pokemon.abilityIndex = 0; - encounter.dialogue.encounterOptionsDialogue!.description = `${namespace}:description_shiny`; - encounter.options[0].dialogue!.buttonTooltip = `${namespace}:option.1.tooltip_shiny`; - } - const price = globalScene.getWaveMoneyAmount(priceMultiplier); - encounter.setDialogueToken("purchasePokemon", pokemon.getNameToRender()); - encounter.setDialogueToken("price", price.toString()); - encounter.misc = { - price: price, - pokemon: pokemon - }; + const starterTier = speciesStarterCosts[species.speciesId]; + // Prices decrease by starter tier less than 5, but only reduces cost by half at max + let priceMultiplier = MAX_POKEMON_PRICE_MULTIPLIER * (Math.max(starterTier, 2.5) / 5); + if (pokemon.shiny) { + // Always max price for shiny (flip HA back to normal), and add special messaging + priceMultiplier = MAX_POKEMON_PRICE_MULTIPLIER; + pokemon.abilityIndex = 0; + encounter.dialogue.encounterOptionsDialogue!.description = `${namespace}:description_shiny`; + encounter.options[0].dialogue!.buttonTooltip = `${namespace}:option.1.tooltip_shiny`; + } + const price = globalScene.getWaveMoneyAmount(priceMultiplier); + encounter.setDialogueToken("purchasePokemon", pokemon.getNameToRender()); + encounter.setDialogueToken("price", price.toString()); + encounter.misc = { + price: price, + pokemon: pokemon, + }; - pokemon.calculateStats(); + pokemon.calculateStats(); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) - .withHasDexProgress(true) - .withSceneMoneyRequirement(0, MAX_POKEMON_PRICE_MULTIPLIER) // Wave scaling money multiplier of 2 - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected_message`, - } - ], - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const price = encounter.misc.price; - const purchasedPokemon = encounter.misc.pokemon as PlayerPokemon; - - // Update money - updatePlayerMoney(-price, true, false); - - // Show dialogue - await showEncounterDialogue(`${namespace}:option.1.selected_dialogue`, `${namespace}:speaker`); - await transitionMysteryEncounterIntroVisuals(); - - // "Catch" purchased pokemon - const data = new PokemonData(purchasedPokemon); - data.player = false; - await catchPokemon(data.toPokemon() as EnemyPokemon, null, PokeballType.POKEBALL, true, true); - - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT) + .withHasDexProgress(true) + .withSceneMoneyRequirement(0, MAX_POKEMON_PRICE_MULTIPLIER) // Wave scaling money multiplier of 2 + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.2.selected`, + text: `${namespace}:option.1.selected_message`, }, ], - }, - async () => { - // Leave encounter with no rewards or exp + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const price = encounter.misc.price; + const purchasedPokemon = encounter.misc.pokemon as PlayerPokemon; + + // Update money + updatePlayerMoney(-price, true, false); + + // Show dialogue + await showEncounterDialogue(`${namespace}:option.1.selected_dialogue`, `${namespace}:speaker`); + await transitionMysteryEncounterIntroVisuals(); + + // "Catch" purchased pokemon + const data = new PokemonData(purchasedPokemon); + data.player = false; + await catchPokemon(data.toPokemon() as EnemyPokemon, null, PokeballType.POKEBALL, true, true); + leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); /** * @returns A random species that has at most 5 starter cost and is not Mythical, Paradox, etc. */ export function getSalesmanSpeciesOffer(): PokemonSpecies { - return getPokemonSpecies(getRandomSpeciesByStarterCost([ 0, 5 ], NON_LEGEND_PARADOX_POKEMON, undefined, false, false, false)); + return getPokemonSpecies( + getRandomSpeciesByStarterCost([0, 5], NON_LEGEND_PARADOX_POKEMON, undefined, false, false, false), + ); } diff --git a/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts b/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts index 9e94e87938e..e54df048430 100644 --- a/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts @@ -1,5 +1,12 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, loadCustomMovesForEncounter, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals, generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + initBattleWithEnemyConfig, + loadCustomMovesForEncounter, + leaveEncounterWithoutBattle, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, + generateModifierType, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -35,179 +42,188 @@ const BST_INCREASE_VALUE = 10; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3803 | GitHub Issue #3803} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TheStrongStuffEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.THE_STRONG_STUFF) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withScenePartySizeRequirement(3, 6) // Must have at least 3 pokemon in party - .withMaxAllowedEncounters(1) - .withHideWildIntroMessage(true) - .withAutoHideIntroVisuals(false) - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - spriteKey: "berry_juice", - fileRoot: "items", - hasShadow: true, - isItem: true, - scale: 1.25, - x: -15, - y: 3, - disableAnimation: true - }, - { - spriteKey: Species.SHUCKLE.toString(), - fileRoot: "pokemon", - hasShadow: true, - repeat: true, - scale: 1.25, - x: 20, - y: 10, - yShadow: 7 - }, - ]) // Set in onInit() - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .withOnInit(() => { +export const TheStrongStuffEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.THE_STRONG_STUFF, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withScenePartySizeRequirement(3, 6) // Must have at least 3 pokemon in party + .withMaxAllowedEncounters(1) + .withHideWildIntroMessage(true) + .withAutoHideIntroVisuals(false) + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + spriteKey: "berry_juice", + fileRoot: "items", + hasShadow: true, + isItem: true, + scale: 1.25, + x: -15, + y: 3, + disableAnimation: true, + }, + { + spriteKey: Species.SHUCKLE.toString(), + fileRoot: "pokemon", + hasShadow: true, + repeat: true, + scale: 1.25, + x: 20, + y: 10, + yShadow: 7, + }, + ]) // Set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + + // Calculate boss mon + const config: EnemyPartyConfig = { + levelAdditiveModifier: 1, + disableSwitch: true, + pokemonConfigs: [ + { + species: getPokemonSpecies(Species.SHUCKLE), + isBoss: true, + bossSegments: 5, + shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked + customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), + nature: Nature.BOLD, + moveSet: [Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER], + modifierConfigs: [ + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType, + }, + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.ENIGMA]) as PokemonHeldItemModifierType, + }, + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.APICOT]) as PokemonHeldItemModifierType, + }, + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.GANLON]) as PokemonHeldItemModifierType, + }, + { + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LUM]) as PokemonHeldItemModifierType, + stackCount: 2, + }, + ], + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: (pokemon: Pokemon) => { + queueEncounterMessage(`${namespace}:option.2.stat_boost`); + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.DEF, Stat.SPDEF], 2), + ); + }, + }, + ], + }; + + encounter.enemyPartyConfigs = [config]; + + loadCustomMovesForEncounter([Moves.GASTRO_ACID, Moves.STEALTH_ROCK]); + + encounter.setDialogueToken("shuckleName", getPokemonSpecies(Species.SHUCKLE).getName()); + + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { const encounter = globalScene.currentBattle.mysteryEncounter!; + // Do blackout and hide intro visuals during blackout + globalScene.time.delayedCall(750, () => { + transitionMysteryEncounterIntroVisuals(true, true, 50); + }); - // Calculate boss mon - const config: EnemyPartyConfig = { - levelAdditiveModifier: 1, - disableSwitch: true, - pokemonConfigs: [ - { - species: getPokemonSpecies(Species.SHUCKLE), - isBoss: true, - bossSegments: 5, - shiny: false, // Shiny lock because shiny is rolled only if the battle option is picked - customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), - nature: Nature.BOLD, - moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ], - modifierConfigs: [ - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ]) as PokemonHeldItemModifierType - }, - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.ENIGMA ]) as PokemonHeldItemModifierType - }, - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.APICOT ]) as PokemonHeldItemModifierType - }, - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.GANLON ]) as PokemonHeldItemModifierType - }, - { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LUM ]) as PokemonHeldItemModifierType, - stackCount: 2 - } - ], - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: (pokemon: Pokemon) => { - queueEncounterMessage(`${namespace}:option.2.stat_boost`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [ Stat.DEF, Stat.SPDEF ], 2)); - } - } - ], - }; + // -15 to all base stats of highest BST (halved for HP), +10 to all base stats of rest of party (halved for HP) + // Sort party by bst + const sortedParty = globalScene + .getPlayerParty() + .slice(0) + .sort((pokemon1, pokemon2) => { + const pokemon1Bst = pokemon1.getSpeciesForm().getBaseStatTotal(); + const pokemon2Bst = pokemon2.getSpeciesForm().getBaseStatTotal(); + return pokemon2Bst - pokemon1Bst; + }); - encounter.enemyPartyConfigs = [ config ]; + sortedParty.forEach((pokemon, index) => { + if (index < 2) { + // -15 to the two highest BST mons + modifyPlayerPokemonBST(pokemon, -HIGH_BST_REDUCTION_VALUE); + encounter.setDialogueToken("highBstPokemon" + (index + 1), pokemon.getNameToRender()); + } else { + // +10 for the rest + modifyPlayerPokemonBST(pokemon, BST_INCREASE_VALUE); + } + }); - loadCustomMovesForEncounter([ Moves.GASTRO_ACID, Moves.STEALTH_ROCK ]); - - encounter.setDialogueToken("shuckleName", getPokemonSpecies(Species.SHUCKLE).getName()); + encounter.setDialogueToken("reductionValue", HIGH_BST_REDUCTION_VALUE.toString()); + encounter.setDialogueToken("increaseValue", BST_INCREASE_VALUE.toString()); + await showEncounterText(`${namespace}:option.1.selected_2`, null, undefined, true); + encounter.dialogue.outro = [ + { + text: `${namespace}:outro`, + }, + ]; + setEncounterRewards({ fillRemaining: true }); + leaveEncounterWithoutBattle(true); return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected` - } - ] - }, - async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - // Do blackout and hide intro visuals during blackout - globalScene.time.delayedCall(750, () => { - transitionMysteryEncounterIntroVisuals(true, true, 50); - }); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Pick battle + const encounter = globalScene.currentBattle.mysteryEncounter!; + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.SOUL_DEW], + fillRemaining: true, + }); + encounter.startOfBattleEffects.push( + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.GASTRO_ACID), + ignorePp: true, + }, + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.STEALTH_ROCK), + ignorePp: true, + }, + ); - // -15 to all base stats of highest BST (halved for HP), +10 to all base stats of rest of party (halved for HP) - // Sort party by bst - const sortedParty = globalScene.getPlayerParty().slice(0) - .sort((pokemon1, pokemon2) => { - const pokemon1Bst = pokemon1.getSpeciesForm().getBaseStatTotal(); - const pokemon2Bst = pokemon2.getSpeciesForm().getBaseStatTotal(); - return pokemon2Bst - pokemon1Bst; - }); - - sortedParty.forEach((pokemon, index) => { - if (index < 2) { - // -15 to the two highest BST mons - modifyPlayerPokemonBST(pokemon, -HIGH_BST_REDUCTION_VALUE); - encounter.setDialogueToken("highBstPokemon" + (index + 1), pokemon.getNameToRender()); - } else { - // +10 for the rest - modifyPlayerPokemonBST(pokemon, BST_INCREASE_VALUE); - } - }); - - encounter.setDialogueToken("reductionValue", HIGH_BST_REDUCTION_VALUE.toString()); - encounter.setDialogueToken("increaseValue", BST_INCREASE_VALUE.toString()); - await showEncounterText(`${namespace}:option.1.selected_2`, null, undefined, true); - - encounter.dialogue.outro = [ - { - text: `${namespace}:outro`, - } - ]; - setEncounterRewards({ fillRemaining: true }); - leaveEncounterWithoutBattle(true); - return true; - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Pick battle - const encounter = globalScene.currentBattle.mysteryEncounter!; - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.SOUL_DEW ], fillRemaining: true }); - encounter.startOfBattleEffects.push( - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.GASTRO_ACID), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.STEALTH_ROCK), - ignorePp: true - }); - - encounter.dialogue.outro = []; - await transitionMysteryEncounterIntroVisuals(true, true, 500); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - } - ) - .build(); + encounter.dialogue.outro = []; + await transitionMysteryEncounterIntroVisuals(true, true, 500); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }, + ) + .build(); diff --git a/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts b/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts index c1a74f67c49..aca04ad50ed 100644 --- a/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts @@ -1,5 +1,12 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { generateModifierType, generateModifierTypeOption, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + generateModifierTypeOption, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -36,111 +43,115 @@ const namespace = "mysteryEncounters/theWinstrateChallenge"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3821 | GitHub Issue #3821} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TheWinstrateChallengeEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.THE_WINSTRATE_CHALLENGE) - .withEncounterTier(MysteryEncounterTier.ROGUE) - .withSceneWaveRangeRequirement(100, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withIntroSpriteConfigs([ - { - spriteKey: "vito", - fileRoot: "trainer", - hasShadow: false, - x: 16, - y: -4 - }, - { - spriteKey: "vivi", - fileRoot: "trainer", - hasShadow: false, - x: -14, - y: -4 - }, - { - spriteKey: "victor", - fileRoot: "trainer", - hasShadow: true, - x: -32 - }, - { - spriteKey: "victoria", - fileRoot: "trainer", - hasShadow: true, - x: 40, - }, - { - spriteKey: "vicky", - fileRoot: "trainer", - hasShadow: true, - x: 3, - y: 5, - yShadow: 5 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, - }, - ]) - .withAutoHideIntroVisuals(false) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const TheWinstrateChallengeEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.THE_WINSTRATE_CHALLENGE, +) + .withEncounterTier(MysteryEncounterTier.ROGUE) + .withSceneWaveRangeRequirement(100, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withIntroSpriteConfigs([ + { + spriteKey: "vito", + fileRoot: "trainer", + hasShadow: false, + x: 16, + y: -4, + }, + { + spriteKey: "vivi", + fileRoot: "trainer", + hasShadow: false, + x: -14, + y: -4, + }, + { + spriteKey: "victor", + fileRoot: "trainer", + hasShadow: true, + x: -32, + }, + { + spriteKey: "victoria", + fileRoot: "trainer", + hasShadow: true, + x: 40, + }, + { + spriteKey: "vicky", + fileRoot: "trainer", + hasShadow: true, + x: 3, + y: 5, + yShadow: 5, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .withAutoHideIntroVisuals(false) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Loaded back to front for pop() operations - encounter.enemyPartyConfigs.push(getVitoTrainerConfig()); - encounter.enemyPartyConfigs.push(getVickyTrainerConfig()); - encounter.enemyPartyConfigs.push(getViviTrainerConfig()); - encounter.enemyPartyConfigs.push(getVictoriaTrainerConfig()); - encounter.enemyPartyConfigs.push(getVictorTrainerConfig()); + // Loaded back to front for pop() operations + encounter.enemyPartyConfigs.push(getVitoTrainerConfig()); + encounter.enemyPartyConfigs.push(getVickyTrainerConfig()); + encounter.enemyPartyConfigs.push(getViviTrainerConfig()); + encounter.enemyPartyConfigs.push(getVictoriaTrainerConfig()); + encounter.enemyPartyConfigs.push(getVictorTrainerConfig()); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:option.1.selected`, - }, - ], - }, - async () => { - // Spawn 5 trainer battles back to back with Macho Brace in rewards - globalScene.currentBattle.mysteryEncounter!.doContinueEncounter = async () => { - await endTrainerBattleAndShowDialogue(); - }; - await transitionMysteryEncounterIntroVisuals(true, false); - await spawnNextTrainerOrEndEncounter(); - } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - speaker: `${namespace}:speaker`, - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Refuse the challenge, they full heal the party and give the player a Rarer Candy - globalScene.unshiftPhase(new PartyHealPhase(true)); - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.RARER_CANDY ], fillRemaining: false }); - leaveEncounterWithoutBattle(); - } - ) - .build(); + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Spawn 5 trainer battles back to back with Macho Brace in rewards + globalScene.currentBattle.mysteryEncounter!.doContinueEncounter = async () => { + await endTrainerBattleAndShowDialogue(); + }; + await transitionMysteryEncounterIntroVisuals(true, false); + await spawnNextTrainerOrEndEncounter(); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + speaker: `${namespace}:speaker`, + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Refuse the challenge, they full heal the party and give the player a Rarer Candy + globalScene.unshiftPhase(new PartyHealPhase(true)); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [modifierTypes.RARER_CANDY], + fillRemaining: false, + }); + leaveEncounterWithoutBattle(); + }, + ) + .build(); async function spawnNextTrainerOrEndEncounter() { const encounter = globalScene.currentBattle.mysteryEncounter!; @@ -159,7 +170,10 @@ async function spawnNextTrainerOrEndEncounter() { globalScene.ui.clearText(); // Clears "Winstrate" title from screen as rewards get animated in const machoBrace = generateModifierTypeOption(modifierTypes.MYSTERY_ENCOUNTER_MACHO_BRACE)!; machoBrace.type.tier = ModifierTier.MASTER; - setEncounterRewards({ guaranteedModifierTypeOptions: [ machoBrace ], fillRemaining: false }); + setEncounterRewards({ + guaranteedModifierTypeOptions: [machoBrace], + fillRemaining: false, + }); encounter.doContinueEncounter = undefined; leaveEncounterWithoutBattle(false, MysteryEncounterMode.NO_BATTLE); } else { @@ -168,6 +182,7 @@ async function spawnNextTrainerOrEndEncounter() { } function endTrainerBattleAndShowDialogue(): Promise { + // biome-ignore lint/suspicious/noAsyncPromiseExecutor: TODO: Consider refactoring to avoid async promise executor return new Promise(async resolve => { if (globalScene.currentBattle.mysteryEncounter!.enemyPartyConfigs.length === 0) { // Battle is over @@ -182,7 +197,7 @@ function endTrainerBattleAndShowDialogue(): Promise { duration: 750, onComplete: () => { globalScene.field.remove(trainer, true); - } + }, }); } @@ -191,13 +206,19 @@ function endTrainerBattleAndShowDialogue(): Promise { } else { globalScene.arena.resetArenaEffects(); const playerField = globalScene.getPlayerField(); - playerField.forEach((pokemon) => pokemon.lapseTag(BattlerTagType.COMMANDED)); + for (const pokemon of playerField) { + pokemon.lapseTag(BattlerTagType.COMMANDED); + } playerField.forEach((_, p) => globalScene.unshiftPhase(new ReturnPhase(p))); for (const pokemon of globalScene.getPlayerParty()) { // Only trigger form change when Eiscue is in Noice form // Hardcoded Eiscue for now in case it is fused with another pokemon - if (pokemon.species.speciesId === Species.EISCUE && pokemon.hasAbility(Abilities.ICE_FACE) && pokemon.formIndex === 1) { + if ( + pokemon.species.speciesId === Species.EISCUE && + pokemon.hasAbility(Abilities.ICE_FACE) && + pokemon.formIndex === 1 + ) { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeAbilityTrigger); } @@ -222,7 +243,7 @@ function endTrainerBattleAndShowDialogue(): Promise { onComplete: () => { globalScene.field.remove(trainer, true); resolve(); - } + }, }); } } @@ -238,38 +259,38 @@ function getVictorTrainerConfig(): EnemyPartyConfig { isBoss: false, abilityIndex: 0, // Guts nature: Nature.ADAMANT, - moveSet: [ Moves.FACADE, Moves.BRAVE_BIRD, Moves.PROTECT, Moves.QUICK_ATTACK ], + moveSet: [Moves.FACADE, Moves.BRAVE_BIRD, Moves.PROTECT, Moves.QUICK_ATTACK], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.FLAME_ORB) as PokemonHeldItemModifierType, - isTransferable: false + isTransferable: false, }, { modifier: generateModifierType(modifierTypes.FOCUS_BAND) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false + isTransferable: false, }, - ] + ], }, { species: getPokemonSpecies(Species.OBSTAGOON), isBoss: false, abilityIndex: 1, // Guts nature: Nature.ADAMANT, - moveSet: [ Moves.FACADE, Moves.OBSTRUCT, Moves.NIGHT_SLASH, Moves.FIRE_PUNCH ], + moveSet: [Moves.FACADE, Moves.OBSTRUCT, Moves.NIGHT_SLASH, Moves.FIRE_PUNCH], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.FLAME_ORB) as PokemonHeldItemModifierType, - isTransferable: false + isTransferable: false, }, { modifier: generateModifierType(modifierTypes.LEFTOVERS) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false - } - ] - } - ] + isTransferable: false, + }, + ], + }, + ], }; } @@ -282,39 +303,43 @@ function getVictoriaTrainerConfig(): EnemyPartyConfig { isBoss: false, abilityIndex: 0, // Natural Cure nature: Nature.CALM, - moveSet: [ Moves.SYNTHESIS, Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.SLEEP_POWDER ], + moveSet: [Moves.SYNTHESIS, Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.SLEEP_POWDER], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType, - isTransferable: false + isTransferable: false, }, { modifier: generateModifierType(modifierTypes.QUICK_CLAW) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false - } - ] + isTransferable: false, + }, + ], }, { species: getPokemonSpecies(Species.GARDEVOIR), isBoss: false, formIndex: 1, nature: Nature.TIMID, - moveSet: [ Moves.PSYSHOCK, Moves.MOONBLAST, Moves.SHADOW_BALL, Moves.WILL_O_WISP ], + moveSet: [Moves.PSYSHOCK, Moves.MOONBLAST, Moves.SHADOW_BALL, Moves.WILL_O_WISP], modifierConfigs: [ { - modifier: generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.PSYCHIC ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ + PokemonType.PSYCHIC, + ]) as PokemonHeldItemModifierType, stackCount: 1, - isTransferable: false + isTransferable: false, }, { - modifier: generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ PokemonType.FAIRY ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, [ + PokemonType.FAIRY, + ]) as PokemonHeldItemModifierType, stackCount: 1, - isTransferable: false - } - ] - } - ] + isTransferable: false, + }, + ], + }, + ], }; } @@ -327,53 +352,53 @@ function getViviTrainerConfig(): EnemyPartyConfig { isBoss: false, abilityIndex: 3, // Lightning Rod nature: Nature.ADAMANT, - moveSet: [ Moves.WATERFALL, Moves.MEGAHORN, Moves.KNOCK_OFF, Moves.REST ], + moveSet: [Moves.WATERFALL, Moves.MEGAHORN, Moves.KNOCK_OFF, Moves.REST], modifierConfigs: [ { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LUM ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LUM]) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false + isTransferable: false, }, { - modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [ Stat.HP ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [Stat.HP]) as PokemonHeldItemModifierType, stackCount: 4, - isTransferable: false - } - ] + isTransferable: false, + }, + ], }, { species: getPokemonSpecies(Species.BRELOOM), isBoss: false, abilityIndex: 1, // Poison Heal nature: Nature.JOLLY, - moveSet: [ Moves.SPORE, Moves.SWORDS_DANCE, Moves.SEED_BOMB, Moves.DRAIN_PUNCH ], + moveSet: [Moves.SPORE, Moves.SWORDS_DANCE, Moves.SEED_BOMB, Moves.DRAIN_PUNCH], modifierConfigs: [ { - modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [ Stat.HP ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [Stat.HP]) as PokemonHeldItemModifierType, stackCount: 4, - isTransferable: false + isTransferable: false, }, { modifier: generateModifierType(modifierTypes.TOXIC_ORB) as PokemonHeldItemModifierType, - isTransferable: false - } - ] + isTransferable: false, + }, + ], }, { species: getPokemonSpecies(Species.CAMERUPT), isBoss: false, formIndex: 1, nature: Nature.CALM, - moveSet: [ Moves.EARTH_POWER, Moves.FIRE_BLAST, Moves.YAWN, Moves.PROTECT ], + moveSet: [Moves.EARTH_POWER, Moves.FIRE_BLAST, Moves.YAWN, Moves.PROTECT], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.QUICK_CLAW) as PokemonHeldItemModifierType, stackCount: 3, - isTransferable: false + isTransferable: false, }, - ] - } - ] + ], + }, + ], }; } @@ -386,15 +411,15 @@ function getVickyTrainerConfig(): EnemyPartyConfig { isBoss: false, formIndex: 1, nature: Nature.IMPISH, - moveSet: [ Moves.AXE_KICK, Moves.ICE_PUNCH, Moves.ZEN_HEADBUTT, Moves.BULLET_PUNCH ], + moveSet: [Moves.AXE_KICK, Moves.ICE_PUNCH, Moves.ZEN_HEADBUTT, Moves.BULLET_PUNCH], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType, - isTransferable: false - } - ] - } - ] + isTransferable: false, + }, + ], + }, + ], }; } @@ -407,110 +432,110 @@ function getVitoTrainerConfig(): EnemyPartyConfig { isBoss: false, abilityIndex: 0, // Soundproof nature: Nature.MODEST, - moveSet: [ Moves.THUNDERBOLT, Moves.GIGA_DRAIN, Moves.FOUL_PLAY, Moves.THUNDER_WAVE ], + moveSet: [Moves.THUNDERBOLT, Moves.GIGA_DRAIN, Moves.FOUL_PLAY, Moves.THUNDER_WAVE], modifierConfigs: [ { - modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [ Stat.SPD ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BASE_STAT_BOOSTER, [Stat.SPD]) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false - } - ] + isTransferable: false, + }, + ], }, { species: getPokemonSpecies(Species.SWALOT), isBoss: false, abilityIndex: 2, // Gluttony nature: Nature.QUIET, - moveSet: [ Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.ICE_BEAM, Moves.EARTHQUAKE ], + moveSet: [Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.ICE_BEAM, Moves.EARTHQUAKE], modifierConfigs: [ { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.APICOT ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.APICOT]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.GANLON ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.GANLON]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.STARF ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.STARF]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.SALAC ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.SALAC]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LUM ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LUM]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LANSAT ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LANSAT]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LIECHI ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LIECHI]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.PETAYA ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.PETAYA]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.ENIGMA ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.ENIGMA]) as PokemonHeldItemModifierType, stackCount: 2, }, { - modifier: generateModifierType(modifierTypes.BERRY, [ BerryType.LEPPA ]) as PokemonHeldItemModifierType, + modifier: generateModifierType(modifierTypes.BERRY, [BerryType.LEPPA]) as PokemonHeldItemModifierType, stackCount: 2, - } - ] + }, + ], }, { species: getPokemonSpecies(Species.DODRIO), isBoss: false, abilityIndex: 2, // Tangled Feet nature: Nature.JOLLY, - moveSet: [ Moves.DRILL_PECK, Moves.QUICK_ATTACK, Moves.THRASH, Moves.KNOCK_OFF ], + moveSet: [Moves.DRILL_PECK, Moves.QUICK_ATTACK, Moves.THRASH, Moves.KNOCK_OFF], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.KINGS_ROCK) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false - } - ] + isTransferable: false, + }, + ], }, { species: getPokemonSpecies(Species.ALAKAZAM), isBoss: false, formIndex: 1, nature: Nature.BOLD, - moveSet: [ Moves.PSYCHIC, Moves.SHADOW_BALL, Moves.FOCUS_BLAST, Moves.THUNDERBOLT ], + moveSet: [Moves.PSYCHIC, Moves.SHADOW_BALL, Moves.FOCUS_BLAST, Moves.THUNDERBOLT], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.WIDE_LENS) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false + isTransferable: false, }, - ] + ], }, { species: getPokemonSpecies(Species.DARMANITAN), isBoss: false, abilityIndex: 0, // Sheer Force nature: Nature.IMPISH, - moveSet: [ Moves.EARTHQUAKE, Moves.U_TURN, Moves.FLARE_BLITZ, Moves.ROCK_SLIDE ], + moveSet: [Moves.EARTHQUAKE, Moves.U_TURN, Moves.FLARE_BLITZ, Moves.ROCK_SLIDE], modifierConfigs: [ { modifier: generateModifierType(modifierTypes.QUICK_CLAW) as PokemonHeldItemModifierType, stackCount: 2, - isTransferable: false + isTransferable: false, }, - ] - } - ] + ], + }, + ], }; } diff --git a/src/data/mystery-encounters/encounters/training-session-encounter.ts b/src/data/mystery-encounters/encounters/training-session-encounter.ts index 9cb388e343c..cc56f3efa42 100644 --- a/src/data/mystery-encounters/encounters/training-session-encounter.ts +++ b/src/data/mystery-encounters/encounters/training-session-encounter.ts @@ -1,7 +1,12 @@ import type { Ability } from "#app/data/ability"; import { allAbilities } from "#app/data/ability"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { initBattleWithEnemyConfig, leaveEncounterWithoutBattle, selectPokemonForOption, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + selectPokemonForOption, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { getNatureName } from "#app/data/nature"; import { speciesStarterCosts } from "#app/data/balance/starters"; import type { PlayerPokemon } from "#app/field/pokemon"; @@ -35,360 +40,350 @@ const namespace = "mysteryEncounters/trainingSession"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3802 | GitHub Issue #3802} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TrainingSessionEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.TRAINING_SESSION) - .withEncounterTier(MysteryEncounterTier.ULTRA) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 unfainted pokemon in party - .withFleeAllowed(false) - .withHideWildIntroMessage(true) - .withPreventGameStatsUpdates(true) // Do not count the Pokemon as seen or defeated since it is ours - .withIntroSpriteConfigs([ - { - spriteKey: "training_session_gear", - fileRoot: "mystery-encounters", - hasShadow: true, - y: 6, - x: 5, - yShadow: -2 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - } - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - encounter.misc = { - playerPokemon: pokemon, +export const TrainingSessionEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.TRAINING_SESSION, +) + .withEncounterTier(MysteryEncounterTier.ULTRA) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withScenePartySizeRequirement(2, 6, true) // Must have at least 2 unfainted pokemon in party + .withFleeAllowed(false) + .withHideWildIntroMessage(true) + .withPreventGameStatsUpdates(true) // Do not count the Pokemon as seen or defeated since it is ours + .withIntroSpriteConfigs([ + { + spriteKey: "training_session_gear", + fileRoot: "mystery-encounters", + hasShadow: true, + y: 6, + x: 5, + yShadow: -2, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + encounter.misc = { + playerPokemon: pokemon, + }; + }; + + // Only Pokemon that are not KOed/legal can be trained + const selectableFilter = (pokemon: Pokemon) => { + return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); + }; + + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; + + // Spawn light training session with chosen pokemon + // Every 50 waves, add +1 boss segment, capping at 5 + const segments = Math.min(2 + Math.floor(globalScene.currentBattle.waveIndex / 50), 5); + const modifiers = new ModifiersHolder(); + const config = getEnemyConfig(playerPokemon, segments, modifiers); + globalScene.removePokemonFromPlayerParty(playerPokemon, false); + + const onBeforeRewardsPhase = () => { + encounter.setDialogueToken("stat1", "-"); + encounter.setDialogueToken("stat2", "-"); + // Add the pokemon back to party with IV boost + let ivIndexes: any[] = []; + playerPokemon.ivs.forEach((iv, index) => { + if (iv < 31) { + ivIndexes.push({ iv: iv, index: index }); + } + }); + + // Improves 2 random non-maxed IVs + // +10 if IV is < 10, +5 if between 10-20, and +3 if > 20 + // A 0-4 starting IV will cap in 6 encounters (assuming you always rolled that IV) + // 5-14 starting IV caps in 5 encounters + // 15-19 starting IV caps in 4 encounters + // 20-24 starting IV caps in 3 encounters + // 25-27 starting IV caps in 2 encounters + let improvedCount = 0; + while (ivIndexes.length > 0 && improvedCount < 2) { + ivIndexes = randSeedShuffle(ivIndexes); + const ivToChange = ivIndexes.pop(); + let newVal = ivToChange.iv; + if (improvedCount === 0) { + encounter.setDialogueToken("stat1", i18next.t(getStatKey(ivToChange.index)) ?? ""); + } else { + encounter.setDialogueToken("stat2", i18next.t(getStatKey(ivToChange.index)) ?? ""); + } + + // Corrects required encounter breakpoints to be continuous for all IV values + if (ivToChange.iv <= 21 && ivToChange.iv - (1 % 5) === 0) { + newVal += 1; + } + + newVal += ivToChange.iv <= 10 ? 10 : ivToChange.iv <= 20 ? 5 : 3; + newVal = Math.min(newVal, 31); + playerPokemon.ivs[ivToChange.index] = newVal; + improvedCount++; + } + + if (improvedCount > 0) { + playerPokemon.calculateStats(); + globalScene.gameData.updateSpeciesDexIvs(playerPokemon.species.getRootSpeciesId(true), playerPokemon.ivs); + globalScene.gameData.setPokemonCaught(playerPokemon, false); + } + + // Add pokemon and mods back + globalScene.getPlayerParty().push(playerPokemon); + for (const mod of modifiers.value) { + mod.pokemonId = playerPokemon.id; + globalScene.addModifier(mod, true, false, false, true); + } + globalScene.updateModifiers(true); + queueEncounterMessage(`${namespace}:option.1.finished`); + }; + + setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); + + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + secondOptionPrompt: `${namespace}:option.2.select_prompt`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + // Open menu for selecting pokemon and Nature + const encounter = globalScene.currentBattle.mysteryEncounter!; + const natures = new Array(25).fill(null).map((_val, i) => i as Nature); + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for nature selection + return natures.map((nature: Nature) => { + const option: OptionSelectItem = { + label: getNatureName(nature, true, true, true, globalScene.uiTheme), + handler: () => { + // Pokemon and second option selected + encounter.setDialogueToken("nature", getNatureName(nature)); + encounter.misc = { + playerPokemon: pokemon, + chosenNature: nature, + }; + return true; + }, }; - }; + return option; + }); + }; - // Only Pokemon that are not KOed/legal can be trained - const selectableFilter = (pokemon: Pokemon) => { - return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); - }; + // Only Pokemon that are not KOed/legal can be trained + const selectableFilter = (pokemon: Pokemon) => { + return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); + }; - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; - // Spawn light training session with chosen pokemon - // Every 50 waves, add +1 boss segment, capping at 5 - const segments = Math.min( - 2 + Math.floor(globalScene.currentBattle.waveIndex / 50), - 5 - ); - const modifiers = new ModifiersHolder(); - const config = getEnemyConfig(playerPokemon, segments, modifiers); - globalScene.removePokemonFromPlayerParty(playerPokemon, false); + // Spawn medium training session with chosen pokemon + // Every 40 waves, add +1 boss segment, capping at 6 + const segments = Math.min(2 + Math.floor(globalScene.currentBattle.waveIndex / 40), 6); + const modifiers = new ModifiersHolder(); + const config = getEnemyConfig(playerPokemon, segments, modifiers); + globalScene.removePokemonFromPlayerParty(playerPokemon, false); - const onBeforeRewardsPhase = () => { - encounter.setDialogueToken("stat1", "-"); - encounter.setDialogueToken("stat2", "-"); - // Add the pokemon back to party with IV boost - let ivIndexes: any[] = []; - playerPokemon.ivs.forEach((iv, index) => { - if (iv < 31) { - ivIndexes.push({ iv: iv, index: index }); - } - }); + const onBeforeRewardsPhase = () => { + queueEncounterMessage(`${namespace}:option.2.finished`); + // Add the pokemon back to party with Nature change + playerPokemon.setCustomNature(encounter.misc.chosenNature); + globalScene.gameData.unlockSpeciesNature(playerPokemon.species, encounter.misc.chosenNature); - // Improves 2 random non-maxed IVs - // +10 if IV is < 10, +5 if between 10-20, and +3 if > 20 - // A 0-4 starting IV will cap in 6 encounters (assuming you always rolled that IV) - // 5-14 starting IV caps in 5 encounters - // 15-19 starting IV caps in 4 encounters - // 20-24 starting IV caps in 3 encounters - // 25-27 starting IV caps in 2 encounters - let improvedCount = 0; - while (ivIndexes.length > 0 && improvedCount < 2) { - ivIndexes = randSeedShuffle(ivIndexes); - const ivToChange = ivIndexes.pop(); - let newVal = ivToChange.iv; - if (improvedCount === 0) { - encounter.setDialogueToken( - "stat1", - i18next.t(getStatKey(ivToChange.index)) ?? "" - ); - } else { - encounter.setDialogueToken( - "stat2", - i18next.t(getStatKey(ivToChange.index)) ?? "" - ); - } + // Add pokemon and modifiers back + globalScene.getPlayerParty().push(playerPokemon); + for (const mod of modifiers.value) { + mod.pokemonId = playerPokemon.id; + globalScene.addModifier(mod, true, false, false, true); + } + globalScene.updateModifiers(true); + }; - // Corrects required encounter breakpoints to be continuous for all IV values - if (ivToChange.iv <= 21 && ivToChange.iv - (1 % 5) === 0) { - newVal += 1; - } + setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); - newVal += ivToChange.iv <= 10 ? 10 : ivToChange.iv <= 20 ? 5 : 3; - newVal = Math.min(newVal, 31); - playerPokemon.ivs[ivToChange.index] = newVal; - improvedCount++; - } + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + secondOptionPrompt: `${namespace}:option.3.select_prompt`, + selected: [ + { + text: `${namespace}:option.selected`, + }, + ], + }) + .withPreOptionPhase(async (): Promise => { + // Open menu for selecting pokemon and ability to learn + const encounter = globalScene.currentBattle.mysteryEncounter!; + const onPokemonSelected = (pokemon: PlayerPokemon) => { + // Return the options for ability selection + const speciesForm = pokemon.getFusionSpeciesForm() + ? pokemon.getFusionSpeciesForm() + : pokemon.getSpeciesForm(); + const abilityCount = speciesForm.getAbilityCount(); + const abilities: Ability[] = new Array(abilityCount) + .fill(null) + .map((_val, i) => allAbilities[speciesForm.getAbility(i)]); - if (improvedCount > 0) { - playerPokemon.calculateStats(); - globalScene.gameData.updateSpeciesDexIvs(playerPokemon.species.getRootSpeciesId(true), playerPokemon.ivs); - globalScene.gameData.setPokemonCaught(playerPokemon, false); - } - - // Add pokemon and mods back - globalScene.getPlayerParty().push(playerPokemon); - for (const mod of modifiers.value) { - mod.pokemonId = playerPokemon.id; - globalScene.addModifier(mod, true, false, false, true); - } - globalScene.updateModifiers(true); - queueEncounterMessage(`${namespace}:option.1.finished`); - }; - - setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); - - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - secondOptionPrompt: `${namespace}:option.2.select_prompt`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - // Open menu for selecting pokemon and Nature - const encounter = globalScene.currentBattle.mysteryEncounter!; - const natures = new Array(25).fill(null).map((val, i) => i as Nature); - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for nature selection - return natures.map((nature: Nature) => { + const optionSelectItems: OptionSelectItem[] = []; + abilities.forEach((ability: Ability, index) => { + if (!optionSelectItems.some(o => o.label === ability.name)) { const option: OptionSelectItem = { - label: getNatureName(nature, true, true, true, globalScene.uiTheme), + label: ability.name, handler: () => { - // Pokemon and second option selected - encounter.setDialogueToken("nature", getNatureName(nature)); + // Pokemon and ability selected + encounter.setDialogueToken("ability", ability.name); encounter.misc = { playerPokemon: pokemon, - chosenNature: nature, + abilityIndex: index, }; return true; }, + onHover: () => { + showEncounterText(ability.description, 0, 0, false); + }, }; - return option; - }); - }; - - // Only Pokemon that are not KOed/legal can be trained - const selectableFilter = (pokemon: Pokemon) => { - return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); - }; - - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; - - // Spawn medium training session with chosen pokemon - // Every 40 waves, add +1 boss segment, capping at 6 - const segments = Math.min(2 + Math.floor(globalScene.currentBattle.waveIndex / 40), 6); - const modifiers = new ModifiersHolder(); - const config = getEnemyConfig(playerPokemon, segments, modifiers); - globalScene.removePokemonFromPlayerParty(playerPokemon, false); - - const onBeforeRewardsPhase = () => { - queueEncounterMessage(`${namespace}:option.2.finished`); - // Add the pokemon back to party with Nature change - playerPokemon.setCustomNature(encounter.misc.chosenNature); - globalScene.gameData.unlockSpeciesNature(playerPokemon.species, encounter.misc.chosenNature); - - // Add pokemon and modifiers back - globalScene.getPlayerParty().push(playerPokemon); - for (const mod of modifiers.value) { - mod.pokemonId = playerPokemon.id; - globalScene.addModifier(mod, true, false, false, true); + optionSelectItems.push(option); } - globalScene.updateModifiers(true); - }; + }); - setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); + return optionSelectItems; + }; - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - secondOptionPrompt: `${namespace}:option.3.select_prompt`, - selected: [ - { - text: `${namespace}:option.selected`, - }, - ], - }) - .withPreOptionPhase(async (): Promise => { - // Open menu for selecting pokemon and ability to learn - const encounter = globalScene.currentBattle.mysteryEncounter!; - const onPokemonSelected = (pokemon: PlayerPokemon) => { - // Return the options for ability selection - const speciesForm = !!pokemon.getFusionSpeciesForm() - ? pokemon.getFusionSpeciesForm() - : pokemon.getSpeciesForm(); - const abilityCount = speciesForm.getAbilityCount(); - const abilities: Ability[] = new Array(abilityCount) - .fill(null) - .map((val, i) => allAbilities[speciesForm.getAbility(i)]); + // Only Pokemon that are not KOed/legal can be trained + const selectableFilter = (pokemon: Pokemon) => { + return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); + }; - const optionSelectItems: OptionSelectItem[] = []; - abilities.forEach((ability: Ability, index) => { - if (!optionSelectItems.some(o => o.label === ability.name)) { - const option: OptionSelectItem = { - label: ability.name, - handler: () => { - // Pokemon and ability selected - encounter.setDialogueToken("ability", ability.name); - encounter.misc = { - playerPokemon: pokemon, - abilityIndex: index, - }; - return true; - }, - onHover: () => { - showEncounterText(ability.description, 0, 0, false); - }, - }; - optionSelectItems.push(option); - } - }); + return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); + }) + .withOptionPhase(async () => { + const encounter = globalScene.currentBattle.mysteryEncounter!; + const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; - return optionSelectItems; - }; + // Spawn hard training session with chosen pokemon + // Every 30 waves, add +1 boss segment, capping at 6 + // Also starts with +1 to all stats + const segments = Math.min(2 + Math.floor(globalScene.currentBattle.waveIndex / 30), 6); + const modifiers = new ModifiersHolder(); + const config = getEnemyConfig(playerPokemon, segments, modifiers); + config.pokemonConfigs![0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON]; + globalScene.removePokemonFromPlayerParty(playerPokemon, false); - // Only Pokemon that are not KOed/legal can be trained - const selectableFilter = (pokemon: Pokemon) => { - return isPokemonValidForEncounterOptionSelection(pokemon, `${namespace}:invalid_selection`); - }; + const onBeforeRewardsPhase = () => { + queueEncounterMessage(`${namespace}:option.3.finished`); + // Add the pokemon back to party with ability change + const abilityIndex = encounter.misc.abilityIndex; - return selectPokemonForOption(onPokemonSelected, undefined, selectableFilter); - }) - .withOptionPhase(async () => { - const encounter = globalScene.currentBattle.mysteryEncounter!; - const playerPokemon: PlayerPokemon = encounter.misc.playerPokemon; + if (playerPokemon.getFusionSpeciesForm()) { + playerPokemon.fusionAbilityIndex = abilityIndex; - // Spawn hard training session with chosen pokemon - // Every 30 waves, add +1 boss segment, capping at 6 - // Also starts with +1 to all stats - const segments = Math.min(2 + Math.floor(globalScene.currentBattle.waveIndex / 30), 6); - const modifiers = new ModifiersHolder(); - const config = getEnemyConfig(playerPokemon, segments, modifiers); - config.pokemonConfigs![0].tags = [ - BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON, - ]; - globalScene.removePokemonFromPlayerParty(playerPokemon, false); - - const onBeforeRewardsPhase = () => { - queueEncounterMessage(`${namespace}:option.3.finished`); - // Add the pokemon back to party with ability change - const abilityIndex = encounter.misc.abilityIndex; - - if (!!playerPokemon.getFusionSpeciesForm()) { - playerPokemon.fusionAbilityIndex = abilityIndex; - - // Only update the fusion's dex data if the Pokemon is already caught in dex (ignore rentals) - const rootFusionSpecies = playerPokemon.fusionSpecies?.getRootSpeciesId(); - if (!isNullOrUndefined(rootFusionSpecies) - && speciesStarterCosts.hasOwnProperty(rootFusionSpecies) - && !!globalScene.gameData.dexData[rootFusionSpecies].caughtAttr) { - globalScene.gameData.starterData[rootFusionSpecies].abilityAttr |= playerPokemon.fusionAbilityIndex !== 1 || playerPokemon.fusionSpecies?.ability2 + // Only update the fusion's dex data if the Pokemon is already caught in dex (ignore rentals) + const rootFusionSpecies = playerPokemon.fusionSpecies?.getRootSpeciesId(); + if ( + !isNullOrUndefined(rootFusionSpecies) && + speciesStarterCosts.hasOwnProperty(rootFusionSpecies) && + !!globalScene.gameData.dexData[rootFusionSpecies].caughtAttr + ) { + globalScene.gameData.starterData[rootFusionSpecies].abilityAttr |= + playerPokemon.fusionAbilityIndex !== 1 || playerPokemon.fusionSpecies?.ability2 ? 1 << playerPokemon.fusionAbilityIndex : AbilityAttr.ABILITY_HIDDEN; - } - } else { - playerPokemon.abilityIndex = abilityIndex; } + } else { + playerPokemon.abilityIndex = abilityIndex; + } - playerPokemon.calculateStats(); - globalScene.gameData.setPokemonCaught(playerPokemon, false); + playerPokemon.calculateStats(); + globalScene.gameData.setPokemonCaught(playerPokemon, false); - // Add pokemon and mods back - globalScene.getPlayerParty().push(playerPokemon); - for (const mod of modifiers.value) { - mod.pokemonId = playerPokemon.id; - globalScene.addModifier(mod, true, false, false, true); - } - globalScene.updateModifiers(true); - }; + // Add pokemon and mods back + globalScene.getPlayerParty().push(playerPokemon); + for (const mod of modifiers.value) { + mod.pokemonId = playerPokemon.id; + globalScene.addModifier(mod, true, false, false, true); + } + globalScene.updateModifiers(true); + }; - setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); + setEncounterRewards({ fillRemaining: true }, undefined, onBeforeRewardsPhase); - await initBattleWithEnemyConfig(config); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.4.label`, - buttonTooltip: `${namespace}:option.4.tooltip`, - selected: [ - { - text: `${namespace}:option.4.selected`, - }, - ], - }, - async () => { - // Leave encounter with no rewards or exp - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + await initBattleWithEnemyConfig(config); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.4.label`, + buttonTooltip: `${namespace}:option.4.tooltip`, + selected: [ + { + text: `${namespace}:option.4.selected`, + }, + ], + }, + async () => { + // Leave encounter with no rewards or exp + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); function getEnemyConfig(playerPokemon: PlayerPokemon, segments: number, modifiers: ModifiersHolder): EnemyPartyConfig { playerPokemon.resetSummonData(); // Passes modifiers by reference modifiers.value = playerPokemon.getHeldItems(); - const modifierConfigs = modifiers.value.map((mod) => { + const modifierConfigs = modifiers.value.map(mod => { return { modifier: mod.clone(), isTransferable: false, - stackCount: mod.stackCount + stackCount: mod.stackCount, }; }) as HeldModifierConfig[]; @@ -410,6 +405,4 @@ function getEnemyConfig(playerPokemon: PlayerPokemon, segments: number, modifier class ModifiersHolder { public value: PokemonHeldItemModifier[] = []; - - constructor() {} } 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 a17b05c4e33..1c617aa2c7f 100644 --- a/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts +++ b/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts @@ -1,5 +1,12 @@ import type { EnemyPartyConfig, EnemyPokemonConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, loadCustomMovesForEncounter, setEncounterRewards, transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + generateModifierType, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + loadCustomMovesForEncounter, + setEncounterRewards, + transitionMysteryEncounterIntroVisuals, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -34,135 +41,149 @@ const SHOP_ITEM_COST_MULTIPLIER = 2.5; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3809 | GitHub Issue #3809} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const TrashToTreasureEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.TRASH_TO_TREASURE) - .withEncounterTier(MysteryEncounterTier.ULTRA) - .withSceneWaveRangeRequirement(60, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) - .withMaxAllowedEncounters(1) - .withFleeAllowed(false) - .withIntroSpriteConfigs([ - { - spriteKey: Species.GARBODOR.toString() + "-gigantamax", - fileRoot: "pokemon", - hasShadow: false, - disableAnimation: true, - scale: 1.5, - y: 8, - tint: 0.4 - } - ]) - .withAutoHideIntroVisuals(false) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const TrashToTreasureEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.TRASH_TO_TREASURE, +) + .withEncounterTier(MysteryEncounterTier.ULTRA) + .withSceneWaveRangeRequirement(60, CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES[1]) + .withMaxAllowedEncounters(1) + .withFleeAllowed(false) + .withIntroSpriteConfigs([ + { + spriteKey: Species.GARBODOR.toString() + "-gigantamax", + fileRoot: "pokemon", + hasShadow: false, + disableAnimation: true, + scale: 1.5, + y: 8, + tint: 0.4, + }, + ]) + .withAutoHideIntroVisuals(false) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculate boss mon (shiny locked) - const bossSpecies = getPokemonSpecies(Species.GARBODOR); - const pokemonConfig: EnemyPokemonConfig = { - species: bossSpecies, - isBoss: true, - shiny: false, // Shiny lock because of custom intro sprite - formIndex: 1, // Gmax - bossSegmentModifier: 1, // +1 Segment from normal - moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ] - }; - const config: EnemyPartyConfig = { - levelAdditiveModifier: 0.5, - pokemonConfigs: [ pokemonConfig ], - disableSwitch: true - }; - encounter.enemyPartyConfigs = [ config ]; + // Calculate boss mon (shiny locked) + const bossSpecies = getPokemonSpecies(Species.GARBODOR); + const pokemonConfig: EnemyPokemonConfig = { + species: bossSpecies, + isBoss: true, + shiny: false, // Shiny lock because of custom intro sprite + formIndex: 1, // Gmax + bossSegmentModifier: 1, // +1 Segment from normal + moveSet: [Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH], + }; + const config: EnemyPartyConfig = { + levelAdditiveModifier: 0.5, + pokemonConfigs: [pokemonConfig], + disableSwitch: true, + }; + encounter.enemyPartyConfigs = [config]; - // Load animations/sfx for Garbodor fight start moves - loadCustomMovesForEncounter([ Moves.TOXIC, Moves.AMNESIA ]); + // Load animations/sfx for Garbodor fight start moves + loadCustomMovesForEncounter([Moves.TOXIC, Moves.AMNESIA]); - globalScene.loadSe("PRSFX- Dig2", "battle_anims", "PRSFX- Dig2.wav"); - globalScene.loadSe("PRSFX- Venom Drench", "battle_anims", "PRSFX- Venom Drench.wav"); + globalScene.loadSe("PRSFX- Dig2", "battle_anims", "PRSFX- Dig2.wav"); + globalScene.loadSe("PRSFX- Venom Drench", "battle_anims", "PRSFX- Venom Drench.wav"); - encounter.setDialogueToken("costMultiplier", SHOP_ITEM_COST_MULTIPLIER.toString()); + encounter.setDialogueToken("costMultiplier", SHOP_ITEM_COST_MULTIPLIER.toString()); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - }, - ], - }) - .withPreOptionPhase(async () => { - // Play Dig2 and then Venom Drench sfx - doGarbageDig(); - }) - .withOptionPhase(async () => { - // Gain 2 Leftovers and 2 Shell Bell - await transitionMysteryEncounterIntroVisuals(); - await tryApplyDigRewardItems(); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Play Dig2 and then Venom Drench sfx + doGarbageDig(); + }) + .withOptionPhase(async () => { + // Gain 2 Leftovers and 2 Shell Bell + await transitionMysteryEncounterIntroVisuals(); + await tryApplyDigRewardItems(); - const blackSludge = generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_BLACK_SLUDGE, [ SHOP_ITEM_COST_MULTIPLIER ]); - const modifier = blackSludge?.newModifier(); - if (modifier) { - await globalScene.addModifier(modifier, false, false, false, true); - globalScene.playSound("battle_anims/PRSFX- Venom Drench", { volume: 2 }); - await showEncounterText(i18next.t("battle:rewardGain", { modifierName: modifier.type.name }), null, undefined, true); - } + const blackSludge = generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_BLACK_SLUDGE, [ + SHOP_ITEM_COST_MULTIPLIER, + ]); + const modifier = blackSludge?.newModifier(); + if (modifier) { + await globalScene.addModifier(modifier, false, false, false, true); + globalScene.playSound("battle_anims/PRSFX- Venom Drench", { + volume: 2, + }); + await showEncounterText( + i18next.t("battle:rewardGain", { + modifierName: modifier.type.name, + }), + null, + undefined, + true, + ); + } - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }) - .withOptionPhase(async () => { - // Investigate garbage, battle Gmax Garbodor - globalScene.setFieldScale(0.75); - await showEncounterText(`${namespace}:option.2.selected_2`); - await transitionMysteryEncounterIntroVisuals(); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }) + .withOptionPhase(async () => { + // Investigate garbage, battle Gmax Garbodor + globalScene.setFieldScale(0.75); + await showEncounterText(`${namespace}:option.2.selected_2`); + await transitionMysteryEncounterIntroVisuals(); - const encounter = globalScene.currentBattle.mysteryEncounter!; + const encounter = globalScene.currentBattle.mysteryEncounter!; - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.GREAT ], fillRemaining: true }); - encounter.startOfBattleEffects.push( - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.PLAYER ], - move: new PokemonMove(Moves.TOXIC), - ignorePp: true - }, - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ BattlerIndex.ENEMY ], - move: new PokemonMove(Moves.AMNESIA), - ignorePp: true - }); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - }) - .build() - ) - .build(); + setEncounterRewards({ + guaranteedModifierTiers: [ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.GREAT], + fillRemaining: true, + }); + encounter.startOfBattleEffects.push( + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.PLAYER], + move: new PokemonMove(Moves.TOXIC), + ignorePp: true, + }, + { + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [BattlerIndex.ENEMY], + move: new PokemonMove(Moves.AMNESIA), + ignorePp: true, + }, + ); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }) + .build(), + ) + .build(); async function tryApplyDigRewardItems() { const shellBell = generateModifierType(modifierTypes.SHELL_BELL) as PokemonHeldItemModifierType; @@ -173,8 +194,10 @@ async function tryApplyDigRewardItems() { // Iterate over the party until an item was successfully given // First leftovers for (const pokemon of party) { - const heldItems = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const heldItems = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, + true, + ) as PokemonHeldItemModifier[]; const existingLeftovers = heldItems.find(m => m instanceof TurnHealModifier) as TurnHealModifier; if (!existingLeftovers || existingLeftovers.getStackCount() < existingLeftovers.getMaxStackCount()) { @@ -185,8 +208,10 @@ async function tryApplyDigRewardItems() { // Second leftovers for (const pokemon of party) { - const heldItems = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const heldItems = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, + true, + ) as PokemonHeldItemModifier[]; const existingLeftovers = heldItems.find(m => m instanceof TurnHealModifier) as TurnHealModifier; if (!existingLeftovers || existingLeftovers.getStackCount() < existingLeftovers.getMaxStackCount()) { @@ -196,12 +221,22 @@ async function tryApplyDigRewardItems() { } globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGainCount", { modifierName: leftovers.name, count: 2 }), null, undefined, true); + await showEncounterText( + i18next.t("battle:rewardGainCount", { + modifierName: leftovers.name, + count: 2, + }), + null, + undefined, + true, + ); // First Shell bell for (const pokemon of party) { - const heldItems = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const heldItems = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, + true, + ) as PokemonHeldItemModifier[]; const existingShellBell = heldItems.find(m => m instanceof HitHealModifier) as HitHealModifier; if (!existingShellBell || existingShellBell.getStackCount() < existingShellBell.getMaxStackCount()) { @@ -212,8 +247,10 @@ async function tryApplyDigRewardItems() { // Second Shell bell for (const pokemon of party) { - const heldItems = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const heldItems = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, + true, + ) as PokemonHeldItemModifier[]; const existingShellBell = heldItems.find(m => m instanceof HitHealModifier) as HitHealModifier; if (!existingShellBell || existingShellBell.getStackCount() < existingShellBell.getMaxStackCount()) { @@ -223,7 +260,15 @@ async function tryApplyDigRewardItems() { } globalScene.playSound("item_fanfare"); - await showEncounterText(i18next.t("battle:rewardGainCount", { modifierName: shellBell.name, count: 2 }), null, undefined, true); + await showEncounterText( + i18next.t("battle:rewardGainCount", { + modifierName: shellBell.name, + count: 2, + }), + null, + undefined, + true, + ); } function doGarbageDig() { diff --git a/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts b/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts index 6c0219688da..ed1866c7a1b 100644 --- a/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts +++ b/src/data/mystery-encounters/encounters/uncommon-breed-encounter.ts @@ -1,6 +1,12 @@ import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { getRandomEncounterSpecies, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterExp, setEncounterRewards } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + getRandomEncounterSpecies, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterExp, + setEncounterRewards, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { CHARMING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import type Pokemon from "#app/field/pokemon"; import type { EnemyPokemon } from "#app/field/pokemon"; @@ -9,10 +15,17 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; -import { MoveRequirement, PersistentModifierRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; +import { + MoveRequirement, + PersistentModifierRequirement, +} from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { catchPokemon, getHighestLevelPlayerPokemon, getSpriteKeysFromPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + catchPokemon, + getHighestLevelPlayerPokemon, + getSpriteKeysFromPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import PokemonData from "#app/system/pokemon-data"; import { isNullOrUndefined, randSeedInt } from "#app/utils"; import type { Moves } from "#enums/moves"; @@ -34,223 +47,228 @@ const namespace = "mysteryEncounters/uncommonBreed"; * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3811 | GitHub Issue #3811} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const UncommonBreedEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.UNCOMMON_BREED) - .withEncounterTier(MysteryEncounterTier.COMMON) - .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) - .withCatchAllowed(true) - .withHideWildIntroMessage(true) - .withFleeAllowed(false) - .withIntroSpriteConfigs([]) // Set in onInit() - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - ]) - .withOnInit(() => { - const encounter = globalScene.currentBattle.mysteryEncounter!; +export const UncommonBreedEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.UNCOMMON_BREED, +) + .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES) + .withCatchAllowed(true) + .withHideWildIntroMessage(true) + .withFleeAllowed(false) + .withIntroSpriteConfigs([]) // Set in onInit() + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + ]) + .withOnInit(() => { + const encounter = globalScene.currentBattle.mysteryEncounter!; - // Calculate boss mon - // Level equal to 2 below highest party member - const level = getHighestLevelPlayerPokemon(false, true).level - 2; - const pokemon = getRandomEncounterSpecies(level, true, true); + // Calculate boss mon + // Level equal to 2 below highest party member + const level = getHighestLevelPlayerPokemon(false, true).level - 2; + const pokemon = getRandomEncounterSpecies(level, true, true); - // Pokemon will always have one of its egg moves in its moveset - const eggMoves = pokemon.getEggMoves(); - if (eggMoves) { - const eggMoveIndex = randSeedInt(4); - const randomEggMove: Moves = eggMoves[eggMoveIndex]; - encounter.misc = { - eggMove: randomEggMove, - pokemon: pokemon - }; - if (pokemon.moveset.length < 4) { - pokemon.moveset.push(new PokemonMove(randomEggMove)); - } else { - pokemon.moveset[0] = new PokemonMove(randomEggMove); - } + // Pokemon will always have one of its egg moves in its moveset + const eggMoves = pokemon.getEggMoves(); + if (eggMoves) { + const eggMoveIndex = randSeedInt(4); + const randomEggMove: Moves = eggMoves[eggMoveIndex]; + encounter.misc = { + eggMove: randomEggMove, + pokemon: pokemon, + }; + if (pokemon.moveset.length < 4) { + pokemon.moveset.push(new PokemonMove(randomEggMove)); } else { - encounter.misc.pokemon = pokemon; + pokemon.moveset[0] = new PokemonMove(randomEggMove); } + } else { + encounter.misc.pokemon = pokemon; + } - // Defense/Spd buffs below wave 50, +1 to all stats otherwise - const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = globalScene.currentBattle.waveIndex < 50 ? - [ Stat.DEF, Stat.SPDEF, Stat.SPD ] : - [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + // Defense/Spd buffs below wave 50, +1 to all stats otherwise + const statChangesForBattle: (Stat.ATK | Stat.DEF | Stat.SPATK | Stat.SPDEF | Stat.SPD | Stat.ACC | Stat.EVA)[] = + globalScene.currentBattle.waveIndex < 50 + ? [Stat.DEF, Stat.SPDEF, Stat.SPD] + : [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; - const config: EnemyPartyConfig = { - pokemonConfigs: [{ + const config: EnemyPartyConfig = { + pokemonConfigs: [ + { level: level, species: pokemon.species, dataSource: new PokemonData(pokemon), isBoss: false, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], mysteryEncounterBattleEffects: (pokemon: Pokemon) => { queueEncounterMessage(`${namespace}:option.1.stat_boost`); - globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1)); - } - }], - }; - encounter.enemyPartyConfigs = [ config ]; - - const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(pokemon); - encounter.spriteConfigs = [ - { - spriteKey: spriteKey, - fileRoot: fileRoot, - hasShadow: true, - x: -5, - repeat: true, - isPokemon: true, - isShiny: pokemon.shiny, - variant: pokemon.variant + globalScene.unshiftPhase( + new StatStageChangePhase(pokemon.getBattlerIndex(), true, statChangesForBattle, 1), + ); + }, }, - ]; + ], + }; + encounter.enemyPartyConfigs = [config]; - encounter.setDialogueToken("enemyPokemon", pokemon.getNameToRender()); - globalScene.loadSe("PRSFX- Spotlight2", "battle_anims", "PRSFX- Spotlight2.wav"); - return true; - }) - .withOnVisualsStart(() => { - // Animate the pokemon - const encounter = globalScene.currentBattle.mysteryEncounter!; - const pokemonSprite = encounter.introVisuals!.getSprites(); - - // Bounce at the end, then shiny sparkle if the Pokemon is shiny - globalScene.tweens.add({ - targets: pokemonSprite, - duration: 300, - ease: "Cubic.easeOut", - yoyo: true, - y: "-=20", - loop: 1, - onComplete: () => encounter.introVisuals?.playShinySparkles() - }); - - globalScene.time.delayedCall(500, () => globalScene.playSound("battle_anims/PRSFX- Spotlight2")); - return true; - }) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withSimpleOption( + const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(pokemon); + encounter.spriteConfigs = [ { - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, + spriteKey: spriteKey, + fileRoot: fileRoot, + hasShadow: true, + x: -5, + repeat: true, + isPokemon: true, + isShiny: pokemon.shiny, + variant: pokemon.variant, + }, + ]; + + encounter.setDialogueToken("enemyPokemon", pokemon.getNameToRender()); + globalScene.loadSe("PRSFX- Spotlight2", "battle_anims", "PRSFX- Spotlight2.wav"); + return true; + }) + .withOnVisualsStart(() => { + // Animate the pokemon + const encounter = globalScene.currentBattle.mysteryEncounter!; + const pokemonSprite = encounter.introVisuals!.getSprites(); + + // Bounce at the end, then shiny sparkle if the Pokemon is shiny + globalScene.tweens.add({ + targets: pokemonSprite, + duration: 300, + ease: "Cubic.easeOut", + yoyo: true, + y: "-=20", + loop: 1, + onComplete: () => encounter.introVisuals?.playShinySparkles(), + }); + + globalScene.time.delayedCall(500, () => globalScene.playSound("battle_anims/PRSFX- Spotlight2")); + return true; + }) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }, + async () => { + // Pick battle + const encounter = globalScene.currentBattle.mysteryEncounter!; + + const eggMove = encounter.misc.eggMove; + if (!isNullOrUndefined(eggMove)) { + // Check what type of move the egg move is to determine target + const pokemonMove = new PokemonMove(eggMove); + const move = pokemonMove.getMove(); + const target = move instanceof SelfStatusMove ? BattlerIndex.ENEMY : BattlerIndex.PLAYER; + + encounter.startOfBattleEffects.push({ + sourceBattlerIndex: BattlerIndex.ENEMY, + targets: [target], + move: pokemonMove, + ignorePp: true, + }); + } + + setEncounterRewards({ fillRemaining: true }); + await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); + }, + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withSceneRequirement(new PersistentModifierRequirement("BerryModifier", 4)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically + .withDialogue({ + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, selected: [ { - text: `${namespace}:option.1.selected`, + text: `${namespace}:option.2.selected`, }, ], - }, - async () => { - // Pick battle - const encounter = globalScene.currentBattle.mysteryEncounter!; + }) + .withOptionPhase(async () => { + // Give it some food - const eggMove = encounter.misc.eggMove; - if (!isNullOrUndefined(eggMove)) { - // Check what type of move the egg move is to determine target - const pokemonMove = new PokemonMove(eggMove); - const move = pokemonMove.getMove(); - const target = move instanceof SelfStatusMove ? BattlerIndex.ENEMY : BattlerIndex.PLAYER; - - encounter.startOfBattleEffects.push( - { - sourceBattlerIndex: BattlerIndex.ENEMY, - targets: [ target ], - move: pokemonMove, - ignorePp: true - }); + // Remove 4 random berries from player's party + // Get all player berry items, remove from party, and store reference + const berryItems: BerryModifier[] = globalScene.findModifiers( + m => m instanceof BerryModifier, + ) as BerryModifier[]; + for (let i = 0; i < 4; i++) { + const index = randSeedInt(berryItems.length); + const randBerry = berryItems[index]; + randBerry.stackCount--; + if (randBerry.stackCount === 0) { + globalScene.removeModifier(randBerry); + berryItems.splice(index, 1); + } } + await globalScene.updateModifiers(true, true); + // Pokemon joins the team, with 2 egg moves + const encounter = globalScene.currentBattle.mysteryEncounter!; + const pokemon = encounter.misc.pokemon; + + // Give 1 additional egg move + givePokemonExtraEggMove(pokemon, encounter.misc.eggMove); + + await catchPokemon(pokemon, null, PokeballType.POKEBALL, false); setEncounterRewards({ fillRemaining: true }); - await initBattleWithEnemyConfig(encounter.enemyPartyConfigs[0]); - } - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withSceneRequirement(new PersistentModifierRequirement("BerryModifier", 4)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically - .withDialogue({ - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected` - } - ] - }) - .withOptionPhase(async () => { - // Give it some food + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + .withPrimaryPokemonRequirement(new MoveRequirement(CHARMING_MOVES, true)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically + .withDialogue({ + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }) + .withOptionPhase(async () => { + // Attract the pokemon with a move + // Pokemon joins the team, with 2 egg moves and IVs rolled an additional time + const encounter = globalScene.currentBattle.mysteryEncounter!; + const pokemon = encounter.misc.pokemon; - // Remove 4 random berries from player's party - // Get all player berry items, remove from party, and store reference - const berryItems: BerryModifier[] = globalScene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; - for (let i = 0; i < 4; i++) { - const index = randSeedInt(berryItems.length); - const randBerry = berryItems[index]; - randBerry.stackCount--; - if (randBerry.stackCount === 0) { - globalScene.removeModifier(randBerry); - berryItems.splice(index, 1); - } - } - await globalScene.updateModifiers(true, true); + // Give 1 additional egg move + givePokemonExtraEggMove(pokemon, encounter.misc.eggMove); - // Pokemon joins the team, with 2 egg moves - const encounter = globalScene.currentBattle.mysteryEncounter!; - const pokemon = encounter.misc.pokemon; + // Roll IVs a second time + pokemon.ivs = pokemon.ivs.map(iv => { + const newValue = randSeedInt(31); + return newValue > iv ? newValue : iv; + }); - // Give 1 additional egg move - givePokemonExtraEggMove(pokemon, encounter.misc.eggMove); - - await catchPokemon(pokemon, null, PokeballType.POKEBALL, false); - setEncounterRewards({ fillRemaining: true }); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) - .withPrimaryPokemonRequirement(new MoveRequirement(CHARMING_MOVES, true)) // Will set option2PrimaryName and option2PrimaryMove dialogue tokens automatically - .withDialogue({ - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected` - } - ] - }) - .withOptionPhase(async () => { - // Attract the pokemon with a move - // Pokemon joins the team, with 2 egg moves and IVs rolled an additional time - const encounter = globalScene.currentBattle.mysteryEncounter!; - const pokemon = encounter.misc.pokemon; - - // Give 1 additional egg move - givePokemonExtraEggMove(pokemon, encounter.misc.eggMove); - - // Roll IVs a second time - pokemon.ivs = pokemon.ivs.map(iv => { - const newValue = randSeedInt(31); - return newValue > iv ? newValue : iv; - }); - - await catchPokemon(pokemon, null, PokeballType.POKEBALL, false); - if (encounter.selectedOption?.primaryPokemon?.id) { - setEncounterExp(encounter.selectedOption.primaryPokemon.id, pokemon.getExpValue(), false); - } - setEncounterRewards({ fillRemaining: true }); - leaveEncounterWithoutBattle(); - }) - .build() - ) - .build(); + await catchPokemon(pokemon, null, PokeballType.POKEBALL, false); + if (encounter.selectedOption?.primaryPokemon?.id) { + setEncounterExp(encounter.selectedOption.primaryPokemon.id, pokemon.getExpValue(), false); + } + setEncounterRewards({ fillRemaining: true }); + leaveEncounterWithoutBattle(); + }) + .build(), + ) + .build(); function givePokemonExtraEggMove(pokemon: EnemyPokemon, previousEggMove: Moves) { const eggMoves = pokemon.getEggMoves(); diff --git a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts index 4f9338ac5cc..758e3fabd76 100644 --- a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts +++ b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts @@ -6,7 +6,12 @@ import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounte import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import type { EnemyPartyConfig, EnemyPokemonConfig } from "../utils/encounter-phase-utils"; -import { generateModifierType, initBattleWithEnemyConfig, leaveEncounterWithoutBattle, setEncounterRewards, } from "../utils/encounter-phase-utils"; +import { + generateModifierType, + initBattleWithEnemyConfig, + leaveEncounterWithoutBattle, + setEncounterRewards, +} from "../utils/encounter-phase-utils"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import type { PlayerPokemon } from "#app/field/pokemon"; @@ -23,7 +28,10 @@ import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter- import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; import i18next from "#app/plugins/i18n"; -import { doPokemonTransformationSequence, TransformationScreenPosition } from "#app/data/mystery-encounters/utils/encounter-transformation-sequence"; +import { + doPokemonTransformationSequence, + TransformationScreenPosition, +} from "#app/data/mystery-encounters/utils/encounter-transformation-sequence"; import { getLevelTotalExp } from "#app/data/exp"; import { Stat } from "#enums/stat"; import { Challenges } from "#enums/challenges"; @@ -104,230 +112,260 @@ const PERCENT_LEVEL_LOSS_ON_REFUSE = 10; * Value ranges of the resulting species BST transformations after adding values to original species * 2 Pokemon in the party use this range */ -const HIGH_BST_TRANSFORM_BASE_VALUES: [number, number] = [ 90, 110 ]; +const HIGH_BST_TRANSFORM_BASE_VALUES: [number, number] = [90, 110]; /** * Value ranges of the resulting species BST transformations after adding values to original species * All remaining Pokemon in the party use this range */ -const STANDARD_BST_TRANSFORM_BASE_VALUES: [number, number] = [ 40, 50 ]; +const STANDARD_BST_TRANSFORM_BASE_VALUES: [number, number] = [40, 50]; /** * Weird Dream encounter. * @see {@link https://github.com/pagefaultgames/pokerogue/issues/3822 | GitHub Issue #3822} * @see For biome requirements check {@linkcode mysteryEncountersByBiome} */ -export const WeirdDreamEncounter: MysteryEncounter = - MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.WEIRD_DREAM) - .withEncounterTier(MysteryEncounterTier.ROGUE) - .withDisallowedChallenges(Challenges.SINGLE_TYPE, Challenges.SINGLE_GENERATION) - // TODO: should reset minimum wave to 10 when there are more Rogue tiers in pool. Matching Dark Deal minimum for now. - .withSceneWaveRangeRequirement(30, 140) - .withIntroSpriteConfigs([ - { - spriteKey: "weird_dream_woman", - fileRoot: "mystery-encounters", - hasShadow: true, - y: 11, - yShadow: 6, - x: 4 - }, - ]) - .withIntroDialogue([ - { - text: `${namespace}:intro`, - }, - { - speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue`, - }, - ]) - .setLocalizationKey(`${namespace}`) - .withTitle(`${namespace}:title`) - .withDescription(`${namespace}:description`) - .withQuery(`${namespace}:query`) - .withOnInit(() => { - globalScene.loadBgm("mystery_encounter_weird_dream", "mystery_encounter_weird_dream.mp3"); +export const WeirdDreamEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType( + MysteryEncounterType.WEIRD_DREAM, +) + .withEncounterTier(MysteryEncounterTier.ROGUE) + .withDisallowedChallenges(Challenges.SINGLE_TYPE, Challenges.SINGLE_GENERATION) + // TODO: should reset minimum wave to 10 when there are more Rogue tiers in pool. Matching Dark Deal minimum for now. + .withSceneWaveRangeRequirement(30, 140) + .withIntroSpriteConfigs([ + { + spriteKey: "weird_dream_woman", + fileRoot: "mystery-encounters", + hasShadow: true, + y: 11, + yShadow: 6, + x: 4, + }, + ]) + .withIntroDialogue([ + { + text: `${namespace}:intro`, + }, + { + speaker: `${namespace}:speaker`, + text: `${namespace}:intro_dialogue`, + }, + ]) + .setLocalizationKey(`${namespace}`) + .withTitle(`${namespace}:title`) + .withDescription(`${namespace}:description`) + .withQuery(`${namespace}:query`) + .withOnInit(() => { + globalScene.loadBgm("mystery_encounter_weird_dream", "mystery_encounter_weird_dream.mp3"); - // Calculate all the newly transformed Pokemon and begin asset load - const teamTransformations = getTeamTransformations(); - const loadAssets = teamTransformations.map(t => (t.newPokemon as PlayerPokemon).loadAssets()); - globalScene.currentBattle.mysteryEncounter!.misc = { - teamTransformations, - loadAssets + // Calculate all the newly transformed Pokemon and begin asset load + const teamTransformations = getTeamTransformations(); + const loadAssets = teamTransformations.map(t => (t.newPokemon as PlayerPokemon).loadAssets()); + globalScene.currentBattle.mysteryEncounter!.misc = { + teamTransformations, + loadAssets, + }; + + return true; + }) + .withOnVisualsStart(() => { + globalScene.fadeAndSwitchBgm("mystery_encounter_weird_dream"); + return true; + }) + .withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue({ + buttonLabel: `${namespace}:option.1.label`, + buttonTooltip: `${namespace}:option.1.tooltip`, + selected: [ + { + text: `${namespace}:option.1.selected`, + }, + ], + }) + .withPreOptionPhase(async () => { + // Play the animation as the player goes through the dialogue + globalScene.time.delayedCall(1000, () => { + doShowDreamBackground(); + }); + + for (const transformation of globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations) { + globalScene.removePokemonFromPlayerParty(transformation.previousPokemon, false); + globalScene.getPlayerParty().push(transformation.newPokemon); + } + }) + .withOptionPhase(async () => { + // Starts cutscene dialogue, but does not await so that cutscene plays as player goes through dialogue + const cutsceneDialoguePromise = showEncounterText(`${namespace}:option.1.cutscene`); + + // Change the entire player's party + // Wait for all new Pokemon assets to be loaded before showing transformation animations + await Promise.all(globalScene.currentBattle.mysteryEncounter!.misc.loadAssets); + const transformations = globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations; + + // If there are 1-3 transformations, do them centered back to back + // Otherwise, the first 3 transformations are executed side-by-side, then any remaining 1-3 transformations occur in those same respective positions + if (transformations.length <= 3) { + for (const transformation of transformations) { + const pokemon1 = transformation.previousPokemon; + const pokemon2 = transformation.newPokemon; + + await doPokemonTransformationSequence(pokemon1, pokemon2, TransformationScreenPosition.CENTER); + } + } else { + await doSideBySideTransformations(transformations); + } + + // Make sure player has finished cutscene dialogue + await cutsceneDialoguePromise; + + doHideDreamBackground(); + await showEncounterText(`${namespace}:option.1.dream_complete`); + + await doNewTeamPostProcess(transformations); + setEncounterRewards({ + guaranteedModifierTypeFuncs: [ + modifierTypes.MEMORY_MUSHROOM, + modifierTypes.ROGUE_BALL, + modifierTypes.MINT, + modifierTypes.MINT, + modifierTypes.MINT, + ], + fillRemaining: false, + }); + leaveEncounterWithoutBattle(true); + }) + .build(), + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.2.label`, + buttonTooltip: `${namespace}:option.2.tooltip`, + selected: [ + { + text: `${namespace}:option.2.selected`, + }, + ], + }, + async () => { + // Battle your "future" team for some item rewards + const transformations: PokemonTransformation[] = + globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations; + + // Uses the pokemon that player's party would have transformed into + const enemyPokemonConfigs: EnemyPokemonConfig[] = []; + for (const transformation of transformations) { + const newPokemon = transformation.newPokemon; + const previousPokemon = transformation.previousPokemon; + + await postProcessTransformedPokemon(previousPokemon, newPokemon, newPokemon.species.getRootSpeciesId(), true); + + const dataSource = new PokemonData(newPokemon); + dataSource.player = false; + + // Copy held items to new pokemon + const newPokemonHeldItemConfigs: HeldModifierConfig[] = []; + for (const item of transformation.heldItems) { + newPokemonHeldItemConfigs.push({ + modifier: item.clone() as PokemonHeldItemModifier, + stackCount: item.getStackCount(), + isTransferable: false, + }); + } + // Any pokemon that is below 570 BST gets +20 permanent BST to 3 stats + if (shouldGetOldGateau(newPokemon)) { + const stats = getOldGateauBoostedStats(newPokemon); + newPokemonHeldItemConfigs.push({ + modifier: generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU, [ + OLD_GATEAU_STATS_UP, + stats, + ]) as PokemonHeldItemModifierType, + stackCount: 1, + isTransferable: false, + }); + } + + const enemyConfig: EnemyPokemonConfig = { + species: transformation.newSpecies, + isBoss: newPokemon.getSpeciesForm().getBaseStatTotal() > NON_LEGENDARY_BST_THRESHOLD, + level: previousPokemon.level, + dataSource: dataSource, + modifierConfigs: newPokemonHeldItemConfigs, + }; + + enemyPokemonConfigs.push(enemyConfig); + } + + const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; + const trainerConfig = + trainerConfigs[ + genderIndex === PlayerGender.FEMALE ? TrainerType.FUTURE_SELF_F : TrainerType.FUTURE_SELF_M + ].clone(); + trainerConfig.setPartyTemplates(new TrainerPartyTemplate(transformations.length, PartyMemberStrength.STRONG)); + const enemyPartyConfig: EnemyPartyConfig = { + trainerConfig: trainerConfig, + pokemonConfigs: enemyPokemonConfigs, + female: genderIndex === PlayerGender.FEMALE, }; - return true; - }) - .withOnVisualsStart(() => { - globalScene.fadeAndSwitchBgm("mystery_encounter_weird_dream"); - return true; - }) - .withOption( - MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue({ - buttonLabel: `${namespace}:option.1.label`, - buttonTooltip: `${namespace}:option.1.tooltip`, - selected: [ - { - text: `${namespace}:option.1.selected`, - } + const onBeforeRewards = () => { + // Before battle rewards, unlock the passive on a pokemon in the player's team for the rest of the run (not permanently) + // One random pokemon will get its passive unlocked + const passiveDisabledPokemon = globalScene.getPlayerParty().filter(p => !p.passive); + if (passiveDisabledPokemon?.length > 0) { + const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)]; + enablePassiveMon.passive = true; + enablePassiveMon.updateInfo(true); + } + }; + + setEncounterRewards( + { + guaranteedModifierTiers: [ + ModifierTier.ROGUE, + ModifierTier.ROGUE, + ModifierTier.ULTRA, + ModifierTier.ULTRA, + ModifierTier.GREAT, + ModifierTier.GREAT, ], - }) - .withPreOptionPhase(async () => { - // Play the animation as the player goes through the dialogue - globalScene.time.delayedCall(1000, () => { - doShowDreamBackground(); - }); + fillRemaining: false, + }, + undefined, + onBeforeRewards, + ); - for (const transformation of globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations) { - globalScene.removePokemonFromPlayerParty(transformation.previousPokemon, false); - globalScene.getPlayerParty().push(transformation.newPokemon); - } - }) - .withOptionPhase(async () => { - // Starts cutscene dialogue, but does not await so that cutscene plays as player goes through dialogue - const cutsceneDialoguePromise = showEncounterText(`${namespace}:option.1.cutscene`); + await showEncounterText(`${namespace}:option.2.selected_2`, null, undefined, true); + await initBattleWithEnemyConfig(enemyPartyConfig); + }, + ) + .withSimpleOption( + { + buttonLabel: `${namespace}:option.3.label`, + buttonTooltip: `${namespace}:option.3.tooltip`, + selected: [ + { + text: `${namespace}:option.3.selected`, + }, + ], + }, + async () => { + // Leave, reduce party levels by 10% + for (const pokemon of globalScene.getPlayerParty()) { + pokemon.level = Math.max(Math.ceil(((100 - PERCENT_LEVEL_LOSS_ON_REFUSE) / 100) * pokemon.level), 1); + pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate); + pokemon.levelExp = 0; - // Change the entire player's party - // Wait for all new Pokemon assets to be loaded before showing transformation animations - await Promise.all(globalScene.currentBattle.mysteryEncounter!.misc.loadAssets); - const transformations = globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations; - - // If there are 1-3 transformations, do them centered back to back - // Otherwise, the first 3 transformations are executed side-by-side, then any remaining 1-3 transformations occur in those same respective positions - if (transformations.length <= 3) { - for (const transformation of transformations) { - const pokemon1 = transformation.previousPokemon; - const pokemon2 = transformation.newPokemon; - - await doPokemonTransformationSequence(pokemon1, pokemon2, TransformationScreenPosition.CENTER); - } - } else { - await doSideBySideTransformations(transformations); - } - - // Make sure player has finished cutscene dialogue - await cutsceneDialoguePromise; - - doHideDreamBackground(); - await showEncounterText(`${namespace}:option.1.dream_complete`); - - await doNewTeamPostProcess(transformations); - setEncounterRewards({ guaranteedModifierTypeFuncs: [ modifierTypes.MEMORY_MUSHROOM, modifierTypes.ROGUE_BALL, modifierTypes.MINT, modifierTypes.MINT, modifierTypes.MINT ], fillRemaining: false }); - leaveEncounterWithoutBattle(true); - }) - .build() - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip`, - selected: [ - { - text: `${namespace}:option.2.selected`, - }, - ], - }, - async () => { - // Battle your "future" team for some item rewards - const transformations: PokemonTransformation[] = globalScene.currentBattle.mysteryEncounter!.misc.teamTransformations; - - // Uses the pokemon that player's party would have transformed into - const enemyPokemonConfigs: EnemyPokemonConfig[] = []; - for (const transformation of transformations) { - const newPokemon = transformation.newPokemon; - const previousPokemon = transformation.previousPokemon; - - await postProcessTransformedPokemon(previousPokemon, newPokemon, newPokemon.species.getRootSpeciesId(), true); - - const dataSource = new PokemonData(newPokemon); - dataSource.player = false; - - // Copy held items to new pokemon - const newPokemonHeldItemConfigs: HeldModifierConfig[] = []; - for (const item of transformation.heldItems) { - newPokemonHeldItemConfigs.push({ - modifier: item.clone() as PokemonHeldItemModifier, - stackCount: item.getStackCount(), - isTransferable: false - }); - } - // Any pokemon that is below 570 BST gets +20 permanent BST to 3 stats - if (shouldGetOldGateau(newPokemon)) { - const stats = getOldGateauBoostedStats(newPokemon); - newPokemonHeldItemConfigs.push({ - modifier: generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU, [ OLD_GATEAU_STATS_UP, stats ]) as PokemonHeldItemModifierType, - stackCount: 1, - isTransferable: false - }); - } - - const enemyConfig: EnemyPokemonConfig = { - species: transformation.newSpecies, - isBoss: newPokemon.getSpeciesForm().getBaseStatTotal() > NON_LEGENDARY_BST_THRESHOLD, - level: previousPokemon.level, - dataSource: dataSource, - modifierConfigs: newPokemonHeldItemConfigs - }; - - enemyPokemonConfigs.push(enemyConfig); - } - - const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; - const trainerConfig = trainerConfigs[genderIndex === PlayerGender.FEMALE ? TrainerType.FUTURE_SELF_F : TrainerType.FUTURE_SELF_M].clone(); - trainerConfig.setPartyTemplates(new TrainerPartyTemplate(transformations.length, PartyMemberStrength.STRONG)); - const enemyPartyConfig: EnemyPartyConfig = { - trainerConfig: trainerConfig, - pokemonConfigs: enemyPokemonConfigs, - female: genderIndex === PlayerGender.FEMALE - }; - - const onBeforeRewards = () => { - // Before battle rewards, unlock the passive on a pokemon in the player's team for the rest of the run (not permanently) - // One random pokemon will get its passive unlocked - const passiveDisabledPokemon = globalScene.getPlayerParty().filter(p => !p.passive); - if (passiveDisabledPokemon?.length > 0) { - const enablePassiveMon = passiveDisabledPokemon[randSeedInt(passiveDisabledPokemon.length)]; - enablePassiveMon.passive = true; - enablePassiveMon.updateInfo(true); - } - }; - - setEncounterRewards({ guaranteedModifierTiers: [ ModifierTier.ROGUE, ModifierTier.ROGUE, ModifierTier.ULTRA, ModifierTier.ULTRA, ModifierTier.GREAT, ModifierTier.GREAT ], fillRemaining: false }, undefined, onBeforeRewards); - - await showEncounterText(`${namespace}:option.2.selected_2`, null, undefined, true); - await initBattleWithEnemyConfig(enemyPartyConfig); + pokemon.calculateStats(); + pokemon.getBattleInfo().setLevel(pokemon.level); + await pokemon.updateInfo(); } - ) - .withSimpleOption( - { - buttonLabel: `${namespace}:option.3.label`, - buttonTooltip: `${namespace}:option.3.tooltip`, - selected: [ - { - text: `${namespace}:option.3.selected`, - }, - ], - }, - async () => { - // Leave, reduce party levels by 10% - for (const pokemon of globalScene.getPlayerParty()) { - pokemon.level = Math.max(Math.ceil((100 - PERCENT_LEVEL_LOSS_ON_REFUSE) / 100 * pokemon.level), 1); - pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate); - pokemon.levelExp = 0; - pokemon.calculateStats(); - pokemon.getBattleInfo().setLevel(pokemon.level); - await pokemon.updateInfo(); - } - - leaveEncounterWithoutBattle(true); - return true; - } - ) - .build(); + leaveEncounterWithoutBattle(true); + return true; + }, + ) + .build(); interface PokemonTransformation { previousPokemon: PlayerPokemon; @@ -342,7 +380,7 @@ function getTeamTransformations(): PokemonTransformation[] { const alreadyUsedSpecies: PokemonSpecies[] = party.map(p => p.species); const pokemonTransformations: PokemonTransformation[] = party.map(p => { return { - previousPokemon: p + previousPokemon: p, } as PokemonTransformation; }); @@ -358,7 +396,9 @@ function getTeamTransformations(): PokemonTransformation[] { for (let i = 0; i < numPokemon; i++) { const removed = removedPokemon[i]; const index = pokemonTransformations.findIndex(p => p.previousPokemon.id === removed.id); - pokemonTransformations[index].heldItems = removed.getHeldItems().filter(m => !(m instanceof PokemonFormChangeItemModifier)); + pokemonTransformations[index].heldItems = removed + .getHeldItems() + .filter(m => !(m instanceof PokemonFormChangeItemModifier)); const bst = removed.getSpeciesForm().getBaseStatTotal(); let newBstRange: [number, number]; @@ -368,7 +408,13 @@ function getTeamTransformations(): PokemonTransformation[] { newBstRange = STANDARD_BST_TRANSFORM_BASE_VALUES; } - const newSpecies = getTransformedSpecies(bst, newBstRange, hasPokemonInSuperLegendaryBstThreshold, hasPokemonInLegendaryBstThreshold, alreadyUsedSpecies); + const newSpecies = getTransformedSpecies( + bst, + newBstRange, + hasPokemonInSuperLegendaryBstThreshold, + hasPokemonInLegendaryBstThreshold, + alreadyUsedSpecies, + ); const newSpeciesBst = newSpecies.getBaseStatTotal(); if (newSpeciesBst > SUPER_LEGENDARY_BST_THRESHOLD) { @@ -378,7 +424,6 @@ function getTeamTransformations(): PokemonTransformation[] { hasPokemonInLegendaryBstThreshold = true; } - pokemonTransformations[index].newSpecies = newSpecies; console.log("New species: " + JSON.stringify(newSpecies)); alreadyUsedSpecies.push(newSpecies); @@ -386,7 +431,12 @@ function getTeamTransformations(): PokemonTransformation[] { for (const transformation of pokemonTransformations) { const newAbilityIndex = randSeedInt(transformation.newSpecies.getAbilityCount()); - transformation.newPokemon = globalScene.addPlayerPokemon(transformation.newSpecies, transformation.previousPokemon.level, newAbilityIndex, undefined); + transformation.newPokemon = globalScene.addPlayerPokemon( + transformation.newSpecies, + transformation.previousPokemon.level, + newAbilityIndex, + undefined, + ); } return pokemonTransformations; @@ -411,8 +461,9 @@ async function doNewTeamPostProcess(transformations: PokemonTransformation[]) { // Any pokemon that is below 570 BST gets +20 permanent BST to 3 stats if (shouldGetOldGateau(newPokemon)) { const stats = getOldGateauBoostedStats(newPokemon); - const modType = modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU() - .generateType(globalScene.getPlayerParty(), [ OLD_GATEAU_STATS_UP, stats ]) + const modType = modifierTypes + .MYSTERY_ENCOUNTER_OLD_GATEAU() + .generateType(globalScene.getPlayerParty(), [OLD_GATEAU_STATS_UP, stats]) ?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU); const modifier = modType?.newModifier(newPokemon); if (modifier) { @@ -446,7 +497,12 @@ async function doNewTeamPostProcess(transformations: PokemonTransformation[]) { * @param speciesRootForm * @param forBattle Default `false`. If false, will perform achievements and dex unlocks for the player. */ -async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, newPokemon: PlayerPokemon, speciesRootForm: Species, forBattle: boolean = false): Promise { +async function postProcessTransformedPokemon( + previousPokemon: PlayerPokemon, + newPokemon: PlayerPokemon, + speciesRootForm: Species, + forBattle = false, +): Promise { let isNewStarter = false; // Roll HA a second time if (newPokemon.species.abilityHidden) { @@ -470,11 +526,17 @@ async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, new }); // Roll a neutral nature - newPokemon.nature = [ Nature.HARDY, Nature.DOCILE, Nature.BASHFUL, Nature.QUIRKY, Nature.SERIOUS ][randSeedInt(5)]; + newPokemon.nature = [Nature.HARDY, Nature.DOCILE, Nature.BASHFUL, Nature.QUIRKY, Nature.SERIOUS][randSeedInt(5)]; // For pokemon at/below 570 BST or any shiny pokemon, unlock it permanently as if you had caught it - if (!forBattle && (newPokemon.getSpeciesForm().getBaseStatTotal() <= NON_LEGENDARY_BST_THRESHOLD || newPokemon.isShiny())) { - if (newPokemon.getSpeciesForm().abilityHidden && newPokemon.abilityIndex === newPokemon.getSpeciesForm().getAbilityCount() - 1) { + if ( + !forBattle && + (newPokemon.getSpeciesForm().getBaseStatTotal() <= NON_LEGENDARY_BST_THRESHOLD || newPokemon.isShiny()) + ) { + if ( + newPokemon.getSpeciesForm().abilityHidden && + newPokemon.abilityIndex === newPokemon.getSpeciesForm().getAbilityCount() - 1 + ) { globalScene.validateAchv(achvs.HIDDEN_ABILITY); } @@ -494,7 +556,11 @@ async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, new const newStarterUnlocked = await globalScene.gameData.setPokemonCaught(newPokemon, true, false, false); if (newStarterUnlocked) { isNewStarter = true; - await showEncounterText(i18next.t("battle:addedAsAStarter", { pokemonName: getPokemonSpecies(speciesRootForm).getName() })); + await showEncounterText( + i18next.t("battle:addedAsAStarter", { + pokemonName: getPokemonSpecies(speciesRootForm).getName(), + }), + ); } } @@ -528,7 +594,7 @@ async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, new // Randomize the second type of the pokemon // If the pokemon does not normally have a second type, it will gain 1 - const newTypes = [ PokemonType.UNKNOWN ]; + const newTypes = [PokemonType.UNKNOWN]; let newType = randSeedInt(18) as PokemonType; while (newType === newTypes[0]) { newType = randSeedInt(18) as PokemonType; @@ -568,23 +634,30 @@ function getOldGateauBoostedStats(pokemon: Pokemon): Stat[] { return stats; } - -function getTransformedSpecies(originalBst: number, bstSearchRange: [number, number], hasPokemonBstHigherThan600: boolean, hasPokemonBstBetween570And600: boolean, alreadyUsedSpecies: PokemonSpecies[]): PokemonSpecies { +function getTransformedSpecies( + originalBst: number, + bstSearchRange: [number, number], + hasPokemonBstHigherThan600: boolean, + hasPokemonBstBetween570And600: boolean, + alreadyUsedSpecies: PokemonSpecies[], +): PokemonSpecies { let newSpecies: PokemonSpecies | undefined; while (isNullOrUndefined(newSpecies)) { const bstCap = originalBst + bstSearchRange[1]; const bstMin = Math.max(originalBst + bstSearchRange[0], 0); // Get any/all species that fall within the Bst range requirements - let validSpecies = allSpecies - .filter(s => { - const speciesBst = s.getBaseStatTotal(); - const bstInRange = speciesBst >= bstMin && speciesBst <= bstCap; - // Checks that a Pokemon has not already been added in the +600 or 570-600 slots; - const validBst = (!hasPokemonBstBetween570And600 || (speciesBst < NON_LEGENDARY_BST_THRESHOLD || speciesBst > SUPER_LEGENDARY_BST_THRESHOLD)) && - (!hasPokemonBstHigherThan600 || speciesBst <= SUPER_LEGENDARY_BST_THRESHOLD); - return bstInRange && validBst && !EXCLUDED_TRANSFORMATION_SPECIES.includes(s.speciesId); - }); + let validSpecies = allSpecies.filter(s => { + const speciesBst = s.getBaseStatTotal(); + const bstInRange = speciesBst >= bstMin && speciesBst <= bstCap; + // Checks that a Pokemon has not already been added in the +600 or 570-600 slots; + const validBst = + (!hasPokemonBstBetween570And600 || + speciesBst < NON_LEGENDARY_BST_THRESHOLD || + speciesBst > SUPER_LEGENDARY_BST_THRESHOLD) && + (!hasPokemonBstHigherThan600 || speciesBst <= SUPER_LEGENDARY_BST_THRESHOLD); + return bstInRange && validBst && !EXCLUDED_TRANSFORMATION_SPECIES.includes(s.speciesId); + }); // There must be at least 20 species available before it will choose one if (validSpecies?.length > 20) { @@ -608,7 +681,13 @@ function doShowDreamBackground() { transformationContainer.name = "Dream Background"; // In case it takes a bit for video to load - const transformationStaticBg = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0); + const transformationStaticBg = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0, + ); transformationStaticBg.setName("Black Background"); transformationStaticBg.setOrigin(0, 0); transformationContainer.add(transformationStaticBg); @@ -631,7 +710,7 @@ function doShowDreamBackground() { targets: transformationContainer, alpha: 1, duration: 3000, - ease: "Sine.easeInOut" + ease: "Sine.easeInOut", }); } @@ -645,7 +724,7 @@ function doHideDreamBackground() { ease: "Sine.easeInOut", onComplete: () => { globalScene.fieldUI.remove(transformationContainer, true); - } + }, }); } @@ -660,16 +739,15 @@ function doSideBySideTransformations(transformations: PokemonTransformation[]) { const pokemon2 = transformation.newPokemon; const screenPosition = i as TransformationScreenPosition; - const transformationPromise = doPokemonTransformationSequence(pokemon1, pokemon2, screenPosition) - .then(() => { - if (transformations.length > i + 3) { - const nextTransformationAtPosition = transformations[i + 3]; - const nextPokemon1 = nextTransformationAtPosition.previousPokemon; - const nextPokemon2 = nextTransformationAtPosition.newPokemon; + const transformationPromise = doPokemonTransformationSequence(pokemon1, pokemon2, screenPosition).then(() => { + if (transformations.length > i + 3) { + const nextTransformationAtPosition = transformations[i + 3]; + const nextPokemon1 = nextTransformationAtPosition.previousPokemon; + const nextPokemon2 = nextTransformationAtPosition.newPokemon; - allTransformationPromises.push(doPokemonTransformationSequence(nextPokemon1, nextPokemon2, screenPosition)); - } - }); + allTransformationPromises.push(doPokemonTransformationSequence(nextPokemon1, nextPokemon2, screenPosition)); + } + }); allTransformationPromises.push(transformationPromise); }); } @@ -691,11 +769,15 @@ function doSideBySideTransformations(transformations: PokemonTransformation[]) { * @param newPokemon * @param speciesRootForm */ -async function addEggMoveToNewPokemonMoveset(newPokemon: PlayerPokemon, speciesRootForm: Species, forBattle: boolean = false): Promise { +async function addEggMoveToNewPokemonMoveset( + newPokemon: PlayerPokemon, + speciesRootForm: Species, + forBattle = false, +): Promise { let eggMoveIndex: null | number = null; const eggMoves = newPokemon.getEggMoves()?.slice(0); if (eggMoves) { - const eggMoveIndices = randSeedShuffle([ 0, 1, 2, 3 ]); + const eggMoveIndices = randSeedShuffle([0, 1, 2, 3]); let randomEggMoveIndex = eggMoveIndices.pop(); let randomEggMove = !isNullOrUndefined(randomEggMoveIndex) ? eggMoves[randomEggMoveIndex] : null; let retries = 0; @@ -717,7 +799,11 @@ async function addEggMoveToNewPokemonMoveset(newPokemon: PlayerPokemon, speciesR } // For pokemon that the player owns (including ones just caught), unlock the egg move - if (!forBattle && !isNullOrUndefined(randomEggMoveIndex) && !!globalScene.gameData.dexData[speciesRootForm].caughtAttr) { + if ( + !forBattle && + !isNullOrUndefined(randomEggMoveIndex) && + !!globalScene.gameData.dexData[speciesRootForm].caughtAttr + ) { await globalScene.gameData.setEggMoveUnlocked(getPokemonSpecies(speciesRootForm), randomEggMoveIndex, true); } } @@ -732,11 +818,18 @@ async function addEggMoveToNewPokemonMoveset(newPokemon: PlayerPokemon, speciesR * @param newPokemonGeneratedMoveset * @param newEggMoveIndex */ -function addFavoredMoveToNewPokemonMoveset(newPokemon: PlayerPokemon, newPokemonGeneratedMoveset: (PokemonMove | null)[], newEggMoveIndex: number | null) { +function addFavoredMoveToNewPokemonMoveset( + newPokemon: PlayerPokemon, + newPokemonGeneratedMoveset: (PokemonMove | null)[], + newEggMoveIndex: number | null, +) { let favoredMove: PokemonMove | null = null; for (const move of newPokemonGeneratedMoveset) { // Needs to match first type, second type will be replaced - if (move?.getMove().type === newPokemon.getTypes()[0] && !newPokemon.moveset.some(m => m?.moveId === move?.moveId)) { + if ( + move?.getMove().type === newPokemon.getTypes()[0] && + !newPokemon.moveset.some(m => m?.moveId === move?.moveId) + ) { favoredMove = move; break; } diff --git a/src/data/mystery-encounters/mystery-encounter-dialogue.ts b/src/data/mystery-encounters/mystery-encounter-dialogue.ts index 39db3d58690..71e1b382f61 100644 --- a/src/data/mystery-encounters/mystery-encounter-dialogue.ts +++ b/src/data/mystery-encounters/mystery-encounter-dialogue.ts @@ -72,4 +72,3 @@ export default class MysteryEncounterDialogue { encounterOptionsDialogue?: EncounterOptionsDialogue; outro?: TextDisplay[]; } - diff --git a/src/data/mystery-encounters/mystery-encounter-option.ts b/src/data/mystery-encounters/mystery-encounter-option.ts index ce9d4839c49..f360658c2dc 100644 --- a/src/data/mystery-encounters/mystery-encounter-option.ts +++ b/src/data/mystery-encounters/mystery-encounter-option.ts @@ -4,13 +4,18 @@ import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { globalScene } from "#app/global-scene"; import type { PokemonType } from "#enums/pokemon-type"; -import { EncounterPokemonRequirement, EncounterSceneRequirement, MoneyRequirement, TypeRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; +import { + EncounterPokemonRequirement, + EncounterSceneRequirement, + MoneyRequirement, + TypeRequirement, +} 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 { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; - +// biome-ignore lint/suspicious/noConfusingVoidType: void unions in callbacks are OK export type OptionPhaseCallback = () => Promise; /** @@ -71,16 +76,22 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption { * Returns true if option contains any {@linkcode EncounterRequirement}s, false otherwise. */ hasRequirements(): boolean { - return this.requirements.length > 0 || this.primaryPokemonRequirements.length > 0 || this.secondaryPokemonRequirements.length > 0; + return ( + this.requirements.length > 0 || + this.primaryPokemonRequirements.length > 0 || + this.secondaryPokemonRequirements.length > 0 + ); } /** * Returns true if all {@linkcode EncounterRequirement}s for the option are met */ meetsRequirements(): boolean { - return !this.requirements.some(requirement => !requirement.meetsRequirement()) - && this.meetsSupportingRequirementAndSupportingPokemonSelected() - && this.meetsPrimaryRequirementAndPrimaryPokemonSelected(); + return ( + !this.requirements.some(requirement => !requirement.meetsRequirement()) && + this.meetsSupportingRequirementAndSupportingPokemonSelected() && + this.meetsPrimaryRequirementAndPrimaryPokemonSelected() + ); } /** @@ -88,7 +99,13 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption { * @param pokemon */ pokemonMeetsPrimaryRequirements(pokemon: Pokemon): boolean { - return !this.primaryPokemonRequirements.some(req => !req.queryParty(globalScene.getPlayerParty()).map(p => p.id).includes(pokemon.id)); + return !this.primaryPokemonRequirements.some( + req => + !req + .queryParty(globalScene.getPlayerParty()) + .map(p => p.id) + .includes(pokemon.id), + ); } /** @@ -125,27 +142,26 @@ export default class MysteryEncounterOption implements IMysteryEncounterOption { } else { overlap.push(qp); } - } if (truePrimaryPool.length > 0) { // always choose from the non-overlapping pokemon first this.primaryPokemon = truePrimaryPool[randSeedInt(truePrimaryPool.length)]; return true; - } else { - // if there are multiple overlapping pokemon, we're okay - just choose one and take it out of the supporting pokemon pool - if (overlap.length > 1 || (this.secondaryPokemon.length - overlap.length >= 1)) { - this.primaryPokemon = overlap[randSeedInt(overlap.length)]; - this.secondaryPokemon = this.secondaryPokemon.filter((supp) => supp !== this.primaryPokemon); - return true; - } - console.log("Mystery Encounter Edge Case: Requirement not met due to primay pokemon overlapping with support pokemon. There's no valid primary pokemon left."); - return false; } - } else { - // Just pick the first qualifying Pokemon - this.primaryPokemon = qualified[0]; - return true; + // if there are multiple overlapping pokemon, we're okay - just choose one and take it out of the supporting pokemon pool + if (overlap.length > 1 || this.secondaryPokemon.length - overlap.length >= 1) { + this.primaryPokemon = overlap[randSeedInt(overlap.length)]; + this.secondaryPokemon = this.secondaryPokemon.filter(supp => supp !== this.primaryPokemon); + return true; + } + console.log( + "Mystery Encounter Edge Case: Requirement not met due to primay pokemon overlapping with support pokemon. There's no valid primary pokemon left.", + ); + return false; } + // Just pick the first qualifying Pokemon + this.primaryPokemon = qualified[0]; + return true; } /** @@ -180,12 +196,14 @@ export class MysteryEncounterOptionBuilder implements Partial { + static newOptionWithMode( + optionMode: MysteryEncounterOptionMode, + ): MysteryEncounterOptionBuilder & Pick { return Object.assign(new MysteryEncounterOptionBuilder(), { optionMode }); } @@ -197,7 +215,9 @@ export class MysteryEncounterOptionBuilder implements Partial> { + withSceneRequirement( + requirement: EncounterSceneRequirement, + ): this & Required> { if (requirement instanceof EncounterPokemonRequirement) { Error("Incorrectly added pokemon requirement as scene requirement."); } @@ -216,7 +236,9 @@ export class MysteryEncounterOptionBuilder implements Partial> { + withPreOptionPhase( + onPreOptionPhase: OptionPhaseCallback, + ): this & Required> { return Object.assign(this, { onPreOptionPhase: onPreOptionPhase }); } @@ -228,7 +250,9 @@ export class MysteryEncounterOptionBuilder implements Partial> { + withPostOptionPhase( + onPostOptionPhase: OptionPhaseCallback, + ): this & Required> { return Object.assign(this, { onPostOptionPhase: onPostOptionPhase }); } @@ -236,13 +260,17 @@ export class MysteryEncounterOptionBuilder implements Partial> { + withPrimaryPokemonRequirement( + requirement: EncounterPokemonRequirement, + ): this & Required> { if (requirement instanceof EncounterSceneRequirement) { Error("Incorrectly added scene requirement as pokemon requirement."); } this.primaryPokemonRequirements.push(requirement); - return Object.assign(this, { primaryPokemonRequirements: this.primaryPokemonRequirements }); + return Object.assign(this, { + primaryPokemonRequirements: this.primaryPokemonRequirements, + }); } /** @@ -254,8 +282,15 @@ export class MysteryEncounterOptionBuilder implements Partial> { + withSecondaryPokemonRequirement( + requirement: EncounterPokemonRequirement, + excludePrimaryFromSecondaryRequirements = true, + ): this & Required> { if (requirement instanceof EncounterSceneRequirement) { Error("Incorrectly added scene requirement as pokemon requirement."); } this.secondaryPokemonRequirements.push(requirement); this.excludePrimaryFromSecondaryRequirements = excludePrimaryFromSecondaryRequirements; - return Object.assign(this, { secondaryPokemonRequirements: this.secondaryPokemonRequirements }); + return Object.assign(this, { + secondaryPokemonRequirements: this.secondaryPokemonRequirements, + }); } /** diff --git a/src/data/mystery-encounters/mystery-encounter-requirements.ts b/src/data/mystery-encounters/mystery-encounter-requirements.ts index 48d2f3766d2..e9398547740 100644 --- a/src/data/mystery-encounters/mystery-encounter-requirements.ts +++ b/src/data/mystery-encounters/mystery-encounter-requirements.ts @@ -76,15 +76,14 @@ export class CombinationSceneRequirement extends EncounterSceneRequirement { override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { if (this.isAnd) { throw new Error("Not implemented (Sorry)"); - } else { - for (const req of this.requirements) { - if (req.meetsRequirement()) { - return req.getDialogueToken(pokemon); - } - } - - return this.requirements[0].getDialogueToken(pokemon); } + for (const req of this.requirements) { + if (req.meetsRequirement()) { + return req.getDialogueToken(pokemon); + } + } + + return this.requirements[0].getDialogueToken(pokemon); } } @@ -153,10 +152,9 @@ export class CombinationPokemonRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (this.isAnd) { return this.requirements.reduce((relevantPokemon, req) => req.queryParty(relevantPokemon), partyPokemon); - } else { - const matchingRequirement = this.requirements.find(req => req.queryParty(partyPokemon).length > 0); - return matchingRequirement ? matchingRequirement.queryParty(partyPokemon) : []; } + const matchingRequirement = this.requirements.find(req => req.queryParty(partyPokemon).length > 0); + return matchingRequirement ? matchingRequirement.queryParty(partyPokemon) : []; } /** @@ -168,15 +166,14 @@ export class CombinationPokemonRequirement extends EncounterPokemonRequirement { override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { if (this.isAnd) { throw new Error("Not implemented (Sorry)"); - } else { - for (const req of this.requirements) { - if (req.meetsRequirement()) { - return req.getDialogueToken(pokemon); - } - } - - return this.requirements[0].getDialogueToken(pokemon); } + for (const req of this.requirements) { + if (req.meetsRequirement()) { + return req.getDialogueToken(pokemon); + } + } + + return this.requirements[0].getDialogueToken(pokemon); } } @@ -193,11 +190,18 @@ export class PreviousEncounterRequirement extends EncounterSceneRequirement { } override meetsRequirement(): boolean { - return globalScene.mysteryEncounterSaveData.encounteredEvents.some(e => e.type === this.previousEncounterRequirement); + return globalScene.mysteryEncounterSaveData.encounteredEvents.some( + e => e.type === this.previousEncounterRequirement, + ); } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "previousEncounter", globalScene.mysteryEncounterSaveData.encounteredEvents.find(e => e.type === this.previousEncounterRequirement)?.[0].toString() ?? "" ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return [ + "previousEncounter", + globalScene.mysteryEncounterSaveData.encounteredEvents + .find(e => e.type === this.previousEncounterRequirement)?.[0] + .toString() ?? "", + ]; } } @@ -217,15 +221,18 @@ export class WaveRangeRequirement extends EncounterSceneRequirement { override meetsRequirement(): boolean { if (!isNullOrUndefined(this.waveRange) && this.waveRange[0] <= this.waveRange[1]) { const waveIndex = globalScene.currentBattle.waveIndex; - if (waveIndex >= 0 && (this.waveRange[0] >= 0 && this.waveRange[0] > waveIndex) || (this.waveRange[1] >= 0 && this.waveRange[1] < waveIndex)) { + if ( + (waveIndex >= 0 && this.waveRange[0] >= 0 && this.waveRange[0] > waveIndex) || + (this.waveRange[1] >= 0 && this.waveRange[1] < waveIndex) + ) { return false; } } return true; } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "waveIndex", globalScene.currentBattle.waveIndex.toString() ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return ["waveIndex", globalScene.currentBattle.waveIndex.toString()]; } } @@ -253,8 +260,8 @@ export class WaveModulusRequirement extends EncounterSceneRequirement { return this.waveModuli.includes(globalScene.currentBattle.waveIndex % this.modulusValue); } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "waveIndex", globalScene.currentBattle.waveIndex.toString() ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return ["waveIndex", globalScene.currentBattle.waveIndex.toString()]; } } @@ -263,20 +270,24 @@ export class TimeOfDayRequirement extends EncounterSceneRequirement { constructor(timeOfDay: TimeOfDay | TimeOfDay[]) { super(); - this.requiredTimeOfDay = Array.isArray(timeOfDay) ? timeOfDay : [ timeOfDay ]; + this.requiredTimeOfDay = Array.isArray(timeOfDay) ? timeOfDay : [timeOfDay]; } override meetsRequirement(): boolean { const timeOfDay = globalScene.arena?.getTimeOfDay(); - if (!isNullOrUndefined(timeOfDay) && this.requiredTimeOfDay?.length > 0 && !this.requiredTimeOfDay.includes(timeOfDay)) { + if ( + !isNullOrUndefined(timeOfDay) && + this.requiredTimeOfDay?.length > 0 && + !this.requiredTimeOfDay.includes(timeOfDay) + ) { return false; } return true; } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "timeOfDay", TimeOfDay[globalScene.arena.getTimeOfDay()].toLocaleLowerCase() ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return ["timeOfDay", TimeOfDay[globalScene.arena.getTimeOfDay()].toLocaleLowerCase()]; } } @@ -285,25 +296,29 @@ export class WeatherRequirement extends EncounterSceneRequirement { constructor(weather: WeatherType | WeatherType[]) { super(); - this.requiredWeather = Array.isArray(weather) ? weather : [ weather ]; + this.requiredWeather = Array.isArray(weather) ? weather : [weather]; } override meetsRequirement(): boolean { const currentWeather = globalScene.arena.weather?.weatherType; - if (!isNullOrUndefined(currentWeather) && this.requiredWeather?.length > 0 && !this.requiredWeather.includes(currentWeather!)) { + if ( + !isNullOrUndefined(currentWeather) && + this.requiredWeather?.length > 0 && + !this.requiredWeather.includes(currentWeather!) + ) { return false; } return true; } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { const currentWeather = globalScene.arena.weather?.weatherType; let token = ""; if (!isNullOrUndefined(currentWeather)) { token = WeatherType[currentWeather].replace("_", " ").toLocaleLowerCase(); } - return [ "weather", token ]; + return ["weather", token]; } } @@ -325,8 +340,13 @@ export class PartySizeRequirement extends EncounterSceneRequirement { override meetsRequirement(): boolean { if (!isNullOrUndefined(this.partySizeRange) && this.partySizeRange[0] <= this.partySizeRange[1]) { - const partySize = this.excludeDisallowedPokemon ? globalScene.getPokemonAllowedInBattle().length : globalScene.getPlayerParty().length; - if (partySize >= 0 && (this.partySizeRange[0] >= 0 && this.partySizeRange[0] > partySize) || (this.partySizeRange[1] >= 0 && this.partySizeRange[1] < partySize)) { + const partySize = this.excludeDisallowedPokemon + ? globalScene.getPokemonAllowedInBattle().length + : globalScene.getPlayerParty().length; + if ( + (partySize >= 0 && this.partySizeRange[0] >= 0 && this.partySizeRange[0] > partySize) || + (this.partySizeRange[1] >= 0 && this.partySizeRange[1] < partySize) + ) { return false; } } @@ -334,8 +354,8 @@ export class PartySizeRequirement extends EncounterSceneRequirement { return true; } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "partySize", globalScene.getPlayerParty().length.toString() ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return ["partySize", globalScene.getPlayerParty().length.toString()]; } } @@ -343,10 +363,10 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement { requiredHeldItemModifiers: string[]; minNumberOfItems: number; - constructor(heldItem: string | string[], minNumberOfItems: number = 1) { + constructor(heldItem: string | string[], minNumberOfItems = 1) { super(); this.minNumberOfItems = minNumberOfItems; - this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [ heldItem ]; + this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [heldItem]; } override meetsRequirement(): boolean { @@ -355,20 +375,20 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement { return false; } let modifierCount = 0; - this.requiredHeldItemModifiers.forEach(modifier => { + for (const modifier of this.requiredHeldItemModifiers) { const matchingMods = globalScene.findModifiers(m => m.constructor.name === modifier); if (matchingMods?.length > 0) { - matchingMods.forEach(matchingMod => { + for (const matchingMod of matchingMods) { modifierCount += matchingMod.stackCount; - }); + } } - }); + } return modifierCount >= this.minNumberOfItems; } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "requiredItem", this.requiredHeldItemModifiers[0] ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + return ["requiredItem", this.requiredHeldItemModifiers[0]]; } } @@ -394,9 +414,12 @@ export class MoneyRequirement extends EncounterSceneRequirement { return !(this.requiredMoney > 0 && this.requiredMoney > money); } - override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const value = this.scalingMultiplier > 0 ? globalScene.getWaveMoneyAmount(this.scalingMultiplier).toString() : this.requiredMoney.toString(); - return [ "money", value ]; + override getDialogueToken(_pokemon?: PlayerPokemon): [string, string] { + const value = + this.scalingMultiplier > 0 + ? globalScene.getWaveMoneyAmount(this.scalingMultiplier).toString() + : this.requiredMoney.toString(); + return ["money", value]; } } @@ -405,11 +428,11 @@ export class SpeciesRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(species: Species | Species[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(species: Species | Species[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredSpecies = Array.isArray(species) ? species : [ species ]; + this.requiredSpecies = Array.isArray(species) ? species : [species]; } override meetsRequirement(): boolean { @@ -422,32 +445,34 @@ export class SpeciesRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredSpecies.filter((species) => pokemon.species.speciesId === species).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed speciess - return partyPokemon.filter((pokemon) => this.requiredSpecies.filter((species) => pokemon.species.speciesId === species).length === 0); + return partyPokemon.filter( + pokemon => this.requiredSpecies.filter(species => pokemon.species.speciesId === species).length > 0, + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed speciess + return partyPokemon.filter( + pokemon => this.requiredSpecies.filter(species => pokemon.species.speciesId === species).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { if (pokemon?.species.speciesId && this.requiredSpecies.includes(pokemon.species.speciesId)) { - return [ "species", Species[pokemon.species.speciesId] ]; + return ["species", Species[pokemon.species.speciesId]]; } - return [ "species", "" ]; + return ["species", ""]; } } - export class NatureRequirement extends EncounterPokemonRequirement { requiredNature: Nature[]; minNumberOfPokemon: number; invertQuery: boolean; - constructor(nature: Nature | Nature[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(nature: Nature | Nature[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredNature = Array.isArray(nature) ? nature : [ nature ]; + this.requiredNature = Array.isArray(nature) ? nature : [nature]; } override meetsRequirement(): boolean { @@ -460,18 +485,17 @@ export class NatureRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredNature.filter((nature) => pokemon.nature === nature).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed natures - return partyPokemon.filter((pokemon) => this.requiredNature.filter((nature) => pokemon.nature === nature).length === 0); + return partyPokemon.filter(pokemon => this.requiredNature.filter(nature => pokemon.nature === nature).length > 0); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed natures + return partyPokemon.filter(pokemon => this.requiredNature.filter(nature => pokemon.nature === nature).length === 0); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { if (!isNullOrUndefined(pokemon?.nature) && this.requiredNature.includes(pokemon.nature)) { - return [ "nature", Nature[pokemon.nature] ]; + return ["nature", Nature[pokemon.nature]]; } - return [ "nature", "" ]; + return ["nature", ""]; } } @@ -481,12 +505,12 @@ export class TypeRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(type: PokemonType | PokemonType[], excludeFainted: boolean = true, minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(type: PokemonType | PokemonType[], excludeFainted = true, minNumberOfPokemon = 1, invertQuery = false) { super(); this.excludeFainted = excludeFainted; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredType = Array.isArray(type) ? type : [ type ]; + this.requiredType = Array.isArray(type) ? type : [type]; } override meetsRequirement(): boolean { @@ -497,7 +521,7 @@ export class TypeRequirement extends EncounterPokemonRequirement { } if (this.excludeFainted) { - partyPokemon = partyPokemon.filter((pokemon) => !pokemon.isFainted()); + partyPokemon = partyPokemon.filter(pokemon => !pokemon.isFainted()); } return this.queryParty(partyPokemon).length >= this.minNumberOfPokemon; @@ -505,35 +529,37 @@ export class TypeRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredType.filter((type) => pokemon.getTypes().includes(type)).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed types - return partyPokemon.filter((pokemon) => this.requiredType.filter((type) => pokemon.getTypes().includes(type)).length === 0); + return partyPokemon.filter( + pokemon => this.requiredType.filter(type => pokemon.getTypes().includes(type)).length > 0, + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed types + return partyPokemon.filter( + pokemon => this.requiredType.filter(type => pokemon.getTypes().includes(type)).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const includedTypes = this.requiredType.filter((ty) => pokemon?.getTypes().includes(ty)); + const includedTypes = this.requiredType.filter(ty => pokemon?.getTypes().includes(ty)); if (includedTypes.length > 0) { - return [ "type", PokemonType[includedTypes[0]] ]; + return ["type", PokemonType[includedTypes[0]]]; } - return [ "type", "" ]; + return ["type", ""]; } } - export class MoveRequirement extends EncounterPokemonRequirement { requiredMoves: Moves[] = []; minNumberOfPokemon: number; invertQuery: boolean; excludeDisallowedPokemon: boolean; - constructor(moves: Moves | Moves[], excludeDisallowedPokemon: boolean, minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(moves: Moves | Moves[], excludeDisallowedPokemon: boolean, minNumberOfPokemon = 1, invertQuery = false) { super(); this.excludeDisallowedPokemon = excludeDisallowedPokemon; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredMoves = Array.isArray(moves) ? moves : [ moves ]; + this.requiredMoves = Array.isArray(moves) ? moves : [moves]; } override meetsRequirement(): boolean { @@ -547,25 +573,27 @@ export class MoveRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { // get the Pokemon with at least one move in the required moves list - return partyPokemon.filter((pokemon) => - (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) - && pokemon.moveset.some((move) => move?.moveId && this.requiredMoves.includes(move.moveId))); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed moves - return partyPokemon.filter((pokemon) => - (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) - && !pokemon.moveset.some((move) => move?.moveId && this.requiredMoves.includes(move.moveId))); + return partyPokemon.filter( + pokemon => + (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) && + pokemon.moveset.some(move => move?.moveId && this.requiredMoves.includes(move.moveId)), + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed moves + return partyPokemon.filter( + pokemon => + (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) && + !pokemon.moveset.some(move => move?.moveId && this.requiredMoves.includes(move.moveId)), + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const includedMoves = pokemon?.moveset.filter((move) => move?.moveId && this.requiredMoves.includes(move.moveId)); + const includedMoves = pokemon?.moveset.filter(move => move?.moveId && this.requiredMoves.includes(move.moveId)); if (includedMoves && includedMoves.length > 0 && includedMoves[0]) { - return [ "move", includedMoves[0].getName() ]; + return ["move", includedMoves[0].getName()]; } - return [ "move", "" ]; + return ["move", ""]; } - } /** @@ -578,11 +606,11 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(learnableMove: Moves | Moves[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(learnableMove: Moves | Moves[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredMoves = Array.isArray(learnableMove) ? learnableMove : [ learnableMove ]; + this.requiredMoves = Array.isArray(learnableMove) ? learnableMove : [learnableMove]; } override meetsRequirement(): boolean { @@ -595,21 +623,31 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredMoves.filter((learnableMove) => pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove)).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed learnableMoves - return partyPokemon.filter((pokemon) => this.requiredMoves.filter((learnableMove) => pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove)).length === 0); + return partyPokemon.filter( + pokemon => + this.requiredMoves.filter(learnableMove => + pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove), + ).length > 0, + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed learnableMoves + return partyPokemon.filter( + pokemon => + this.requiredMoves.filter(learnableMove => + pokemon.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(learnableMove), + ).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const includedCompatMoves = this.requiredMoves.filter((reqMove) => pokemon?.compatibleTms.filter((tm) => !pokemon.moveset.find(m => m?.moveId === tm)).includes(reqMove)); + const includedCompatMoves = this.requiredMoves.filter(reqMove => + pokemon?.compatibleTms.filter(tm => !pokemon.moveset.find(m => m?.moveId === tm)).includes(reqMove), + ); if (includedCompatMoves.length > 0) { - return [ "compatibleMove", Moves[includedCompatMoves[0]] ]; + return ["compatibleMove", Moves[includedCompatMoves[0]]]; } - return [ "compatibleMove", "" ]; + return ["compatibleMove", ""]; } - } export class AbilityRequirement extends EncounterPokemonRequirement { @@ -618,12 +656,17 @@ export class AbilityRequirement extends EncounterPokemonRequirement { invertQuery: boolean; excludeDisallowedPokemon: boolean; - constructor(abilities: Abilities | Abilities[], excludeDisallowedPokemon: boolean, minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor( + abilities: Abilities | Abilities[], + excludeDisallowedPokemon: boolean, + minNumberOfPokemon = 1, + invertQuery = false, + ) { super(); this.excludeDisallowedPokemon = excludeDisallowedPokemon; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredAbilities = Array.isArray(abilities) ? abilities : [ abilities ]; + this.requiredAbilities = Array.isArray(abilities) ? abilities : [abilities]; } override meetsRequirement(): boolean { @@ -636,23 +679,26 @@ export class AbilityRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => - (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) - && this.requiredAbilities.some((ability) => pokemon.hasAbility(ability, false))); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed abilities - return partyPokemon.filter((pokemon) => - (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) - && this.requiredAbilities.filter((ability) => pokemon.hasAbility(ability, false)).length === 0); + return partyPokemon.filter( + pokemon => + (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) && + this.requiredAbilities.some(ability => pokemon.hasAbility(ability, false)), + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed abilities + return partyPokemon.filter( + pokemon => + (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) && + this.requiredAbilities.filter(ability => pokemon.hasAbility(ability, false)).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { const matchingAbility = this.requiredAbilities.find(a => pokemon?.hasAbility(a, false)); if (!isNullOrUndefined(matchingAbility)) { - return [ "ability", allAbilities[matchingAbility].name ]; + return ["ability", allAbilities[matchingAbility].name]; } - return [ "ability", "" ]; + return ["ability", ""]; } } @@ -661,11 +707,11 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(statusEffect: StatusEffect | StatusEffect[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(statusEffect: StatusEffect | StatusEffect[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredStatusEffect = Array.isArray(statusEffect) ? statusEffect : [ statusEffect ]; + this.requiredStatusEffect = Array.isArray(statusEffect) ? statusEffect : [statusEffect]; } override meetsRequirement(): boolean { @@ -680,44 +726,50 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => { - return this.requiredStatusEffect.some((statusEffect) => { + return partyPokemon.filter(pokemon => { + return this.requiredStatusEffect.some(statusEffect => { if (statusEffect === StatusEffect.NONE) { // StatusEffect.NONE also checks for null or undefined status - return isNullOrUndefined(pokemon.status) || isNullOrUndefined(pokemon.status.effect) || pokemon.status.effect === statusEffect; - } else { - return pokemon.status?.effect === statusEffect; - } - }); - }); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed StatusEffects - return partyPokemon.filter((pokemon) => { - return !this.requiredStatusEffect.some((statusEffect) => { - if (statusEffect === StatusEffect.NONE) { - // StatusEffect.NONE also checks for null or undefined status - return isNullOrUndefined(pokemon.status) || isNullOrUndefined(pokemon.status.effect) || pokemon.status.effect === statusEffect; - } else { - return pokemon.status?.effect === statusEffect; + return ( + isNullOrUndefined(pokemon.status) || + isNullOrUndefined(pokemon.status.effect) || + pokemon.status.effect === statusEffect + ); } + return pokemon.status?.effect === statusEffect; }); }); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed StatusEffects + return partyPokemon.filter(pokemon => { + return !this.requiredStatusEffect.some(statusEffect => { + if (statusEffect === StatusEffect.NONE) { + // StatusEffect.NONE also checks for null or undefined status + return ( + isNullOrUndefined(pokemon.status) || + isNullOrUndefined(pokemon.status.effect) || + pokemon.status.effect === statusEffect + ); + } + return pokemon.status?.effect === statusEffect; + }); + }); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const reqStatus = this.requiredStatusEffect.filter((a) => { + const reqStatus = this.requiredStatusEffect.filter(a => { if (a === StatusEffect.NONE) { - return isNullOrUndefined(pokemon?.status) || isNullOrUndefined(pokemon.status.effect) || pokemon.status.effect === a; + return ( + isNullOrUndefined(pokemon?.status) || isNullOrUndefined(pokemon.status.effect) || pokemon.status.effect === a + ); } return pokemon!.status?.effect === a; }); if (reqStatus.length > 0) { - return [ "status", StatusEffect[reqStatus[0]] ]; + return ["status", StatusEffect[reqStatus[0]]]; } - return [ "status", "" ]; + return ["status", ""]; } - } /** @@ -730,11 +782,11 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen minNumberOfPokemon: number; invertQuery: boolean; - constructor(formChangeItem: FormChangeItem | FormChangeItem[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(formChangeItem: FormChangeItem | FormChangeItem[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredFormChangeItem = Array.isArray(formChangeItem) ? formChangeItem : [ formChangeItem ]; + this.requiredFormChangeItem = Array.isArray(formChangeItem) ? formChangeItem : [formChangeItem]; } override meetsRequirement(): boolean { @@ -746,35 +798,44 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen } filterByForm(pokemon, formChangeItem) { - if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) + if ( + pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) && // Get all form changes for this species with an item trigger, including any compound triggers - && pokemonFormChanges[pokemon.species.speciesId].filter(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger)) + pokemonFormChanges[pokemon.species.speciesId] + .filter(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger)) // Returns true if any form changes match this item - .map(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) - .flat().flatMap(fc => fc.item).includes(formChangeItem)) { + .flatMap(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) + .flatMap(fc => fc.item) + .includes(formChangeItem) + ) { return true; - } else { - return false; } + return false; } override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredFormChangeItem.filter((formChangeItem) => this.filterByForm(pokemon, formChangeItem)).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed formChangeItems - return partyPokemon.filter((pokemon) => this.requiredFormChangeItem.filter((formChangeItem) => this.filterByForm(pokemon, formChangeItem)).length === 0); + return partyPokemon.filter( + pokemon => + this.requiredFormChangeItem.filter(formChangeItem => this.filterByForm(pokemon, formChangeItem)).length > 0, + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed formChangeItems + return partyPokemon.filter( + pokemon => + this.requiredFormChangeItem.filter(formChangeItem => this.filterByForm(pokemon, formChangeItem)).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const requiredItems = this.requiredFormChangeItem.filter((formChangeItem) => this.filterByForm(pokemon, formChangeItem)); + const requiredItems = this.requiredFormChangeItem.filter(formChangeItem => + this.filterByForm(pokemon, formChangeItem), + ); if (requiredItems.length > 0) { - return [ "formChangeItem", FormChangeItem[requiredItems[0]] ]; + return ["formChangeItem", FormChangeItem[requiredItems[0]]]; } - return [ "formChangeItem", "" ]; + return ["formChangeItem", ""]; } - } export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement { @@ -782,11 +843,11 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(evolutionItems: EvolutionItem | EvolutionItem[], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(evolutionItems: EvolutionItem | EvolutionItem[], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredEvolutionItem = Array.isArray(evolutionItems) ? evolutionItems : [ evolutionItems ]; + this.requiredEvolutionItem = Array.isArray(evolutionItems) ? evolutionItems : [evolutionItems]; } override meetsRequirement(): boolean { @@ -798,11 +859,23 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement { } filterByEvo(pokemon, evolutionItem) { - if (pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) && pokemonEvolutions[pokemon.species.speciesId].filter(e => e.item === evolutionItem - && (!e.condition || e.condition.predicate(pokemon))).length && (pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX)) { + if ( + pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) && + pokemonEvolutions[pokemon.species.speciesId].filter( + e => e.item === evolutionItem && (!e.condition || e.condition.predicate(pokemon)), + ).length && + pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX + ) { return true; - } else if (pokemon.isFusion() && pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) && pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(e => e.item === evolutionItem - && (!e.condition || e.condition.predicate(pokemon))).length && (pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX)) { + } + if ( + pokemon.isFusion() && + pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) && + pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter( + e => e.item === evolutionItem && (!e.condition || e.condition.predicate(pokemon)), + ).length && + pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX + ) { return true; } return false; @@ -810,19 +883,24 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredEvolutionItem.filter((evolutionItem) => this.filterByEvo(pokemon, evolutionItem)).length > 0); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed evolutionItemss - return partyPokemon.filter((pokemon) => this.requiredEvolutionItem.filter((evolutionItems) => this.filterByEvo(pokemon, evolutionItems)).length === 0); + return partyPokemon.filter( + pokemon => + this.requiredEvolutionItem.filter(evolutionItem => this.filterByEvo(pokemon, evolutionItem)).length > 0, + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed evolutionItemss + return partyPokemon.filter( + pokemon => + this.requiredEvolutionItem.filter(evolutionItems => this.filterByEvo(pokemon, evolutionItems)).length === 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const requiredItems = this.requiredEvolutionItem.filter((evoItem) => this.filterByEvo(pokemon, evoItem)); + const requiredItems = this.requiredEvolutionItem.filter(evoItem => this.filterByEvo(pokemon, evoItem)); if (requiredItems.length > 0) { - return [ "evolutionItem", EvolutionItem[requiredItems[0]] ]; + return ["evolutionItem", EvolutionItem[requiredItems[0]]]; } - return [ "evolutionItem", "" ]; + return ["evolutionItem", ""]; } } @@ -832,11 +910,11 @@ export class HeldItemRequirement extends EncounterPokemonRequirement { invertQuery: boolean; requireTransferable: boolean; - constructor(heldItem: string | string[], minNumberOfPokemon: number = 1, invertQuery: boolean = false, requireTransferable: boolean = true) { + constructor(heldItem: string | string[], minNumberOfPokemon = 1, invertQuery = false, requireTransferable = true) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [ heldItem ]; + this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [heldItem]; this.requireTransferable = requireTransferable; } @@ -850,30 +928,38 @@ export class HeldItemRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredHeldItemModifiers.some((heldItem) => { - return pokemon.getHeldItems().some((it) => { - return it.constructor.name === heldItem && (!this.requireTransferable || it.isTransferable); - }); - })); - } else { - // for an inverted query, we only want to get the pokemon that have any held items that are NOT in requiredHeldItemModifiers - // E.g. functions as a blacklist - return partyPokemon.filter((pokemon) => pokemon.getHeldItems().filter((it) => { - return !this.requiredHeldItemModifiers.some(heldItem => it.constructor.name === heldItem) - && (!this.requireTransferable || it.isTransferable); - }).length > 0); + return partyPokemon.filter(pokemon => + this.requiredHeldItemModifiers.some(heldItem => { + return pokemon.getHeldItems().some(it => { + return it.constructor.name === heldItem && (!this.requireTransferable || it.isTransferable); + }); + }), + ); } + // for an inverted query, we only want to get the pokemon that have any held items that are NOT in requiredHeldItemModifiers + // E.g. functions as a blacklist + return partyPokemon.filter( + pokemon => + pokemon.getHeldItems().filter(it => { + return ( + !this.requiredHeldItemModifiers.some(heldItem => it.constructor.name === heldItem) && + (!this.requireTransferable || it.isTransferable) + ); + }).length > 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const requiredItems = pokemon?.getHeldItems().filter((it) => { - return this.requiredHeldItemModifiers.some(heldItem => it.constructor.name === heldItem) - && (!this.requireTransferable || it.isTransferable); + const requiredItems = pokemon?.getHeldItems().filter(it => { + return ( + this.requiredHeldItemModifiers.some(heldItem => it.constructor.name === heldItem) && + (!this.requireTransferable || it.isTransferable) + ); }); if (requiredItems && requiredItems.length > 0) { - return [ "heldItem", requiredItems[0].type.name ]; + return ["heldItem", requiredItems[0].type.name]; } - return [ "heldItem", "" ]; + return ["heldItem", ""]; } } @@ -883,11 +969,16 @@ export class AttackTypeBoosterHeldItemTypeRequirement extends EncounterPokemonRe invertQuery: boolean; requireTransferable: boolean; - constructor(heldItemTypes: PokemonType | PokemonType[], minNumberOfPokemon: number = 1, invertQuery: boolean = false, requireTransferable: boolean = true) { + constructor( + heldItemTypes: PokemonType | PokemonType[], + minNumberOfPokemon = 1, + invertQuery = false, + requireTransferable = true, + ) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredHeldItemTypes = Array.isArray(heldItemTypes) ? heldItemTypes : [ heldItemTypes ]; + this.requiredHeldItemTypes = Array.isArray(heldItemTypes) ? heldItemTypes : [heldItemTypes]; this.requireTransferable = requireTransferable; } @@ -901,36 +992,48 @@ export class AttackTypeBoosterHeldItemTypeRequirement extends EncounterPokemonRe override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => this.requiredHeldItemTypes.some((heldItemType) => { - return pokemon.getHeldItems().some((it) => { - return it instanceof AttackTypeBoosterModifier - && (it.type as AttackTypeBoosterModifierType).moveType === heldItemType - && (!this.requireTransferable || it.isTransferable); - }); - })); - } else { - // for an inverted query, we only want to get the pokemon that have any held items that are NOT in requiredHeldItemModifiers - // E.g. functions as a blacklist - return partyPokemon.filter((pokemon) => pokemon.getHeldItems().filter((it) => { - return !this.requiredHeldItemTypes.some(heldItemType => - it instanceof AttackTypeBoosterModifier - && (it.type as AttackTypeBoosterModifierType).moveType === heldItemType - && (!this.requireTransferable || it.isTransferable)); - }).length > 0); + return partyPokemon.filter(pokemon => + this.requiredHeldItemTypes.some(heldItemType => { + return pokemon.getHeldItems().some(it => { + return ( + it instanceof AttackTypeBoosterModifier && + (it.type as AttackTypeBoosterModifierType).moveType === heldItemType && + (!this.requireTransferable || it.isTransferable) + ); + }); + }), + ); } + // for an inverted query, we only want to get the pokemon that have any held items that are NOT in requiredHeldItemModifiers + // E.g. functions as a blacklist + return partyPokemon.filter( + pokemon => + pokemon.getHeldItems().filter(it => { + return !this.requiredHeldItemTypes.some( + heldItemType => + it instanceof AttackTypeBoosterModifier && + (it.type as AttackTypeBoosterModifierType).moveType === heldItemType && + (!this.requireTransferable || it.isTransferable), + ); + }).length > 0, + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - const requiredItems = pokemon?.getHeldItems().filter((it) => { - return this.requiredHeldItemTypes.some(heldItemType => - it instanceof AttackTypeBoosterModifier - && (it.type as AttackTypeBoosterModifierType).moveType === heldItemType) - && (!this.requireTransferable || it.isTransferable); + const requiredItems = pokemon?.getHeldItems().filter(it => { + return ( + this.requiredHeldItemTypes.some( + heldItemType => + it instanceof AttackTypeBoosterModifier && + (it.type as AttackTypeBoosterModifierType).moveType === heldItemType, + ) && + (!this.requireTransferable || it.isTransferable) + ); }); if (requiredItems && requiredItems.length > 0) { - return [ "heldItem", requiredItems[0].type.name ]; + return ["heldItem", requiredItems[0].type.name]; } - return [ "heldItem", "" ]; + return ["heldItem", ""]; } } @@ -939,7 +1042,7 @@ export class LevelRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(requiredLevelRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(requiredLevelRange: [number, number], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; @@ -960,15 +1063,18 @@ export class LevelRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => pokemon.level >= this.requiredLevelRange[0] && pokemon.level <= this.requiredLevelRange[1]); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredLevelRanges - return partyPokemon.filter((pokemon) => pokemon.level < this.requiredLevelRange[0] || pokemon.level > this.requiredLevelRange[1]); + return partyPokemon.filter( + pokemon => pokemon.level >= this.requiredLevelRange[0] && pokemon.level <= this.requiredLevelRange[1], + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredLevelRanges + return partyPokemon.filter( + pokemon => pokemon.level < this.requiredLevelRange[0] || pokemon.level > this.requiredLevelRange[1], + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "level", pokemon?.level.toString() ?? "" ]; + return ["level", pokemon?.level.toString() ?? ""]; } } @@ -977,7 +1083,7 @@ export class FriendshipRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(requiredFriendshipRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(requiredFriendshipRange: [number, number], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; @@ -986,7 +1092,10 @@ export class FriendshipRequirement extends EncounterPokemonRequirement { override meetsRequirement(): boolean { // Party Pokemon inside required friendship range - if (!isNullOrUndefined(this.requiredFriendshipRange) && this.requiredFriendshipRange[0] <= this.requiredFriendshipRange[1]) { + if ( + !isNullOrUndefined(this.requiredFriendshipRange) && + this.requiredFriendshipRange[0] <= this.requiredFriendshipRange[1] + ) { const partyPokemon = globalScene.getPlayerParty(); const pokemonInRange = this.queryParty(partyPokemon); if (pokemonInRange.length < this.minNumberOfPokemon) { @@ -998,15 +1107,21 @@ export class FriendshipRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => pokemon.friendship >= this.requiredFriendshipRange[0] && pokemon.friendship <= this.requiredFriendshipRange[1]); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredFriendshipRanges - return partyPokemon.filter((pokemon) => pokemon.friendship < this.requiredFriendshipRange[0] || pokemon.friendship > this.requiredFriendshipRange[1]); + return partyPokemon.filter( + pokemon => + pokemon.friendship >= this.requiredFriendshipRange[0] && + pokemon.friendship <= this.requiredFriendshipRange[1], + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredFriendshipRanges + return partyPokemon.filter( + pokemon => + pokemon.friendship < this.requiredFriendshipRange[0] || pokemon.friendship > this.requiredFriendshipRange[1], + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "friendship", pokemon?.friendship.toString() ?? "" ]; + return ["friendship", pokemon?.friendship.toString() ?? ""]; } } @@ -1020,7 +1135,7 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(requiredHealthRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(requiredHealthRange: [number, number], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; @@ -1041,21 +1156,25 @@ export class HealthRatioRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => { - return pokemon.getHpRatio() >= this.requiredHealthRange[0] && pokemon.getHpRatio() <= this.requiredHealthRange[1]; + return partyPokemon.filter(pokemon => { + return ( + pokemon.getHpRatio() >= this.requiredHealthRange[0] && pokemon.getHpRatio() <= this.requiredHealthRange[1] + ); }); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredHealthRanges - return partyPokemon.filter((pokemon) => pokemon.getHpRatio() < this.requiredHealthRange[0] || pokemon.getHpRatio() > this.requiredHealthRange[1]); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredHealthRanges + return partyPokemon.filter( + pokemon => + pokemon.getHpRatio() < this.requiredHealthRange[0] || pokemon.getHpRatio() > this.requiredHealthRange[1], + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { const hpRatio = pokemon?.getHpRatio(); if (!isNullOrUndefined(hpRatio)) { - return [ "healthRatio", Math.floor(hpRatio * 100).toString() + "%" ]; + return ["healthRatio", Math.floor(hpRatio * 100).toString() + "%"]; } - return [ "healthRatio", "" ]; + return ["healthRatio", ""]; } } @@ -1064,7 +1183,7 @@ export class WeightRequirement extends EncounterPokemonRequirement { minNumberOfPokemon: number; invertQuery: boolean; - constructor(requiredWeightRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false) { + constructor(requiredWeightRange: [number, number], minNumberOfPokemon = 1, invertQuery = false) { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; @@ -1085,15 +1204,18 @@ export class WeightRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => pokemon.getWeight() >= this.requiredWeightRange[0] && pokemon.getWeight() <= this.requiredWeightRange[1]); - } else { - // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredWeightRanges - return partyPokemon.filter((pokemon) => pokemon.getWeight() < this.requiredWeightRange[0] || pokemon.getWeight() > this.requiredWeightRange[1]); + return partyPokemon.filter( + pokemon => + pokemon.getWeight() >= this.requiredWeightRange[0] && pokemon.getWeight() <= this.requiredWeightRange[1], + ); } + // for an inverted query, we only want to get the pokemon that don't have ANY of the listed requiredWeightRanges + return partyPokemon.filter( + pokemon => pokemon.getWeight() < this.requiredWeightRange[0] || pokemon.getWeight() > this.requiredWeightRange[1], + ); } override getDialogueToken(pokemon?: PlayerPokemon): [string, string] { - return [ "weight", pokemon?.getWeight().toString() ?? "" ]; + return ["weight", pokemon?.getWeight().toString() ?? ""]; } } - diff --git a/src/data/mystery-encounters/mystery-encounter.ts b/src/data/mystery-encounters/mystery-encounter.ts index c90649e551d..53e976cda8a 100644 --- a/src/data/mystery-encounters/mystery-encounter.ts +++ b/src/data/mystery-encounters/mystery-encounter.ts @@ -12,7 +12,14 @@ import type MysteryEncounterDialogue from "./mystery-encounter-dialogue"; import type { OptionPhaseCallback } from "./mystery-encounter-option"; import type MysteryEncounterOption from "./mystery-encounter-option"; import { MysteryEncounterOptionBuilder } from "./mystery-encounter-option"; -import { EncounterPokemonRequirement, EncounterSceneRequirement, HealthRatioRequirement, PartySizeRequirement, StatusEffectRequirement, WaveRangeRequirement } from "./mystery-encounter-requirements"; +import { + EncounterPokemonRequirement, + EncounterSceneRequirement, + HealthRatioRequirement, + PartySizeRequirement, + StatusEffectRequirement, + WaveRangeRequirement, +} from "./mystery-encounter-requirements"; import type { BattlerIndex } from "#app/battle"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; @@ -276,9 +283,12 @@ export default class MysteryEncounter implements IMysteryEncounter { this.encounterTier = this.encounterTier ?? MysteryEncounterTier.COMMON; this.localizationKey = this.localizationKey ?? ""; this.dialogue = this.dialogue ?? {}; - this.spriteConfigs = this.spriteConfigs ? [ ...this.spriteConfigs ] : []; + this.spriteConfigs = this.spriteConfigs ? [...this.spriteConfigs] : []; // Default max is 1 for ROGUE encounters, 2 for others - this.maxAllowedEncounters = this.maxAllowedEncounters ?? this.encounterTier === MysteryEncounterTier.ROGUE ? DEFAULT_MAX_ALLOWED_ROGUE_ENCOUNTERS : DEFAULT_MAX_ALLOWED_ENCOUNTERS; + this.maxAllowedEncounters = + (this.maxAllowedEncounters ?? this.encounterTier === MysteryEncounterTier.ROGUE) + ? DEFAULT_MAX_ALLOWED_ROGUE_ENCOUNTERS + : DEFAULT_MAX_ALLOWED_ENCOUNTERS; this.encounterMode = MysteryEncounterMode.DEFAULT; this.requirements = this.requirements ? this.requirements : []; this.hideBattleIntroMessage = this.hideBattleIntroMessage ?? false; @@ -317,7 +327,13 @@ export default class MysteryEncounter implements IMysteryEncounter { * @param pokemon */ pokemonMeetsPrimaryRequirements(pokemon: Pokemon): boolean { - return !this.primaryPokemonRequirements.some(req => !req.queryParty(globalScene.getPlayerParty()).map(p => p.id).includes(pokemon.id)); + return !this.primaryPokemonRequirements.some( + req => + !req + .queryParty(globalScene.getPlayerParty()) + .map(p => p.id) + .includes(pokemon.id), + ); } /** @@ -359,28 +375,27 @@ export default class MysteryEncounter implements IMysteryEncounter { } else { overlap.push(qp); } - } if (truePrimaryPool.length > 0) { // Always choose from the non-overlapping pokemon first this.primaryPokemon = truePrimaryPool[Utils.randSeedInt(truePrimaryPool.length, 0)]; return true; - } else { - // If there are multiple overlapping pokemon, we're okay - just choose one and take it out of the primary pokemon pool - if (overlap.length > 1 || (this.secondaryPokemon.length - overlap.length >= 1)) { - // is this working? - this.primaryPokemon = overlap[Utils.randSeedInt(overlap.length, 0)]; - this.secondaryPokemon = this.secondaryPokemon.filter((supp) => supp !== this.primaryPokemon); - return true; - } - console.log("Mystery Encounter Edge Case: Requirement not met due to primary pokemon overlapping with secondary pokemon. There's no valid primary pokemon left."); - return false; } - } else { - // this means we CAN have the same pokemon be a primary and secondary pokemon, so just choose any qualifying one randomly. - this.primaryPokemon = qualified[Utils.randSeedInt(qualified.length, 0)]; - return true; + // If there are multiple overlapping pokemon, we're okay - just choose one and take it out of the primary pokemon pool + if (overlap.length > 1 || this.secondaryPokemon.length - overlap.length >= 1) { + // is this working? + this.primaryPokemon = overlap[Utils.randSeedInt(overlap.length, 0)]; + this.secondaryPokemon = this.secondaryPokemon.filter(supp => supp !== this.primaryPokemon); + return true; + } + console.log( + "Mystery Encounter Edge Case: Requirement not met due to primary pokemon overlapping with secondary pokemon. There's no valid primary pokemon left.", + ); + return false; } + // this means we CAN have the same pokemon be a primary and secondary pokemon, so just choose any qualifying one randomly. + this.primaryPokemon = qualified[Utils.randSeedInt(qualified.length, 0)]; + return true; } /** @@ -533,28 +548,28 @@ export class MysteryEncounterBuilder implements Partial { options: [MysteryEncounterOption, MysteryEncounterOption, ...MysteryEncounterOption[]]; enemyPartyConfigs: EnemyPartyConfig[] = []; - localizationKey: string = ""; + localizationKey = ""; dialogue: MysteryEncounterDialogue = {}; requirements: EncounterSceneRequirement[] = []; primaryPokemonRequirements: EncounterPokemonRequirement[] = []; secondaryPokemonRequirements: EncounterPokemonRequirement[] = []; - excludePrimaryFromSupportRequirements: boolean = true; + excludePrimaryFromSupportRequirements = true; dialogueTokens: Record = {}; - hideBattleIntroMessage: boolean = false; - autoHideIntroVisuals: boolean = true; - enterIntroVisualsFromRight: boolean = false; - continuousEncounter: boolean = false; - catchAllowed: boolean = false; - fleeAllowed: boolean = true; - lockEncounterRewardTiers: boolean = false; - startOfBattleEffectsComplete: boolean = false; - hasBattleAnimationsWithoutTargets: boolean = false; - skipEnemyBattleTurns: boolean = false; - skipToFightInput: boolean = false; - preventGameStatsUpdates: boolean = false; - maxAllowedEncounters: number = 3; - expMultiplier: number = 1; + hideBattleIntroMessage = false; + autoHideIntroVisuals = true; + enterIntroVisualsFromRight = false; + continuousEncounter = false; + catchAllowed = false; + fleeAllowed = true; + lockEncounterRewardTiers = false; + startOfBattleEffectsComplete = false; + hasBattleAnimationsWithoutTargets = false; + skipEnemyBattleTurns = false; + skipToFightInput = false; + preventGameStatsUpdates = false; + maxAllowedEncounters = 3; + expMultiplier = 1; /** * REQUIRED @@ -566,7 +581,9 @@ export class MysteryEncounterBuilder implements Partial { * @param encounterType * @returns this */ - static withEncounterType(encounterType: MysteryEncounterType): MysteryEncounterBuilder & Pick { + static withEncounterType( + encounterType: MysteryEncounterType, + ): MysteryEncounterBuilder & Pick { return Object.assign(new MysteryEncounterBuilder(), { encounterType }); } @@ -580,12 +597,11 @@ export class MysteryEncounterBuilder implements Partial { */ withOption(option: MysteryEncounterOption): this & Pick { if (!this.options) { - const options = [ option ]; + const options = [option]; return Object.assign(this, { options }); - } else { - this.options.push(option); - return this; } + this.options.push(option); + return this; } /** @@ -598,8 +614,16 @@ export class MysteryEncounterBuilder implements Partial { * @param callback {@linkcode OptionPhaseCallback} * @returns */ - withSimpleOption(dialogue: OptionTextDisplay, callback: OptionPhaseCallback): this & Pick { - return this.withOption(MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT).withDialogue(dialogue).withOptionPhase(callback).build()); + withSimpleOption( + dialogue: OptionTextDisplay, + callback: OptionPhaseCallback, + ): this & Pick { + return this.withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withDialogue(dialogue) + .withOptionPhase(callback) + .build(), + ); } /** @@ -612,12 +636,17 @@ export class MysteryEncounterBuilder implements Partial { * @param callback {@linkcode OptionPhaseCallback} * @returns */ - withSimpleDexProgressOption(dialogue: OptionTextDisplay, callback: OptionPhaseCallback): this & Pick { - return this.withOption(MysteryEncounterOptionBuilder - .newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) - .withHasDexProgress(true) - .withDialogue(dialogue) - .withOptionPhase(callback).build()); + withSimpleDexProgressOption( + dialogue: OptionTextDisplay, + callback: OptionPhaseCallback, + ): this & Pick { + return this.withOption( + MysteryEncounterOptionBuilder.newOptionWithMode(MysteryEncounterOptionMode.DEFAULT) + .withHasDexProgress(true) + .withDialogue(dialogue) + .withOptionPhase(callback) + .build(), + ); } /** @@ -626,7 +655,9 @@ export class MysteryEncounterBuilder implements Partial { * @param spriteConfigs * @returns */ - withIntroSpriteConfigs(spriteConfigs: MysteryEncounterSpriteConfig[]): this & Pick { + withIntroSpriteConfigs( + spriteConfigs: MysteryEncounterSpriteConfig[], + ): this & Pick { return Object.assign(this, { spriteConfigs: spriteConfigs }); } @@ -635,7 +666,13 @@ export class MysteryEncounterBuilder implements Partial { return this; } - withIntro({ spriteConfigs, dialogue } : {spriteConfigs: MysteryEncounterSpriteConfig[], dialogue?: MysteryEncounterDialogue["intro"]}) { + withIntro({ + spriteConfigs, + dialogue, + }: { + spriteConfigs: MysteryEncounterSpriteConfig[]; + dialogue?: MysteryEncounterDialogue["intro"]; + }) { return this.withIntroSpriteConfigs(spriteConfigs).withIntroDialogue(dialogue); } @@ -676,8 +713,10 @@ export class MysteryEncounterBuilder implements Partial { * @param encounterAnimations * @returns */ - withAnimations(...encounterAnimations: EncounterAnim[]): this & Required> { - const animations = Array.isArray(encounterAnimations) ? encounterAnimations : [ encounterAnimations ]; + withAnimations( + ...encounterAnimations: EncounterAnim[] + ): this & Required> { + const animations = Array.isArray(encounterAnimations) ? encounterAnimations : [encounterAnimations]; return Object.assign(this, { encounterAnimations: animations }); } @@ -686,8 +725,10 @@ export class MysteryEncounterBuilder implements Partial { * @returns * @param disallowedGameModes */ - withDisallowedGameModes(...disallowedGameModes: GameModes[]): this & Required> { - const gameModes = Array.isArray(disallowedGameModes) ? disallowedGameModes : [ disallowedGameModes ]; + withDisallowedGameModes( + ...disallowedGameModes: GameModes[] + ): this & Required> { + const gameModes = Array.isArray(disallowedGameModes) ? disallowedGameModes : [disallowedGameModes]; return Object.assign(this, { disallowedGameModes: gameModes }); } @@ -696,8 +737,10 @@ export class MysteryEncounterBuilder implements Partial { * @returns * @param disallowedChallenges */ - withDisallowedChallenges(...disallowedChallenges: Challenges[]): this & Required> { - const challenges = Array.isArray(disallowedChallenges) ? disallowedChallenges : [ disallowedChallenges ]; + withDisallowedChallenges( + ...disallowedChallenges: Challenges[] + ): this & Required> { + const challenges = Array.isArray(disallowedChallenges) ? disallowedChallenges : [disallowedChallenges]; return Object.assign(this, { disallowedChallenges: challenges }); } @@ -707,7 +750,9 @@ export class MysteryEncounterBuilder implements Partial { * Default false * @param continuousEncounter */ - withContinuousEncounter(continuousEncounter: boolean): this & Required> { + withContinuousEncounter( + continuousEncounter: boolean, + ): this & Required> { return Object.assign(this, { continuousEncounter: continuousEncounter }); } @@ -717,7 +762,9 @@ export class MysteryEncounterBuilder implements Partial { * Default false * @param hasBattleAnimationsWithoutTargets */ - withBattleAnimationsWithoutTargets(hasBattleAnimationsWithoutTargets: boolean): this & Required> { + withBattleAnimationsWithoutTargets( + hasBattleAnimationsWithoutTargets: boolean, + ): this & Required> { return Object.assign(this, { hasBattleAnimationsWithoutTargets }); } @@ -727,7 +774,9 @@ export class MysteryEncounterBuilder implements Partial { * Default false * @param skipEnemyBattleTurns */ - withSkipEnemyBattleTurns(skipEnemyBattleTurns: boolean): this & Required> { + withSkipEnemyBattleTurns( + skipEnemyBattleTurns: boolean, + ): this & Required> { return Object.assign(this, { skipEnemyBattleTurns }); } @@ -744,7 +793,9 @@ export class MysteryEncounterBuilder implements Partial { * If true, will prevent updating {@linkcode GameStats} for encountering and/or defeating Pokemon * Default `false` */ - withPreventGameStatsUpdates(preventGameStatsUpdates: boolean): this & Required> { + withPreventGameStatsUpdates( + preventGameStatsUpdates: boolean, + ): this & Required> { return Object.assign(this, { preventGameStatsUpdates }); } @@ -753,7 +804,9 @@ export class MysteryEncounterBuilder implements Partial { * @param maxAllowedEncounters * @returns */ - withMaxAllowedEncounters(maxAllowedEncounters: number): this & Required> { + withMaxAllowedEncounters( + maxAllowedEncounters: number, + ): this & Required> { return Object.assign(this, { maxAllowedEncounters: maxAllowedEncounters }); } @@ -764,7 +817,9 @@ export class MysteryEncounterBuilder implements Partial { * @param requirement * @returns */ - withSceneRequirement(requirement: EncounterSceneRequirement): this & Required> { + withSceneRequirement( + requirement: EncounterSceneRequirement, + ): this & Required> { if (requirement instanceof EncounterPokemonRequirement) { Error("Incorrectly added pokemon requirement as scene requirement."); } @@ -780,7 +835,7 @@ export class MysteryEncounterBuilder implements Partial { * @returns */ withSceneWaveRangeRequirement(min: number, max?: number): this & Required> { - return this.withSceneRequirement(new WaveRangeRequirement([ min, max ?? min ])); + return this.withSceneRequirement(new WaveRangeRequirement([min, max ?? min])); } /** @@ -791,8 +846,12 @@ export class MysteryEncounterBuilder implements Partial { * @param excludeDisallowedPokemon if true, only counts allowed (legal in Challenge/unfainted) mons * @returns */ - withScenePartySizeRequirement(min: number, max?: number, excludeDisallowedPokemon: boolean = false): this & Required> { - return this.withSceneRequirement(new PartySizeRequirement([ min, max ?? min ], excludeDisallowedPokemon)); + withScenePartySizeRequirement( + min: number, + max?: number, + excludeDisallowedPokemon = false, + ): this & Required> { + return this.withSceneRequirement(new PartySizeRequirement([min, max ?? min], excludeDisallowedPokemon)); } /** @@ -801,13 +860,17 @@ export class MysteryEncounterBuilder implements Partial { * @param requirement {@linkcode EncounterPokemonRequirement} * @returns */ - withPrimaryPokemonRequirement(requirement: EncounterPokemonRequirement): this & Required> { + withPrimaryPokemonRequirement( + requirement: EncounterPokemonRequirement, + ): this & Required> { if (requirement instanceof EncounterSceneRequirement) { Error("Incorrectly added scene requirement as pokemon requirement."); } this.primaryPokemonRequirements.push(requirement); - return Object.assign(this, { primaryPokemonRequirements: this.primaryPokemonRequirements }); + return Object.assign(this, { + primaryPokemonRequirements: this.primaryPokemonRequirements, + }); } /** @@ -818,8 +881,14 @@ export class MysteryEncounterBuilder implements Partial { * @param invertQuery if true will invert the query * @returns */ - withPrimaryPokemonStatusEffectRequirement(statusEffect: StatusEffect | StatusEffect[], minNumberOfPokemon: number = 1, invertQuery: boolean = false): this & Required> { - return this.withPrimaryPokemonRequirement(new StatusEffectRequirement(statusEffect, minNumberOfPokemon, invertQuery)); + withPrimaryPokemonStatusEffectRequirement( + statusEffect: StatusEffect | StatusEffect[], + minNumberOfPokemon = 1, + invertQuery = false, + ): this & Required> { + return this.withPrimaryPokemonRequirement( + new StatusEffectRequirement(statusEffect, minNumberOfPokemon, invertQuery), + ); } /** @@ -830,21 +899,33 @@ export class MysteryEncounterBuilder implements Partial { * @param invertQuery if true will invert the query * @returns */ - withPrimaryPokemonHealthRatioRequirement(requiredHealthRange: [number, number], minNumberOfPokemon: number = 1, invertQuery: boolean = false): this & Required> { - return this.withPrimaryPokemonRequirement(new HealthRatioRequirement(requiredHealthRange, minNumberOfPokemon, invertQuery)); + withPrimaryPokemonHealthRatioRequirement( + requiredHealthRange: [number, number], + minNumberOfPokemon = 1, + invertQuery = false, + ): this & Required> { + return this.withPrimaryPokemonRequirement( + new HealthRatioRequirement(requiredHealthRange, minNumberOfPokemon, invertQuery), + ); } // TODO: Maybe add an optional parameter for excluding primary pokemon from the support cast? // ex. if your only grass type pokemon, a snivy, is chosen as primary, if the support pokemon requires a grass type, the event won't trigger because // it's already been - withSecondaryPokemonRequirement(requirement: EncounterPokemonRequirement, excludePrimaryFromSecondaryRequirements: boolean = false): this & Required> { + withSecondaryPokemonRequirement( + requirement: EncounterPokemonRequirement, + excludePrimaryFromSecondaryRequirements = false, + ): this & Required> { if (requirement instanceof EncounterSceneRequirement) { Error("Incorrectly added scene requirement as pokemon requirement."); } this.secondaryPokemonRequirements.push(requirement); this.excludePrimaryFromSupportRequirements = excludePrimaryFromSecondaryRequirements; - return Object.assign(this, { excludePrimaryFromSecondaryRequirements: this.excludePrimaryFromSupportRequirements, secondaryPokemonRequirements: this.secondaryPokemonRequirements }); + return Object.assign(this, { + excludePrimaryFromSecondaryRequirements: this.excludePrimaryFromSupportRequirements, + secondaryPokemonRequirements: this.secondaryPokemonRequirements, + }); } /** @@ -919,15 +1000,21 @@ export class MysteryEncounterBuilder implements Partial { * @param hideBattleIntroMessage If `true`, will not show the trainerAppeared/wildAppeared/bossAppeared message for an encounter * @returns */ - withHideWildIntroMessage(hideBattleIntroMessage: boolean): this & Required> { - return Object.assign(this, { hideBattleIntroMessage: hideBattleIntroMessage }); + withHideWildIntroMessage( + hideBattleIntroMessage: boolean, + ): this & Required> { + return Object.assign(this, { + hideBattleIntroMessage: hideBattleIntroMessage, + }); } /** * @param autoHideIntroVisuals If `false`, will not hide the intro visuals that are displayed at the beginning of encounter * @returns */ - withAutoHideIntroVisuals(autoHideIntroVisuals: boolean): this & Required> { + withAutoHideIntroVisuals( + autoHideIntroVisuals: boolean, + ): this & Required> { return Object.assign(this, { autoHideIntroVisuals: autoHideIntroVisuals }); } @@ -936,8 +1023,12 @@ export class MysteryEncounterBuilder implements Partial { * Default false * @returns */ - withEnterIntroVisualsFromRight(enterIntroVisualsFromRight: boolean): this & Required> { - return Object.assign(this, { enterIntroVisualsFromRight: enterIntroVisualsFromRight }); + withEnterIntroVisualsFromRight( + enterIntroVisualsFromRight: boolean, + ): this & Required> { + return Object.assign(this, { + enterIntroVisualsFromRight: enterIntroVisualsFromRight, + }); } /** @@ -954,7 +1045,7 @@ export class MysteryEncounterBuilder implements Partial { encounterOptionsDialogue: { ...encounterOptionsDialogue, title, - } + }, }; return this; @@ -974,7 +1065,7 @@ export class MysteryEncounterBuilder implements Partial { encounterOptionsDialogue: { ...encounterOptionsDialogue, description, - } + }, }; return this; @@ -994,7 +1085,7 @@ export class MysteryEncounterBuilder implements Partial { encounterOptionsDialogue: { ...encounterOptionsDialogue, query, - } + }, }; return this; diff --git a/src/data/mystery-encounters/mystery-encounters.ts b/src/data/mystery-encounters/mystery-encounters.ts index 3219640e4e5..354f69d0ca3 100644 --- a/src/data/mystery-encounters/mystery-encounters.ts +++ b/src/data/mystery-encounters/mystery-encounters.ts @@ -80,7 +80,7 @@ export const EXTREME_ENCOUNTER_BIOMES = [ Biome.WASTELAND, Biome.ABYSS, Biome.SPACE, - Biome.END + Biome.END, ]; export const NON_EXTREME_ENCOUNTER_BIOMES = [ @@ -108,7 +108,7 @@ export const NON_EXTREME_ENCOUNTER_BIOMES = [ Biome.SLUM, Biome.SNOWY_FOREST, Biome.ISLAND, - Biome.LABORATORY + Biome.LABORATORY, ]; /** @@ -147,7 +147,7 @@ export const HUMAN_TRANSITABLE_BIOMES = [ Biome.SLUM, Biome.SNOWY_FOREST, Biome.ISLAND, - Biome.LABORATORY + Biome.LABORATORY, ]; /** @@ -168,11 +168,12 @@ export const CIVILIZATION_ENCOUNTER_BIOMES = [ Biome.FACTORY, Biome.CONSTRUCTION_SITE, Biome.SLUM, - Biome.ISLAND + Biome.ISLAND, ]; -export const allMysteryEncounters: { [encounterType: number]: MysteryEncounter } = {}; - +export const allMysteryEncounters: { + [encounterType: number]: MysteryEncounter; +} = {}; const extremeBiomeEncounters: MysteryEncounterType[] = []; @@ -187,14 +188,14 @@ const humanTransitableBiomeEncounters: MysteryEncounterType[] = [ MysteryEncounterType.THE_POKEMON_SALESMAN, // MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, Disabled MysteryEncounterType.THE_WINSTRATE_CHALLENGE, - MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER + MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER, ]; const civilizationBiomeEncounters: MysteryEncounterType[] = [ MysteryEncounterType.DEPARTMENT_STORE_SALE, MysteryEncounterType.PART_TIMER, MysteryEncounterType.FUN_AND_GAMES, - MysteryEncounterType.GLOBAL_TRADE_SYSTEM + MysteryEncounterType.GLOBAL_TRADE_SYSTEM, ]; /** @@ -213,7 +214,7 @@ const anyBiomeEncounters: MysteryEncounterType[] = [ MysteryEncounterType.WEIRD_DREAM, MysteryEncounterType.TELEPORTING_HIJINKS, MysteryEncounterType.BUG_TYPE_SUPERFAN, - MysteryEncounterType.UNCOMMON_BREED + MysteryEncounterType.UNCOMMON_BREED, ]; /** @@ -224,72 +225,40 @@ const anyBiomeEncounters: MysteryEncounterType[] = [ * that biome groups do not cover */ export const mysteryEncountersByBiome = new Map([ - [ Biome.TOWN, []], - [ Biome.PLAINS, [ - MysteryEncounterType.SLUMBERING_SNORLAX, - MysteryEncounterType.ABSOLUTE_AVARICE - ]], - [ Biome.GRASS, [ - MysteryEncounterType.SLUMBERING_SNORLAX, - MysteryEncounterType.ABSOLUTE_AVARICE - ]], - [ Biome.TALL_GRASS, [ - MysteryEncounterType.ABSOLUTE_AVARICE - ]], - [ Biome.METROPOLIS, []], - [ Biome.FOREST, [ - MysteryEncounterType.SAFARI_ZONE, - MysteryEncounterType.ABSOLUTE_AVARICE - ]], - [ Biome.SEA, [ - MysteryEncounterType.LOST_AT_SEA - ]], - [ Biome.SWAMP, [ - MysteryEncounterType.SAFARI_ZONE - ]], - [ Biome.BEACH, []], - [ Biome.LAKE, []], - [ Biome.SEABED, []], - [ Biome.MOUNTAIN, []], - [ Biome.BADLANDS, [ - MysteryEncounterType.DANCING_LESSONS - ]], - [ Biome.CAVE, [ - MysteryEncounterType.THE_STRONG_STUFF - ]], - [ Biome.DESERT, [ - MysteryEncounterType.DANCING_LESSONS - ]], - [ Biome.ICE_CAVE, []], - [ Biome.MEADOW, []], - [ Biome.POWER_PLANT, []], - [ Biome.VOLCANO, [ - MysteryEncounterType.FIERY_FALLOUT, - MysteryEncounterType.DANCING_LESSONS - ]], - [ Biome.GRAVEYARD, []], - [ Biome.DOJO, []], - [ Biome.FACTORY, []], - [ Biome.RUINS, []], - [ Biome.WASTELAND, [ - MysteryEncounterType.DANCING_LESSONS - ]], - [ Biome.ABYSS, [ - MysteryEncounterType.DANCING_LESSONS - ]], - [ Biome.SPACE, [ - MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER - ]], - [ Biome.CONSTRUCTION_SITE, []], - [ Biome.JUNGLE, [ - MysteryEncounterType.SAFARI_ZONE - ]], - [ Biome.FAIRY_CAVE, []], - [ Biome.TEMPLE, []], - [ Biome.SLUM, []], - [ Biome.SNOWY_FOREST, []], - [ Biome.ISLAND, []], - [ Biome.LABORATORY, []] + [Biome.TOWN, []], + [Biome.PLAINS, [MysteryEncounterType.SLUMBERING_SNORLAX, MysteryEncounterType.ABSOLUTE_AVARICE]], + [Biome.GRASS, [MysteryEncounterType.SLUMBERING_SNORLAX, MysteryEncounterType.ABSOLUTE_AVARICE]], + [Biome.TALL_GRASS, [MysteryEncounterType.ABSOLUTE_AVARICE]], + [Biome.METROPOLIS, []], + [Biome.FOREST, [MysteryEncounterType.SAFARI_ZONE, MysteryEncounterType.ABSOLUTE_AVARICE]], + [Biome.SEA, [MysteryEncounterType.LOST_AT_SEA]], + [Biome.SWAMP, [MysteryEncounterType.SAFARI_ZONE]], + [Biome.BEACH, []], + [Biome.LAKE, []], + [Biome.SEABED, []], + [Biome.MOUNTAIN, []], + [Biome.BADLANDS, [MysteryEncounterType.DANCING_LESSONS]], + [Biome.CAVE, [MysteryEncounterType.THE_STRONG_STUFF]], + [Biome.DESERT, [MysteryEncounterType.DANCING_LESSONS]], + [Biome.ICE_CAVE, []], + [Biome.MEADOW, []], + [Biome.POWER_PLANT, []], + [Biome.VOLCANO, [MysteryEncounterType.FIERY_FALLOUT, MysteryEncounterType.DANCING_LESSONS]], + [Biome.GRAVEYARD, []], + [Biome.DOJO, []], + [Biome.FACTORY, []], + [Biome.RUINS, []], + [Biome.WASTELAND, [MysteryEncounterType.DANCING_LESSONS]], + [Biome.ABYSS, [MysteryEncounterType.DANCING_LESSONS]], + [Biome.SPACE, [MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER]], + [Biome.CONSTRUCTION_SITE, []], + [Biome.JUNGLE, [MysteryEncounterType.SAFARI_ZONE]], + [Biome.FAIRY_CAVE, []], + [Biome.TEMPLE, []], + [Biome.SLUM, []], + [Biome.SNOWY_FOREST, []], + [Biome.ISLAND, []], + [Biome.LABORATORY, []], ]); export function initMysteryEncounters() { @@ -364,7 +333,7 @@ export function initMysteryEncounters() { // Add ANY biome encounters to biome map // eslint-disable-next-line - let encounterBiomeTableLog = ""; + let _encounterBiomeTableLog = ""; mysteryEncountersByBiome.forEach((biomeEncounters, biome) => { anyBiomeEncounters.forEach(encounter => { if (!biomeEncounters.includes(encounter)) { @@ -372,7 +341,10 @@ export function initMysteryEncounters() { } }); - encounterBiomeTableLog += `${getBiomeName(biome).toUpperCase()}: [${biomeEncounters.map(type => MysteryEncounterType[type].toString().toLowerCase()).sort().join(", ")}]\n`; + _encounterBiomeTableLog += `${getBiomeName(biome).toUpperCase()}: [${biomeEncounters + .map(type => MysteryEncounterType[type].toString().toLowerCase()) + .sort() + .join(", ")}]\n`; }); //console.debug("All Mystery Encounters by Biome:\n" + encounterBiomeTableLog); 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 3d454269204..a7ffe3e26ca 100644 --- a/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts +++ b/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts @@ -29,7 +29,7 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement { constructor(requiredMoves: Moves | Moves[], options: CanLearnMoveRequirementOptions = {}) { super(); - this.requiredMoves = Array.isArray(requiredMoves) ? requiredMoves : [ requiredMoves ]; + this.requiredMoves = Array.isArray(requiredMoves) ? requiredMoves : [requiredMoves]; this.excludeLevelMoves = options.excludeLevelMoves ?? false; this.excludeTmMoves = options.excludeTmMoves ?? false; @@ -40,7 +40,9 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement { } override meetsRequirement(): boolean { - const partyPokemon = globalScene.getPlayerParty().filter((pkm) => (this.includeFainted ? pkm.isAllowedInChallenge() : pkm.isAllowedInBattle())); + const partyPokemon = globalScene + .getPlayerParty() + .filter(pkm => (this.includeFainted ? pkm.isAllowedInChallenge() : pkm.isAllowedInBattle())); if (isNullOrUndefined(partyPokemon) || this.requiredMoves?.length < 0) { return false; @@ -51,25 +53,24 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement { override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] { if (!this.invertQuery) { - return partyPokemon.filter((pokemon) => + return partyPokemon.filter(pokemon => // every required move should be included - this.requiredMoves.every((requiredMove) => this.getAllPokemonMoves(pokemon).includes(requiredMove)) - ); - } else { - return partyPokemon.filter( - (pokemon) => - // none of the "required" moves should be included - !this.requiredMoves.some((requiredMove) => this.getAllPokemonMoves(pokemon).includes(requiredMove)) + this.requiredMoves.every(requiredMove => this.getAllPokemonMoves(pokemon).includes(requiredMove)), ); } + return partyPokemon.filter( + pokemon => + // none of the "required" moves should be included + !this.requiredMoves.some(requiredMove => this.getAllPokemonMoves(pokemon).includes(requiredMove)), + ); } override getDialogueToken(__pokemon?: PlayerPokemon): [string, string] { - return [ "requiredMoves", this.requiredMoves.map(m => new PokemonMove(m).getName()).join(", ") ]; + return ["requiredMoves", this.requiredMoves.map(m => new PokemonMove(m).getName()).join(", ")]; } private getPokemonLevelMoves(pkm: PlayerPokemon): Moves[] { - return pkm.getLevelMoves().map(([ _level, move ]) => move); + return pkm.getLevelMoves().map(([_level, move]) => move); } private getAllPokemonMoves(pkm: PlayerPokemon): Moves[] { diff --git a/src/data/mystery-encounters/requirements/requirement-groups.ts b/src/data/mystery-encounters/requirements/requirement-groups.ts index 76bbb8f03a7..d9d62819fa6 100644 --- a/src/data/mystery-encounters/requirements/requirement-groups.ts +++ b/src/data/mystery-encounters/requirements/requirement-groups.ts @@ -4,14 +4,7 @@ import { Abilities } from "#enums/abilities"; /** * Moves that "steal" things */ -export const STEALING_MOVES = [ - Moves.PLUCK, - Moves.COVET, - Moves.KNOCK_OFF, - Moves.THIEF, - Moves.TRICK, - Moves.SWITCHEROO -]; +export const STEALING_MOVES = [Moves.PLUCK, Moves.COVET, Moves.KNOCK_OFF, Moves.THIEF, Moves.TRICK, Moves.SWITCHEROO]; /** * Moves that "charm" someone @@ -24,7 +17,7 @@ export const CHARMING_MOVES = [ Moves.ATTRACT, Moves.SWEET_SCENT, Moves.CAPTIVATE, - Moves.AROMATIC_MIST + Moves.AROMATIC_MIST, ]; /** @@ -42,7 +35,7 @@ export const DANCING_MOVES = [ Moves.QUIVER_DANCE, Moves.SWORDS_DANCE, Moves.TEETER_DANCE, - Moves.VICTORY_DANCE + Moves.VICTORY_DANCE, ]; /** @@ -60,7 +53,7 @@ export const DISTRACTION_MOVES = [ Moves.CAPTIVATE, Moves.RAGE_POWDER, Moves.SUBSTITUTE, - Moves.SHED_TAIL + Moves.SHED_TAIL, ]; /** @@ -79,7 +72,7 @@ export const PROTECTING_MOVES = [ Moves.CRAFTY_SHIELD, Moves.SPIKY_SHIELD, Moves.OBSTRUCT, - Moves.DETECT + Moves.DETECT, ]; /** @@ -116,7 +109,7 @@ export const EXTORTION_ABILITIES = [ Abilities.ARENA_TRAP, Abilities.SHADOW_TAG, Abilities.SUCTION_CUPS, - Abilities.STICKY_HOLD + Abilities.STICKY_HOLD, ]; /** @@ -133,5 +126,5 @@ export const FIRE_RESISTANT_ABILITIES = [ Abilities.MAGMA_ARMOR, Abilities.WATER_VEIL, Abilities.STEAM_ENGINE, - Abilities.PRIMORDIAL_SEA + Abilities.PRIMORDIAL_SEA, ]; diff --git a/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts b/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts index df9b6355017..94790145687 100644 --- a/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-dialogue-utils.ts @@ -63,7 +63,13 @@ export function queueEncounterMessage(contentKey: string): void { * @param callbackDelay * @param promptDelay */ -export function showEncounterText(contentKey: string, delay: number | null = null, callbackDelay: number = 0, prompt: boolean = true, promptDelay: number | null = null): Promise { +export function showEncounterText( + contentKey: string, + delay: number | null = null, + callbackDelay = 0, + prompt = true, + promptDelay: number | null = null, +): Promise { return new Promise(resolve => { const text: string | null = getEncounterText(contentKey); globalScene.ui.showText(text ?? "", delay, () => resolve(), callbackDelay, prompt, promptDelay); @@ -78,7 +84,12 @@ export function showEncounterText(contentKey: string, delay: number | null = nul * @param speakerContentKey * @param callbackDelay */ -export function showEncounterDialogue(textContentKey: string, speakerContentKey: string, delay: number | null = null, callbackDelay: number = 0): Promise { +export function showEncounterDialogue( + textContentKey: string, + speakerContentKey: string, + delay: number | null = null, + callbackDelay = 0, +): Promise { return new Promise(resolve => { const text: string | null = getEncounterText(textContentKey); const speaker: string | null = getEncounterText(speakerContentKey); diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index a6ca236f735..d37ac340a7c 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -2,14 +2,29 @@ import type Battle from "#app/battle"; import { BattlerIndex, BattleType } from "#app/battle"; import { biomeLinks, BiomePoolTier } from "#app/data/balance/biomes"; import type MysteryEncounterOption from "#app/data/mystery-encounters/mystery-encounter-option"; -import { AVERAGE_ENCOUNTERS_PER_RUN_TARGET, WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters"; +import { + AVERAGE_ENCOUNTERS_PER_RUN_TARGET, + WEIGHT_INCREMENT_ON_SPAWN_MISS, +} from "#app/data/mystery-encounters/mystery-encounters"; import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import type { AiType, PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon, FieldPosition, PokemonMove, PokemonSummonData } from "#app/field/pokemon"; import type { CustomModifierSettings, ModifierType } from "#app/modifier/modifier-type"; -import { getPartyLuckValue, ModifierPoolType, ModifierTypeGenerator, ModifierTypeOption, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; -import { MysteryEncounterBattlePhase, MysteryEncounterBattleStartCleanupPhase, MysteryEncounterPhase, MysteryEncounterRewardsPhase } from "#app/phases/mystery-encounter-phases"; +import { + getPartyLuckValue, + ModifierPoolType, + ModifierTypeGenerator, + ModifierTypeOption, + modifierTypes, + regenerateModifierPoolThresholds, +} from "#app/modifier/modifier-type"; +import { + MysteryEncounterBattlePhase, + MysteryEncounterBattleStartCleanupPhase, + MysteryEncounterPhase, + MysteryEncounterRewardsPhase, +} from "#app/phases/mystery-encounter-phases"; 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"; @@ -71,7 +86,7 @@ export function doTrainerExclamation() { globalScene.time.delayedCall(800, () => { globalScene.field.remove(exclamationSprite, true); }); - } + }, }); globalScene.playSound("battle_anims/GEN8- Exclaim", { volume: 0.7 }); @@ -151,8 +166,15 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): const doubleTrainer = trainerConfig.doubleOnly || (trainerConfig.hasDouble && !!partyConfig.doubleBattle); doubleBattle = doubleTrainer; - const trainerFemale = isNullOrUndefined(partyConfig.female) ? !!(Utils.randSeedInt(2)) : partyConfig.female; - const newTrainer = new Trainer(trainerConfig.trainerType, doubleTrainer ? TrainerVariant.DOUBLE : trainerFemale ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, undefined, undefined, undefined, trainerConfig); + const trainerFemale = isNullOrUndefined(partyConfig.female) ? !!Utils.randSeedInt(2) : partyConfig.female; + const newTrainer = new Trainer( + trainerConfig.trainerType, + doubleTrainer ? TrainerVariant.DOUBLE : trainerFemale ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT, + undefined, + undefined, + undefined, + trainerConfig, + ); newTrainer.x += 300; newTrainer.setVisible(false); globalScene.field.add(newTrainer); @@ -163,7 +185,12 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): } else { // Wild globalScene.currentBattle.mysteryEncounter!.encounterMode = MysteryEncounterMode.WILD_BATTLE; - const numEnemies = partyConfig?.pokemonConfigs && partyConfig.pokemonConfigs.length > 0 ? partyConfig?.pokemonConfigs?.length : doubleBattle ? 2 : 1; + const numEnemies = + partyConfig?.pokemonConfigs && partyConfig.pokemonConfigs.length > 0 + ? partyConfig?.pokemonConfigs?.length + : doubleBattle + ? 2 + : 1; battle.enemyLevels = new Array(numEnemies).fill(null).map(() => globalScene.currentBattle.getLevelForWave()); } @@ -183,8 +210,8 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): battle.enemyLevels = battle.enemyLevels.map(level => level + additive); battle.enemyLevels.forEach((level, e) => { - let enemySpecies; - let dataSource; + let enemySpecies: PokemonSpecies | undefined; + let dataSource: PokemonData | undefined; let isBoss = false; if (!loaded) { if ((!isNullOrUndefined(trainerType) || trainerConfig) && battle.trainer) { @@ -195,7 +222,14 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): dataSource = config.dataSource; enemySpecies = config.species; isBoss = config.isBoss; - battle.enemyParty[e] = globalScene.addEnemyPokemon(enemySpecies, level, TrainerSlot.TRAINER, isBoss, false, dataSource); + battle.enemyParty[e] = globalScene.addEnemyPokemon( + enemySpecies, + level, + TrainerSlot.TRAINER, + isBoss, + false, + dataSource, + ); } else { battle.enemyParty[e] = battle.trainer.genPartyMember(e); } @@ -213,7 +247,14 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): enemySpecies = globalScene.randomSpecies(battle.waveIndex, level, true); } - battle.enemyParty[e] = globalScene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, isBoss, false, dataSource); + battle.enemyParty[e] = globalScene.addEnemyPokemon( + enemySpecies, + level, + TrainerSlot.NONE, + isBoss, + false, + dataSource, + ); } } @@ -229,7 +270,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): enemyPokemon.resetSummonData(); } - if (!loaded && isNullOrUndefined(partyConfig.countAsSeen) || partyConfig.countAsSeen) { + if ((!loaded && isNullOrUndefined(partyConfig.countAsSeen)) || partyConfig.countAsSeen) { globalScene.gameData.setPokemonSeen(enemyPokemon, true, !!(trainerType || trainerConfig)); } @@ -268,7 +309,9 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): // Set Boss if (config.isBoss) { - let segments = !isNullOrUndefined(config.bossSegments) ? config.bossSegments! : globalScene.getEncounterBossSegments(globalScene.currentBattle.waveIndex, level, enemySpecies, true); + let segments = !isNullOrUndefined(config.bossSegments) + ? config.bossSegments! + : globalScene.getEncounterBossSegments(globalScene.currentBattle.waveIndex, level, enemySpecies, true); if (!isNullOrUndefined(config.bossSegmentModifier)) { segments += config.bossSegmentModifier; } @@ -295,7 +338,11 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): if (statusEffects) { // Default to cureturn 3 for sleep const status = Array.isArray(statusEffects) ? statusEffects[0] : statusEffects; - const cureTurn = Array.isArray(statusEffects) ? statusEffects[1] : statusEffects === StatusEffect.SLEEP ? 3 : undefined; + const cureTurn = Array.isArray(statusEffects) + ? statusEffects[1] + : statusEffects === StatusEffect.SLEEP + ? 3 + : undefined; enemyPokemon.status = new Status(status, 0, cureTurn); } @@ -368,7 +415,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): ` Spd: ${enemyPokemon.stats[5]} (${enemyPokemon.ivs[5]})`, ]; const moveset: string[] = []; - enemyPokemon.getMoveset().forEach((move) => { + enemyPokemon.getMoveset().forEach(move => { moveset.push(move!.getName()); // TODO: remove `!` after moveset-null removal PR }); @@ -381,7 +428,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): console.log( `Ability: ${enemyPokemon.getAbility().name}`, `| Passive Ability${enemyPokemon.hasPassive() ? "" : " (inactive)"}: ${enemyPokemon.getPassiveAbility().name}`, - `${enemyPokemon.isBoss() ? `| Boss Bars: ${enemyPokemon.bossSegments}` : ""}` + `${enemyPokemon.isBoss() ? `| Boss Bars: ${enemyPokemon.bossSegments}` : ""}`, ); console.log("Moveset:", moveset); }); @@ -400,7 +447,10 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): } }); if (!loaded) { - regenerateModifierPoolThresholds(globalScene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD); + regenerateModifierPoolThresholds( + globalScene.getEnemyField(), + battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD, + ); const customModifierTypes = partyConfig?.pokemonConfigs ?.filter(config => config?.modifierConfigs) .map(config => config.modifierConfigs!); @@ -416,9 +466,8 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): * @param moves */ export function loadCustomMovesForEncounter(moves: Moves | Moves[]) { - moves = Array.isArray(moves) ? moves : [ moves ]; - return Promise.all(moves.map(move => initMoveAnim(move))) - .then(() => loadMoveAnimAssets(moves)); + moves = Array.isArray(moves) ? moves : [moves]; + return Promise.all(moves.map(move => initMoveAnim(move))).then(() => loadMoveAnimAssets(moves)); } /** @@ -427,7 +476,7 @@ export function loadCustomMovesForEncounter(moves: Moves | Moves[]) { * @param playSound * @param showMessage */ -export function updatePlayerMoney(changeValue: number, playSound: boolean = true, showMessage: boolean = true) { +export function updatePlayerMoney(changeValue: number, playSound = true, showMessage = true) { globalScene.money = Math.min(Math.max(globalScene.money + changeValue, 0), Number.MAX_SAFE_INTEGER); globalScene.updateMoneyText(); globalScene.animateMoneyChanged(false); @@ -436,9 +485,21 @@ export function updatePlayerMoney(changeValue: number, playSound: boolean = true } if (showMessage) { if (changeValue < 0) { - globalScene.queueMessage(i18next.t("mysteryEncounterMessages:paid_money", { amount: -changeValue }), null, true); + globalScene.queueMessage( + i18next.t("mysteryEncounterMessages:paid_money", { + amount: -changeValue, + }), + null, + true, + ); } else { - globalScene.queueMessage(i18next.t("mysteryEncounterMessages:receive_money", { amount: changeValue }), null, true); + globalScene.queueMessage( + i18next.t("mysteryEncounterMessages:receive_money", { + amount: changeValue, + }), + null, + true, + ); } } } @@ -461,7 +522,9 @@ export function generateModifierType(modifier: () => ModifierType, pregenArgs?: .withIdFromFunc(modifierTypes[modifierId]) .withTierFromPool(ModifierPoolType.PLAYER, globalScene.getPlayerParty()); - return result instanceof ModifierTypeGenerator ? result.generateType(globalScene.getPlayerParty(), pregenArgs) : result; + return result instanceof ModifierTypeGenerator + ? result.generateType(globalScene.getPlayerParty(), pregenArgs) + : result; } /** @@ -469,7 +532,10 @@ export function generateModifierType(modifier: () => ModifierType, pregenArgs?: * @param modifier * @param pregenArgs - can specify BerryType for berries, TM for TMs, AttackBoostType for item, etc. */ -export function generateModifierTypeOption(modifier: () => ModifierType, pregenArgs?: any[]): ModifierTypeOption | null { +export function generateModifierTypeOption( + modifier: () => ModifierType, + pregenArgs?: any[], +): ModifierTypeOption | null { const result = generateModifierType(modifier, pregenArgs); if (result) { return new ModifierTypeOption(result, 0); @@ -484,80 +550,100 @@ export function generateModifierTypeOption(modifier: () => ModifierType, pregenA * @param onPokemonNotSelected - Any logic that needs to be performed if no Pokemon is chosen * @param selectablePokemonFilter */ -export function selectPokemonForOption(onPokemonSelected: (pokemon: PlayerPokemon) => void | OptionSelectItem[], onPokemonNotSelected?: () => void, selectablePokemonFilter?: PokemonSelectFilter): Promise { +export function selectPokemonForOption( + // biome-ignore lint/suspicious/noConfusingVoidType: Takes a function that either returns void or an array of OptionSelectItem + onPokemonSelected: (pokemon: PlayerPokemon) => void | OptionSelectItem[], + onPokemonNotSelected?: () => void, + selectablePokemonFilter?: PokemonSelectFilter, +): Promise { return new Promise(resolve => { const modeToSetOnExit = globalScene.ui.getMode(); // Open party screen to choose pokemon - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => { - if (slotIndex < globalScene.getPlayerParty().length) { - globalScene.ui.setMode(modeToSetOnExit).then(() => { - const pokemon = globalScene.getPlayerParty()[slotIndex]; - const secondaryOptions = onPokemonSelected(pokemon); - if (!secondaryOptions) { - globalScene.currentBattle.mysteryEncounter!.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); - resolve(true); - return; - } + globalScene.ui.setMode( + Mode.PARTY, + PartyUiMode.SELECT, + -1, + (slotIndex: number, _option: PartyOption) => { + if (slotIndex < globalScene.getPlayerParty().length) { + globalScene.ui.setMode(modeToSetOnExit).then(() => { + const pokemon = globalScene.getPlayerParty()[slotIndex]; + const secondaryOptions = onPokemonSelected(pokemon); + if (!secondaryOptions) { + globalScene.currentBattle.mysteryEncounter!.setDialogueToken( + "selectedPokemon", + pokemon.getNameToRender(), + ); + resolve(true); + return; + } - // There is a second option to choose after selecting the Pokemon - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - const displayOptions = () => { - // Always appends a cancel option to bottom of options - const fullOptions = secondaryOptions.map(option => { - // Update handler to resolve promise - const onSelect = option.handler; - option.handler = () => { - onSelect(); - globalScene.currentBattle.mysteryEncounter!.setDialogueToken("selectedPokemon", pokemon.getNameToRender()); - resolve(true); - return true; + // There is a second option to choose after selecting the Pokemon + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + const displayOptions = () => { + // Always appends a cancel option to bottom of options + const fullOptions = secondaryOptions + .map(option => { + // Update handler to resolve promise + const onSelect = option.handler; + option.handler = () => { + onSelect(); + globalScene.currentBattle.mysteryEncounter!.setDialogueToken( + "selectedPokemon", + pokemon.getNameToRender(), + ); + resolve(true); + return true; + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), + handler: () => { + globalScene.ui.clearText(); + globalScene.ui.setMode(modeToSetOnExit); + resolve(false); + return true; + }, + onHover: () => { + showEncounterText(i18next.t("mysteryEncounterMessages:cancel_option"), 0, 0, false); + }, + }); + + const config: OptionSelectConfig = { + options: fullOptions, + maxOptions: 7, + yOffset: 0, + supportHover: true, }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - globalScene.ui.clearText(); - globalScene.ui.setMode(modeToSetOnExit); - resolve(false); - return true; - }, - onHover: () => { - showEncounterText(i18next.t("mysteryEncounterMessages:cancel_option"), 0, 0, false); - } - }); - const config: OptionSelectConfig = { - options: fullOptions, - maxOptions: 7, - yOffset: 0, - supportHover: true + // Do hover over the starting selection option + if (fullOptions[0].onHover) { + fullOptions[0].onHover(); + } + globalScene.ui.setModeWithoutClear(Mode.OPTION_SELECT, config, null, true); }; - // Do hover over the starting selection option - if (fullOptions[0].onHover) { - fullOptions[0].onHover(); + const textPromptKey = + globalScene.currentBattle.mysteryEncounter?.selectedOption?.dialogue?.secondOptionPrompt; + if (!textPromptKey) { + displayOptions(); + } else { + showEncounterText(textPromptKey).then(() => displayOptions()); } - globalScene.ui.setModeWithoutClear(Mode.OPTION_SELECT, config, null, true); - }; - - const textPromptKey = globalScene.currentBattle.mysteryEncounter?.selectedOption?.dialogue?.secondOptionPrompt; - if (!textPromptKey) { - displayOptions(); - } else { - showEncounterText(textPromptKey).then(() => displayOptions()); - } + }); }); - }); - } else { - globalScene.ui.setMode(modeToSetOnExit).then(() => { - if (onPokemonNotSelected) { - onPokemonNotSelected(); - } - resolve(false); - }); - } - }, selectablePokemonFilter); + } else { + globalScene.ui.setMode(modeToSetOnExit).then(() => { + if (onPokemonNotSelected) { + onPokemonNotSelected(); + } + resolve(false); + }); + } + }, + selectablePokemonFilter, + ); }); } @@ -575,7 +661,12 @@ interface PokemonAndOptionSelected { * @param selectablePokemonFilter * @param onHoverOverCancelOption */ -export function selectOptionThenPokemon(options: OptionSelectItem[], optionSelectPromptKey: string, selectablePokemonFilter?: PokemonSelectFilter, onHoverOverCancelOption?: () => void): Promise { +export function selectOptionThenPokemon( + options: OptionSelectItem[], + optionSelectPromptKey: string, + selectablePokemonFilter?: PokemonSelectFilter, + onHoverOverCancelOption?: () => void, +): Promise { return new Promise(resolve => { const modeToSetOnExit = globalScene.ui.getMode(); @@ -601,51 +692,62 @@ export function selectOptionThenPokemon(options: OptionSelectItem[], optionSelec const selectPokemonAfterOption = (selectedOptionIndex: number) => { // Open party screen to choose a Pokemon - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.SELECT, -1, (slotIndex: number, option: PartyOption) => { - if (slotIndex < globalScene.getPlayerParty().length) { - // Pokemon and option selected - globalScene.ui.setMode(modeToSetOnExit).then(() => { - const result: PokemonAndOptionSelected = { selectedPokemonIndex: slotIndex, selectedOptionIndex: selectedOptionIndex }; - resolve(result); - }); - } else { - // Back to first option select screen - displayOptions(config); - } - }, selectablePokemonFilter); + globalScene.ui.setMode( + Mode.PARTY, + PartyUiMode.SELECT, + -1, + (slotIndex: number, _option: PartyOption) => { + if (slotIndex < globalScene.getPlayerParty().length) { + // Pokemon and option selected + globalScene.ui.setMode(modeToSetOnExit).then(() => { + const result: PokemonAndOptionSelected = { + selectedPokemonIndex: slotIndex, + selectedOptionIndex: selectedOptionIndex, + }; + resolve(result); + }); + } else { + // Back to first option select screen + displayOptions(config); + } + }, + selectablePokemonFilter, + ); }; // Always appends a cancel option to bottom of options - const fullOptions = options.map((option, index) => { - // Update handler to resolve promise - const onSelect = option.handler; - option.handler = () => { - onSelect(); - selectPokemonAfterOption(index); - return true; - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - globalScene.ui.clearText(); - globalScene.ui.setMode(modeToSetOnExit); - resolve(null); - return true; - }, - onHover: () => { - if (onHoverOverCancelOption) { - onHoverOverCancelOption(); - } - showEncounterText(i18next.t("mysteryEncounterMessages:cancel_option"), 0, 0, false); - } - }); + const fullOptions = options + .map((option, index) => { + // Update handler to resolve promise + const onSelect = option.handler; + option.handler = () => { + onSelect(); + selectPokemonAfterOption(index); + return true; + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), + handler: () => { + globalScene.ui.clearText(); + globalScene.ui.setMode(modeToSetOnExit); + resolve(null); + return true; + }, + onHover: () => { + if (onHoverOverCancelOption) { + onHoverOverCancelOption(); + } + showEncounterText(i18next.t("mysteryEncounterMessages:cancel_option"), 0, 0, false); + }, + }); const config: OptionSelectConfig = { options: fullOptions, maxOptions: 7, yOffset: 0, - supportHover: true + supportHover: true, }; displayOptions(config); @@ -659,7 +761,11 @@ export function selectOptionThenPokemon(options: OptionSelectItem[], optionSelec * @param eggRewards * @param preRewardsCallback - can execute an arbitrary callback before the new phases if necessary (useful for updating items/party/injecting new phases before {@linkcode MysteryEncounterRewardsPhase}) */ -export function setEncounterRewards(customShopRewards?: CustomModifierSettings, eggRewards?: IEggOptions[], preRewardsCallback?: Function) { +export function setEncounterRewards( + customShopRewards?: CustomModifierSettings, + eggRewards?: IEggOptions[], + preRewardsCallback?: Function, +) { globalScene.currentBattle.mysteryEncounter!.doEncounterRewards = () => { if (preRewardsCallback) { preRewardsCallback(); @@ -702,8 +808,8 @@ export function setEncounterRewards(customShopRewards?: CustomModifierSettings, * https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_effort_value_yield_(Generation_IX) * @param useWaveIndex - set to false when directly passing the the full exp value instead of baseExpValue */ -export function setEncounterExp(participantId: number | number[], baseExpValue: number, useWaveIndex: boolean = true) { - const participantIds = Array.isArray(participantId) ? participantId : [ participantId ]; +export function setEncounterExp(participantId: number | number[], baseExpValue: number, useWaveIndex = true) { + const participantIds = Array.isArray(participantId) ? participantId : [participantId]; globalScene.currentBattle.mysteryEncounter!.doEncounterExp = () => { globalScene.unshiftPhase(new PartyExpPhase(baseExpValue, useWaveIndex, new Set(participantIds))); @@ -737,7 +843,10 @@ export function initSubsequentOptionSelect(optionSelectSettings: OptionSelectSet * @param addHealPhase - when true, will add a shop phase to end of encounter with 0 rewards but healing items are available * @param encounterMode - Can set custom encounter mode if necessary (may be required for forcing Pokemon to return before next phase) */ -export function leaveEncounterWithoutBattle(addHealPhase: boolean = false, encounterMode: MysteryEncounterMode = MysteryEncounterMode.NO_BATTLE) { +export function leaveEncounterWithoutBattle( + addHealPhase = false, + encounterMode: MysteryEncounterMode = MysteryEncounterMode.NO_BATTLE, +) { globalScene.currentBattle.mysteryEncounter!.encounterMode = encounterMode; globalScene.clearPhaseQueue(); globalScene.clearPhaseQueueSplice(); @@ -749,8 +858,8 @@ export function leaveEncounterWithoutBattle(addHealPhase: boolean = false, encou * @param addHealPhase - Adds an empty shop phase to allow player to purchase healing items * @param doNotContinue - default `false`. If set to true, will not end the battle and continue to next wave */ -export function handleMysteryEncounterVictory(addHealPhase: boolean = false, doNotContinue: boolean = false) { - const allowedPkm = globalScene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle()); +export function handleMysteryEncounterVictory(addHealPhase = false, doNotContinue = false) { + const allowedPkm = globalScene.getPlayerParty().filter(pkm => pkm.isAllowedInBattle()); if (allowedPkm.length === 0) { globalScene.clearPhaseQueue(); @@ -763,10 +872,17 @@ export function handleMysteryEncounterVictory(addHealPhase: boolean = false, doN const encounter = globalScene.currentBattle.mysteryEncounter!; if (encounter.continuousEncounter || doNotContinue) { return; - } else if (encounter.encounterMode === MysteryEncounterMode.NO_BATTLE) { + } + if (encounter.encounterMode === MysteryEncounterMode.NO_BATTLE) { globalScene.pushPhase(new MysteryEncounterRewardsPhase(addHealPhase)); globalScene.pushPhase(new EggLapsePhase()); - } else if (!globalScene.getEnemyParty().find(p => encounter.encounterMode !== MysteryEncounterMode.TRAINER_BATTLE ? p.isOnField() : !p?.isFainted(true))) { + } else if ( + !globalScene + .getEnemyParty() + .find(p => + encounter.encounterMode !== MysteryEncounterMode.TRAINER_BATTLE ? p.isOnField() : !p?.isFainted(true), + ) + ) { globalScene.pushPhase(new BattleEndPhase(true)); if (encounter.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) { globalScene.pushPhase(new TrainerVictoryPhase()); @@ -785,8 +901,8 @@ export function handleMysteryEncounterVictory(addHealPhase: boolean = false, doN * Similar to {@linkcode handleMysteryEncounterVictory}, but for cases where the player lost a battle or failed a challenge * @param addHealPhase */ -export function handleMysteryEncounterBattleFailed(addHealPhase: boolean = false, doNotContinue: boolean = false) { - const allowedPkm = globalScene.getPlayerParty().filter((pkm) => pkm.isAllowedInBattle()); +export function handleMysteryEncounterBattleFailed(addHealPhase = false, doNotContinue = false) { + const allowedPkm = globalScene.getPlayerParty().filter(pkm => pkm.isAllowedInBattle()); if (allowedPkm.length === 0) { globalScene.clearPhaseQueue(); @@ -799,7 +915,8 @@ export function handleMysteryEncounterBattleFailed(addHealPhase: boolean = false const encounter = globalScene.currentBattle.mysteryEncounter!; if (encounter.continuousEncounter || doNotContinue) { return; - } else if (encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE) { + } + if (encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE) { globalScene.pushPhase(new BattleEndPhase(false)); } @@ -817,7 +934,7 @@ export function handleMysteryEncounterBattleFailed(addHealPhase: boolean = false * @param destroy - If true, will destroy visuals ONLY ON HIDE TRANSITION. Does nothing on show. Defaults to true * @param duration */ -export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, destroy: boolean = true, duration: number = 750): Promise { +export function transitionMysteryEncounterIntroVisuals(hide = true, destroy = true, duration = 750): Promise { return new Promise(resolve => { const introVisuals = globalScene.currentBattle.mysteryEncounter!.introVisuals; const enemyPokemon = globalScene.getEnemyField(); @@ -835,7 +952,7 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des // Transition globalScene.tweens.add({ - targets: [ introVisuals, enemyPokemon ], + targets: [introVisuals, enemyPokemon], x: `${hide ? "+" : "-"}=16`, y: `${hide ? "-" : "+"}=16`, alpha: hide ? 0 : 1, @@ -852,7 +969,7 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des globalScene.currentBattle.mysteryEncounter!.introVisuals = undefined; } resolve(true); - } + }, }); } else { resolve(true); @@ -866,10 +983,15 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des */ export function handleMysteryEncounterBattleStartEffects() { const encounter = globalScene.currentBattle.mysteryEncounter; - if (globalScene.currentBattle.isBattleMysteryEncounter() && encounter && encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE && !encounter.startOfBattleEffectsComplete) { + if ( + globalScene.currentBattle.isBattleMysteryEncounter() && + encounter && + encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE && + !encounter.startOfBattleEffectsComplete + ) { const effects = encounter.startOfBattleEffects; effects.forEach(effect => { - let source; + let source: EnemyPokemon | Pokemon; if (effect.sourcePokemon) { source = effect.sourcePokemon; } else if (!isNullOrUndefined(effect.sourceBattlerIndex)) { @@ -887,6 +1009,7 @@ export function handleMysteryEncounterBattleStartEffects() { } else { source = globalScene.getEnemyField()[0]; } + // @ts-ignore: source cannot be undefined globalScene.pushPhase(new MovePhase(source, effect.targets, effect.move, effect.followUp, effect.ignorePp)); }); @@ -919,20 +1042,31 @@ export function handleMysteryEncounterTurnStartEffects(): boolean { * @param rerollHidden whether the mon should get an extra roll for Hidden Ability * @returns {@linkcode EnemyPokemon} for the requested encounter */ -export function getRandomEncounterSpecies(level: number, isBoss: boolean = false, rerollHidden: boolean = false): EnemyPokemon { +export function getRandomEncounterSpecies(level: number, isBoss = false, rerollHidden = false): EnemyPokemon { let bossSpecies: PokemonSpecies; let isEventEncounter = false; const eventEncounters = globalScene.eventManager.getEventEncounters(); - let formIndex; + let formIndex: number | undefined; if (eventEncounters.length > 0 && randSeedInt(2) === 1) { const eventEncounter = randSeedItem(eventEncounters); - const levelSpecies = getPokemonSpecies(eventEncounter.species).getWildSpeciesForLevel(level, !eventEncounter.blockEvolution, isBoss, globalScene.gameMode); + const levelSpecies = getPokemonSpecies(eventEncounter.species).getWildSpeciesForLevel( + level, + !eventEncounter.blockEvolution, + isBoss, + globalScene.gameMode, + ); isEventEncounter = true; bossSpecies = getPokemonSpecies(levelSpecies); formIndex = eventEncounter.formIndex; } else { - bossSpecies = globalScene.arena.randomSpecies(globalScene.currentBattle.waveIndex, level, 0, getPartyLuckValue(globalScene.getPlayerParty()), isBoss); + bossSpecies = globalScene.arena.randomSpecies( + globalScene.currentBattle.waveIndex, + level, + 0, + getPartyLuckValue(globalScene.getPlayerParty()), + isBoss, + ); } const ret = new EnemyPokemon(bossSpecies, level, TrainerSlot.NONE, isBoss); if (formIndex) { @@ -959,15 +1093,24 @@ export function getRandomEncounterSpecies(level: number, isBoss: boolean = false export function calculateMEAggregateStats(baseSpawnWeight: number) { const numRuns = 1000; let run = 0; - const biomes = Object.keys(Biome).filter(key => isNaN(Number(key))); - const alwaysPickTheseBiomes = [ Biome.ISLAND, Biome.ABYSS, Biome.WASTELAND, Biome.FAIRY_CAVE, Biome.TEMPLE, Biome.LABORATORY, Biome.SPACE, Biome.WASTELAND ]; + const biomes = Object.keys(Biome).filter(key => Number.isNaN(Number(key))); + const alwaysPickTheseBiomes = [ + Biome.ISLAND, + Biome.ABYSS, + Biome.WASTELAND, + Biome.FAIRY_CAVE, + Biome.TEMPLE, + Biome.LABORATORY, + Biome.SPACE, + Biome.WASTELAND, + ]; const calculateNumEncounters = (): any[] => { let encounterRate = baseSpawnWeight; // BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT - const numEncounters = [ 0, 0, 0, 0 ]; + const numEncounters = [0, 0, 0, 0]; let mostRecentEncounterWave = 0; - const encountersByBiome = new Map(biomes.map(b => [ b, 0 ])); - const validMEfloorsByBiome = new Map(biomes.map(b => [ b, 0 ])); + const encountersByBiome = new Map(biomes.map(b => [b, 0])); + const validMEfloorsByBiome = new Map(biomes.map(b => [b, 0])); let currentBiome = Biome.TOWN; let currentArena = globalScene.newArena(currentBiome); globalScene.setSeed(Utils.randomString(24)); @@ -987,7 +1130,7 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { .filter(b => { return !Array.isArray(b) || !Utils.randSeedInt(b[1]); }) - .map(b => !Array.isArray(b) ? b : b[0]); + .map(b => (!Array.isArray(b) ? b : b[0])); }, i * 100); if (biomes! && biomes.length > 0) { const specialBiomes = biomes.filter(b => alwaysPickTheseBiomes.includes(b)); @@ -998,7 +1141,7 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { } } } else if (biomeLinks.hasOwnProperty(currentBiome)) { - currentBiome = (biomeLinks[currentBiome] as Biome); + currentBiome = biomeLinks[currentBiome] as Biome; } else { if (!(i % 50)) { currentBiome = Biome.END; @@ -1027,12 +1170,12 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { // If total number of encounters is lower than expected for the run, slightly favor a new encounter // Do the reverse as well - const expectedEncountersByFloor = AVERAGE_ENCOUNTERS_PER_RUN_TARGET / (180 - 10) * (i - 10); + const expectedEncountersByFloor = (AVERAGE_ENCOUNTERS_PER_RUN_TARGET / (180 - 10)) * (i - 10); const currentRunDiffFromAvg = expectedEncountersByFloor - numEncounters.reduce((a, b) => a + b); const favoredEncounterRate = encounterRate + currentRunDiffFromAvg * 15; // If the most recent ME was 3 or fewer waves ago, can never spawn a ME - const canSpawn = (i - mostRecentEncounterWave) > 3; + const canSpawn = i - mostRecentEncounterWave > 3; if (canSpawn && roll < favoredEncounterRate) { mostRecentEncounterWave = i; @@ -1040,7 +1183,7 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { // Calculate encounter rarity // Common / Uncommon / Rare / Super Rare (base is out of 128) - const tierWeights = [ 66, 40, 19, 3 ]; + const tierWeights = [66, 40, 19, 3]; // Adjust tier weights by currently encountered events (pity system that lowers odds of multiple Common/Great) tierWeights[0] = tierWeights[0] - 6 * numEncounters[0]; @@ -1052,14 +1195,20 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { const uncommonThreshold = totalWeight - tierWeights[0] - tierWeights[1]; // 64 - 32 - 16 = 16 const rareThreshold = totalWeight - tierWeights[0] - tierWeights[1] - tierWeights[2]; // 64 - 32 - 16 - 10 = 6 - tierValue > commonThreshold ? ++numEncounters[0] : tierValue > uncommonThreshold ? ++numEncounters[1] : tierValue > rareThreshold ? ++numEncounters[2] : ++numEncounters[3]; + tierValue > commonThreshold + ? ++numEncounters[0] + : tierValue > uncommonThreshold + ? ++numEncounters[1] + : tierValue > rareThreshold + ? ++numEncounters[2] + : ++numEncounters[3]; encountersByBiome.set(Biome[currentBiome], (encountersByBiome.get(Biome[currentBiome]) ?? 0) + 1); } else { encounterRate += WEIGHT_INCREMENT_ON_SPAWN_MISS; } } - return [ numEncounters, encountersByBiome, validMEfloorsByBiome ]; + return [numEncounters, encountersByBiome, validMEfloorsByBiome]; }; const encounterRuns: number[][] = []; @@ -1067,7 +1216,7 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { const validFloorsByBiome: Map[] = []; while (run < numRuns) { globalScene.executeWithSeedOffset(() => { - const [ numEncounters, encountersByBiome, validMEfloorsByBiome ] = calculateNumEncounters(); + const [numEncounters, encountersByBiome, validMEfloorsByBiome] = calculateNumEncounters(); encounterRuns.push(numEncounters); encountersByBiomeRuns.push(encountersByBiome); validFloorsByBiome.push(validMEfloorsByBiome); @@ -1108,13 +1257,17 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { let stats = `Starting weight: ${baseSpawnWeight}\nAverage MEs per run: ${totalMean}\nStandard Deviation: ${totalStd}\nAvg Commons: ${commonMean}\nAvg Greats: ${uncommonMean}\nAvg Ultras: ${rareMean}\nAvg Rogues: ${superRareMean}\n`; - const meanEncountersPerRunPerBiomeSorted = [ ...meanEncountersPerRunPerBiome.entries() ].sort((e1, e2) => e2[1] - e1[1]); - meanEncountersPerRunPerBiomeSorted.forEach(value => stats = stats + `${value[0]}: avg valid floors ${meanMEFloorsPerRunPerBiome.get(value[0])}, avg MEs ${value[1]},\n`); + const meanEncountersPerRunPerBiomeSorted = [...meanEncountersPerRunPerBiome.entries()].sort( + (e1, e2) => e2[1] - e1[1], + ); + + for (const value of meanEncountersPerRunPerBiomeSorted) { + stats += value[0] + "avg valid floors " + meanMEFloorsPerRunPerBiome.get(value[0]) + ", avg MEs ${value[1]},\n"; + } console.log(stats); } - /** * TODO: remove once encounter spawn rate is finalized * Just a helper function to calculate aggregate stats for MEs in a Classic run @@ -1125,7 +1278,7 @@ export function calculateRareSpawnAggregateStats(luckValue: number) { let run = 0; const calculateNumRareEncounters = (): any[] => { - const bossEncountersByRarity = [ 0, 0, 0, 0 ]; + const bossEncountersByRarity = [0, 0, 0, 0]; globalScene.setSeed(Utils.randomString(24)); globalScene.resetSeed(); // There are 12 wild boss floors @@ -1133,17 +1286,20 @@ export function calculateRareSpawnAggregateStats(luckValue: number) { // Roll boss tier // luck influences encounter rarity let luckModifier = 0; - if (!isNaN(luckValue)) { + if (!Number.isNaN(luckValue)) { luckModifier = luckValue * 0.5; } const tierValue = Utils.randSeedInt(64 - luckModifier); - const tier = tierValue >= 20 ? BiomePoolTier.BOSS : tierValue >= 6 ? BiomePoolTier.BOSS_RARE : tierValue >= 1 ? BiomePoolTier.BOSS_SUPER_RARE : BiomePoolTier.BOSS_ULTRA_RARE; + const tier = + tierValue >= 20 + ? BiomePoolTier.BOSS + : tierValue >= 6 + ? BiomePoolTier.BOSS_RARE + : tierValue >= 1 + ? BiomePoolTier.BOSS_SUPER_RARE + : BiomePoolTier.BOSS_ULTRA_RARE; switch (tier) { - default: - case BiomePoolTier.BOSS: - ++bossEncountersByRarity[0]; - break; case BiomePoolTier.BOSS_RARE: ++bossEncountersByRarity[1]; break; @@ -1153,6 +1309,10 @@ export function calculateRareSpawnAggregateStats(luckValue: number) { case BiomePoolTier.BOSS_ULTRA_RARE: ++bossEncountersByRarity[3]; break; + case BiomePoolTier.BOSS: + default: + ++bossEncountersByRarity[0]; + break; } } diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index 3871b919e62..275078dbace 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -4,7 +4,12 @@ import { isNullOrUndefined, randSeedInt } from "#app/utils"; import { PokemonHeldItemModifier } from "#app/modifier/modifier"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; -import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor } from "#app/data/pokeball"; +import { + doPokeballBounceAnim, + getPokeballAtlasKey, + getPokeballCatchMultiplier, + getPokeballTintColor, +} from "#app/data/pokeball"; import { PlayerGender } from "#enums/player-gender"; import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims"; import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; @@ -17,7 +22,11 @@ import type { PokemonType } from "#enums/pokemon-type"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { speciesStarterCosts } from "#app/data/balance/starters"; -import { getEncounterText, queueEncounterMessage, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; +import { + getEncounterText, + queueEncounterMessage, + showEncounterText, +} from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { getPokemonNameWithAffix } from "#app/messages"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type"; @@ -41,18 +50,41 @@ export const STANDARD_ENCOUNTER_BOOSTED_LEVEL_MODIFIER = 1; * @param shiny * @param variant */ -export function getSpriteKeysFromSpecies(species: Species, female?: boolean, formIndex?: number, shiny?: boolean, variant?: number): { spriteKey: string, fileRoot: string } { - const spriteKey = getPokemonSpecies(species).getSpriteKey(female ?? false, formIndex ?? 0, shiny ?? false, variant ?? 0); - const fileRoot = getPokemonSpecies(species).getSpriteAtlasPath(female ?? false, formIndex ?? 0, shiny ?? false, variant ?? 0); +export function getSpriteKeysFromSpecies( + species: Species, + female?: boolean, + formIndex?: number, + shiny?: boolean, + variant?: number, +): { spriteKey: string; fileRoot: string } { + const spriteKey = getPokemonSpecies(species).getSpriteKey( + female ?? false, + formIndex ?? 0, + shiny ?? false, + variant ?? 0, + ); + const fileRoot = getPokemonSpecies(species).getSpriteAtlasPath( + female ?? false, + formIndex ?? 0, + shiny ?? false, + variant ?? 0, + ); return { spriteKey, fileRoot }; } /** * Gets the sprite key and file root for a given Pokemon (accounts for gender, shiny, variants, forms, and experimental) */ -export function getSpriteKeysFromPokemon(pokemon: Pokemon): { spriteKey: string, fileRoot: string } { - const spriteKey = pokemon.getSpeciesForm().getSpriteKey(pokemon.getGender() === Gender.FEMALE, pokemon.formIndex, pokemon.shiny, pokemon.variant); - const fileRoot = pokemon.getSpeciesForm().getSpriteAtlasPath(pokemon.getGender() === Gender.FEMALE, pokemon.formIndex, pokemon.shiny, pokemon.variant); +export function getSpriteKeysFromPokemon(pokemon: Pokemon): { + spriteKey: string; + fileRoot: string; +} { + const spriteKey = pokemon + .getSpeciesForm() + .getSpriteKey(pokemon.getGender() === Gender.FEMALE, pokemon.formIndex, pokemon.shiny, pokemon.variant); + const fileRoot = pokemon + .getSpeciesForm() + .getSpriteAtlasPath(pokemon.getGender() === Gender.FEMALE, pokemon.formIndex, pokemon.shiny, pokemon.variant); return { spriteKey, fileRoot }; } @@ -65,7 +97,11 @@ export function getSpriteKeysFromPokemon(pokemon: Pokemon): { spriteKey: string, * @param doNotReturnLastAllowedMon Default `false`. If `true`, will never return the last unfainted pokemon in the party. Useful when this function is being used to determine what Pokemon to remove from the party (Don't want to remove last unfainted) * @returns */ -export function getRandomPlayerPokemon(isAllowed: boolean = false, isFainted: boolean = false, doNotReturnLastAllowedMon: boolean = false): PlayerPokemon { +export function getRandomPlayerPokemon( + isAllowed = false, + isFainted = false, + doNotReturnLastAllowedMon = false, +): PlayerPokemon { const party = globalScene.getPlayerParty(); let chosenIndex: number; let chosenPokemon: PlayerPokemon | null = null; @@ -104,7 +140,7 @@ export function getRandomPlayerPokemon(isAllowed: boolean = false, isFainted: bo * @param isFainted Default false. If true, includes fainted mons. * @returns */ -export function getHighestLevelPlayerPokemon(isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { +export function getHighestLevelPlayerPokemon(isAllowed = false, isFainted = false): PlayerPokemon { const party = globalScene.getPlayerParty(); let pokemon: PlayerPokemon | null = null; @@ -116,7 +152,7 @@ export function getHighestLevelPlayerPokemon(isAllowed: boolean = false, isFaint continue; } - pokemon = pokemon ? pokemon?.level < p?.level ? p : pokemon : p; + pokemon = pokemon ? (pokemon?.level < p?.level ? p : pokemon) : p; } return pokemon!; @@ -130,7 +166,7 @@ export function getHighestLevelPlayerPokemon(isAllowed: boolean = false, isFaint * @param isFainted Default false. If true, includes fainted mons. * @returns */ -export function getHighestStatPlayerPokemon(stat: PermanentStat, isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { +export function getHighestStatPlayerPokemon(stat: PermanentStat, isAllowed = false, isFainted = false): PlayerPokemon { const party = globalScene.getPlayerParty(); let pokemon: PlayerPokemon | null = null; @@ -142,7 +178,7 @@ export function getHighestStatPlayerPokemon(stat: PermanentStat, isAllowed: bool continue; } - pokemon = pokemon ? pokemon.getStat(stat) < p?.getStat(stat) ? p : pokemon : p; + pokemon = pokemon ? (pokemon.getStat(stat) < p?.getStat(stat) ? p : pokemon) : p; } return pokemon!; @@ -155,7 +191,7 @@ export function getHighestStatPlayerPokemon(stat: PermanentStat, isAllowed: bool * @param isFainted Default false. If true, includes fainted mons. * @returns */ -export function getLowestLevelPlayerPokemon(isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { +export function getLowestLevelPlayerPokemon(isAllowed = false, isFainted = false): PlayerPokemon { const party = globalScene.getPlayerParty(); let pokemon: PlayerPokemon | null = null; @@ -167,7 +203,7 @@ export function getLowestLevelPlayerPokemon(isAllowed: boolean = false, isFainte continue; } - pokemon = pokemon ? pokemon?.level > p?.level ? p : pokemon : p; + pokemon = pokemon ? (pokemon?.level > p?.level ? p : pokemon) : p; } return pokemon!; @@ -180,7 +216,7 @@ export function getLowestLevelPlayerPokemon(isAllowed: boolean = false, isFainte * @param isFainted Default false. If true, includes fainted mons. * @returns */ -export function getHighestStatTotalPlayerPokemon(isAllowed: boolean = false, isFainted: boolean = false): PlayerPokemon { +export function getHighestStatTotalPlayerPokemon(isAllowed = false, isFainted = false): PlayerPokemon { const party = globalScene.getPlayerParty(); let pokemon: PlayerPokemon | null = null; @@ -192,7 +228,7 @@ export function getHighestStatTotalPlayerPokemon(isAllowed: boolean = false, isF continue; } - pokemon = pokemon ? pokemon?.stats.reduce((a, b) => a + b) < p?.stats.reduce((a, b) => a + b) ? p : pokemon : p; + pokemon = pokemon ? (pokemon?.stats.reduce((a, b) => a + b) < p?.stats.reduce((a, b) => a + b) ? p : pokemon) : p; } return pokemon!; @@ -209,28 +245,40 @@ export function getHighestStatTotalPlayerPokemon(isAllowed: boolean = false, isF * @param allowMythical * @returns */ -export function getRandomSpeciesByStarterCost(starterTiers: number | [number, number], excludedSpecies?: Species[], types?: PokemonType[], allowSubLegendary: boolean = true, allowLegendary: boolean = true, allowMythical: boolean = true): Species { +export function getRandomSpeciesByStarterCost( + starterTiers: number | [number, number], + excludedSpecies?: Species[], + types?: PokemonType[], + allowSubLegendary = true, + allowLegendary = true, + allowMythical = true, +): Species { let min = Array.isArray(starterTiers) ? starterTiers[0] : starterTiers; let max = Array.isArray(starterTiers) ? starterTiers[1] : starterTiers; let filteredSpecies: [PokemonSpecies, number][] = Object.keys(speciesStarterCosts) - .map(s => [ parseInt(s) as Species, speciesStarterCosts[s] as number ]) + .map(s => [Number.parseInt(s) as Species, speciesStarterCosts[s] as number]) .filter(s => { const pokemonSpecies = getPokemonSpecies(s[0]); - return pokemonSpecies && (!excludedSpecies || !excludedSpecies.includes(s[0])) - && (allowSubLegendary || !pokemonSpecies.subLegendary) - && (allowLegendary || !pokemonSpecies.legendary) - && (allowMythical || !pokemonSpecies.mythical); + return ( + pokemonSpecies && + (!excludedSpecies || !excludedSpecies.includes(s[0])) && + (allowSubLegendary || !pokemonSpecies.subLegendary) && + (allowLegendary || !pokemonSpecies.legendary) && + (allowMythical || !pokemonSpecies.mythical) + ); }) - .map(s => [ getPokemonSpecies(s[0]), s[1] ]); + .map(s => [getPokemonSpecies(s[0]), s[1]]); if (types && types.length > 0) { - filteredSpecies = filteredSpecies.filter(s => types.includes(s[0].type1) || (!isNullOrUndefined(s[0].type2) && types.includes(s[0].type2))); + filteredSpecies = filteredSpecies.filter( + s => types.includes(s[0].type1) || (!isNullOrUndefined(s[0].type2) && types.includes(s[0].type2)), + ); } // If no filtered mons exist at specified starter tiers, will expand starter search range until there are // Starts by decrementing starter tier min until it is 0, then increments tier max up to 10 - let tryFilterStarterTiers: [PokemonSpecies, number][] = filteredSpecies.filter(s => (s[1] >= min && s[1] <= max)); + let tryFilterStarterTiers: [PokemonSpecies, number][] = filteredSpecies.filter(s => s[1] >= min && s[1] <= max); while (tryFilterStarterTiers.length === 0 && !(min === 0 && max === 10)) { if (min > 0) { min--; @@ -259,7 +307,11 @@ export function koPlayerPokemon(pokemon: PlayerPokemon) { pokemon.hp = 0; pokemon.trySetStatus(StatusEffect.FAINT); pokemon.updateInfo(); - queueEncounterMessage(i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + queueEncounterMessage( + i18next.t("battle:fainted", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } /** @@ -290,7 +342,9 @@ function applyHpChangeToPokemon(pokemon: PlayerPokemon, value: number) { */ export function applyDamageToPokemon(pokemon: PlayerPokemon, damage: number) { if (damage <= 0) { - console.warn("Healing pokemon with `applyDamageToPokemon` is not recommended! Please use `applyHealToPokemon` instead."); + console.warn( + "Healing pokemon with `applyDamageToPokemon` is not recommended! Please use `applyHealToPokemon` instead.", + ); } // If a Pokemon would faint from the damage applied, its HP is instead set to 1. if (pokemon.isAllowedInBattle() && pokemon.hp - damage <= 0) { @@ -308,7 +362,9 @@ export function applyDamageToPokemon(pokemon: PlayerPokemon, damage: number) { */ export function applyHealToPokemon(pokemon: PlayerPokemon, heal: number) { if (heal <= 0) { - console.warn("Damaging pokemon with `applyHealToPokemon` is not recommended! Please use `applyDamageToPokemon` instead."); + console.warn( + "Damaging pokemon with `applyHealToPokemon` is not recommended! Please use `applyDamageToPokemon` instead.", + ); } applyHpChangeToPokemon(pokemon, heal); @@ -321,8 +377,9 @@ export function applyHealToPokemon(pokemon: PlayerPokemon, heal: number) { * @param value */ export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: number) { - const modType = modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE() - .generateType(globalScene.getPlayerParty(), [ value ]) + const modType = modifierTypes + .MYSTERY_ENCOUNTER_SHUCKLE_JUICE() + .generateType(globalScene.getPlayerParty(), [value]) ?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE); const modifier = modType?.newModifier(pokemon); if (modifier) { @@ -339,15 +396,20 @@ export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, value: numb * @param modType * @param fallbackModifierType */ -export async function applyModifierTypeToPlayerPokemon(pokemon: PlayerPokemon, modType: PokemonHeldItemModifierType, fallbackModifierType?: PokemonHeldItemModifierType) { +export async function applyModifierTypeToPlayerPokemon( + pokemon: PlayerPokemon, + modType: PokemonHeldItemModifierType, + fallbackModifierType?: PokemonHeldItemModifierType, +) { // Check if the Pokemon has max stacks of that item already const modifier = modType.newModifier(pokemon); - const existing = globalScene.findModifier(m => ( - m instanceof PokemonHeldItemModifier && - m.type.id === modType.id && - m.pokemonId === pokemon.id && - m.matchType(modifier) - )) as PokemonHeldItemModifier; + const existing = globalScene.findModifier( + m => + m instanceof PokemonHeldItemModifier && + m.type.id === modType.id && + m.pokemonId === pokemon.id && + m.matchType(modifier), + ) as PokemonHeldItemModifier; // At max stacks if (existing && existing.getStackCount() >= existing.getMaxStackCount()) { @@ -373,7 +435,11 @@ export async function applyModifierTypeToPlayerPokemon(pokemon: PlayerPokemon, m * @param pokeballType * @param ballTwitchRate - can pass custom ball catch rates (for special events, like safari) */ -export function trainerThrowPokeball(pokemon: EnemyPokemon, pokeballType: PokeballType, ballTwitchRate?: number): Promise { +export function trainerThrowPokeball( + pokemon: EnemyPokemon, + pokeballType: PokeballType, + ballTwitchRate?: number, +): Promise { const originalY: number = pokemon.y; if (!ballTwitchRate) { @@ -397,7 +463,9 @@ export function trainerThrowPokeball(pokemon: EnemyPokemon, pokeballType: Pokeba }); return new Promise(resolve => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`, + ); globalScene.time.delayedCall(512, () => { globalScene.playSound("se/pb_throw"); @@ -406,7 +474,9 @@ export function trainerThrowPokeball(pokemon: EnemyPokemon, pokeballType: Pokeba globalScene.time.delayedCall(256, () => { globalScene.trainer.setFrame("3"); globalScene.time.delayedCall(768, () => { - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back`, + ); }); }); @@ -486,22 +556,22 @@ export function trainerThrowPokeball(pokemon: EnemyPokemon, pokeballType: Pokeba alpha: 0, duration: 200, easing: "Sine.easeIn", - onComplete: () => pbTint.destroy() + onComplete: () => pbTint.destroy(), }); - } + }, }); } }, onComplete: () => { catchPokemon(pokemon, pokeball, pokeballType).then(() => resolve(true)); - } + }, }); }; globalScene.time.delayedCall(250, () => doPokeballBounceAnim(pokeball, 16, 72, 350, doShake)); - } + }, }); - } + }, }); }); }); @@ -515,7 +585,12 @@ export function trainerThrowPokeball(pokemon: EnemyPokemon, pokeballType: Pokeba * @param pokeball * @param pokeballType */ -function failCatch(pokemon: EnemyPokemon, originalY: number, pokeball: Phaser.GameObjects.Sprite, pokeballType: PokeballType) { +function failCatch( + pokemon: EnemyPokemon, + originalY: number, + pokeball: Phaser.GameObjects.Sprite, + pokeballType: PokeballType, +) { return new Promise(resolve => { globalScene.playSound("se/pb_rel"); pokemon.setY(originalY); @@ -534,13 +609,21 @@ function failCatch(pokemon: EnemyPokemon, originalY: number, pokeball: Phaser.Ga targets: pokemon, duration: 250, ease: "Sine.easeOut", - scale: 1 + scale: 1, }); globalScene.currentBattle.lastUsedPokeball = pokeballType; removePb(pokeball); - globalScene.ui.showText(i18next.t("battle:pokemonBrokeFree", { pokemonName: pokemon.getNameToRender() }), null, () => resolve(), null, true); + globalScene.ui.showText( + i18next.t("battle:pokemonBrokeFree", { + pokemonName: pokemon.getNameToRender(), + }), + null, + () => resolve(), + null, + true, + ); }); } @@ -553,10 +636,19 @@ function failCatch(pokemon: EnemyPokemon, originalY: number, pokeball: Phaser.Ga * @param showCatchObtainMessage * @param isObtain */ -export async function catchPokemon(pokemon: EnemyPokemon, pokeball: Phaser.GameObjects.Sprite | null, pokeballType: PokeballType, showCatchObtainMessage: boolean = true, isObtain: boolean = false): Promise { +export async function catchPokemon( + pokemon: EnemyPokemon, + pokeball: Phaser.GameObjects.Sprite | null, + pokeballType: PokeballType, + showCatchObtainMessage = true, + isObtain = false, +): Promise { const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); - if (speciesForm.abilityHidden && (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1) { + if ( + speciesForm.abilityHidden && + (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1 + ) { globalScene.validateAchv(achvs.HIDDEN_ABILITY); } @@ -611,35 +703,70 @@ export async function catchPokemon(pokemon: EnemyPokemon, pokeball: Phaser.GameO } }); }; - Promise.all([ pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon) ]).then(() => { + Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => { if (globalScene.getPlayerParty().length === 6) { const promptRelease = () => { - globalScene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => { - globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); - globalScene.ui.setMode(Mode.CONFIRM, () => { - const newPokemon = globalScene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); - globalScene.ui.setMode(Mode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - promptRelease(); - }); - }, false); - }, () => { - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, 0, (slotIndex: number, _option: PartyOption) => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - if (slotIndex < 6) { - addToParty(slotIndex); - } else { - promptRelease(); - } - }); - }); - }, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - removePokemon(); - end(); - }); - }, "fullParty"); - }); + globalScene.ui.showText( + i18next.t("battle:partyFull", { + pokemonName: pokemon.getNameToRender(), + }), + null, + () => { + globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); + globalScene.ui.setMode( + Mode.CONFIRM, + () => { + const newPokemon = globalScene.addPlayerPokemon( + pokemon.species, + pokemon.level, + pokemon.abilityIndex, + pokemon.formIndex, + pokemon.gender, + pokemon.shiny, + pokemon.variant, + pokemon.ivs, + pokemon.nature, + pokemon, + ); + globalScene.ui.setMode( + Mode.SUMMARY, + newPokemon, + 0, + SummaryUiMode.DEFAULT, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + promptRelease(); + }); + }, + false, + ); + }, + () => { + globalScene.ui.setMode( + Mode.PARTY, + PartyUiMode.RELEASE, + 0, + (slotIndex: number, _option: PartyOption) => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + if (slotIndex < 6) { + addToParty(slotIndex); + } else { + promptRelease(); + } + }); + }, + ); + }, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + removePokemon(); + end(); + }); + }, + "fullParty", + ); + }, + ); }; promptRelease(); } else { @@ -649,7 +776,15 @@ export async function catchPokemon(pokemon: EnemyPokemon, pokeball: Phaser.GameO }; if (showCatchObtainMessage) { - globalScene.ui.showText(i18next.t(isObtain ? "battle:pokemonObtained" : "battle:pokemonCaught", { pokemonName: pokemon.getNameToRender() }), null, doPokemonCatchMenu, 0, true); + globalScene.ui.showText( + i18next.t(isObtain ? "battle:pokemonObtained" : "battle:pokemonCaught", { + pokemonName: pokemon.getNameToRender(), + }), + null, + doPokemonCatchMenu, + 0, + true, + ); } else { doPokemonCatchMenu(); } @@ -671,7 +806,7 @@ function removePb(pokeball: Phaser.GameObjects.Sprite) { alpha: 0, onComplete: () => { pokeball.destroy(); - } + }, }); } } @@ -696,11 +831,17 @@ export async function doPokemonFlee(pokemon: EnemyPokemon): Promise { onComplete: () => { pokemon.setVisible(false); pokemon.leaveField(true, true, true); - showEncounterText(i18next.t("battle:pokemonFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false) - .then(() => { - resolve(); - }); - } + showEncounterText( + i18next.t("battle:pokemonFled", { + pokemonName: pokemon.getNameToRender(), + }), + null, + 600, + false, + ).then(() => { + resolve(); + }); + }, }); }); } @@ -724,11 +865,17 @@ export function doPlayerFlee(pokemon: EnemyPokemon): Promise { onComplete: () => { pokemon.setVisible(false); pokemon.leaveField(true, true, true); - showEncounterText(i18next.t("battle:playerFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false) - .then(() => { - resolve(); - }); - } + showEncounterText( + i18next.t("battle:playerFled", { + pokemonName: pokemon.getNameToRender(), + }), + null, + 600, + false, + ).then(() => { + resolve(); + }); + }, }); }); } @@ -737,33 +884,33 @@ export function doPlayerFlee(pokemon: EnemyPokemon): Promise { * Bug Species and their corresponding weights */ const GOLDEN_BUG_NET_SPECIES_POOL: [Species, number][] = [ - [ Species.SCYTHER, 40 ], - [ Species.SCIZOR, 40 ], - [ Species.KLEAVOR, 40 ], - [ Species.PINSIR, 40 ], - [ Species.HERACROSS, 40 ], - [ Species.YANMA, 40 ], - [ Species.YANMEGA, 40 ], - [ Species.SHUCKLE, 40 ], - [ Species.ANORITH, 40 ], - [ Species.ARMALDO, 40 ], - [ Species.ESCAVALIER, 40 ], - [ Species.ACCELGOR, 40 ], - [ Species.JOLTIK, 40 ], - [ Species.GALVANTULA, 40 ], - [ Species.DURANT, 40 ], - [ Species.LARVESTA, 40 ], - [ Species.VOLCARONA, 40 ], - [ Species.DEWPIDER, 40 ], - [ Species.ARAQUANID, 40 ], - [ Species.WIMPOD, 40 ], - [ Species.GOLISOPOD, 40 ], - [ Species.SIZZLIPEDE, 40 ], - [ Species.CENTISKORCH, 40 ], - [ Species.NYMBLE, 40 ], - [ Species.LOKIX, 40 ], - [ Species.BUZZWOLE, 1 ], - [ Species.PHEROMOSA, 1 ], + [Species.SCYTHER, 40], + [Species.SCIZOR, 40], + [Species.KLEAVOR, 40], + [Species.PINSIR, 40], + [Species.HERACROSS, 40], + [Species.YANMA, 40], + [Species.YANMEGA, 40], + [Species.SHUCKLE, 40], + [Species.ANORITH, 40], + [Species.ARMALDO, 40], + [Species.ESCAVALIER, 40], + [Species.ACCELGOR, 40], + [Species.JOLTIK, 40], + [Species.GALVANTULA, 40], + [Species.DURANT, 40], + [Species.LARVESTA, 40], + [Species.VOLCARONA, 40], + [Species.DEWPIDER, 40], + [Species.ARAQUANID, 40], + [Species.WIMPOD, 40], + [Species.GOLISOPOD, 40], + [Species.SIZZLIPEDE, 40], + [Species.CENTISKORCH, 40], + [Species.NYMBLE, 40], + [Species.LOKIX, 40], + [Species.BUZZWOLE, 1], + [Species.PHEROMOSA, 1], ]; /** @@ -792,7 +939,7 @@ export function getGoldenBugNetSpecies(level: number): PokemonSpecies { * @param scene * @param levelAdditiveModifier Default 0. will add +(1 level / 10 waves * levelAdditiveModifier) to the level calculation */ -export function getEncounterPokemonLevelForWave(levelAdditiveModifier: number = 0) { +export function getEncounterPokemonLevelForWave(levelAdditiveModifier = 0) { const currentBattle = globalScene.currentBattle; const baseLevel = currentBattle.getLevelForWave(); @@ -803,7 +950,10 @@ export function getEncounterPokemonLevelForWave(levelAdditiveModifier: number = export async function addPokemonDataToDexAndValidateAchievements(pokemon: PlayerPokemon) { const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); - if (speciesForm.abilityHidden && (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1) { + if ( + speciesForm.abilityHidden && + (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1 + ) { globalScene.validateAchv(achvs.HIDDEN_ABILITY); } @@ -832,9 +982,16 @@ export async function addPokemonDataToDexAndValidateAchievements(pokemon: Player * @param scene * @param invalidSelectionKey */ -export function isPokemonValidForEncounterOptionSelection(pokemon: Pokemon, invalidSelectionKey: string): string | null { +export function isPokemonValidForEncounterOptionSelection( + pokemon: Pokemon, + invalidSelectionKey: string, +): string | null { if (!pokemon.isAllowedInChallenge()) { - return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: pokemon.getNameToRender() }) ?? null; + return ( + i18next.t("partyUiHandler:cantBeUsed", { + pokemonName: pokemon.getNameToRender(), + }) ?? null + ); } if (!pokemon.isAllowedInBattle()) { return getEncounterText(invalidSelectionKey) ?? null; diff --git a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts index 0cb2a695de8..15085bb2bf8 100644 --- a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts +++ b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts @@ -7,7 +7,7 @@ import { globalScene } from "#app/global-scene"; export enum TransformationScreenPosition { CENTER, LEFT, - RIGHT + RIGHT, } /** @@ -17,7 +17,11 @@ export enum TransformationScreenPosition { * @param transformPokemon * @param screenPosition */ -export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, transformPokemon: PlayerPokemon, screenPosition: TransformationScreenPosition) { +export function doPokemonTransformationSequence( + previousPokemon: PlayerPokemon, + transformPokemon: PlayerPokemon, + screenPosition: TransformationScreenPosition, +) { return new Promise(resolve => { const transformationContainer = globalScene.fieldUI.getByName("Dream Background") as Phaser.GameObjects.Container; const transformationBaseBg = globalScene.add.image(0, 0, "default_bg"); @@ -30,14 +34,26 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, let pokemonEvoSprite: Phaser.GameObjects.Sprite; let pokemonEvoTintSprite: Phaser.GameObjects.Sprite; - const xOffset = screenPosition === TransformationScreenPosition.CENTER ? 0 : - screenPosition === TransformationScreenPosition.RIGHT ? 100 : -100; + const xOffset = + screenPosition === TransformationScreenPosition.CENTER + ? 0 + : screenPosition === TransformationScreenPosition.RIGHT + ? 100 + : -100; // Centered transformations occur at a lower y Position const yOffset = screenPosition !== TransformationScreenPosition.CENTER ? -15 : 0; const getPokemonSprite = () => { - const ret = globalScene.addPokemonSprite(previousPokemon, transformationBaseBg.displayWidth / 2 + xOffset, transformationBaseBg.displayHeight / 2 + yOffset, "pkmn__sub"); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + const ret = globalScene.addPokemonSprite( + previousPokemon, + transformationBaseBg.displayWidth / 2 + xOffset, + transformationBaseBg.displayHeight / 2 + yOffset, + "pkmn__sub", + ); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); return ret; }; @@ -48,12 +64,12 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, pokemonSprite.setAlpha(0); pokemonTintSprite.setAlpha(0); - pokemonTintSprite.setTintFill(0xFFFFFF); + pokemonTintSprite.setTintFill(0xffffff); pokemonEvoSprite.setVisible(false); pokemonEvoTintSprite.setVisible(false); - pokemonEvoTintSprite.setTintFill(0xFFFFFF); + pokemonEvoTintSprite.setTintFill(0xffffff); - [ pokemonSprite, pokemonTintSprite, pokemonEvoSprite, pokemonEvoTintSprite ].map(sprite => { + [pokemonSprite, pokemonTintSprite, pokemonEvoSprite, pokemonEvoTintSprite].map(sprite => { const spriteKey = previousPokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -61,12 +77,17 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(previousPokemon.getTeraType()), isTerastallized: previousPokemon.isTerastallized }); + sprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: false, + teraColor: getTypeRgb(previousPokemon.getTeraType()), + isTerastallized: previousPokemon.isTerastallized, + }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", previousPokemon.getSpriteKey()); sprite.setPipelineData("shiny", previousPokemon.shiny); sprite.setPipelineData("variant", previousPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (previousPokemon.summonData?.speciesForm) { k += "Base"; } @@ -74,7 +95,7 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, }); }); - [ pokemonEvoSprite, pokemonEvoTintSprite ].map(sprite => { + [pokemonEvoSprite, pokemonEvoTintSprite].map(sprite => { const spriteKey = transformPokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -86,7 +107,7 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, sprite.setPipelineData("spriteKey", transformPokemon.getSpriteKey()); sprite.setPipelineData("shiny", transformPokemon.shiny); sprite.setPipelineData("variant", transformPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (transformPokemon.summonData?.speciesForm) { k += "Base"; } @@ -139,18 +160,18 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, previousPokemon.destroy(); transformPokemon.setVisible(false); transformPokemon.setAlpha(1); - } + }, }); }); - } + }, }); }); }); }); }); - } + }, }); - } + }, }); }); } @@ -163,7 +184,12 @@ export function doPokemonTransformationSequence(previousPokemon: PlayerPokemon, * @param xOffset * @param yOffset */ -function doSpiralUpward(transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doSpiralUpward( + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { let f = 0; globalScene.tweens.addCounter({ @@ -173,12 +199,18 @@ function doSpiralUpward(transformationBaseBg: Phaser.GameObjects.Image, transfor if (f < 64) { if (!(f & 7)) { for (let i = 0; i < 4; i++) { - doSpiralUpwardParticle((f & 120) * 2 + i * 64, transformationBaseBg, transformationContainer, xOffset, yOffset); + doSpiralUpwardParticle( + (f & 120) * 2 + i * 64, + transformationBaseBg, + transformationContainer, + xOffset, + yOffset, + ); } } f++; } - } + }, }); } @@ -190,7 +222,12 @@ function doSpiralUpward(transformationBaseBg: Phaser.GameObjects.Image, transfor * @param xOffset * @param yOffset */ -function doArcDownward(transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doArcDownward( + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { let f = 0; globalScene.tweens.addCounter({ @@ -205,7 +242,7 @@ function doArcDownward(transformationBaseBg: Phaser.GameObjects.Image, transform } f++; } - } + }, }); } @@ -217,7 +254,12 @@ function doArcDownward(transformationBaseBg: Phaser.GameObjects.Image, transform * @param pokemonTintSprite * @param pokemonEvoTintSprite */ -function doCycle(l: number, lastCycle: number, pokemonTintSprite: Phaser.GameObjects.Sprite, pokemonEvoTintSprite: Phaser.GameObjects.Sprite): Promise { +function doCycle( + l: number, + lastCycle: number, + pokemonTintSprite: Phaser.GameObjects.Sprite, + pokemonEvoTintSprite: Phaser.GameObjects.Sprite, +): Promise { return new Promise(resolve => { const isLastCycle = l === lastCycle; globalScene.tweens.add({ @@ -225,7 +267,7 @@ function doCycle(l: number, lastCycle: number, pokemonTintSprite: Phaser.GameObj scale: 0.25, ease: "Cubic.easeInOut", duration: 500 / l, - yoyo: !isLastCycle + yoyo: !isLastCycle, }); globalScene.tweens.add({ targets: pokemonEvoTintSprite, @@ -240,7 +282,7 @@ function doCycle(l: number, lastCycle: number, pokemonTintSprite: Phaser.GameObj pokemonTintSprite.setVisible(false); resolve(true); } - } + }, }); }); } @@ -253,7 +295,12 @@ function doCycle(l: number, lastCycle: number, pokemonTintSprite: Phaser.GameObj * @param xOffset * @param yOffset */ -function doCircleInward(transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doCircleInward( + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { let f = 0; globalScene.tweens.addCounter({ @@ -270,7 +317,7 @@ function doCircleInward(transformationBaseBg: Phaser.GameObjects.Image, transfor } } f++; - } + }, }); } @@ -283,7 +330,13 @@ function doCircleInward(transformationBaseBg: Phaser.GameObjects.Image, transfor * @param xOffset * @param yOffset */ -function doSpiralUpwardParticle(trigIndex: number, transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doSpiralUpwardParticle( + trigIndex: number, + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { const initialX = transformationBaseBg.displayWidth / 2 + xOffset; const particle = globalScene.add.image(initialX, 0, "evo_sparkle"); transformationContainer.add(particle); @@ -296,7 +349,7 @@ function doSpiralUpwardParticle(trigIndex: number, transformationBaseBg: Phaser. duration: getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -304,7 +357,7 @@ function doSpiralUpwardParticle(trigIndex: number, transformationBaseBg: Phaser. particle.setPosition(initialX, 88 - (f * f) / 80 + yOffset); particle.y += sin(trigIndex, amp) / 4; particle.x += cos(trigIndex, amp); - particle.setScale(1 - (f / 80)); + particle.setScale(1 - f / 80); trigIndex += 4; if (f & 1) { amp--; @@ -328,7 +381,13 @@ function doSpiralUpwardParticle(trigIndex: number, transformationBaseBg: Phaser. * @param xOffset * @param yOffset */ -function doArcDownParticle(trigIndex: number, transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doArcDownParticle( + trigIndex: number, + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { const initialX = transformationBaseBg.displayWidth / 2 + xOffset; const particle = globalScene.add.image(initialX, 0, "evo_sparkle"); particle.setScale(0.5); @@ -342,7 +401,7 @@ function doArcDownParticle(trigIndex: number, transformationBaseBg: Phaser.GameO duration: getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -371,7 +430,14 @@ function doArcDownParticle(trigIndex: number, transformationBaseBg: Phaser.GameO * @param xOffset * @param yOffset */ -function doCircleInwardParticle(trigIndex: number, speed: number, transformationBaseBg: Phaser.GameObjects.Image, transformationContainer: Phaser.GameObjects.Container, xOffset: number, yOffset: number) { +function doCircleInwardParticle( + trigIndex: number, + speed: number, + transformationBaseBg: Phaser.GameObjects.Image, + transformationContainer: Phaser.GameObjects.Container, + xOffset: number, + yOffset: number, +) { const initialX = transformationBaseBg.displayWidth / 2 + xOffset; const initialY = transformationBaseBg.displayHeight / 2 + yOffset; const particle = globalScene.add.image(initialX, initialY, "evo_sparkle"); @@ -384,7 +450,7 @@ function doCircleInwardParticle(trigIndex: number, speed: number, transformation duration: getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { diff --git a/src/data/nature.ts b/src/data/nature.ts index b90047ce6f0..e23d92c14b0 100644 --- a/src/data/nature.ts +++ b/src/data/nature.ts @@ -5,11 +5,17 @@ import { UiTheme } from "#enums/ui-theme"; import i18next from "i18next"; import { Stat, EFFECTIVE_STATS, getShortenedStatKey } from "#enums/stat"; -export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false, ignoreBBCode: boolean = false, uiTheme: UiTheme = UiTheme.DEFAULT): string { +export function getNatureName( + nature: Nature, + includeStatEffects = false, + forStarterSelect = false, + ignoreBBCode = false, + uiTheme: UiTheme = UiTheme.DEFAULT, +): string { let ret = Utils.toReadableString(Nature[nature]); //Translating nature - if (i18next.exists("nature:" + ret)) { - ret = i18next.t("nature:" + ret as any); + if (i18next.exists(`nature:${ret}`)) { + ret = i18next.t(`nature:${ret}` as any); } if (includeStatEffects) { let increasedStat: Stat | null = null; @@ -23,7 +29,9 @@ export function getNatureName(nature: Nature, includeStatEffects: boolean = fals } } const textStyle = forStarterSelect ? TextStyle.SUMMARY_ALT : TextStyle.WINDOW; - const getTextFrag = !ignoreBBCode ? (text: string, style: TextStyle) => getBBCodeFrag(text, style, uiTheme) : (text: string, style: TextStyle) => text; + const getTextFrag = !ignoreBBCode + ? (text: string, style: TextStyle) => getBBCodeFrag(text, style, uiTheme) + : (text: string, _style: TextStyle) => text; if (increasedStat && decreasedStat) { ret = `${getTextFrag(`${ret}${!forStarterSelect ? "\n" : " "}(`, textStyle)}${getTextFrag(`+${i18next.t(getShortenedStatKey(increasedStat))}`, TextStyle.SUMMARY_PINK)}${getTextFrag("/", textStyle)}${getTextFrag(`-${i18next.t(getShortenedStatKey(decreasedStat))}`, TextStyle.SUMMARY_BLUE)}${getTextFrag(")", textStyle)}`; } else { diff --git a/src/data/pokeball.ts b/src/data/pokeball.ts index 7cd9f061cdd..b0744237755 100644 --- a/src/data/pokeball.ts +++ b/src/data/pokeball.ts @@ -95,16 +95,31 @@ export function getCriticalCaptureChance(modifiedCatchRate: number): number { const dexCount = globalScene.gameData.getSpeciesCount(d => !!d.caughtAttr); const catchingCharmMultiplier = new NumberHolder(1); globalScene.findModifier(m => m instanceof CriticalCatchChanceBoosterModifier)?.apply(catchingCharmMultiplier); - const dexMultiplier = globalScene.gameMode.isDaily || dexCount > 800 ? 2.5 - : dexCount > 600 ? 2 - : dexCount > 400 ? 1.5 - : dexCount > 200 ? 1 - : dexCount > 100 ? 0.5 - : 0; - return Math.floor(catchingCharmMultiplier.value * dexMultiplier * Math.min(255, modifiedCatchRate) / 6); + const dexMultiplier = + globalScene.gameMode.isDaily || dexCount > 800 + ? 2.5 + : dexCount > 600 + ? 2 + : dexCount > 400 + ? 1.5 + : dexCount > 200 + ? 1 + : dexCount > 100 + ? 0.5 + : 0; + return Math.floor((catchingCharmMultiplier.value * dexMultiplier * Math.min(255, modifiedCatchRate)) / 6); } -export function doPokeballBounceAnim(pokeball: Phaser.GameObjects.Sprite, y1: number, y2: number, baseBounceDuration: number, callback: Function, isCritical: boolean = false) { +// TODO: fix Function annotations +export function doPokeballBounceAnim( + pokeball: Phaser.GameObjects.Sprite, + y1: number, + y2: number, + baseBounceDuration: number, + // biome-ignore lint/complexity/noBannedTypes: TODO + callback: Function, + isCritical = false, +) { let bouncePower = 1; let bounceYOffset = y1; let bounceY = y2; @@ -134,12 +149,12 @@ export function doPokeballBounceAnim(pokeball: Phaser.GameObjects.Sprite, y1: nu y: bounceY, duration: bouncePower * baseBounceDuration, ease: "Cubic.easeOut", - onComplete: () => doBounce() + onComplete: () => doBounce(), }); } else if (callback) { callback(); } - } + }, }); }; @@ -165,12 +180,12 @@ export function doPokeballBounceAnim(pokeball: Phaser.GameObjects.Sprite, y1: nu x: x0, duration: 60, ease: "Linear", - onComplete: () => globalScene.time.delayedCall(500, doBounce) + onComplete: () => globalScene.time.delayedCall(500, doBounce), }); } - } + }, }); - } + }, }); }; diff --git a/src/data/pokemon-forms.ts b/src/data/pokemon-forms.ts index 1192f7f17c1..4636e68d6d6 100644 --- a/src/data/pokemon-forms.ts +++ b/src/data/pokemon-forms.ts @@ -113,7 +113,7 @@ export enum FormChangeItem { DRACO_PLATE, DREAD_PLATE, PIXIE_PLATE, - BLANK_PLATE, // TODO: Find a potential use for this + BLANK_PLATE, // TODO: Find a potential use for this LEGEND_PLATE, // TODO: Find a potential use for this FIGHTING_MEMORY, FLYING_MEMORY, @@ -132,7 +132,7 @@ export enum FormChangeItem { DRAGON_MEMORY, DARK_MEMORY, FAIRY_MEMORY, - NORMAL_MEMORY // TODO: Find a potential use for this + NORMAL_MEMORY, // TODO: Find a potential use for this } export type SpeciesFormChangeConditionPredicate = (p: Pokemon) => boolean; @@ -146,7 +146,14 @@ export class SpeciesFormChange { public quiet: boolean; public readonly conditions: SpeciesFormChangeCondition[]; - constructor(speciesId: Species, preFormKey: string, evoFormKey: string, trigger: SpeciesFormChangeTrigger, quiet: boolean = false, ...conditions: SpeciesFormChangeCondition[]) { + constructor( + speciesId: Species, + preFormKey: string, + evoFormKey: string, + trigger: SpeciesFormChangeTrigger, + quiet = false, + ...conditions: SpeciesFormChangeCondition[] + ) { this.speciesId = speciesId; this.preFormKey = preFormKey; this.formKey = evoFormKey; @@ -212,9 +219,9 @@ export class SpeciesFormChangeCondition { } export abstract class SpeciesFormChangeTrigger { - public description: string = ""; + public description = ""; - canChange(pokemon: Pokemon): boolean { + canChange(_pokemon: Pokemon): boolean { return true; } @@ -223,20 +230,22 @@ export abstract class SpeciesFormChangeTrigger { } } -export class SpeciesFormChangeManualTrigger extends SpeciesFormChangeTrigger { -} +export class SpeciesFormChangeManualTrigger extends SpeciesFormChangeTrigger {} export class SpeciesFormChangeAbilityTrigger extends SpeciesFormChangeTrigger { public description: string = i18next.t("pokemonEvolutions:Forms.ability"); } export class SpeciesFormChangeCompoundTrigger { - public description: string = ""; + public description = ""; public triggers: SpeciesFormChangeTrigger[]; constructor(...triggers: SpeciesFormChangeTrigger[]) { this.triggers = triggers; - this.description = this.triggers.filter(trigger => trigger?.description?.length > 0).map(trigger => trigger.description).join(", "); + this.description = this.triggers + .filter(trigger => trigger?.description?.length > 0) + .map(trigger => trigger.description) + .join(", "); } canChange(pokemon: Pokemon): boolean { @@ -258,17 +267,27 @@ export class SpeciesFormChangeItemTrigger extends SpeciesFormChangeTrigger { public item: FormChangeItem; public active: boolean; - constructor(item: FormChangeItem, active: boolean = true) { + constructor(item: FormChangeItem, active = true) { super(); this.item = item; this.active = active; - this.description = this.active ? - i18next.t("pokemonEvolutions:Forms.item", { item: i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.item]}`) }) : - i18next.t("pokemonEvolutions:Forms.deactivateItem", { item: i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.item]}`) }); + this.description = this.active + ? i18next.t("pokemonEvolutions:Forms.item", { + item: i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.item]}`), + }) + : i18next.t("pokemonEvolutions:Forms.deactivateItem", { + item: i18next.t(`modifierType:FormChangeItem.${FormChangeItem[this.item]}`), + }); } canChange(pokemon: Pokemon): boolean { - return !!globalScene.findModifier(m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === pokemon.id && m.formChangeItem === this.item && m.active === this.active); + return !!globalScene.findModifier( + m => + m instanceof PokemonFormChangeItemModifier && + m.pokemonId === pokemon.id && + m.formChangeItem === this.item && + m.active === this.active, + ); } } @@ -281,7 +300,7 @@ export class SpeciesFormChangeTimeOfDayTrigger extends SpeciesFormChangeTrigger this.description = i18next.t("pokemonEvolutions:Forms.timeOfDay"); } - canChange(pokemon: Pokemon): boolean { + canChange(_pokemon: Pokemon): boolean { return this.timesOfDay.indexOf(globalScene.arena.getTimeOfDay()) > -1; } } @@ -289,10 +308,12 @@ export class SpeciesFormChangeTimeOfDayTrigger extends SpeciesFormChangeTrigger export class SpeciesFormChangeActiveTrigger extends SpeciesFormChangeTrigger { public active: boolean; - constructor(active: boolean = false) { + constructor(active = false) { super(); this.active = active; - this.description = this.active ? i18next.t("pokemonEvolutions:Forms.enter") : i18next.t("pokemonEvolutions:Forms.leave"); + this.description = this.active + ? i18next.t("pokemonEvolutions:Forms.enter") + : i18next.t("pokemonEvolutions:Forms.leave"); } canChange(pokemon: Pokemon): boolean { @@ -304,10 +325,10 @@ export class SpeciesFormChangeStatusEffectTrigger extends SpeciesFormChangeTrigg public statusEffects: StatusEffect[]; public invert: boolean; - constructor(statusEffects: StatusEffect | StatusEffect[], invert: boolean = false) { + constructor(statusEffects: StatusEffect | StatusEffect[], invert = false) { super(); if (!Array.isArray(statusEffects)) { - statusEffects = [ statusEffects ]; + statusEffects = [statusEffects]; } this.statusEffects = statusEffects; this.invert = invert; @@ -315,7 +336,7 @@ export class SpeciesFormChangeStatusEffectTrigger extends SpeciesFormChangeTrigg } canChange(pokemon: Pokemon): boolean { - return (this.statusEffects.indexOf(pokemon.status?.effect || StatusEffect.NONE) > -1) !== this.invert; + return this.statusEffects.indexOf(pokemon.status?.effect || StatusEffect.NONE) > -1 !== this.invert; } } @@ -323,17 +344,26 @@ export class SpeciesFormChangeMoveLearnedTrigger extends SpeciesFormChangeTrigge public move: Moves; public known: boolean; - constructor(move: Moves, known: boolean = true) { + constructor(move: Moves, known = true) { super(); this.move = move; this.known = known; - const moveKey = Moves[this.move].split("_").filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join("") as unknown as string; - this.description = known ? i18next.t("pokemonEvolutions:Forms.moveLearned", { move: i18next.t(`move:${moveKey}.name`) }) : - i18next.t("pokemonEvolutions:Forms.moveForgotten", { move: i18next.t(`move:${moveKey}.name`) }); + const moveKey = Moves[this.move] + .split("_") + .filter(f => f) + .map((f, i) => (i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase())) + .join("") as unknown as string; + this.description = known + ? i18next.t("pokemonEvolutions:Forms.moveLearned", { + move: i18next.t(`move:${moveKey}.name`), + }) + : i18next.t("pokemonEvolutions:Forms.moveForgotten", { + move: i18next.t(`move:${moveKey}.name`), + }); } canChange(pokemon: Pokemon): boolean { - return (!!pokemon.moveset.filter(m => m?.moveId === this.move).length) === this.known; + return !!pokemon.moveset.filter(m => m?.moveId === this.move).length === this.known; } } @@ -341,7 +371,7 @@ export abstract class SpeciesFormChangeMoveTrigger extends SpeciesFormChangeTrig public movePredicate: (m: Moves) => boolean; public used: boolean; - constructor(move: Moves | ((m: Moves) => boolean), used: boolean = true) { + constructor(move: Moves | ((m: Moves) => boolean), used = true) { super(); this.movePredicate = typeof move === "function" ? move : (m: Moves) => m === move; this.used = used; @@ -361,7 +391,9 @@ export class SpeciesFormChangePostMoveTrigger extends SpeciesFormChangeMoveTrigg description = i18next.t("pokemonEvolutions:Forms.postMove"); canChange(pokemon: Pokemon): boolean { - return pokemon.summonData && !!pokemon.getLastXMoves(1).filter(m => this.movePredicate(m.move)).length === this.used; + return ( + pokemon.summonData && !!pokemon.getLastXMoves(1).filter(m => this.movePredicate(m.move)).length === this.used + ); } } @@ -369,13 +401,12 @@ export class MeloettaFormChangePostMoveTrigger extends SpeciesFormChangePostMove override canChange(pokemon: Pokemon): boolean { if (globalScene.gameMode.hasChallenge(Challenges.SINGLE_TYPE)) { return false; - } else { - // Meloetta will not transform if it has the ability Sheer Force when using Relic Song - if (pokemon.hasAbility(Abilities.SHEER_FORCE)) { - return false; - } - return super.canChange(pokemon); } + // Meloetta will not transform if it has the ability Sheer Force when using Relic Song + if (pokemon.hasAbility(Abilities.SHEER_FORCE)) { + return false; + } + return super.canChange(pokemon); } } @@ -389,7 +420,11 @@ export class SpeciesDefaultFormMatchTrigger extends SpeciesFormChangeTrigger { } canChange(pokemon: Pokemon): boolean { - return this.formKey === pokemon.species.forms[globalScene.getSpeciesFormIndex(pokemon.species, pokemon.gender, pokemon.getNature(), true)].formKey; + return ( + this.formKey === + pokemon.species.forms[globalScene.getSpeciesFormIndex(pokemon.species, pokemon.gender, pokemon.getNature(), true)] + .formKey + ); } } @@ -399,7 +434,7 @@ export class SpeciesDefaultFormMatchTrigger extends SpeciesFormChangeTrigger { * @extends SpeciesFormChangeTrigger */ export class SpeciesFormChangeTeraTrigger extends SpeciesFormChangeTrigger { - description = i18next.t("pokemonEvolutions:Forms.tera" ); + description = i18next.t("pokemonEvolutions:Forms.tera"); } /** @@ -440,7 +475,12 @@ export class SpeciesFormChangeWeatherTrigger extends SpeciesFormChangeTrigger { const isWeatherSuppressed = globalScene.arena.weather?.isEffectSuppressed(); const isAbilitySuppressed = pokemon.summonData.abilitySuppressed; - return !isAbilitySuppressed && !isWeatherSuppressed && (pokemon.hasAbility(this.ability) && this.weathers.includes(currentWeather)); + return ( + !isAbilitySuppressed && + !isWeatherSuppressed && + pokemon.hasAbility(this.ability) && + this.weathers.includes(currentWeather) + ); } } @@ -491,16 +531,27 @@ export function getSpeciesFormChangeMessage(pokemon: Pokemon, formChange: Specie const isEmax = formChange.formKey.indexOf(SpeciesFormKey.ETERNAMAX) > -1; const isRevert = !isMega && formChange.formKey === pokemon.species.forms[0].formKey; if (isMega) { - return i18next.t("battlePokemonForm:megaChange", { preName, pokemonName: pokemon.name }); + return i18next.t("battlePokemonForm:megaChange", { + preName, + pokemonName: pokemon.name, + }); } if (isGmax) { - return i18next.t("battlePokemonForm:gigantamaxChange", { preName, pokemonName: pokemon.name }); + return i18next.t("battlePokemonForm:gigantamaxChange", { + preName, + pokemonName: pokemon.name, + }); } if (isEmax) { - return i18next.t("battlePokemonForm:eternamaxChange", { preName, pokemonName: pokemon.name }); + return i18next.t("battlePokemonForm:eternamaxChange", { + preName, + pokemonName: pokemon.name, + }); } if (isRevert) { - return i18next.t("battlePokemonForm:revertChange", { pokemonName: getPokemonNameWithAffix(pokemon) }); + return i18next.t("battlePokemonForm:revertChange", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } if (pokemon.getAbility().id === Abilities.DISGUISE) { return i18next.t("battlePokemonForm:disguiseChange"); @@ -515,13 +566,14 @@ export function getSpeciesFormChangeMessage(pokemon: Pokemon, formChange: Specie * @returns A {@linkcode SpeciesFormChangeCondition} checking if that species is registered as caught */ function getSpeciesDependentFormChangeCondition(species: Species): SpeciesFormChangeCondition { - return new SpeciesFormChangeCondition(p => !!globalScene.gameData.dexData[species].caughtAttr); + return new SpeciesFormChangeCondition(_p => !!globalScene.gameData.dexData[species].caughtAttr); } interface PokemonFormChanges { - [key: string]: SpeciesFormChange[] + [key: string]: SpeciesFormChange[]; } +// biome-ignore format: manually formatted export const pokemonFormChanges: PokemonFormChanges = { [Species.VENUSAUR]: [ new SpeciesFormChange(Species.VENUSAUR, "", SpeciesFormKey.MEGA, new SpeciesFormChangeItemTrigger(FormChangeItem.VENUSAURITE)), @@ -994,16 +1046,22 @@ export const pokemonFormChanges: PokemonFormChanges = { export function initPokemonForms() { const formChangeKeys = Object.keys(pokemonFormChanges); - formChangeKeys.forEach(pk => { + for (const pk of formChangeKeys) { const formChanges = pokemonFormChanges[pk]; const newFormChanges: SpeciesFormChange[] = []; for (const fc of formChanges) { const itemTrigger = fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger; if (itemTrigger && !formChanges.find(c => fc.formKey === c.preFormKey && fc.preFormKey === c.formKey)) { - newFormChanges.push(new SpeciesFormChange(fc.speciesId, fc.formKey, fc.preFormKey, new SpeciesFormChangeItemTrigger(itemTrigger.item, false))); + newFormChanges.push( + new SpeciesFormChange( + fc.speciesId, + fc.formKey, + fc.preFormKey, + new SpeciesFormChangeItemTrigger(itemTrigger.item, false), + ), + ); } } formChanges.push(...newFormChanges); - }); + } } - diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 796678a200c..1bf97209613 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -13,10 +13,18 @@ import { uncatchableSpecies } from "#app/data/balance/biomes"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { GrowthRate } from "#app/data/exp"; import type { EvolutionLevel } from "#app/data/balance/pokemon-evolutions"; -import { SpeciesWildEvolutionDelay, pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; +import { + SpeciesWildEvolutionDelay, + pokemonEvolutions, + pokemonPrevolutions, +} from "#app/data/balance/pokemon-evolutions"; import { PokemonType } from "#enums/pokemon-type"; import type { LevelMoves } from "#app/data/balance/pokemon-level-moves"; -import { pokemonFormLevelMoves, pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balance/pokemon-level-moves"; +import { + pokemonFormLevelMoves, + pokemonFormLevelMoves as pokemonSpeciesFormLevelMoves, + pokemonSpeciesLevelMoves, +} from "#app/data/balance/pokemon-level-moves"; import type { Stat } from "#enums/stat"; import type { Variant, VariantSet } from "#app/data/variant"; import { variantData } from "#app/data/variant"; @@ -29,7 +37,7 @@ export enum Region { ALOLA, GALAR, HISUI, - PALDEA + PALDEA, } // TODO: this is horrible and will need to be removed once a refactor/cleanup of forms is executed. @@ -60,7 +68,7 @@ export const normalForm: Species[] = [ Species.MARSHADOW, Species.CRAMORANT, Species.ZARUDE, - Species.CALYREX + Species.CALYREX, ]; /** @@ -81,9 +89,10 @@ export function getPokemonSpecies(species: Species | Species[]): PokemonSpecies } export function getPokemonSpeciesForm(species: Species, formIndex: number): PokemonSpeciesForm { - const retSpecies: PokemonSpecies = species >= 2000 - ? allSpecies.find(s => s.speciesId === species)! // TODO: is the bang correct? - : allSpecies[species - 1]; + const retSpecies: PokemonSpecies = + species >= 2000 + ? allSpecies.find(s => s.speciesId === species)! // TODO: is the bang correct? + : allSpecies[species - 1]; if (formIndex < retSpecies.forms?.length) { return retSpecies.forms[formIndex]; } @@ -94,8 +103,8 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string): const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i; const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i; - const [ speciesAPrefixMatch, speciesBPrefixMatch ] = [ speciesAName, speciesBName ].map(n => /^(?:[^ ]+) /.exec(n)); - const [ speciesAPrefix, speciesBPrefix ] = [ speciesAPrefixMatch, speciesBPrefixMatch ].map(m => m ? m[0] : ""); + const [speciesAPrefixMatch, speciesBPrefixMatch] = [speciesAName, speciesBName].map(n => /^(?:[^ ]+) /.exec(n)); + const [speciesAPrefix, speciesBPrefix] = [speciesAPrefixMatch, speciesBPrefixMatch].map(m => (m ? m[0] : "")); if (speciesAPrefix) { speciesAName = speciesAName.slice(speciesAPrefix.length); @@ -104,8 +113,8 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string): speciesBName = speciesBName.slice(speciesBPrefix.length); } - const [ speciesASuffixMatch, speciesBSuffixMatch ] = [ speciesAName, speciesBName ].map(n => / (?:[^ ]+)$/.exec(n)); - const [ speciesASuffix, speciesBSuffix ] = [ speciesASuffixMatch, speciesBSuffixMatch ].map(m => m ? m[0] : ""); + const [speciesASuffixMatch, speciesBSuffixMatch] = [speciesAName, speciesBName].map(n => / (?:[^ ]+)$/.exec(n)); + const [speciesASuffix, speciesBSuffix] = [speciesASuffixMatch, speciesBSuffixMatch].map(m => (m ? m[0] : "")); if (speciesASuffix) { speciesAName = speciesAName.slice(0, -speciesASuffix.length); @@ -123,9 +132,7 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string): let fragA: string; let fragB: string; - fragA = splitNameA.length === 1 - ? fragAMatch ? fragAMatch[1] : speciesAName - : splitNameA[splitNameA.length - 1]; + fragA = splitNameA.length === 1 ? (fragAMatch ? fragAMatch[1] : speciesAName) : splitNameA[splitNameA.length - 1]; if (splitNameB.length === 1) { if (fragBMatch) { @@ -179,9 +186,26 @@ export abstract class PokemonSpeciesForm { readonly genderDiffs: boolean; readonly isStarterSelectable: boolean; - constructor(type1: PokemonType, type2: PokemonType | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities, - baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number, - catchRate: number, baseFriendship: number, baseExp: number, genderDiffs: boolean, isStarterSelectable: boolean + constructor( + type1: PokemonType, + type2: PokemonType | null, + height: number, + weight: number, + ability1: Abilities, + ability2: Abilities, + abilityHidden: Abilities, + baseTotal: number, + baseHp: number, + baseAtk: number, + baseDef: number, + baseSpatk: number, + baseSpdef: number, + baseSpd: number, + catchRate: number, + baseFriendship: number, + baseExp: number, + genderDiffs: boolean, + isStarterSelectable: boolean, ) { this.type1 = type1; this.type2 = type2; @@ -191,7 +215,7 @@ export abstract class PokemonSpeciesForm { this.ability2 = ability2 === Abilities.NONE ? ability1 : ability2; this.abilityHidden = abilityHidden; this.baseTotal = baseTotal; - this.baseStats = [ baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd ]; + this.baseStats = [baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd]; this.catchRate = catchRate; this.baseFriendship = baseFriendship; this.baseExp = baseExp; @@ -206,7 +230,7 @@ export abstract class PokemonSpeciesForm { * @param forStarter boolean to get the nonbaby form of a starter * @returns The species */ - getRootSpeciesId(forStarter: boolean = false): Species { + getRootSpeciesId(forStarter = false): Species { let ret = this.speciesId; while (pokemonPrevolutions.hasOwnProperty(ret) && (!forStarter || !speciesStarterCosts.hasOwnProperty(ret))) { ret = pokemonPrevolutions[ret]; @@ -269,23 +293,29 @@ export abstract class PokemonSpeciesForm { formIndex = this.formIndex; } let starterSpeciesId = this.speciesId; - while (!(starterSpeciesId in starterPassiveAbilities) || !(formIndex in starterPassiveAbilities[starterSpeciesId])) { + while ( + !(starterSpeciesId in starterPassiveAbilities) || + !(formIndex in starterPassiveAbilities[starterSpeciesId]) + ) { if (pokemonPrevolutions.hasOwnProperty(starterSpeciesId)) { starterSpeciesId = pokemonPrevolutions[starterSpeciesId]; - } else { // If we've reached the base species and still haven't found a matching ability, use form 0 if possible + } else { + // If we've reached the base species and still haven't found a matching ability, use form 0 if possible if (0 in starterPassiveAbilities[starterSpeciesId]) { return starterPassiveAbilities[starterSpeciesId][0]; - } else { - console.log("No passive ability found for %s, using run away", this.speciesId); - return Abilities.RUN_AWAY; } + console.log("No passive ability found for %s, using run away", this.speciesId); + return Abilities.RUN_AWAY; } } return starterPassiveAbilities[starterSpeciesId][formIndex]; } getLevelMoves(): LevelMoves { - if (pokemonSpeciesFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonSpeciesFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) { + if ( + pokemonSpeciesFormLevelMoves.hasOwnProperty(this.speciesId) && + pokemonSpeciesFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex) + ) { return pokemonSpeciesFormLevelMoves[this.speciesId][this.formIndex].slice(0); } return pokemonSpeciesLevelMoves[this.speciesId].slice(0); @@ -296,7 +326,7 @@ export abstract class PokemonSpeciesForm { } isObtainable(): boolean { - return (this.generation <= 9 || pokemonPrevolutions.hasOwnProperty(this.speciesId)); + return this.generation <= 9 || pokemonPrevolutions.hasOwnProperty(this.speciesId); } isCatchable(): boolean { @@ -308,7 +338,7 @@ export abstract class PokemonSpeciesForm { } isTrainerForbidden(): boolean { - return [ Species.ETERNAL_FLOETTE, Species.BLOODMOON_URSALUNA ].includes(this.speciesId); + return [Species.ETERNAL_FLOETTE, Species.BLOODMOON_URSALUNA].includes(this.speciesId); } isRareRegional(): boolean { @@ -357,18 +387,19 @@ export abstract class PokemonSpeciesForm { return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`; } - getSpriteId(female: boolean, formIndex?: number, shiny?: boolean, variant: number = 0, back?: boolean): string { + getSpriteId(female: boolean, formIndex?: number, shiny?: boolean, variant = 0, back?: boolean): string { if (formIndex === undefined || this instanceof PokemonForm) { formIndex = this.formIndex; } const formSpriteKey = this.getFormSpriteKey(formIndex); - const showGenderDiffs = this.genderDiffs && female && ![ SpeciesFormKey.MEGA, SpeciesFormKey.GIGANTAMAX ].find(k => formSpriteKey === k); + const showGenderDiffs = + this.genderDiffs && female && ![SpeciesFormKey.MEGA, SpeciesFormKey.GIGANTAMAX].find(k => formSpriteKey === k); const baseSpriteKey = `${showGenderDiffs ? "female__" : ""}${this.speciesId}${formSpriteKey ? `-${formSpriteKey}` : ""}`; let config = variantData; - `${back ? "back__" : ""}${baseSpriteKey}`.split("__").map(p => config ? config = config[p] : null); + `${back ? "back__" : ""}${baseSpriteKey}`.split("__").map(p => (config ? (config = config[p]) : null)); const variantSet = config as VariantSet; return `${back ? "back__" : ""}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? "shiny__" : ""}${baseSpriteKey}${shiny && variantSet && variantSet[variant] === 2 ? `_${variant + 1}` : ""}`; @@ -380,7 +411,6 @@ export abstract class PokemonSpeciesForm { abstract getFormSpriteKey(formIndex?: number): string; - /** * Variant Data key/index is either species id or species id followed by -formkey * @param formIndex optional form index for pokemon with different forms @@ -401,7 +431,8 @@ export abstract class PokemonSpeciesForm { getIconAtlasKey(formIndex?: number, shiny?: boolean, variant?: number): string { const variantDataIndex = this.getVariantDataIndex(formIndex); - const isVariant = shiny && variantData[variantDataIndex] && (variant !== undefined && variantData[variantDataIndex][variant]); + const isVariant = + shiny && variantData[variantDataIndex] && variant !== undefined && variantData[variantDataIndex][variant]; return `pokemon_icons_${this.generation}${isVariant ? "v" : ""}`; } @@ -414,7 +445,8 @@ export abstract class PokemonSpeciesForm { let ret = this.speciesId.toString(); - const isVariant = shiny && variantData[variantDataIndex] && (variant !== undefined && variantData[variantDataIndex][variant]); + const isVariant = + shiny && variantData[variantDataIndex] && variant !== undefined && variantData[variantDataIndex][variant]; if (shiny && !isVariant) { ret += "s"; @@ -479,7 +511,9 @@ export abstract class PokemonSpeciesForm { const forms = getPokemonSpecies(speciesId).forms; if (forms.length) { if (formIndex !== undefined && formIndex >= forms.length) { - console.warn(`Attempted accessing form with index ${formIndex} of species ${getPokemonSpecies(speciesId).getName()} with only ${forms.length || 0} forms`); + console.warn( + `Attempted accessing form with index ${formIndex} of species ${getPokemonSpecies(speciesId).getName()} with only ${forms.length || 0} forms`, + ); formIndex = Math.min(formIndex, forms.length - 1); } const formKey = forms[formIndex || 0].formKey; @@ -532,11 +566,14 @@ export abstract class PokemonSpeciesForm { for (const moveId of moveset) { if (speciesEggMoves.hasOwnProperty(rootSpeciesId)) { const eggMoveIndex = speciesEggMoves[rootSpeciesId].findIndex(m => m === moveId); - if (eggMoveIndex > -1 && (eggMoves & (1 << eggMoveIndex))) { + if (eggMoveIndex > -1 && eggMoves & (1 << eggMoveIndex)) { continue; } } - if (pokemonFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) { + if ( + pokemonFormLevelMoves.hasOwnProperty(this.speciesId) && + pokemonFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex) + ) { if (!pokemonFormLevelMoves[this.speciesId][this.formIndex].find(lm => lm[0] <= 5 && lm[1] === moveId)) { return false; } @@ -548,7 +585,14 @@ export abstract class PokemonSpeciesForm { return true; } - loadAssets(female: boolean, formIndex?: number, shiny?: boolean, variant?: Variant, startLoad?: boolean, back?: boolean): Promise { + loadAssets( + female: boolean, + formIndex?: number, + shiny?: boolean, + variant?: Variant, + startLoad?: boolean, + back?: boolean, + ): Promise { return new Promise(resolve => { const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant, back); globalScene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant, back)); @@ -557,19 +601,26 @@ export abstract class PokemonSpeciesForm { const originalWarn = console.warn; // Ignore warnings for missing frames, because there will be a lot console.warn = () => {}; - const frameNames = globalScene.anims.generateFrameNames(spriteKey, { zeroPad: 4, suffix: ".png", start: 1, end: 400 }); + const frameNames = globalScene.anims.generateFrameNames(spriteKey, { + zeroPad: 4, + suffix: ".png", + start: 1, + end: 400, + }); console.warn = originalWarn; - if (!(globalScene.anims.exists(spriteKey))) { + if (!globalScene.anims.exists(spriteKey)) { globalScene.anims.create({ key: this.getSpriteKey(female, formIndex, shiny, variant, back), frames: frameNames, frameRate: 10, - repeat: -1 + repeat: -1, }); } else { globalScene.anims.get(spriteKey).frameRate = 10; } - const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant, back).replace("variant/", "").replace(/_[1-3]$/, ""); + const spritePath = this.getSpriteAtlasPath(female, formIndex, shiny, variant, back) + .replace("variant/", "") + .replace(/_[1-3]$/, ""); globalScene.loadPokemonVariantAssets(spriteKey, spritePath, variant).then(() => resolve()); }); if (startLoad) { @@ -618,9 +669,9 @@ export abstract class PokemonSpeciesForm { for (let i = 0; i < pixelData.length; i += 4) { if (pixelData[i + 3]) { const pixel = pixelData.slice(i, i + 4); - const [ r, g, b, a ] = pixel; + const [r, g, b, a] = pixel; if (!spriteColors.find(c => c[0] === r && c[1] === g && c[2] === b)) { - spriteColors.push([ r, g, b, a ]); + spriteColors.push([r, g, b, a]); } } } @@ -630,7 +681,14 @@ export abstract class PokemonSpeciesForm { if (!total) { continue; } - pixelColors.push(argbFromRgba({ r: pixelData[i], g: pixelData[i + 1], b: pixelData[i + 2], a: pixelData[i + 3] })); + pixelColors.push( + argbFromRgba({ + r: pixelData[i], + g: pixelData[i + 1], + b: pixelData[i + 2], + a: pixelData[i + 3], + }), + ); } } @@ -639,9 +697,13 @@ export abstract class PokemonSpeciesForm { const originalRandom = Math.random; Math.random = () => Phaser.Math.RND.realInRange(0, 1); - globalScene.executeWithSeedOffset(() => { - paletteColors = QuantizerCelebi.quantize(pixelColors, 2); - }, 0, "This result should not vary"); + globalScene.executeWithSeedOffset( + () => { + paletteColors = QuantizerCelebi.quantize(pixelColors, 2); + }, + 0, + "This result should not vary", + ); Math.random = originalRandom; @@ -661,14 +723,57 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali readonly canChangeForm: boolean; readonly forms: PokemonForm[]; - constructor(id: Species, generation: number, subLegendary: boolean, legendary: boolean, mythical: boolean, species: string, - type1: PokemonType, type2: PokemonType | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities, - baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number, - catchRate: number, baseFriendship: number, baseExp: number, growthRate: GrowthRate, malePercent: number | null, - genderDiffs: boolean, canChangeForm?: boolean, ...forms: PokemonForm[] + constructor( + id: Species, + generation: number, + subLegendary: boolean, + legendary: boolean, + mythical: boolean, + species: string, + type1: PokemonType, + type2: PokemonType | null, + height: number, + weight: number, + ability1: Abilities, + ability2: Abilities, + abilityHidden: Abilities, + baseTotal: number, + baseHp: number, + baseAtk: number, + baseDef: number, + baseSpatk: number, + baseSpdef: number, + baseSpd: number, + catchRate: number, + baseFriendship: number, + baseExp: number, + growthRate: GrowthRate, + malePercent: number | null, + genderDiffs: boolean, + canChangeForm?: boolean, + ...forms: PokemonForm[] ) { - super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd, - catchRate, baseFriendship, baseExp, genderDiffs, false); + super( + type1, + type2, + height, + weight, + ability1, + ability2, + abilityHidden, + baseTotal, + baseHp, + baseAtk, + baseDef, + baseSpatk, + baseSpdef, + baseSpd, + catchRate, + baseFriendship, + baseExp, + genderDiffs, + false, + ); this.speciesId = id; this.formIndex = 0; this.generation = generation; @@ -712,7 +817,9 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } if (key) { - return i18next.t(`battlePokemonForm:${key}`, { pokemonName: this.name }); + return i18next.t(`battlePokemonForm:${key}`, { + pokemonName: this.name, + }); } } return this.name; @@ -725,29 +832,47 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali getExpandedSpeciesName(): string { if (this.speciesId < 2000) { return this.name; // Other special cases could be put here too - } else { // Everything beyond this point essentially follows the pattern of FORMNAME_SPECIES - return i18next.t(`pokemonForm:appendForm.${Species[this.speciesId].split("_")[0]}`, { pokemonName: this.name }); } + // Everything beyond this point essentially follows the pattern of FORMNAME_SPECIES + return i18next.t(`pokemonForm:appendForm.${Species[this.speciesId].split("_")[0]}`, { pokemonName: this.name }); } /** - * Find the form name for species with just one form (regional variants, Floette, Ursaluna) - * @param formIndex The form index to check (defaults to 0) - * @param append Whether to append the species name to the end (defaults to false) - * @returns the pokemon-form locale key for the single form name ("Alolan Form", "Eternal Flower" etc) - */ - getFormNameToDisplay(formIndex: number = 0, append: boolean = false): string { + * Find the form name for species with just one form (regional variants, Floette, Ursaluna) + * @param formIndex The form index to check (defaults to 0) + * @param append Whether to append the species name to the end (defaults to false) + * @returns the pokemon-form locale key for the single form name ("Alolan Form", "Eternal Flower" etc) + */ + getFormNameToDisplay(formIndex = 0, append = false): string { const formKey = this.forms?.[formIndex!]?.formKey; const formText = Utils.capitalizeString(formKey, "-", false, false) || ""; const speciesName = Utils.capitalizeString(Species[this.speciesId], "_", true, false); - let ret: string = ""; + let ret = ""; const region = this.getRegion(); if (this.speciesId === Species.ARCEUS) { ret = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`); - } else if ([ SpeciesFormKey.MEGA, SpeciesFormKey.MEGA_X, SpeciesFormKey.MEGA_Y, SpeciesFormKey.PRIMAL, SpeciesFormKey.GIGANTAMAX, SpeciesFormKey.GIGANTAMAX_RAPID, SpeciesFormKey.GIGANTAMAX_SINGLE, SpeciesFormKey.ETERNAMAX ].includes(formKey as SpeciesFormKey)) { - return append ? i18next.t(`battlePokemonForm:${formKey}`, { pokemonName: this.name }) : i18next.t(`pokemonForm:battleForm.${formKey}`); - } else if (region === Region.NORMAL || (this.speciesId === Species.GALAR_DARMANITAN && formIndex > 0) || this.speciesId === Species.PALDEA_TAUROS) { // More special cases can be added here + } else if ( + [ + SpeciesFormKey.MEGA, + SpeciesFormKey.MEGA_X, + SpeciesFormKey.MEGA_Y, + SpeciesFormKey.PRIMAL, + SpeciesFormKey.GIGANTAMAX, + SpeciesFormKey.GIGANTAMAX_RAPID, + SpeciesFormKey.GIGANTAMAX_SINGLE, + SpeciesFormKey.ETERNAMAX, + ].includes(formKey as SpeciesFormKey) + ) { + return append + ? i18next.t(`battlePokemonForm:${formKey}`, { pokemonName: this.name }) + : i18next.t(`pokemonForm:battleForm.${formKey}`); + } else if ( + region === Region.NORMAL || + (this.speciesId === Species.GALAR_DARMANITAN && formIndex > 0) || + this.speciesId === Species.PALDEA_TAUROS + ) { + // More special cases can be added here const i18key = `pokemonForm:${speciesName}${formText}`; if (i18next.exists(i18key)) { ret = i18next.t(i18key); @@ -756,16 +881,25 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali const i18RootKey = `pokemonForm:${rootSpeciesName}${formText}`; ret = i18next.exists(i18RootKey) ? i18next.t(i18RootKey) : formText; } - } else if (append) { // Everything beyond this has an expanded name + } else if (append) { + // Everything beyond this has an expanded name return this.getExpandedSpeciesName(); - } else if (this.speciesId === Species.ETERNAL_FLOETTE) { // Not a real form, so the key is made up + } else if (this.speciesId === Species.ETERNAL_FLOETTE) { + // Not a real form, so the key is made up return i18next.t("pokemonForm:floetteEternalFlower"); - } else if (this.speciesId === Species.BLOODMOON_URSALUNA) { // Not a real form, so the key is made up + } else if (this.speciesId === Species.BLOODMOON_URSALUNA) { + // Not a real form, so the key is made up return i18next.t("pokemonForm:ursalunaBloodmoon"); - } else { // Only regional forms should be left at this point + } else { + // Only regional forms should be left at this point return i18next.t(`pokemonForm:regionalForm.${Region[region]}`); } - return append ? i18next.t("pokemonForm:appendForm.GENERIC", { pokemonName: this.name, formName: ret }) : ret; + return append + ? i18next.t("pokemonForm:appendForm.GENERIC", { + pokemonName: this.name, + formName: ret, + }) + : ret; } localize(): void { @@ -773,10 +907,20 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): Species { - return this.getSpeciesForLevel(level, allowEvolving, false, (isBoss ? PartyMemberStrength.WEAKER : PartyMemberStrength.AVERAGE) + (gameMode?.isEndless ? 1 : 0)); + return this.getSpeciesForLevel( + level, + allowEvolving, + false, + (isBoss ? PartyMemberStrength.WEAKER : PartyMemberStrength.AVERAGE) + (gameMode?.isEndless ? 1 : 0), + ); } - getTrainerSpeciesForLevel(level: number, allowEvolving: boolean = false, strength: PartyMemberStrength, currentWave: number = 0): Species { + getTrainerSpeciesForLevel( + level: number, + allowEvolving = false, + strength: PartyMemberStrength, + currentWave = 0, + ): Species { return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave); } @@ -815,7 +959,13 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } } - getSpeciesForLevel(level: number, allowEvolving: boolean = false, forTrainer: boolean = false, strength: PartyMemberStrength = PartyMemberStrength.WEAKER, currentWave: number = 0): Species { + getSpeciesForLevel( + level: number, + allowEvolving = false, + forTrainer = false, + strength: PartyMemberStrength = PartyMemberStrength.WEAKER, + currentWave = 0, + ): Species { const prevolutionLevels = this.getPrevolutionLevels(); if (prevolutionLevels.length) { @@ -827,10 +977,13 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } } - if ( // If evolutions shouldn't happen, add more cases here :) - !allowEvolving - || !pokemonEvolutions.hasOwnProperty(this.speciesId) - || globalScene.currentBattle?.waveIndex === 20 && globalScene.gameMode.isClassic && globalScene.currentBattle.trainer + if ( + // If evolutions shouldn't happen, add more cases here :) + !allowEvolving || + !pokemonEvolutions.hasOwnProperty(this.speciesId) || + (globalScene.currentBattle?.waveIndex === 20 && + globalScene.gameMode.isClassic && + globalScene.currentBattle.trainer) ) { return this.speciesId; } @@ -864,20 +1017,32 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali const maxLevelDiff = this.getStrengthLevelDiff(strength); //The maximum distance from the evolution level tolerated for the mon to not evolve const minChance: number = 0.875 - 0.125 * strength; - evolutionChance = Math.min(minChance + easeInFunc(Math.min(level - ev.level, maxLevelDiff) / maxLevelDiff) * (1 - minChance), 1); + evolutionChance = Math.min( + minChance + easeInFunc(Math.min(level - ev.level, maxLevelDiff) / maxLevelDiff) * (1 - minChance), + 1, + ); } } else { - const preferredMinLevel = Math.max((ev.level - 1) + (ev.wildDelay!) * this.getStrengthLevelDiff(strength), 1); // TODO: is the bang correct? + const preferredMinLevel = Math.max(ev.level - 1 + ev.wildDelay! * this.getStrengthLevelDiff(strength), 1); // TODO: is the bang correct? let evolutionLevel = Math.max(ev.level > 1 ? ev.level : Math.floor(preferredMinLevel / 2), 1); if (ev.level <= 1 && pokemonPrevolutions.hasOwnProperty(this.speciesId)) { - const prevolutionLevel = pokemonEvolutions[pokemonPrevolutions[this.speciesId]].find(ev => ev.speciesId === this.speciesId)!.level; // TODO: is the bang correct? + const prevolutionLevel = pokemonEvolutions[pokemonPrevolutions[this.speciesId]].find( + ev => ev.speciesId === this.speciesId, + )!.level; // TODO: is the bang correct? if (prevolutionLevel > 1) { evolutionLevel = prevolutionLevel; } } - evolutionChance = Math.min(0.65 * easeInFunc(Math.min(Math.max(level - evolutionLevel, 0), preferredMinLevel) / preferredMinLevel) + 0.35 * easeOutFunc(Math.min(Math.max(level - evolutionLevel, 0), preferredMinLevel * 2.5) / (preferredMinLevel * 2.5)), 1); + evolutionChance = Math.min( + 0.65 * easeInFunc(Math.min(Math.max(level - evolutionLevel, 0), preferredMinLevel) / preferredMinLevel) + + 0.35 * + easeOutFunc( + Math.min(Math.max(level - evolutionLevel, 0), preferredMinLevel * 2.5) / (preferredMinLevel * 2.5), + ), + 1, + ); } } @@ -890,14 +1055,14 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali if (evolutionChance > 0) { if (isRegionalEvolution) { - evolutionChance /= (evolutionSpecies.isRareRegional() ? 16 : 4); + evolutionChance /= evolutionSpecies.isRareRegional() ? 16 : 4; } totalWeight += evolutionChance; evolutionPool.set(totalWeight, ev.speciesId); - if ((1 - evolutionChance) < noEvolutionChance) { + if (1 - evolutionChance < noEvolutionChance) { noEvolutionChance = 1 - evolutionChance; } } @@ -912,7 +1077,13 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali for (const weight of evolutionPool.keys()) { if (randValue < weight) { // TODO: this entire function is dumb and should be changed, adding a `!` here for now until then - return getPokemonSpecies(evolutionPool.get(weight)!).getSpeciesForLevel(level, true, forTrainer, strength, currentWave); + return getPokemonSpecies(evolutionPool.get(weight)!).getSpeciesForLevel( + level, + true, + forTrainer, + strength, + currentWave, + ); } } @@ -928,7 +1099,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali for (const e of pokemonEvolutions[this.speciesId]) { const speciesId = e.speciesId; const level = e.level; - evolutionLevels.push([ speciesId, level ]); + evolutionLevels.push([speciesId, level]); //console.log(Species[speciesId], getPokemonSpecies(speciesId), getPokemonSpecies(speciesId).getEvolutionLevels()); const nextEvolutionLevels = getPokemonSpecies(speciesId).getEvolutionLevels(); for (const npl of nextEvolutionLevels) { @@ -946,10 +1117,14 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali const allEvolvingPokemon = Object.keys(pokemonEvolutions); for (const p of allEvolvingPokemon) { for (const e of pokemonEvolutions[p]) { - if (e.speciesId === this.speciesId && (!this.forms.length || !e.evoFormKey || e.evoFormKey === this.forms[this.formIndex].formKey) && prevolutionLevels.every(pe => pe[0] !== parseInt(p))) { - const speciesId = parseInt(p) as Species; + if ( + e.speciesId === this.speciesId && + (!this.forms.length || !e.evoFormKey || e.evoFormKey === this.forms[this.formIndex].formKey) && + prevolutionLevels.every(pe => pe[0] !== Number.parseInt(p)) + ) { + const speciesId = Number.parseInt(p) as Species; const level = e.level; - prevolutionLevels.push([ speciesId, level ]); + prevolutionLevels.push([speciesId, level]); const subPrevolutionLevels = getPokemonSpecies(speciesId).getPrevolutionLevels(); for (const spl of subPrevolutionLevels) { prevolutionLevels.push(spl); @@ -962,21 +1137,53 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } // This could definitely be written better and more accurate to the getSpeciesForLevel logic, but it is only for generating movesets for evolved Pokemon - getSimulatedEvolutionChain(currentLevel: number, forTrainer: boolean = false, isBoss: boolean = false, player: boolean = false): EvolutionLevel[] { + getSimulatedEvolutionChain( + currentLevel: number, + forTrainer = false, + isBoss = false, + player = false, + ): EvolutionLevel[] { const ret: EvolutionLevel[] = []; if (pokemonPrevolutions.hasOwnProperty(this.speciesId)) { const prevolutionLevels = this.getPrevolutionLevels().reverse(); - const levelDiff = player ? 0 : forTrainer || isBoss ? forTrainer && isBoss ? 2.5 : 5 : 10; - ret.push([ prevolutionLevels[0][0], 1 ]); + const levelDiff = player ? 0 : forTrainer || isBoss ? (forTrainer && isBoss ? 2.5 : 5) : 10; + ret.push([prevolutionLevels[0][0], 1]); for (let l = 1; l < prevolutionLevels.length; l++) { - const evolution = pokemonEvolutions[prevolutionLevels[l - 1][0]].find(e => e.speciesId === prevolutionLevels[l][0]); - ret.push([ prevolutionLevels[l][0], Math.min(Math.max((evolution?.level!) + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max((evolution?.wildDelay!), 0.5) * 5) - 1, 2, (evolution?.level!)), currentLevel - 1) ]); // TODO: are those bangs correct? + const evolution = pokemonEvolutions[prevolutionLevels[l - 1][0]].find( + e => e.speciesId === prevolutionLevels[l][0], + ); + ret.push([ + prevolutionLevels[l][0], + Math.min( + Math.max( + evolution?.level! + + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max(evolution?.wildDelay!, 0.5) * 5) - + 1, + 2, + evolution?.level!, + ), + currentLevel - 1, + ), + ]); // TODO: are those bangs correct? } const lastPrevolutionLevel = ret[prevolutionLevels.length - 1][1]; - const evolution = pokemonEvolutions[prevolutionLevels[prevolutionLevels.length - 1][0]].find(e => e.speciesId === this.speciesId); - ret.push([ this.speciesId, Math.min(Math.max(lastPrevolutionLevel + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max((evolution?.wildDelay!), 0.5) * 5), lastPrevolutionLevel + 1, (evolution?.level!)), currentLevel) ]); // TODO: are those bangs correct? + const evolution = pokemonEvolutions[prevolutionLevels[prevolutionLevels.length - 1][0]].find( + e => e.speciesId === this.speciesId, + ); + ret.push([ + this.speciesId, + Math.min( + Math.max( + lastPrevolutionLevel + + Math.round(Utils.randSeedGauss(0.5, 1 + levelDiff * 0.2) * Math.max(evolution?.wildDelay!, 0.5) * 5), + lastPrevolutionLevel + 1, + evolution?.level!, + ), + currentLevel, + ), + ]); // TODO: are those bangs correct? } else { - ret.push([ this.speciesId, 1 ]); + ret.push([this.speciesId, 1]); } return ret; @@ -990,19 +1197,17 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali const mythical = this.mythical; return species => { return ( - subLegendary - || legendary - || mythical - || ( - pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution - && pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution - ) - ) - && species.subLegendary === subLegendary - && species.legendary === legendary - && species.mythical === mythical - && (this.isTrainerForbidden() || !species.isTrainerForbidden()) - && species.speciesId !== Species.DITTO; + (subLegendary || + legendary || + mythical || + (pokemonEvolutions.hasOwnProperty(species.speciesId) === hasEvolution && + pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution)) && + species.subLegendary === subLegendary && + species.legendary === legendary && + species.mythical === mythical && + (this.isTrainerForbidden() || !species.isTrainerForbidden()) && + species.speciesId !== Species.DITTO + ); }; } @@ -1022,13 +1227,13 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } getFormSpriteKey(formIndex?: number) { - if (this.forms.length && (formIndex !== undefined && formIndex >= this.forms.length)) { - console.warn(`Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms.length || 0} forms`); + if (this.forms.length && formIndex !== undefined && formIndex >= this.forms.length) { + console.warn( + `Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms.length || 0} forms`, + ); formIndex = Math.min(formIndex, this.forms.length - 1); } - return this.forms?.length - ? this.forms[formIndex || 0].getFormSpriteKey() - : ""; + return this.forms?.length ? this.forms[formIndex || 0].getFormSpriteKey() : ""; } /** @@ -1037,7 +1242,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali * @returns {@linkcode bigint} Maximum unlocks, can be compared with {@linkcode DexEntry.caughtAttr}. */ getFullUnlocksData(): bigint { - let caughtAttr: bigint = 0n; + let caughtAttr = 0n; caughtAttr += DexAttr.NON_SHINY; caughtAttr += DexAttr.SHINY; if (this.malePercent !== null) { @@ -1055,9 +1260,12 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } // Summing successive bigints for each obtainable form - caughtAttr += this?.forms?.length > 1 ? - this.forms.map((f, index) => f.isUnobtainable ? 0n : 128n * 2n ** BigInt(index)).reduce((acc, val) => acc + val, 0n) : - DexAttr.DEFAULT_FORM; + caughtAttr += + this?.forms?.length > 1 + ? this.forms + .map((f, index) => (f.isUnobtainable ? 0n : 128n * 2n ** BigInt(index))) + .reduce((acc, val) => acc + val, 0n) + : DexAttr.DEFAULT_FORM; return caughtAttr; } @@ -1070,15 +1278,66 @@ export class PokemonForm extends PokemonSpeciesForm { public isUnobtainable: boolean; // This is a collection of form keys that have in-run form changes, but should still be separately selectable from the start screen - private starterSelectableKeys: string[] = [ "10", "50", "10-pc", "50-pc", "red", "orange", "yellow", "green", "blue", "indigo", "violet" ]; + private starterSelectableKeys: string[] = [ + "10", + "50", + "10-pc", + "50-pc", + "red", + "orange", + "yellow", + "green", + "blue", + "indigo", + "violet", + ]; - constructor(formName: string, formKey: string, type1: PokemonType, type2: PokemonType | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities, - baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number, - catchRate: number, baseFriendship: number, baseExp: number, genderDiffs: boolean = false, formSpriteKey: string | null = null, isStarterSelectable: boolean = false, - isUnobtainable: boolean = false + constructor( + formName: string, + formKey: string, + type1: PokemonType, + type2: PokemonType | null, + height: number, + weight: number, + ability1: Abilities, + ability2: Abilities, + abilityHidden: Abilities, + baseTotal: number, + baseHp: number, + baseAtk: number, + baseDef: number, + baseSpatk: number, + baseSpdef: number, + baseSpd: number, + catchRate: number, + baseFriendship: number, + baseExp: number, + genderDiffs = false, + formSpriteKey: string | null = null, + isStarterSelectable = false, + isUnobtainable = false, ) { - super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd, - catchRate, baseFriendship, baseExp, genderDiffs, (isStarterSelectable || !formKey)); + super( + type1, + type2, + height, + weight, + ability1, + ability2, + abilityHidden, + baseTotal, + baseHp, + baseAtk, + baseDef, + baseSpatk, + baseSpdef, + baseSpd, + catchRate, + baseFriendship, + baseExp, + genderDiffs, + isStarterSelectable || !formKey, + ); this.formName = formName; this.formKey = formKey; this.formSpriteKey = formSpriteKey; @@ -1091,27 +1350,32 @@ export class PokemonForm extends PokemonSpeciesForm { } /** -* Method to get the daily list of starters with Pokerus. -* @returns A list of starters with Pokerus -*/ + * Method to get the daily list of starters with Pokerus. + * @returns A list of starters with Pokerus + */ export function getPokerusStarters(): PokemonSpecies[] { const pokerusStarters: PokemonSpecies[] = []; const date = new Date(); date.setUTCHours(0, 0, 0, 0); - globalScene.executeWithSeedOffset(() => { - while (pokerusStarters.length < POKERUS_STARTER_COUNT) { - const randomSpeciesId = parseInt(Utils.randSeedItem(Object.keys(speciesStarterCosts)), 10); - const species = getPokemonSpecies(randomSpeciesId); - if (!pokerusStarters.includes(species)) { - pokerusStarters.push(species); + globalScene.executeWithSeedOffset( + () => { + while (pokerusStarters.length < POKERUS_STARTER_COUNT) { + const randomSpeciesId = Number.parseInt(Utils.randSeedItem(Object.keys(speciesStarterCosts)), 10); + const species = getPokemonSpecies(randomSpeciesId); + if (!pokerusStarters.includes(species)) { + pokerusStarters.push(species); + } } - } - }, 0, date.getTime().toString()); + }, + 0, + date.getTime().toString(), + ); return pokerusStarters; } export const allSpecies: PokemonSpecies[] = []; +// biome-ignore format: manually formatted export function initSpecies() { allSpecies.push( new PokemonSpecies(Species.BULBASAUR, 1, false, false, false, "Seed Pokémon", PokemonType.GRASS, PokemonType.POISON, 0.7, 6.9, Abilities.OVERGROW, Abilities.NONE, Abilities.CHLOROPHYLL, 318, 45, 49, 49, 65, 65, 45, 45, 50, 64, GrowthRate.MEDIUM_SLOW, 87.5, false), @@ -2887,23 +3151,3 @@ export function initSpecies() { new PokemonSpecies(Species.BLOODMOON_URSALUNA, 9, true, false, false, "Peat Pokémon", PokemonType.GROUND, PokemonType.NORMAL, 2.7, 333, Abilities.MINDS_EYE, Abilities.NONE, Abilities.NONE, 555, 113, 70, 120, 135, 65, 52, 75, 50, 278, GrowthRate.MEDIUM_FAST, 50, false), //Marked as Sub-Legend, for casing purposes ); } - -// TODO: Remove -{ - //setTimeout(() => { - /*for (let tc of Object.keys(trainerConfigs)) { - console.log(TrainerType[tc], !trainerConfigs[tc].speciesFilter ? 'all' : [...new Set(allSpecies.filter(s => s.generation <= 9).filter(trainerConfigs[tc].speciesFilter).map(s => { - while (pokemonPrevolutions.hasOwnProperty(s.speciesId)) - s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]); - return s; - }))].map(s => s.name)); - } - - const speciesFilter = (species: PokemonSpecies) => !species.legendary && !species.pseudoLegendary && !species.mythical && species.baseTotal >= 540; - console.log(!speciesFilter ? 'all' : [...new Set(allSpecies.filter(s => s.generation <= 9).filter(speciesFilter).map(s => { - while (pokemonPrevolutions.hasOwnProperty(s.speciesId)) - s = getPokemonSpecies(pokemonPrevolutions[s.speciesId]); - return s; - }))].map(s => s.name));*/ - //}, 1000); -} diff --git a/src/data/splash-messages.ts b/src/data/splash-messages.ts index 1f00ce0d555..9fd71d9d95b 100644 --- a/src/data/splash-messages.ts +++ b/src/data/splash-messages.ts @@ -185,26 +185,38 @@ const seasonalSplashMessages: Season[] = [ name: "Halloween", start: "09-15", end: "10-31", - messages: [ "halloween.pumpkabooAbout", "halloween.mayContainSpiders", "halloween.spookyScarySkeledirge", "halloween.gourgeistUsedTrickOrTreat", "halloween.letsSnuggleForever" ], + messages: [ + "halloween.pumpkabooAbout", + "halloween.mayContainSpiders", + "halloween.spookyScarySkeledirge", + "halloween.gourgeistUsedTrickOrTreat", + "halloween.letsSnuggleForever", + ], }, { name: "XMAS", start: "12-01", end: "12-26", - messages: [ "xmas.happyHolidays", "xmas.unaffilicatedWithDelibirdServices", "xmas.delibirdSeason", "xmas.diamondsFromTheSky", "xmas.holidayStylePikachuNotIncluded" ], + messages: [ + "xmas.happyHolidays", + "xmas.unaffilicatedWithDelibirdServices", + "xmas.delibirdSeason", + "xmas.diamondsFromTheSky", + "xmas.holidayStylePikachuNotIncluded", + ], }, { name: "New Year's", start: "01-01", end: "01-31", - messages: [ "newYears.happyNewYear" ], + messages: ["newYears.happyNewYear"], }, ]; //#endregion export function getSplashMessages(): string[] { - const splashMessages: string[] = [ ...commonSplashMessages ]; + const splashMessages: string[] = [...commonSplashMessages]; console.log("use seasonal splash messages", USE_SEASONAL_SPLASH_MESSAGES); if (USE_SEASONAL_SPLASH_MESSAGES) { // add seasonal splash messages if the season is active @@ -215,13 +227,13 @@ export function getSplashMessages(): string[] { if (now >= startDate && now <= endDate) { console.log(`Adding ${messages.length} ${name} splash messages (weight: x${SEASONAL_WEIGHT_MULTIPLIER})`); - messages.forEach((message) => { + for (const message of messages) { const weightedMessage = Array(SEASONAL_WEIGHT_MULTIPLIER).fill(message); splashMessages.push(...weightedMessage); - }); + } } } } - return splashMessages.map((message) => `splashMessages:${message}`); + return splashMessages.map(message => `splashMessages:${message}`); } diff --git a/src/data/status-effect.ts b/src/data/status-effect.ts index 35a956cbb93..fe4fa380d46 100644 --- a/src/data/status-effect.ts +++ b/src/data/status-effect.ts @@ -6,10 +6,10 @@ import i18next from "i18next"; export class Status { public effect: StatusEffect; /** Toxic damage is `1/16 max HP * toxicTurnCount` */ - public toxicTurnCount: number = 0; + public toxicTurnCount = 0; public sleepTurnsRemaining?: number; - constructor(effect: StatusEffect, toxicTurnCount: number = 0, sleepTurnsRemaining?: number) { + constructor(effect: StatusEffect, toxicTurnCount = 0, sleepTurnsRemaining?: number) { this.effect = effect; this.toxicTurnCount = toxicTurnCount; this.sleepTurnsRemaining = sleepTurnsRemaining; @@ -23,7 +23,9 @@ export class Status { } isPostTurn(): boolean { - return this.effect === StatusEffect.POISON || this.effect === StatusEffect.TOXIC || this.effect === StatusEffect.BURN; + return ( + this.effect === StatusEffect.POISON || this.effect === StatusEffect.TOXIC || this.effect === StatusEffect.BURN + ); } } @@ -46,17 +48,24 @@ function getStatusEffectMessageKey(statusEffect: StatusEffect | undefined): stri } } -export function getStatusEffectObtainText(statusEffect: StatusEffect | undefined, pokemonNameWithAffix: string, sourceText?: string): string { +export function getStatusEffectObtainText( + statusEffect: StatusEffect | undefined, + pokemonNameWithAffix: string, + sourceText?: string, +): string { if (statusEffect === StatusEffect.NONE) { return ""; } if (!sourceText) { - const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.obtain`as ParseKeys; + const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.obtain` as ParseKeys; return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix }); } - const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.obtainSource`as ParseKeys; - return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix, sourceText: sourceText }); + const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.obtainSource` as ParseKeys; + return i18next.t(i18nKey, { + pokemonNameWithAffix: pokemonNameWithAffix, + sourceText: sourceText, + }); } export function getStatusEffectActivationText(statusEffect: StatusEffect, pokemonNameWithAffix: string): string { @@ -107,17 +116,17 @@ export function getStatusEffectCatchRateMultiplier(statusEffect: StatusEffect): } /** -* Returns a random non-volatile StatusEffect -*/ + * Returns a random non-volatile StatusEffect + */ export function generateRandomStatusEffect(): StatusEffect { return randIntRange(1, 6); } /** -* Returns a random non-volatile StatusEffect between the two provided -* @param statusEffectA The first StatusEffect -* @param statusEffectA The second StatusEffect -*/ + * Returns a random non-volatile StatusEffect between the two provided + * @param statusEffectA The first StatusEffect + * @param statusEffectA The second StatusEffect + */ export function getRandomStatusEffect(statusEffectA: StatusEffect, statusEffectB: StatusEffect): StatusEffect { if (statusEffectA === StatusEffect.NONE || statusEffectA === StatusEffect.FAINT) { return statusEffectB; @@ -130,10 +139,10 @@ export function getRandomStatusEffect(statusEffectA: StatusEffect, statusEffectB } /** -* Returns a random non-volatile StatusEffect between the two provided -* @param statusA The first Status -* @param statusB The second Status -*/ + * Returns a random non-volatile StatusEffect between the two provided + * @param statusA The first Status + * @param statusB The second Status + */ export function getRandomStatus(statusA: Status | null, statusB: Status | null): Status | null { if (!statusA || statusA.effect === StatusEffect.NONE || statusA.effect === StatusEffect.FAINT) { return statusB; @@ -142,7 +151,6 @@ export function getRandomStatus(statusA: Status | null, statusB: Status | null): return statusA; } - return randIntRange(0, 2) ? statusA : statusB; } @@ -150,14 +158,14 @@ export function getRandomStatus(statusA: Status | null, statusB: Status | null): * Gets all non volatile status effects * @returns A list containing all non volatile status effects */ -export function getNonVolatileStatusEffects():Array { +export function getNonVolatileStatusEffects(): Array { return [ StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.PARALYSIS, StatusEffect.SLEEP, StatusEffect.FREEZE, - StatusEffect.BURN + StatusEffect.BURN, ]; } diff --git a/src/data/terrain.ts b/src/data/terrain.ts index c727ef724c9..894fb8a7955 100644 --- a/src/data/terrain.ts +++ b/src/data/terrain.ts @@ -10,7 +10,7 @@ export enum TerrainType { MISTY, ELECTRIC, GRASSY, - PSYCHIC + PSYCHIC, } export class Terrain { @@ -57,7 +57,10 @@ export class Terrain { case TerrainType.PSYCHIC: if (!move.hasAttr(ProtectAttr)) { // Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain - return move.getPriority(user) > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded()); + return ( + move.getPriority(user) > 0 && + user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded()) + ); } } @@ -80,18 +83,17 @@ export function getTerrainName(terrainType: TerrainType): string { return ""; } - -export function getTerrainColor(terrainType: TerrainType): [ number, number, number ] { +export function getTerrainColor(terrainType: TerrainType): [number, number, number] { switch (terrainType) { case TerrainType.MISTY: - return [ 232, 136, 200 ]; + return [232, 136, 200]; case TerrainType.ELECTRIC: - return [ 248, 248, 120 ]; + return [248, 248, 120]; case TerrainType.GRASSY: - return [ 120, 200, 80 ]; + return [120, 200, 80]; case TerrainType.PSYCHIC: - return [ 160, 64, 160 ]; + return [160, 64, 160]; } - return [ 0, 0, 0 ]; + return [0, 0, 0]; } diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 2b912bda603..693338c145e 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -30,21 +30,21 @@ const ELITE_FOUR_MINIMUM_BST = 460; const GYM_LEADER_TERA_WAVE = 100; export enum TrainerPoolTier { - COMMON, - UNCOMMON, - RARE, - SUPER_RARE, - ULTRA_RARE + COMMON, + UNCOMMON, + RARE, + SUPER_RARE, + ULTRA_RARE, } export interface TrainerTierPools { - [key: number]: Species[] + [key: number]: Species[]; } export enum TrainerSlot { - NONE, - TRAINER, - TRAINER_PARTNER + NONE, + TRAINER, + TRAINER_PARTNER, } export class TrainerPartyTemplate { @@ -60,15 +60,15 @@ export class TrainerPartyTemplate { this.balanced = !!balanced; } - getStrength(index: number): PartyMemberStrength { + getStrength(_index: number): PartyMemberStrength { return this.strength; } - isSameSpecies(index: number): boolean { + isSameSpecies(_index: number): boolean { return this.sameSpecies; } - isBalanced(index: number): boolean { + isBalanced(_index: number): boolean { return this.balanced; } } @@ -77,10 +77,13 @@ export class TrainerPartyCompoundTemplate extends TrainerPartyTemplate { public templates: TrainerPartyTemplate[]; constructor(...templates: TrainerPartyTemplate[]) { - super(templates.reduce((total: number, template: TrainerPartyTemplate) => { - total += template.size; - return total; - }, 0), PartyMemberStrength.AVERAGE); + super( + templates.reduce((total: number, template: TrainerPartyTemplate) => { + total += template.size; + return total; + }, 0), + PartyMemberStrength.AVERAGE, + ); this.templates = templates; } @@ -122,22 +125,52 @@ export class TrainerPartyCompoundTemplate extends TrainerPartyTemplate { } export const trainerPartyTemplates = { - ONE_WEAK_ONE_STRONG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.WEAK), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), + ONE_WEAK_ONE_STRONG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.WEAK), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), ONE_AVG: new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), - ONE_AVG_ONE_STRONG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), + ONE_AVG_ONE_STRONG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), ONE_STRONG: new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), ONE_STRONGER: new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), TWO_WEAKER: new TrainerPartyTemplate(2, PartyMemberStrength.WEAKER), TWO_WEAK: new TrainerPartyTemplate(2, PartyMemberStrength.WEAK), - TWO_WEAK_ONE_AVG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.WEAK), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE)), - TWO_WEAK_SAME_ONE_AVG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE)), - TWO_WEAK_SAME_TWO_WEAK_SAME: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true), new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true)), - TWO_WEAK_ONE_STRONG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.WEAK), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), + TWO_WEAK_ONE_AVG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.WEAK), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + ), + TWO_WEAK_SAME_ONE_AVG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + ), + TWO_WEAK_SAME_TWO_WEAK_SAME: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true), + new TrainerPartyTemplate(2, PartyMemberStrength.WEAK, true), + ), + TWO_WEAK_ONE_STRONG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.WEAK), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), TWO_AVG: new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), - TWO_AVG_ONE_STRONG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), - TWO_AVG_SAME_ONE_AVG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE)), - TWO_AVG_SAME_ONE_STRONG: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), - TWO_AVG_SAME_TWO_AVG_SAME: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true)), + TWO_AVG_ONE_STRONG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + TWO_AVG_SAME_ONE_AVG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + ), + TWO_AVG_SAME_ONE_STRONG: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + TWO_AVG_SAME_TWO_AVG_SAME: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, true), + ), TWO_STRONG: new TrainerPartyTemplate(2, PartyMemberStrength.STRONG), THREE_WEAK: new TrainerPartyTemplate(3, PartyMemberStrength.WEAK), THREE_WEAK_SAME: new TrainerPartyTemplate(3, PartyMemberStrength.WEAK, true), @@ -157,22 +190,75 @@ export const trainerPartyTemplates = { SIX_WEAK_SAME: new TrainerPartyTemplate(6, PartyMemberStrength.WEAK, true), SIX_WEAK_BALANCED: new TrainerPartyTemplate(6, PartyMemberStrength.WEAK, false, true), - GYM_LEADER_1: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), - GYM_LEADER_2: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)), - GYM_LEADER_3: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)), - GYM_LEADER_4: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)), - GYM_LEADER_5: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(2, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)), + GYM_LEADER_1: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + GYM_LEADER_2: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), + GYM_LEADER_3: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), + GYM_LEADER_4: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), + GYM_LEADER_5: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(2, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), - ELITE_FOUR: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)), + ELITE_FOUR: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(3, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), - CHAMPION: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(4, PartyMemberStrength.STRONG), new TrainerPartyTemplate(2, PartyMemberStrength.STRONGER, false, true)), + CHAMPION: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(4, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(2, PartyMemberStrength.STRONGER, false, true), + ), - RIVAL: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE)), - RIVAL_2: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true)), - RIVAL_3: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true)), - RIVAL_4: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true)), - RIVAL_5: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONG)), - RIVAL_6: new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)) + RIVAL: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + ), + RIVAL_2: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true), + ), + RIVAL_3: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE, false, true), + new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true), + ), + RIVAL_4: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE, false, true), + new TrainerPartyTemplate(1, PartyMemberStrength.WEAK, false, true), + ), + RIVAL_5: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + ), + RIVAL_6: new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), }; type PartyTemplateFunc = () => TrainerPartyTemplate; @@ -181,13 +267,13 @@ type GenModifiersFunc = (party: EnemyPokemon[]) => PersistentModifier[]; type GenAIFunc = (party: EnemyPokemon[]) => void; export interface PartyMemberFuncs { - [key: number]: PartyMemberFunc + [key: number]: PartyMemberFunc; } export enum TeraAIMode { NO_TERA, INSTANT_TERA, - SMART_TERA + SMART_TERA, } /** @@ -231,14 +317,14 @@ export class TrainerConfig { public nameDouble: string; public title: string; public titleDouble: string; - public hasGenders: boolean = false; - public hasDouble: boolean = false; - public hasCharSprite: boolean = false; - public doubleOnly: boolean = false; - public moneyMultiplier: number = 1; - public isBoss: boolean = false; - public hasStaticParty: boolean = false; - public useSameSeedForAllMembers: boolean = false; + public hasGenders = false; + public hasDouble = false; + public hasCharSprite = false; + public doubleOnly = false; + public moneyMultiplier = 1; + public isBoss = false; + public hasStaticParty = false; + public useSameSeedForAllMembers = false; public mixedBattleBgm: string; public battleBgm: string; public encounterBgm: string; @@ -255,7 +341,7 @@ export class TrainerConfig { public speciesPools: TrainerTierPools; public speciesFilter: PokemonSpeciesFilter; public specialtyType: PokemonType; - public hasVoucher: boolean = false; + public hasVoucher = false; public trainerAI: TrainerAI; public encounterMessages: string[] = []; @@ -277,15 +363,17 @@ export class TrainerConfig { this.battleBgm = "battle_trainer"; this.mixedBattleBgm = "battle_trainer"; this.victoryBgm = "victory_trainer"; - this.partyTemplates = [ trainerPartyTemplates.TWO_AVG ]; - this.speciesFilter = species => (allowLegendaries || (!species.legendary && !species.subLegendary && !species.mythical)) && !species.isTrainerForbidden(); + this.partyTemplates = [trainerPartyTemplates.TWO_AVG]; + this.speciesFilter = species => + (allowLegendaries || (!species.legendary && !species.subLegendary && !species.mythical)) && + !species.isTrainerForbidden(); } getKey(): string { return TrainerType[this.getDerivedType()].toString().toLowerCase(); } - getSpriteKey(female?: boolean, isDouble: boolean = false): string { + getSpriteKey(female?: boolean, isDouble = false): string { let ret = this.getKey(); if (this.hasGenders) { ret += `_${female ? "f" : "m"}`; @@ -336,16 +424,14 @@ export class TrainerConfig { // Get the title from the i18n file this.title = i18next.t(`titles:${title}`); - return this; } - /** - * Returns the derived trainer type for a given trainer type. - * @param trainerTypeToDeriveFrom - The trainer type to derive from. (If null, the this.trainerType property will be used.) - * @returns {TrainerType} - The derived trainer type. - */ + * Returns the derived trainer type for a given trainer type. + * @param trainerTypeToDeriveFrom - The trainer type to derive from. (If null, the this.trainerType property will be used.) + * @returns {TrainerType} - The derived trainer type. + */ getDerivedType(trainerTypeToDeriveFrom: TrainerType | null = null): TrainerType { let trainerType = trainerTypeToDeriveFrom ? trainerTypeToDeriveFrom : this.trainerType; switch (trainerType) { @@ -414,11 +500,11 @@ export class TrainerConfig { } /** - * Sets the configuration for trainers with genders, including the female name and encounter background music (BGM). - * @param {string} [nameFemale] The name of the female trainer. If 'Ivy', a localized name will be assigned. - * @param {TrainerType | string} [femaleEncounterBgm] The encounter BGM for the female trainer, which can be a TrainerType or a string. - * @returns {TrainerConfig} The updated TrainerConfig instance. - **/ + * Sets the configuration for trainers with genders, including the female name and encounter background music (BGM). + * @param {string} [nameFemale] The name of the female trainer. If 'Ivy', a localized name will be assigned. + * @param {TrainerType | string} [femaleEncounterBgm] The encounter BGM for the female trainer, which can be a TrainerType or a string. + * @returns {TrainerConfig} The updated TrainerConfig instance. + **/ setHasGenders(nameFemale?: string, femaleEncounterBgm?: TrainerType | string): TrainerConfig { // If the female name is 'Ivy' (the rival), assign a localized name. if (nameFemale === "Ivy") { @@ -441,9 +527,10 @@ export class TrainerConfig { if (femaleEncounterBgm) { // If the BGM is a TrainerType (number), convert it to a string, replace underscores with spaces, and convert to lowercase. // Otherwise, assign the provided string as the BGM. - this.femaleEncounterBgm = typeof femaleEncounterBgm === "number" - ? TrainerType[femaleEncounterBgm].toString().replace(/_/g, " ").toLowerCase() - : femaleEncounterBgm; + this.femaleEncounterBgm = + typeof femaleEncounterBgm === "number" + ? TrainerType[femaleEncounterBgm].toString().replace(/_/g, " ").toLowerCase() + : femaleEncounterBgm; } // Return the updated TrainerConfig instance. @@ -451,25 +538,28 @@ export class TrainerConfig { } /** - * Sets the configuration for trainers with double battles, including the name of the double trainer and the encounter BGM. - * @param nameDouble The name of the double trainer (e.g., "Ace Duo" for Trainer Class Doubles or "red_blue_double" for NAMED trainer doubles). - * @param doubleEncounterBgm The encounter BGM for the double trainer, which can be a TrainerType or a string. - * @returns {TrainerConfig} The updated TrainerConfig instance. - */ + * Sets the configuration for trainers with double battles, including the name of the double trainer and the encounter BGM. + * @param nameDouble The name of the double trainer (e.g., "Ace Duo" for Trainer Class Doubles or "red_blue_double" for NAMED trainer doubles). + * @param doubleEncounterBgm The encounter BGM for the double trainer, which can be a TrainerType or a string. + * @returns {TrainerConfig} The updated TrainerConfig instance. + */ setHasDouble(nameDouble: string, doubleEncounterBgm?: TrainerType | string): TrainerConfig { this.hasDouble = true; this.nameDouble = nameDouble; if (doubleEncounterBgm) { - this.doubleEncounterBgm = typeof doubleEncounterBgm === "number" ? TrainerType[doubleEncounterBgm].toString().replace(/\_/g, " ").toLowerCase() : doubleEncounterBgm; + this.doubleEncounterBgm = + typeof doubleEncounterBgm === "number" + ? TrainerType[doubleEncounterBgm].toString().replace(/\_/g, " ").toLowerCase() + : doubleEncounterBgm; } return this; } /** - * Sets the trainer type for double battles. - * @param trainerTypeDouble The TrainerType of the partner in a double battle. - * @returns {TrainerConfig} The updated TrainerConfig instance. - */ + * Sets the trainer type for double battles. + * @param trainerTypeDouble The TrainerType of the partner in a double battle. + * @returns {TrainerConfig} The updated TrainerConfig instance. + */ setDoubleTrainerType(trainerTypeDouble: TrainerType): TrainerConfig { this.trainerTypeDouble = trainerTypeDouble; this.setDoubleMessages(this.nameDouble); @@ -477,9 +567,9 @@ export class TrainerConfig { } /** - * Sets the encounter and victory messages for double trainers. - * @param nameDouble - The name of the pair (e.g. "red_blue_double"). - */ + * Sets the encounter and victory messages for double trainers. + * @param nameDouble - The name of the pair (e.g. "red_blue_double"). + */ setDoubleMessages(nameDouble: string) { // Check if there is double battle dialogue for this trainer if (doubleBattleDialogue[nameDouble]) { @@ -491,10 +581,10 @@ export class TrainerConfig { } /** - * Sets the title for double trainers - * @param titleDouble The key for the title in the i18n file. (e.g., "champion_double"). - * @returns {TrainerConfig} The updated TrainerConfig instance. - */ + * Sets the title for double trainers + * @param titleDouble The key for the title in the i18n file. (e.g., "champion_double"). + * @returns {TrainerConfig} The updated TrainerConfig instance. + */ setDoubleTitle(titleDouble: string): TrainerConfig { // First check if i18n is initialized if (!getIsInitialized()) { @@ -551,7 +641,8 @@ export class TrainerConfig { } setEncounterBgm(encounterBgm: TrainerType | string): TrainerConfig { - this.encounterBgm = typeof encounterBgm === "number" ? TrainerType[encounterBgm].toString().toLowerCase() : encounterBgm; + this.encounterBgm = + typeof encounterBgm === "number" ? TrainerType[encounterBgm].toString().toLowerCase() : encounterBgm; return this; } @@ -576,7 +667,9 @@ export class TrainerConfig { } setSpeciesPools(speciesPools: TrainerTierPools | Species[]): TrainerConfig { - this.speciesPools = (Array.isArray(speciesPools) ? { [TrainerPoolTier.COMMON]: speciesPools } : speciesPools) as unknown as TrainerTierPools; + this.speciesPools = (Array.isArray(speciesPools) + ? { [TrainerPoolTier.COMMON]: speciesPools } + : speciesPools) as unknown as TrainerTierPools; return this; } @@ -605,11 +698,14 @@ export class TrainerConfig { setRandomTeraModifiers(count: () => number, slot?: number): TrainerConfig { this.genAIFuncs.push((party: EnemyPokemon[]) => { const shedinjaCanTera = !this.hasSpecialtyType() || this.specialtyType === PokemonType.BUG; // Better to check one time than 6 - const partyMemberIndexes = new Array(party.length).fill(null).map((_, i) => i) + const partyMemberIndexes = new Array(party.length) + .fill(null) + .map((_, i) => i) .filter(i => shedinjaCanTera || party[i].species.speciesId !== Species.SHEDINJA); // Shedinja can only Tera on Bug specialty type (or no specialty type) const setPartySlot = !Utils.isNullOrUndefined(slot) ? Phaser.Math.Wrap(slot, 0, party.length) : -1; // If we have a tera slot defined, wrap it to party size. for (let t = 0; t < Math.min(count(), party.length); t++) { - const randomIndex = partyMemberIndexes.indexOf(setPartySlot) > -1 ? setPartySlot : Utils.randSeedItem(partyMemberIndexes); + const randomIndex = + partyMemberIndexes.indexOf(setPartySlot) > -1 ? setPartySlot : Utils.randSeedItem(partyMemberIndexes); partyMemberIndexes.splice(partyMemberIndexes.indexOf(randomIndex), 1); if (this.hasSpecialtyType()) { party[randomIndex].teraType = this.specialtyType; @@ -651,7 +747,6 @@ export class TrainerConfig { return this; } - setModifierRewardFuncs(...modifierTypeFuncs: (() => ModifierTypeFunc)[]): TrainerConfig { this.modifierRewardFuncs = modifierTypeFuncs.map(func => () => { const modifierTypeFunc = func(); @@ -663,116 +758,421 @@ export class TrainerConfig { } /** - * Returns the pool of species for an evil team admin - * @param team - The evil team the admin belongs to. - * @returns {TrainerTierPools} - */ + * Returns the pool of species for an evil team admin + * @param team - The evil team the admin belongs to. + * @returns {TrainerTierPools} + */ speciesPoolPerEvilTeamAdmin(team): TrainerTierPools { team = team.toLowerCase(); switch (team) { case "rocket": { return { - [TrainerPoolTier.COMMON]: [ Species.RATICATE, Species.ARBOK, Species.VILEPLUME, Species.ARCANINE, Species.GENGAR, Species.HYPNO, Species.ELECTRODE, Species.EXEGGUTOR, Species.CUBONE, Species.KOFFING, Species.GYARADOS, Species.CROBAT, Species.STEELIX, Species.HOUNDOOM, Species.HONCHKROW ], - [TrainerPoolTier.UNCOMMON]: [ Species.OMASTAR, Species.KABUTOPS, Species.MAGNEZONE, Species.ELECTIVIRE, Species.MAGMORTAR, Species.PORYGON_Z, Species.ANNIHILAPE, Species.ALOLA_SANDSLASH, Species.ALOLA_PERSIAN, Species.ALOLA_GOLEM, Species.ALOLA_MUK, Species.PALDEA_TAUROS ], - [TrainerPoolTier.RARE]: [ Species.DRAGONITE, Species.TYRANITAR ] + [TrainerPoolTier.COMMON]: [ + Species.RATICATE, + Species.ARBOK, + Species.VILEPLUME, + Species.ARCANINE, + Species.GENGAR, + Species.HYPNO, + Species.ELECTRODE, + Species.EXEGGUTOR, + Species.CUBONE, + Species.KOFFING, + Species.GYARADOS, + Species.CROBAT, + Species.STEELIX, + Species.HOUNDOOM, + Species.HONCHKROW, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.OMASTAR, + Species.KABUTOPS, + Species.MAGNEZONE, + Species.ELECTIVIRE, + Species.MAGMORTAR, + Species.PORYGON_Z, + Species.ANNIHILAPE, + Species.ALOLA_SANDSLASH, + Species.ALOLA_PERSIAN, + Species.ALOLA_GOLEM, + Species.ALOLA_MUK, + Species.PALDEA_TAUROS, + ], + [TrainerPoolTier.RARE]: [Species.DRAGONITE, Species.TYRANITAR], }; } case "magma": { return { - [TrainerPoolTier.COMMON]: [ Species.ARCANINE, Species.MAGCARGO, Species.HOUNDOOM, Species.TORKOAL, Species.SOLROCK, Species.CLAYDOL, Species.HIPPOWDON, Species.MAGMORTAR, Species.GLISCOR, Species.COALOSSAL ], - [TrainerPoolTier.UNCOMMON]: [ Species.AGGRON, Species.FLYGON, Species.CRADILY, Species.ARMALDO, Species.RHYPERIOR, Species.TURTONATOR, Species.SANDACONDA, Species.TOEDSCRUEL, Species.HISUI_ARCANINE ], - [TrainerPoolTier.RARE]: [ Species.CHARCADET, Species.SCOVILLAIN ] + [TrainerPoolTier.COMMON]: [ + Species.ARCANINE, + Species.MAGCARGO, + Species.HOUNDOOM, + Species.TORKOAL, + Species.SOLROCK, + Species.CLAYDOL, + Species.HIPPOWDON, + Species.MAGMORTAR, + Species.GLISCOR, + Species.COALOSSAL, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.AGGRON, + Species.FLYGON, + Species.CRADILY, + Species.ARMALDO, + Species.RHYPERIOR, + Species.TURTONATOR, + Species.SANDACONDA, + Species.TOEDSCRUEL, + Species.HISUI_ARCANINE, + ], + [TrainerPoolTier.RARE]: [Species.CHARCADET, Species.SCOVILLAIN], }; } case "aqua": { return { - [TrainerPoolTier.COMMON]: [ Species.TENTACRUEL, Species.LANTURN, Species.AZUMARILL, Species.QUAGSIRE, Species.OCTILLERY, Species.LUDICOLO, Species.PELIPPER, Species.WAILORD, Species.WHISCASH, Species.CRAWDAUNT, Species.WALREIN, Species.CLAMPERL ], - [TrainerPoolTier.UNCOMMON]: [ Species.QUAGSIRE, Species.MANTINE, Species.KINGDRA, Species.MILOTIC, Species.DRAGALGE, Species.DHELMISE, Species.BARRASKEWDA, Species.GRAPPLOCT, Species.OVERQWIL ], - [TrainerPoolTier.RARE]: [ Species.BASCULEGION, Species.DONDOZO ] + [TrainerPoolTier.COMMON]: [ + Species.TENTACRUEL, + Species.LANTURN, + Species.AZUMARILL, + Species.QUAGSIRE, + Species.OCTILLERY, + Species.LUDICOLO, + Species.PELIPPER, + Species.WAILORD, + Species.WHISCASH, + Species.CRAWDAUNT, + Species.WALREIN, + Species.CLAMPERL, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.QUAGSIRE, + Species.MANTINE, + Species.KINGDRA, + Species.MILOTIC, + Species.DRAGALGE, + Species.DHELMISE, + Species.BARRASKEWDA, + Species.GRAPPLOCT, + Species.OVERQWIL, + ], + [TrainerPoolTier.RARE]: [Species.BASCULEGION, Species.DONDOZO], }; } case "galactic": { return { - [TrainerPoolTier.COMMON]: [ Species.ELECTRODE, Species.GYARADOS, Species.CROBAT, Species.HONCHKROW, Species.BRONZONG, Species.DRAPION, Species.LICKILICKY, Species.TANGROWTH, Species.ELECTIVIRE, Species.MAGMORTAR, Species.YANMEGA, Species.MAMOSWINE ], - [TrainerPoolTier.UNCOMMON]: [ Species.ALAKAZAM, Species.WEAVILE, Species.GLISCOR, Species.DUSKNOIR, Species.ROTOM, Species.OVERQWIL, Species.HISUI_ARCANINE, Species.HISUI_ELECTRODE ], - [TrainerPoolTier.RARE]: [ Species.SPIRITOMB, Species.URSALUNA, Species.SNEASLER, Species.HISUI_LILLIGANT ] + [TrainerPoolTier.COMMON]: [ + Species.ELECTRODE, + Species.GYARADOS, + Species.CROBAT, + Species.HONCHKROW, + Species.BRONZONG, + Species.DRAPION, + Species.LICKILICKY, + Species.TANGROWTH, + Species.ELECTIVIRE, + Species.MAGMORTAR, + Species.YANMEGA, + Species.MAMOSWINE, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.ALAKAZAM, + Species.WEAVILE, + Species.GLISCOR, + Species.DUSKNOIR, + Species.ROTOM, + Species.OVERQWIL, + Species.HISUI_ARCANINE, + Species.HISUI_ELECTRODE, + ], + [TrainerPoolTier.RARE]: [Species.SPIRITOMB, Species.URSALUNA, Species.SNEASLER, Species.HISUI_LILLIGANT], }; } case "plasma": { return { - [TrainerPoolTier.COMMON]: [ Species.GIGALITH, Species.CONKELDURR, Species.SEISMITOAD, Species.KROOKODILE, Species.DARMANITAN, Species.COFAGRIGUS, Species.VANILLUXE, Species.AMOONGUSS, Species.JELLICENT, Species.GALVANTULA, Species.FERROTHORN, Species.BEARTIC ], - [TrainerPoolTier.UNCOMMON]: [ Species.EXCADRILL, Species.SIGILYPH, Species.ZOROARK, Species.KLINKLANG, Species.EELEKTROSS, Species.MIENSHAO, Species.GOLURK, Species.BISHARP, Species.MANDIBUZZ, Species.DURANT, Species.GALAR_DARMANITAN ], - [TrainerPoolTier.RARE]: [ Species.HAXORUS, Species.HYDREIGON, Species.HISUI_ZOROARK, Species.HISUI_BRAVIARY ] + [TrainerPoolTier.COMMON]: [ + Species.GIGALITH, + Species.CONKELDURR, + Species.SEISMITOAD, + Species.KROOKODILE, + Species.DARMANITAN, + Species.COFAGRIGUS, + Species.VANILLUXE, + Species.AMOONGUSS, + Species.JELLICENT, + Species.GALVANTULA, + Species.FERROTHORN, + Species.BEARTIC, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.EXCADRILL, + Species.SIGILYPH, + Species.ZOROARK, + Species.KLINKLANG, + Species.EELEKTROSS, + Species.MIENSHAO, + Species.GOLURK, + Species.BISHARP, + Species.MANDIBUZZ, + Species.DURANT, + Species.GALAR_DARMANITAN, + ], + [TrainerPoolTier.RARE]: [Species.HAXORUS, Species.HYDREIGON, Species.HISUI_ZOROARK, Species.HISUI_BRAVIARY], }; } case "plasma_2": { return { - [TrainerPoolTier.COMMON]: [ Species.MUK, Species.ELECTRODE, Species.BRONZONG, Species.MAGNEZONE, Species.PORYGON_Z, Species.MUSHARNA, Species.REUNICLUS, Species.GALVANTULA, Species.FERROTHORN, Species.EELEKTROSS, Species.BEHEEYEM ], - [TrainerPoolTier.UNCOMMON]: [ Species.METAGROSS, Species.ROTOM, Species.CARRACOSTA, Species.ARCHEOPS, Species.GOLURK, Species.DURANT, Species.VIKAVOLT, Species.ORBEETLE, Species.REVAVROOM, Species.ALOLA_MUK, Species.HISUI_ELECTRODE ], - [TrainerPoolTier.RARE]: [ Species.ELECTIVIRE, Species.MAGMORTAR, Species.BISHARP, Species.ARCHALUDON ] + [TrainerPoolTier.COMMON]: [ + Species.MUK, + Species.ELECTRODE, + Species.BRONZONG, + Species.MAGNEZONE, + Species.PORYGON_Z, + Species.MUSHARNA, + Species.REUNICLUS, + Species.GALVANTULA, + Species.FERROTHORN, + Species.EELEKTROSS, + Species.BEHEEYEM, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.METAGROSS, + Species.ROTOM, + Species.CARRACOSTA, + Species.ARCHEOPS, + Species.GOLURK, + Species.DURANT, + Species.VIKAVOLT, + Species.ORBEETLE, + Species.REVAVROOM, + Species.ALOLA_MUK, + Species.HISUI_ELECTRODE, + ], + [TrainerPoolTier.RARE]: [Species.ELECTIVIRE, Species.MAGMORTAR, Species.BISHARP, Species.ARCHALUDON], }; } case "flare": { return { - [TrainerPoolTier.COMMON]: [ Species.MANECTRIC, Species.DRAPION, Species.LIEPARD, Species.AMOONGUSS, Species.DIGGERSBY, Species.TALONFLAME, Species.PYROAR, Species.PANGORO, Species.MEOWSTIC, Species.MALAMAR, Species.CLAWITZER, Species.HELIOLISK ], - [TrainerPoolTier.UNCOMMON]: [ Species.HOUNDOOM, Species.WEAVILE, Species.CHANDELURE, Species.AEGISLASH, Species.BARBARACLE, Species.DRAGALGE, Species.GOODRA, Species.TREVENANT, Species.GOURGEIST ], - [TrainerPoolTier.RARE]: [ Species.NOIVERN, Species.HISUI_GOODRA, Species.HISUI_AVALUGG ] + [TrainerPoolTier.COMMON]: [ + Species.MANECTRIC, + Species.DRAPION, + Species.LIEPARD, + Species.AMOONGUSS, + Species.DIGGERSBY, + Species.TALONFLAME, + Species.PYROAR, + Species.PANGORO, + Species.MEOWSTIC, + Species.MALAMAR, + Species.CLAWITZER, + Species.HELIOLISK, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.HOUNDOOM, + Species.WEAVILE, + Species.CHANDELURE, + Species.AEGISLASH, + Species.BARBARACLE, + Species.DRAGALGE, + Species.GOODRA, + Species.TREVENANT, + Species.GOURGEIST, + ], + [TrainerPoolTier.RARE]: [Species.NOIVERN, Species.HISUI_GOODRA, Species.HISUI_AVALUGG], }; } case "aether": { return { - [TrainerPoolTier.COMMON]: [ Species.ALAKAZAM, Species.SLOWBRO, Species.EXEGGUTOR, Species.XATU, Species.CLAYDOL, Species.BEHEEYEM, Species.ORANGURU, Species.BRUXISH, Species.ORBEETLE, Species.FARIGIRAF, Species.ALOLA_RAICHU ], - [TrainerPoolTier.UNCOMMON]: [ Species.KIRLIA, Species.MEDICHAM, Species.METAGROSS, Species.MALAMAR, Species.HATTERENE, Species.MR_RIME, Species.GALAR_SLOWKING ], - [TrainerPoolTier.RARE]: [ Species.PORYGON_Z, Species.ARMAROUGE, Species.HISUI_BRAVIARY ] + [TrainerPoolTier.COMMON]: [ + Species.ALAKAZAM, + Species.SLOWBRO, + Species.EXEGGUTOR, + Species.XATU, + Species.CLAYDOL, + Species.BEHEEYEM, + Species.ORANGURU, + Species.BRUXISH, + Species.ORBEETLE, + Species.FARIGIRAF, + Species.ALOLA_RAICHU, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.KIRLIA, + Species.MEDICHAM, + Species.METAGROSS, + Species.MALAMAR, + Species.HATTERENE, + Species.MR_RIME, + Species.GALAR_SLOWKING, + ], + [TrainerPoolTier.RARE]: [Species.PORYGON_Z, Species.ARMAROUGE, Species.HISUI_BRAVIARY], }; } case "skull": { return { - [TrainerPoolTier.COMMON]: [ Species.NIDOQUEEN, Species.GENGAR, Species.KOFFING, Species.CROBAT, Species.ROSERADE, Species.SKUNTANK, Species.TOXICROAK, Species.SCOLIPEDE, Species.TOXAPEX, Species.LURANTIS, Species.ALOLA_MUK ], - [TrainerPoolTier.UNCOMMON]: [ Species.DRAPION, Species.MANDIBUZZ, Species.OVERQWIL, Species.GLIMMORA, Species.CLODSIRE, Species.GALAR_SLOWBRO ], - [TrainerPoolTier.RARE]: [ Species.DRAGALGE, Species.SNEASLER ] + [TrainerPoolTier.COMMON]: [ + Species.NIDOQUEEN, + Species.GENGAR, + Species.KOFFING, + Species.CROBAT, + Species.ROSERADE, + Species.SKUNTANK, + Species.TOXICROAK, + Species.SCOLIPEDE, + Species.TOXAPEX, + Species.LURANTIS, + Species.ALOLA_MUK, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.DRAPION, + Species.MANDIBUZZ, + Species.OVERQWIL, + Species.GLIMMORA, + Species.CLODSIRE, + Species.GALAR_SLOWBRO, + ], + [TrainerPoolTier.RARE]: [Species.DRAGALGE, Species.SNEASLER], }; } case "macro": { return { - [TrainerPoolTier.COMMON]: [ Species.NINETALES, Species.BELLOSSOM, Species.MILOTIC, Species.FROSLASS, Species.GOTHITELLE, Species.JELLICENT, Species.SALAZZLE, Species.TSAREENA, Species.POLTEAGEIST, Species.HATTERENE, Species.GALAR_RAPIDASH ], - [TrainerPoolTier.UNCOMMON]: [ Species.TOGEKISS, Species.MANDIBUZZ, Species.TOXAPEX, Species.APPLETUN, Species.CURSOLA, Species.ALOLA_NINETALES ], - [TrainerPoolTier.RARE]: [ Species.TINKATON, Species.HISUI_LILLIGANT ] + [TrainerPoolTier.COMMON]: [ + Species.NINETALES, + Species.BELLOSSOM, + Species.MILOTIC, + Species.FROSLASS, + Species.GOTHITELLE, + Species.JELLICENT, + Species.SALAZZLE, + Species.TSAREENA, + Species.POLTEAGEIST, + Species.HATTERENE, + Species.GALAR_RAPIDASH, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.TOGEKISS, + Species.MANDIBUZZ, + Species.TOXAPEX, + Species.APPLETUN, + Species.CURSOLA, + Species.ALOLA_NINETALES, + ], + [TrainerPoolTier.RARE]: [Species.TINKATON, Species.HISUI_LILLIGANT], }; } case "star_1": { return { - [TrainerPoolTier.COMMON]: [ Species.SHIFTRY, Species.CACTURNE, Species.HONCHKROW, Species.SKUNTANK, Species.KROOKODILE, Species.OBSTAGOON, Species.LOKIX, Species.MABOSSTIFF ], - [TrainerPoolTier.UNCOMMON]: [ Species.UMBREON, Species.CRAWDAUNT, Species.WEAVILE, Species.ZOROARK, Species.MALAMAR, Species.BOMBIRDIER ], - [TrainerPoolTier.RARE]: [ Species.HYDREIGON, Species.MEOWSCARADA ] + [TrainerPoolTier.COMMON]: [ + Species.SHIFTRY, + Species.CACTURNE, + Species.HONCHKROW, + Species.SKUNTANK, + Species.KROOKODILE, + Species.OBSTAGOON, + Species.LOKIX, + Species.MABOSSTIFF, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.UMBREON, + Species.CRAWDAUNT, + Species.WEAVILE, + Species.ZOROARK, + Species.MALAMAR, + Species.BOMBIRDIER, + ], + [TrainerPoolTier.RARE]: [Species.HYDREIGON, Species.MEOWSCARADA], }; } case "star_2": { return { - [TrainerPoolTier.COMMON]: [ Species.ARCANINE, Species.HOUNDOOM, Species.CAMERUPT, Species.CHANDELURE, Species.TALONFLAME, Species.PYROAR, Species.COALOSSAL, Species.SCOVILLAIN ], - [TrainerPoolTier.UNCOMMON]: [ Species.RAPIDASH, Species.FLAREON, Species.TORKOAL, Species.MAGMORTAR, Species.SALAZZLE, Species.TURTONATOR ], - [TrainerPoolTier.RARE]: [ Species.VOLCARONA, Species.SKELEDIRGE ] + [TrainerPoolTier.COMMON]: [ + Species.ARCANINE, + Species.HOUNDOOM, + Species.CAMERUPT, + Species.CHANDELURE, + Species.TALONFLAME, + Species.PYROAR, + Species.COALOSSAL, + Species.SCOVILLAIN, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.RAPIDASH, + Species.FLAREON, + Species.TORKOAL, + Species.MAGMORTAR, + Species.SALAZZLE, + Species.TURTONATOR, + ], + [TrainerPoolTier.RARE]: [Species.VOLCARONA, Species.SKELEDIRGE], }; } case "star_3": { return { - [TrainerPoolTier.COMMON]: [ Species.MUK, Species.CROBAT, Species.SKUNTANK, Species.AMOONGUSS, Species.TOXAPEX, Species.TOXTRICITY, Species.GRAFAIAI, Species.CLODSIRE ], - [TrainerPoolTier.UNCOMMON]: [ Species.GENGAR, Species.SEVIPER, Species.DRAGALGE, Species.OVERQWIL, Species.ALOLA_MUK, Species.GALAR_SLOWBRO ], - [TrainerPoolTier.RARE]: [ Species.GLIMMORA, Species.VENUSAUR ] + [TrainerPoolTier.COMMON]: [ + Species.MUK, + Species.CROBAT, + Species.SKUNTANK, + Species.AMOONGUSS, + Species.TOXAPEX, + Species.TOXTRICITY, + Species.GRAFAIAI, + Species.CLODSIRE, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.GENGAR, + Species.SEVIPER, + Species.DRAGALGE, + Species.OVERQWIL, + Species.ALOLA_MUK, + Species.GALAR_SLOWBRO, + ], + [TrainerPoolTier.RARE]: [Species.GLIMMORA, Species.VENUSAUR], }; } case "star_4": { return { - [TrainerPoolTier.COMMON]: [ Species.CLEFABLE, Species.WIGGLYTUFF, Species.AZUMARILL, Species.WHIMSICOTT, Species.FLORGES, Species.HATTERENE, Species.GRIMMSNARL, Species.TINKATON ], - [TrainerPoolTier.UNCOMMON]: [ Species.TOGEKISS, Species.GARDEVOIR, Species.SYLVEON, Species.KLEFKI, Species.MIMIKYU, Species.ALOLA_NINETALES ], - [TrainerPoolTier.RARE]: [ Species.GALAR_RAPIDASH, Species.PRIMARINA ] + [TrainerPoolTier.COMMON]: [ + Species.CLEFABLE, + Species.WIGGLYTUFF, + Species.AZUMARILL, + Species.WHIMSICOTT, + Species.FLORGES, + Species.HATTERENE, + Species.GRIMMSNARL, + Species.TINKATON, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.TOGEKISS, + Species.GARDEVOIR, + Species.SYLVEON, + Species.KLEFKI, + Species.MIMIKYU, + Species.ALOLA_NINETALES, + ], + [TrainerPoolTier.RARE]: [Species.GALAR_RAPIDASH, Species.PRIMARINA], }; } case "star_5": { return { - [TrainerPoolTier.COMMON]: [ Species.BRELOOM, Species.HARIYAMA, Species.MEDICHAM, Species.TOXICROAK, Species.SCRAFTY, Species.MIENSHAO, Species.PAWMOT, Species.PALDEA_TAUROS ], - [TrainerPoolTier.UNCOMMON]: [ Species.LUCARIO, Species.CONKELDURR, Species.HAWLUCHA, Species.PASSIMIAN, Species.FALINKS, Species.FLAMIGO ], - [TrainerPoolTier.RARE]: [ Species.KOMMO_O, Species.QUAQUAVAL ] + [TrainerPoolTier.COMMON]: [ + Species.BRELOOM, + Species.HARIYAMA, + Species.MEDICHAM, + Species.TOXICROAK, + Species.SCRAFTY, + Species.MIENSHAO, + Species.PAWMOT, + Species.PALDEA_TAUROS, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.LUCARIO, + Species.CONKELDURR, + Species.HAWLUCHA, + Species.PASSIMIAN, + Species.FALINKS, + Species.FLAMIGO, + ], + [TrainerPoolTier.RARE]: [Species.KOMMO_O, Species.QUAQUAVAL], }; } } @@ -782,14 +1182,19 @@ export class TrainerConfig { } /** - * Initializes the trainer configuration for an evil team admin. - * @param title The title of the evil team admin. - * @param poolName The evil team the admin belongs to. - * @param {Species | Species[]} signatureSpecies The signature species for the evil team leader. - * @param specialtyType The specialty Type of the admin, if they have one - * @returns {TrainerConfig} The updated TrainerConfig instance. - * **/ - initForEvilTeamAdmin(title: string, poolName: string, signatureSpecies: (Species | Species[])[], specialtyType?: PokemonType): TrainerConfig { + * Initializes the trainer configuration for an evil team admin. + * @param title The title of the evil team admin. + * @param poolName The evil team the admin belongs to. + * @param {Species | Species[]} signatureSpecies The signature species for the evil team leader. + * @param specialtyType The specialty Type of the admin, if they have one + * @returns {TrainerConfig} The updated TrainerConfig instance. + * **/ + initForEvilTeamAdmin( + title: string, + poolName: string, + signatureSpecies: (Species | Species[])[], + specialtyType?: PokemonType, + ): TrainerConfig { if (!getIsInitialized()) { initI18n(); } @@ -805,7 +1210,7 @@ export class TrainerConfig { signatureSpecies.forEach((speciesPool, s) => { if (!Array.isArray(speciesPool)) { - speciesPool = [ speciesPool ]; + speciesPool = [speciesPool]; } this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); }); @@ -825,10 +1230,10 @@ export class TrainerConfig { /** * Initializes the trainer configuration for a Stat Trainer, as part of the Trainer's Test Mystery Encounter. - * @param isMale Whether the stat trainer is Male or Female (for localization of the title). + * @param _isMale Whether the stat trainer is Male or Female (for localization of the title). * @returns {TrainerConfig} The updated TrainerConfig instance. **/ - initForStatTrainer(isMale: boolean = false): TrainerConfig { + initForStatTrainer(_isMale = false): TrainerConfig { if (!getIsInitialized()) { initI18n(); } @@ -849,13 +1254,18 @@ export class TrainerConfig { } /** - * Initializes the trainer configuration for an evil team leader. Temporarily hardcoding evil leader teams though. - * @param {Species | Species[]} signatureSpecies The signature species for the evil team leader. - * @param {PokemonType} specialtyType The specialty type for the evil team Leader. - * @param boolean Whether or not this is the rematch fight - * @returns {TrainerConfig} The updated TrainerConfig instance. - * **/ - initForEvilTeamLeader(title: string, signatureSpecies: (Species | Species[])[], rematch: boolean = false, specialtyType?: PokemonType): TrainerConfig { + * Initializes the trainer configuration for an evil team leader. Temporarily hardcoding evil leader teams though. + * @param {Species | Species[]} signatureSpecies The signature species for the evil team leader. + * @param {PokemonType} specialtyType The specialty type for the evil team Leader. + * @param boolean Whether or not this is the rematch fight + * @returns {TrainerConfig} The updated TrainerConfig instance. + * **/ + initForEvilTeamLeader( + title: string, + signatureSpecies: (Species | Species[])[], + rematch = false, + specialtyType?: PokemonType, + ): TrainerConfig { if (!getIsInitialized()) { initI18n(); } @@ -866,7 +1276,7 @@ export class TrainerConfig { } signatureSpecies.forEach((speciesPool, s) => { if (!Array.isArray(speciesPool)) { - speciesPool = [ speciesPool ]; + speciesPool = [speciesPool]; } this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); }); @@ -888,15 +1298,21 @@ export class TrainerConfig { } /** - * Initializes the trainer configuration for a Gym Leader. - * @param {Species | Species[]} signatureSpecies The signature species for the Gym Leader. Added to party in reverse order. - * @param isMale Whether the Gym Leader is Male or Not (for localization of the title). - * @param {PokemonType} specialtyType The specialty type for the Gym Leader. - * @param ignoreMinTeraWave Whether the Gym Leader always uses Tera (true), or only Teras after {@linkcode GYM_LEADER_TERA_WAVE} (false). Defaults to false. - * @param teraSlot Optional, sets the party member in this slot to Terastallize. Wraps based on party size. - * @returns {TrainerConfig} The updated TrainerConfig instance. - * **/ - initForGymLeader(signatureSpecies: (Species | Species[])[], isMale: boolean, specialtyType: PokemonType, ignoreMinTeraWave: boolean = false, teraSlot?: number): TrainerConfig { + * Initializes the trainer configuration for a Gym Leader. + * @param {Species | Species[]} signatureSpecies The signature species for the Gym Leader. Added to party in reverse order. + * @param isMale Whether the Gym Leader is Male or Not (for localization of the title). + * @param {PokemonType} specialtyType The specialty type for the Gym Leader. + * @param ignoreMinTeraWave Whether the Gym Leader always uses Tera (true), or only Teras after {@linkcode GYM_LEADER_TERA_WAVE} (false). Defaults to false. + * @param teraSlot Optional, sets the party member in this slot to Terastallize. Wraps based on party size. + * @returns {TrainerConfig} The updated TrainerConfig instance. + * **/ + initForGymLeader( + signatureSpecies: (Species | Species[])[], + isMale: boolean, + specialtyType: PokemonType, + ignoreMinTeraWave = false, + teraSlot?: number, + ): TrainerConfig { // Check if the internationalization (i18n) system is initialized. if (!getIsInitialized()) { initI18n(); @@ -909,7 +1325,7 @@ export class TrainerConfig { signatureSpecies.forEach((speciesPool, s) => { // Ensure speciesPool is an array. if (!Array.isArray(speciesPool)) { - speciesPool = [ speciesPool ]; + speciesPool = [speciesPool]; } // Set a function to get a random party member from the species pool. this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); @@ -936,20 +1352,28 @@ export class TrainerConfig { this.setHasVoucher(true); this.setBattleBgm("battle_unova_gym"); this.setVictoryBgm("victory_gym"); - this.setRandomTeraModifiers(() => (ignoreMinTeraWave || globalScene.currentBattle.waveIndex >= GYM_LEADER_TERA_WAVE) ? 1 : 0, teraSlot); + this.setRandomTeraModifiers( + () => (ignoreMinTeraWave || globalScene.currentBattle.waveIndex >= GYM_LEADER_TERA_WAVE ? 1 : 0), + teraSlot, + ); return this; } /** - * Initializes the trainer configuration for an Elite Four member. - * @param {Species | Species[]} signatureSpecies The signature species for the Elite Four member. - * @param isMale Whether the Elite Four Member is Male or Female (for localization of the title). - * @param specialtyType {PokemonType} The specialty type for the Elite Four member. - * @param teraSlot Optional, sets the party member in this slot to Terastallize. - * @returns {TrainerConfig} The updated TrainerConfig instance. - **/ - initForEliteFour(signatureSpecies: (Species | Species[])[], isMale: boolean, specialtyType?: PokemonType, teraSlot?: number): TrainerConfig { + * Initializes the trainer configuration for an Elite Four member. + * @param {Species | Species[]} signatureSpecies The signature species for the Elite Four member. + * @param isMale Whether the Elite Four Member is Male or Female (for localization of the title). + * @param specialtyType {PokemonType} The specialty type for the Elite Four member. + * @param teraSlot Optional, sets the party member in this slot to Terastallize. + * @returns {TrainerConfig} The updated TrainerConfig instance. + **/ + initForEliteFour( + signatureSpecies: (Species | Species[])[], + isMale: boolean, + specialtyType?: PokemonType, + teraSlot?: number, + ): TrainerConfig { // Check if the internationalization (i18n) system is initialized. if (!getIsInitialized()) { initI18n(); @@ -962,7 +1386,7 @@ export class TrainerConfig { signatureSpecies.forEach((speciesPool, s) => { // Ensure speciesPool is an array. if (!Array.isArray(speciesPool)) { - speciesPool = [ speciesPool ]; + speciesPool = [speciesPool]; } // Set a function to get a random party member from the species pool. this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); @@ -999,11 +1423,11 @@ export class TrainerConfig { } /** - * Initializes the trainer configuration for a Champion. - * @param {Species | Species[]} signatureSpecies The signature species for the Champion. - * @param isMale Whether the Champion is Male or Female (for localization of the title). - * @returns {TrainerConfig} The updated TrainerConfig instance. - **/ + * Initializes the trainer configuration for a Champion. + * @param {Species | Species[]} signatureSpecies The signature species for the Champion. + * @param isMale Whether the Champion is Male or Female (for localization of the title). + * @returns {TrainerConfig} The updated TrainerConfig instance. + **/ initForChampion(isMale: boolean): TrainerConfig { // Check if the internationalization (i18n) system is initialized. if (!getIsInitialized()) { @@ -1023,7 +1447,6 @@ export class TrainerConfig { this.setTitle("champion_female"); } - // Configure various properties for the Champion. this.setMoneyMultiplier(10); this.setBoss(); @@ -1050,11 +1473,11 @@ export class TrainerConfig { } /** - * Retrieves the title for the trainer based on the provided trainer slot and variant. - * @param {TrainerSlot} trainerSlot - The slot to determine which title to use. Defaults to TrainerSlot.NONE. - * @param {TrainerVariant} variant - The variant of the trainer to determine the specific title. - * @returns {string} - The title of the trainer. - **/ + * Retrieves the title for the trainer based on the provided trainer slot and variant. + * @param {TrainerSlot} trainerSlot - The slot to determine which title to use. Defaults to TrainerSlot.NONE. + * @param {TrainerVariant} variant - The variant of the trainer to determine the specific title. + * @returns {string} - The title of the trainer. + **/ getTitle(trainerSlot: TrainerSlot = TrainerSlot.NONE, variant: TrainerVariant): string { const ret = this.name; @@ -1068,24 +1491,24 @@ export class TrainerConfig { // If the name is already set if (this.nameFemale) { // Check if the variant is either female or this is for the partner in a double battle - if (variant === TrainerVariant.FEMALE || (variant === TrainerVariant.DOUBLE && trainerSlot === TrainerSlot.TRAINER_PARTNER)) { + if ( + variant === TrainerVariant.FEMALE || + (variant === TrainerVariant.DOUBLE && trainerSlot === TrainerSlot.TRAINER_PARTNER) + ) { return this.nameFemale; } - } else + } // Check if !variant is true, if so return the name, else return the name with _female appended - if (variant) { - if (!getIsInitialized()) { - initI18n(); - } - // Check if the female version exists in the i18n file - if (i18next.exists(`trainerClasses:${this.name.toLowerCase()}`)) { - // If it does, return - return ret + "_female"; - } else { - // If it doesn't, we do not do anything and go to the normal return - // This is to prevent the game from displaying an error if a female version of the trainer does not exist in the localization - } + else if (variant) { + if (!getIsInitialized()) { + initI18n(); } + // Check if the female version exists in the i18n file + if (i18next.exists(`trainerClasses:${this.name.toLowerCase()}`)) { + // If it does, return + return ret + "_female"; + } + } } return ret; @@ -1103,37 +1526,36 @@ export class TrainerConfig { globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => { const originalWarn = console.warn; // Ignore warnings for missing frames, because there will be a lot - console.warn = () => { - }; + console.warn = () => {}; const frameNames = globalScene.anims.generateFrameNames(trainerKey, { zeroPad: 4, suffix: ".png", start: 1, - end: 128 + end: 128, }); const partnerFrameNames = isDouble ? globalScene.anims.generateFrameNames(partnerTrainerKey, { - zeroPad: 4, - suffix: ".png", - start: 1, - end: 128 - }) + zeroPad: 4, + suffix: ".png", + start: 1, + end: 128, + }) : ""; console.warn = originalWarn; - if (!(globalScene.anims.exists(trainerKey))) { + if (!globalScene.anims.exists(trainerKey)) { globalScene.anims.create({ key: trainerKey, frames: frameNames, frameRate: 24, - repeat: -1 + repeat: -1, }); } - if (isDouble && !(globalScene.anims.exists(partnerTrainerKey))) { + if (isDouble && !globalScene.anims.exists(partnerTrainerKey)) { globalScene.anims.create({ key: partnerTrainerKey, frames: partnerFrameNames, frameRate: 24, - repeat: -1 + repeat: -1, }); } resolve(); @@ -1186,8 +1608,8 @@ export class TrainerConfig { clone = this.partyTemplateFunc ? clone.setPartyTemplateFunc(this.partyTemplateFunc) : clone; if (this.partyMemberFuncs) { - Object.keys(this.partyMemberFuncs).forEach((index) => { - clone = clone.setPartyMemberFunc(parseInt(index, 10), this.partyMemberFuncs[index]); + Object.keys(this.partyMemberFuncs).forEach(index => { + clone = clone.setPartyMemberFunc(Number.parseInt(index, 10), this.partyMemberFuncs[index]); }); } @@ -1214,7 +1636,7 @@ export class TrainerConfig { let t = 0; interface TrainerConfigs { - [key: number]: TrainerConfig + [key: number]: TrainerConfig; } /** @@ -1225,23 +1647,42 @@ function getEvilGruntPartyTemplate(): TrainerPartyTemplate { const waveIndex = globalScene.currentBattle?.waveIndex; if (waveIndex < 40) { return trainerPartyTemplates.TWO_AVG; - } else if (waveIndex < 63) { - return trainerPartyTemplates.THREE_AVG; - } else if (waveIndex < 65) { - return trainerPartyTemplates.TWO_AVG_ONE_STRONG; - } else if (waveIndex < 112) { - return trainerPartyTemplates.GYM_LEADER_4; // 3avg 1 strong 1 stronger - } else { - return trainerPartyTemplates.GYM_LEADER_5; // 3 avg 2 strong 1 stronger } + if (waveIndex < 63) { + return trainerPartyTemplates.THREE_AVG; + } + if (waveIndex < 65) { + return trainerPartyTemplates.TWO_AVG_ONE_STRONG; + } + if (waveIndex < 112) { + return trainerPartyTemplates.GYM_LEADER_4; // 3avg 1 strong 1 stronger + } + return trainerPartyTemplates.GYM_LEADER_5; // 3 avg 2 strong 1 stronger } function getWavePartyTemplate(...templates: TrainerPartyTemplate[]) { - return templates[Math.min(Math.max(Math.ceil((globalScene.gameMode.getWaveForDifficulty(globalScene.currentBattle?.waveIndex || startingWave, true) - 20) / 30), 0), templates.length - 1)]; + return templates[ + Math.min( + Math.max( + Math.ceil( + (globalScene.gameMode.getWaveForDifficulty(globalScene.currentBattle?.waveIndex || startingWave, true) - 20) / + 30, + ), + 0, + ), + templates.length - 1, + ) + ]; } function getGymLeaderPartyTemplate() { - return getWavePartyTemplate(trainerPartyTemplates.GYM_LEADER_1, trainerPartyTemplates.GYM_LEADER_2, trainerPartyTemplates.GYM_LEADER_3, trainerPartyTemplates.GYM_LEADER_4, trainerPartyTemplates.GYM_LEADER_5); + return getWavePartyTemplate( + trainerPartyTemplates.GYM_LEADER_1, + trainerPartyTemplates.GYM_LEADER_2, + trainerPartyTemplates.GYM_LEADER_3, + trainerPartyTemplates.GYM_LEADER_4, + trainerPartyTemplates.GYM_LEADER_5, + ); } /** @@ -1252,13 +1693,31 @@ function getGymLeaderPartyTemplate() { * @param ignoreEvolution * @param postProcess */ -export function getRandomPartyMemberFunc(speciesPool: Species[], trainerSlot: TrainerSlot = TrainerSlot.TRAINER, ignoreEvolution: boolean = false, postProcess?: (enemyPokemon: EnemyPokemon) => void) { +export function getRandomPartyMemberFunc( + speciesPool: Species[], + trainerSlot: TrainerSlot = TrainerSlot.TRAINER, + ignoreEvolution = false, + postProcess?: (enemyPokemon: EnemyPokemon) => void, +) { return (level: number, strength: PartyMemberStrength) => { let species = Utils.randSeedItem(speciesPool); if (!ignoreEvolution) { - species = getPokemonSpecies(species).getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex); + species = getPokemonSpecies(species).getTrainerSpeciesForLevel( + level, + true, + strength, + globalScene.currentBattle.waveIndex, + ); } - return globalScene.addEnemyPokemon(getPokemonSpecies(species), level, trainerSlot, undefined, false, undefined, postProcess); + return globalScene.addEnemyPokemon( + getPokemonSpecies(species), + level, + trainerSlot, + undefined, + false, + undefined, + postProcess, + ); }; } @@ -1266,9 +1725,8 @@ function getSpeciesFilterRandomPartyMemberFunc( originalSpeciesFilter: PokemonSpeciesFilter, trainerSlot: TrainerSlot = TrainerSlot.TRAINER, allowLegendaries?: boolean, - postProcess?: (EnemyPokemon: EnemyPokemon) => void + postProcess?: (EnemyPokemon: EnemyPokemon) => void, ): PartyMemberFunc { - const speciesFilter = (species: PokemonSpecies): boolean => { const notLegendary = !species.legendary && !species.subLegendary && !species.mythical; return (allowLegendaries || notLegendary) && !species.isTrainerForbidden() && originalSpeciesFilter(species); @@ -1276,16 +1734,18 @@ function getSpeciesFilterRandomPartyMemberFunc( return (level: number, strength: PartyMemberStrength) => { const waveIndex = globalScene.currentBattle.waveIndex; - const species = getPokemonSpecies(globalScene.randomSpecies(waveIndex, level, false, speciesFilter) - .getTrainerSpeciesForLevel(level, true, strength, waveIndex)); + const species = getPokemonSpecies( + globalScene + .randomSpecies(waveIndex, level, false, speciesFilter) + .getTrainerSpeciesForLevel(level, true, strength, waveIndex), + ); return globalScene.addEnemyPokemon(species, level, trainerSlot, undefined, false, undefined, postProcess); }; } - type SignatureSpecies = { - [key in string]: (Species | Species[])[]; + [key in string]: (Species | Species[])[]; }; /* @@ -1294,1639 +1754,4223 @@ type SignatureSpecies = { * This is in a separate const so it can be accessed from other places and not just the trainerConfigs */ export const signatureSpecies: SignatureSpecies = { - BROCK: [ Species.GEODUDE, Species.ONIX ], - MISTY: [ Species.STARYU, Species.PSYDUCK ], - LT_SURGE: [ Species.VOLTORB, Species.PIKACHU, Species.ELECTABUZZ ], - ERIKA: [ Species.ODDISH, Species.BELLSPROUT, Species.TANGELA, Species.HOPPIP ], - JANINE: [ Species.VENONAT, Species.SPINARAK, Species.ZUBAT ], - SABRINA: [ Species.ABRA, Species.MR_MIME, Species.ESPEON ], - BLAINE: [ Species.GROWLITHE, Species.PONYTA, Species.MAGMAR ], - GIOVANNI: [ Species.SANDILE, Species.MURKROW, Species.NIDORAN_M, Species.NIDORAN_F ], - FALKNER: [ Species.PIDGEY, Species.HOOTHOOT, Species.DODUO ], - BUGSY: [ Species.SCYTHER, Species.HERACROSS, Species.SHUCKLE, Species.PINSIR ], - WHITNEY: [ Species.JIGGLYPUFF, Species.MILTANK, Species.AIPOM, Species.GIRAFARIG ], - MORTY: [ Species.GASTLY, Species.MISDREAVUS, Species.SABLEYE ], - CHUCK: [ Species.POLIWRATH, Species.MANKEY ], - JASMINE: [ Species.MAGNEMITE, Species.STEELIX ], - PRYCE: [ Species.SEEL, Species.SWINUB ], - CLAIR: [ Species.DRATINI, Species.HORSEA, Species.GYARADOS ], - ROXANNE: [ Species.GEODUDE, Species.NOSEPASS ], - BRAWLY: [ Species.MACHOP, Species.MAKUHITA ], - WATTSON: [ Species.MAGNEMITE, Species.VOLTORB, Species.ELECTRIKE ], - FLANNERY: [ Species.SLUGMA, Species.TORKOAL, Species.NUMEL ], - NORMAN: [ Species.SLAKOTH, Species.SPINDA, Species.ZIGZAGOON, Species.KECLEON ], - WINONA: [ Species.SWABLU, Species.WINGULL, Species.TROPIUS, Species.SKARMORY ], - TATE: [ Species.SOLROCK, Species.NATU, Species.CHIMECHO, Species.GALLADE ], - LIZA: [ Species.LUNATONE, Species.SPOINK, Species.BALTOY, Species.GARDEVOIR ], - JUAN: [ Species.HORSEA, Species.BARBOACH, Species.SPHEAL, Species.RELICANTH ], - ROARK: [ Species.CRANIDOS, Species.LARVITAR, Species.GEODUDE ], - GARDENIA: [ Species.ROSELIA, Species.TANGELA, Species.TURTWIG ], - MAYLENE: [ Species.LUCARIO, Species.MEDITITE, Species.CHIMCHAR ], - CRASHER_WAKE: [ Species.BUIZEL, Species.WOOPER, Species.PIPLUP, Species.MAGIKARP ], - FANTINA: [ Species.MISDREAVUS, Species.DRIFLOON, Species.SPIRITOMB ], - BYRON: [ Species.SHIELDON, Species.BRONZOR, Species.AGGRON ], - CANDICE: [ Species.SNEASEL, Species.SNOVER, Species.SNORUNT ], - VOLKNER: [ Species.SHINX, Species.CHINCHOU, Species.ROTOM ], - CILAN: [ Species.PANSAGE, Species.FOONGUS, Species.PETILIL ], - CHILI: [ Species.PANSEAR, Species.DARUMAKA, Species.NUMEL ], - CRESS: [ Species.PANPOUR, Species.TYMPOLE, Species.SLOWPOKE ], - CHEREN: [ Species.LILLIPUP, Species.MINCCINO, Species.PIDOVE ], - LENORA: [ Species.PATRAT, Species.DEERLING, Species.AUDINO ], - ROXIE: [ Species.VENIPEDE, Species.TRUBBISH, Species.SKORUPI ], - BURGH: [ Species.SEWADDLE, Species.SHELMET, Species.KARRABLAST ], - ELESA: [ Species.EMOLGA, Species.BLITZLE, Species.JOLTIK ], - CLAY: [ Species.DRILBUR, Species.SANDILE, Species.GOLETT ], - SKYLA: [ Species.DUCKLETT, Species.WOOBAT, Species.RUFFLET ], - BRYCEN: [ Species.CRYOGONAL, Species.VANILLITE, Species.CUBCHOO ], - DRAYDEN: [ Species.DRUDDIGON, Species.AXEW, Species.DEINO ], - MARLON: [ Species.WAILMER, Species.FRILLISH, Species.TIRTOUGA ], - VIOLA: [ Species.SURSKIT, Species.SCATTERBUG ], - GRANT: [ Species.AMAURA, Species.TYRUNT ], - KORRINA: [ Species.HAWLUCHA, Species.LUCARIO, Species.MIENFOO ], - RAMOS: [ Species.SKIDDO, Species.HOPPIP, Species.BELLSPROUT ], - CLEMONT: [ Species.HELIOPTILE, Species.MAGNEMITE, Species.EMOLGA ], - VALERIE: [ Species.SYLVEON, Species.MAWILE, Species.MR_MIME ], - OLYMPIA: [ Species.ESPURR, Species.SIGILYPH, Species.SLOWKING ], - WULFRIC: [ Species.BERGMITE, Species.SNOVER, Species.CRYOGONAL ], - MILO: [ Species.GOSSIFLEUR, Species.APPLIN, Species.BOUNSWEET ], - NESSA: [ Species.CHEWTLE, Species.ARROKUDA, Species.WIMPOD ], - KABU: [ Species.SIZZLIPEDE, Species.VULPIX, Species.TORKOAL ], - BEA: [ Species.GALAR_FARFETCHD, Species.MACHOP, Species.CLOBBOPUS ], - ALLISTER: [ Species.GALAR_YAMASK, Species.GALAR_CORSOLA, Species.GASTLY ], - OPAL: [ Species.MILCERY, Species.TOGETIC, Species.GALAR_WEEZING ], - BEDE: [ Species.HATENNA, Species.GALAR_PONYTA, Species.GARDEVOIR ], - GORDIE: [ Species.ROLYCOLY, Species.STONJOURNER, Species.BINACLE ], - MELONY: [ Species.SNOM, Species.GALAR_DARUMAKA, Species.GALAR_MR_MIME ], - PIERS: [ Species.GALAR_ZIGZAGOON, Species.SCRAGGY, Species.INKAY ], - MARNIE: [ Species.IMPIDIMP, Species.PURRLOIN, Species.MORPEKO ], - RAIHAN: [ Species.DURALUDON, Species.TURTONATOR, Species.GOOMY ], - KATY: [ Species.TEDDIURSA, Species.NYMBLE, Species.TAROUNTULA ], // Tera Bug Teddiursa - BRASSIUS: [ Species.SUDOWOODO, Species.BRAMBLIN, Species.SMOLIV ], // Tera Grass Sudowoodo - IONO: [ Species.MISDREAVUS, Species.TADBULB, Species.WATTREL ], // Tera Ghost Misdreavus - KOFU: [ Species.CRABRAWLER, Species.VELUZA, Species.WIGLETT, Species.WINGULL ], // Tera Water Crabrawler - LARRY: [ Species.STARLY, Species.DUNSPARCE, Species.LECHONK, Species.KOMALA ], // Tera Normal Starly - RYME: [ Species.TOXEL, Species.GREAVARD, Species.SHUPPET, Species.MIMIKYU ], // Tera Ghost Toxel - TULIP: [ Species.FLABEBE, Species.FLITTLE, Species.RALTS, Species.GIRAFARIG ], // Tera Psychic Flabebe - GRUSHA: [ Species.SWABLU, Species.CETODDLE, Species.CUBCHOO, Species.ALOLA_VULPIX ], // Tera Ice Swablu - LORELEI: [ Species.JYNX, [ Species.SLOWBRO, Species.GALAR_SLOWBRO ], Species.LAPRAS, [ Species.CLOYSTER, Species.ALOLA_SANDSLASH ]], - BRUNO: [ Species.MACHAMP, Species.HITMONCHAN, Species.HITMONLEE, [ Species.GOLEM, Species.ALOLA_GOLEM ]], - AGATHA: [ Species.GENGAR, [ Species.ARBOK, Species.WEEZING ], Species.CROBAT, Species.ALOLA_MAROWAK ], - LANCE: [ Species.DRAGONITE, Species.GYARADOS, Species.AERODACTYL, Species.ALOLA_EXEGGUTOR ], - WILL: [ Species.XATU, Species.JYNX, [ Species.SLOWBRO, Species.SLOWKING ], Species.EXEGGUTOR ], - KOGA: [[ Species.MUK, Species.WEEZING ], [ Species.VENOMOTH, Species.ARIADOS ], Species.CROBAT, Species.TENTACRUEL ], - KAREN: [ Species.UMBREON, Species.HONCHKROW, Species.HOUNDOOM, Species.WEAVILE ], - SIDNEY: [[ Species.SHIFTRY, Species.CACTURNE ], [ Species.SHARPEDO, Species.CRAWDAUNT ], Species.ABSOL, Species.MIGHTYENA ], - PHOEBE: [ Species.SABLEYE, Species.DUSKNOIR, Species.BANETTE, [ Species.DRIFBLIM, Species.MISMAGIUS ]], - GLACIA: [ Species.GLALIE, Species.WALREIN, Species.FROSLASS, Species.ABOMASNOW ], - DRAKE: [ Species.ALTARIA, Species.SALAMENCE, Species.FLYGON, Species.KINGDRA ], - AARON: [[ Species.SCIZOR, Species.KLEAVOR ], Species.HERACROSS, [ Species.VESPIQUEN, Species.YANMEGA ], Species.DRAPION ], - BERTHA: [ Species.WHISCASH, Species.HIPPOWDON, Species.GLISCOR, Species.RHYPERIOR ], - FLINT: [[ Species.RAPIDASH, Species.FLAREON ], Species.MAGMORTAR, [ Species.STEELIX, Species.LOPUNNY ], Species.INFERNAPE ], // Tera Fire Steelix or Lopunny - LUCIAN: [ Species.MR_MIME, Species.GALLADE, Species.BRONZONG, [ Species.ALAKAZAM, Species.ESPEON ]], - SHAUNTAL: [ Species.COFAGRIGUS, Species.CHANDELURE, Species.GOLURK, Species.JELLICENT ], - MARSHAL: [ Species.CONKELDURR, Species.MIENSHAO, Species.THROH, Species.SAWK ], - GRIMSLEY: [ Species.LIEPARD, Species.KINGAMBIT, Species.SCRAFTY, Species.KROOKODILE ], - CAITLIN: [ Species.MUSHARNA, Species.GOTHITELLE, Species.SIGILYPH, Species.REUNICLUS ], - MALVA: [ Species.PYROAR, Species.TORKOAL, Species.CHANDELURE, Species.TALONFLAME ], - SIEBOLD: [ Species.CLAWITZER, Species.GYARADOS, Species.BARBARACLE, Species.STARMIE ], - WIKSTROM: [ Species.KLEFKI, Species.PROBOPASS, Species.SCIZOR, Species.AEGISLASH ], - DRASNA: [ Species.DRAGALGE, Species.DRUDDIGON, Species.ALTARIA, Species.NOIVERN ], - HALA: [ Species.HARIYAMA, Species.BEWEAR, Species.CRABOMINABLE, [ Species.POLIWRATH, Species.ANNIHILAPE ]], - MOLAYNE: [ Species.KLEFKI, Species.MAGNEZONE, Species.METAGROSS, Species.ALOLA_DUGTRIO ], - OLIVIA: [ Species.RELICANTH, Species.CARBINK, Species.ALOLA_GOLEM, Species.LYCANROC ], - ACEROLA: [[ Species.BANETTE, Species.DRIFBLIM ], Species.MIMIKYU, Species.DHELMISE, Species.PALOSSAND ], - KAHILI: [[ Species.BRAVIARY, Species.MANDIBUZZ ], Species.HAWLUCHA, Species.ORICORIO, Species.TOUCANNON ], - MARNIE_ELITE: [ Species.MORPEKO, Species.LIEPARD, [ Species.TOXICROAK, Species.SCRAFTY ], Species.GRIMMSNARL ], - NESSA_ELITE: [ Species.GOLISOPOD, [ Species.QUAGSIRE, Species.PELIPPER ], Species.TOXAPEX, Species.DREDNAW ], - BEA_ELITE: [ Species.HAWLUCHA, [ Species.GRAPPLOCT, Species.SIRFETCHD ], Species.FALINKS, Species.MACHAMP ], - ALLISTER_ELITE: [ Species.DUSKNOIR, [ Species.POLTEAGEIST, Species.RUNERIGUS ], Species.CURSOLA, Species.GENGAR ], - RAIHAN_ELITE: [ Species.GOODRA, [ Species.TORKOAL, Species.TURTONATOR ], Species.FLYGON, Species.ARCHALUDON ], - RIKA: [ Species.CLODSIRE, [ Species.DUGTRIO, Species.DONPHAN ], Species.CAMERUPT, Species.WHISCASH ], // Tera Ground Clodsire - POPPY: [ Species.TINKATON, Species.BRONZONG, Species.CORVIKNIGHT, Species.COPPERAJAH ], // Tera Steel Tinkaton - LARRY_ELITE: [ Species.FLAMIGO, Species.STARAPTOR, [ Species.ALTARIA, Species.TROPIUS ], Species.ORICORIO ], // Tera Flying Flamigo; random Oricorio - HASSEL: [ Species.BAXCALIBUR, [ Species.FLAPPLE, Species.APPLETUN ], Species.DRAGALGE, Species.NOIVERN ], // Tera Dragon Baxcalibur - CRISPIN: [ Species.BLAZIKEN, Species.MAGMORTAR, [ Species.CAMERUPT, Species.TALONFLAME ], Species.ROTOM ], // Tera Fire Blaziken; Heat Rotom - AMARYS: [ Species.METAGROSS, Species.SCIZOR, Species.EMPOLEON, Species.SKARMORY ], // Tera Steel Metagross - LACEY: [ Species.EXCADRILL, Species.PRIMARINA, [ Species.WHIMSICOTT, Species.ALCREMIE ], Species.GRANBULL ], // Tera Fairy Excadrill - DRAYTON: [ Species.ARCHALUDON, Species.DRAGONITE, Species.HAXORUS, Species.SCEPTILE ], // Tera Dragon Archaludon + BROCK: [Species.GEODUDE, Species.ONIX], + MISTY: [Species.STARYU, Species.PSYDUCK], + LT_SURGE: [Species.VOLTORB, Species.PIKACHU, Species.ELECTABUZZ], + ERIKA: [Species.ODDISH, Species.BELLSPROUT, Species.TANGELA, Species.HOPPIP], + JANINE: [Species.VENONAT, Species.SPINARAK, Species.ZUBAT], + SABRINA: [Species.ABRA, Species.MR_MIME, Species.ESPEON], + BLAINE: [Species.GROWLITHE, Species.PONYTA, Species.MAGMAR], + GIOVANNI: [Species.SANDILE, Species.MURKROW, Species.NIDORAN_M, Species.NIDORAN_F], + FALKNER: [Species.PIDGEY, Species.HOOTHOOT, Species.DODUO], + BUGSY: [Species.SCYTHER, Species.HERACROSS, Species.SHUCKLE, Species.PINSIR], + WHITNEY: [Species.JIGGLYPUFF, Species.MILTANK, Species.AIPOM, Species.GIRAFARIG], + MORTY: [Species.GASTLY, Species.MISDREAVUS, Species.SABLEYE], + CHUCK: [Species.POLIWRATH, Species.MANKEY], + JASMINE: [Species.MAGNEMITE, Species.STEELIX], + PRYCE: [Species.SEEL, Species.SWINUB], + CLAIR: [Species.DRATINI, Species.HORSEA, Species.GYARADOS], + ROXANNE: [Species.GEODUDE, Species.NOSEPASS], + BRAWLY: [Species.MACHOP, Species.MAKUHITA], + WATTSON: [Species.MAGNEMITE, Species.VOLTORB, Species.ELECTRIKE], + FLANNERY: [Species.SLUGMA, Species.TORKOAL, Species.NUMEL], + NORMAN: [Species.SLAKOTH, Species.SPINDA, Species.ZIGZAGOON, Species.KECLEON], + WINONA: [Species.SWABLU, Species.WINGULL, Species.TROPIUS, Species.SKARMORY], + TATE: [Species.SOLROCK, Species.NATU, Species.CHIMECHO, Species.GALLADE], + LIZA: [Species.LUNATONE, Species.SPOINK, Species.BALTOY, Species.GARDEVOIR], + JUAN: [Species.HORSEA, Species.BARBOACH, Species.SPHEAL, Species.RELICANTH], + ROARK: [Species.CRANIDOS, Species.LARVITAR, Species.GEODUDE], + GARDENIA: [Species.ROSELIA, Species.TANGELA, Species.TURTWIG], + MAYLENE: [Species.LUCARIO, Species.MEDITITE, Species.CHIMCHAR], + CRASHER_WAKE: [Species.BUIZEL, Species.WOOPER, Species.PIPLUP, Species.MAGIKARP], + FANTINA: [Species.MISDREAVUS, Species.DRIFLOON, Species.SPIRITOMB], + BYRON: [Species.SHIELDON, Species.BRONZOR, Species.AGGRON], + CANDICE: [Species.SNEASEL, Species.SNOVER, Species.SNORUNT], + VOLKNER: [Species.SHINX, Species.CHINCHOU, Species.ROTOM], + CILAN: [Species.PANSAGE, Species.FOONGUS, Species.PETILIL], + CHILI: [Species.PANSEAR, Species.DARUMAKA, Species.NUMEL], + CRESS: [Species.PANPOUR, Species.TYMPOLE, Species.SLOWPOKE], + CHEREN: [Species.LILLIPUP, Species.MINCCINO, Species.PIDOVE], + LENORA: [Species.PATRAT, Species.DEERLING, Species.AUDINO], + ROXIE: [Species.VENIPEDE, Species.TRUBBISH, Species.SKORUPI], + BURGH: [Species.SEWADDLE, Species.SHELMET, Species.KARRABLAST], + ELESA: [Species.EMOLGA, Species.BLITZLE, Species.JOLTIK], + CLAY: [Species.DRILBUR, Species.SANDILE, Species.GOLETT], + SKYLA: [Species.DUCKLETT, Species.WOOBAT, Species.RUFFLET], + BRYCEN: [Species.CRYOGONAL, Species.VANILLITE, Species.CUBCHOO], + DRAYDEN: [Species.DRUDDIGON, Species.AXEW, Species.DEINO], + MARLON: [Species.WAILMER, Species.FRILLISH, Species.TIRTOUGA], + VIOLA: [Species.SURSKIT, Species.SCATTERBUG], + GRANT: [Species.AMAURA, Species.TYRUNT], + KORRINA: [Species.HAWLUCHA, Species.LUCARIO, Species.MIENFOO], + RAMOS: [Species.SKIDDO, Species.HOPPIP, Species.BELLSPROUT], + CLEMONT: [Species.HELIOPTILE, Species.MAGNEMITE, Species.EMOLGA], + VALERIE: [Species.SYLVEON, Species.MAWILE, Species.MR_MIME], + OLYMPIA: [Species.ESPURR, Species.SIGILYPH, Species.SLOWKING], + WULFRIC: [Species.BERGMITE, Species.SNOVER, Species.CRYOGONAL], + MILO: [Species.GOSSIFLEUR, Species.APPLIN, Species.BOUNSWEET], + NESSA: [Species.CHEWTLE, Species.ARROKUDA, Species.WIMPOD], + KABU: [Species.SIZZLIPEDE, Species.VULPIX, Species.TORKOAL], + BEA: [Species.GALAR_FARFETCHD, Species.MACHOP, Species.CLOBBOPUS], + ALLISTER: [Species.GALAR_YAMASK, Species.GALAR_CORSOLA, Species.GASTLY], + OPAL: [Species.MILCERY, Species.TOGETIC, Species.GALAR_WEEZING], + BEDE: [Species.HATENNA, Species.GALAR_PONYTA, Species.GARDEVOIR], + GORDIE: [Species.ROLYCOLY, Species.STONJOURNER, Species.BINACLE], + MELONY: [Species.SNOM, Species.GALAR_DARUMAKA, Species.GALAR_MR_MIME], + PIERS: [Species.GALAR_ZIGZAGOON, Species.SCRAGGY, Species.INKAY], + MARNIE: [Species.IMPIDIMP, Species.PURRLOIN, Species.MORPEKO], + RAIHAN: [Species.DURALUDON, Species.TURTONATOR, Species.GOOMY], + KATY: [Species.TEDDIURSA, Species.NYMBLE, Species.TAROUNTULA], // Tera Bug Teddiursa + BRASSIUS: [Species.SUDOWOODO, Species.BRAMBLIN, Species.SMOLIV], // Tera Grass Sudowoodo + IONO: [Species.MISDREAVUS, Species.TADBULB, Species.WATTREL], // Tera Ghost Misdreavus + KOFU: [Species.CRABRAWLER, Species.VELUZA, Species.WIGLETT, Species.WINGULL], // Tera Water Crabrawler + LARRY: [Species.STARLY, Species.DUNSPARCE, Species.LECHONK, Species.KOMALA], // Tera Normal Starly + RYME: [Species.TOXEL, Species.GREAVARD, Species.SHUPPET, Species.MIMIKYU], // Tera Ghost Toxel + TULIP: [Species.FLABEBE, Species.FLITTLE, Species.RALTS, Species.GIRAFARIG], // Tera Psychic Flabebe + GRUSHA: [Species.SWABLU, Species.CETODDLE, Species.CUBCHOO, Species.ALOLA_VULPIX], // Tera Ice Swablu + LORELEI: [ + Species.JYNX, + [Species.SLOWBRO, Species.GALAR_SLOWBRO], + Species.LAPRAS, + [Species.CLOYSTER, Species.ALOLA_SANDSLASH], + ], + BRUNO: [Species.MACHAMP, Species.HITMONCHAN, Species.HITMONLEE, [Species.GOLEM, Species.ALOLA_GOLEM]], + AGATHA: [Species.GENGAR, [Species.ARBOK, Species.WEEZING], Species.CROBAT, Species.ALOLA_MAROWAK], + LANCE: [Species.DRAGONITE, Species.GYARADOS, Species.AERODACTYL, Species.ALOLA_EXEGGUTOR], + WILL: [Species.XATU, Species.JYNX, [Species.SLOWBRO, Species.SLOWKING], Species.EXEGGUTOR], + KOGA: [[Species.MUK, Species.WEEZING], [Species.VENOMOTH, Species.ARIADOS], Species.CROBAT, Species.TENTACRUEL], + KAREN: [Species.UMBREON, Species.HONCHKROW, Species.HOUNDOOM, Species.WEAVILE], + SIDNEY: [ + [Species.SHIFTRY, Species.CACTURNE], + [Species.SHARPEDO, Species.CRAWDAUNT], + Species.ABSOL, + Species.MIGHTYENA, + ], + PHOEBE: [Species.SABLEYE, Species.DUSKNOIR, Species.BANETTE, [Species.DRIFBLIM, Species.MISMAGIUS]], + GLACIA: [Species.GLALIE, Species.WALREIN, Species.FROSLASS, Species.ABOMASNOW], + DRAKE: [Species.ALTARIA, Species.SALAMENCE, Species.FLYGON, Species.KINGDRA], + AARON: [[Species.SCIZOR, Species.KLEAVOR], Species.HERACROSS, [Species.VESPIQUEN, Species.YANMEGA], Species.DRAPION], + BERTHA: [Species.WHISCASH, Species.HIPPOWDON, Species.GLISCOR, Species.RHYPERIOR], + FLINT: [ + [Species.RAPIDASH, Species.FLAREON], + Species.MAGMORTAR, + [Species.STEELIX, Species.LOPUNNY], + Species.INFERNAPE, + ], // Tera Fire Steelix or Lopunny + LUCIAN: [Species.MR_MIME, Species.GALLADE, Species.BRONZONG, [Species.ALAKAZAM, Species.ESPEON]], + SHAUNTAL: [Species.COFAGRIGUS, Species.CHANDELURE, Species.GOLURK, Species.JELLICENT], + MARSHAL: [Species.CONKELDURR, Species.MIENSHAO, Species.THROH, Species.SAWK], + GRIMSLEY: [Species.LIEPARD, Species.KINGAMBIT, Species.SCRAFTY, Species.KROOKODILE], + CAITLIN: [Species.MUSHARNA, Species.GOTHITELLE, Species.SIGILYPH, Species.REUNICLUS], + MALVA: [Species.PYROAR, Species.TORKOAL, Species.CHANDELURE, Species.TALONFLAME], + SIEBOLD: [Species.CLAWITZER, Species.GYARADOS, Species.BARBARACLE, Species.STARMIE], + WIKSTROM: [Species.KLEFKI, Species.PROBOPASS, Species.SCIZOR, Species.AEGISLASH], + DRASNA: [Species.DRAGALGE, Species.DRUDDIGON, Species.ALTARIA, Species.NOIVERN], + HALA: [Species.HARIYAMA, Species.BEWEAR, Species.CRABOMINABLE, [Species.POLIWRATH, Species.ANNIHILAPE]], + MOLAYNE: [Species.KLEFKI, Species.MAGNEZONE, Species.METAGROSS, Species.ALOLA_DUGTRIO], + OLIVIA: [Species.RELICANTH, Species.CARBINK, Species.ALOLA_GOLEM, Species.LYCANROC], + ACEROLA: [[Species.BANETTE, Species.DRIFBLIM], Species.MIMIKYU, Species.DHELMISE, Species.PALOSSAND], + KAHILI: [[Species.BRAVIARY, Species.MANDIBUZZ], Species.HAWLUCHA, Species.ORICORIO, Species.TOUCANNON], + MARNIE_ELITE: [Species.MORPEKO, Species.LIEPARD, [Species.TOXICROAK, Species.SCRAFTY], Species.GRIMMSNARL], + NESSA_ELITE: [Species.GOLISOPOD, [Species.QUAGSIRE, Species.PELIPPER], Species.TOXAPEX, Species.DREDNAW], + BEA_ELITE: [Species.HAWLUCHA, [Species.GRAPPLOCT, Species.SIRFETCHD], Species.FALINKS, Species.MACHAMP], + ALLISTER_ELITE: [Species.DUSKNOIR, [Species.POLTEAGEIST, Species.RUNERIGUS], Species.CURSOLA, Species.GENGAR], + RAIHAN_ELITE: [Species.GOODRA, [Species.TORKOAL, Species.TURTONATOR], Species.FLYGON, Species.ARCHALUDON], + RIKA: [Species.CLODSIRE, [Species.DUGTRIO, Species.DONPHAN], Species.CAMERUPT, Species.WHISCASH], // Tera Ground Clodsire + POPPY: [Species.TINKATON, Species.BRONZONG, Species.CORVIKNIGHT, Species.COPPERAJAH], // Tera Steel Tinkaton + LARRY_ELITE: [Species.FLAMIGO, Species.STARAPTOR, [Species.ALTARIA, Species.TROPIUS], Species.ORICORIO], // Tera Flying Flamigo; random Oricorio + HASSEL: [Species.BAXCALIBUR, [Species.FLAPPLE, Species.APPLETUN], Species.DRAGALGE, Species.NOIVERN], // Tera Dragon Baxcalibur + CRISPIN: [Species.BLAZIKEN, Species.MAGMORTAR, [Species.CAMERUPT, Species.TALONFLAME], Species.ROTOM], // Tera Fire Blaziken; Heat Rotom + AMARYS: [Species.METAGROSS, Species.SCIZOR, Species.EMPOLEON, Species.SKARMORY], // Tera Steel Metagross + LACEY: [Species.EXCADRILL, Species.PRIMARINA, [Species.WHIMSICOTT, Species.ALCREMIE], Species.GRANBULL], // Tera Fairy Excadrill + DRAYTON: [Species.ARCHALUDON, Species.DRAGONITE, Species.HAXORUS, Species.SCEPTILE], // Tera Dragon Archaludon }; export const trainerConfigs: TrainerConfigs = { [TrainerType.UNKNOWN]: new TrainerConfig(0).setHasGenders(), - [TrainerType.ACE_TRAINER]: new TrainerConfig(++t).setHasGenders("Ace Trainer Female").setHasDouble("Ace Duo").setMoneyMultiplier(2.25).setEncounterBgm(TrainerType.ACE_TRAINER) - .setPartyTemplateFunc(() => getWavePartyTemplate(trainerPartyTemplates.THREE_WEAK_BALANCED, trainerPartyTemplates.FOUR_WEAK_BALANCED, trainerPartyTemplates.FIVE_WEAK_BALANCED, trainerPartyTemplates.SIX_WEAK_BALANCED)), - [TrainerType.ARTIST]: new TrainerConfig(++t).setEncounterBgm(TrainerType.RICH).setPartyTemplates(trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.THREE_AVG) - .setSpeciesPools([ Species.SMEARGLE ]), - [TrainerType.BACKERS]: new TrainerConfig(++t).setHasGenders("Backers").setDoubleOnly().setEncounterBgm(TrainerType.CYCLIST), - [TrainerType.BACKPACKER]: new TrainerConfig(++t).setHasGenders("Backpacker Female").setHasDouble("Backpackers").setSpeciesFilter(s => s.isOfType(PokemonType.FLYING) || s.isOfType(PokemonType.ROCK)).setEncounterBgm(TrainerType.BACKPACKER) - .setPartyTemplates(trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.ONE_WEAK_ONE_STRONG, trainerPartyTemplates.ONE_AVG_ONE_STRONG) + [TrainerType.ACE_TRAINER]: new TrainerConfig(++t) + .setHasGenders("Ace Trainer Female") + .setHasDouble("Ace Duo") + .setMoneyMultiplier(2.25) + .setEncounterBgm(TrainerType.ACE_TRAINER) + .setPartyTemplateFunc(() => + getWavePartyTemplate( + trainerPartyTemplates.THREE_WEAK_BALANCED, + trainerPartyTemplates.FOUR_WEAK_BALANCED, + trainerPartyTemplates.FIVE_WEAK_BALANCED, + trainerPartyTemplates.SIX_WEAK_BALANCED, + ), + ), + [TrainerType.ARTIST]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.RICH) + .setPartyTemplates(trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.THREE_AVG) + .setSpeciesPools([Species.SMEARGLE]), + [TrainerType.BACKERS]: new TrainerConfig(++t) + .setHasGenders("Backers") + .setDoubleOnly() + .setEncounterBgm(TrainerType.CYCLIST), + [TrainerType.BACKPACKER]: new TrainerConfig(++t) + .setHasGenders("Backpacker Female") + .setHasDouble("Backpackers") + .setSpeciesFilter(s => s.isOfType(PokemonType.FLYING) || s.isOfType(PokemonType.ROCK)) + .setEncounterBgm(TrainerType.BACKPACKER) + .setPartyTemplates( + trainerPartyTemplates.ONE_STRONG, + trainerPartyTemplates.ONE_WEAK_ONE_STRONG, + trainerPartyTemplates.ONE_AVG_ONE_STRONG, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.RHYHORN, Species.AIPOM, Species.MAKUHITA, Species.MAWILE, Species.NUMEL, Species.LILLIPUP, Species.SANDILE, Species.WOOLOO ], - [TrainerPoolTier.UNCOMMON]: [ Species.GIRAFARIG, Species.ZANGOOSE, Species.SEVIPER, Species.CUBCHOO, Species.PANCHAM, Species.SKIDDO, Species.MUDBRAY ], - [TrainerPoolTier.RARE]: [ Species.TAUROS, Species.STANTLER, Species.DARUMAKA, Species.BOUFFALANT, Species.DEERLING, Species.IMPIDIMP ], - [TrainerPoolTier.SUPER_RARE]: [ Species.GALAR_DARUMAKA, Species.TEDDIURSA ] + [TrainerPoolTier.COMMON]: [ + Species.RHYHORN, + Species.AIPOM, + Species.MAKUHITA, + Species.MAWILE, + Species.NUMEL, + Species.LILLIPUP, + Species.SANDILE, + Species.WOOLOO, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.GIRAFARIG, + Species.ZANGOOSE, + Species.SEVIPER, + Species.CUBCHOO, + Species.PANCHAM, + Species.SKIDDO, + Species.MUDBRAY, + ], + [TrainerPoolTier.RARE]: [ + Species.TAUROS, + Species.STANTLER, + Species.DARUMAKA, + Species.BOUFFALANT, + Species.DEERLING, + Species.IMPIDIMP, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.GALAR_DARUMAKA, Species.TEDDIURSA], }), - [TrainerType.BAKER]: new TrainerConfig(++t).setEncounterBgm(TrainerType.CLERK).setMoneyMultiplier(1.35).setSpeciesFilter(s => s.isOfType(PokemonType.GRASS) || s.isOfType(PokemonType.FIRE)), + [TrainerType.BAKER]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.CLERK) + .setMoneyMultiplier(1.35) + .setSpeciesFilter(s => s.isOfType(PokemonType.GRASS) || s.isOfType(PokemonType.FIRE)), [TrainerType.BEAUTY]: new TrainerConfig(++t).setMoneyMultiplier(1.55).setEncounterBgm(TrainerType.PARASOL_LADY), - [TrainerType.BIKER]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setEncounterBgm(TrainerType.ROUGHNECK).setSpeciesFilter(s => s.isOfType(PokemonType.POISON)), - [TrainerType.BLACK_BELT]: new TrainerConfig(++t).setHasGenders("Battle Girl", TrainerType.PSYCHIC).setHasDouble("Crush Kin").setEncounterBgm(TrainerType.ROUGHNECK).setSpecialtyType(PokemonType.FIGHTING) - .setPartyTemplates(trainerPartyTemplates.TWO_WEAK_ONE_AVG, trainerPartyTemplates.TWO_WEAK_ONE_AVG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_WEAK_ONE_STRONG, trainerPartyTemplates.THREE_AVG, trainerPartyTemplates.TWO_AVG_ONE_STRONG) + [TrainerType.BIKER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpeciesFilter(s => s.isOfType(PokemonType.POISON)), + [TrainerType.BLACK_BELT]: new TrainerConfig(++t) + .setHasGenders("Battle Girl", TrainerType.PSYCHIC) + .setHasDouble("Crush Kin") + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpecialtyType(PokemonType.FIGHTING) + .setPartyTemplates( + trainerPartyTemplates.TWO_WEAK_ONE_AVG, + trainerPartyTemplates.TWO_WEAK_ONE_AVG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_WEAK_ONE_STRONG, + trainerPartyTemplates.THREE_AVG, + trainerPartyTemplates.TWO_AVG_ONE_STRONG, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.NIDORAN_F, Species.NIDORAN_M, Species.MACHOP, Species.MAKUHITA, Species.MEDITITE, Species.CROAGUNK, Species.TIMBURR ], - [TrainerPoolTier.UNCOMMON]: [ Species.MANKEY, Species.POLIWRATH, Species.TYROGUE, Species.BRELOOM, Species.SCRAGGY, Species.MIENFOO, Species.PANCHAM, Species.STUFFUL, Species.CRABRAWLER ], - [TrainerPoolTier.RARE]: [ Species.HERACROSS, Species.RIOLU, Species.THROH, Species.SAWK, Species.PASSIMIAN, Species.CLOBBOPUS ], - [TrainerPoolTier.SUPER_RARE]: [ Species.HITMONTOP, Species.INFERNAPE, Species.GALLADE, Species.HAWLUCHA, Species.HAKAMO_O ], - [TrainerPoolTier.ULTRA_RARE]: [ Species.KUBFU ] + [TrainerPoolTier.COMMON]: [ + Species.NIDORAN_F, + Species.NIDORAN_M, + Species.MACHOP, + Species.MAKUHITA, + Species.MEDITITE, + Species.CROAGUNK, + Species.TIMBURR, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.MANKEY, + Species.POLIWRATH, + Species.TYROGUE, + Species.BRELOOM, + Species.SCRAGGY, + Species.MIENFOO, + Species.PANCHAM, + Species.STUFFUL, + Species.CRABRAWLER, + ], + [TrainerPoolTier.RARE]: [ + Species.HERACROSS, + Species.RIOLU, + Species.THROH, + Species.SAWK, + Species.PASSIMIAN, + Species.CLOBBOPUS, + ], + [TrainerPoolTier.SUPER_RARE]: [ + Species.HITMONTOP, + Species.INFERNAPE, + Species.GALLADE, + Species.HAWLUCHA, + Species.HAKAMO_O, + ], + [TrainerPoolTier.ULTRA_RARE]: [Species.KUBFU], }), - [TrainerType.BREEDER]: new TrainerConfig(++t).setMoneyMultiplier(1.325).setEncounterBgm(TrainerType.POKEFAN).setHasGenders("Breeder Female").setHasDouble("Breeders") - .setPartyTemplateFunc(() => getWavePartyTemplate(trainerPartyTemplates.FOUR_WEAKER, trainerPartyTemplates.FIVE_WEAKER, trainerPartyTemplates.SIX_WEAKER)) + [TrainerType.BREEDER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.325) + .setEncounterBgm(TrainerType.POKEFAN) + .setHasGenders("Breeder Female") + .setHasDouble("Breeders") + .setPartyTemplateFunc(() => + getWavePartyTemplate( + trainerPartyTemplates.FOUR_WEAKER, + trainerPartyTemplates.FIVE_WEAKER, + trainerPartyTemplates.SIX_WEAKER, + ), + ) .setSpeciesFilter(s => s.baseTotal < 450), - [TrainerType.CLERK]: new TrainerConfig(++t).setHasGenders("Clerk Female").setHasDouble("Colleagues").setEncounterBgm(TrainerType.CLERK) - .setPartyTemplates(trainerPartyTemplates.TWO_WEAK, trainerPartyTemplates.THREE_WEAK, trainerPartyTemplates.ONE_AVG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_WEAK_ONE_AVG) + [TrainerType.CLERK]: new TrainerConfig(++t) + .setHasGenders("Clerk Female") + .setHasDouble("Colleagues") + .setEncounterBgm(TrainerType.CLERK) + .setPartyTemplates( + trainerPartyTemplates.TWO_WEAK, + trainerPartyTemplates.THREE_WEAK, + trainerPartyTemplates.ONE_AVG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_WEAK_ONE_AVG, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.MEOWTH, Species.PSYDUCK, Species.BUDEW, Species.PIDOVE, Species.CINCCINO, Species.LITLEO ], - [TrainerPoolTier.UNCOMMON]: [ Species.JIGGLYPUFF, Species.MAGNEMITE, Species.MARILL, Species.COTTONEE, Species.SKIDDO ], - [TrainerPoolTier.RARE]: [ Species.BUIZEL, Species.SNEASEL, Species.KLEFKI, Species.INDEEDEE ] + [TrainerPoolTier.COMMON]: [ + Species.MEOWTH, + Species.PSYDUCK, + Species.BUDEW, + Species.PIDOVE, + Species.CINCCINO, + Species.LITLEO, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.JIGGLYPUFF, + Species.MAGNEMITE, + Species.MARILL, + Species.COTTONEE, + Species.SKIDDO, + ], + [TrainerPoolTier.RARE]: [Species.BUIZEL, Species.SNEASEL, Species.KLEFKI, Species.INDEEDEE], }), - [TrainerType.CYCLIST]: new TrainerConfig(++t).setMoneyMultiplier(1.3).setHasGenders("Cyclist Female").setHasDouble("Cyclists").setEncounterBgm(TrainerType.CYCLIST) + [TrainerType.CYCLIST]: new TrainerConfig(++t) + .setMoneyMultiplier(1.3) + .setHasGenders("Cyclist Female") + .setHasDouble("Cyclists") + .setEncounterBgm(TrainerType.CYCLIST) .setPartyTemplates(trainerPartyTemplates.TWO_WEAK, trainerPartyTemplates.ONE_AVG) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.PICHU, Species.STARLY, Species.TAILLOW, Species.BOLTUND ], - [TrainerPoolTier.UNCOMMON]: [ Species.DODUO, Species.ELECTRIKE, Species.BLITZLE, Species.WATTREL ], - [TrainerPoolTier.RARE]: [ Species.YANMA, Species.NINJASK, Species.WHIRLIPEDE, Species.EMOLGA ], - [TrainerPoolTier.SUPER_RARE]: [ Species.ACCELGOR, Species.DREEPY ] + [TrainerPoolTier.COMMON]: [Species.PICHU, Species.STARLY, Species.TAILLOW, Species.BOLTUND], + [TrainerPoolTier.UNCOMMON]: [Species.DODUO, Species.ELECTRIKE, Species.BLITZLE, Species.WATTREL], + [TrainerPoolTier.RARE]: [Species.YANMA, Species.NINJASK, Species.WHIRLIPEDE, Species.EMOLGA], + [TrainerPoolTier.SUPER_RARE]: [Species.ACCELGOR, Species.DREEPY], }), - [TrainerType.DANCER]: new TrainerConfig(++t).setMoneyMultiplier(1.55).setEncounterBgm(TrainerType.CYCLIST) - .setPartyTemplates(trainerPartyTemplates.TWO_WEAK, trainerPartyTemplates.ONE_AVG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_WEAK_SAME_TWO_WEAK_SAME) + [TrainerType.DANCER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.55) + .setEncounterBgm(TrainerType.CYCLIST) + .setPartyTemplates( + trainerPartyTemplates.TWO_WEAK, + trainerPartyTemplates.ONE_AVG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_WEAK_SAME_TWO_WEAK_SAME, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.RALTS, Species.SPOINK, Species.LOTAD, Species.BUDEW ], - [TrainerPoolTier.UNCOMMON]: [ Species.SPINDA, Species.SWABLU, Species.MARACTUS, ], - [TrainerPoolTier.RARE]: [ Species.BELLOSSOM, Species.HITMONTOP, Species.MIME_JR, Species.ORICORIO ], - [TrainerPoolTier.SUPER_RARE]: [ Species.POPPLIO ] + [TrainerPoolTier.COMMON]: [Species.RALTS, Species.SPOINK, Species.LOTAD, Species.BUDEW], + [TrainerPoolTier.UNCOMMON]: [Species.SPINDA, Species.SWABLU, Species.MARACTUS], + [TrainerPoolTier.RARE]: [Species.BELLOSSOM, Species.HITMONTOP, Species.MIME_JR, Species.ORICORIO], + [TrainerPoolTier.SUPER_RARE]: [Species.POPPLIO], }), [TrainerType.DEPOT_AGENT]: new TrainerConfig(++t).setMoneyMultiplier(1.45).setEncounterBgm(TrainerType.CLERK), - [TrainerType.DOCTOR]: new TrainerConfig(++t).setHasGenders("Nurse", "lass").setHasDouble("Medical Team").setMoneyMultiplier(3).setEncounterBgm(TrainerType.CLERK) + [TrainerType.DOCTOR]: new TrainerConfig(++t) + .setHasGenders("Nurse", "lass") + .setHasDouble("Medical Team") + .setMoneyMultiplier(3) + .setEncounterBgm(TrainerType.CLERK) .setSpeciesFilter(s => !!s.getLevelMoves().find(plm => plm[1] === Moves.HEAL_PULSE)), - [TrainerType.FIREBREATHER]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setEncounterBgm(TrainerType.ROUGHNECK) + [TrainerType.FIREBREATHER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setEncounterBgm(TrainerType.ROUGHNECK) .setSpeciesFilter(s => !!s.getLevelMoves().find(plm => plm[1] === Moves.SMOG) || s.isOfType(PokemonType.FIRE)), - [TrainerType.FISHERMAN]: new TrainerConfig(++t).setMoneyMultiplier(1.25).setEncounterBgm(TrainerType.BACKPACKER).setSpecialtyType(PokemonType.WATER) - .setPartyTemplates(trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, trainerPartyTemplates.ONE_AVG, trainerPartyTemplates.THREE_WEAK_SAME, trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.SIX_WEAKER) + [TrainerType.FISHERMAN]: new TrainerConfig(++t) + .setMoneyMultiplier(1.25) + .setEncounterBgm(TrainerType.BACKPACKER) + .setSpecialtyType(PokemonType.WATER) + .setPartyTemplates( + trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, + trainerPartyTemplates.ONE_AVG, + trainerPartyTemplates.THREE_WEAK_SAME, + trainerPartyTemplates.ONE_STRONG, + trainerPartyTemplates.SIX_WEAKER, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.TENTACOOL, Species.MAGIKARP, Species.GOLDEEN, Species.STARYU, Species.REMORAID, Species.SKRELP, Species.CLAUNCHER, Species.ARROKUDA ], - [TrainerPoolTier.UNCOMMON]: [ Species.POLIWAG, Species.SHELLDER, Species.KRABBY, Species.HORSEA, Species.CARVANHA, Species.BARBOACH, Species.CORPHISH, Species.FINNEON, Species.TYMPOLE, Species.BASCULIN, Species.FRILLISH, Species.INKAY ], - [TrainerPoolTier.RARE]: [ Species.CHINCHOU, Species.CORSOLA, Species.WAILMER, Species.BARBOACH, Species.CLAMPERL, Species.LUVDISC, Species.MANTYKE, Species.ALOMOMOLA, Species.TATSUGIRI, Species.VELUZA ], - [TrainerPoolTier.SUPER_RARE]: [ Species.LAPRAS, Species.FEEBAS, Species.RELICANTH, Species.DONDOZO ] + [TrainerPoolTier.COMMON]: [ + Species.TENTACOOL, + Species.MAGIKARP, + Species.GOLDEEN, + Species.STARYU, + Species.REMORAID, + Species.SKRELP, + Species.CLAUNCHER, + Species.ARROKUDA, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.POLIWAG, + Species.SHELLDER, + Species.KRABBY, + Species.HORSEA, + Species.CARVANHA, + Species.BARBOACH, + Species.CORPHISH, + Species.FINNEON, + Species.TYMPOLE, + Species.BASCULIN, + Species.FRILLISH, + Species.INKAY, + ], + [TrainerPoolTier.RARE]: [ + Species.CHINCHOU, + Species.CORSOLA, + Species.WAILMER, + Species.BARBOACH, + Species.CLAMPERL, + Species.LUVDISC, + Species.MANTYKE, + Species.ALOMOMOLA, + Species.TATSUGIRI, + Species.VELUZA, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.LAPRAS, Species.FEEBAS, Species.RELICANTH, Species.DONDOZO], }), - [TrainerType.GUITARIST]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.ROUGHNECK).setSpecialtyType(PokemonType.ELECTRIC).setSpeciesFilter(s => s.isOfType(PokemonType.ELECTRIC)), - [TrainerType.HARLEQUIN]: new TrainerConfig(++t).setEncounterBgm(TrainerType.PSYCHIC).setSpeciesFilter(s => tmSpecies[Moves.TRICK_ROOM].indexOf(s.speciesId) > -1), - [TrainerType.HIKER]: new TrainerConfig(++t).setEncounterBgm(TrainerType.BACKPACKER) - .setPartyTemplates(trainerPartyTemplates.TWO_AVG_SAME_ONE_AVG, trainerPartyTemplates.TWO_AVG_SAME_ONE_STRONG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.FOUR_WEAK, trainerPartyTemplates.ONE_STRONG) + [TrainerType.GUITARIST]: new TrainerConfig(++t) + .setMoneyMultiplier(1.2) + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpecialtyType(PokemonType.ELECTRIC) + .setSpeciesFilter(s => s.isOfType(PokemonType.ELECTRIC)), + [TrainerType.HARLEQUIN]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.PSYCHIC) + .setSpeciesFilter(s => tmSpecies[Moves.TRICK_ROOM].indexOf(s.speciesId) > -1), + [TrainerType.HIKER]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.BACKPACKER) + .setPartyTemplates( + trainerPartyTemplates.TWO_AVG_SAME_ONE_AVG, + trainerPartyTemplates.TWO_AVG_SAME_ONE_STRONG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.FOUR_WEAK, + trainerPartyTemplates.ONE_STRONG, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.SANDSHREW, Species.DIGLETT, Species.GEODUDE, Species.MACHOP, Species.ARON, Species.ROGGENROLA, Species.DRILBUR, Species.NACLI ], - [TrainerPoolTier.UNCOMMON]: [ Species.ZUBAT, Species.RHYHORN, Species.ONIX, Species.CUBONE, Species.WOOBAT, Species.SWINUB, Species.NOSEPASS, Species.HIPPOPOTAS, Species.DWEBBLE, Species.KLAWF, Species.TOEDSCOOL ], - [TrainerPoolTier.RARE]: [ Species.TORKOAL, Species.TRAPINCH, Species.BARBOACH, Species.GOLETT, Species.ALOLA_DIGLETT, Species.ALOLA_GEODUDE, Species.GALAR_STUNFISK, Species.PALDEA_WOOPER ], - [TrainerPoolTier.SUPER_RARE]: [ Species.MAGBY, Species.LARVITAR ] + [TrainerPoolTier.COMMON]: [ + Species.SANDSHREW, + Species.DIGLETT, + Species.GEODUDE, + Species.MACHOP, + Species.ARON, + Species.ROGGENROLA, + Species.DRILBUR, + Species.NACLI, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.ZUBAT, + Species.RHYHORN, + Species.ONIX, + Species.CUBONE, + Species.WOOBAT, + Species.SWINUB, + Species.NOSEPASS, + Species.HIPPOPOTAS, + Species.DWEBBLE, + Species.KLAWF, + Species.TOEDSCOOL, + ], + [TrainerPoolTier.RARE]: [ + Species.TORKOAL, + Species.TRAPINCH, + Species.BARBOACH, + Species.GOLETT, + Species.ALOLA_DIGLETT, + Species.ALOLA_GEODUDE, + Species.GALAR_STUNFISK, + Species.PALDEA_WOOPER, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.MAGBY, Species.LARVITAR], }), - [TrainerType.HOOLIGANS]: new TrainerConfig(++t).setDoubleOnly().setEncounterBgm(TrainerType.ROUGHNECK).setSpeciesFilter(s => s.isOfType(PokemonType.POISON) || s.isOfType(PokemonType.DARK)), + [TrainerType.HOOLIGANS]: new TrainerConfig(++t) + .setDoubleOnly() + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpeciesFilter(s => s.isOfType(PokemonType.POISON) || s.isOfType(PokemonType.DARK)), [TrainerType.HOOPSTER]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.CYCLIST), [TrainerType.INFIELDER]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.CYCLIST), [TrainerType.JANITOR]: new TrainerConfig(++t).setMoneyMultiplier(1.1).setEncounterBgm(TrainerType.CLERK), [TrainerType.LINEBACKER]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.CYCLIST), [TrainerType.MAID]: new TrainerConfig(++t).setMoneyMultiplier(1.6).setEncounterBgm(TrainerType.RICH), - [TrainerType.MUSICIAN]: new TrainerConfig(++t).setEncounterBgm(TrainerType.ROUGHNECK).setSpeciesFilter(s => !!s.getLevelMoves().find(plm => plm[1] === Moves.SING)), - [TrainerType.HEX_MANIAC]: new TrainerConfig(++t).setMoneyMultiplier(1.5).setEncounterBgm(TrainerType.PSYCHIC) - .setPartyTemplates(trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.ONE_AVG_ONE_STRONG, trainerPartyTemplates.TWO_AVG_SAME_ONE_AVG, trainerPartyTemplates.THREE_AVG, trainerPartyTemplates.TWO_STRONG) + [TrainerType.MUSICIAN]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpeciesFilter(s => !!s.getLevelMoves().find(plm => plm[1] === Moves.SING)), + [TrainerType.HEX_MANIAC]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .setEncounterBgm(TrainerType.PSYCHIC) + .setPartyTemplates( + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.ONE_AVG_ONE_STRONG, + trainerPartyTemplates.TWO_AVG_SAME_ONE_AVG, + trainerPartyTemplates.THREE_AVG, + trainerPartyTemplates.TWO_STRONG, + ) .setSpeciesFilter(s => s.isOfType(PokemonType.GHOST)), [TrainerType.NURSERY_AIDE]: new TrainerConfig(++t).setMoneyMultiplier(1.3).setEncounterBgm("lass"), - [TrainerType.OFFICER]: new TrainerConfig(++t).setMoneyMultiplier(1.55).setEncounterBgm(TrainerType.CLERK) - .setPartyTemplates(trainerPartyTemplates.ONE_AVG, trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG) + [TrainerType.OFFICER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.55) + .setEncounterBgm(TrainerType.CLERK) + .setPartyTemplates( + trainerPartyTemplates.ONE_AVG, + trainerPartyTemplates.ONE_STRONG, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.VULPIX, Species.GROWLITHE, Species.SNUBBULL, Species.POOCHYENA, Species.ELECTRIKE, Species.LILLIPUP, Species.YAMPER, Species.FIDOUGH ], - [TrainerPoolTier.UNCOMMON]: [ Species.HOUNDOUR, Species.ROCKRUFF, Species.MASCHIFF ], - [TrainerPoolTier.RARE]: [ Species.JOLTEON, Species.RIOLU ], + [TrainerPoolTier.COMMON]: [ + Species.VULPIX, + Species.GROWLITHE, + Species.SNUBBULL, + Species.POOCHYENA, + Species.ELECTRIKE, + Species.LILLIPUP, + Species.YAMPER, + Species.FIDOUGH, + ], + [TrainerPoolTier.UNCOMMON]: [Species.HOUNDOUR, Species.ROCKRUFF, Species.MASCHIFF], + [TrainerPoolTier.RARE]: [Species.JOLTEON, Species.RIOLU], [TrainerPoolTier.SUPER_RARE]: [], - [TrainerPoolTier.ULTRA_RARE]: [ Species.ENTEI, Species.SUICUNE, Species.RAIKOU ] + [TrainerPoolTier.ULTRA_RARE]: [Species.ENTEI, Species.SUICUNE, Species.RAIKOU], }), - [TrainerType.PARASOL_LADY]: new TrainerConfig(++t).setMoneyMultiplier(1.55).setEncounterBgm(TrainerType.PARASOL_LADY).setSpeciesFilter(s => s.isOfType(PokemonType.WATER)), - [TrainerType.PILOT]: new TrainerConfig(++t).setEncounterBgm(TrainerType.CLERK).setSpeciesFilter(s => tmSpecies[Moves.FLY].indexOf(s.speciesId) > -1), - [TrainerType.POKEFAN]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setName("PokéFan").setHasGenders("PokéFan Female").setHasDouble("PokéFan Family").setEncounterBgm(TrainerType.POKEFAN) - .setPartyTemplates(trainerPartyTemplates.SIX_WEAKER, trainerPartyTemplates.FOUR_WEAK, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.ONE_STRONG, trainerPartyTemplates.FOUR_WEAK_SAME, trainerPartyTemplates.FIVE_WEAK, trainerPartyTemplates.SIX_WEAKER_SAME), - [TrainerType.PRESCHOOLER]: new TrainerConfig(++t).setMoneyMultiplier(0.2).setEncounterBgm(TrainerType.YOUNGSTER).setHasGenders("Preschooler Female", "lass").setHasDouble("Preschoolers") - .setPartyTemplates(trainerPartyTemplates.THREE_WEAK, trainerPartyTemplates.FOUR_WEAKER, trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, trainerPartyTemplates.FIVE_WEAKER) + [TrainerType.PARASOL_LADY]: new TrainerConfig(++t) + .setMoneyMultiplier(1.55) + .setEncounterBgm(TrainerType.PARASOL_LADY) + .setSpeciesFilter(s => s.isOfType(PokemonType.WATER)), + [TrainerType.PILOT]: new TrainerConfig(++t) + .setEncounterBgm(TrainerType.CLERK) + .setSpeciesFilter(s => tmSpecies[Moves.FLY].indexOf(s.speciesId) > -1), + [TrainerType.POKEFAN]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setName("PokéFan") + .setHasGenders("PokéFan Female") + .setHasDouble("PokéFan Family") + .setEncounterBgm(TrainerType.POKEFAN) + .setPartyTemplates( + trainerPartyTemplates.SIX_WEAKER, + trainerPartyTemplates.FOUR_WEAK, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.ONE_STRONG, + trainerPartyTemplates.FOUR_WEAK_SAME, + trainerPartyTemplates.FIVE_WEAK, + trainerPartyTemplates.SIX_WEAKER_SAME, + ), + [TrainerType.PRESCHOOLER]: new TrainerConfig(++t) + .setMoneyMultiplier(0.2) + .setEncounterBgm(TrainerType.YOUNGSTER) + .setHasGenders("Preschooler Female", "lass") + .setHasDouble("Preschoolers") + .setPartyTemplates( + trainerPartyTemplates.THREE_WEAK, + trainerPartyTemplates.FOUR_WEAKER, + trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, + trainerPartyTemplates.FIVE_WEAKER, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.CATERPIE, Species.PICHU, Species.SANDSHREW, Species.LEDYBA, Species.BUDEW, Species.BURMY, Species.WOOLOO, Species.PAWMI, Species.SMOLIV ], - [TrainerPoolTier.UNCOMMON]: [ Species.EEVEE, Species.CLEFFA, Species.IGGLYBUFF, Species.SWINUB, Species.WOOPER, Species.DRIFLOON, Species.DEDENNE, Species.STUFFUL ], - [TrainerPoolTier.RARE]: [ Species.RALTS, Species.RIOLU, Species.JOLTIK, Species.TANDEMAUS ], - [TrainerPoolTier.SUPER_RARE]: [ Species.DARUMAKA, Species.TINKATINK ], + [TrainerPoolTier.COMMON]: [ + Species.CATERPIE, + Species.PICHU, + Species.SANDSHREW, + Species.LEDYBA, + Species.BUDEW, + Species.BURMY, + Species.WOOLOO, + Species.PAWMI, + Species.SMOLIV, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.EEVEE, + Species.CLEFFA, + Species.IGGLYBUFF, + Species.SWINUB, + Species.WOOPER, + Species.DRIFLOON, + Species.DEDENNE, + Species.STUFFUL, + ], + [TrainerPoolTier.RARE]: [Species.RALTS, Species.RIOLU, Species.JOLTIK, Species.TANDEMAUS], + [TrainerPoolTier.SUPER_RARE]: [Species.DARUMAKA, Species.TINKATINK], }), - [TrainerType.PSYCHIC]: new TrainerConfig(++t).setHasGenders("Psychic Female").setHasDouble("Psychics").setMoneyMultiplier(1.4).setEncounterBgm(TrainerType.PSYCHIC) - .setPartyTemplates(trainerPartyTemplates.TWO_WEAK, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, trainerPartyTemplates.TWO_WEAK_SAME_TWO_WEAK_SAME, trainerPartyTemplates.ONE_STRONGER) + [TrainerType.PSYCHIC]: new TrainerConfig(++t) + .setHasGenders("Psychic Female") + .setHasDouble("Psychics") + .setMoneyMultiplier(1.4) + .setEncounterBgm(TrainerType.PSYCHIC) + .setPartyTemplates( + trainerPartyTemplates.TWO_WEAK, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_WEAK_SAME_ONE_AVG, + trainerPartyTemplates.TWO_WEAK_SAME_TWO_WEAK_SAME, + trainerPartyTemplates.ONE_STRONGER, + ) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.ABRA, Species.DROWZEE, Species.RALTS, Species.SPOINK, Species.GOTHITA, Species.SOLOSIS, Species.BLIPBUG, Species.ESPURR, Species.HATENNA ], - [TrainerPoolTier.UNCOMMON]: [ Species.MIME_JR, Species.EXEGGCUTE, Species.MEDITITE, Species.NATU, Species.EXEGGCUTE, Species.WOOBAT, Species.INKAY, Species.ORANGURU ], - [TrainerPoolTier.RARE]: [ Species.ELGYEM, Species.SIGILYPH, Species.BALTOY, Species.GIRAFARIG, Species.MEOWSTIC ], - [TrainerPoolTier.SUPER_RARE]: [ Species.BELDUM, Species.ESPEON, Species.STANTLER ], + [TrainerPoolTier.COMMON]: [ + Species.ABRA, + Species.DROWZEE, + Species.RALTS, + Species.SPOINK, + Species.GOTHITA, + Species.SOLOSIS, + Species.BLIPBUG, + Species.ESPURR, + Species.HATENNA, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.MIME_JR, + Species.EXEGGCUTE, + Species.MEDITITE, + Species.NATU, + Species.EXEGGCUTE, + Species.WOOBAT, + Species.INKAY, + Species.ORANGURU, + ], + [TrainerPoolTier.RARE]: [Species.ELGYEM, Species.SIGILYPH, Species.BALTOY, Species.GIRAFARIG, Species.MEOWSTIC], + [TrainerPoolTier.SUPER_RARE]: [Species.BELDUM, Species.ESPEON, Species.STANTLER], }), - [TrainerType.RANGER]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setName("Pokémon Ranger").setEncounterBgm(TrainerType.BACKPACKER).setHasGenders("Pokémon Ranger Female").setHasDouble("Pokémon Rangers") + [TrainerType.RANGER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setName("Pokémon Ranger") + .setEncounterBgm(TrainerType.BACKPACKER) + .setHasGenders("Pokémon Ranger Female") + .setHasDouble("Pokémon Rangers") .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.PICHU, Species.GROWLITHE, Species.PONYTA, Species.ZIGZAGOON, Species.SEEDOT, Species.BIDOOF, Species.RIOLU, Species.SEWADDLE, Species.SKIDDO, Species.SALANDIT, Species.YAMPER ], - [TrainerPoolTier.UNCOMMON]: [ Species.AZURILL, Species.TAUROS, Species.MAREEP, Species.FARFETCHD, Species.TEDDIURSA, Species.SHROOMISH, Species.ELECTRIKE, Species.BUDEW, Species.BUIZEL, Species.MUDBRAY, Species.STUFFUL ], - [TrainerPoolTier.RARE]: [ Species.EEVEE, Species.SCYTHER, Species.KANGASKHAN, Species.RALTS, Species.MUNCHLAX, Species.ZORUA, Species.PALDEA_TAUROS, Species.TINKATINK, Species.CYCLIZAR, Species.FLAMIGO ], - [TrainerPoolTier.SUPER_RARE]: [ Species.LARVESTA ], + [TrainerPoolTier.COMMON]: [ + Species.PICHU, + Species.GROWLITHE, + Species.PONYTA, + Species.ZIGZAGOON, + Species.SEEDOT, + Species.BIDOOF, + Species.RIOLU, + Species.SEWADDLE, + Species.SKIDDO, + Species.SALANDIT, + Species.YAMPER, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.AZURILL, + Species.TAUROS, + Species.MAREEP, + Species.FARFETCHD, + Species.TEDDIURSA, + Species.SHROOMISH, + Species.ELECTRIKE, + Species.BUDEW, + Species.BUIZEL, + Species.MUDBRAY, + Species.STUFFUL, + ], + [TrainerPoolTier.RARE]: [ + Species.EEVEE, + Species.SCYTHER, + Species.KANGASKHAN, + Species.RALTS, + Species.MUNCHLAX, + Species.ZORUA, + Species.PALDEA_TAUROS, + Species.TINKATINK, + Species.CYCLIZAR, + Species.FLAMIGO, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.LARVESTA], }), - [TrainerType.RICH]: new TrainerConfig(++t).setMoneyMultiplier(5).setName("Gentleman").setHasGenders("Madame").setHasDouble("Rich Couple"), - [TrainerType.RICH_KID]: new TrainerConfig(++t).setMoneyMultiplier(3.75).setName("Rich Boy").setHasGenders("Lady").setHasDouble("Rich Kids").setEncounterBgm(TrainerType.RICH), - [TrainerType.ROUGHNECK]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setEncounterBgm(TrainerType.ROUGHNECK).setSpeciesFilter(s => s.isOfType(PokemonType.DARK)), - [TrainerType.SAILOR]: new TrainerConfig(++t).setMoneyMultiplier(1.4).setEncounterBgm(TrainerType.BACKPACKER).setSpeciesFilter(s => s.isOfType(PokemonType.WATER) || s.isOfType(PokemonType.FIGHTING)), - [TrainerType.SCIENTIST]: new TrainerConfig(++t).setHasGenders("Scientist Female").setHasDouble("Scientists").setMoneyMultiplier(1.7).setEncounterBgm(TrainerType.SCIENTIST) + [TrainerType.RICH]: new TrainerConfig(++t) + .setMoneyMultiplier(5) + .setName("Gentleman") + .setHasGenders("Madame") + .setHasDouble("Rich Couple"), + [TrainerType.RICH_KID]: new TrainerConfig(++t) + .setMoneyMultiplier(3.75) + .setName("Rich Boy") + .setHasGenders("Lady") + .setHasDouble("Rich Kids") + .setEncounterBgm(TrainerType.RICH), + [TrainerType.ROUGHNECK]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setEncounterBgm(TrainerType.ROUGHNECK) + .setSpeciesFilter(s => s.isOfType(PokemonType.DARK)), + [TrainerType.SAILOR]: new TrainerConfig(++t) + .setMoneyMultiplier(1.4) + .setEncounterBgm(TrainerType.BACKPACKER) + .setSpeciesFilter(s => s.isOfType(PokemonType.WATER) || s.isOfType(PokemonType.FIGHTING)), + [TrainerType.SCIENTIST]: new TrainerConfig(++t) + .setHasGenders("Scientist Female") + .setHasDouble("Scientists") + .setMoneyMultiplier(1.7) + .setEncounterBgm(TrainerType.SCIENTIST) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.MAGNEMITE, Species.GRIMER, Species.DROWZEE, Species.VOLTORB, Species.KOFFING ], - [TrainerPoolTier.UNCOMMON]: [ Species.BALTOY, Species.BRONZOR, Species.FERROSEED, Species.KLINK, Species.CHARJABUG, Species.BLIPBUG, Species.HELIOPTILE ], - [TrainerPoolTier.RARE]: [ Species.ABRA, Species.DITTO, Species.PORYGON, Species.ELEKID, Species.SOLOSIS, Species.GALAR_WEEZING ], - [TrainerPoolTier.SUPER_RARE]: [ Species.OMANYTE, Species.KABUTO, Species.AERODACTYL, Species.LILEEP, Species.ANORITH, Species.CRANIDOS, Species.SHIELDON, Species.TIRTOUGA, Species.ARCHEN, Species.ARCTOVISH, Species.ARCTOZOLT, Species.DRACOVISH, Species.DRACOZOLT ], - [TrainerPoolTier.ULTRA_RARE]: [ Species.ROTOM, Species.MELTAN ] + [TrainerPoolTier.COMMON]: [Species.MAGNEMITE, Species.GRIMER, Species.DROWZEE, Species.VOLTORB, Species.KOFFING], + [TrainerPoolTier.UNCOMMON]: [ + Species.BALTOY, + Species.BRONZOR, + Species.FERROSEED, + Species.KLINK, + Species.CHARJABUG, + Species.BLIPBUG, + Species.HELIOPTILE, + ], + [TrainerPoolTier.RARE]: [ + Species.ABRA, + Species.DITTO, + Species.PORYGON, + Species.ELEKID, + Species.SOLOSIS, + Species.GALAR_WEEZING, + ], + [TrainerPoolTier.SUPER_RARE]: [ + Species.OMANYTE, + Species.KABUTO, + Species.AERODACTYL, + Species.LILEEP, + Species.ANORITH, + Species.CRANIDOS, + Species.SHIELDON, + Species.TIRTOUGA, + Species.ARCHEN, + Species.ARCTOVISH, + Species.ARCTOZOLT, + Species.DRACOVISH, + Species.DRACOZOLT, + ], + [TrainerPoolTier.ULTRA_RARE]: [Species.ROTOM, Species.MELTAN], }), [TrainerType.SMASHER]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.CYCLIST), - [TrainerType.SNOW_WORKER]: new TrainerConfig(++t).setName("Worker").setHasDouble("Workers").setMoneyMultiplier(1.7).setEncounterBgm(TrainerType.CLERK).setSpeciesFilter(s => s.isOfType(PokemonType.ICE) || s.isOfType(PokemonType.STEEL)), + [TrainerType.SNOW_WORKER]: new TrainerConfig(++t) + .setName("Worker") + .setHasDouble("Workers") + .setMoneyMultiplier(1.7) + .setEncounterBgm(TrainerType.CLERK) + .setSpeciesFilter(s => s.isOfType(PokemonType.ICE) || s.isOfType(PokemonType.STEEL)), [TrainerType.STRIKER]: new TrainerConfig(++t).setMoneyMultiplier(1.2).setEncounterBgm(TrainerType.CYCLIST), - [TrainerType.SCHOOL_KID]: new TrainerConfig(++t).setMoneyMultiplier(0.75).setEncounterBgm(TrainerType.YOUNGSTER).setHasGenders("School Kid Female", "lass").setHasDouble("School Kids") + [TrainerType.SCHOOL_KID]: new TrainerConfig(++t) + .setMoneyMultiplier(0.75) + .setEncounterBgm(TrainerType.YOUNGSTER) + .setHasGenders("School Kid Female", "lass") + .setHasDouble("School Kids") .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.ODDISH, Species.EXEGGCUTE, Species.TEDDIURSA, Species.WURMPLE, Species.RALTS, Species.SHROOMISH, Species.FLETCHLING ], - [TrainerPoolTier.UNCOMMON]: [ Species.VOLTORB, Species.WHISMUR, Species.MEDITITE, Species.MIME_JR, Species.NYMBLE ], - [TrainerPoolTier.RARE]: [ Species.TANGELA, Species.EEVEE, Species.YANMA ], - [TrainerPoolTier.SUPER_RARE]: [ Species.TADBULB ] + [TrainerPoolTier.COMMON]: [ + Species.ODDISH, + Species.EXEGGCUTE, + Species.TEDDIURSA, + Species.WURMPLE, + Species.RALTS, + Species.SHROOMISH, + Species.FLETCHLING, + ], + [TrainerPoolTier.UNCOMMON]: [Species.VOLTORB, Species.WHISMUR, Species.MEDITITE, Species.MIME_JR, Species.NYMBLE], + [TrainerPoolTier.RARE]: [Species.TANGELA, Species.EEVEE, Species.YANMA], + [TrainerPoolTier.SUPER_RARE]: [Species.TADBULB], }), - [TrainerType.SWIMMER]: new TrainerConfig(++t).setMoneyMultiplier(1.3).setEncounterBgm(TrainerType.PARASOL_LADY).setHasGenders("Swimmer Female").setHasDouble("Swimmers").setSpecialtyType(PokemonType.WATER).setSpeciesFilter(s => s.isOfType(PokemonType.WATER)), - [TrainerType.TWINS]: new TrainerConfig(++t).setDoubleOnly().setMoneyMultiplier(0.65).setUseSameSeedForAllMembers() - .setPartyTemplateFunc(() => getWavePartyTemplate(trainerPartyTemplates.TWO_WEAK, trainerPartyTemplates.TWO_AVG, trainerPartyTemplates.TWO_STRONG)) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.PLUSLE, Species.VOLBEAT, Species.PACHIRISU, Species.SILCOON, Species.METAPOD, Species.IGGLYBUFF, Species.PETILIL, Species.EEVEE ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.MINUN, Species.ILLUMISE, Species.EMOLGA, Species.CASCOON, Species.KAKUNA, Species.CLEFFA, Species.COTTONEE, Species.EEVEE ], TrainerSlot.TRAINER_PARTNER)) + [TrainerType.SWIMMER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.3) + .setEncounterBgm(TrainerType.PARASOL_LADY) + .setHasGenders("Swimmer Female") + .setHasDouble("Swimmers") + .setSpecialtyType(PokemonType.WATER) + .setSpeciesFilter(s => s.isOfType(PokemonType.WATER)), + [TrainerType.TWINS]: new TrainerConfig(++t) + .setDoubleOnly() + .setMoneyMultiplier(0.65) + .setUseSameSeedForAllMembers() + .setPartyTemplateFunc(() => + getWavePartyTemplate( + trainerPartyTemplates.TWO_WEAK, + trainerPartyTemplates.TWO_AVG, + trainerPartyTemplates.TWO_STRONG, + ), + ) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([ + Species.PLUSLE, + Species.VOLBEAT, + Species.PACHIRISU, + Species.SILCOON, + Species.METAPOD, + Species.IGGLYBUFF, + Species.PETILIL, + Species.EEVEE, + ]), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.MINUN, + Species.ILLUMISE, + Species.EMOLGA, + Species.CASCOON, + Species.KAKUNA, + Species.CLEFFA, + Species.COTTONEE, + Species.EEVEE, + ], + TrainerSlot.TRAINER_PARTNER, + ), + ) .setEncounterBgm(TrainerType.TWINS), - [TrainerType.VETERAN]: new TrainerConfig(++t).setHasGenders("Veteran Female").setHasDouble("Veteran Duo").setMoneyMultiplier(2.5).setEncounterBgm(TrainerType.ACE_TRAINER).setSpeciesFilter(s => s.isOfType(PokemonType.DRAGON)), - [TrainerType.WAITER]: new TrainerConfig(++t).setHasGenders("Waitress").setHasDouble("Restaurant Staff").setMoneyMultiplier(1.5).setEncounterBgm(TrainerType.CLERK) + [TrainerType.VETERAN]: new TrainerConfig(++t) + .setHasGenders("Veteran Female") + .setHasDouble("Veteran Duo") + .setMoneyMultiplier(2.5) + .setEncounterBgm(TrainerType.ACE_TRAINER) + .setSpeciesFilter(s => s.isOfType(PokemonType.DRAGON)), + [TrainerType.WAITER]: new TrainerConfig(++t) + .setHasGenders("Waitress") + .setHasDouble("Restaurant Staff") + .setMoneyMultiplier(1.5) + .setEncounterBgm(TrainerType.CLERK) .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.CLEFFA, Species.CHATOT, Species.PANSAGE, Species.PANSEAR, Species.PANPOUR, Species.MINCCINO ], - [TrainerPoolTier.UNCOMMON]: [ Species.TROPIUS, Species.PETILIL, Species.BOUNSWEET, Species.INDEEDEE ], - [TrainerPoolTier.RARE]: [ Species.APPLIN, Species.SINISTEA, Species.POLTCHAGEIST ] + [TrainerPoolTier.COMMON]: [ + Species.CLEFFA, + Species.CHATOT, + Species.PANSAGE, + Species.PANSEAR, + Species.PANPOUR, + Species.MINCCINO, + ], + [TrainerPoolTier.UNCOMMON]: [Species.TROPIUS, Species.PETILIL, Species.BOUNSWEET, Species.INDEEDEE], + [TrainerPoolTier.RARE]: [Species.APPLIN, Species.SINISTEA, Species.POLTCHAGEIST], }), - [TrainerType.WORKER]: new TrainerConfig(++t).setHasGenders("Worker Female").setHasDouble("Workers").setEncounterBgm(TrainerType.CLERK).setMoneyMultiplier(1.7).setSpeciesFilter(s => s.isOfType(PokemonType.ROCK) || s.isOfType(PokemonType.STEEL)), - [TrainerType.YOUNGSTER]: new TrainerConfig(++t).setMoneyMultiplier(0.5).setEncounterBgm(TrainerType.YOUNGSTER).setHasGenders("Lass", "lass").setHasDouble("Beginners").setPartyTemplates(trainerPartyTemplates.TWO_WEAKER) - .setSpeciesPools( - [ Species.CATERPIE, Species.WEEDLE, Species.RATTATA, Species.SENTRET, Species.POOCHYENA, Species.ZIGZAGOON, Species.WURMPLE, Species.BIDOOF, Species.PATRAT, Species.LILLIPUP ] + [TrainerType.WORKER]: new TrainerConfig(++t) + .setHasGenders("Worker Female") + .setHasDouble("Workers") + .setEncounterBgm(TrainerType.CLERK) + .setMoneyMultiplier(1.7) + .setSpeciesFilter(s => s.isOfType(PokemonType.ROCK) || s.isOfType(PokemonType.STEEL)), + [TrainerType.YOUNGSTER]: new TrainerConfig(++t) + .setMoneyMultiplier(0.5) + .setEncounterBgm(TrainerType.YOUNGSTER) + .setHasGenders("Lass", "lass") + .setHasDouble("Beginners") + .setPartyTemplates(trainerPartyTemplates.TWO_WEAKER) + .setSpeciesPools([ + Species.CATERPIE, + Species.WEEDLE, + Species.RATTATA, + Species.SENTRET, + Species.POOCHYENA, + Species.ZIGZAGOON, + Species.WURMPLE, + Species.BIDOOF, + Species.PATRAT, + Species.LILLIPUP, + ]), + [TrainerType.ROCKET_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Rocket Grunt Female") + .setHasDouble("Rocket Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_rocket_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.WEEDLE, + Species.RATTATA, + Species.EKANS, + Species.SANDSHREW, + Species.ZUBAT, + Species.ODDISH, + Species.GEODUDE, + Species.SLOWPOKE, + Species.GRIMER, + Species.KOFFING, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.MANKEY, + Species.GROWLITHE, + Species.MAGNEMITE, + Species.GASTLY, + Species.VOLTORB, + Species.EXEGGCUTE, + Species.CUBONE, + Species.LICKITUNG, + Species.SCYTHER, + Species.TAUROS, + Species.GYARADOS, + Species.MURKROW, + Species.ELEKID, + Species.MAGBY, + ], + [TrainerPoolTier.RARE]: [ + Species.PORYGON, + Species.OMANYTE, + Species.KABUTO, + Species.ALOLA_RATTATA, + Species.ALOLA_SANDSHREW, + Species.ALOLA_MEOWTH, + Species.ALOLA_GEODUDE, + Species.ALOLA_GRIMER, + Species.PALDEA_TAUROS, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.DRATINI, Species.LARVITAR], + }), + [TrainerType.ARCHER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("rocket_admin", "rocket", [Species.HOUNDOOM]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_rocket_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.ARIANA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("rocket_admin_female", "rocket", [Species.ARBOK]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_rocket_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.PROTON]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("rocket_admin", "rocket", [Species.CROBAT]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_rocket_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.PETREL]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("rocket_admin", "rocket", [Species.WEEZING]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_rocket_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.MAGMA_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Magma Grunt Female") + .setHasDouble("Magma Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.DIGLETT, + Species.GROWLITHE, + Species.SLUGMA, + Species.MAGBY, + Species.POOCHYENA, + Species.ZIGZAGOON, + Species.NUMEL, + Species.TORKOAL, + Species.BALTOY, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.RHYHORN, + Species.GLIGAR, + Species.PHANPY, + Species.SOLROCK, + Species.HIPPOPOTAS, + Species.HEATMOR, + Species.ROLYCOLY, + Species.SILICOBRA, + ], + [TrainerPoolTier.RARE]: [ + Species.ARON, + Species.TRAPINCH, + Species.LILEEP, + Species.ANORITH, + Species.TURTONATOR, + Species.TOEDSCOOL, + Species.HISUI_GROWLITHE, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.CHARCADET, Species.CAPSAKID], + }), + [TrainerType.TABITHA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("magma_admin", "magma", [Species.CAMERUPT]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.COURTNEY]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("magma_admin_female", "magma", [Species.CAMERUPT]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.AQUA_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Aqua Grunt Female") + .setHasDouble("Aqua Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.QWILFISH, + Species.REMORAID, + Species.ZIGZAGOON, + Species.LOTAD, + Species.CARVANHA, + Species.WAILMER, + Species.BARBOACH, + Species.CORPHISH, + Species.SPHEAL, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.TENTACOOL, + Species.HORSEA, + Species.CHINCHOU, + Species.WOOPER, + Species.WINGULL, + Species.AZURILL, + Species.CLAMPERL, + Species.CLOBBOPUS, + ], + [TrainerPoolTier.RARE]: [ + Species.MANTYKE, + Species.SKRELP, + Species.DHELMISE, + Species.ARROKUDA, + Species.HISUI_QWILFISH, + Species.PALDEA_WOOPER, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.BASCULEGION, Species.DONDOZO], + }), + [TrainerType.MATT]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("aqua_admin", "aqua", [Species.SHARPEDO]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.SHELLY]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("aqua_admin_female", "aqua", [Species.SHARPEDO]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aqua_magma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.GALACTIC_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Galactic Grunt Female") + .setHasDouble("Galactic Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_galactic_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.WURMPLE, + Species.SHINX, + Species.BURMY, + Species.DRIFLOON, + Species.GLAMEOW, + Species.STUNKY, + Species.BRONZOR, + Species.CROAGUNK, + Species.CARNIVINE, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.ZUBAT, + Species.LICKITUNG, + Species.RHYHORN, + Species.TANGELA, + Species.YANMA, + Species.GLIGAR, + Species.SWINUB, + Species.SKORUPI, + ], + [TrainerPoolTier.RARE]: [ + Species.SNEASEL, + Species.ELEKID, + Species.MAGBY, + Species.DUSKULL, + Species.HISUI_GROWLITHE, + Species.HISUI_QWILFISH, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.SPIRITOMB, Species.ROTOM, Species.HISUI_SNEASEL], + }), + [TrainerType.JUPITER]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("galactic_commander_female", "galactic", [Species.SKUNTANK]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_galactic_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.MARS]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("galactic_commander_female", "galactic", [Species.PURUGLY]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_galactic_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.SATURN]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("galactic_commander", "galactic", [Species.TOXICROAK]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_galactic_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.PLASMA_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Plasma Grunt Female") + .setHasDouble("Plasma Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_plasma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.PATRAT, + Species.LILLIPUP, + Species.PURRLOIN, + Species.WOOBAT, + Species.TYMPOLE, + Species.SANDILE, + Species.SCRAGGY, + Species.TRUBBISH, + Species.VANILLITE, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.TIMBURR, + Species.VENIPEDE, + Species.DARUMAKA, + Species.FOONGUS, + Species.FRILLISH, + Species.JOLTIK, + Species.KLINK, + Species.CUBCHOO, + Species.GOLETT, + ], + [TrainerPoolTier.RARE]: [ + Species.DRILBUR, + Species.ZORUA, + Species.MIENFOO, + Species.PAWNIARD, + Species.BOUFFALANT, + Species.RUFFLET, + Species.VULLABY, + Species.DURANT, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.AXEW, Species.DRUDDIGON, Species.DEINO, Species.HISUI_ZORUA], + }), + [TrainerType.ZINZOLIN]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("plasma_sage", "plasma", [Species.CRYOGONAL]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_plasma_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.COLRESS]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("plasma_boss", "plasma_2", [Species.KLINKLANG]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_colress") + .setMixedBattleBgm("battle_colress") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.FLARE_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Flare Grunt Female") + .setHasDouble("Flare Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_flare_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.PONYTA, + Species.HOUNDOUR, + Species.SKORUPI, + Species.CROAGUNK, + Species.SCRAGGY, + Species.FLETCHLING, + Species.SCATTERBUG, + Species.LITLEO, + Species.ESPURR, + Species.INKAY, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.POOCHYENA, + Species.ELECTRIKE, + Species.PURRLOIN, + Species.FOONGUS, + Species.PANCHAM, + Species.BINACLE, + Species.SKRELP, + Species.CLAUNCHER, + Species.HELIOPTILE, + Species.PHANTUMP, + Species.PUMPKABOO, + ], + [TrainerPoolTier.RARE]: [Species.SNEASEL, Species.LITWICK, Species.PAWNIARD, Species.SLIGGOO], + [TrainerPoolTier.SUPER_RARE]: [Species.NOIBAT, Species.HISUI_SLIGGOO, Species.HISUI_AVALUGG], + }), + [TrainerType.BRYONY]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("flare_admin_female", "flare", [Species.LIEPARD]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_flare_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.XEROSIC]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("flare_admin", "flare", [Species.MALAMAR]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_flare_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.AETHER_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Aether Grunt Female") + .setHasDouble("Aether Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aether_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.CORSOLA, + Species.LILLIPUP, + Species.PIKIPEK, + Species.YUNGOOS, + Species.ROCKRUFF, + Species.MORELULL, + Species.BOUNSWEET, + Species.COMFEY, + Species.KOMALA, + Species.TOGEDEMARU, + Species.ALOLA_RAICHU, + Species.ALOLA_DIGLETT, + Species.ALOLA_GEODUDE, + Species.ALOLA_EXEGGUTOR, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.POLIWAG, + Species.CRABRAWLER, + Species.ORICORIO, + Species.CUTIEFLY, + Species.WISHIWASHI, + Species.MUDBRAY, + Species.STUFFUL, + Species.ORANGURU, + Species.PASSIMIAN, + Species.PYUKUMUKU, + Species.MINIOR, + Species.BRUXISH, + Species.ALOLA_SANDSHREW, + Species.ALOLA_VULPIX, + Species.ALOLA_MAROWAK, + ], + [TrainerPoolTier.RARE]: [ + Species.MAGNEMITE, + Species.TURTONATOR, + Species.MIMIKYU, + Species.DRAMPA, + Species.GALAR_CORSOLA, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.PORYGON, Species.JANGMO_O], + }), + [TrainerType.FABA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("aether_admin", "aether", [Species.HYPNO]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_aether_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.SKULL_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Skull Grunt Female") + .setHasDouble("Skull Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_skull_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.EKANS, + Species.DROWZEE, + Species.KOFFING, + Species.SPINARAK, + Species.SCRAGGY, + Species.TRUBBISH, + Species.MAREANIE, + Species.SALANDIT, + Species.ALOLA_RATTATA, + Species.ALOLA_MEOWTH, + Species.ALOLA_GRIMER, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.ZUBAT, + Species.GASTLY, + Species.HOUNDOUR, + Species.SABLEYE, + Species.VENIPEDE, + Species.SANDILE, + Species.VULLABY, + Species.PANCHAM, + Species.FOMANTIS, + Species.ALOLA_MAROWAK, + ], + [TrainerPoolTier.RARE]: [ + Species.PAWNIARD, + Species.WISHIWASHI, + Species.SANDYGAST, + Species.MIMIKYU, + Species.DHELMISE, + Species.NYMBLE, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.GRUBBIN, Species.DEWPIDER], + }), + [TrainerType.PLUMERIA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("skull_admin", "skull", [Species.SALAZZLE]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_skull_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.MACRO_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Macro Grunt Female") + .setHasDouble("Macro Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_macro_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.STEELIX, + Species.MAWILE, + Species.FERROSEED, + Species.KLINK, + Species.SKWOVET, + Species.ROOKIDEE, + Species.CRAMORANT, + Species.CUFANT, + Species.GALAR_MEOWTH, + Species.GALAR_ZIGZAGOON, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.MAGNEMITE, + Species.RIOLU, + Species.DRILBUR, + Species.APPLIN, + Species.ARROKUDA, + Species.SINISTEA, + Species.HATENNA, + Species.GALAR_PONYTA, + Species.GALAR_YAMASK, + ], + [TrainerPoolTier.RARE]: [ + Species.SCIZOR, + Species.BELDUM, + Species.HONEDGE, + Species.FALINKS, + Species.GALAR_FARFETCHD, + Species.GALAR_MR_MIME, + Species.GALAR_DARUMAKA, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.DURALUDON, Species.DREEPY], + }), + [TrainerType.OLEANA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("macro_admin", "macro", [Species.GARBODOR]) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_oleana") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), + [TrainerType.STAR_GRUNT]: new TrainerConfig(++t) + .setHasGenders("Star Grunt Female") + .setHasDouble("Star Grunts") + .setMoneyMultiplier(1.0) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_grunt") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setSpeciesPools({ + [TrainerPoolTier.COMMON]: [ + Species.DUNSPARCE, + Species.HOUNDOUR, + Species.AZURILL, + Species.GULPIN, + Species.FOONGUS, + Species.FLETCHLING, + Species.LITLEO, + Species.FLABEBE, + Species.CRABRAWLER, + Species.NYMBLE, + Species.PAWMI, + Species.FIDOUGH, + Species.SQUAWKABILLY, + Species.MASCHIFF, + Species.SHROODLE, + Species.KLAWF, + Species.WIGLETT, + Species.PALDEA_WOOPER, + ], + [TrainerPoolTier.UNCOMMON]: [ + Species.KOFFING, + Species.EEVEE, + Species.GIRAFARIG, + Species.RALTS, + Species.TORKOAL, + Species.SEVIPER, + Species.SCRAGGY, + Species.ZORUA, + Species.MIMIKYU, + Species.IMPIDIMP, + Species.FALINKS, + Species.CAPSAKID, + Species.TINKATINK, + Species.BOMBIRDIER, + Species.CYCLIZAR, + Species.FLAMIGO, + Species.PALDEA_TAUROS, + ], + [TrainerPoolTier.RARE]: [ + Species.MANKEY, + Species.PAWNIARD, + Species.CHARCADET, + Species.FLITTLE, + Species.VAROOM, + Species.ORTHWORM, + ], + [TrainerPoolTier.SUPER_RARE]: [Species.DONDOZO, Species.GIMMIGHOUL], + }), + [TrainerType.GIACOMO]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("star_admin", "star_1", [Species.KINGAMBIT], PokemonType.DARK) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Segin Starmobile + p.moveset = [ + new PokemonMove(Moves.WICKED_TORQUE), + new PokemonMove(Moves.SPIN_OUT), + new PokemonMove(Moves.SHIFT_GEAR), + new PokemonMove(Moves.HIGH_HORSEPOWER), + ]; + }), + ), + [TrainerType.MELA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("star_admin", "star_2", [Species.ARMAROUGE], PokemonType.FIRE) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = 2; // Schedar Starmobile + p.moveset = [ + new PokemonMove(Moves.BLAZING_TORQUE), + new PokemonMove(Moves.SPIN_OUT), + new PokemonMove(Moves.SHIFT_GEAR), + new PokemonMove(Moves.HIGH_HORSEPOWER), + ]; + }), + ), + [TrainerType.ATTICUS]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("star_admin", "star_3", [Species.REVAVROOM], PokemonType.POISON) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = 3; // Navi Starmobile + p.moveset = [ + new PokemonMove(Moves.NOXIOUS_TORQUE), + new PokemonMove(Moves.SPIN_OUT), + new PokemonMove(Moves.SHIFT_GEAR), + new PokemonMove(Moves.HIGH_HORSEPOWER), + ]; + }), + ), + [TrainerType.ORTEGA]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("star_admin", "star_4", [Species.DACHSBUN], PokemonType.FAIRY) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = 4; // Ruchbah Starmobile + p.moveset = [ + new PokemonMove(Moves.MAGICAL_TORQUE), + new PokemonMove(Moves.SPIN_OUT), + new PokemonMove(Moves.SHIFT_GEAR), + new PokemonMove(Moves.HIGH_HORSEPOWER), + ]; + }), + ), + [TrainerType.ERI]: new TrainerConfig(++t) + .setMoneyMultiplier(1.5) + .initForEvilTeamAdmin("star_admin", "star_5", [Species.ANNIHILAPE], PokemonType.FIGHTING) + .setEncounterBgm(TrainerType.PLASMA_GRUNT) + .setBattleBgm("battle_plasma_grunt") + .setMixedBattleBgm("battle_star_admin") + .setVictoryBgm("victory_team_plasma") + .setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = 5; // Caph Starmobile + p.moveset = [ + new PokemonMove(Moves.COMBAT_TORQUE), + new PokemonMove(Moves.SPIN_OUT), + new PokemonMove(Moves.SHIFT_GEAR), + new PokemonMove(Moves.HIGH_HORSEPOWER), + ]; + }), ), - [TrainerType.ROCKET_GRUNT]: new TrainerConfig(++t).setHasGenders("Rocket Grunt Female").setHasDouble("Rocket Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_rocket_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.WEEDLE, Species.RATTATA, Species.EKANS, Species.SANDSHREW, Species.ZUBAT, Species.ODDISH, Species.GEODUDE, Species.SLOWPOKE, Species.GRIMER, Species.KOFFING ], - [TrainerPoolTier.UNCOMMON]: [ Species.MANKEY, Species.GROWLITHE, Species.MAGNEMITE, Species.GASTLY, Species.VOLTORB, Species.EXEGGCUTE, Species.CUBONE, Species.LICKITUNG, Species.SCYTHER, Species.TAUROS, Species.GYARADOS, Species.MURKROW, Species.ELEKID, Species.MAGBY ], - [TrainerPoolTier.RARE]: [ Species.PORYGON, Species.OMANYTE, Species.KABUTO, Species.ALOLA_RATTATA, Species.ALOLA_SANDSHREW, Species.ALOLA_MEOWTH, Species.ALOLA_GEODUDE, Species.ALOLA_GRIMER, Species.PALDEA_TAUROS ], - [TrainerPoolTier.SUPER_RARE]: [ Species.DRATINI, Species.LARVITAR ] - }), - [TrainerType.ARCHER]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("rocket_admin", "rocket", [ Species.HOUNDOOM ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_rocket_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.ARIANA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("rocket_admin_female", "rocket", [ Species.ARBOK ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_rocket_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.PROTON]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("rocket_admin", "rocket", [ Species.CROBAT ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_rocket_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.PETREL]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("rocket_admin", "rocket", [ Species.WEEZING ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_rocket_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.MAGMA_GRUNT]: new TrainerConfig(++t).setHasGenders("Magma Grunt Female").setHasDouble("Magma Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.DIGLETT, Species.GROWLITHE, Species.SLUGMA, Species.MAGBY, Species.POOCHYENA, Species.ZIGZAGOON, Species.NUMEL, Species.TORKOAL, Species.BALTOY ], - [TrainerPoolTier.UNCOMMON]: [ Species.RHYHORN, Species.GLIGAR, Species.PHANPY, Species.SOLROCK, Species.HIPPOPOTAS, Species.HEATMOR, Species.ROLYCOLY, Species.SILICOBRA ], - [TrainerPoolTier.RARE]: [ Species.ARON, Species.TRAPINCH, Species.LILEEP, Species.ANORITH, Species.TURTONATOR, Species.TOEDSCOOL, Species.HISUI_GROWLITHE ], - [TrainerPoolTier.SUPER_RARE]: [ Species.CHARCADET, Species.CAPSAKID ] - }), - [TrainerType.TABITHA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("magma_admin", "magma", [ Species.CAMERUPT ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.COURTNEY]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("magma_admin_female", "magma", [ Species.CAMERUPT ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.AQUA_GRUNT]: new TrainerConfig(++t).setHasGenders("Aqua Grunt Female").setHasDouble("Aqua Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.QWILFISH, Species.REMORAID, Species.ZIGZAGOON, Species.LOTAD, Species.CARVANHA, Species.WAILMER, Species.BARBOACH, Species.CORPHISH, Species.SPHEAL ], - [TrainerPoolTier.UNCOMMON]: [ Species.TENTACOOL, Species.HORSEA, Species.CHINCHOU, Species.WOOPER, Species.WINGULL, Species.AZURILL, Species.CLAMPERL, Species.CLOBBOPUS ], - [TrainerPoolTier.RARE]: [ Species.MANTYKE, Species.SKRELP, Species.DHELMISE, Species.ARROKUDA, Species.HISUI_QWILFISH, Species.PALDEA_WOOPER ], - [TrainerPoolTier.SUPER_RARE]: [ Species.BASCULEGION, Species.DONDOZO ] - }), - [TrainerType.MATT]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("aqua_admin", "aqua", [ Species.SHARPEDO ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.SHELLY]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("aqua_admin_female", "aqua", [ Species.SHARPEDO ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aqua_magma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.GALACTIC_GRUNT]: new TrainerConfig(++t).setHasGenders("Galactic Grunt Female").setHasDouble("Galactic Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_galactic_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.WURMPLE, Species.SHINX, Species.BURMY, Species.DRIFLOON, Species.GLAMEOW, Species.STUNKY, Species.BRONZOR, Species.CROAGUNK, Species.CARNIVINE ], - [TrainerPoolTier.UNCOMMON]: [ Species.ZUBAT, Species.LICKITUNG, Species.RHYHORN, Species.TANGELA, Species.YANMA, Species.GLIGAR, Species.SWINUB, Species.SKORUPI ], - [TrainerPoolTier.RARE]: [ Species.SNEASEL, Species.ELEKID, Species.MAGBY, Species.DUSKULL, Species.HISUI_GROWLITHE, Species.HISUI_QWILFISH ], - [TrainerPoolTier.SUPER_RARE]: [ Species.SPIRITOMB, Species.ROTOM, Species.HISUI_SNEASEL ] - }), - [TrainerType.JUPITER]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("galactic_commander_female", "galactic", [ Species.SKUNTANK ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_galactic_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.MARS]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("galactic_commander_female", "galactic", [ Species.PURUGLY ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_galactic_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.SATURN]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("galactic_commander", "galactic", [ Species.TOXICROAK ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_galactic_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.PLASMA_GRUNT]: new TrainerConfig(++t).setHasGenders("Plasma Grunt Female").setHasDouble("Plasma Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_plasma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.PATRAT, Species.LILLIPUP, Species.PURRLOIN, Species.WOOBAT, Species.TYMPOLE, Species.SANDILE, Species.SCRAGGY, Species.TRUBBISH, Species.VANILLITE ], - [TrainerPoolTier.UNCOMMON]: [ Species.TIMBURR, Species.VENIPEDE, Species.DARUMAKA, Species.FOONGUS, Species.FRILLISH, Species.JOLTIK, Species.KLINK, Species.CUBCHOO, Species.GOLETT ], - [TrainerPoolTier.RARE]: [ Species.DRILBUR, Species.ZORUA, Species.MIENFOO, Species.PAWNIARD, Species.BOUFFALANT, Species.RUFFLET, Species.VULLABY, Species.DURANT ], - [TrainerPoolTier.SUPER_RARE]: [ Species.AXEW, Species.DRUDDIGON, Species.DEINO, Species.HISUI_ZORUA ] - }), - [TrainerType.ZINZOLIN]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("plasma_sage", "plasma", [ Species.CRYOGONAL ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_plasma_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.COLRESS]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("plasma_boss", "plasma_2", [ Species.KLINKLANG ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_colress").setMixedBattleBgm("battle_colress").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.FLARE_GRUNT]: new TrainerConfig(++t).setHasGenders("Flare Grunt Female").setHasDouble("Flare Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_flare_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.PONYTA, Species.HOUNDOUR, Species.SKORUPI, Species.CROAGUNK, Species.SCRAGGY, Species.FLETCHLING, Species.SCATTERBUG, Species.LITLEO, Species.ESPURR, Species.INKAY ], - [TrainerPoolTier.UNCOMMON]: [ Species.POOCHYENA, Species.ELECTRIKE, Species.PURRLOIN, Species.FOONGUS, Species.PANCHAM, Species.BINACLE, Species.SKRELP, Species.CLAUNCHER, Species.HELIOPTILE, Species.PHANTUMP, Species.PUMPKABOO ], - [TrainerPoolTier.RARE]: [ Species.SNEASEL, Species.LITWICK, Species.PAWNIARD, Species.SLIGGOO ], - [TrainerPoolTier.SUPER_RARE]: [ Species.NOIBAT, Species.HISUI_SLIGGOO, Species.HISUI_AVALUGG ] - }), - [TrainerType.BRYONY]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("flare_admin_female", "flare", [ Species.LIEPARD ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_flare_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.XEROSIC]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("flare_admin", "flare", [ Species.MALAMAR ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_flare_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.AETHER_GRUNT]: new TrainerConfig(++t).setHasGenders("Aether Grunt Female").setHasDouble("Aether Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aether_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.CORSOLA, Species.LILLIPUP, Species.PIKIPEK, Species.YUNGOOS, Species.ROCKRUFF, Species.MORELULL, Species.BOUNSWEET, Species.COMFEY, Species.KOMALA, Species.TOGEDEMARU, Species.ALOLA_RAICHU, Species.ALOLA_DIGLETT, Species.ALOLA_GEODUDE, Species.ALOLA_EXEGGUTOR ], - [TrainerPoolTier.UNCOMMON]: [ Species.POLIWAG, Species.CRABRAWLER, Species.ORICORIO, Species.CUTIEFLY, Species.WISHIWASHI, Species.MUDBRAY, Species.STUFFUL, Species.ORANGURU, Species.PASSIMIAN, Species.PYUKUMUKU, Species.MINIOR, Species.BRUXISH, Species.ALOLA_SANDSHREW, Species.ALOLA_VULPIX, Species.ALOLA_MAROWAK ], - [TrainerPoolTier.RARE]: [ Species.MAGNEMITE, Species.TURTONATOR, Species.MIMIKYU, Species.DRAMPA, Species.GALAR_CORSOLA ], - [TrainerPoolTier.SUPER_RARE]: [ Species.PORYGON, Species.JANGMO_O ] - }), - [TrainerType.FABA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("aether_admin", "aether", [ Species.HYPNO ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_aether_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.SKULL_GRUNT]: new TrainerConfig(++t).setHasGenders("Skull Grunt Female").setHasDouble("Skull Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_skull_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.EKANS, Species.DROWZEE, Species.KOFFING, Species.SPINARAK, Species.SCRAGGY, Species.TRUBBISH, Species.MAREANIE, Species.SALANDIT, Species.ALOLA_RATTATA, Species.ALOLA_MEOWTH, Species.ALOLA_GRIMER ], - [TrainerPoolTier.UNCOMMON]: [ Species.ZUBAT, Species.GASTLY, Species.HOUNDOUR, Species.SABLEYE, Species.VENIPEDE, Species.SANDILE, Species.VULLABY, Species.PANCHAM, Species.FOMANTIS, Species.ALOLA_MAROWAK ], - [TrainerPoolTier.RARE]: [ Species.PAWNIARD, Species.WISHIWASHI, Species.SANDYGAST, Species.MIMIKYU, Species.DHELMISE, Species.NYMBLE ], - [TrainerPoolTier.SUPER_RARE]: [ Species.GRUBBIN, Species.DEWPIDER ] - }), - [TrainerType.PLUMERIA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("skull_admin", "skull", [ Species.SALAZZLE ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_skull_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.MACRO_GRUNT]: new TrainerConfig(++t).setHasGenders("Macro Grunt Female").setHasDouble("Macro Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_macro_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.STEELIX, Species.MAWILE, Species.FERROSEED, Species.KLINK, Species.SKWOVET, Species.ROOKIDEE, Species.CRAMORANT, Species.CUFANT, Species.GALAR_MEOWTH, Species.GALAR_ZIGZAGOON ], - [TrainerPoolTier.UNCOMMON]: [ Species.MAGNEMITE, Species.RIOLU, Species.DRILBUR, Species.APPLIN, Species.ARROKUDA, Species.SINISTEA, Species.HATENNA, Species.GALAR_PONYTA, Species.GALAR_YAMASK ], - [TrainerPoolTier.RARE]: [ Species.SCIZOR, Species.BELDUM, Species.HONEDGE, Species.FALINKS, Species.GALAR_FARFETCHD, Species.GALAR_MR_MIME, Species.GALAR_DARUMAKA ], - [TrainerPoolTier.SUPER_RARE]: [ Species.DURALUDON, Species.DREEPY ] - }), - [TrainerType.OLEANA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("macro_admin", "macro", [ Species.GARBODOR ]).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_oleana").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()), - [TrainerType.STAR_GRUNT]: new TrainerConfig(++t).setHasGenders("Star Grunt Female").setHasDouble("Star Grunts").setMoneyMultiplier(1.0).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_grunt").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setSpeciesPools({ - [TrainerPoolTier.COMMON]: [ Species.DUNSPARCE, Species.HOUNDOUR, Species.AZURILL, Species.GULPIN, Species.FOONGUS, Species.FLETCHLING, Species.LITLEO, Species.FLABEBE, Species.CRABRAWLER, Species.NYMBLE, Species.PAWMI, Species.FIDOUGH, Species.SQUAWKABILLY, Species.MASCHIFF, Species.SHROODLE, Species.KLAWF, Species.WIGLETT, Species.PALDEA_WOOPER ], - [TrainerPoolTier.UNCOMMON]: [ Species.KOFFING, Species.EEVEE, Species.GIRAFARIG, Species.RALTS, Species.TORKOAL, Species.SEVIPER, Species.SCRAGGY, Species.ZORUA, Species.MIMIKYU, Species.IMPIDIMP, Species.FALINKS, Species.CAPSAKID, Species.TINKATINK, Species.BOMBIRDIER, Species.CYCLIZAR, Species.FLAMIGO, Species.PALDEA_TAUROS ], - [TrainerPoolTier.RARE]: [ Species.MANKEY, Species.PAWNIARD, Species.CHARCADET, Species.FLITTLE, Species.VAROOM, Species.ORTHWORM ], - [TrainerPoolTier.SUPER_RARE]: [ Species.DONDOZO, Species.GIMMIGHOUL ] - }), - [TrainerType.GIACOMO]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("star_admin", "star_1", [ Species.KINGAMBIT ], PokemonType.DARK).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Segin Starmobile - p.moveset = [ new PokemonMove(Moves.WICKED_TORQUE), new PokemonMove(Moves.SPIN_OUT), new PokemonMove(Moves.SHIFT_GEAR), new PokemonMove(Moves.HIGH_HORSEPOWER) ]; - })), - [TrainerType.MELA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("star_admin", "star_2", [ Species.ARMAROUGE ], PokemonType.FIRE).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 2; // Schedar Starmobile - p.moveset = [ new PokemonMove(Moves.BLAZING_TORQUE), new PokemonMove(Moves.SPIN_OUT), new PokemonMove(Moves.SHIFT_GEAR), new PokemonMove(Moves.HIGH_HORSEPOWER) ]; - })), - [TrainerType.ATTICUS]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("star_admin", "star_3", [ Species.REVAVROOM ], PokemonType.POISON).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 3; // Navi Starmobile - p.moveset = [ new PokemonMove(Moves.NOXIOUS_TORQUE), new PokemonMove(Moves.SPIN_OUT), new PokemonMove(Moves.SHIFT_GEAR), new PokemonMove(Moves.HIGH_HORSEPOWER) ]; - })), - [TrainerType.ORTEGA]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("star_admin", "star_4", [ Species.DACHSBUN ], PokemonType.FAIRY).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 4; // Ruchbah Starmobile - p.moveset = [ new PokemonMove(Moves.MAGICAL_TORQUE), new PokemonMove(Moves.SPIN_OUT), new PokemonMove(Moves.SHIFT_GEAR), new PokemonMove(Moves.HIGH_HORSEPOWER) ]; - })), - [TrainerType.ERI]: new TrainerConfig(++t).setMoneyMultiplier(1.5).initForEvilTeamAdmin("star_admin", "star_5", [ Species.ANNIHILAPE ], PokemonType.FIGHTING).setEncounterBgm(TrainerType.PLASMA_GRUNT).setBattleBgm("battle_plasma_grunt").setMixedBattleBgm("battle_star_admin").setVictoryBgm("victory_team_plasma").setPartyTemplateFunc(() => getEvilGruntPartyTemplate()) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 5; // Caph Starmobile - p.moveset = [ new PokemonMove(Moves.COMBAT_TORQUE), new PokemonMove(Moves.SPIN_OUT), new PokemonMove(Moves.SHIFT_GEAR), new PokemonMove(Moves.HIGH_HORSEPOWER) ]; - })), - [TrainerType.BROCK]: new TrainerConfig((t = TrainerType.BROCK)).initForGymLeader(signatureSpecies["BROCK"], true, PokemonType.ROCK).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.MISTY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MISTY"], false, PokemonType.WATER).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.LT_SURGE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["LT_SURGE"], true, PokemonType.ELECTRIC).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.ERIKA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["ERIKA"], false, PokemonType.GRASS).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.JANINE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["JANINE"], false, PokemonType.POISON).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.SABRINA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["SABRINA"], false, PokemonType.PSYCHIC).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.BLAINE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BLAINE"], true, PokemonType.FIRE).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.GIOVANNI]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GIOVANNI"], true, PokemonType.DARK).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.FALKNER]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["FALKNER"], true, PokemonType.FLYING).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.BUGSY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BUGSY"], true, PokemonType.BUG).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.WHITNEY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WHITNEY"], false, PokemonType.NORMAL).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.MORTY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MORTY"], true, PokemonType.GHOST).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.CHUCK]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CHUCK"], true, PokemonType.FIGHTING).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.JASMINE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["JASMINE"], false, PokemonType.STEEL).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.PRYCE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["PRYCE"], true, PokemonType.ICE).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.CLAIR]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CLAIR"], false, PokemonType.DRAGON).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.ROXANNE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["ROXANNE"], false, PokemonType.ROCK).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.BRAWLY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BRAWLY"], true, PokemonType.FIGHTING).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.WATTSON]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WATTSON"], true, PokemonType.ELECTRIC).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.FLANNERY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["FLANNERY"], false, PokemonType.FIRE).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.NORMAN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["NORMAN"], true, PokemonType.NORMAL).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.WINONA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WINONA"], false, PokemonType.FLYING).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.TATE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["TATE"], true, PokemonType.PSYCHIC).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym").setHasDouble("tate_liza_double").setDoubleTrainerType(TrainerType.LIZA).setDoubleTitle("gym_leader_double"), - [TrainerType.LIZA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["LIZA"], false, PokemonType.PSYCHIC).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym").setHasDouble("liza_tate_double").setDoubleTrainerType(TrainerType.TATE).setDoubleTitle("gym_leader_double"), - [TrainerType.JUAN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["JUAN"], true, PokemonType.WATER).setBattleBgm("battle_hoenn_gym").setMixedBattleBgm("battle_hoenn_gym"), - [TrainerType.ROARK]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["ROARK"], true, PokemonType.ROCK).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.GARDENIA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GARDENIA"], false, PokemonType.GRASS).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.MAYLENE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MAYLENE"], false, PokemonType.FIGHTING).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.CRASHER_WAKE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CRASHER_WAKE"], true, PokemonType.WATER).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.FANTINA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["FANTINA"], false, PokemonType.GHOST).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.BYRON]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BYRON"], true, PokemonType.STEEL).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.CANDICE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CANDICE"], false, PokemonType.ICE).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.VOLKNER]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["VOLKNER"], true, PokemonType.ELECTRIC).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.CILAN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CILAN"], true, PokemonType.GRASS).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.CHILI]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CHILI"], true, PokemonType.FIRE).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.CRESS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CRESS"], true, PokemonType.WATER).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.CHEREN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CHEREN"], true, PokemonType.NORMAL).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.LENORA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["LENORA"], false, PokemonType.NORMAL).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.ROXIE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["ROXIE"], false, PokemonType.POISON).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.BURGH]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BURGH"], true, PokemonType.BUG).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.ELESA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["ELESA"], false, PokemonType.ELECTRIC).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.CLAY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CLAY"], true, PokemonType.GROUND).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.SKYLA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["SKYLA"], false, PokemonType.FLYING).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.BRYCEN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BRYCEN"], true, PokemonType.ICE).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.DRAYDEN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["DRAYDEN"], true, PokemonType.DRAGON).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.MARLON]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MARLON"], true, PokemonType.WATER).setMixedBattleBgm("battle_unova_gym"), - [TrainerType.VIOLA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["VIOLA"], false, PokemonType.BUG).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.GRANT]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GRANT"], true, PokemonType.ROCK).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.KORRINA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KORRINA"], false, PokemonType.FIGHTING).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.RAMOS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["RAMOS"], true, PokemonType.GRASS).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.CLEMONT]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CLEMONT"], true, PokemonType.ELECTRIC).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.VALERIE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["VALERIE"], false, PokemonType.FAIRY).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.OLYMPIA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["OLYMPIA"], false, PokemonType.PSYCHIC).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.WULFRIC]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WULFRIC"], true, PokemonType.ICE).setMixedBattleBgm("battle_kalos_gym"), - [TrainerType.MILO]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MILO"], true, PokemonType.GRASS).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.NESSA]: new TrainerConfig(++t).setName("Nessa").initForGymLeader(signatureSpecies["NESSA"], false, PokemonType.WATER).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.KABU]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KABU"], true, PokemonType.FIRE).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.BEA]: new TrainerConfig(++t).setName("Bea").initForGymLeader(signatureSpecies["BEA"], false, PokemonType.FIGHTING).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.ALLISTER]: new TrainerConfig(++t).setName("Allister").initForGymLeader(signatureSpecies["ALLISTER"], true, PokemonType.GHOST).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.OPAL]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["OPAL"], false, PokemonType.FAIRY).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.BEDE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BEDE"], true, PokemonType.FAIRY).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.GORDIE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GORDIE"], true, PokemonType.ROCK).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.MELONY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MELONY"], false, PokemonType.ICE).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.PIERS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["PIERS"], true, PokemonType.DARK).setHasDouble("piers_marnie_double").setDoubleTrainerType(TrainerType.MARNIE).setDoubleTitle("gym_leader_double").setMixedBattleBgm("battle_galar_gym"), - [TrainerType.MARNIE]: new TrainerConfig(++t).setName("Marnie").initForGymLeader(signatureSpecies["MARNIE"], false, PokemonType.DARK).setHasDouble("marnie_piers_double").setDoubleTrainerType(TrainerType.PIERS).setDoubleTitle("gym_leader_double").setMixedBattleBgm("battle_galar_gym"), - [TrainerType.RAIHAN]: new TrainerConfig(++t).setName("Raihan").initForGymLeader(signatureSpecies["RAIHAN"], true, PokemonType.DRAGON).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.KATY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KATY"], false, PokemonType.BUG, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.BRASSIUS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BRASSIUS"], true, PokemonType.GRASS, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.IONO]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["IONO"], false, PokemonType.ELECTRIC, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.KOFU]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KOFU"], true, PokemonType.WATER, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.LARRY]: new TrainerConfig(++t).setName("Larry").initForGymLeader(signatureSpecies["LARRY"], true, PokemonType.NORMAL, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.RYME]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["RYME"], false, PokemonType.GHOST, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.TULIP]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["TULIP"], false, PokemonType.PSYCHIC, true, -1).setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.GRUSHA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GRUSHA"], true, PokemonType.ICE, true, -1).setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.BROCK]: new TrainerConfig((t = TrainerType.BROCK)) + .initForGymLeader(signatureSpecies["BROCK"], true, PokemonType.ROCK) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.MISTY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MISTY"], false, PokemonType.WATER) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.LT_SURGE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["LT_SURGE"], true, PokemonType.ELECTRIC) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.ERIKA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["ERIKA"], false, PokemonType.GRASS) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.JANINE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["JANINE"], false, PokemonType.POISON) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.SABRINA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["SABRINA"], false, PokemonType.PSYCHIC) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.BLAINE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BLAINE"], true, PokemonType.FIRE) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.GIOVANNI]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["GIOVANNI"], true, PokemonType.DARK) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.FALKNER]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["FALKNER"], true, PokemonType.FLYING) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.BUGSY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BUGSY"], true, PokemonType.BUG) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.WHITNEY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["WHITNEY"], false, PokemonType.NORMAL) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.MORTY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MORTY"], true, PokemonType.GHOST) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.CHUCK]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CHUCK"], true, PokemonType.FIGHTING) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.JASMINE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["JASMINE"], false, PokemonType.STEEL) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.PRYCE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["PRYCE"], true, PokemonType.ICE) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.CLAIR]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CLAIR"], false, PokemonType.DRAGON) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.ROXANNE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["ROXANNE"], false, PokemonType.ROCK) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.BRAWLY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BRAWLY"], true, PokemonType.FIGHTING) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.WATTSON]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["WATTSON"], true, PokemonType.ELECTRIC) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.FLANNERY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["FLANNERY"], false, PokemonType.FIRE) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.NORMAN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["NORMAN"], true, PokemonType.NORMAL) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.WINONA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["WINONA"], false, PokemonType.FLYING) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.TATE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["TATE"], true, PokemonType.PSYCHIC) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym") + .setHasDouble("tate_liza_double") + .setDoubleTrainerType(TrainerType.LIZA) + .setDoubleTitle("gym_leader_double"), + [TrainerType.LIZA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["LIZA"], false, PokemonType.PSYCHIC) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym") + .setHasDouble("liza_tate_double") + .setDoubleTrainerType(TrainerType.TATE) + .setDoubleTitle("gym_leader_double"), + [TrainerType.JUAN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["JUAN"], true, PokemonType.WATER) + .setBattleBgm("battle_hoenn_gym") + .setMixedBattleBgm("battle_hoenn_gym"), + [TrainerType.ROARK]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["ROARK"], true, PokemonType.ROCK) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.GARDENIA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["GARDENIA"], false, PokemonType.GRASS) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.MAYLENE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MAYLENE"], false, PokemonType.FIGHTING) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.CRASHER_WAKE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CRASHER_WAKE"], true, PokemonType.WATER) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.FANTINA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["FANTINA"], false, PokemonType.GHOST) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.BYRON]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BYRON"], true, PokemonType.STEEL) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.CANDICE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CANDICE"], false, PokemonType.ICE) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.VOLKNER]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["VOLKNER"], true, PokemonType.ELECTRIC) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.CILAN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CILAN"], true, PokemonType.GRASS) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.CHILI]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CHILI"], true, PokemonType.FIRE) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.CRESS]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CRESS"], true, PokemonType.WATER) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.CHEREN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CHEREN"], true, PokemonType.NORMAL) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.LENORA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["LENORA"], false, PokemonType.NORMAL) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.ROXIE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["ROXIE"], false, PokemonType.POISON) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.BURGH]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BURGH"], true, PokemonType.BUG) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.ELESA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["ELESA"], false, PokemonType.ELECTRIC) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.CLAY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CLAY"], true, PokemonType.GROUND) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.SKYLA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["SKYLA"], false, PokemonType.FLYING) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.BRYCEN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BRYCEN"], true, PokemonType.ICE) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.DRAYDEN]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["DRAYDEN"], true, PokemonType.DRAGON) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.MARLON]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MARLON"], true, PokemonType.WATER) + .setMixedBattleBgm("battle_unova_gym"), + [TrainerType.VIOLA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["VIOLA"], false, PokemonType.BUG) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.GRANT]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["GRANT"], true, PokemonType.ROCK) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.KORRINA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["KORRINA"], false, PokemonType.FIGHTING) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.RAMOS]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["RAMOS"], true, PokemonType.GRASS) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.CLEMONT]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["CLEMONT"], true, PokemonType.ELECTRIC) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.VALERIE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["VALERIE"], false, PokemonType.FAIRY) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.OLYMPIA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["OLYMPIA"], false, PokemonType.PSYCHIC) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.WULFRIC]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["WULFRIC"], true, PokemonType.ICE) + .setMixedBattleBgm("battle_kalos_gym"), + [TrainerType.MILO]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MILO"], true, PokemonType.GRASS) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.NESSA]: new TrainerConfig(++t) + .setName("Nessa") + .initForGymLeader(signatureSpecies["NESSA"], false, PokemonType.WATER) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.KABU]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["KABU"], true, PokemonType.FIRE) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.BEA]: new TrainerConfig(++t) + .setName("Bea") + .initForGymLeader(signatureSpecies["BEA"], false, PokemonType.FIGHTING) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.ALLISTER]: new TrainerConfig(++t) + .setName("Allister") + .initForGymLeader(signatureSpecies["ALLISTER"], true, PokemonType.GHOST) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.OPAL]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["OPAL"], false, PokemonType.FAIRY) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.BEDE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BEDE"], true, PokemonType.FAIRY) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.GORDIE]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["GORDIE"], true, PokemonType.ROCK) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.MELONY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["MELONY"], false, PokemonType.ICE) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.PIERS]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["PIERS"], true, PokemonType.DARK) + .setHasDouble("piers_marnie_double") + .setDoubleTrainerType(TrainerType.MARNIE) + .setDoubleTitle("gym_leader_double") + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.MARNIE]: new TrainerConfig(++t) + .setName("Marnie") + .initForGymLeader(signatureSpecies["MARNIE"], false, PokemonType.DARK) + .setHasDouble("marnie_piers_double") + .setDoubleTrainerType(TrainerType.PIERS) + .setDoubleTitle("gym_leader_double") + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.RAIHAN]: new TrainerConfig(++t) + .setName("Raihan") + .initForGymLeader(signatureSpecies["RAIHAN"], true, PokemonType.DRAGON) + .setMixedBattleBgm("battle_galar_gym"), + [TrainerType.KATY]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["KATY"], false, PokemonType.BUG, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.BRASSIUS]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["BRASSIUS"], true, PokemonType.GRASS, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.IONO]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["IONO"], false, PokemonType.ELECTRIC, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.KOFU]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["KOFU"], true, PokemonType.WATER, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.LARRY]: new TrainerConfig(++t) + .setName("Larry") + .initForGymLeader(signatureSpecies["LARRY"], true, PokemonType.NORMAL, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.RYME]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["RYME"], false, PokemonType.GHOST, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.TULIP]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["TULIP"], false, PokemonType.PSYCHIC, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), + [TrainerType.GRUSHA]: new TrainerConfig(++t) + .initForGymLeader(signatureSpecies["GRUSHA"], true, PokemonType.ICE, true, -1) + .setMixedBattleBgm("battle_paldea_gym"), - [TrainerType.LORELEI]: new TrainerConfig((t = TrainerType.LORELEI)).initForEliteFour(signatureSpecies["LORELEI"], false, PokemonType.ICE).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.BRUNO]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["BRUNO"], true, PokemonType.FIGHTING).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.AGATHA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["AGATHA"], false, PokemonType.GHOST).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.LANCE]: new TrainerConfig(++t).setName("Lance").initForEliteFour(signatureSpecies["LANCE"], true, PokemonType.DRAGON).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), - [TrainerType.WILL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["WILL"], true, PokemonType.PSYCHIC).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.KOGA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["KOGA"], true, PokemonType.POISON).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.KAREN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["KAREN"], false, PokemonType.DARK).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.SIDNEY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["SIDNEY"], true, PokemonType.DARK).setMixedBattleBgm("battle_hoenn_elite"), - [TrainerType.PHOEBE]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["PHOEBE"], false, PokemonType.GHOST).setMixedBattleBgm("battle_hoenn_elite"), - [TrainerType.GLACIA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["GLACIA"], false, PokemonType.ICE).setMixedBattleBgm("battle_hoenn_elite"), - [TrainerType.DRAKE]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRAKE"], true, PokemonType.DRAGON).setMixedBattleBgm("battle_hoenn_elite"), - [TrainerType.AARON]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["AARON"], true, PokemonType.BUG).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.BERTHA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["BERTHA"], false, PokemonType.GROUND).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.FLINT]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["FLINT"], true, PokemonType.FIRE, 3).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.LUCIAN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["LUCIAN"], true, PokemonType.PSYCHIC).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.SHAUNTAL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["SHAUNTAL"], false, PokemonType.GHOST).setMixedBattleBgm("battle_unova_elite"), - [TrainerType.MARSHAL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["MARSHAL"], true, PokemonType.FIGHTING).setMixedBattleBgm("battle_unova_elite"), - [TrainerType.GRIMSLEY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["GRIMSLEY"], true, PokemonType.DARK).setMixedBattleBgm("battle_unova_elite"), - [TrainerType.CAITLIN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["CAITLIN"], false, PokemonType.PSYCHIC).setMixedBattleBgm("battle_unova_elite"), - [TrainerType.MALVA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["MALVA"], false, PokemonType.FIRE).setMixedBattleBgm("battle_kalos_elite"), - [TrainerType.SIEBOLD]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["SIEBOLD"], true, PokemonType.WATER).setMixedBattleBgm("battle_kalos_elite"), - [TrainerType.WIKSTROM]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["WIKSTROM"], true, PokemonType.STEEL).setMixedBattleBgm("battle_kalos_elite"), - [TrainerType.DRASNA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRASNA"], false, PokemonType.DRAGON).setMixedBattleBgm("battle_kalos_elite"), - [TrainerType.HALA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["HALA"], true, PokemonType.FIGHTING).setMixedBattleBgm("battle_alola_elite"), - [TrainerType.MOLAYNE]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["MOLAYNE"], true, PokemonType.STEEL).setMixedBattleBgm("battle_alola_elite"), - [TrainerType.OLIVIA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["OLIVIA"], false, PokemonType.ROCK).setMixedBattleBgm("battle_alola_elite"), - [TrainerType.ACEROLA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["ACEROLA"], false, PokemonType.GHOST).setMixedBattleBgm("battle_alola_elite"), - [TrainerType.KAHILI]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["KAHILI"], false, PokemonType.FLYING).setMixedBattleBgm("battle_alola_elite"), - [TrainerType.MARNIE_ELITE]: new TrainerConfig(++t).setName("Marnie").initForEliteFour(signatureSpecies["MARNIE_ELITE"], false, PokemonType.DARK).setMixedBattleBgm("battle_galar_elite"), - [TrainerType.NESSA_ELITE]: new TrainerConfig(++t).setName("Nessa").initForEliteFour(signatureSpecies["NESSA_ELITE"], false, PokemonType.WATER).setMixedBattleBgm("battle_galar_elite"), - [TrainerType.BEA_ELITE]: new TrainerConfig(++t).setName("Bea").initForEliteFour(signatureSpecies["BEA_ELITE"], false, PokemonType.FIGHTING).setMixedBattleBgm("battle_galar_elite"), - [TrainerType.ALLISTER_ELITE]: new TrainerConfig(++t).setName("Allister").initForEliteFour(signatureSpecies["ALLISTER_ELITE"], true, PokemonType.GHOST).setMixedBattleBgm("battle_galar_elite"), - [TrainerType.RAIHAN_ELITE]: new TrainerConfig(++t).setName("Raihan").initForEliteFour(signatureSpecies["RAIHAN_ELITE"], true, PokemonType.DRAGON).setMixedBattleBgm("battle_galar_elite"), - [TrainerType.RIKA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["RIKA"], false, PokemonType.GROUND, 5).setMixedBattleBgm("battle_paldea_elite"), - [TrainerType.POPPY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["POPPY"], false, PokemonType.STEEL, 5).setMixedBattleBgm("battle_paldea_elite"), - [TrainerType.LARRY_ELITE]: new TrainerConfig(++t).setName("Larry").initForEliteFour(signatureSpecies["LARRY_ELITE"], true, PokemonType.FLYING, 5).setMixedBattleBgm("battle_paldea_elite"), - [TrainerType.HASSEL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["HASSEL"], true, PokemonType.DRAGON, 5).setMixedBattleBgm("battle_paldea_elite"), - [TrainerType.CRISPIN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["CRISPIN"], true, PokemonType.FIRE, 5).setMixedBattleBgm("battle_bb_elite"), - [TrainerType.AMARYS]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["AMARYS"], false, PokemonType.STEEL, 5).setMixedBattleBgm("battle_bb_elite"), - [TrainerType.LACEY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["LACEY"], false, PokemonType.FAIRY, 5).setMixedBattleBgm("battle_bb_elite"), - [TrainerType.DRAYTON]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRAYTON"], true, PokemonType.DRAGON, 5).setMixedBattleBgm("battle_bb_elite"), + [TrainerType.LORELEI]: new TrainerConfig((t = TrainerType.LORELEI)) + .initForEliteFour(signatureSpecies["LORELEI"], false, PokemonType.ICE) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.BRUNO]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["BRUNO"], true, PokemonType.FIGHTING) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.AGATHA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["AGATHA"], false, PokemonType.GHOST) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.LANCE]: new TrainerConfig(++t) + .setName("Lance") + .initForEliteFour(signatureSpecies["LANCE"], true, PokemonType.DRAGON) + .setBattleBgm("battle_kanto_gym") + .setMixedBattleBgm("battle_kanto_gym"), + [TrainerType.WILL]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["WILL"], true, PokemonType.PSYCHIC) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.KOGA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["KOGA"], true, PokemonType.POISON) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.KAREN]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["KAREN"], false, PokemonType.DARK) + .setBattleBgm("battle_johto_gym") + .setMixedBattleBgm("battle_johto_gym"), + [TrainerType.SIDNEY]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["SIDNEY"], true, PokemonType.DARK) + .setMixedBattleBgm("battle_hoenn_elite"), + [TrainerType.PHOEBE]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["PHOEBE"], false, PokemonType.GHOST) + .setMixedBattleBgm("battle_hoenn_elite"), + [TrainerType.GLACIA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["GLACIA"], false, PokemonType.ICE) + .setMixedBattleBgm("battle_hoenn_elite"), + [TrainerType.DRAKE]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["DRAKE"], true, PokemonType.DRAGON) + .setMixedBattleBgm("battle_hoenn_elite"), + [TrainerType.AARON]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["AARON"], true, PokemonType.BUG) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.BERTHA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["BERTHA"], false, PokemonType.GROUND) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.FLINT]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["FLINT"], true, PokemonType.FIRE, 3) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.LUCIAN]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["LUCIAN"], true, PokemonType.PSYCHIC) + .setBattleBgm("battle_sinnoh_gym") + .setMixedBattleBgm("battle_sinnoh_gym"), + [TrainerType.SHAUNTAL]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["SHAUNTAL"], false, PokemonType.GHOST) + .setMixedBattleBgm("battle_unova_elite"), + [TrainerType.MARSHAL]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["MARSHAL"], true, PokemonType.FIGHTING) + .setMixedBattleBgm("battle_unova_elite"), + [TrainerType.GRIMSLEY]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["GRIMSLEY"], true, PokemonType.DARK) + .setMixedBattleBgm("battle_unova_elite"), + [TrainerType.CAITLIN]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["CAITLIN"], false, PokemonType.PSYCHIC) + .setMixedBattleBgm("battle_unova_elite"), + [TrainerType.MALVA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["MALVA"], false, PokemonType.FIRE) + .setMixedBattleBgm("battle_kalos_elite"), + [TrainerType.SIEBOLD]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["SIEBOLD"], true, PokemonType.WATER) + .setMixedBattleBgm("battle_kalos_elite"), + [TrainerType.WIKSTROM]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["WIKSTROM"], true, PokemonType.STEEL) + .setMixedBattleBgm("battle_kalos_elite"), + [TrainerType.DRASNA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["DRASNA"], false, PokemonType.DRAGON) + .setMixedBattleBgm("battle_kalos_elite"), + [TrainerType.HALA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["HALA"], true, PokemonType.FIGHTING) + .setMixedBattleBgm("battle_alola_elite"), + [TrainerType.MOLAYNE]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["MOLAYNE"], true, PokemonType.STEEL) + .setMixedBattleBgm("battle_alola_elite"), + [TrainerType.OLIVIA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["OLIVIA"], false, PokemonType.ROCK) + .setMixedBattleBgm("battle_alola_elite"), + [TrainerType.ACEROLA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["ACEROLA"], false, PokemonType.GHOST) + .setMixedBattleBgm("battle_alola_elite"), + [TrainerType.KAHILI]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["KAHILI"], false, PokemonType.FLYING) + .setMixedBattleBgm("battle_alola_elite"), + [TrainerType.MARNIE_ELITE]: new TrainerConfig(++t) + .setName("Marnie") + .initForEliteFour(signatureSpecies["MARNIE_ELITE"], false, PokemonType.DARK) + .setMixedBattleBgm("battle_galar_elite"), + [TrainerType.NESSA_ELITE]: new TrainerConfig(++t) + .setName("Nessa") + .initForEliteFour(signatureSpecies["NESSA_ELITE"], false, PokemonType.WATER) + .setMixedBattleBgm("battle_galar_elite"), + [TrainerType.BEA_ELITE]: new TrainerConfig(++t) + .setName("Bea") + .initForEliteFour(signatureSpecies["BEA_ELITE"], false, PokemonType.FIGHTING) + .setMixedBattleBgm("battle_galar_elite"), + [TrainerType.ALLISTER_ELITE]: new TrainerConfig(++t) + .setName("Allister") + .initForEliteFour(signatureSpecies["ALLISTER_ELITE"], true, PokemonType.GHOST) + .setMixedBattleBgm("battle_galar_elite"), + [TrainerType.RAIHAN_ELITE]: new TrainerConfig(++t) + .setName("Raihan") + .initForEliteFour(signatureSpecies["RAIHAN_ELITE"], true, PokemonType.DRAGON) + .setMixedBattleBgm("battle_galar_elite"), + [TrainerType.RIKA]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["RIKA"], false, PokemonType.GROUND, 5) + .setMixedBattleBgm("battle_paldea_elite"), + [TrainerType.POPPY]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["POPPY"], false, PokemonType.STEEL, 5) + .setMixedBattleBgm("battle_paldea_elite"), + [TrainerType.LARRY_ELITE]: new TrainerConfig(++t) + .setName("Larry") + .initForEliteFour(signatureSpecies["LARRY_ELITE"], true, PokemonType.FLYING, 5) + .setMixedBattleBgm("battle_paldea_elite"), + [TrainerType.HASSEL]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["HASSEL"], true, PokemonType.DRAGON, 5) + .setMixedBattleBgm("battle_paldea_elite"), + [TrainerType.CRISPIN]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["CRISPIN"], true, PokemonType.FIRE, 5) + .setMixedBattleBgm("battle_bb_elite"), + [TrainerType.AMARYS]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["AMARYS"], false, PokemonType.STEEL, 5) + .setMixedBattleBgm("battle_bb_elite"), + [TrainerType.LACEY]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["LACEY"], false, PokemonType.FAIRY, 5) + .setMixedBattleBgm("battle_bb_elite"), + [TrainerType.DRAYTON]: new TrainerConfig(++t) + .initForEliteFour(signatureSpecies["DRAYTON"], true, PokemonType.DRAGON, 5) + .setMixedBattleBgm("battle_bb_elite"), - [TrainerType.BLUE]: new TrainerConfig((t = TrainerType.BLUE)).initForChampion(true).setBattleBgm("battle_kanto_champion").setMixedBattleBgm("battle_kanto_champion").setHasDouble("blue_red_double").setDoubleTrainerType(TrainerType.RED).setDoubleTitle("champion_double") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ALAKAZAM ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.MACHAMP ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.HO_OH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.RHYPERIOR, Species.ELECTIVIRE, Species.MAGMORTAR ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.ARCANINE, Species.EXEGGUTOR, Species.GYARADOS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.PIDGEOT ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Pidgeot - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.MALE; - })) + [TrainerType.BLUE]: new TrainerConfig((t = TrainerType.BLUE)) + .initForChampion(true) + .setBattleBgm("battle_kanto_champion") + .setMixedBattleBgm("battle_kanto_champion") + .setHasDouble("blue_red_double") + .setDoubleTrainerType(TrainerType.RED) + .setDoubleTitle("champion_double") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.ALAKAZAM])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.MACHAMP])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.HO_OH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.RHYPERIOR, Species.ELECTIVIRE, Species.MAGMORTAR])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc( + [Species.ARCANINE, Species.EXEGGUTOR, Species.GYARADOS], + TrainerSlot.TRAINER, + true, + p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }, + ), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.PIDGEOT], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Pidgeot + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.MALE; + }), + ) .setInstantTera(3), // Tera Ground or Rock Rhyperior / Electric Electivire / Fire Magmortar - [TrainerType.RED]: new TrainerConfig(++t).initForChampion(true).setBattleBgm("battle_johto_champion").setMixedBattleBgm("battle_johto_champion").setHasDouble("red_blue_double").setDoubleTrainerType(TrainerType.BLUE).setDoubleTitle("champion_double") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.PIKACHU ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 8; // G-Max Pikachu - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.ESPEON, Species.UMBREON, Species.SYLVEON ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.LUGIA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.SNORLAX ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Venusaur, Mega Charizard X, or Mega Blastoise - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.MALE; - })) + [TrainerType.RED]: new TrainerConfig(++t) + .initForChampion(true) + .setBattleBgm("battle_johto_champion") + .setMixedBattleBgm("battle_johto_champion") + .setHasDouble("red_blue_double") + .setDoubleTrainerType(TrainerType.BLUE) + .setDoubleTitle("champion_double") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.PIKACHU], TrainerSlot.TRAINER, true, p => { + p.formIndex = 8; // G-Max Pikachu + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.ESPEON, Species.UMBREON, Species.SYLVEON])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.LUGIA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.SNORLAX], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc( + [Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE], + TrainerSlot.TRAINER, + true, + p => { + p.formIndex = 1; // Mega Venusaur, Mega Charizard X, or Mega Blastoise + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.MALE; + }, + ), + ) .setInstantTera(3), // Tera Grass Meganium / Fire Typhlosion / Water Feraligatr - [TrainerType.LANCE_CHAMPION]: new TrainerConfig(++t).setName("Lance").initForChampion(true).setBattleBgm("battle_johto_champion").setMixedBattleBgm("battle_johto_champion") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.GYARADOS, Species.KINGDRA ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.AERODACTYL ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SALAMENCE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Salamence - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.CHARIZARD ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.TYRANITAR, Species.GARCHOMP, Species.KOMMO_O ], TrainerSlot.TRAINER, true, p => { - p.teraType = PokemonType.DRAGON; - p.abilityIndex = p.species.speciesId === Species.KOMMO_O ? 1 : 2; // Soundproof Kommo-o, Unnerve Tyranitar, Rough Skin Garchomp - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.DRAGONITE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.setBoss(true, 2); - })) + [TrainerType.LANCE_CHAMPION]: new TrainerConfig(++t) + .setName("Lance") + .initForChampion(true) + .setBattleBgm("battle_johto_champion") + .setMixedBattleBgm("battle_johto_champion") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.GYARADOS, Species.KINGDRA])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.AERODACTYL])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SALAMENCE], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Salamence + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.CHARIZARD])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.TYRANITAR, Species.GARCHOMP, Species.KOMMO_O], TrainerSlot.TRAINER, true, p => { + p.teraType = PokemonType.DRAGON; + p.abilityIndex = p.species.speciesId === Species.KOMMO_O ? 1 : 2; // Soundproof Kommo-o, Unnerve Tyranitar, Rough Skin Garchomp + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.DRAGONITE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.setBoss(true, 2); + }), + ) .setInstantTera(4), // Tera Dragon Tyranitar / Garchomp / Kommo-o - [TrainerType.STEVEN]: new TrainerConfig(++t).initForChampion(true).setBattleBgm("battle_hoenn_champion_g5").setMixedBattleBgm("battle_hoenn_champion_g6").setHasDouble("steven_wallace_double").setDoubleTrainerType(TrainerType.WALLACE).setDoubleTitle("champion_double") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.SKARMORY ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.CRADILY, Species.ARMALDO ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.AGGRON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GOLURK, Species.RUNERIGUS ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.REGIROCK, Species.REGICE, Species.REGISTEEL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.METAGROSS ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Metagross - p.generateAndPopulateMoveset(); - p.generateName(); - })) + [TrainerType.STEVEN]: new TrainerConfig(++t) + .initForChampion(true) + .setBattleBgm("battle_hoenn_champion_g5") + .setMixedBattleBgm("battle_hoenn_champion_g6") + .setHasDouble("steven_wallace_double") + .setDoubleTrainerType(TrainerType.WALLACE) + .setDoubleTitle("champion_double") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.SKARMORY])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.CRADILY, Species.ARMALDO])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.AGGRON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.GOLURK, Species.RUNERIGUS])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.REGIROCK, Species.REGICE, Species.REGISTEEL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.METAGROSS], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Metagross + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) .setInstantTera(4), // Tera Rock Regirock / Ice Regice / Steel Registeel - [TrainerType.WALLACE]: new TrainerConfig(++t).initForChampion(true).setBattleBgm("battle_hoenn_champion_g5").setMixedBattleBgm("battle_hoenn_champion_g6").setHasDouble("wallace_steven_double").setDoubleTrainerType(TrainerType.STEVEN).setDoubleTitle("champion_double") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.PELIPPER ], TrainerSlot.TRAINER, true, p => { - p.abilityIndex = 1; // Drizzle - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.LUDICOLO ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.LATIAS, Species.LATIOS ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Latios or Mega Latias - p.generateAndPopulateMoveset(); - p.generateName(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.SWAMPERT, Species.GASTRODON, Species.SEISMITOAD ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.REGIELEKI, Species.REGIDRAGO ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.MILOTIC ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - p.setBoss(true, 2); - })) + [TrainerType.WALLACE]: new TrainerConfig(++t) + .initForChampion(true) + .setBattleBgm("battle_hoenn_champion_g5") + .setMixedBattleBgm("battle_hoenn_champion_g6") + .setHasDouble("wallace_steven_double") + .setDoubleTrainerType(TrainerType.STEVEN) + .setDoubleTitle("champion_double") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.PELIPPER], TrainerSlot.TRAINER, true, p => { + p.abilityIndex = 1; // Drizzle + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.LUDICOLO])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.LATIAS, Species.LATIOS], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Latios or Mega Latias + p.generateAndPopulateMoveset(); + p.generateName(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.SWAMPERT, Species.GASTRODON, Species.SEISMITOAD])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.REGIELEKI, Species.REGIDRAGO], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.MILOTIC], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + p.setBoss(true, 2); + }), + ) .setInstantTera(4), // Tera Electric Regieleki / Dragon Regidrago - [TrainerType.CYNTHIA]: new TrainerConfig(++t).initForChampion(false).setBattleBgm("battle_sinnoh_champion").setMixedBattleBgm("battle_sinnoh_champion") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.SPIRITOMB ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.LUCARIO ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.GIRATINA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.MILOTIC, Species.ROSERADE, Species.HISUI_ARCANINE ], TrainerSlot.TRAINER, true, p => { - p.teraType = p.species.type1; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.TOGEKISS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.GARCHOMP ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Garchomp - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.FEMALE; - })) + [TrainerType.CYNTHIA]: new TrainerConfig(++t) + .initForChampion(false) + .setBattleBgm("battle_sinnoh_champion") + .setMixedBattleBgm("battle_sinnoh_champion") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.SPIRITOMB], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.LUCARIO])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.GIRATINA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc( + [Species.MILOTIC, Species.ROSERADE, Species.HISUI_ARCANINE], + TrainerSlot.TRAINER, + true, + p => { + p.teraType = p.species.type1; + }, + ), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.TOGEKISS], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.GARCHOMP], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Garchomp + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.FEMALE; + }), + ) .setInstantTera(3), // Tera Water Milotic / Grass Roserade / Fire Hisuian Arcanine - [TrainerType.ALDER]: new TrainerConfig(++t).initForChampion(true).setHasDouble("alder_iris_double").setDoubleTrainerType(TrainerType.IRIS).setDoubleTitle("champion_double").setBattleBgm("battle_champion_alder").setMixedBattleBgm("battle_champion_alder") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BOUFFALANT, Species.BRAVIARY ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.HISUI_LILLIGANT, Species.HISUI_ZOROARK, Species.BASCULEGION ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.ZEKROM ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.KELDEO ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.CHANDELURE, Species.KROOKODILE, Species.REUNICLUS, Species.CONKELDURR ], TrainerSlot.TRAINER, true, p => { - p.teraType = p.species.speciesId === Species.KROOKODILE ? PokemonType.DARK : p.species.type1; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.VOLCARONA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.setBoss(true, 2); - })) + [TrainerType.ALDER]: new TrainerConfig(++t) + .initForChampion(true) + .setHasDouble("alder_iris_double") + .setDoubleTrainerType(TrainerType.IRIS) + .setDoubleTitle("champion_double") + .setBattleBgm("battle_champion_alder") + .setMixedBattleBgm("battle_champion_alder") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.BOUFFALANT, Species.BRAVIARY])) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [Species.HISUI_LILLIGANT, Species.HISUI_ZOROARK, Species.BASCULEGION], + TrainerSlot.TRAINER, + true, + p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }, + ), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.ZEKROM], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.KELDEO], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc( + [Species.CHANDELURE, Species.KROOKODILE, Species.REUNICLUS, Species.CONKELDURR], + TrainerSlot.TRAINER, + true, + p => { + p.teraType = p.species.speciesId === Species.KROOKODILE ? PokemonType.DARK : p.species.type1; + }, + ), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.VOLCARONA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.setBoss(true, 2); + }), + ) .setInstantTera(4), // Tera Ghost Chandelure / Dark Krookodile / Psychic Reuniclus / Fighting Conkeldurr - [TrainerType.IRIS]: new TrainerConfig(++t).initForChampion(false).setBattleBgm("battle_champion_iris").setMixedBattleBgm("battle_champion_iris").setHasDouble("iris_alder_double").setDoubleTrainerType(TrainerType.ALDER).setDoubleTitle("champion_double") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.DRUDDIGON ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.ARCHEOPS ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.RESHIRAM ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.SALAMENCE, Species.HYDREIGON, Species.ARCHALUDON ], TrainerSlot.TRAINER, true, p => { - p.teraType = PokemonType.DRAGON; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.LAPRAS ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // G-Max Lapras - p.generateAndPopulateMoveset(); - p.generateName(); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.HAXORUS ], TrainerSlot.TRAINER, true, p => { - p.abilityIndex = 1; // Mold Breaker - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - p.setBoss(true, 2); - })) + [TrainerType.IRIS]: new TrainerConfig(++t) + .initForChampion(false) + .setBattleBgm("battle_champion_iris") + .setMixedBattleBgm("battle_champion_iris") + .setHasDouble("iris_alder_double") + .setDoubleTrainerType(TrainerType.ALDER) + .setDoubleTitle("champion_double") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.DRUDDIGON])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.ARCHEOPS])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.RESHIRAM], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc( + [Species.SALAMENCE, Species.HYDREIGON, Species.ARCHALUDON], + TrainerSlot.TRAINER, + true, + p => { + p.teraType = PokemonType.DRAGON; + }, + ), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.LAPRAS], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // G-Max Lapras + p.generateAndPopulateMoveset(); + p.generateName(); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.HAXORUS], TrainerSlot.TRAINER, true, p => { + p.abilityIndex = 1; // Mold Breaker + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + p.setBoss(true, 2); + }), + ) .setInstantTera(3), // Tera Dragon Salamence / Hydreigon / Archaludon - [TrainerType.DIANTHA]: new TrainerConfig(++t).initForChampion(false).setMixedBattleBgm("battle_kalos_champion") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.HAWLUCHA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.TREVENANT, Species.GOURGEIST ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.XERNEAS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.TYRANTRUM, Species.AURORUS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 2; // Rock Head Tyrantrum, Snow Warning Aurorus - p.teraType = p.species.type2!; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GOODRA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.GARDEVOIR ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Mega Gardevoir - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.FEMALE; - })) + [TrainerType.DIANTHA]: new TrainerConfig(++t) + .initForChampion(false) + .setMixedBattleBgm("battle_kalos_champion") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.HAWLUCHA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.TREVENANT, Species.GOURGEIST])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.XERNEAS], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.TYRANTRUM, Species.AURORUS], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 2; // Rock Head Tyrantrum, Snow Warning Aurorus + p.teraType = p.species.type2!; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.GOODRA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.GARDEVOIR], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Mega Gardevoir + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.FEMALE; + }), + ) .setInstantTera(3), // Tera Dragon Tyrantrum / Ice Aurorus - [TrainerType.KUKUI]: new TrainerConfig(++t).initForChampion(true).setMixedBattleBgm("battle_champion_kukui") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.LYCANROC ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 2; // Dusk Lycanroc - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.MAGNEZONE, Species.ALOLA_NINETALES ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.TORNADUS, Species.THUNDURUS, Species.LANDORUS ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Therian Formes - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.TAPU_KOKO, Species.TAPU_FINI ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.SNORLAX ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 1; // G-Max Snorlax - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.INCINEROAR, Species.HISUI_DECIDUEYE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.teraType = p.species.type2!; - })) + [TrainerType.KUKUI]: new TrainerConfig(++t) + .initForChampion(true) + .setMixedBattleBgm("battle_champion_kukui") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.LYCANROC], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 2; // Dusk Lycanroc + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.MAGNEZONE, Species.ALOLA_NINETALES])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc( + [Species.TORNADUS, Species.THUNDURUS, Species.LANDORUS], + TrainerSlot.TRAINER, + true, + p => { + p.formIndex = 1; // Therian Formes + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }, + ), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.TAPU_KOKO, Species.TAPU_FINI], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.SNORLAX], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 1; // G-Max Snorlax + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.INCINEROAR, Species.HISUI_DECIDUEYE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.teraType = p.species.type2!; + }), + ) .setInstantTera(5), // Tera Dark Incineroar / Fighting Hisuian Decidueye - [TrainerType.HAU]: new TrainerConfig(++t).initForChampion(true).setMixedBattleBgm("battle_alola_champion") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ALOLA_RAICHU ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.NOIVERN ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SOLGALEO ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.TAPU_LELE, Species.TAPU_BULU ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.teraType = p.species.type1; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.ZYGARDE ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 1; // Zygarde 10% forme, Aura Break - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.DECIDUEYE, Species.PRIMARINA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - p.gender = p.species.speciesId === Species.PRIMARINA ? Gender.FEMALE : Gender.MALE; - })) + [TrainerType.HAU]: new TrainerConfig(++t) + .initForChampion(true) + .setMixedBattleBgm("battle_alola_champion") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.ALOLA_RAICHU], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.NOIVERN])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SOLGALEO], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.TAPU_LELE, Species.TAPU_BULU], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.teraType = p.species.type1; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.ZYGARDE], TrainerSlot.TRAINER, true, p => { + p.formIndex = 1; // Zygarde 10% forme, Aura Break + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.DECIDUEYE, Species.PRIMARINA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + p.gender = p.species.speciesId === Species.PRIMARINA ? Gender.FEMALE : Gender.MALE; + }), + ) .setInstantTera(3), // Tera Psychic Tapu Lele / Grass Tapu Bulu - [TrainerType.LEON]: new TrainerConfig(++t).initForChampion(true).setMixedBattleBgm("battle_galar_champion") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.AEGISLASH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.RHYPERIOR, Species.SEISMITOAD, Species.MR_RIME ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.ZACIAN ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.DRAGAPULT ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.RILLABOOM, Species.CINDERACE, Species.INTELEON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.CHARIZARD ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 3; // G-Max Charizard - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.MALE; - })) + [TrainerType.LEON]: new TrainerConfig(++t) + .initForChampion(true) + .setMixedBattleBgm("battle_galar_champion") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.AEGISLASH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.RHYPERIOR, Species.SEISMITOAD, Species.MR_RIME])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.ZACIAN], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.DRAGAPULT])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc( + [Species.RILLABOOM, Species.CINDERACE, Species.INTELEON], + TrainerSlot.TRAINER, + true, + p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + }, + ), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.CHARIZARD], TrainerSlot.TRAINER, true, p => { + p.formIndex = 3; // G-Max Charizard + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.MALE; + }), + ) .setInstantTera(3), // Tera Dragapult to Ghost or Dragon - [TrainerType.MUSTARD]: new TrainerConfig(++t).initForChampion(true).setMixedBattleBgm("battle_mustard") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.CORVIKNIGHT ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.KOMMO_O ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.GALAR_SLOWBRO, Species.GALAR_SLOWKING ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.teraType = PokemonType.PSYCHIC; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GALAR_DARMANITAN ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.BLASTOISE, Species.VENUSAUR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.setBoss(true, 2); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.URSHIFU ], TrainerSlot.TRAINER, true, p => { - p.formIndex = Utils.randSeedInt(2, 2); // Random G-Max Urshifu - p.generateAndPopulateMoveset(); - p.generateName(); - p.gender = Gender.MALE; - p.pokeball = PokeballType.ULTRA_BALL; - })) + [TrainerType.MUSTARD]: new TrainerConfig(++t) + .initForChampion(true) + .setMixedBattleBgm("battle_mustard") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.CORVIKNIGHT], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.KOMMO_O], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.GALAR_SLOWBRO, Species.GALAR_SLOWKING], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.teraType = PokemonType.PSYCHIC; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.GALAR_DARMANITAN], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.BLASTOISE, Species.VENUSAUR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.setBoss(true, 2); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.URSHIFU], TrainerSlot.TRAINER, true, p => { + p.formIndex = Utils.randSeedInt(2, 2); // Random G-Max Urshifu + p.generateAndPopulateMoveset(); + p.generateName(); + p.gender = Gender.MALE; + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) .setInstantTera(2), // Tera Psychic Galar-Slowbro / Galar-Slowking - [TrainerType.GEETA]: new TrainerConfig(++t).initForChampion(false).setMixedBattleBgm("battle_champion_geeta") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.GLIMMORA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.setBoss(true, 2); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.ESPATHRA, Species.VELUZA ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.MIRAIDON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.BAXCALIBUR ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA ])) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.KINGAMBIT ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Supreme Overlord - p.teraType = PokemonType.FLYING; - })) + [TrainerType.GEETA]: new TrainerConfig(++t) + .initForChampion(false) + .setMixedBattleBgm("battle_champion_geeta") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.GLIMMORA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.setBoss(true, 2); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.ESPATHRA, Species.VELUZA])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.MIRAIDON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.BAXCALIBUR])) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA])) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.KINGAMBIT], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Supreme Overlord + p.teraType = PokemonType.FLYING; + }), + ) .setInstantTera(5), // Tera Flying Kingambit - [TrainerType.NEMONA]: new TrainerConfig(++t).initForChampion(false).setMixedBattleBgm("battle_champion_nemona") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.LYCANROC ], TrainerSlot.TRAINER, true, p => { - p.formIndex = 0; // Midday form - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PAWMOT ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.KORAIDON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GHOLDENGO ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.ARMAROUGE, Species.CERULEDGE ], TrainerSlot.TRAINER, true, p => { - p.teraType = p.species.type2!; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.setBoss(true, 2); - })) + [TrainerType.NEMONA]: new TrainerConfig(++t) + .initForChampion(false) + .setMixedBattleBgm("battle_champion_nemona") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.LYCANROC], TrainerSlot.TRAINER, true, p => { + p.formIndex = 0; // Midday form + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.PAWMOT])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.KORAIDON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.GHOLDENGO])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.ARMAROUGE, Species.CERULEDGE], TrainerSlot.TRAINER, true, p => { + p.teraType = p.species.type2!; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc( + [Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL], + TrainerSlot.TRAINER, + true, + p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.setBoss(true, 2); + }, + ), + ) .setInstantTera(4), // Tera Psychic Armarouge / Ghost Ceruledge - [TrainerType.KIERAN]: new TrainerConfig(++t).initForChampion(true).setMixedBattleBgm("battle_champion_kieran") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.POLIWRATH, Species.POLITOED ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.INCINEROAR, Species.GRIMMSNARL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = p.species.speciesId === Species.INCINEROAR ? 2 : 0; // Intimidate Incineroar, Prankster Grimmsnarl - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.TERAPAGOS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.URSALUNA, Species.BLOODMOON_URSALUNA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.OGERPON ], TrainerSlot.TRAINER, true, p => { - p.formIndex = Utils.randSeedInt(4); // Random Ogerpon Tera Mask - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.IVY_CUDGEL)) { // Check if Ivy Cudgel is in the moveset, if not, replace the first move with Ivy Cudgel. - p.moveset[0] = new PokemonMove(Moves.IVY_CUDGEL); - } - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.HYDRAPPLE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.setBoss(true, 2); - })) + [TrainerType.KIERAN]: new TrainerConfig(++t) + .initForChampion(true) + .setMixedBattleBgm("battle_champion_kieran") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.POLIWRATH, Species.POLITOED], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.INCINEROAR, Species.GRIMMSNARL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = p.species.speciesId === Species.INCINEROAR ? 2 : 0; // Intimidate Incineroar, Prankster Grimmsnarl + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.TERAPAGOS], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.URSALUNA, Species.BLOODMOON_URSALUNA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.OGERPON], TrainerSlot.TRAINER, true, p => { + p.formIndex = Utils.randSeedInt(4); // Random Ogerpon Tera Mask + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.IVY_CUDGEL)) { + // Check if Ivy Cudgel is in the moveset, if not, replace the first move with Ivy Cudgel. + p.moveset[0] = new PokemonMove(Moves.IVY_CUDGEL); + } + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.HYDRAPPLE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.setBoss(true, 2); + }), + ) .setInstantTera(4), // Tera Ogerpon - [TrainerType.RIVAL]: new TrainerConfig((t = TrainerType.RIVAL)).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL) - .setModifierRewardFuncs(() => modifierTypes.SUPER_EXP_CHARM, () => modifierTypes.EXP_SHARE) - .setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM, () => modifierTypes.ABILITY_CHARM, () => modifierTypes.CATCHING_CHARM) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, Species.TREECKO, Species.TORCHIC, Species.MUDKIP, Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, Species.SNIVY, Species.TEPIG, Species.OSHAWOTT, Species.CHESPIN, Species.FENNEKIN, Species.FROAKIE, Species.ROWLET, Species.LITTEN, Species.POPPLIO, Species.GROOKEY, Species.SCORBUNNY, Species.SOBBLE, Species.SPRIGATITO, Species.FUECOCO, Species.QUAXLY ], TrainerSlot.TRAINER, true, - (p => p.abilityIndex = 0))) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEY, Species.HOOTHOOT, Species.TAILLOW, Species.STARLY, Species.PIDOVE, Species.FLETCHLING, Species.PIKIPEK, Species.ROOKIDEE, Species.WATTREL ], TrainerSlot.TRAINER, true)), - [TrainerType.RIVAL_2]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_2) + [TrainerType.RIVAL]: new TrainerConfig((t = TrainerType.RIVAL)) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setStaticParty() + .setEncounterBgm(TrainerType.RIVAL) + .setBattleBgm("battle_rival") + .setMixedBattleBgm("battle_rival") + .setPartyTemplates(trainerPartyTemplates.RIVAL) + .setModifierRewardFuncs( + () => modifierTypes.SUPER_EXP_CHARM, + () => modifierTypes.EXP_SHARE, + ) + .setEventModifierRewardFuncs( + () => modifierTypes.SHINY_CHARM, + () => modifierTypes.ABILITY_CHARM, + () => modifierTypes.CATCHING_CHARM, + ) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.BULBASAUR, + Species.CHARMANDER, + Species.SQUIRTLE, + Species.CHIKORITA, + Species.CYNDAQUIL, + Species.TOTODILE, + Species.TREECKO, + Species.TORCHIC, + Species.MUDKIP, + Species.TURTWIG, + Species.CHIMCHAR, + Species.PIPLUP, + Species.SNIVY, + Species.TEPIG, + Species.OSHAWOTT, + Species.CHESPIN, + Species.FENNEKIN, + Species.FROAKIE, + Species.ROWLET, + Species.LITTEN, + Species.POPPLIO, + Species.GROOKEY, + Species.SCORBUNNY, + Species.SOBBLE, + Species.SPRIGATITO, + Species.FUECOCO, + Species.QUAXLY, + ], + TrainerSlot.TRAINER, + true, + p => (p.abilityIndex = 0), + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEY, + Species.HOOTHOOT, + Species.TAILLOW, + Species.STARLY, + Species.PIDOVE, + Species.FLETCHLING, + Species.PIKIPEK, + Species.ROOKIDEE, + Species.WATTREL, + ], + TrainerSlot.TRAINER, + true, + ), + ), + [TrainerType.RIVAL_2]: new TrainerConfig(++t) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setStaticParty() + .setMoneyMultiplier(1.25) + .setEncounterBgm(TrainerType.RIVAL) + .setBattleBgm("battle_rival") + .setMixedBattleBgm("battle_rival") + .setPartyTemplates(trainerPartyTemplates.RIVAL_2) .setModifierRewardFuncs(() => modifierTypes.EXP_SHARE) .setEventModifierRewardFuncs(() => modifierTypes.SHINY_CHARM) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.IVYSAUR, Species.CHARMELEON, Species.WARTORTLE, Species.BAYLEEF, Species.QUILAVA, Species.CROCONAW, Species.GROVYLE, Species.COMBUSKEN, Species.MARSHTOMP, Species.GROTLE, Species.MONFERNO, Species.PRINPLUP, Species.SERVINE, Species.PIGNITE, Species.DEWOTT, Species.QUILLADIN, Species.BRAIXEN, Species.FROGADIER, Species.DARTRIX, Species.TORRACAT, Species.BRIONNE, Species.THWACKEY, Species.RABOOT, Species.DRIZZILE, Species.FLORAGATO, Species.CROCALOR, Species.QUAXWELL ], TrainerSlot.TRAINER, true, - (p => p.abilityIndex = 0))) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOTTO, Species.HOOTHOOT, Species.TAILLOW, Species.STARAVIA, Species.TRANQUILL, Species.FLETCHINDER, Species.TRUMBEAK, Species.CORVISQUIRE, Species.WATTREL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)), - [TrainerType.RIVAL_3]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setStaticParty().setMoneyMultiplier(1.5).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival").setMixedBattleBgm("battle_rival").setPartyTemplates(trainerPartyTemplates.RIVAL_3) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, - (p => p.abilityIndex = 0))) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.IVYSAUR, + Species.CHARMELEON, + Species.WARTORTLE, + Species.BAYLEEF, + Species.QUILAVA, + Species.CROCONAW, + Species.GROVYLE, + Species.COMBUSKEN, + Species.MARSHTOMP, + Species.GROTLE, + Species.MONFERNO, + Species.PRINPLUP, + Species.SERVINE, + Species.PIGNITE, + Species.DEWOTT, + Species.QUILLADIN, + Species.BRAIXEN, + Species.FROGADIER, + Species.DARTRIX, + Species.TORRACAT, + Species.BRIONNE, + Species.THWACKEY, + Species.RABOOT, + Species.DRIZZILE, + Species.FLORAGATO, + Species.CROCALOR, + Species.QUAXWELL, + ], + TrainerSlot.TRAINER, + true, + p => (p.abilityIndex = 0), + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEOTTO, + Species.HOOTHOOT, + Species.TAILLOW, + Species.STARAVIA, + Species.TRANQUILL, + Species.FLETCHINDER, + Species.TRUMBEAK, + Species.CORVISQUIRE, + Species.WATTREL, + ], + TrainerSlot.TRAINER, + true, + ), + ) + .setPartyMemberFunc( + 2, + getSpeciesFilterRandomPartyMemberFunc( + (species: PokemonSpecies) => + !pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + species.baseTotal >= 450, + ), + ), + [TrainerType.RIVAL_3]: new TrainerConfig(++t) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setStaticParty() + .setMoneyMultiplier(1.5) + .setEncounterBgm(TrainerType.RIVAL) + .setBattleBgm("battle_rival") + .setMixedBattleBgm("battle_rival") + .setPartyTemplates(trainerPartyTemplates.RIVAL_3) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.VENUSAUR, + Species.CHARIZARD, + Species.BLASTOISE, + Species.MEGANIUM, + Species.TYPHLOSION, + Species.FERALIGATR, + Species.SCEPTILE, + Species.BLAZIKEN, + Species.SWAMPERT, + Species.TORTERRA, + Species.INFERNAPE, + Species.EMPOLEON, + Species.SERPERIOR, + Species.EMBOAR, + Species.SAMUROTT, + Species.CHESNAUGHT, + Species.DELPHOX, + Species.GRENINJA, + Species.DECIDUEYE, + Species.INCINEROAR, + Species.PRIMARINA, + Species.RILLABOOM, + Species.CINDERACE, + Species.INTELEON, + Species.MEOWSCARADA, + Species.SKELEDIRGE, + Species.QUAQUAVAL, + ], + TrainerSlot.TRAINER, + true, + p => (p.abilityIndex = 0), + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEOT, + Species.NOCTOWL, + Species.SWELLOW, + Species.STARAPTOR, + Species.UNFEZANT, + Species.TALONFLAME, + Species.TOUCANNON, + Species.CORVIKNIGHT, + Species.KILOWATTREL, + ], + TrainerSlot.TRAINER, + true, + ), + ) + .setPartyMemberFunc( + 2, + getSpeciesFilterRandomPartyMemberFunc( + (species: PokemonSpecies) => + !pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + species.baseTotal >= 450, + ), + ) .setSpeciesFilter(species => species.baseTotal >= 540), - [TrainerType.RIVAL_4]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(1.75).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_2").setMixedBattleBgm("battle_rival_2").setPartyTemplates(trainerPartyTemplates.RIVAL_4) + [TrainerType.RIVAL_4]: new TrainerConfig(++t) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setBoss() + .setStaticParty() + .setMoneyMultiplier(1.75) + .setEncounterBgm(TrainerType.RIVAL) + .setBattleBgm("battle_rival_2") + .setMixedBattleBgm("battle_rival_2") + .setPartyTemplates(trainerPartyTemplates.RIVAL_4) .setModifierRewardFuncs(() => modifierTypes.TERA_ORB) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, - (p => { - p.abilityIndex = 0; - p.teraType = p.species.type1; - }))) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.VENUSAUR, + Species.CHARIZARD, + Species.BLASTOISE, + Species.MEGANIUM, + Species.TYPHLOSION, + Species.FERALIGATR, + Species.SCEPTILE, + Species.BLAZIKEN, + Species.SWAMPERT, + Species.TORTERRA, + Species.INFERNAPE, + Species.EMPOLEON, + Species.SERPERIOR, + Species.EMBOAR, + Species.SAMUROTT, + Species.CHESNAUGHT, + Species.DELPHOX, + Species.GRENINJA, + Species.DECIDUEYE, + Species.INCINEROAR, + Species.PRIMARINA, + Species.RILLABOOM, + Species.CINDERACE, + Species.INTELEON, + Species.MEOWSCARADA, + Species.SKELEDIRGE, + Species.QUAQUAVAL, + ], + TrainerSlot.TRAINER, + true, + p => { + p.abilityIndex = 0; + p.teraType = p.species.type1; + }, + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEOT, + Species.NOCTOWL, + Species.SWELLOW, + Species.STARAPTOR, + Species.UNFEZANT, + Species.TALONFLAME, + Species.TOUCANNON, + Species.CORVIKNIGHT, + Species.KILOWATTREL, + ], + TrainerSlot.TRAINER, + true, + ), + ) + .setPartyMemberFunc( + 2, + getSpeciesFilterRandomPartyMemberFunc( + (species: PokemonSpecies) => + !pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + species.baseTotal >= 450, + ), + ) .setSpeciesFilter(species => species.baseTotal >= 540) .setInstantTera(0), // Tera starter to primary type - [TrainerType.RIVAL_5]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(2.25).setEncounterBgm(TrainerType.RIVAL).setBattleBgm("battle_rival_3").setMixedBattleBgm("battle_rival_3").setPartyTemplates(trainerPartyTemplates.RIVAL_5) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, - p => { - p.setBoss(true, 2); - p.abilityIndex = 0; - p.teraType = p.species.type1; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) + [TrainerType.RIVAL_5]: new TrainerConfig(++t) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setBoss() + .setStaticParty() + .setMoneyMultiplier(2.25) + .setEncounterBgm(TrainerType.RIVAL) + .setBattleBgm("battle_rival_3") + .setMixedBattleBgm("battle_rival_3") + .setPartyTemplates(trainerPartyTemplates.RIVAL_5) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.VENUSAUR, + Species.CHARIZARD, + Species.BLASTOISE, + Species.MEGANIUM, + Species.TYPHLOSION, + Species.FERALIGATR, + Species.SCEPTILE, + Species.BLAZIKEN, + Species.SWAMPERT, + Species.TORTERRA, + Species.INFERNAPE, + Species.EMPOLEON, + Species.SERPERIOR, + Species.EMBOAR, + Species.SAMUROTT, + Species.CHESNAUGHT, + Species.DELPHOX, + Species.GRENINJA, + Species.DECIDUEYE, + Species.INCINEROAR, + Species.PRIMARINA, + Species.RILLABOOM, + Species.CINDERACE, + Species.INTELEON, + Species.MEOWSCARADA, + Species.SKELEDIRGE, + Species.QUAQUAVAL, + ], + TrainerSlot.TRAINER, + true, + p => { + p.setBoss(true, 2); + p.abilityIndex = 0; + p.teraType = p.species.type1; + }, + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEOT, + Species.NOCTOWL, + Species.SWELLOW, + Species.STARAPTOR, + Species.UNFEZANT, + Species.TALONFLAME, + Species.TOUCANNON, + Species.CORVIKNIGHT, + Species.KILOWATTREL, + ], + TrainerSlot.TRAINER, + true, + ), + ) + .setPartyMemberFunc( + 2, + getSpeciesFilterRandomPartyMemberFunc( + (species: PokemonSpecies) => + !pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + species.baseTotal >= 450, + ), + ) .setSpeciesFilter(species => species.baseTotal >= 540) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.RAYQUAZA ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 3); - p.pokeball = PokeballType.MASTER_BALL; - p.shiny = true; - p.variant = 1; - })) - .setInstantTera(0), // Tera starter to primary type - [TrainerType.RIVAL_6]: new TrainerConfig(++t).setName("Finn").setHasGenders("Ivy").setHasCharSprite().setTitle("Rival").setBoss().setStaticParty().setMoneyMultiplier(3).setEncounterBgm("final").setBattleBgm("battle_rival_3").setMixedBattleBgm("battle_rival_3").setPartyTemplates(trainerPartyTemplates.RIVAL_6) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, - p => { + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.RAYQUAZA], TrainerSlot.TRAINER, true, p => { p.setBoss(true, 3); - p.abilityIndex = 0; - p.teraType = p.species.type1; - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true, - p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) + p.pokeball = PokeballType.MASTER_BALL; + p.shiny = true; + p.variant = 1; + }), + ) + .setInstantTera(0), // Tera starter to primary type + [TrainerType.RIVAL_6]: new TrainerConfig(++t) + .setName("Finn") + .setHasGenders("Ivy") + .setHasCharSprite() + .setTitle("Rival") + .setBoss() + .setStaticParty() + .setMoneyMultiplier(3) + .setEncounterBgm("final") + .setBattleBgm("battle_rival_3") + .setMixedBattleBgm("battle_rival_3") + .setPartyTemplates(trainerPartyTemplates.RIVAL_6) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc( + [ + Species.VENUSAUR, + Species.CHARIZARD, + Species.BLASTOISE, + Species.MEGANIUM, + Species.TYPHLOSION, + Species.FERALIGATR, + Species.SCEPTILE, + Species.BLAZIKEN, + Species.SWAMPERT, + Species.TORTERRA, + Species.INFERNAPE, + Species.EMPOLEON, + Species.SERPERIOR, + Species.EMBOAR, + Species.SAMUROTT, + Species.CHESNAUGHT, + Species.DELPHOX, + Species.GRENINJA, + Species.DECIDUEYE, + Species.INCINEROAR, + Species.PRIMARINA, + Species.RILLABOOM, + Species.CINDERACE, + Species.INTELEON, + Species.MEOWSCARADA, + Species.SKELEDIRGE, + Species.QUAQUAVAL, + ], + TrainerSlot.TRAINER, + true, + p => { + p.setBoss(true, 3); + p.abilityIndex = 0; + p.teraType = p.species.type1; + p.generateAndPopulateMoveset(); + }, + ), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc( + [ + Species.PIDGEOT, + Species.NOCTOWL, + Species.SWELLOW, + Species.STARAPTOR, + Species.UNFEZANT, + Species.TALONFLAME, + Species.TOUCANNON, + Species.CORVIKNIGHT, + Species.KILOWATTREL, + ], + TrainerSlot.TRAINER, + true, + p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + }, + ), + ) + .setPartyMemberFunc( + 2, + getSpeciesFilterRandomPartyMemberFunc( + (species: PokemonSpecies) => + !pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + species.baseTotal >= 450, + ), + ) .setSpeciesFilter(species => species.baseTotal >= 540) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.RAYQUAZA ], TrainerSlot.TRAINER, true, p => { - p.setBoss(); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - p.shiny = true; - p.variant = 1; - p.formIndex = 1; // Mega Rayquaza - p.generateName(); - })) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.RAYQUAZA], TrainerSlot.TRAINER, true, p => { + p.setBoss(); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + p.shiny = true; + p.variant = 1; + p.formIndex = 1; // Mega Rayquaza + p.generateName(); + }), + ) .setInstantTera(0), // Tera starter to primary type - [TrainerType.ROCKET_BOSS_GIOVANNI_1]: new TrainerConfig(t = TrainerType.ROCKET_BOSS_GIOVANNI_1).setName("Giovanni").initForEvilTeamLeader("Rocket Boss", []).setMixedBattleBgm("battle_rocket_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.PERSIAN ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.DUGTRIO, Species.ALOLA_DUGTRIO ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.HONCHKROW ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.NIDOQUEEN, Species.NIDOKING ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.RHYPERIOR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.abilityIndex = 1; // Solid Rock - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.KANGASKHAN ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Kangaskhan - p.generateName(); - })), - [TrainerType.ROCKET_BOSS_GIOVANNI_2]: new TrainerConfig(++t).setName("Giovanni").initForEvilTeamLeader("Rocket Boss", [], true).setMixedBattleBgm("battle_rocket_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.TYRANITAR ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.GASTRODON, Species.SEISMITOAD ], TrainerSlot.TRAINER, true, p => { - if (p.species.speciesId === Species.GASTRODON) { - p.abilityIndex = 0; // Storm Drain - } else if (p.species.speciesId === Species.SEISMITOAD) { - p.abilityIndex = 2; // Water Absorb - } - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.GARCHOMP, Species.EXCADRILL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - if (p.species.speciesId === Species.GARCHOMP) { - p.abilityIndex = 2; // Rough Skin - } else if (p.species.speciesId === Species.EXCADRILL) { - p.abilityIndex = 0; // Sand Rush - } - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.RHYPERIOR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.abilityIndex = 1; // Solid Rock - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.KANGASKHAN ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Kangaskhan - p.generateName(); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.MEWTWO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.MAXIE]: new TrainerConfig(++t).setName("Maxie").initForEvilTeamLeader("Magma Boss", []).setMixedBattleBgm("battle_aqua_magma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.SOLROCK ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.TALONFLAME ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.WEEZING, Species.GALAR_WEEZING ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.TORKOAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Drought - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.DONPHAN ])) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.CAMERUPT ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Camerupt - p.generateName(); - p.gender = Gender.MALE; - })), - [TrainerType.MAXIE_2]: new TrainerConfig(++t).setName("Maxie").initForEvilTeamLeader("Magma Boss", [], true).setMixedBattleBgm("battle_aqua_magma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.TYPHLOSION, Species.SOLROCK ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.NINETALES, Species.TORKOAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.NINETALES) { - p.abilityIndex = 2; // Drought - } else if (p.species.speciesId === Species.TORKOAL) { - p.abilityIndex = 1; // Drought - } - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SCOVILLAIN ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 0; // Chlorophyll - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GREAT_TUSK ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.CAMERUPT ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Camerupt - p.generateName(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.GROUDON ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.ARCHIE]: new TrainerConfig(++t).setName("Archie").initForEvilTeamLeader("Aqua Boss", []).setMixedBattleBgm("battle_aqua_magma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.LUDICOLO ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PELIPPER ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Drizzle - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.MUK, Species.ALOLA_MUK ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.WAILORD ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.QWILFISH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Swift Swim - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.SHARPEDO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Sharpedo - p.generateName(); - p.gender = Gender.MALE; - })), - [TrainerType.ARCHIE_2]: new TrainerConfig(++t).setName("Archie").initForEvilTeamLeader("Aqua Boss", [], true).setMixedBattleBgm("battle_aqua_magma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.LUDICOLO, Species.EMPOLEON ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.POLITOED, Species.PELIPPER ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.POLITOED) { - p.abilityIndex = 2; // Drizzle - } else if (p.species.speciesId === Species.PELIPPER) { - p.abilityIndex = 1; // Drizzle - } - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.DHELMISE ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.OVERQWIL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Swift Swim - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.SHARPEDO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Sharpedo - p.generateName(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.KYOGRE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.CYRUS]: new TrainerConfig(++t).setName("Cyrus").initForEvilTeamLeader("Galactic Boss", []).setMixedBattleBgm("battle_galactic_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.GYARADOS ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.HONCHKROW, Species.HISUI_BRAVIARY ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.MAGNEZONE ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.UXIE, Species.MESPRIT, Species.AZELF ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.HOUNDOOM ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Houndoom - p.generateName(); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.WEAVILE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.gender = Gender.MALE; - })), - [TrainerType.CYRUS_2]: new TrainerConfig(++t).setName("Cyrus").initForEvilTeamLeader("Galactic Boss", [], true).setMixedBattleBgm("battle_galactic_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.CROBAT ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.MAGNEZONE ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.UXIE, Species.MESPRIT, Species.AZELF ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.HOUNDOOM ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Houndoom - p.generateName(); - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.WEAVILE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.DIALGA, Species.PALKIA ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.GHETSIS]: new TrainerConfig(++t).setName("Ghetsis").initForEvilTeamLeader("Plasma Boss", []).setMixedBattleBgm("battle_plasma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.COFAGRIGUS ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.SEISMITOAD ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.GALVANTULA, Species.EELEKTROSS ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.DRAPION, Species.TOXICROAK ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.KINGAMBIT ])) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.HYDREIGON ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.gender = Gender.MALE; - })), - [TrainerType.GHETSIS_2]: new TrainerConfig(++t).setName("Ghetsis").initForEvilTeamLeader("Plasma Boss", [], true).setMixedBattleBgm("battle_plasma_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.RUNERIGUS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.JELLICENT, Species.BASCULEGION ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - p.formIndex = 0; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.KINGAMBIT ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.VOLCARONA, Species.IRON_MOTH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.HYDREIGON, Species.IRON_JUGULIS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - if (p.species.speciesId === Species.HYDREIGON) { + [TrainerType.ROCKET_BOSS_GIOVANNI_1]: new TrainerConfig((t = TrainerType.ROCKET_BOSS_GIOVANNI_1)) + .setName("Giovanni") + .initForEvilTeamLeader("Rocket Boss", []) + .setMixedBattleBgm("battle_rocket_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.PERSIAN], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); p.gender = Gender.MALE; - } else if (p.species.speciesId === Species.IRON_JUGULIS) { - p.gender = Gender.GENDERLESS; - } - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.KYUREM ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.LYSANDRE]: new TrainerConfig(++t).setName("Lysandre").initForEvilTeamLeader("Flare Boss", []).setMixedBattleBgm("battle_flare_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.MIENSHAO ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.HONCHKROW, Species.TALONFLAME ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.PYROAR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.DRAGALGE, Species.CLAWITZER ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.DRAGALGE) { - p.abilityIndex = 2; // Adaptability - } else if (p.species.speciesId === Species.CLAWITZER) { - p.abilityIndex = 0; // Mega Launcher - } - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GALLADE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Sharpness - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.GYARADOS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Gyarados - p.generateName(); - p.gender = Gender.MALE; - })), - [TrainerType.LYSANDRE_2]: new TrainerConfig(++t).setName("Lysandre").initForEvilTeamLeader("Flare Boss", [], true).setMixedBattleBgm("battle_flare_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.PYROAR ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.DRAGALGE, Species.CLAWITZER ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.DRAGALGE) { - p.abilityIndex = 2; // Adaptability - } else if (p.species.speciesId === Species.CLAWITZER) { - p.abilityIndex = 0; // Mega Launcher - } - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.AEGISLASH, Species.HISUI_GOODRA ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.IRON_VALIANT ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GYARADOS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = 1; // Mega Gyarados - p.generateName(); - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.ZYGARDE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - p.formIndex = 0; // 50% Forme, Aura Break - })), - [TrainerType.LUSAMINE]: new TrainerConfig(++t).setName("Lusamine").initForEvilTeamLeader("Aether Boss", []).setMixedBattleBgm("battle_aether_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.CLEFABLE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.LILLIGANT, Species.HISUI_LILLIGANT ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.MILOTIC, Species.PRIMARINA ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GALAR_SLOWBRO, Species.GALAR_SLOWKING ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.BEWEAR ])) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.NIHILEGO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })), - [TrainerType.LUSAMINE_2]: new TrainerConfig(++t).setName("Lusamine").initForEvilTeamLeader("Aether Boss", [], true).setMixedBattleBgm("battle_aether_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.CLEFABLE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.MILOTIC, Species.PRIMARINA ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SILVALLY ], TrainerSlot.TRAINER, true, p => { - p.formIndex = Utils.randSeedInt(18); // Random Silvally Form - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.MULTI_ATTACK)) { // Check if Multi Attack is in the moveset, if not, replace the first move with Multi Attack. - p.moveset[0] = new PokemonMove(Moves.MULTI_ATTACK); - } - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.PHEROMOSA ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.NIHILEGO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.NECROZMA ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.formIndex = 2; // Dawn Wings - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.GUZMA]: new TrainerConfig(++t).setName("Guzma").initForEvilTeamLeader("Skull Boss", []).setMixedBattleBgm("battle_skull_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.YANMEGA, Species.LOKIX ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.YANMEGA) { - p.abilityIndex = 1; // Tinted Lens - } else if (p.species.speciesId === Species.LOKIX) { - p.abilityIndex = 2; // Tinted Lens - } - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.HERACROSS ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SCIZOR, Species.KLEAVOR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.SCIZOR) { - p.abilityIndex = 1; // Technician - } else if (p.species.speciesId === Species.KLEAVOR) { - p.abilityIndex = 2; // Sharpness - } - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GALVANTULA, Species.VIKAVOLT ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.PINSIR ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 1; // Mega Pinsir - p.pokeball = PokeballType.ULTRA_BALL; - p.generateName(); - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.GOLISOPOD ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.gender = Gender.MALE; - })), - [TrainerType.GUZMA_2]: new TrainerConfig(++t).setName("Guzma").initForEvilTeamLeader("Skull Boss", [], true).setMixedBattleBgm("battle_skull_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.GOLISOPOD ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.abilityIndex = 2; // Anticipation - p.gender = Gender.MALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.BUZZWOLE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.CRAWDAUNT, Species.HISUI_SAMUROTT ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 2; // Sharpness Hisuian Samurott, Adaptability Crawdaunt - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.XURKITREE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GENESECT ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.formIndex = Utils.randSeedInt(4, 1); // Shock, Burn, Chill, or Douse Drive - if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.TECHNO_BLAST)) { // Check if Techno Blast is in the moveset, if not, replace the first move with Techno Blast. - p.moveset[0] = new PokemonMove(Moves.TECHNO_BLAST); - } - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.PINSIR ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.formIndex = 1; // Mega Pinsir - p.generateAndPopulateMoveset(); - p.generateName(); - p.pokeball = PokeballType.ULTRA_BALL; - })), - [TrainerType.ROSE]: new TrainerConfig(++t).setName("Rose").initForEvilTeamLeader("Macro Boss", []).setMixedBattleBgm("battle_macro_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ARCHALUDON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.ESCAVALIER, Species.FERROTHORN ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.SIRFETCHD, Species.MR_RIME ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.CORVIKNIGHT ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.KLINKLANG, Species.PERRSERKER ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.COPPERAJAH ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 1; // G-Max Copperajah - p.generateName(); - p.pokeball = PokeballType.ULTRA_BALL; - p.gender = Gender.FEMALE; - })), - [TrainerType.ROSE_2]: new TrainerConfig(++t).setName("Rose").initForEvilTeamLeader("Macro Boss", [], true).setMixedBattleBgm("battle_macro_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ARCHALUDON ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.AEGISLASH, Species.GHOLDENGO ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.DRACOZOLT, Species.DRACOVISH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - p.abilityIndex = 1; // Strong Jaw Dracovish, Hustle Dracozolt - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.MELMETAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GALAR_ARTICUNO, Species.GALAR_ZAPDOS, Species.GALAR_MOLTRES ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.COPPERAJAH ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 1; // G-Max Copperajah - p.generateName(); - p.pokeball = PokeballType.ULTRA_BALL; - p.gender = Gender.FEMALE; - })), - [TrainerType.PENNY]: new TrainerConfig(++t).setName("Cassiopeia").initForEvilTeamLeader("Star Boss", []).setMixedBattleBgm("battle_star_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.JOLTEON, Species.LEAFEON ])) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.VAPOREON, Species.UMBREON ])) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.ESPEON, Species.GLACEON ])) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.FLAREON ])) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.SYLVEON ], TrainerSlot.TRAINER, true, p => { - p.abilityIndex = 2; // Pixilate - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.EEVEE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 2; // G-Max Eevee - p.pokeball = PokeballType.ULTRA_BALL; - p.generateName(); - })) + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.DUGTRIO, Species.ALOLA_DUGTRIO])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.HONCHKROW])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.NIDOQUEEN, Species.NIDOKING])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.RHYPERIOR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.abilityIndex = 1; // Solid Rock + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.KANGASKHAN], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Kangaskhan + p.generateName(); + }), + ), + [TrainerType.ROCKET_BOSS_GIOVANNI_2]: new TrainerConfig(++t) + .setName("Giovanni") + .initForEvilTeamLeader("Rocket Boss", [], true) + .setMixedBattleBgm("battle_rocket_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.TYRANITAR], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.GASTRODON, Species.SEISMITOAD], TrainerSlot.TRAINER, true, p => { + if (p.species.speciesId === Species.GASTRODON) { + p.abilityIndex = 0; // Storm Drain + } else if (p.species.speciesId === Species.SEISMITOAD) { + p.abilityIndex = 2; // Water Absorb + } + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.GARCHOMP, Species.EXCADRILL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + if (p.species.speciesId === Species.GARCHOMP) { + p.abilityIndex = 2; // Rough Skin + } else if (p.species.speciesId === Species.EXCADRILL) { + p.abilityIndex = 0; // Sand Rush + } + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.RHYPERIOR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.abilityIndex = 1; // Solid Rock + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.KANGASKHAN], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Kangaskhan + p.generateName(); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.MEWTWO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.MAXIE]: new TrainerConfig(++t) + .setName("Maxie") + .initForEvilTeamLeader("Magma Boss", []) + .setMixedBattleBgm("battle_aqua_magma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.SOLROCK])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.TALONFLAME])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.WEEZING, Species.GALAR_WEEZING])) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.TORKOAL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Drought + }), + ) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.DONPHAN])) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.CAMERUPT], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Camerupt + p.generateName(); + p.gender = Gender.MALE; + }), + ), + [TrainerType.MAXIE_2]: new TrainerConfig(++t) + .setName("Maxie") + .initForEvilTeamLeader("Magma Boss", [], true) + .setMixedBattleBgm("battle_aqua_magma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.TYPHLOSION, Species.SOLROCK], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.NINETALES, Species.TORKOAL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.NINETALES) { + p.abilityIndex = 2; // Drought + } else if (p.species.speciesId === Species.TORKOAL) { + p.abilityIndex = 1; // Drought + } + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SCOVILLAIN], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 0; // Chlorophyll + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.GREAT_TUSK], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.CAMERUPT], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Camerupt + p.generateName(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.GROUDON], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.ARCHIE]: new TrainerConfig(++t) + .setName("Archie") + .initForEvilTeamLeader("Aqua Boss", []) + .setMixedBattleBgm("battle_aqua_magma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.LUDICOLO])) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.PELIPPER], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Drizzle + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.MUK, Species.ALOLA_MUK])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.WAILORD])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.QWILFISH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Swift Swim + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.SHARPEDO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Sharpedo + p.generateName(); + p.gender = Gender.MALE; + }), + ), + [TrainerType.ARCHIE_2]: new TrainerConfig(++t) + .setName("Archie") + .initForEvilTeamLeader("Aqua Boss", [], true) + .setMixedBattleBgm("battle_aqua_magma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.LUDICOLO, Species.EMPOLEON], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.POLITOED, Species.PELIPPER], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.POLITOED) { + p.abilityIndex = 2; // Drizzle + } else if (p.species.speciesId === Species.PELIPPER) { + p.abilityIndex = 1; // Drizzle + } + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.DHELMISE])) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.OVERQWIL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Swift Swim + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.SHARPEDO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Sharpedo + p.generateName(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.KYOGRE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.CYRUS]: new TrainerConfig(++t) + .setName("Cyrus") + .initForEvilTeamLeader("Galactic Boss", []) + .setMixedBattleBgm("battle_galactic_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.GYARADOS])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.HONCHKROW, Species.HISUI_BRAVIARY])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.MAGNEZONE])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.UXIE, Species.MESPRIT, Species.AZELF])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.HOUNDOOM], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Houndoom + p.generateName(); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.WEAVILE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.gender = Gender.MALE; + }), + ), + [TrainerType.CYRUS_2]: new TrainerConfig(++t) + .setName("Cyrus") + .initForEvilTeamLeader("Galactic Boss", [], true) + .setMixedBattleBgm("battle_galactic_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.CROBAT], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.MAGNEZONE])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.UXIE, Species.MESPRIT, Species.AZELF], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.HOUNDOOM], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Houndoom + p.generateName(); + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.WEAVILE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.DIALGA, Species.PALKIA], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.GHETSIS]: new TrainerConfig(++t) + .setName("Ghetsis") + .initForEvilTeamLeader("Plasma Boss", []) + .setMixedBattleBgm("battle_plasma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.COFAGRIGUS])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.SEISMITOAD])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.GALVANTULA, Species.EELEKTROSS])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.DRAPION, Species.TOXICROAK])) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.KINGAMBIT])) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.HYDREIGON], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.gender = Gender.MALE; + }), + ), + [TrainerType.GHETSIS_2]: new TrainerConfig(++t) + .setName("Ghetsis") + .initForEvilTeamLeader("Plasma Boss", [], true) + .setMixedBattleBgm("battle_plasma_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.RUNERIGUS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.JELLICENT, Species.BASCULEGION], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + p.formIndex = 0; + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.KINGAMBIT])) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.VOLCARONA, Species.IRON_MOTH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.HYDREIGON, Species.IRON_JUGULIS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + if (p.species.speciesId === Species.HYDREIGON) { + p.gender = Gender.MALE; + } else if (p.species.speciesId === Species.IRON_JUGULIS) { + p.gender = Gender.GENDERLESS; + } + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.KYUREM], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.LYSANDRE]: new TrainerConfig(++t) + .setName("Lysandre") + .initForEvilTeamLeader("Flare Boss", []) + .setMixedBattleBgm("battle_flare_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.MIENSHAO])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.HONCHKROW, Species.TALONFLAME])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.PYROAR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.DRAGALGE, Species.CLAWITZER], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.DRAGALGE) { + p.abilityIndex = 2; // Adaptability + } else if (p.species.speciesId === Species.CLAWITZER) { + p.abilityIndex = 0; // Mega Launcher + } + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.GALLADE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Sharpness + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.GYARADOS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Gyarados + p.generateName(); + p.gender = Gender.MALE; + }), + ), + [TrainerType.LYSANDRE_2]: new TrainerConfig(++t) + .setName("Lysandre") + .initForEvilTeamLeader("Flare Boss", [], true) + .setMixedBattleBgm("battle_flare_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.PYROAR], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.DRAGALGE, Species.CLAWITZER], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.DRAGALGE) { + p.abilityIndex = 2; // Adaptability + } else if (p.species.speciesId === Species.CLAWITZER) { + p.abilityIndex = 0; // Mega Launcher + } + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.AEGISLASH, Species.HISUI_GOODRA])) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.IRON_VALIANT], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.GYARADOS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = 1; // Mega Gyarados + p.generateName(); + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.ZYGARDE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + p.formIndex = 0; // 50% Forme, Aura Break + }), + ), + [TrainerType.LUSAMINE]: new TrainerConfig(++t) + .setName("Lusamine") + .initForEvilTeamLeader("Aether Boss", []) + .setMixedBattleBgm("battle_aether_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.CLEFABLE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.LILLIGANT, Species.HISUI_LILLIGANT])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.MILOTIC, Species.PRIMARINA])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.GALAR_SLOWBRO, Species.GALAR_SLOWKING])) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.BEWEAR])) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.NIHILEGO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ), + [TrainerType.LUSAMINE_2]: new TrainerConfig(++t) + .setName("Lusamine") + .initForEvilTeamLeader("Aether Boss", [], true) + .setMixedBattleBgm("battle_aether_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.CLEFABLE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.MILOTIC, Species.PRIMARINA])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SILVALLY], TrainerSlot.TRAINER, true, p => { + p.formIndex = Utils.randSeedInt(18); // Random Silvally Form + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.MULTI_ATTACK)) { + // Check if Multi Attack is in the moveset, if not, replace the first move with Multi Attack. + p.moveset[0] = new PokemonMove(Moves.MULTI_ATTACK); + } + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.PHEROMOSA], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.NIHILEGO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.NECROZMA], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.formIndex = 2; // Dawn Wings + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.GUZMA]: new TrainerConfig(++t) + .setName("Guzma") + .initForEvilTeamLeader("Skull Boss", []) + .setMixedBattleBgm("battle_skull_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.YANMEGA, Species.LOKIX], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.YANMEGA) { + p.abilityIndex = 1; // Tinted Lens + } else if (p.species.speciesId === Species.LOKIX) { + p.abilityIndex = 2; // Tinted Lens + } + }), + ) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.HERACROSS])) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SCIZOR, Species.KLEAVOR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.SCIZOR) { + p.abilityIndex = 1; // Technician + } else if (p.species.speciesId === Species.KLEAVOR) { + p.abilityIndex = 2; // Sharpness + } + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.GALVANTULA, Species.VIKAVOLT])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.PINSIR], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 1; // Mega Pinsir + p.pokeball = PokeballType.ULTRA_BALL; + p.generateName(); + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.GOLISOPOD], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.gender = Gender.MALE; + }), + ), + [TrainerType.GUZMA_2]: new TrainerConfig(++t) + .setName("Guzma") + .initForEvilTeamLeader("Skull Boss", [], true) + .setMixedBattleBgm("battle_skull_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.GOLISOPOD], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.abilityIndex = 2; // Anticipation + p.gender = Gender.MALE; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.BUZZWOLE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.CRAWDAUNT, Species.HISUI_SAMUROTT], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 2; // Sharpness Hisuian Samurott, Adaptability Crawdaunt + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.XURKITREE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.GENESECT], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.formIndex = Utils.randSeedInt(4, 1); // Shock, Burn, Chill, or Douse Drive + if (!p.moveset.some(move => !Utils.isNullOrUndefined(move) && move.moveId === Moves.TECHNO_BLAST)) { + // Check if Techno Blast is in the moveset, if not, replace the first move with Techno Blast. + p.moveset[0] = new PokemonMove(Moves.TECHNO_BLAST); + } + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.PINSIR], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.formIndex = 1; // Mega Pinsir + p.generateAndPopulateMoveset(); + p.generateName(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ), + [TrainerType.ROSE]: new TrainerConfig(++t) + .setName("Rose") + .initForEvilTeamLeader("Macro Boss", []) + .setMixedBattleBgm("battle_macro_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.ARCHALUDON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.ESCAVALIER, Species.FERROTHORN], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.SIRFETCHD, Species.MR_RIME], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.CORVIKNIGHT], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.KLINKLANG, Species.PERRSERKER], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.COPPERAJAH], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 1; // G-Max Copperajah + p.generateName(); + p.pokeball = PokeballType.ULTRA_BALL; + p.gender = Gender.FEMALE; + }), + ), + [TrainerType.ROSE_2]: new TrainerConfig(++t) + .setName("Rose") + .initForEvilTeamLeader("Macro Boss", [], true) + .setMixedBattleBgm("battle_macro_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.ARCHALUDON], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.AEGISLASH, Species.GHOLDENGO], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.DRACOZOLT, Species.DRACOVISH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + p.abilityIndex = 1; // Strong Jaw Dracovish, Hustle Dracozolt + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.MELMETAL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc( + [Species.GALAR_ARTICUNO, Species.GALAR_ZAPDOS, Species.GALAR_MOLTRES], + TrainerSlot.TRAINER, + true, + p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }, + ), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.COPPERAJAH], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 1; // G-Max Copperajah + p.generateName(); + p.pokeball = PokeballType.ULTRA_BALL; + p.gender = Gender.FEMALE; + }), + ), + [TrainerType.PENNY]: new TrainerConfig(++t) + .setName("Cassiopeia") + .initForEvilTeamLeader("Star Boss", []) + .setMixedBattleBgm("battle_star_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.JOLTEON, Species.LEAFEON])) + .setPartyMemberFunc(1, getRandomPartyMemberFunc([Species.VAPOREON, Species.UMBREON])) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.ESPEON, Species.GLACEON])) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.FLAREON])) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.SYLVEON], TrainerSlot.TRAINER, true, p => { + p.abilityIndex = 2; // Pixilate + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.EEVEE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 2; // G-Max Eevee + p.pokeball = PokeballType.ULTRA_BALL; + p.generateName(); + }), + ) .setInstantTera(4), // Tera Fairy Sylveon - [TrainerType.PENNY_2]: new TrainerConfig(++t).setName("Cassiopeia").initForEvilTeamLeader("Star Boss", [], true).setMixedBattleBgm("battle_star_boss").setVictoryBgm("victory_team_plasma") - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.SYLVEON ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.abilityIndex = 2; // Pixilate - p.generateAndPopulateMoveset(); - p.gender = Gender.FEMALE; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.ROTOM ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = Utils.randSeedInt(5, 1); // Heat, Wash, Frost, Fan, or Mow - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.RAIKOU, Species.ENTEI, Species.SUICUNE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.REVAVROOM ], TrainerSlot.TRAINER, true, p => { - p.formIndex = Utils.randSeedInt(5, 1); // Random Starmobile form - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ROGUE_BALL; - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.ZAMAZENTA ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.EEVEE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 2; - p.generateName(); - p.pokeball = PokeballType.ULTRA_BALL; - })) + [TrainerType.PENNY_2]: new TrainerConfig(++t) + .setName("Cassiopeia") + .initForEvilTeamLeader("Star Boss", [], true) + .setMixedBattleBgm("battle_star_boss") + .setVictoryBgm("victory_team_plasma") + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.SYLVEON], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.abilityIndex = 2; // Pixilate + p.generateAndPopulateMoveset(); + p.gender = Gender.FEMALE; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.ROTOM], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = Utils.randSeedInt(5, 1); // Heat, Wash, Frost, Fan, or Mow + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.RAIKOU, Species.ENTEI, Species.SUICUNE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.REVAVROOM], TrainerSlot.TRAINER, true, p => { + p.formIndex = Utils.randSeedInt(5, 1); // Random Starmobile form + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ROGUE_BALL; + }), + ) + .setPartyMemberFunc( + 4, + getRandomPartyMemberFunc([Species.ZAMAZENTA], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.EEVEE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 2; + p.generateName(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) .setInstantTera(0), // Tera Fairy Sylveon - [TrainerType.BUCK]: new TrainerConfig(++t).setName("Buck").initForStatTrainer(true) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.CLAYDOL ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 3); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.COALOSSAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.GREAT_BALL; - if (p.species.speciesId === Species.VENUSAUR) { - p.formIndex = 2; // Gmax - p.abilityIndex = 2; // Venusaur gets Chlorophyll - } else { + [TrainerType.BUCK]: new TrainerConfig(++t) + .setName("Buck") + .initForStatTrainer(true) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.CLAYDOL], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 3); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.VENUSAUR, Species.COALOSSAL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.GREAT_BALL; + if (p.species.speciesId === Species.VENUSAUR) { + p.formIndex = 2; // Gmax + p.abilityIndex = 2; // Venusaur gets Chlorophyll + } else { + p.formIndex = 1; // Gmax + } + p.generateName(); + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.AGGRON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 1; // Mega + p.generateName(); + }), + ) + .setPartyMemberFunc( + 3, + getRandomPartyMemberFunc([Species.TORKOAL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.abilityIndex = 1; // Drought + }), + ) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.GREAT_TUSK], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.HEATRAN], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.CHERYL]: new TrainerConfig(++t) + .setName("Cheryl") + .initForStatTrainer() + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.BLISSEY], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 3); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.SNORLAX, Species.LAPRAS], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.GREAT_BALL; p.formIndex = 1; // Gmax - } - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.AGGRON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 1; // Mega - p.generateName(); - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.TORKOAL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.abilityIndex = 1; // Drought - })) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.GREAT_TUSK ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.HEATRAN ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.CHERYL]: new TrainerConfig(++t).setName("Cheryl").initForStatTrainer() - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BLISSEY ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 3); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.SNORLAX, Species.LAPRAS ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.GREAT_BALL; - p.formIndex = 1; // Gmax - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.AUDINO ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 1; // Mega - p.generateName(); - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.GOODRA ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.IRON_HANDS ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.CRESSELIA, Species.ENAMORUS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.ENAMORUS) { - p.formIndex = 1; // Therian p.generateName(); - } - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.MARLEY]: new TrainerConfig(++t).setName("Marley").initForStatTrainer() - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ARCANINE ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 3); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.ULTRA_BALL; - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.CINDERACE, Species.INTELEON ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.GREAT_BALL; - p.formIndex = 1; // Gmax - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.AERODACTYL ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.formIndex = 1; // Mega - p.generateName(); - })) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.DRAGAPULT ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.IRON_BUNDLE ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.REGIELEKI ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.MIRA]: new TrainerConfig(++t).setName("Mira").initForStatTrainer() - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.ALAKAZAM ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 1; - p.pokeball = PokeballType.ULTRA_BALL; - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.GENGAR, Species.HATTERENE ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.GREAT_BALL; - p.formIndex = p.species.speciesId === Species.GENGAR ? 2 : 1; // Gmax - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.FLUTTER_MANE ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.HYDREIGON ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.MAGNEZONE ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.LATIOS, Species.LATIAS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.RILEY]: new TrainerConfig(++t).setName("Riley").initForStatTrainer(true) - .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.LUCARIO ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - p.formIndex = 1; - p.pokeball = PokeballType.ULTRA_BALL; - p.generateName(); - })) - .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.RILLABOOM, Species.CENTISKORCH ], TrainerSlot.TRAINER, true, p => { - p.generateAndPopulateMoveset(); - p.pokeball = PokeballType.GREAT_BALL; - p.formIndex = 1; // Gmax - p.generateName(); - })) - .setPartyMemberFunc(2, getRandomPartyMemberFunc([ Species.TYRANITAR ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(3, getRandomPartyMemberFunc([ Species.ROARING_MOON ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(4, getRandomPartyMemberFunc([ Species.URSALUNA ], TrainerSlot.TRAINER, true)) - .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.REGIGIGAS, Species.LANDORUS ], TrainerSlot.TRAINER, true, p => { - p.setBoss(true, 2); - p.generateAndPopulateMoveset(); - if (p.species.speciesId === Species.LANDORUS) { - p.formIndex = 1; // Therian + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.AUDINO], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 1; // Mega p.generateName(); - } - p.pokeball = PokeballType.MASTER_BALL; - })), - [TrainerType.VICTOR]: new TrainerConfig(++t).setTitle("The Winstrates").setLocalizedName("Victor") + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.GOODRA], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.IRON_HANDS], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.CRESSELIA, Species.ENAMORUS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.ENAMORUS) { + p.formIndex = 1; // Therian + p.generateName(); + } + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.MARLEY]: new TrainerConfig(++t) + .setName("Marley") + .initForStatTrainer() + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.ARCANINE], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 3); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.ULTRA_BALL; + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.CINDERACE, Species.INTELEON], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.GREAT_BALL; + p.formIndex = 1; // Gmax + p.generateName(); + }), + ) + .setPartyMemberFunc( + 2, + getRandomPartyMemberFunc([Species.AERODACTYL], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.formIndex = 1; // Mega + p.generateName(); + }), + ) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.DRAGAPULT], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.IRON_BUNDLE], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.REGIELEKI], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.MIRA]: new TrainerConfig(++t) + .setName("Mira") + .initForStatTrainer() + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.ALAKAZAM], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 1; + p.pokeball = PokeballType.ULTRA_BALL; + p.generateName(); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.GENGAR, Species.HATTERENE], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.GREAT_BALL; + p.formIndex = p.species.speciesId === Species.GENGAR ? 2 : 1; // Gmax + p.generateName(); + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.FLUTTER_MANE], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.HYDREIGON], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.MAGNEZONE], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.LATIOS, Species.LATIAS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.RILEY]: new TrainerConfig(++t) + .setName("Riley") + .initForStatTrainer(true) + .setPartyMemberFunc( + 0, + getRandomPartyMemberFunc([Species.LUCARIO], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + p.formIndex = 1; + p.pokeball = PokeballType.ULTRA_BALL; + p.generateName(); + }), + ) + .setPartyMemberFunc( + 1, + getRandomPartyMemberFunc([Species.RILLABOOM, Species.CENTISKORCH], TrainerSlot.TRAINER, true, p => { + p.generateAndPopulateMoveset(); + p.pokeball = PokeballType.GREAT_BALL; + p.formIndex = 1; // Gmax + p.generateName(); + }), + ) + .setPartyMemberFunc(2, getRandomPartyMemberFunc([Species.TYRANITAR], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(3, getRandomPartyMemberFunc([Species.ROARING_MOON], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc(4, getRandomPartyMemberFunc([Species.URSALUNA], TrainerSlot.TRAINER, true)) + .setPartyMemberFunc( + 5, + getRandomPartyMemberFunc([Species.REGIGIGAS, Species.LANDORUS], TrainerSlot.TRAINER, true, p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + if (p.species.speciesId === Species.LANDORUS) { + p.formIndex = 1; // Therian + p.generateName(); + } + p.pokeball = PokeballType.MASTER_BALL; + }), + ), + [TrainerType.VICTOR]: new TrainerConfig(++t) + .setTitle("The Winstrates") + .setLocalizedName("Victor") .setMoneyMultiplier(1) // The Winstrate trainers have total money multiplier of 6 .setPartyTemplates(trainerPartyTemplates.ONE_AVG_ONE_STRONG), - [TrainerType.VICTORIA]: new TrainerConfig(++t).setTitle("The Winstrates").setLocalizedName("Victoria") + [TrainerType.VICTORIA]: new TrainerConfig(++t) + .setTitle("The Winstrates") + .setLocalizedName("Victoria") .setMoneyMultiplier(1) .setPartyTemplates(trainerPartyTemplates.ONE_AVG_ONE_STRONG), - [TrainerType.VIVI]: new TrainerConfig(++t).setTitle("The Winstrates").setLocalizedName("Vivi") + [TrainerType.VIVI]: new TrainerConfig(++t) + .setTitle("The Winstrates") + .setLocalizedName("Vivi") .setMoneyMultiplier(1) .setPartyTemplates(trainerPartyTemplates.TWO_AVG_ONE_STRONG), - [TrainerType.VICKY]: new TrainerConfig(++t).setTitle("The Winstrates").setLocalizedName("Vicky") + [TrainerType.VICKY]: new TrainerConfig(++t) + .setTitle("The Winstrates") + .setLocalizedName("Vicky") .setMoneyMultiplier(1) .setPartyTemplates(trainerPartyTemplates.ONE_AVG), - [TrainerType.VITO]: new TrainerConfig(++t).setTitle("The Winstrates").setLocalizedName("Vito") + [TrainerType.VITO]: new TrainerConfig(++t) + .setTitle("The Winstrates") + .setLocalizedName("Vito") .setMoneyMultiplier(2) - .setPartyTemplates(new TrainerPartyCompoundTemplate(new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), new TrainerPartyTemplate(2, PartyMemberStrength.STRONG))), - [TrainerType.BUG_TYPE_SUPERFAN]: new TrainerConfig(++t).setMoneyMultiplier(2.25).setEncounterBgm(TrainerType.ACE_TRAINER) + .setPartyTemplates( + new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(2, PartyMemberStrength.STRONG), + ), + ), + [TrainerType.BUG_TYPE_SUPERFAN]: new TrainerConfig(++t) + .setMoneyMultiplier(2.25) + .setEncounterBgm(TrainerType.ACE_TRAINER) .setPartyTemplates(new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE)), - [TrainerType.EXPERT_POKEMON_BREEDER]: new TrainerConfig(++t).setMoneyMultiplier(3).setEncounterBgm(TrainerType.ACE_TRAINER).setLocalizedName("Expert Pokemon Breeder") + [TrainerType.EXPERT_POKEMON_BREEDER]: new TrainerConfig(++t) + .setMoneyMultiplier(3) + .setEncounterBgm(TrainerType.ACE_TRAINER) + .setLocalizedName("Expert Pokemon Breeder") .setPartyTemplates(new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE)), [TrainerType.FUTURE_SELF_M]: new TrainerConfig(++t) .setMoneyMultiplier(0) @@ -2943,6 +5987,5 @@ export const trainerConfigs: TrainerConfigs = { .setMixedBattleBgm("mystery_encounter_weird_dream") .setVictoryBgm("mystery_encounter_weird_dream") .setLocalizedName("Future Self F") - .setPartyTemplates(new TrainerPartyTemplate(6, PartyMemberStrength.STRONG)) + .setPartyTemplates(new TrainerPartyTemplate(6, PartyMemberStrength.STRONG)), }; - diff --git a/src/data/trainer-names.ts b/src/data/trainer-names.ts index 8b0091d4398..c72356d88ae 100644 --- a/src/data/trainer-names.ts +++ b/src/data/trainer-names.ts @@ -6,7 +6,7 @@ class TrainerNameConfig { public femaleUrls: string[] | null; constructor(type: TrainerType, ...urls: string[]) { - this.urls = urls.length ? urls : [ Utils.toReadableString(TrainerType[type]).replace(/ /g, "_") ]; + this.urls = urls.length ? urls : [Utils.toReadableString(TrainerType[type]).replace(/ /g, "_")]; } hasGenderVariant(...femaleUrls: string[]): TrainerNameConfig { @@ -16,11 +16,11 @@ class TrainerNameConfig { } interface TrainerNameConfigs { - [key: number]: TrainerNameConfig + [key: number]: TrainerNameConfig; } // used in a commented code -// eslint-disable-next-line @typescript-eslint/no-unused-vars +// biome-ignore lint/correctness/noUnusedVariables: Used by commented code const trainerNameConfigs: TrainerNameConfigs = { [TrainerType.ACE_TRAINER]: new TrainerNameConfig(TrainerType.ACE_TRAINER), [TrainerType.ARTIST]: new TrainerNameConfig(TrainerType.ARTIST), @@ -71,65 +71,2663 @@ const trainerNameConfigs: TrainerNameConfigs = { [TrainerType.VETERAN]: new TrainerNameConfig(TrainerType.VETERAN), [TrainerType.WAITER]: new TrainerNameConfig(TrainerType.WAITER).hasGenderVariant("Waitress"), [TrainerType.WORKER]: new TrainerNameConfig(TrainerType.WORKER), - [TrainerType.YOUNGSTER]: new TrainerNameConfig(TrainerType.YOUNGSTER).hasGenderVariant("Lass") + [TrainerType.YOUNGSTER]: new TrainerNameConfig(TrainerType.YOUNGSTER).hasGenderVariant("Lass"), }; export const trainerNamePools = { - [TrainerType.ACE_TRAINER]: [[ "Aaron", "Allen", "Blake", "Brian", "Gaven", "Jake", "Kevin", "Mike", "Nick", "Paul", "Ryan", "Sean", "Darin", "Albert", "Berke", "Clyde", "Edgar", "George", "Leroy", "Owen", "Parker", "Randall", "Ruben", "Samuel", "Vincent", "Warren", "Wilton", "Zane", "Alfred", "Braxton", "Felix", "Gerald", "Jonathan", "Leonel", "Marcel", "Mitchell", "Quincy", "Roderick", "Colby", "Rolando", "Yuji", "Abel", "Anton", "Arthur", "Cesar", "Dalton", "Dennis", "Ernest", "Garrett", "Graham", "Henry", "Isaiah", "Jonah", "Jose", "Keenan", "Micah", "Omar", "Quinn", "Rodolfo", "Saul", "Sergio", "Skylar", "Stefan", "Zachery", "Alton", "Arabella", "Bonita", "Cal", "Cody", "French", "Kobe", "Paulo", "Shaye", "Austin", "Beckett", "Charlie", "Corky", "David", "Dwayne", "Elmer", "Jesse", "Jared", "Johan", "Jordan", "Kipp", "Lou", "Terry", "Tom", "Webster", "Billy", "Doyle", "Enzio", "Geoff", "Grant", "Kelsey", "Miguel", "Pierce", "Ray", "Santino", "Shel", "Adelbert", "Bence", "Emil", "Evan", "Mathis", "Maxim", "Neil", "Rico", "Robbie", "Theo", "Viktor", "Benedict", "Cornelius", "Hisato", "Leopold", "Neville", "Vito", "Chase", "Cole", "Hiroshi", "Jackson", "Jim", "Kekoa", "Makana", "Yuki", "Elwood", "Seth", "Alvin", "Arjun", "Arnold", "Cameron", "Carl", "Carlton", "Christopher", "Dave", "Dax", "Dominic", "Edmund", "Finn", "Fred", "Garret", "Grayson", "Jace", "Jaxson", "Jay", "Jirard", "Johnson", "Kayden", "Kite", "Louis", "Mac", "Marty", "Percy", "Raymond", "Ronnie", "Satch", "Tim", "Zach", "Conner", "Vince", "Bedro", "Boda", "Botan", "Daras", "Dury", "Herton", "Rewn", "Stum", "Tock", "Trilo", "Berki", "Cruik", "Dazon", "Desid", "Dillot", "Farfin", "Forgon", "Hebel", "Morfon", "Moril", "Shadd", "Vanhub", "Bardo", "Carben", "Degin", "Gorps", "Klept", "Lask", "Malex", "Mopar", "Niled", "Noxon", "Teslor", "Tetil" ], [ "Beth", "Carol", "Cybil", "Emma", "Fran", "Gwen", "Irene", "Jenn", "Joyce", "Kate", "Kelly", "Lois", "Lola", "Megan", "Quinn", "Reena", "Cara", "Alexa", "Brooke", "Caroline", "Elaine", "Hope", "Jennifer", "Jody", "Julie", "Lori", "Mary", "Michelle", "Shannon", "Wendy", "Alexia", "Alicia", "Athena", "Carolina", "Cristin", "Darcy", "Dianne", "Halle", "Jazmyn", "Katelynn", "Keira", "Marley", "Allyson", "Kathleen", "Naomi", "Alyssa", "Ariana", "Brandi", "Breanna", "Brenda", "Brenna", "Catherine", "Clarice", "Dana", "Deanna", "Destiny", "Jamie", "Jasmin", "Kassandra", "Laura", "Maria", "Mariah", "Maya", "Meagan", "Mikayla", "Monique", "Natasha", "Olivia", "Sandra", "Savannah", "Sydney", "Moira", "Piper", "Salma", "Allison", "Beverly", "Cathy", "Cheyenne", "Clara", "Dara", "Eileen", "Glinda", "Junko", "Lena", "Lucille", "Mariana", "Olwen", "Shanta", "Stella", "Angi", "Belle", "Chandra", "Cora", "Eve", "Jacqueline", "Jeanne", "Juliet", "Kathrine", "Layla", "Lucca", "Melina", "Miki", "Nina", "Sable", "Shelly", "Summer", "Trish", "Vicki", "Alanza", "Cordelia", "Hilde", "Imelda", "Michele", "Mireille", "Claudia", "Constance", "Harriet", "Honor", "Melba", "Portia", "Alexis", "Angela", "Karla", "Lindsey", "Tori", "Sheri", "Jada", "Kailee", "Amanda", "Annie", "Kindra", "Kyla", "Sofia", "Yvette", "Becky", "Flora", "Gloria", "Buna", "Ferda", "Lehan", "Liqui", "Lomen", "Neira", "Atilo", "Detta", "Gilly", "Gosney", "Levens", "Moden", "Rask", "Rateis", "Rosno", "Tynan", "Veron", "Zoel", "Cida", "Dibsin", "Dodin", "Ebson", "Equin", "Flostin", "Gabsen", "Halsion", "Hileon", "Quelor", "Rapeel", "Roze", "Tensin" ]], - [TrainerType.ARTIST]: [[ "Ismael", "William", "Horton", "Pierre", "Zach", "Gough", "Salvador", "Vincent", "Duncan" ], [ "Georgia" ]], - [TrainerType.BACKERS]: [[ "Alf & Fred", "Hawk & Dar", "Joe & Ross", "Les & Web", "Masa & Yas", "Stu & Art" ], [ "Ai & Ciel", "Ami & Eira", "Cam & Abby", "Fey & Sue", "Kat & Phae", "Kay & Ali", "Ava & Aya", "Cleo & Rio", "May & Mal" ]], - [TrainerType.BACKPACKER]: [[ "Alexander", "Carlos", "Herman", "Jerome", "Keane", "Kelsey", "Kiyo", "Michael", "Nate", "Peter", "Sam", "Stephen", "Talon", "Terrance", "Toru", "Waylon", "Boone", "Clifford", "Ivan", "Kendall", "Lowell", "Randall", "Reece", "Roland", "Shane", "Walt", "Farid", "Heike", "Joren", "Lane", "Roderick", "Darnell", "Deon", "Emory", "Graeme", "Grayson", "Aitor", "Alex", "Arturo", "Asier", "Jaime", "Jonathan", "Julio", "Kevin", "Kosuke", "Lander", "Markel", "Mateo", "Nil", "Pau", "Samuel" ], [ "Anna", "Corin", "Elaine", "Emi", "Jill", "Kumiko", "Liz", "Lois", "Lora", "Molly", "Patty", "Ruth", "Vicki", "Annie", "Blossom", "Clara", "Eileen", "Mae", "Myra", "Rachel", "Tami", "Ashley", "Mikiko", "Kiana", "Perdy", "Maria", "Yuho", "Peren", "Barbara", "Diane" ]], - [TrainerType.BAKER]: [ "Chris", "Jenn", "Lilly" ], - [TrainerType.BEAUTY]: [ "Cassie", "Julia", "Olivia", "Samantha", "Valerie", "Victoria", "Bridget", "Connie", "Jessica", "Johanna", "Melissa", "Sheila", "Shirley", "Tiffany", "Namiko", "Thalia", "Grace", "Lola", "Lori", "Maura", "Tamia", "Cyndy", "Devon", "Gabriella", "Harley", "Lindsay", "Nicola", "Callie", "Charlotte", "Kassandra", "December", "Fleming", "Nikola", "Aimee", "Anais", "Brigitte", "Cassandra", "Andrea", "Brittney", "Carolyn", "Krystal", "Alexis", "Alice", "Aina", "Anya", "Arianna", "Aubrey", "Beverly", "Camille", "Beauty", "Evette", "Hansol", "Haruka", "Jill", "Jo", "Lana", "Lois", "Lucy", "Mai", "Nickie", "Nicole", "Prita", "Rose", "Shelly", "Suzy", "Tessa", "Anita", "Alissa", "Rita", "Cudsy", "Eloff", "Miru", "Minot", "Nevah", "Niven", "Ogoin" ], - [TrainerType.BIKER]: [ "Charles", "Dwayne", "Glenn", "Harris", "Joel", "Riley", "Zeke", "Alex", "Billy", "Ernest", "Gerald", "Hideo", "Isaac", "Jared", "Jaren", "Jaxon", "Jordy", "Lao", "Lukas", "Malik", "Nikolas", "Ricardo", "Ruben", "Virgil", "William", "Aiden", "Dale", "Dan", "Jacob", "Markey", "Reese", "Teddy", "Theron", "Jeremy", "Morgann", "Phillip", "Philip", "Stanley", "Dillon" ], - [TrainerType.BLACK_BELT]: [[ "Kenji", "Lao", "Lung", "Nob", "Wai", "Yoshi", "Atsushi", "Daisuke", "Hideki", "Hitoshi", "Kiyo", "Koichi", "Koji", "Yuji", "Cristian", "Rhett", "Takao", "Theodore", "Zander", "Aaron", "Hugh", "Mike", "Nicolas", "Shea", "Takashi", "Adam", "Carl", "Colby", "Darren", "David", "Davon", "Derek", "Eddie", "Gregory", "Griffin", "Jarrett", "Jeffery", "Kendal", "Kyle", "Luke", "Miles", "Nathaniel", "Philip", "Rafael", "Ray", "Ricky", "Sean", "Willie", "Ander", "Manford", "Benjamin", "Corey", "Edward", "Grant", "Jay", "Kendrew", "Kentaro", "Ryder", "Teppei", "Thomas", "Tyrone", "Andrey", "Donny", "Drago", "Gordon", "Grigor", "Jeriel", "Kenneth", "Martell", "Mathis", "Rich", "Rocky", "Rodrigo", "Wesley", "Zachery", "Alonzo", "Cadoc", "Gunnar", "Igor", "Killian", "Markus", "Ricardo", "Yanis", "Banting", "Clayton", "Duane", "Earl", "Greg", "Roy", "Terry", "Tracy", "Walter", "Alvaro", "Curtis", "Francis", "Ross", "Brice", "Cheng", "Dudley", "Eric", "Kano", "Masahiro", "Randy", "Ryuji", "Steve", "Tadashi", "Wong", "Yuen", "Brian", "Carter", "Reece", "Nick", "Yang" ], [ "Cora", "Cyndy", "Jill", "Laura", "Sadie", "Tessa", "Vivian", "Aisha", "Callie", "Danielle", "Helene", "Jocelyn", "Lilith", "Paula", "Reyna", "Helen", "Kelsey", "Tyler", "Amy", "Chandra", "Hillary", "Janie", "Lee", "Maggie", "Mikiko", "Miriam", "Sharon", "Susie", "Xiao", "Alize", "Azra", "Brenda", "Chalina", "Chan", "Glinda", "Maki", "Tia", "Tiffany", "Wendy", "Andrea", "Gabrielle", "Gerardine", "Hailey", "Hedvig", "Justine", "Kinsey", "Sigrid", "Veronique", "Tess" ]], - [TrainerType.BREEDER]: [[ "Isaac", "Myles", "Salvadore", "Albert", "Kahlil", "Eustace", "Galen", "Owen", "Addison", "Marcus", "Foster", "Cory", "Glenn", "Jay", "Wesley", "William", "Adrian", "Bradley", "Jaime" ], [ "Allison", "Alize", "Bethany", "Lily", "Lydia", "Gabrielle", "Jayden", "Pat", "Veronica", "Amber", "Jennifer", "Kaylee", "Adelaide", "Brooke", "Ethel", "April", "Irene", "Magnolia", "Amala", "Mercy", "Amanda", "Ikue", "Savannah", "Yuka", "Chloe", "Debra", "Denise", "Elena" ]], - [TrainerType.CLERK]: [[ "Chaz", "Clemens", "Doug", "Fredric", "Ivan", "Isaac", "Nelson", "Wade", "Warren", "Augustin", "Gilligan", "Cody", "Jeremy", "Shane", "Dugal", "Royce", "Ronald" ], [ "Alberta", "Ingrid", "Katie", "Piper", "Trisha", "Wren", "Britney", "Lana", "Jessica", "Kristen", "Michelle", "Gabrielle" ]], - [TrainerType.CYCLIST]: [[ "Axel", "James", "John", "Ryan", "Hector", "Jeremiah" ], [ "Kayla", "Megan", "Nicole", "Rachel", "Krissa", "Adelaide" ]], - [TrainerType.DANCER]: [ "Brian", "Davey", "Dirk", "Edmond", "Mickey", "Raymond", "Cara", "Julia", "Maika", "Mireille", "Ronda", "Zoe" ], - [TrainerType.DEPOT_AGENT]: [ "Josh", "Hank", "Vincent" ], - [TrainerType.DOCTOR]: [[ "Hank", "Jerry", "Jules", "Logan", "Wayne", "Braid", "Derek", "Heath", "Julius", "Kit", "Graham" ], [ "Kirsten", "Sachiko", "Shery", "Carol", "Dixie", "Mariah" ]], - [TrainerType.FIREBREATHER]: [ "Bill", "Burt", "Cliff", "Dick", "Lyle", "Ned", "Otis", "Ray", "Richard", "Walt" ], - [TrainerType.FISHERMAN]: [ "Andre", "Arnold", "Barney", "Chris", "Edgar", "Henry", "Jonah", "Justin", "Kyle", "Martin", "Marvin", "Ralph", "Raymond", "Scott", "Stephen", "Wilton", "Tully", "Andrew", "Barny", "Carter", "Claude", "Dale", "Elliot", "Eugene", "Ivan", "Ned", "Nolan", "Roger", "Ronald", "Wade", "Wayne", "Darian", "Kai", "Chip", "Hank", "Kaden", "Tommy", "Tylor", "Alec", "Brett", "Cameron", "Cody", "Cole", "Cory", "Erick", "George", "Joseph", "Juan", "Kenneth", "Luc", "Miguel", "Travis", "Walter", "Zachary", "Josh", "Gideon", "Kyler", "Liam", "Murphy", "Bruce", "Damon", "Devon", "Hubert", "Jones", "Lydon", "Mick", "Pete", "Sean", "Sid", "Vince", "Bucky", "Dean", "Eustace", "Kenzo", "Leroy", "Mack", "Ryder", "Ewan", "Finn", "Murray", "Seward", "Shad", "Wharton", "Finley", "Fisher", "Fisk", "River", "Sheaffer", "Timin", "Carl", "Ernest", "Hal", "Herbert", "Hisato", "Mike", "Vernon", "Harriet", "Marina", "Chase" ], - [TrainerType.GUITARIST]: [ "Anna", "Beverly", "January", "Tina", "Alicia", "Claudia", "Julia", "Lidia", "Mireia", "Noelia", "Sara", "Sheila", "Tatiana" ], - [TrainerType.HARLEQUIN]: [ "Charley", "Ian", "Jack", "Kerry", "Louis", "Pat", "Paul", "Rick", "Anders", "Clarence", "Gary" ], - [TrainerType.HIKER]: [ "Anthony", "Bailey", "Benjamin", "Daniel", "Erik", "Jim", "Kenny", "Leonard", "Michael", "Parry", "Phillip", "Russell", "Sidney", "Tim", "Timothy", "Alan", "Brice", "Clark", "Eric", "Lenny", "Lucas", "Mike", "Trent", "Devan", "Eli", "Marc", "Sawyer", "Allen", "Daryl", "Dudley", "Earl", "Franklin", "Jeremy", "Marcos", "Nob", "Oliver", "Wayne", "Alexander", "Damon", "Jonathan", "Justin", "Kevin", "Lorenzo", "Louis", "Maurice", "Nicholas", "Reginald", "Robert", "Theodore", "Bruce", "Clarke", "Devin", "Dwight", "Edwin", "Eoin", "Noland", "Russel", "Andy", "Bret", "Darrell", "Gene", "Hardy", "Hugh", "Jebediah", "Jeremiah", "Kit", "Neil", "Terrell", "Don", "Doug", "Hunter", "Jared", "Jerome", "Keith", "Manuel", "Markus", "Otto", "Shelby", "Stephen", "Teppei", "Tobias", "Wade", "Zaiem", "Aaron", "Alain", "Bergin", "Bernard", "Brent", "Corwin", "Craig", "Delmon", "Dunstan", "Orestes", "Ross", "Davian", "Calhoun", "David", "Gabriel", "Ryan", "Thomas", "Travis", "Zachary", "Anuhea", "Barnaby", "Claus", "Collin", "Colson", "Dexter", "Dillan", "Eugine", "Farkas", "Hisato", "Julius", "Kenji", "Irwin", "Lionel", "Paul", "Richter", "Valentino", "Donald", "Douglas", "Kevyn", "Chester" ], //["Angela","Carla","Celia","Daniela","Estela","Fatima","Helena","Leire","Lucia","Luna","Manuela","Mar","Marina","Miyu","Nancy","Nerea","Paula","Rocio","Yanira"] - [TrainerType.HOOLIGANS]: [ "Jim & Cas", "Rob & Sal" ], - [TrainerType.HOOPSTER]: [ "Bobby", "John", "Lamarcus", "Derrick", "Nicolas" ], - [TrainerType.INFIELDER]: [ "Alex", "Connor", "Todd" ], - [TrainerType.JANITOR]: [ "Caleb", "Geoff", "Brady", "Felix", "Orville", "Melvin", "Shawn" ], - [TrainerType.LINEBACKER]: [ "Bob", "Dan", "Jonah" ], - [TrainerType.MAID]: [ "Belinda", "Sophie", "Emily", "Elena", "Clare", "Alica", "Tanya", "Tammy" ], - [TrainerType.MUSICIAN]: [ "Boris", "Preston", "Charles", "Clyde", "Vincent", "Dalton", "Kirk", "Shawn", "Fabian", "Fernando", "Joseph", "Marcos", "Arturo", "Jerry", "Lonnie", "Tony" ], - [TrainerType.NURSERY_AIDE]: [ "Autumn", "Briana", "Leah", "Miho", "Ethel", "Hollie", "Ilse", "June", "Kimya", "Rosalyn" ], - [TrainerType.OFFICER]: [ "Dirk", "Keith", "Alex", "Bobby", "Caleb", "Danny", "Dylan", "Thomas", "Daniel", "Jeff", "Braven", "Dell", "Neagle", "Haruki", "Mitchell", "Raymond" ], - [TrainerType.PARASOL_LADY]: [ "Angelica", "Clarissa", "Madeline", "Akari", "Annabell", "Kayley", "Rachel", "Alexa", "Sabrina", "April", "Gwyneth", "Laura", "Lumi", "Mariah", "Melita", "Nicole", "Tihana", "Ingrid", "Tyra" ], - [TrainerType.PILOT]: [ "Chase", "Leonard", "Ted", "Elron", "Ewing", "Flynn", "Winslow" ], - [TrainerType.POKEFAN]: [[ "Alex", "Allan", "Brandon", "Carter", "Colin", "Derek", "Jeremy", "Joshua", "Rex", "Robert", "Trevor", "William", "Colton", "Miguel", "Francisco", "Kaleb", "Leonard", "Boone", "Elliot", "Jude", "Norbert", "Corey", "Gabe", "Baxter" ], [ "Beverly", "Georgia", "Jaime", "Ruth", "Isabel", "Marissa", "Vanessa", "Annika", "Bethany", "Kimberly", "Meredith", "Rebekah", "Eleanor", "Darcy", "Lydia", "Sachiko", "Abigail", "Agnes", "Lydie", "Roisin", "Tara", "Carmen", "Janet" ]], - [TrainerType.PRESCHOOLER]: [[ "Billy", "Doyle", "Evan", "Homer", "Tully", "Albert", "Buster", "Greg", "Ike", "Jojo", "Tyrone", "Adrian", "Oliver", "Hayden", "Hunter", "Kaleb", "Liam", "Dylan" ], [ "Juliet", "Mia", "Sarah", "Wendy", "Winter", "Chrissy", "Eva", "Lin", "Samantha", "Ella", "Lily", "Natalie", "Ailey", "Hannah", "Malia", "Kindra", "Nancy" ]], - [TrainerType.PSYCHIC]: [[ "Fidel", "Franklin", "Gilbert", "Greg", "Herman", "Jared", "Mark", "Nathan", "Norman", "Phil", "Richard", "Rodney", "Cameron", "Edward", "Fritz", "Joshua", "Preston", "Virgil", "William", "Alvaro", "Blake", "Cedric", "Keenan", "Nicholas", "Dario", "Johan", "Lorenzo", "Tyron", "Bryce", "Corbin", "Deandre", "Elijah", "Kody", "Landon", "Maxwell", "Mitchell", "Sterling", "Eli", "Nelson", "Vernon", "Gaven", "Gerard", "Low", "Micki", "Perry", "Rudolf", "Tommy", "Al", "Nandor", "Tully", "Arthur", "Emanuel", "Franz", "Harry", "Paschal", "Robert", "Sayid", "Angelo", "Anton", "Arin", "Avery", "Danny", "Frasier", "Harrison", "Jaime", "Ross", "Rui", "Vlad", "Mason" ], [ "Alexis", "Hannah", "Jacki", "Jaclyn", "Kayla", "Maura", "Samantha", "Alix", "Brandi", "Edie", "Macey", "Mariella", "Marlene", "Laura", "Rodette", "Abigail", "Brittney", "Chelsey", "Daisy", "Desiree", "Kendra", "Lindsey", "Rachael", "Valencia", "Belle", "Cybil", "Doreen", "Dua", "Future", "Lin", "Madhu", "Alia", "Ena", "Joyce", "Lynette", "Olesia", "Sarah" ]], - [TrainerType.RANGER]: [[ "Carlos", "Jackson", "Sebastian", "Gav", "Lorenzo", "Logan", "Nicolas", "Trenton", "Deshawn", "Dwayne", "Jeffery", "Kyler", "Taylor", "Alain", "Claude", "Crofton", "Forrest", "Harry", "Jaden", "Keith", "Lewis", "Miguel", "Pedro", "Ralph", "Richard", "Bret", "Daryl", "Eddie", "Johan", "Leaf", "Louis", "Maxwell", "Parker", "Rick", "Steve", "Bjorn", "Chaise", "Dean", "Lee", "Maurice", "Nash", "Ralf", "Reed", "Shinobu", "Silas" ], [ "Catherine", "Jenna", "Sophia", "Merdith", "Nora", "Beth", "Chelsea", "Katelyn", "Madeline", "Allison", "Ashlee", "Felicia", "Krista", "Annie", "Audra", "Brenda", "Chloris", "Eliza", "Heidi", "Irene", "Mary", "Mylene", "Shanti", "Shelly", "Thalia", "Anja", "Briana", "Dianna", "Elaine", "Elle", "Hillary", "Katie", "Lena", "Lois", "Malory", "Melita", "Mikiko", "Naoko", "Serenity", "Ambre", "Brooke", "Clementine", "Melina", "Petra", "Twiggy" ]], - [TrainerType.RICH]: [[ "Alfred", "Edward", "Gregory", "Preston", "Thomas", "Tucker", "Walter", "Clifford", "Everett", "Micah", "Nate", "Pierre", "Terrance", "Arthur", "Brooks", "Emanuel", "Lamar", "Jeremy", "Leonardo", "Milton", "Frederic", "Renaud", "Robert", "Yan", "Daniel", "Sheldon", "Stonewall", "Gerald", "Ronald", "Smith", "Stanley", "Reginald", "Orson", "Wilco", "Caden", "Glenn" ], [ "Rebecca", "Reina", "Cassandra", "Emilia", "Grace", "Marian", "Elizabeth", "Kathleen", "Sayuri", "Caroline", "Judy" ]], - [TrainerType.RICH_KID]: [[ "Garret", "Winston", "Dawson", "Enrique", "Jason", "Roman", "Trey", "Liam", "Anthony", "Brad", "Cody", "Manuel", "Martin", "Pierce", "Rolan", "Keenan", "Filbert", "Antoin", "Cyus", "Diek", "Dugo", "Flitz", "Jurek", "Lond", "Perd", "Quint", "Basto", "Benit", "Brot", "Denc", "Guyit", "Marcon", "Perc", "Puros", "Roex", "Sainz", "Symin", "Tark", "Venak" ], [ "Anette", "Brianna", "Cindy", "Colleen", "Daphne", "Elizabeth", "Naomi", "Sarah", "Charlotte", "Gillian", "Jacki", "Lady", "Melissa", "Celeste", "Colette", "Elizandra", "Isabel", "Lynette", "Magnolia", "Sophie", "Lina", "Dulcie", "Auro", "Brin", "Caril", "Eloos", "Gwin", "Illa", "Kowly", "Rima", "Ristin", "Vesey", "Brena", "Deasy", "Denslon", "Kylet", "Nemi", "Rene", "Sanol", "Stouner", "Sturk", "Talmen", "Zoila" ]], - [TrainerType.ROUGHNECK]: [ "Camron", "Corey", "Gabriel", "Isaiah", "Jamal", "Koji", "Luke", "Paxton", "Raul", "Zeek", "Kirby", "Chance", "Dave", "Fletcher", "Johnny", "Reese", "Joey", "Ricky", "Silvester", "Martin" ], - [TrainerType.SAILOR]: [ "Alberto", "Bost", "Brennan", "Brenden", "Claude", "Cory", "Damian", "Dirk", "Duncan", "Dwayne", "Dylan", "Eddie", "Edmond", "Elijah", "Ernest", "Eugene", "Garrett", "Golos", "Gratin", "Grestly", "Harry", "Hols", "Hudson", "Huey", "Jebol", "Jeff", "Leonald", "Luther", "Kelvin", "Kenneth", "Kent", "Knook", "Marc", "Mifis", "Monar", "Morkor", "Ordes", "Oxlin", "Parker", "Paul", "Philip", "Roberto", "Samson", "Skyler", "Stanly", "Tebu", "Terrell", "Trevor", "Yasu", "Zachariah" ], - [TrainerType.SCIENTIST]: [[ "Jed", "Marc", "Mitch", "Rich", "Ross", "Beau", "Braydon", "Connor", "Ed", "Ivan", "Jerry", "Jose", "Joshua", "Parker", "Rodney", "Taylor", "Ted", "Travis", "Zackery", "Darrius", "Emilio", "Fredrick", "Shaun", "Stefano", "Travon", "Daniel", "Garett", "Gregg", "Linden", "Lowell", "Trenton", "Dudley", "Luke", "Markus", "Nathan", "Orville", "Randall", "Ron", "Ronald", "Simon", "Steve", "William", "Franklin", "Clarke", "Jacques", "Terrance", "Ernst", "Justus", "Ikaika", "Jayson", "Kyle", "Reid", "Tyrone", "Adam", "Albert", "Alphonse", "Cory", "Donnie", "Elton", "Francis", "Gordon", "Herbert", "Humphrey", "Jordan", "Julian", "Keaton", "Levi", "Melvin", "Murray", "West", "Craig", "Coren", "Dubik", "Kotan", "Lethco", "Mante", "Mort", "Myron", "Odlow", "Ribek", "Roeck", "Vogi", "Vonder", "Zogo", "Doimo", "Doton", "Durel", "Hildon", "Kukla", "Messa", "Nanot", "Platen", "Raburn", "Reman", "Acrod", "Coffy", "Elrok", "Foss", "Hardig", "Hombol", "Hospel", "Kaller", "Klots", "Krilok", "Limar", "Loket", "Mesak", "Morbit", "Newin", "Orill", "Tabor", "Tekot" ], [ "Blythe", "Chan", "Kathrine", "Marie", "Maria", "Naoko", "Samantha", "Satomi", "Shannon", "Athena", "Caroline", "Lumi", "Lumina", "Marissa", "Sonia" ]], - [TrainerType.SMASHER]: [ "Aspen", "Elena", "Mari", "Amy", "Lizzy" ], - [TrainerType.SNOW_WORKER]: [[ "Braden", "Brendon", "Colin", "Conrad", "Dillan", "Gary", "Gerardo", "Holden", "Jackson", "Mason", "Quentin", "Willy", "Noel", "Arnold", "Brady", "Brand", "Cairn", "Cliff", "Don", "Eddie", "Felix", "Filipe", "Glenn", "Gus", "Heath", "Matthew", "Patton", "Rich", "Rob", "Ryan", "Scott", "Shelby", "Sterling", "Tyler", "Victor", "Zack", "Friedrich", "Herman", "Isaac", "Leo", "Maynard", "Mitchell", "Morgann", "Nathan", "Niel", "Pasqual", "Paul", "Tavarius", "Tibor", "Dimitri", "Narek", "Yusif", "Frank", "Jeff", "Vaclav", "Ovid", "Francis", "Keith", "Russel", "Sangon", "Toway", "Bomber", "Chean", "Demit", "Hubor", "Kebile", "Laber", "Ordo", "Retay", "Ronix", "Wagel", "Dobit", "Kaster", "Lobel", "Releo", "Saken", "Rustix" ], [ "Georgia", "Sandra", "Yvonne" ]], - [TrainerType.STRIKER]: [ "Marco", "Roberto", "Tony" ], - [TrainerType.SCHOOL_KID]: [[ "Alan", "Billy", "Chad", "Danny", "Dudley", "Jack", "Joe", "Johnny", "Kipp", "Nate", "Ricky", "Tommy", "Jerry", "Paul", "Ted", "Chance", "Esteban", "Forrest", "Harrison", "Connor", "Sherman", "Torin", "Travis", "Al", "Carter", "Edgar", "Jem", "Sammy", "Shane", "Shayne", "Alvin", "Keston", "Neil", "Seymour", "William", "Carson", "Clark", "Nolan" ], [ "Georgia", "Karen", "Meiko", "Christine", "Mackenzie", "Tiera", "Ann", "Gina", "Lydia", "Marsha", "Millie", "Sally", "Serena", "Silvia", "Alberta", "Cassie", "Mara", "Rita", "Georgie", "Meena", "Nitzel" ]], - [TrainerType.SWIMMER]: [[ "Berke", "Cameron", "Charlie", "George", "Harold", "Jerome", "Kirk", "Mathew", "Parker", "Randall", "Seth", "Simon", "Tucker", "Austin", "Barry", "Chad", "Cody", "Darrin", "David", "Dean", "Douglas", "Franklin", "Gilbert", "Herman", "Jack", "Luis", "Matthew", "Reed", "Richard", "Rodney", "Roland", "Spencer", "Stan", "Tony", "Clarence", "Declan", "Dominik", "Harrison", "Kevin", "Leonardo", "Nolen", "Pete", "Santiago", "Axle", "Braden", "Finn", "Garrett", "Mymo", "Reece", "Samir", "Toby", "Adrian", "Colton", "Dillon", "Erik", "Evan", "Francisco", "Glenn", "Kurt", "Oscar", "Ricardo", "Sam", "Sheltin", "Troy", "Vincent", "Wade", "Wesley", "Duane", "Elmo", "Esteban", "Frankie", "Ronald", "Tyson", "Bart", "Matt", "Tim", "Wright", "Jeffery", "Kyle", "Alessandro", "Estaban", "Kieran", "Ramses", "Casey", "Dakota", "Jared", "Kalani", "Keoni", "Lawrence", "Logan", "Robert", "Roddy", "Yasu", "Derek", "Jacob", "Bruce", "Clayton" ], [ "Briana", "Dawn", "Denise", "Diana", "Elaine", "Kara", "Kaylee", "Lori", "Nicole", "Nikki", "Paula", "Susie", "Wendy", "Alice", "Beth", "Beverly", "Brenda", "Dana", "Debra", "Grace", "Jenny", "Katie", "Laurel", "Linda", "Missy", "Sharon", "Tanya", "Tara", "Tisha", "Carlee", "Imani", "Isabelle", "Kyla", "Sienna", "Abigail", "Amara", "Anya", "Connie", "Maria", "Melissa", "Nora", "Shirley", "Shania", "Tiffany", "Aubree", "Cassandra", "Claire", "Crystal", "Erica", "Gabrielle", "Haley", "Jessica", "Joanna", "Lydia", "Mallory", "Mary", "Miranda", "Paige", "Sophia", "Vanessa", "Chelan", "Debbie", "Joy", "Kendra", "Leona", "Mina", "Caroline", "Joyce", "Larissa", "Rebecca", "Tyra", "Dara", "Desiree", "Kaoru", "Ruth", "Coral", "Genevieve", "Isla", "Marissa", "Romy", "Sheryl", "Alexandria", "Alicia", "Chelsea", "Jade", "Kelsie", "Laura", "Portia", "Shelby", "Sara", "Tiare", "Kyra", "Natasha", "Layla", "Scarlett", "Cora" ]], - [TrainerType.TWINS]: [ "Amy & May", "Jo & Zoe", "Meg & Peg", "Ann & Anne", "Lea & Pia", "Amy & Liv", "Gina & Mia", "Miu & Yuki", "Tori & Tia", "Eli & Anne", "Jen & Kira", "Joy & Meg", "Kiri & Jan", "Miu & Mia", "Emma & Lil", "Liv & Liz", "Teri & Tia", "Amy & Mimi", "Clea & Gil", "Day & Dani", "Kay & Tia", "Tori & Til", "Saya & Aya", "Emy & Lin", "Kumi & Amy", "Mayo & May", "Ally & Amy", "Lia & Lily", "Rae & Ula", "Sola & Ana", "Tara & Val", "Faith & Joy", "Nana & Nina" ], - [TrainerType.VETERAN]: [[ "Armando", "Brenden", "Brian", "Clayton", "Edgar", "Emanuel", "Grant", "Harlan", "Terrell", "Arlen", "Chester", "Hugo", "Martell", "Ray", "Shaun", "Abraham", "Carter", "Claude", "Jerry", "Lucius", "Murphy", "Rayne", "Ron", "Sinan", "Sterling", "Vincent", "Zach", "Gerard", "Gilles", "Louis", "Timeo", "Akira", "Don", "Eric", "Harry", "Leon", "Roger", "Angus", "Aristo", "Brone", "Johnny" ], [ "Julia", "Karla", "Kim", "Sayuri", "Tiffany", "Cathy", "Cecile", "Chloris", "Denae", "Gina", "Maya", "Oriana", "Portia", "Rhona", "Rosaline", "Catrina", "Inga", "Trisha", "Heather", "Lynn", "Sheri", "Alonsa", "Ella", "Leticia", "Kiara" ]], - [TrainerType.WAITER]: [[ "Bert", "Clint", "Maxwell", "Lou" ], [ "Kati", "Aurora", "Bonita", "Flo", "Tia", "Jan", "Olwen", "Paget", "Paula", "Talia" ]], - [TrainerType.WORKER]: [[ "Braden", "Brendon", "Colin", "Conrad", "Dillan", "Gary", "Gerardo", "Holden", "Jackson", "Mason", "Quentin", "Willy", "Noel", "Arnold", "Brady", "Brand", "Cairn", "Cliff", "Don", "Eddie", "Felix", "Filipe", "Glenn", "Gus", "Heath", "Matthew", "Patton", "Rich", "Rob", "Ryan", "Scott", "Shelby", "Sterling", "Tyler", "Victor", "Zack", "Friedrich", "Herman", "Isaac", "Leo", "Maynard", "Mitchell", "Morgann", "Nathan", "Niel", "Pasqual", "Paul", "Tavarius", "Tibor", "Dimitri", "Narek", "Yusif", "Frank", "Jeff", "Vaclav", "Ovid", "Francis", "Keith", "Russel", "Sangon", "Toway", "Bomber", "Chean", "Demit", "Hubor", "Kebile", "Laber", "Ordo", "Retay", "Ronix", "Wagel", "Dobit", "Kaster", "Lobel", "Releo", "Saken", "Rustix" ], [ "Georgia", "Sandra", "Yvonne" ]], - [TrainerType.YOUNGSTER]: [[ "Albert", "Gordon", "Ian", "Jason", "Jimmy", "Mikey", "Owen", "Samuel", "Warren", "Allen", "Ben", "Billy", "Calvin", "Dillion", "Eddie", "Joey", "Josh", "Neal", "Timmy", "Tommy", "Breyden", "Deandre", "Demetrius", "Dillon", "Jaylen", "Johnson", "Shigenobu", "Chad", "Cole", "Cordell", "Dan", "Dave", "Destin", "Nash", "Tyler", "Yasu", "Austin", "Dallas", "Darius", "Donny", "Jonathon", "Logan", "Michael", "Oliver", "Sebastian", "Tristan", "Wayne", "Norman", "Roland", "Regis", "Abe", "Astor", "Keita", "Kenneth", "Kevin", "Kyle", "Lester", "Masao", "Nicholas", "Parker", "Wes", "Zachary", "Cody", "Henley", "Jaye", "Karl", "Kenny", "Masahiro", "Pedro", "Petey", "Sinclair", "Terrell", "Waylon", "Aidan", "Anthony", "David", "Jacob", "Jayden", "Cutler", "Ham", "Caleb", "Kai", "Honus", "Kenway", "Bret", "Chris", "Cid", "Dennis", "Easton", "Ken", "Robby", "Ronny", "Shawn", "Benjamin", "Jake", "Travis", "Adan", "Aday", "Beltran", "Elian", "Hernan", "Julen", "Luka", "Roi", "Bernie", "Dustin", "Jonathan", "Wyatt" ], [ "Alice", "Bridget", "Carrie", "Connie", "Dana", "Ellen", "Krise", "Laura", "Linda", "Michelle", "Shannon", "Andrea", "Crissy", "Janice", "Robin", "Sally", "Tiana", "Haley", "Ali", "Ann", "Dalia", "Dawn", "Iris", "Joana", "Julia", "Kay", "Lisa", "Megan", "Mikaela", "Miriam", "Paige", "Reli", "Blythe", "Briana", "Caroline", "Cassidy", "Kaitlin", "Madeline", "Molly", "Natalie", "Samantha", "Sarah", "Cathy", "Dye", "Eri", "Eva", "Fey", "Kara", "Lurleen", "Maki", "Mali", "Maya", "Miki", "Sibyl", "Daya", "Diana", "Flo", "Helia", "Henrietta", "Isabel", "Mai", "Persephone", "Serena", "Anna", "Charlotte", "Elin", "Elsa", "Lise", "Sara", "Suzette", "Audrey", "Emmy", "Isabella", "Madison", "Rika", "Rylee", "Salla", "Ellie", "Alexandra", "Amy", "Lass", "Brittany", "Chel", "Cindy", "Dianne", "Emily", "Emma", "Evelyn", "Hana", "Harleen", "Hazel", "Jocelyn", "Katrina", "Kimberly", "Lina", "Marge", "Mila", "Mizuki", "Rena", "Sal", "Satoko", "Summer", "Tomoe", "Vicky", "Yue", "Yumi", "Lauren", "Rei", "Riley", "Lois", "Nancy", "Tammy", "Terry" ]], - [TrainerType.HEX_MANIAC]: [ "Kindra", "Patricia", "Tammy", "Tasha", "Valerie", "Alaina", "Kathleen", "Leah", "Makie", "Sylvia", "Anina", "Arachna", "Carrie", "Desdemona", "Josette", "Luna", "Melanie", "Osanna", "Raziah" ], + [TrainerType.ACE_TRAINER]: [ + [ + "Aaron", + "Allen", + "Blake", + "Brian", + "Gaven", + "Jake", + "Kevin", + "Mike", + "Nick", + "Paul", + "Ryan", + "Sean", + "Darin", + "Albert", + "Berke", + "Clyde", + "Edgar", + "George", + "Leroy", + "Owen", + "Parker", + "Randall", + "Ruben", + "Samuel", + "Vincent", + "Warren", + "Wilton", + "Zane", + "Alfred", + "Braxton", + "Felix", + "Gerald", + "Jonathan", + "Leonel", + "Marcel", + "Mitchell", + "Quincy", + "Roderick", + "Colby", + "Rolando", + "Yuji", + "Abel", + "Anton", + "Arthur", + "Cesar", + "Dalton", + "Dennis", + "Ernest", + "Garrett", + "Graham", + "Henry", + "Isaiah", + "Jonah", + "Jose", + "Keenan", + "Micah", + "Omar", + "Quinn", + "Rodolfo", + "Saul", + "Sergio", + "Skylar", + "Stefan", + "Zachery", + "Alton", + "Arabella", + "Bonita", + "Cal", + "Cody", + "French", + "Kobe", + "Paulo", + "Shaye", + "Austin", + "Beckett", + "Charlie", + "Corky", + "David", + "Dwayne", + "Elmer", + "Jesse", + "Jared", + "Johan", + "Jordan", + "Kipp", + "Lou", + "Terry", + "Tom", + "Webster", + "Billy", + "Doyle", + "Enzio", + "Geoff", + "Grant", + "Kelsey", + "Miguel", + "Pierce", + "Ray", + "Santino", + "Shel", + "Adelbert", + "Bence", + "Emil", + "Evan", + "Mathis", + "Maxim", + "Neil", + "Rico", + "Robbie", + "Theo", + "Viktor", + "Benedict", + "Cornelius", + "Hisato", + "Leopold", + "Neville", + "Vito", + "Chase", + "Cole", + "Hiroshi", + "Jackson", + "Jim", + "Kekoa", + "Makana", + "Yuki", + "Elwood", + "Seth", + "Alvin", + "Arjun", + "Arnold", + "Cameron", + "Carl", + "Carlton", + "Christopher", + "Dave", + "Dax", + "Dominic", + "Edmund", + "Finn", + "Fred", + "Garret", + "Grayson", + "Jace", + "Jaxson", + "Jay", + "Jirard", + "Johnson", + "Kayden", + "Kite", + "Louis", + "Mac", + "Marty", + "Percy", + "Raymond", + "Ronnie", + "Satch", + "Tim", + "Zach", + "Conner", + "Vince", + "Bedro", + "Boda", + "Botan", + "Daras", + "Dury", + "Herton", + "Rewn", + "Stum", + "Tock", + "Trilo", + "Berki", + "Cruik", + "Dazon", + "Desid", + "Dillot", + "Farfin", + "Forgon", + "Hebel", + "Morfon", + "Moril", + "Shadd", + "Vanhub", + "Bardo", + "Carben", + "Degin", + "Gorps", + "Klept", + "Lask", + "Malex", + "Mopar", + "Niled", + "Noxon", + "Teslor", + "Tetil", + ], + [ + "Beth", + "Carol", + "Cybil", + "Emma", + "Fran", + "Gwen", + "Irene", + "Jenn", + "Joyce", + "Kate", + "Kelly", + "Lois", + "Lola", + "Megan", + "Quinn", + "Reena", + "Cara", + "Alexa", + "Brooke", + "Caroline", + "Elaine", + "Hope", + "Jennifer", + "Jody", + "Julie", + "Lori", + "Mary", + "Michelle", + "Shannon", + "Wendy", + "Alexia", + "Alicia", + "Athena", + "Carolina", + "Cristin", + "Darcy", + "Dianne", + "Halle", + "Jazmyn", + "Katelynn", + "Keira", + "Marley", + "Allyson", + "Kathleen", + "Naomi", + "Alyssa", + "Ariana", + "Brandi", + "Breanna", + "Brenda", + "Brenna", + "Catherine", + "Clarice", + "Dana", + "Deanna", + "Destiny", + "Jamie", + "Jasmin", + "Kassandra", + "Laura", + "Maria", + "Mariah", + "Maya", + "Meagan", + "Mikayla", + "Monique", + "Natasha", + "Olivia", + "Sandra", + "Savannah", + "Sydney", + "Moira", + "Piper", + "Salma", + "Allison", + "Beverly", + "Cathy", + "Cheyenne", + "Clara", + "Dara", + "Eileen", + "Glinda", + "Junko", + "Lena", + "Lucille", + "Mariana", + "Olwen", + "Shanta", + "Stella", + "Angi", + "Belle", + "Chandra", + "Cora", + "Eve", + "Jacqueline", + "Jeanne", + "Juliet", + "Kathrine", + "Layla", + "Lucca", + "Melina", + "Miki", + "Nina", + "Sable", + "Shelly", + "Summer", + "Trish", + "Vicki", + "Alanza", + "Cordelia", + "Hilde", + "Imelda", + "Michele", + "Mireille", + "Claudia", + "Constance", + "Harriet", + "Honor", + "Melba", + "Portia", + "Alexis", + "Angela", + "Karla", + "Lindsey", + "Tori", + "Sheri", + "Jada", + "Kailee", + "Amanda", + "Annie", + "Kindra", + "Kyla", + "Sofia", + "Yvette", + "Becky", + "Flora", + "Gloria", + "Buna", + "Ferda", + "Lehan", + "Liqui", + "Lomen", + "Neira", + "Atilo", + "Detta", + "Gilly", + "Gosney", + "Levens", + "Moden", + "Rask", + "Rateis", + "Rosno", + "Tynan", + "Veron", + "Zoel", + "Cida", + "Dibsin", + "Dodin", + "Ebson", + "Equin", + "Flostin", + "Gabsen", + "Halsion", + "Hileon", + "Quelor", + "Rapeel", + "Roze", + "Tensin", + ], + ], + [TrainerType.ARTIST]: [ + ["Ismael", "William", "Horton", "Pierre", "Zach", "Gough", "Salvador", "Vincent", "Duncan"], + ["Georgia"], + ], + [TrainerType.BACKERS]: [ + ["Alf & Fred", "Hawk & Dar", "Joe & Ross", "Les & Web", "Masa & Yas", "Stu & Art"], + [ + "Ai & Ciel", + "Ami & Eira", + "Cam & Abby", + "Fey & Sue", + "Kat & Phae", + "Kay & Ali", + "Ava & Aya", + "Cleo & Rio", + "May & Mal", + ], + ], + [TrainerType.BACKPACKER]: [ + [ + "Alexander", + "Carlos", + "Herman", + "Jerome", + "Keane", + "Kelsey", + "Kiyo", + "Michael", + "Nate", + "Peter", + "Sam", + "Stephen", + "Talon", + "Terrance", + "Toru", + "Waylon", + "Boone", + "Clifford", + "Ivan", + "Kendall", + "Lowell", + "Randall", + "Reece", + "Roland", + "Shane", + "Walt", + "Farid", + "Heike", + "Joren", + "Lane", + "Roderick", + "Darnell", + "Deon", + "Emory", + "Graeme", + "Grayson", + "Aitor", + "Alex", + "Arturo", + "Asier", + "Jaime", + "Jonathan", + "Julio", + "Kevin", + "Kosuke", + "Lander", + "Markel", + "Mateo", + "Nil", + "Pau", + "Samuel", + ], + [ + "Anna", + "Corin", + "Elaine", + "Emi", + "Jill", + "Kumiko", + "Liz", + "Lois", + "Lora", + "Molly", + "Patty", + "Ruth", + "Vicki", + "Annie", + "Blossom", + "Clara", + "Eileen", + "Mae", + "Myra", + "Rachel", + "Tami", + "Ashley", + "Mikiko", + "Kiana", + "Perdy", + "Maria", + "Yuho", + "Peren", + "Barbara", + "Diane", + ], + ], + [TrainerType.BAKER]: ["Chris", "Jenn", "Lilly"], + [TrainerType.BEAUTY]: [ + "Cassie", + "Julia", + "Olivia", + "Samantha", + "Valerie", + "Victoria", + "Bridget", + "Connie", + "Jessica", + "Johanna", + "Melissa", + "Sheila", + "Shirley", + "Tiffany", + "Namiko", + "Thalia", + "Grace", + "Lola", + "Lori", + "Maura", + "Tamia", + "Cyndy", + "Devon", + "Gabriella", + "Harley", + "Lindsay", + "Nicola", + "Callie", + "Charlotte", + "Kassandra", + "December", + "Fleming", + "Nikola", + "Aimee", + "Anais", + "Brigitte", + "Cassandra", + "Andrea", + "Brittney", + "Carolyn", + "Krystal", + "Alexis", + "Alice", + "Aina", + "Anya", + "Arianna", + "Aubrey", + "Beverly", + "Camille", + "Beauty", + "Evette", + "Hansol", + "Haruka", + "Jill", + "Jo", + "Lana", + "Lois", + "Lucy", + "Mai", + "Nickie", + "Nicole", + "Prita", + "Rose", + "Shelly", + "Suzy", + "Tessa", + "Anita", + "Alissa", + "Rita", + "Cudsy", + "Eloff", + "Miru", + "Minot", + "Nevah", + "Niven", + "Ogoin", + ], + [TrainerType.BIKER]: [ + "Charles", + "Dwayne", + "Glenn", + "Harris", + "Joel", + "Riley", + "Zeke", + "Alex", + "Billy", + "Ernest", + "Gerald", + "Hideo", + "Isaac", + "Jared", + "Jaren", + "Jaxon", + "Jordy", + "Lao", + "Lukas", + "Malik", + "Nikolas", + "Ricardo", + "Ruben", + "Virgil", + "William", + "Aiden", + "Dale", + "Dan", + "Jacob", + "Markey", + "Reese", + "Teddy", + "Theron", + "Jeremy", + "Morgann", + "Phillip", + "Philip", + "Stanley", + "Dillon", + ], + [TrainerType.BLACK_BELT]: [ + [ + "Kenji", + "Lao", + "Lung", + "Nob", + "Wai", + "Yoshi", + "Atsushi", + "Daisuke", + "Hideki", + "Hitoshi", + "Kiyo", + "Koichi", + "Koji", + "Yuji", + "Cristian", + "Rhett", + "Takao", + "Theodore", + "Zander", + "Aaron", + "Hugh", + "Mike", + "Nicolas", + "Shea", + "Takashi", + "Adam", + "Carl", + "Colby", + "Darren", + "David", + "Davon", + "Derek", + "Eddie", + "Gregory", + "Griffin", + "Jarrett", + "Jeffery", + "Kendal", + "Kyle", + "Luke", + "Miles", + "Nathaniel", + "Philip", + "Rafael", + "Ray", + "Ricky", + "Sean", + "Willie", + "Ander", + "Manford", + "Benjamin", + "Corey", + "Edward", + "Grant", + "Jay", + "Kendrew", + "Kentaro", + "Ryder", + "Teppei", + "Thomas", + "Tyrone", + "Andrey", + "Donny", + "Drago", + "Gordon", + "Grigor", + "Jeriel", + "Kenneth", + "Martell", + "Mathis", + "Rich", + "Rocky", + "Rodrigo", + "Wesley", + "Zachery", + "Alonzo", + "Cadoc", + "Gunnar", + "Igor", + "Killian", + "Markus", + "Ricardo", + "Yanis", + "Banting", + "Clayton", + "Duane", + "Earl", + "Greg", + "Roy", + "Terry", + "Tracy", + "Walter", + "Alvaro", + "Curtis", + "Francis", + "Ross", + "Brice", + "Cheng", + "Dudley", + "Eric", + "Kano", + "Masahiro", + "Randy", + "Ryuji", + "Steve", + "Tadashi", + "Wong", + "Yuen", + "Brian", + "Carter", + "Reece", + "Nick", + "Yang", + ], + [ + "Cora", + "Cyndy", + "Jill", + "Laura", + "Sadie", + "Tessa", + "Vivian", + "Aisha", + "Callie", + "Danielle", + "Helene", + "Jocelyn", + "Lilith", + "Paula", + "Reyna", + "Helen", + "Kelsey", + "Tyler", + "Amy", + "Chandra", + "Hillary", + "Janie", + "Lee", + "Maggie", + "Mikiko", + "Miriam", + "Sharon", + "Susie", + "Xiao", + "Alize", + "Azra", + "Brenda", + "Chalina", + "Chan", + "Glinda", + "Maki", + "Tia", + "Tiffany", + "Wendy", + "Andrea", + "Gabrielle", + "Gerardine", + "Hailey", + "Hedvig", + "Justine", + "Kinsey", + "Sigrid", + "Veronique", + "Tess", + ], + ], + [TrainerType.BREEDER]: [ + [ + "Isaac", + "Myles", + "Salvadore", + "Albert", + "Kahlil", + "Eustace", + "Galen", + "Owen", + "Addison", + "Marcus", + "Foster", + "Cory", + "Glenn", + "Jay", + "Wesley", + "William", + "Adrian", + "Bradley", + "Jaime", + ], + [ + "Allison", + "Alize", + "Bethany", + "Lily", + "Lydia", + "Gabrielle", + "Jayden", + "Pat", + "Veronica", + "Amber", + "Jennifer", + "Kaylee", + "Adelaide", + "Brooke", + "Ethel", + "April", + "Irene", + "Magnolia", + "Amala", + "Mercy", + "Amanda", + "Ikue", + "Savannah", + "Yuka", + "Chloe", + "Debra", + "Denise", + "Elena", + ], + ], + [TrainerType.CLERK]: [ + [ + "Chaz", + "Clemens", + "Doug", + "Fredric", + "Ivan", + "Isaac", + "Nelson", + "Wade", + "Warren", + "Augustin", + "Gilligan", + "Cody", + "Jeremy", + "Shane", + "Dugal", + "Royce", + "Ronald", + ], + [ + "Alberta", + "Ingrid", + "Katie", + "Piper", + "Trisha", + "Wren", + "Britney", + "Lana", + "Jessica", + "Kristen", + "Michelle", + "Gabrielle", + ], + ], + [TrainerType.CYCLIST]: [ + ["Axel", "James", "John", "Ryan", "Hector", "Jeremiah"], + ["Kayla", "Megan", "Nicole", "Rachel", "Krissa", "Adelaide"], + ], + [TrainerType.DANCER]: [ + "Brian", + "Davey", + "Dirk", + "Edmond", + "Mickey", + "Raymond", + "Cara", + "Julia", + "Maika", + "Mireille", + "Ronda", + "Zoe", + ], + [TrainerType.DEPOT_AGENT]: ["Josh", "Hank", "Vincent"], + [TrainerType.DOCTOR]: [ + ["Hank", "Jerry", "Jules", "Logan", "Wayne", "Braid", "Derek", "Heath", "Julius", "Kit", "Graham"], + ["Kirsten", "Sachiko", "Shery", "Carol", "Dixie", "Mariah"], + ], + [TrainerType.FIREBREATHER]: ["Bill", "Burt", "Cliff", "Dick", "Lyle", "Ned", "Otis", "Ray", "Richard", "Walt"], + [TrainerType.FISHERMAN]: [ + "Andre", + "Arnold", + "Barney", + "Chris", + "Edgar", + "Henry", + "Jonah", + "Justin", + "Kyle", + "Martin", + "Marvin", + "Ralph", + "Raymond", + "Scott", + "Stephen", + "Wilton", + "Tully", + "Andrew", + "Barny", + "Carter", + "Claude", + "Dale", + "Elliot", + "Eugene", + "Ivan", + "Ned", + "Nolan", + "Roger", + "Ronald", + "Wade", + "Wayne", + "Darian", + "Kai", + "Chip", + "Hank", + "Kaden", + "Tommy", + "Tylor", + "Alec", + "Brett", + "Cameron", + "Cody", + "Cole", + "Cory", + "Erick", + "George", + "Joseph", + "Juan", + "Kenneth", + "Luc", + "Miguel", + "Travis", + "Walter", + "Zachary", + "Josh", + "Gideon", + "Kyler", + "Liam", + "Murphy", + "Bruce", + "Damon", + "Devon", + "Hubert", + "Jones", + "Lydon", + "Mick", + "Pete", + "Sean", + "Sid", + "Vince", + "Bucky", + "Dean", + "Eustace", + "Kenzo", + "Leroy", + "Mack", + "Ryder", + "Ewan", + "Finn", + "Murray", + "Seward", + "Shad", + "Wharton", + "Finley", + "Fisher", + "Fisk", + "River", + "Sheaffer", + "Timin", + "Carl", + "Ernest", + "Hal", + "Herbert", + "Hisato", + "Mike", + "Vernon", + "Harriet", + "Marina", + "Chase", + ], + [TrainerType.GUITARIST]: [ + "Anna", + "Beverly", + "January", + "Tina", + "Alicia", + "Claudia", + "Julia", + "Lidia", + "Mireia", + "Noelia", + "Sara", + "Sheila", + "Tatiana", + ], + [TrainerType.HARLEQUIN]: [ + "Charley", + "Ian", + "Jack", + "Kerry", + "Louis", + "Pat", + "Paul", + "Rick", + "Anders", + "Clarence", + "Gary", + ], + [TrainerType.HIKER]: [ + "Anthony", + "Bailey", + "Benjamin", + "Daniel", + "Erik", + "Jim", + "Kenny", + "Leonard", + "Michael", + "Parry", + "Phillip", + "Russell", + "Sidney", + "Tim", + "Timothy", + "Alan", + "Brice", + "Clark", + "Eric", + "Lenny", + "Lucas", + "Mike", + "Trent", + "Devan", + "Eli", + "Marc", + "Sawyer", + "Allen", + "Daryl", + "Dudley", + "Earl", + "Franklin", + "Jeremy", + "Marcos", + "Nob", + "Oliver", + "Wayne", + "Alexander", + "Damon", + "Jonathan", + "Justin", + "Kevin", + "Lorenzo", + "Louis", + "Maurice", + "Nicholas", + "Reginald", + "Robert", + "Theodore", + "Bruce", + "Clarke", + "Devin", + "Dwight", + "Edwin", + "Eoin", + "Noland", + "Russel", + "Andy", + "Bret", + "Darrell", + "Gene", + "Hardy", + "Hugh", + "Jebediah", + "Jeremiah", + "Kit", + "Neil", + "Terrell", + "Don", + "Doug", + "Hunter", + "Jared", + "Jerome", + "Keith", + "Manuel", + "Markus", + "Otto", + "Shelby", + "Stephen", + "Teppei", + "Tobias", + "Wade", + "Zaiem", + "Aaron", + "Alain", + "Bergin", + "Bernard", + "Brent", + "Corwin", + "Craig", + "Delmon", + "Dunstan", + "Orestes", + "Ross", + "Davian", + "Calhoun", + "David", + "Gabriel", + "Ryan", + "Thomas", + "Travis", + "Zachary", + "Anuhea", + "Barnaby", + "Claus", + "Collin", + "Colson", + "Dexter", + "Dillan", + "Eugine", + "Farkas", + "Hisato", + "Julius", + "Kenji", + "Irwin", + "Lionel", + "Paul", + "Richter", + "Valentino", + "Donald", + "Douglas", + "Kevyn", + "Chester", + ], //["Angela","Carla","Celia","Daniela","Estela","Fatima","Helena","Leire","Lucia","Luna","Manuela","Mar","Marina","Miyu","Nancy","Nerea","Paula","Rocio","Yanira"] + [TrainerType.HOOLIGANS]: ["Jim & Cas", "Rob & Sal"], + [TrainerType.HOOPSTER]: ["Bobby", "John", "Lamarcus", "Derrick", "Nicolas"], + [TrainerType.INFIELDER]: ["Alex", "Connor", "Todd"], + [TrainerType.JANITOR]: ["Caleb", "Geoff", "Brady", "Felix", "Orville", "Melvin", "Shawn"], + [TrainerType.LINEBACKER]: ["Bob", "Dan", "Jonah"], + [TrainerType.MAID]: ["Belinda", "Sophie", "Emily", "Elena", "Clare", "Alica", "Tanya", "Tammy"], + [TrainerType.MUSICIAN]: [ + "Boris", + "Preston", + "Charles", + "Clyde", + "Vincent", + "Dalton", + "Kirk", + "Shawn", + "Fabian", + "Fernando", + "Joseph", + "Marcos", + "Arturo", + "Jerry", + "Lonnie", + "Tony", + ], + [TrainerType.NURSERY_AIDE]: [ + "Autumn", + "Briana", + "Leah", + "Miho", + "Ethel", + "Hollie", + "Ilse", + "June", + "Kimya", + "Rosalyn", + ], + [TrainerType.OFFICER]: [ + "Dirk", + "Keith", + "Alex", + "Bobby", + "Caleb", + "Danny", + "Dylan", + "Thomas", + "Daniel", + "Jeff", + "Braven", + "Dell", + "Neagle", + "Haruki", + "Mitchell", + "Raymond", + ], + [TrainerType.PARASOL_LADY]: [ + "Angelica", + "Clarissa", + "Madeline", + "Akari", + "Annabell", + "Kayley", + "Rachel", + "Alexa", + "Sabrina", + "April", + "Gwyneth", + "Laura", + "Lumi", + "Mariah", + "Melita", + "Nicole", + "Tihana", + "Ingrid", + "Tyra", + ], + [TrainerType.PILOT]: ["Chase", "Leonard", "Ted", "Elron", "Ewing", "Flynn", "Winslow"], + [TrainerType.POKEFAN]: [ + [ + "Alex", + "Allan", + "Brandon", + "Carter", + "Colin", + "Derek", + "Jeremy", + "Joshua", + "Rex", + "Robert", + "Trevor", + "William", + "Colton", + "Miguel", + "Francisco", + "Kaleb", + "Leonard", + "Boone", + "Elliot", + "Jude", + "Norbert", + "Corey", + "Gabe", + "Baxter", + ], + [ + "Beverly", + "Georgia", + "Jaime", + "Ruth", + "Isabel", + "Marissa", + "Vanessa", + "Annika", + "Bethany", + "Kimberly", + "Meredith", + "Rebekah", + "Eleanor", + "Darcy", + "Lydia", + "Sachiko", + "Abigail", + "Agnes", + "Lydie", + "Roisin", + "Tara", + "Carmen", + "Janet", + ], + ], + [TrainerType.PRESCHOOLER]: [ + [ + "Billy", + "Doyle", + "Evan", + "Homer", + "Tully", + "Albert", + "Buster", + "Greg", + "Ike", + "Jojo", + "Tyrone", + "Adrian", + "Oliver", + "Hayden", + "Hunter", + "Kaleb", + "Liam", + "Dylan", + ], + [ + "Juliet", + "Mia", + "Sarah", + "Wendy", + "Winter", + "Chrissy", + "Eva", + "Lin", + "Samantha", + "Ella", + "Lily", + "Natalie", + "Ailey", + "Hannah", + "Malia", + "Kindra", + "Nancy", + ], + ], + [TrainerType.PSYCHIC]: [ + [ + "Fidel", + "Franklin", + "Gilbert", + "Greg", + "Herman", + "Jared", + "Mark", + "Nathan", + "Norman", + "Phil", + "Richard", + "Rodney", + "Cameron", + "Edward", + "Fritz", + "Joshua", + "Preston", + "Virgil", + "William", + "Alvaro", + "Blake", + "Cedric", + "Keenan", + "Nicholas", + "Dario", + "Johan", + "Lorenzo", + "Tyron", + "Bryce", + "Corbin", + "Deandre", + "Elijah", + "Kody", + "Landon", + "Maxwell", + "Mitchell", + "Sterling", + "Eli", + "Nelson", + "Vernon", + "Gaven", + "Gerard", + "Low", + "Micki", + "Perry", + "Rudolf", + "Tommy", + "Al", + "Nandor", + "Tully", + "Arthur", + "Emanuel", + "Franz", + "Harry", + "Paschal", + "Robert", + "Sayid", + "Angelo", + "Anton", + "Arin", + "Avery", + "Danny", + "Frasier", + "Harrison", + "Jaime", + "Ross", + "Rui", + "Vlad", + "Mason", + ], + [ + "Alexis", + "Hannah", + "Jacki", + "Jaclyn", + "Kayla", + "Maura", + "Samantha", + "Alix", + "Brandi", + "Edie", + "Macey", + "Mariella", + "Marlene", + "Laura", + "Rodette", + "Abigail", + "Brittney", + "Chelsey", + "Daisy", + "Desiree", + "Kendra", + "Lindsey", + "Rachael", + "Valencia", + "Belle", + "Cybil", + "Doreen", + "Dua", + "Future", + "Lin", + "Madhu", + "Alia", + "Ena", + "Joyce", + "Lynette", + "Olesia", + "Sarah", + ], + ], + [TrainerType.RANGER]: [ + [ + "Carlos", + "Jackson", + "Sebastian", + "Gav", + "Lorenzo", + "Logan", + "Nicolas", + "Trenton", + "Deshawn", + "Dwayne", + "Jeffery", + "Kyler", + "Taylor", + "Alain", + "Claude", + "Crofton", + "Forrest", + "Harry", + "Jaden", + "Keith", + "Lewis", + "Miguel", + "Pedro", + "Ralph", + "Richard", + "Bret", + "Daryl", + "Eddie", + "Johan", + "Leaf", + "Louis", + "Maxwell", + "Parker", + "Rick", + "Steve", + "Bjorn", + "Chaise", + "Dean", + "Lee", + "Maurice", + "Nash", + "Ralf", + "Reed", + "Shinobu", + "Silas", + ], + [ + "Catherine", + "Jenna", + "Sophia", + "Merdith", + "Nora", + "Beth", + "Chelsea", + "Katelyn", + "Madeline", + "Allison", + "Ashlee", + "Felicia", + "Krista", + "Annie", + "Audra", + "Brenda", + "Chloris", + "Eliza", + "Heidi", + "Irene", + "Mary", + "Mylene", + "Shanti", + "Shelly", + "Thalia", + "Anja", + "Briana", + "Dianna", + "Elaine", + "Elle", + "Hillary", + "Katie", + "Lena", + "Lois", + "Malory", + "Melita", + "Mikiko", + "Naoko", + "Serenity", + "Ambre", + "Brooke", + "Clementine", + "Melina", + "Petra", + "Twiggy", + ], + ], + [TrainerType.RICH]: [ + [ + "Alfred", + "Edward", + "Gregory", + "Preston", + "Thomas", + "Tucker", + "Walter", + "Clifford", + "Everett", + "Micah", + "Nate", + "Pierre", + "Terrance", + "Arthur", + "Brooks", + "Emanuel", + "Lamar", + "Jeremy", + "Leonardo", + "Milton", + "Frederic", + "Renaud", + "Robert", + "Yan", + "Daniel", + "Sheldon", + "Stonewall", + "Gerald", + "Ronald", + "Smith", + "Stanley", + "Reginald", + "Orson", + "Wilco", + "Caden", + "Glenn", + ], + [ + "Rebecca", + "Reina", + "Cassandra", + "Emilia", + "Grace", + "Marian", + "Elizabeth", + "Kathleen", + "Sayuri", + "Caroline", + "Judy", + ], + ], + [TrainerType.RICH_KID]: [ + [ + "Garret", + "Winston", + "Dawson", + "Enrique", + "Jason", + "Roman", + "Trey", + "Liam", + "Anthony", + "Brad", + "Cody", + "Manuel", + "Martin", + "Pierce", + "Rolan", + "Keenan", + "Filbert", + "Antoin", + "Cyus", + "Diek", + "Dugo", + "Flitz", + "Jurek", + "Lond", + "Perd", + "Quint", + "Basto", + "Benit", + "Brot", + "Denc", + "Guyit", + "Marcon", + "Perc", + "Puros", + "Roex", + "Sainz", + "Symin", + "Tark", + "Venak", + ], + [ + "Anette", + "Brianna", + "Cindy", + "Colleen", + "Daphne", + "Elizabeth", + "Naomi", + "Sarah", + "Charlotte", + "Gillian", + "Jacki", + "Lady", + "Melissa", + "Celeste", + "Colette", + "Elizandra", + "Isabel", + "Lynette", + "Magnolia", + "Sophie", + "Lina", + "Dulcie", + "Auro", + "Brin", + "Caril", + "Eloos", + "Gwin", + "Illa", + "Kowly", + "Rima", + "Ristin", + "Vesey", + "Brena", + "Deasy", + "Denslon", + "Kylet", + "Nemi", + "Rene", + "Sanol", + "Stouner", + "Sturk", + "Talmen", + "Zoila", + ], + ], + [TrainerType.ROUGHNECK]: [ + "Camron", + "Corey", + "Gabriel", + "Isaiah", + "Jamal", + "Koji", + "Luke", + "Paxton", + "Raul", + "Zeek", + "Kirby", + "Chance", + "Dave", + "Fletcher", + "Johnny", + "Reese", + "Joey", + "Ricky", + "Silvester", + "Martin", + ], + [TrainerType.SAILOR]: [ + "Alberto", + "Bost", + "Brennan", + "Brenden", + "Claude", + "Cory", + "Damian", + "Dirk", + "Duncan", + "Dwayne", + "Dylan", + "Eddie", + "Edmond", + "Elijah", + "Ernest", + "Eugene", + "Garrett", + "Golos", + "Gratin", + "Grestly", + "Harry", + "Hols", + "Hudson", + "Huey", + "Jebol", + "Jeff", + "Leonald", + "Luther", + "Kelvin", + "Kenneth", + "Kent", + "Knook", + "Marc", + "Mifis", + "Monar", + "Morkor", + "Ordes", + "Oxlin", + "Parker", + "Paul", + "Philip", + "Roberto", + "Samson", + "Skyler", + "Stanly", + "Tebu", + "Terrell", + "Trevor", + "Yasu", + "Zachariah", + ], + [TrainerType.SCIENTIST]: [ + [ + "Jed", + "Marc", + "Mitch", + "Rich", + "Ross", + "Beau", + "Braydon", + "Connor", + "Ed", + "Ivan", + "Jerry", + "Jose", + "Joshua", + "Parker", + "Rodney", + "Taylor", + "Ted", + "Travis", + "Zackery", + "Darrius", + "Emilio", + "Fredrick", + "Shaun", + "Stefano", + "Travon", + "Daniel", + "Garett", + "Gregg", + "Linden", + "Lowell", + "Trenton", + "Dudley", + "Luke", + "Markus", + "Nathan", + "Orville", + "Randall", + "Ron", + "Ronald", + "Simon", + "Steve", + "William", + "Franklin", + "Clarke", + "Jacques", + "Terrance", + "Ernst", + "Justus", + "Ikaika", + "Jayson", + "Kyle", + "Reid", + "Tyrone", + "Adam", + "Albert", + "Alphonse", + "Cory", + "Donnie", + "Elton", + "Francis", + "Gordon", + "Herbert", + "Humphrey", + "Jordan", + "Julian", + "Keaton", + "Levi", + "Melvin", + "Murray", + "West", + "Craig", + "Coren", + "Dubik", + "Kotan", + "Lethco", + "Mante", + "Mort", + "Myron", + "Odlow", + "Ribek", + "Roeck", + "Vogi", + "Vonder", + "Zogo", + "Doimo", + "Doton", + "Durel", + "Hildon", + "Kukla", + "Messa", + "Nanot", + "Platen", + "Raburn", + "Reman", + "Acrod", + "Coffy", + "Elrok", + "Foss", + "Hardig", + "Hombol", + "Hospel", + "Kaller", + "Klots", + "Krilok", + "Limar", + "Loket", + "Mesak", + "Morbit", + "Newin", + "Orill", + "Tabor", + "Tekot", + ], + [ + "Blythe", + "Chan", + "Kathrine", + "Marie", + "Maria", + "Naoko", + "Samantha", + "Satomi", + "Shannon", + "Athena", + "Caroline", + "Lumi", + "Lumina", + "Marissa", + "Sonia", + ], + ], + [TrainerType.SMASHER]: ["Aspen", "Elena", "Mari", "Amy", "Lizzy"], + [TrainerType.SNOW_WORKER]: [ + [ + "Braden", + "Brendon", + "Colin", + "Conrad", + "Dillan", + "Gary", + "Gerardo", + "Holden", + "Jackson", + "Mason", + "Quentin", + "Willy", + "Noel", + "Arnold", + "Brady", + "Brand", + "Cairn", + "Cliff", + "Don", + "Eddie", + "Felix", + "Filipe", + "Glenn", + "Gus", + "Heath", + "Matthew", + "Patton", + "Rich", + "Rob", + "Ryan", + "Scott", + "Shelby", + "Sterling", + "Tyler", + "Victor", + "Zack", + "Friedrich", + "Herman", + "Isaac", + "Leo", + "Maynard", + "Mitchell", + "Morgann", + "Nathan", + "Niel", + "Pasqual", + "Paul", + "Tavarius", + "Tibor", + "Dimitri", + "Narek", + "Yusif", + "Frank", + "Jeff", + "Vaclav", + "Ovid", + "Francis", + "Keith", + "Russel", + "Sangon", + "Toway", + "Bomber", + "Chean", + "Demit", + "Hubor", + "Kebile", + "Laber", + "Ordo", + "Retay", + "Ronix", + "Wagel", + "Dobit", + "Kaster", + "Lobel", + "Releo", + "Saken", + "Rustix", + ], + ["Georgia", "Sandra", "Yvonne"], + ], + [TrainerType.STRIKER]: ["Marco", "Roberto", "Tony"], + [TrainerType.SCHOOL_KID]: [ + [ + "Alan", + "Billy", + "Chad", + "Danny", + "Dudley", + "Jack", + "Joe", + "Johnny", + "Kipp", + "Nate", + "Ricky", + "Tommy", + "Jerry", + "Paul", + "Ted", + "Chance", + "Esteban", + "Forrest", + "Harrison", + "Connor", + "Sherman", + "Torin", + "Travis", + "Al", + "Carter", + "Edgar", + "Jem", + "Sammy", + "Shane", + "Shayne", + "Alvin", + "Keston", + "Neil", + "Seymour", + "William", + "Carson", + "Clark", + "Nolan", + ], + [ + "Georgia", + "Karen", + "Meiko", + "Christine", + "Mackenzie", + "Tiera", + "Ann", + "Gina", + "Lydia", + "Marsha", + "Millie", + "Sally", + "Serena", + "Silvia", + "Alberta", + "Cassie", + "Mara", + "Rita", + "Georgie", + "Meena", + "Nitzel", + ], + ], + [TrainerType.SWIMMER]: [ + [ + "Berke", + "Cameron", + "Charlie", + "George", + "Harold", + "Jerome", + "Kirk", + "Mathew", + "Parker", + "Randall", + "Seth", + "Simon", + "Tucker", + "Austin", + "Barry", + "Chad", + "Cody", + "Darrin", + "David", + "Dean", + "Douglas", + "Franklin", + "Gilbert", + "Herman", + "Jack", + "Luis", + "Matthew", + "Reed", + "Richard", + "Rodney", + "Roland", + "Spencer", + "Stan", + "Tony", + "Clarence", + "Declan", + "Dominik", + "Harrison", + "Kevin", + "Leonardo", + "Nolen", + "Pete", + "Santiago", + "Axle", + "Braden", + "Finn", + "Garrett", + "Mymo", + "Reece", + "Samir", + "Toby", + "Adrian", + "Colton", + "Dillon", + "Erik", + "Evan", + "Francisco", + "Glenn", + "Kurt", + "Oscar", + "Ricardo", + "Sam", + "Sheltin", + "Troy", + "Vincent", + "Wade", + "Wesley", + "Duane", + "Elmo", + "Esteban", + "Frankie", + "Ronald", + "Tyson", + "Bart", + "Matt", + "Tim", + "Wright", + "Jeffery", + "Kyle", + "Alessandro", + "Estaban", + "Kieran", + "Ramses", + "Casey", + "Dakota", + "Jared", + "Kalani", + "Keoni", + "Lawrence", + "Logan", + "Robert", + "Roddy", + "Yasu", + "Derek", + "Jacob", + "Bruce", + "Clayton", + ], + [ + "Briana", + "Dawn", + "Denise", + "Diana", + "Elaine", + "Kara", + "Kaylee", + "Lori", + "Nicole", + "Nikki", + "Paula", + "Susie", + "Wendy", + "Alice", + "Beth", + "Beverly", + "Brenda", + "Dana", + "Debra", + "Grace", + "Jenny", + "Katie", + "Laurel", + "Linda", + "Missy", + "Sharon", + "Tanya", + "Tara", + "Tisha", + "Carlee", + "Imani", + "Isabelle", + "Kyla", + "Sienna", + "Abigail", + "Amara", + "Anya", + "Connie", + "Maria", + "Melissa", + "Nora", + "Shirley", + "Shania", + "Tiffany", + "Aubree", + "Cassandra", + "Claire", + "Crystal", + "Erica", + "Gabrielle", + "Haley", + "Jessica", + "Joanna", + "Lydia", + "Mallory", + "Mary", + "Miranda", + "Paige", + "Sophia", + "Vanessa", + "Chelan", + "Debbie", + "Joy", + "Kendra", + "Leona", + "Mina", + "Caroline", + "Joyce", + "Larissa", + "Rebecca", + "Tyra", + "Dara", + "Desiree", + "Kaoru", + "Ruth", + "Coral", + "Genevieve", + "Isla", + "Marissa", + "Romy", + "Sheryl", + "Alexandria", + "Alicia", + "Chelsea", + "Jade", + "Kelsie", + "Laura", + "Portia", + "Shelby", + "Sara", + "Tiare", + "Kyra", + "Natasha", + "Layla", + "Scarlett", + "Cora", + ], + ], + [TrainerType.TWINS]: [ + "Amy & May", + "Jo & Zoe", + "Meg & Peg", + "Ann & Anne", + "Lea & Pia", + "Amy & Liv", + "Gina & Mia", + "Miu & Yuki", + "Tori & Tia", + "Eli & Anne", + "Jen & Kira", + "Joy & Meg", + "Kiri & Jan", + "Miu & Mia", + "Emma & Lil", + "Liv & Liz", + "Teri & Tia", + "Amy & Mimi", + "Clea & Gil", + "Day & Dani", + "Kay & Tia", + "Tori & Til", + "Saya & Aya", + "Emy & Lin", + "Kumi & Amy", + "Mayo & May", + "Ally & Amy", + "Lia & Lily", + "Rae & Ula", + "Sola & Ana", + "Tara & Val", + "Faith & Joy", + "Nana & Nina", + ], + [TrainerType.VETERAN]: [ + [ + "Armando", + "Brenden", + "Brian", + "Clayton", + "Edgar", + "Emanuel", + "Grant", + "Harlan", + "Terrell", + "Arlen", + "Chester", + "Hugo", + "Martell", + "Ray", + "Shaun", + "Abraham", + "Carter", + "Claude", + "Jerry", + "Lucius", + "Murphy", + "Rayne", + "Ron", + "Sinan", + "Sterling", + "Vincent", + "Zach", + "Gerard", + "Gilles", + "Louis", + "Timeo", + "Akira", + "Don", + "Eric", + "Harry", + "Leon", + "Roger", + "Angus", + "Aristo", + "Brone", + "Johnny", + ], + [ + "Julia", + "Karla", + "Kim", + "Sayuri", + "Tiffany", + "Cathy", + "Cecile", + "Chloris", + "Denae", + "Gina", + "Maya", + "Oriana", + "Portia", + "Rhona", + "Rosaline", + "Catrina", + "Inga", + "Trisha", + "Heather", + "Lynn", + "Sheri", + "Alonsa", + "Ella", + "Leticia", + "Kiara", + ], + ], + [TrainerType.WAITER]: [ + ["Bert", "Clint", "Maxwell", "Lou"], + ["Kati", "Aurora", "Bonita", "Flo", "Tia", "Jan", "Olwen", "Paget", "Paula", "Talia"], + ], + [TrainerType.WORKER]: [ + [ + "Braden", + "Brendon", + "Colin", + "Conrad", + "Dillan", + "Gary", + "Gerardo", + "Holden", + "Jackson", + "Mason", + "Quentin", + "Willy", + "Noel", + "Arnold", + "Brady", + "Brand", + "Cairn", + "Cliff", + "Don", + "Eddie", + "Felix", + "Filipe", + "Glenn", + "Gus", + "Heath", + "Matthew", + "Patton", + "Rich", + "Rob", + "Ryan", + "Scott", + "Shelby", + "Sterling", + "Tyler", + "Victor", + "Zack", + "Friedrich", + "Herman", + "Isaac", + "Leo", + "Maynard", + "Mitchell", + "Morgann", + "Nathan", + "Niel", + "Pasqual", + "Paul", + "Tavarius", + "Tibor", + "Dimitri", + "Narek", + "Yusif", + "Frank", + "Jeff", + "Vaclav", + "Ovid", + "Francis", + "Keith", + "Russel", + "Sangon", + "Toway", + "Bomber", + "Chean", + "Demit", + "Hubor", + "Kebile", + "Laber", + "Ordo", + "Retay", + "Ronix", + "Wagel", + "Dobit", + "Kaster", + "Lobel", + "Releo", + "Saken", + "Rustix", + ], + ["Georgia", "Sandra", "Yvonne"], + ], + [TrainerType.YOUNGSTER]: [ + [ + "Albert", + "Gordon", + "Ian", + "Jason", + "Jimmy", + "Mikey", + "Owen", + "Samuel", + "Warren", + "Allen", + "Ben", + "Billy", + "Calvin", + "Dillion", + "Eddie", + "Joey", + "Josh", + "Neal", + "Timmy", + "Tommy", + "Breyden", + "Deandre", + "Demetrius", + "Dillon", + "Jaylen", + "Johnson", + "Shigenobu", + "Chad", + "Cole", + "Cordell", + "Dan", + "Dave", + "Destin", + "Nash", + "Tyler", + "Yasu", + "Austin", + "Dallas", + "Darius", + "Donny", + "Jonathon", + "Logan", + "Michael", + "Oliver", + "Sebastian", + "Tristan", + "Wayne", + "Norman", + "Roland", + "Regis", + "Abe", + "Astor", + "Keita", + "Kenneth", + "Kevin", + "Kyle", + "Lester", + "Masao", + "Nicholas", + "Parker", + "Wes", + "Zachary", + "Cody", + "Henley", + "Jaye", + "Karl", + "Kenny", + "Masahiro", + "Pedro", + "Petey", + "Sinclair", + "Terrell", + "Waylon", + "Aidan", + "Anthony", + "David", + "Jacob", + "Jayden", + "Cutler", + "Ham", + "Caleb", + "Kai", + "Honus", + "Kenway", + "Bret", + "Chris", + "Cid", + "Dennis", + "Easton", + "Ken", + "Robby", + "Ronny", + "Shawn", + "Benjamin", + "Jake", + "Travis", + "Adan", + "Aday", + "Beltran", + "Elian", + "Hernan", + "Julen", + "Luka", + "Roi", + "Bernie", + "Dustin", + "Jonathan", + "Wyatt", + ], + [ + "Alice", + "Bridget", + "Carrie", + "Connie", + "Dana", + "Ellen", + "Krise", + "Laura", + "Linda", + "Michelle", + "Shannon", + "Andrea", + "Crissy", + "Janice", + "Robin", + "Sally", + "Tiana", + "Haley", + "Ali", + "Ann", + "Dalia", + "Dawn", + "Iris", + "Joana", + "Julia", + "Kay", + "Lisa", + "Megan", + "Mikaela", + "Miriam", + "Paige", + "Reli", + "Blythe", + "Briana", + "Caroline", + "Cassidy", + "Kaitlin", + "Madeline", + "Molly", + "Natalie", + "Samantha", + "Sarah", + "Cathy", + "Dye", + "Eri", + "Eva", + "Fey", + "Kara", + "Lurleen", + "Maki", + "Mali", + "Maya", + "Miki", + "Sibyl", + "Daya", + "Diana", + "Flo", + "Helia", + "Henrietta", + "Isabel", + "Mai", + "Persephone", + "Serena", + "Anna", + "Charlotte", + "Elin", + "Elsa", + "Lise", + "Sara", + "Suzette", + "Audrey", + "Emmy", + "Isabella", + "Madison", + "Rika", + "Rylee", + "Salla", + "Ellie", + "Alexandra", + "Amy", + "Lass", + "Brittany", + "Chel", + "Cindy", + "Dianne", + "Emily", + "Emma", + "Evelyn", + "Hana", + "Harleen", + "Hazel", + "Jocelyn", + "Katrina", + "Kimberly", + "Lina", + "Marge", + "Mila", + "Mizuki", + "Rena", + "Sal", + "Satoko", + "Summer", + "Tomoe", + "Vicky", + "Yue", + "Yumi", + "Lauren", + "Rei", + "Riley", + "Lois", + "Nancy", + "Tammy", + "Terry", + ], + ], + [TrainerType.HEX_MANIAC]: [ + "Kindra", + "Patricia", + "Tammy", + "Tasha", + "Valerie", + "Alaina", + "Kathleen", + "Leah", + "Makie", + "Sylvia", + "Anina", + "Arachna", + "Carrie", + "Desdemona", + "Josette", + "Luna", + "Melanie", + "Osanna", + "Raziah", + ], }; // function used in a commented code -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function fetchAndPopulateTrainerNames(url: string, parser: DOMParser, trainerNames: Set, femaleTrainerNames: Set, forceFemale: boolean = false) { +// biome-ignore lint/correctness/noUnusedVariables: TODO make this into a script instead of having it be in src/data... +function fetchAndPopulateTrainerNames( + url: string, + parser: DOMParser, + trainerNames: Set, + femaleTrainerNames: Set, + forceFemale = false, +) { return new Promise(resolve => { fetch(`https://bulbapedia.bulbagarden.net/wiki/${url}_(Trainer_class)`) .then(response => response.text()) @@ -140,19 +2738,21 @@ function fetchAndPopulateTrainerNames(url: string, parser: DOMParser, trainerNam if (!trainerListHeader) { return []; } - const elements = [ ...(trainerListHeader?.parentElement?.childNodes ?? []) ]; + const elements = [...(trainerListHeader?.parentElement?.childNodes ?? [])]; const startChildIndex = elements.indexOf(trainerListHeader); const endChildIndex = elements.findIndex(h => h.nodeName === "H2" && elements.indexOf(h) > startChildIndex); - const tables = elements.filter(t => { - if (t.nodeName !== "TABLE" || t["className"] !== "expandable") { - return false; - } - const childIndex = elements.indexOf(t); - return childIndex > startChildIndex && childIndex < endChildIndex; - }).map(t => t as Element); + const tables = elements + .filter(t => { + if (t.nodeName !== "TABLE" || t["className"] !== "expandable") { + return false; + } + const childIndex = elements.indexOf(t); + return childIndex > startChildIndex && childIndex < endChildIndex; + }) + .map(t => t as Element); console.log(url, tables); for (const table of tables) { - const trainerRows = [ ...table.querySelectorAll("tr:not(:first-child)") ].filter(r => r.children.length === 9); + const trainerRows = [...table.querySelectorAll("tr:not(:first-child)")].filter(r => r.children.length === 9); for (const row of trainerRows) { const nameCell = row.firstElementChild; if (!nameCell) { diff --git a/src/data/type.ts b/src/data/type.ts index c57fd3b94a3..c9bf346fb85 100644 --- a/src/data/type.ts +++ b/src/data/type.ts @@ -271,7 +271,10 @@ export function getTypeDamageMultiplier(attackType: PokemonType, defType: Pokemo * Retrieve the color corresponding to a specific damage multiplier * @returns A color or undefined if the default color should be used */ -export function getTypeDamageMultiplierColor(multiplier: TypeDamageMultiplier, side: "defense" | "offense"): string | undefined { +export function getTypeDamageMultiplierColor( + multiplier: TypeDamageMultiplier, + side: "defense" | "offense", +): string | undefined { if (side === "offense") { switch (multiplier) { case 0: @@ -291,7 +294,8 @@ export function getTypeDamageMultiplierColor(multiplier: TypeDamageMultiplier, s case 8: return "#52C200"; } - } else if (side === "defense") { + } + if (side === "defense") { switch (multiplier) { case 0: return "#B1B100"; @@ -313,47 +317,47 @@ export function getTypeDamageMultiplierColor(multiplier: TypeDamageMultiplier, s } } -export function getTypeRgb(type: PokemonType): [ number, number, number ] { +export function getTypeRgb(type: PokemonType): [number, number, number] { switch (type) { case PokemonType.NORMAL: - return [ 168, 168, 120 ]; + return [168, 168, 120]; case PokemonType.FIGHTING: - return [ 192, 48, 40 ]; + return [192, 48, 40]; case PokemonType.FLYING: - return [ 168, 144, 240 ]; + return [168, 144, 240]; case PokemonType.POISON: - return [ 160, 64, 160 ]; + return [160, 64, 160]; case PokemonType.GROUND: - return [ 224, 192, 104 ]; + return [224, 192, 104]; case PokemonType.ROCK: - return [ 184, 160, 56 ]; + return [184, 160, 56]; case PokemonType.BUG: - return [ 168, 184, 32 ]; + return [168, 184, 32]; case PokemonType.GHOST: - return [ 112, 88, 152 ]; + return [112, 88, 152]; case PokemonType.STEEL: - return [ 184, 184, 208 ]; + return [184, 184, 208]; case PokemonType.FIRE: - return [ 240, 128, 48 ]; + return [240, 128, 48]; case PokemonType.WATER: - return [ 104, 144, 240 ]; + return [104, 144, 240]; case PokemonType.GRASS: - return [ 120, 200, 80 ]; + return [120, 200, 80]; case PokemonType.ELECTRIC: - return [ 248, 208, 48 ]; + return [248, 208, 48]; case PokemonType.PSYCHIC: - return [ 248, 88, 136 ]; + return [248, 88, 136]; case PokemonType.ICE: - return [ 152, 216, 216 ]; + return [152, 216, 216]; case PokemonType.DRAGON: - return [ 112, 56, 248 ]; + return [112, 56, 248]; case PokemonType.DARK: - return [ 112, 88, 72 ]; + return [112, 88, 72]; case PokemonType.FAIRY: - return [ 232, 136, 200 ]; + return [232, 136, 200]; case PokemonType.STELLAR: - return [ 255, 255, 255 ]; + return [255, 255, 255]; default: - return [ 0, 0, 0 ]; + return [0, 0, 0]; } } diff --git a/src/data/weather.ts b/src/data/weather.ts index 2b7333de7dd..c2b0263c9f6 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -106,9 +106,13 @@ export class Weather { const field = globalScene.getField(true); for (const pokemon of field) { - let suppressWeatherEffectAbAttr: SuppressWeatherEffectAbAttr | null = pokemon.getAbility().getAttrs(SuppressWeatherEffectAbAttr)[0]; + let suppressWeatherEffectAbAttr: SuppressWeatherEffectAbAttr | null = pokemon + .getAbility() + .getAttrs(SuppressWeatherEffectAbAttr)[0]; if (!suppressWeatherEffectAbAttr) { - suppressWeatherEffectAbAttr = pokemon.hasPassive() ? pokemon.getPassiveAbility().getAttrs(SuppressWeatherEffectAbAttr)[0] : null; + suppressWeatherEffectAbAttr = pokemon.hasPassive() + ? pokemon.getPassiveAbility().getAttrs(SuppressWeatherEffectAbAttr)[0] + : null; } if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable)) { return true; @@ -172,9 +176,13 @@ export function getWeatherLapseMessage(weatherType: WeatherType): string | null export function getWeatherDamageMessage(weatherType: WeatherType, pokemon: Pokemon): string | null { switch (weatherType) { case WeatherType.SANDSTORM: - return i18next.t("weather:sandstormDamageMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("weather:sandstormDamageMessage", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); case WeatherType.HAIL: - return i18next.t("weather:hailDamageMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("weather:hailDamageMessage", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } return null; @@ -261,9 +269,14 @@ export function getTerrainClearMessage(terrainType: TerrainType): string | null export function getTerrainBlockMessage(pokemon: Pokemon, terrainType: TerrainType): string { if (terrainType === TerrainType.MISTY) { - return i18next.t("terrain:mistyBlockMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }); + return i18next.t("terrain:mistyBlockMessage", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }); } - return i18next.t("terrain:defaultBlockMessage", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), terrainName: getTerrainName(terrainType) }); + return i18next.t("terrain:defaultBlockMessage", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + terrainName: getTerrainName(terrainType), + }); } export interface WeatherPoolEntry { @@ -276,9 +289,7 @@ export function getRandomWeatherType(arena: Arena): WeatherType { const hasSun = arena.getTimeOfDay() < 2; switch (arena.biomeType) { case Biome.GRASS: - weatherPool = [ - { weatherType: WeatherType.NONE, weight: 7 } - ]; + weatherPool = [{ weatherType: WeatherType.NONE, weight: 7 }]; if (hasSun) { weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 3 }); } @@ -295,26 +306,26 @@ export function getRandomWeatherType(arena: Arena): WeatherType { case Biome.FOREST: weatherPool = [ { weatherType: WeatherType.NONE, weight: 8 }, - { weatherType: WeatherType.RAIN, weight: 5 } + { weatherType: WeatherType.RAIN, weight: 5 }, ]; break; case Biome.SEA: weatherPool = [ { weatherType: WeatherType.NONE, weight: 3 }, - { weatherType: WeatherType.RAIN, weight: 12 } + { weatherType: WeatherType.RAIN, weight: 12 }, ]; break; case Biome.SWAMP: weatherPool = [ { weatherType: WeatherType.NONE, weight: 3 }, { weatherType: WeatherType.RAIN, weight: 4 }, - { weatherType: WeatherType.FOG, weight: 1 } + { weatherType: WeatherType.FOG, weight: 1 }, ]; break; case Biome.BEACH: weatherPool = [ { weatherType: WeatherType.NONE, weight: 8 }, - { weatherType: WeatherType.RAIN, weight: 3 } + { weatherType: WeatherType.RAIN, weight: 3 }, ]; if (hasSun) { weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 5 }); @@ -324,27 +335,23 @@ export function getRandomWeatherType(arena: Arena): WeatherType { weatherPool = [ { weatherType: WeatherType.NONE, weight: 10 }, { weatherType: WeatherType.RAIN, weight: 5 }, - { weatherType: WeatherType.FOG, weight: 1 } + { weatherType: WeatherType.FOG, weight: 1 }, ]; break; case Biome.SEABED: - weatherPool = [ - { weatherType: WeatherType.RAIN, weight: 1 } - ]; + weatherPool = [{ weatherType: WeatherType.RAIN, weight: 1 }]; break; case Biome.BADLANDS: weatherPool = [ { weatherType: WeatherType.NONE, weight: 8 }, - { weatherType: WeatherType.SANDSTORM, weight: 2 } + { weatherType: WeatherType.SANDSTORM, weight: 2 }, ]; if (hasSun) { weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 5 }); } break; case Biome.DESERT: - weatherPool = [ - { weatherType: WeatherType.SANDSTORM, weight: 2 } - ]; + weatherPool = [{ weatherType: WeatherType.SANDSTORM, weight: 2 }]; if (hasSun) { weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 2 }); } @@ -353,37 +360,38 @@ export function getRandomWeatherType(arena: Arena): WeatherType { weatherPool = [ { weatherType: WeatherType.NONE, weight: 3 }, { weatherType: WeatherType.SNOW, weight: 4 }, - { weatherType: WeatherType.HAIL, weight: 1 } + { weatherType: WeatherType.HAIL, weight: 1 }, ]; break; case Biome.MEADOW: - weatherPool = [ - { weatherType: WeatherType.NONE, weight: 2 } - ]; + weatherPool = [{ weatherType: WeatherType.NONE, weight: 2 }]; if (hasSun) { weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 2 }); } case Biome.VOLCANO: weatherPool = [ - { weatherType: hasSun ? WeatherType.SUNNY : WeatherType.NONE, weight: 1 } + { + weatherType: hasSun ? WeatherType.SUNNY : WeatherType.NONE, + weight: 1, + }, ]; break; case Biome.GRAVEYARD: weatherPool = [ { weatherType: WeatherType.NONE, weight: 3 }, - { weatherType: WeatherType.FOG, weight: 1 } + { weatherType: WeatherType.FOG, weight: 1 }, ]; break; case Biome.JUNGLE: weatherPool = [ { weatherType: WeatherType.NONE, weight: 8 }, - { weatherType: WeatherType.RAIN, weight: 2 } + { weatherType: WeatherType.RAIN, weight: 2 }, ]; break; case Biome.SNOWY_FOREST: weatherPool = [ { weatherType: WeatherType.SNOW, weight: 7 }, - { weatherType: WeatherType.HAIL, weight: 1 } + { weatherType: WeatherType.HAIL, weight: 1 }, ]; break; case Biome.ISLAND: @@ -403,7 +411,9 @@ export function getRandomWeatherType(arena: Arena): WeatherType { if (weatherPool.length > 1) { let totalWeight = 0; - weatherPool.forEach(w => totalWeight += w.weight); + for (const w of weatherPool) { + totalWeight += w.weight; + } const rand = Utils.randSeedInt(totalWeight); let w = 0; @@ -415,7 +425,5 @@ export function getRandomWeatherType(arena: Arena): WeatherType { } } - return weatherPool.length - ? weatherPool[0].weatherType - : WeatherType.NONE; + return weatherPool.length ? weatherPool[0].weatherType : WeatherType.NONE; } diff --git a/src/debug.js b/src/debug.js index e0f27332d3d..6ddf6046c7a 100644 --- a/src/debug.js +++ b/src/debug.js @@ -3,7 +3,9 @@ export function getData() { if (!dataStr) { return null; } - return JSON.parse(atob(dataStr), (k, v) => k.endsWith("Attr") && ![ "natureAttr", "abilityAttr", "passiveAttr" ].includes(k) ? BigInt(v) : v); + return JSON.parse(atob(dataStr), (k, v) => + k.endsWith("Attr") && !["natureAttr", "abilityAttr", "passiveAttr"].includes(k) ? BigInt(v) : v, + ); } export function getSession() { diff --git a/src/enums/stat.ts b/src/enums/stat.ts index 6b3f7dc6d79..a2b81b7e64b 100644 --- a/src/enums/stat.ts +++ b/src/enums/stat.ts @@ -48,9 +48,11 @@ export type TempBattleStat = typeof TEMP_BATTLE_STATS[number]; export function getStatStageChangeDescriptionKey(stages: number, isIncrease: boolean) { if (stages === 1) { return isIncrease ? "battle:statRose" : "battle:statFell"; - } else if (stages === 2) { + } + if (stages === 2) { return isIncrease ? "battle:statSharplyRose" : "battle:statHarshlyFell"; - } else if (stages > 2 && stages <= 6) { + } + if (stages > 2 && stages <= 6) { return isIncrease ? "battle:statRoseDrastically" : "battle:statSeverelyFell"; } return isIncrease ? "battle:statWontGoAnyHigher" : "battle:statWontGoAnyLower"; diff --git a/src/events/arena.ts b/src/events/arena.ts index 660a113f96b..ad77289b76b 100644 --- a/src/events/arena.ts +++ b/src/events/arena.ts @@ -32,7 +32,7 @@ export class ArenaEvent extends Event { /** * Container class for {@linkcode ArenaEventType.WEATHER_CHANGED} events * @extends ArenaEvent -*/ + */ export class WeatherChangedEvent extends ArenaEvent { /** The {@linkcode WeatherType} being overridden */ public oldWeatherType: WeatherType; @@ -48,7 +48,7 @@ export class WeatherChangedEvent extends ArenaEvent { /** * Container class for {@linkcode ArenaEventType.TERRAIN_CHANGED} events * @extends ArenaEvent -*/ + */ export class TerrainChangedEvent extends ArenaEvent { /** The {@linkcode TerrainType} being overridden */ public oldTerrainType: TerrainType; @@ -65,7 +65,7 @@ export class TerrainChangedEvent extends ArenaEvent { /** * Container class for {@linkcode ArenaEventType.TAG_ADDED} events * @extends ArenaEvent -*/ + */ export class TagAddedEvent extends ArenaEvent { /** The {@linkcode ArenaTagType} being added */ public arenaTagType: ArenaTagType; @@ -76,7 +76,13 @@ export class TagAddedEvent extends ArenaEvent { /** The maximum amount of layers of the arena trap. */ public arenaTagMaxLayers: number; - constructor(arenaTagType: ArenaTagType, arenaTagSide: ArenaTagSide, duration: number, arenaTagLayers?: number, arenaTagMaxLayers?: number) { + constructor( + arenaTagType: ArenaTagType, + arenaTagSide: ArenaTagSide, + duration: number, + arenaTagLayers?: number, + arenaTagMaxLayers?: number, + ) { super(ArenaEventType.TAG_ADDED, duration); this.arenaTagType = arenaTagType; @@ -88,7 +94,7 @@ export class TagAddedEvent extends ArenaEvent { /** * Container class for {@linkcode ArenaEventType.TAG_REMOVED} events * @extends ArenaEvent -*/ + */ export class TagRemovedEvent extends ArenaEvent { /** The {@linkcode ArenaTagType} being removed */ public arenaTagType: ArenaTagType; diff --git a/src/events/battle-scene.ts b/src/events/battle-scene.ts index 4ed0e60cdc7..83d260bd7d2 100644 --- a/src/events/battle-scene.ts +++ b/src/events/battle-scene.ts @@ -34,7 +34,7 @@ export enum BattleSceneEventType { * Triggers after a turn ends in battle * @see {@linkcode TurnEndEvent} */ - TURN_END = "onTurnEnd", + TURN_END = "onTurnEnd", /** * Triggers when a new {@linkcode Arena} is created during initialization @@ -46,7 +46,7 @@ export enum BattleSceneEventType { /** * Container class for {@linkcode BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED} events * @extends Event -*/ + */ export class CandyUpgradeNotificationChangedEvent extends Event { /** The new value the setting was changed to */ public newValue: number; @@ -60,7 +60,7 @@ export class CandyUpgradeNotificationChangedEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.MOVE_USED} events * @extends Event -*/ + */ export class MoveUsedEvent extends Event { /** The ID of the {@linkcode Pokemon} that used the {@linkcode Move} */ public pokemonId: number; @@ -79,7 +79,7 @@ export class MoveUsedEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.BERRY_USED} events * @extends Event -*/ + */ export class BerryUsedEvent extends Event { /** The {@linkcode BerryModifier} being used */ public berryModifier: BerryModifier; @@ -93,7 +93,7 @@ export class BerryUsedEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.ENCOUNTER_PHASE} events * @extends Event -*/ + */ export class EncounterPhaseEvent extends Event { constructor() { super(BattleSceneEventType.ENCOUNTER_PHASE); @@ -102,7 +102,7 @@ export class EncounterPhaseEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.TURN_INIT} events * @extends Event -*/ + */ export class TurnInitEvent extends Event { constructor() { super(BattleSceneEventType.TURN_INIT); @@ -111,7 +111,7 @@ export class TurnInitEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.TURN_END} events * @extends Event -*/ + */ export class TurnEndEvent extends Event { /** The amount of turns in the current battle */ public turnCount: number; @@ -124,7 +124,7 @@ export class TurnEndEvent extends Event { /** * Container class for {@linkcode BattleSceneEventType.NEW_ARENA} events * @extends Event -*/ + */ export class NewArenaEvent extends Event { constructor() { super(BattleSceneEventType.NEW_ARENA); diff --git a/src/events/egg.ts b/src/events/egg.ts index dc3d2b55ffe..a0c26c82883 100644 --- a/src/events/egg.ts +++ b/src/events/egg.ts @@ -3,13 +3,13 @@ export enum EggEventType { * Triggers when egg count is changed. * @see {@linkcode MoveUsedEvent} */ - EGG_COUNT_CHANGED = "onEggCountChanged" + EGG_COUNT_CHANGED = "onEggCountChanged", } /** * Container class for {@linkcode EggEventType.EGG_COUNT_CHANGED} events * @extends Event -*/ + */ export class EggCountChangedEvent extends Event { /** The updated egg count. */ public eggCount: number; diff --git a/src/field/anims.ts b/src/field/anims.ts index 9ffaae59bbc..cd6209dddff 100644 --- a/src/field/anims.ts +++ b/src/field/anims.ts @@ -24,13 +24,17 @@ export function addPokeballOpenParticles(x: number, y: number, pokeballType: Pok } function doDefaultPbOpenParticles(x: number, y: number, radius: number) { - const pbOpenParticlesFrameNames = globalScene.anims.generateFrameNames("pb_particles", { start: 0, end: 3, suffix: ".png" }); - if (!(globalScene.anims.exists("pb_open_particle"))) { + const pbOpenParticlesFrameNames = globalScene.anims.generateFrameNames("pb_particles", { + start: 0, + end: 3, + suffix: ".png", + }); + if (!globalScene.anims.exists("pb_open_particle")) { globalScene.anims.create({ key: "pb_open_particle", frames: pbOpenParticlesFrameNames, frameRate: 16, - repeat: -1 + repeat: -1, }); } @@ -38,17 +42,17 @@ function doDefaultPbOpenParticles(x: number, y: number, radius: number) { const particle = globalScene.add.sprite(x, y, "pb_open_particle"); globalScene.field.add(particle); const angle = index * 45; - const [ xCoord, yCoord ] = [ radius * Math.cos(angle * Math.PI / 180), radius * Math.sin(angle * Math.PI / 180) ]; + const [xCoord, yCoord] = [radius * Math.cos((angle * Math.PI) / 180), radius * Math.sin((angle * Math.PI) / 180)]; globalScene.tweens.add({ targets: particle, x: x + xCoord, y: y + yCoord, - duration: 575 + duration: 575, }); particle.play({ key: "pb_open_particle", startFrame: (index + 3) % 4, - frameRate: Math.floor(16 * globalScene.gameSpeed) + frameRate: Math.floor(16 * globalScene.gameSpeed), }); globalScene.tweens.add({ targets: particle, @@ -56,7 +60,7 @@ function doDefaultPbOpenParticles(x: number, y: number, radius: number) { duration: 75, alpha: 0, ease: "Sine.easeIn", - onComplete: () => particle.destroy() + onComplete: () => particle.destroy(), }); }; @@ -64,7 +68,7 @@ function doDefaultPbOpenParticles(x: number, y: number, radius: number) { globalScene.time.addEvent({ delay: 20, repeat: 16, - callback: () => addParticle(++particleCount) + callback: () => addParticle(++particleCount), }); } @@ -84,7 +88,7 @@ function doUbOpenParticles(x: number, y: number, frameIndex: number) { for (const particle of particles) { particle.destroy(); } - } + }, }); } @@ -105,12 +109,20 @@ function doMbOpenParticles(x: number, y: number) { for (const particle of particles) { particle.destroy(); } - } + }, }); } } -function doFanOutParticle(trigIndex: number, x: number, y: number, xSpeed: number, ySpeed: number, angle: number, frameIndex: number): Phaser.GameObjects.Image { +function doFanOutParticle( + trigIndex: number, + x: number, + y: number, + xSpeed: number, + ySpeed: number, + angle: number, + frameIndex: number, +): Phaser.GameObjects.Image { let f = 0; const particle = globalScene.add.image(x, y, "pb_particles", `${frameIndex}.png`); @@ -122,7 +134,7 @@ function doFanOutParticle(trigIndex: number, x: number, y: number, xSpeed: numbe } particle.x = x + sin(trigIndex, f * xSpeed); particle.y = y + cos(trigIndex, f * ySpeed); - trigIndex = (trigIndex + angle); + trigIndex = trigIndex + angle; f++; }; @@ -131,7 +143,7 @@ function doFanOutParticle(trigIndex: number, x: number, y: number, xSpeed: numbe duration: getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); return particle; @@ -155,16 +167,16 @@ export function addPokeballCaptureStars(pokeball: Phaser.GameObjects.Sprite): vo y: pokeball.y, alpha: 0, ease: "Sine.easeIn", - duration: 250 + duration: 250, }); - } + }, }); const dist = randGauss(25); globalScene.tweens.add({ targets: particle, x: pokeball.x + dist, - duration: 500 + duration: 500, }); globalScene.tweens.add({ @@ -172,7 +184,7 @@ export function addPokeballCaptureStars(pokeball: Phaser.GameObjects.Sprite): vo alpha: 0, delay: 425, duration: 75, - onComplete: () => particle.destroy() + onComplete: () => particle.destroy(), }); }; @@ -200,7 +212,10 @@ export function doShinySparkleAnim(sparkleSprite: Phaser.GameObjects.Sprite, var // Make sure the animation exists, and create it if not if (!globalScene.anims.exists(animationKey)) { - const frameNames = globalScene.anims.generateFrameNames(spriteKey, { suffix: ".png", end: 34 }); + const frameNames = globalScene.anims.generateFrameNames(spriteKey, { + suffix: ".png", + end: 34, + }); globalScene.anims.create({ key: `sparkle${keySuffix}`, frames: frameNames, diff --git a/src/field/arena.ts b/src/field/arena.ts index aedb0c1c5f8..2ed94e0e3e3 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -5,7 +5,14 @@ import type { Constructor } from "#app/utils"; import * as Utils from "#app/utils"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; -import { getTerrainClearMessage, getTerrainStartMessage, getWeatherClearMessage, getWeatherStartMessage, getLegendaryWeatherContinuesMessage, Weather } from "#app/data/weather"; +import { + getTerrainClearMessage, + getTerrainStartMessage, + getWeatherClearMessage, + getWeatherStartMessage, + getLegendaryWeatherContinuesMessage, + Weather, +} from "#app/data/weather"; import { CommonAnim } from "#app/data/battle-anims"; import type { PokemonType } from "#enums/pokemon-type"; import type Move from "#app/data/moves/move"; @@ -19,7 +26,7 @@ import { applyPostWeatherChangeAbAttrs, PostTerrainChangeAbAttr, PostWeatherChangeAbAttr, - TerrainEventTypeChangeAbAttr + TerrainEventTypeChangeAbAttr, } from "#app/data/ability"; import type Pokemon from "#app/field/pokemon"; import Overrides from "#app/overrides"; @@ -58,7 +65,7 @@ export class Arena { public readonly eventTarget: EventTarget = new EventTarget(); - constructor(biome: Biome, bgm: string, playerFaints: number = 0) { + constructor(biome: Biome, bgm: string, playerFaints = 0) { this.biomeType = biome; this.tags = []; this.bgm = bgm; @@ -88,19 +95,29 @@ export class Arena { if (timeOfDay !== this.lastTimeOfDay) { this.pokemonPool = {}; for (const tier of Object.keys(biomePokemonPools[this.biomeType])) { - this.pokemonPool[tier] = Object.assign([], biomePokemonPools[this.biomeType][tier][TimeOfDay.ALL]).concat(biomePokemonPools[this.biomeType][tier][timeOfDay]); + this.pokemonPool[tier] = Object.assign([], biomePokemonPools[this.biomeType][tier][TimeOfDay.ALL]).concat( + biomePokemonPools[this.biomeType][tier][timeOfDay], + ); } this.lastTimeOfDay = timeOfDay; } } - randomSpecies(waveIndex: number, level: number, attempt?: number, luckValue?: number, isBoss?: boolean): PokemonSpecies { + randomSpecies( + waveIndex: number, + level: number, + attempt?: number, + luckValue?: number, + isBoss?: boolean, + ): PokemonSpecies { const overrideSpecies = globalScene.gameMode.getOverrideSpecies(waveIndex); if (overrideSpecies) { return overrideSpecies; } - const isBossSpecies = !!globalScene.getEncounterBossSegments(waveIndex, level) && !!this.pokemonPool[BiomePoolTier.BOSS].length - && (this.biomeType !== Biome.END || globalScene.gameMode.isClassic || globalScene.gameMode.isWaveFinal(waveIndex)); + const isBossSpecies = + !!globalScene.getEncounterBossSegments(waveIndex, level) && + !!this.pokemonPool[BiomePoolTier.BOSS].length && + (this.biomeType !== Biome.END || globalScene.gameMode.isClassic || globalScene.gameMode.isWaveFinal(waveIndex)); const randVal = isBossSpecies ? 64 : 512; // luck influences encounter rarity let luckModifier = 0; @@ -109,8 +126,22 @@ export class Arena { } const tierValue = Utils.randSeedInt(randVal - luckModifier); let tier = !isBossSpecies - ? tierValue >= 156 ? BiomePoolTier.COMMON : tierValue >= 32 ? BiomePoolTier.UNCOMMON : tierValue >= 6 ? BiomePoolTier.RARE : tierValue >= 1 ? BiomePoolTier.SUPER_RARE : BiomePoolTier.ULTRA_RARE - : tierValue >= 20 ? BiomePoolTier.BOSS : tierValue >= 6 ? BiomePoolTier.BOSS_RARE : tierValue >= 1 ? BiomePoolTier.BOSS_SUPER_RARE : BiomePoolTier.BOSS_ULTRA_RARE; + ? tierValue >= 156 + ? BiomePoolTier.COMMON + : tierValue >= 32 + ? BiomePoolTier.UNCOMMON + : tierValue >= 6 + ? BiomePoolTier.RARE + : tierValue >= 1 + ? BiomePoolTier.SUPER_RARE + : BiomePoolTier.ULTRA_RARE + : tierValue >= 20 + ? BiomePoolTier.BOSS + : tierValue >= 6 + ? BiomePoolTier.BOSS_RARE + : tierValue >= 1 + ? BiomePoolTier.BOSS_SUPER_RARE + : BiomePoolTier.BOSS_ULTRA_RARE; console.log(BiomePoolTier[tier]); while (!this.pokemonPool[tier].length) { console.log(`Downgraded rarity tier from ${BiomePoolTier[tier]} to ${BiomePoolTier[tier - 1]}`); @@ -129,7 +160,7 @@ export class Arena { } else { const levelThresholds = Object.keys(entry); for (let l = levelThresholds.length - 1; l >= 0; l--) { - const levelThreshold = parseInt(levelThresholds[l]); + const levelThreshold = Number.parseInt(levelThresholds[l]); if (level >= levelThreshold) { const speciesIds = entry[levelThreshold]; if (speciesIds.length > 1) { @@ -146,13 +177,13 @@ export class Arena { if (ret.subLegendary || ret.legendary || ret.mythical) { switch (true) { - case (ret.baseTotal >= 720): + case ret.baseTotal >= 720: regen = level < 90; break; - case (ret.baseTotal >= 670): + case ret.baseTotal >= 670: regen = level < 70; break; - case (ret.baseTotal >= 580): + case ret.baseTotal >= 580: regen = level < 50; break; default: @@ -175,14 +206,29 @@ export class Arena { return ret; } - randomTrainerType(waveIndex: number, isBoss: boolean = false): TrainerType { - const isTrainerBoss = !!this.trainerPool[BiomePoolTier.BOSS].length - && (globalScene.gameMode.isTrainerBoss(waveIndex, this.biomeType, globalScene.offsetGym) || isBoss); + randomTrainerType(waveIndex: number, isBoss = false): TrainerType { + const isTrainerBoss = + !!this.trainerPool[BiomePoolTier.BOSS].length && + (globalScene.gameMode.isTrainerBoss(waveIndex, this.biomeType, globalScene.offsetGym) || isBoss); console.log(isBoss, this.trainerPool); const tierValue = Utils.randSeedInt(!isTrainerBoss ? 512 : 64); let tier = !isTrainerBoss - ? tierValue >= 156 ? BiomePoolTier.COMMON : tierValue >= 32 ? BiomePoolTier.UNCOMMON : tierValue >= 6 ? BiomePoolTier.RARE : tierValue >= 1 ? BiomePoolTier.SUPER_RARE : BiomePoolTier.ULTRA_RARE - : tierValue >= 20 ? BiomePoolTier.BOSS : tierValue >= 6 ? BiomePoolTier.BOSS_RARE : tierValue >= 1 ? BiomePoolTier.BOSS_SUPER_RARE : BiomePoolTier.BOSS_ULTRA_RARE; + ? tierValue >= 156 + ? BiomePoolTier.COMMON + : tierValue >= 32 + ? BiomePoolTier.UNCOMMON + : tierValue >= 6 + ? BiomePoolTier.RARE + : tierValue >= 1 + ? BiomePoolTier.SUPER_RARE + : BiomePoolTier.ULTRA_RARE + : tierValue >= 20 + ? BiomePoolTier.BOSS + : tierValue >= 6 + ? BiomePoolTier.BOSS_RARE + : tierValue >= 1 + ? BiomePoolTier.BOSS_SUPER_RARE + : BiomePoolTier.BOSS_ULTRA_RARE; console.log(BiomePoolTier[tier]); while (tier && !this.trainerPool[tier].length) { console.log(`Downgraded trainer rarity tier from ${BiomePoolTier[tier]} to ${BiomePoolTier[tier - 1]}`); @@ -274,14 +320,21 @@ export class Arena { const oldWeatherType = this.weather?.weatherType || WeatherType.NONE; - if (this.weather?.isImmutable() && ![ WeatherType.HARSH_SUN, WeatherType.HEAVY_RAIN, WeatherType.STRONG_WINDS, WeatherType.NONE ].includes(weather)) { - globalScene.unshiftPhase(new CommonAnimPhase(undefined, undefined, CommonAnim.SUNNY + (oldWeatherType - 1), true)); + if ( + this.weather?.isImmutable() && + ![WeatherType.HARSH_SUN, WeatherType.HEAVY_RAIN, WeatherType.STRONG_WINDS, WeatherType.NONE].includes(weather) + ) { + globalScene.unshiftPhase( + new CommonAnimPhase(undefined, undefined, CommonAnim.SUNNY + (oldWeatherType - 1), true), + ); globalScene.queueMessage(getLegendaryWeatherContinuesMessage(oldWeatherType)!); return false; } this.weather = weather ? new Weather(weather, hasPokemonSource ? 5 : 0) : null; - this.eventTarget.dispatchEvent(new WeatherChangedEvent(oldWeatherType, this.weather?.weatherType!, this.weather?.turnsLeft!)); // TODO: is this bang correct? + this.eventTarget.dispatchEvent( + new WeatherChangedEvent(oldWeatherType, this.weather?.weatherType!, this.weather?.turnsLeft!), + ); // TODO: is this bang correct? if (this.weather) { globalScene.unshiftPhase(new CommonAnimPhase(undefined, undefined, CommonAnim.SUNNY + (weather - 1), true)); @@ -290,10 +343,15 @@ export class Arena { globalScene.queueMessage(getWeatherClearMessage(oldWeatherType)!); // TODO: is this bang correct? } - globalScene.getField(true).filter(p => p.isOnField()).map(pokemon => { - pokemon.findAndRemoveTags(t => "weatherTypes" in t && !(t.weatherTypes as WeatherType[]).find(t => t === weather)); - applyPostWeatherChangeAbAttrs(PostWeatherChangeAbAttr, pokemon, weather); - }); + globalScene + .getField(true) + .filter(p => p.isOnField()) + .map(pokemon => { + pokemon.findAndRemoveTags( + t => "weatherTypes" in t && !(t.weatherTypes as WeatherType[]).find(t => t === weather), + ); + applyPostWeatherChangeAbAttrs(PostWeatherChangeAbAttr, pokemon, weather); + }); return true; } @@ -302,9 +360,9 @@ export class Arena { * Function to trigger all weather based form changes */ triggerWeatherBasedFormChanges(): void { - globalScene.getField(true).forEach( p => { - const isCastformWithForecast = (p.hasAbility(Abilities.FORECAST) && p.species.speciesId === Species.CASTFORM); - const isCherrimWithFlowerGift = (p.hasAbility(Abilities.FLOWER_GIFT) && p.species.speciesId === Species.CHERRIM); + globalScene.getField(true).forEach(p => { + const isCastformWithForecast = p.hasAbility(Abilities.FORECAST) && p.species.speciesId === Species.CASTFORM; + const isCherrimWithFlowerGift = p.hasAbility(Abilities.FLOWER_GIFT) && p.species.speciesId === Species.CHERRIM; if (isCastformWithForecast || isCherrimWithFlowerGift) { new ShowAbilityPhase(p.getBattlerIndex()); @@ -317,9 +375,11 @@ export class Arena { * Function to trigger all weather based form changes back into their normal forms */ triggerWeatherBasedFormChangesToNormal(): void { - globalScene.getField(true).forEach( p => { - const isCastformWithForecast = (p.hasAbility(Abilities.FORECAST, false, true) && p.species.speciesId === Species.CASTFORM); - const isCherrimWithFlowerGift = (p.hasAbility(Abilities.FLOWER_GIFT, false, true) && p.species.speciesId === Species.CHERRIM); + globalScene.getField(true).forEach(p => { + const isCastformWithForecast = + p.hasAbility(Abilities.FORECAST, false, true) && p.species.speciesId === Species.CASTFORM; + const isCherrimWithFlowerGift = + p.hasAbility(Abilities.FLOWER_GIFT, false, true) && p.species.speciesId === Species.CHERRIM; if (isCastformWithForecast || isCherrimWithFlowerGift) { new ShowAbilityPhase(p.getBattlerIndex()); @@ -328,7 +388,7 @@ export class Arena { }); } - trySetTerrain(terrain: TerrainType, hasPokemonSource: boolean, ignoreAnim: boolean = false): boolean { + trySetTerrain(terrain: TerrainType, hasPokemonSource: boolean, ignoreAnim = false): boolean { if (this.terrain?.terrainType === (terrain || undefined)) { return false; } @@ -336,7 +396,9 @@ export class Arena { const oldTerrainType = this.terrain?.terrainType || TerrainType.NONE; this.terrain = terrain ? new Terrain(terrain, hasPokemonSource ? 5 : 0) : null; - this.eventTarget.dispatchEvent(new TerrainChangedEvent(oldTerrainType, this.terrain?.terrainType!, this.terrain?.turnsLeft!)); // TODO: are those bangs correct? + this.eventTarget.dispatchEvent( + new TerrainChangedEvent(oldTerrainType, this.terrain?.terrainType!, this.terrain?.turnsLeft!), + ); // TODO: are those bangs correct? if (this.terrain) { if (!ignoreAnim) { @@ -347,11 +409,16 @@ export class Arena { globalScene.queueMessage(getTerrainClearMessage(oldTerrainType)!); // TODO: is this bang correct? } - globalScene.getField(true).filter(p => p.isOnField()).map(pokemon => { - pokemon.findAndRemoveTags(t => "terrainTypes" in t && !(t.terrainTypes as TerrainType[]).find(t => t === terrain)); - applyPostTerrainChangeAbAttrs(PostTerrainChangeAbAttr, pokemon, terrain); - applyAbAttrs(TerrainEventTypeChangeAbAttr, pokemon, null, false); - }); + globalScene + .getField(true) + .filter(p => p.isOnField()) + .map(pokemon => { + pokemon.findAndRemoveTags( + t => "terrainTypes" in t && !(t.terrainTypes as TerrainType[]).find(t => t === terrain), + ); + applyPostTerrainChangeAbAttrs(PostTerrainChangeAbAttr, pokemon, terrain); + applyAbAttrs(TerrainEventTypeChangeAbAttr, pokemon, null, false); + }); return true; } @@ -478,16 +545,13 @@ export class Arena { overrideTint(): [number, number, number] { switch (Overrides.ARENA_TINT_OVERRIDE) { case TimeOfDay.DUSK: - return [ 98, 48, 73 ].map(c => Math.round((c + 128) / 2)) as [number, number, number]; - break; - case (TimeOfDay.NIGHT): - return [ 64, 64, 64 ]; - break; + return [98, 48, 73].map(c => Math.round((c + 128) / 2)) as [number, number, number]; + case TimeOfDay.NIGHT: + return [64, 64, 64]; case TimeOfDay.DAWN: case TimeOfDay.DAY: default: - return [ 128, 128, 128 ]; - break; + return [128, 128, 128]; } } @@ -497,9 +561,9 @@ export class Arena { } switch (this.biomeType) { case Biome.ABYSS: - return [ 64, 64, 64 ]; + return [64, 64, 64]; default: - return [ 128, 128, 128 ]; + return [128, 128, 128]; } } @@ -508,12 +572,12 @@ export class Arena { return this.overrideTint(); } if (!this.isOutside()) { - return [ 0, 0, 0 ]; + return [0, 0, 0]; } switch (this.biomeType) { default: - return [ 98, 48, 73 ].map(c => Math.round((c + 128) / 2)) as [number, number, number]; + return [98, 48, 73].map(c => Math.round((c + 128) / 2)) as [number, number, number]; } } @@ -529,12 +593,12 @@ export class Arena { } if (!this.isOutside()) { - return [ 64, 64, 64 ]; + return [64, 64, 64]; } switch (this.biomeType) { default: - return [ 48, 48, 98 ]; + return [48, 48, 98]; } } @@ -550,10 +614,16 @@ export class Arena { * @param simulated if `true`, this applies arena tags without changing game state * @param args array of parameters that the called upon tags may need */ - applyTagsForSide(tagType: ArenaTagType | Constructor, side: ArenaTagSide, simulated: boolean, ...args: unknown[]): void { - let tags = typeof tagType === "string" - ? this.tags.filter(t => t.tagType === tagType) - : this.tags.filter(t => t instanceof tagType); + applyTagsForSide( + tagType: ArenaTagType | Constructor, + side: ArenaTagSide, + simulated: boolean, + ...args: unknown[] + ): void { + let tags = + typeof tagType === "string" + ? this.tags.filter(t => t.tagType === tagType) + : this.tags.filter(t => t instanceof tagType); if (side !== ArenaTagSide.BOTH) { tags = tags.filter(t => t.side === side); } @@ -582,7 +652,15 @@ export class Arena { * @param targetIndex The {@linkcode BattlerIndex} of the target pokemon * @returns `false` if there already exists a tag of this type in the Arena */ - addTag(tagType: ArenaTagType, turnCount: number, sourceMove: Moves | undefined, sourceId: number, side: ArenaTagSide = ArenaTagSide.BOTH, quiet: boolean = false, targetIndex?: BattlerIndex): boolean { + addTag( + tagType: ArenaTagType, + turnCount: number, + sourceMove: Moves | undefined, + sourceId: number, + side: ArenaTagSide = ArenaTagSide.BOTH, + quiet = false, + targetIndex?: BattlerIndex, + ): boolean { const existingTag = this.getTagOnSide(tagType, side); if (existingTag) { existingTag.onOverlap(this); @@ -603,7 +681,9 @@ export class Arena { const { layers = 0, maxLayers = 0 } = newTag instanceof ArenaTrapTag ? newTag : {}; - this.eventTarget.dispatchEvent(new TagAddedEvent(newTag.tagType, newTag.side, newTag.turnCount, layers, maxLayers)); + this.eventTarget.dispatchEvent( + new TagAddedEvent(newTag.tagType, newTag.side, newTag.turnCount, layers, maxLayers), + ); } return true; @@ -618,7 +698,7 @@ export class Arena { return this.getTagOnSide(tagType, ArenaTagSide.BOTH); } - hasTag(tagType: ArenaTagType) : boolean { + hasTag(tagType: ArenaTagType): boolean { return !!this.getTag(tagType); } @@ -631,9 +711,13 @@ export class Arena { * @returns either the {@linkcode ArenaTag}, or `undefined` if it isn't there */ getTagOnSide(tagType: ArenaTagType | Constructor, side: ArenaTagSide): ArenaTag | undefined { - return typeof(tagType) === "string" - ? this.tags.find(t => t.tagType === tagType && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side)) - : this.tags.find(t => t instanceof tagType && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side)); + return typeof tagType === "string" + ? this.tags.find( + t => t.tagType === tagType && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side), + ) + : this.tags.find( + t => t instanceof tagType && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side), + ); } /** @@ -652,16 +736,20 @@ export class Arena { * @returns array of {@linkcode ArenaTag}s from which the Arena's tags return `true` and apply to the given side */ findTagsOnSide(tagPredicate: (t: ArenaTag) => boolean, side: ArenaTagSide): ArenaTag[] { - return this.tags.filter(t => tagPredicate(t) && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side)); + return this.tags.filter( + t => tagPredicate(t) && (side === ArenaTagSide.BOTH || t.side === ArenaTagSide.BOTH || t.side === side), + ); } lapseTags(): void { - this.tags.filter(t => !(t.lapse(this))).forEach(t => { - t.onRemove(this); - this.tags.splice(this.tags.indexOf(t), 1); + this.tags + .filter(t => !t.lapse(this)) + .forEach(t => { + t.onRemove(this); + this.tags.splice(this.tags.indexOf(t), 1); - this.eventTarget.dispatchEvent(new TagRemovedEvent(t.tagType, t.side, t.turnCount)); - }); + this.eventTarget.dispatchEvent(new TagRemovedEvent(t.tagType, t.side, t.turnCount)); + }); } removeTag(tagType: ArenaTagType): boolean { @@ -676,7 +764,7 @@ export class Arena { return !!tag; } - removeTagOnSide(tagType: ArenaTagType, side: ArenaTagSide, quiet: boolean = false): boolean { + removeTagOnSide(tagType: ArenaTagType, side: ArenaTagSide, quiet = false): boolean { const tag = this.getTagOnSide(tagType, side); if (tag) { tag.onRemove(this, quiet); @@ -687,11 +775,12 @@ export class Arena { return !!tag; } - removeAllTags(): void { while (this.tags.length) { this.tags[0].onRemove(this); - this.eventTarget.dispatchEvent(new TagRemovedEvent(this.tags[0].tagType, this.tags[0].side, this.tags[0].turnCount)); + this.eventTarget.dispatchEvent( + new TagRemovedEvent(this.tags[0].tagType, this.tags[0].side, this.tags[0].turnCount), + ); this.tags.splice(0, 1); } @@ -726,7 +815,7 @@ export class Arena { case Biome.TALL_GRASS: return 9.608; case Biome.METROPOLIS: - return 141.470; + return 141.47; case Biome.FOREST: return 0.341; case Biome.SEA: @@ -738,17 +827,17 @@ export class Arena { case Biome.LAKE: return 7.215; case Biome.SEABED: - return 2.600; + return 2.6; case Biome.MOUNTAIN: return 4.018; case Biome.BADLANDS: - return 17.790; + return 17.79; case Biome.CAVE: - return 14.240; + return 14.24; case Biome.DESERT: return 1.143; case Biome.ICE_CAVE: - return 0.000; + return 0.0; case Biome.MEADOW: return 3.891; case Biome.POWER_PLANT: @@ -762,17 +851,17 @@ export class Arena { case Biome.FACTORY: return 4.985; case Biome.RUINS: - return 0.000; + return 0.0; case Biome.WASTELAND: return 6.336; case Biome.ABYSS: - return 5.130; + return 5.13; case Biome.SPACE: return 20.036; case Biome.CONSTRUCTION_SITE: return 1.222; case Biome.JUNGLE: - return 0.000; + return 0.0; case Biome.FAIRY_CAVE: return 4.542; case Biome.TEMPLE: @@ -782,7 +871,7 @@ export class Arena { case Biome.LABORATORY: return 114.862; case Biome.SLUM: - return 0.000; + return 0.0; case Biome.SNOWY_FOREST: return 3.047; case Biome.END: @@ -850,13 +939,14 @@ export class ArenaBase extends Phaser.GameObjects.Container { this.base = globalScene.addFieldSprite(0, 0, "plains_a", undefined, 1); this.base.setOrigin(0, 0); - this.props = !player ? - new Array(3).fill(null).map(() => { - const ret = globalScene.addFieldSprite(0, 0, "plains_b", undefined, 1); - ret.setOrigin(0, 0); - ret.setVisible(false); - return ret; - }) : []; + this.props = !player + ? new Array(3).fill(null).map(() => { + const ret = globalScene.addFieldSprite(0, 0, "plains_b", undefined, 1); + ret.setOrigin(0, 0); + ret.setVisible(false); + return ret; + }) + : []; } setBiome(biome: Biome, propValue?: number): void { @@ -868,13 +958,18 @@ export class ArenaBase extends Phaser.GameObjects.Container { this.base.setTexture(baseKey); if (this.base.texture.frameTotal > 1) { - const baseFrameNames = globalScene.anims.generateFrameNames(baseKey, { zeroPad: 4, suffix: ".png", start: 1, end: this.base.texture.frameTotal - 1 }); - if (!(globalScene.anims.exists(baseKey))) { + const baseFrameNames = globalScene.anims.generateFrameNames(baseKey, { + zeroPad: 4, + suffix: ".png", + start: 1, + end: this.base.texture.frameTotal - 1, + }); + if (!globalScene.anims.exists(baseKey)) { globalScene.anims.create({ key: baseKey, frames: baseFrameNames, frameRate: 12, - repeat: -1 + repeat: -1, }); } this.base.play(baseKey); @@ -886,33 +981,40 @@ export class ArenaBase extends Phaser.GameObjects.Container { } if (!this.player) { - globalScene.executeWithSeedOffset(() => { - this.propValue = propValue === undefined - ? hasProps ? Utils.randSeedInt(8) : 0 - : propValue; - this.props.forEach((prop, p) => { - const propKey = `${biomeKey}_b${hasProps ? `_${p + 1}` : ""}`; - prop.setTexture(propKey); + globalScene.executeWithSeedOffset( + () => { + this.propValue = propValue === undefined ? (hasProps ? Utils.randSeedInt(8) : 0) : propValue; + this.props.forEach((prop, p) => { + const propKey = `${biomeKey}_b${hasProps ? `_${p + 1}` : ""}`; + prop.setTexture(propKey); - if (hasProps && prop.texture.frameTotal > 1) { - const propFrameNames = globalScene.anims.generateFrameNames(propKey, { zeroPad: 4, suffix: ".png", start: 1, end: prop.texture.frameTotal - 1 }); - if (!(globalScene.anims.exists(propKey))) { - globalScene.anims.create({ - key: propKey, - frames: propFrameNames, - frameRate: 12, - repeat: -1 + if (hasProps && prop.texture.frameTotal > 1) { + const propFrameNames = globalScene.anims.generateFrameNames(propKey, { + zeroPad: 4, + suffix: ".png", + start: 1, + end: prop.texture.frameTotal - 1, }); + if (!globalScene.anims.exists(propKey)) { + globalScene.anims.create({ + key: propKey, + frames: propFrameNames, + frameRate: 12, + repeat: -1, + }); + } + prop.play(propKey); + } else { + prop.stop(); } - prop.play(propKey); - } else { - prop.stop(); - } - prop.setVisible(hasProps && !!(this.propValue & (1 << p))); - this.add(prop); - }); - }, globalScene.currentBattle?.waveIndex || 0, globalScene.waveSeed); + prop.setVisible(hasProps && !!(this.propValue & (1 << p))); + this.add(prop); + }); + }, + globalScene.currentBattle?.waveIndex || 0, + globalScene.waveSeed, + ); } } } diff --git a/src/field/damage-number-handler.ts b/src/field/damage-number-handler.ts index 1551edc9697..63da641a114 100644 --- a/src/field/damage-number-handler.ts +++ b/src/field/damage-number-handler.ts @@ -6,7 +6,7 @@ import * as Utils from "../utils"; import type { BattlerIndex } from "../battle"; import { globalScene } from "#app/global-scene"; -type TextAndShadowArr = [ string | null, string | null ]; +type TextAndShadowArr = [string | null, string | null]; export default class DamageNumberHandler { private damageNumbers: Map; @@ -15,35 +15,45 @@ export default class DamageNumberHandler { this.damageNumbers = new Map(); } - add(target: Pokemon, amount: number, result: DamageResult | HitResult.HEAL = HitResult.EFFECTIVE, critical: boolean = false): void { + add( + target: Pokemon, + amount: number, + result: DamageResult | HitResult.HEAL = HitResult.EFFECTIVE, + critical = false, + ): void { if (!globalScene?.damageNumbersMode) { return; } const battlerIndex = target.getBattlerIndex(); const baseScale = target.getSpriteScale() / 6; - const damageNumber = addTextObject(target.x, -(globalScene.game.canvas.height / 6) + target.y - target.getSprite().height / 2, Utils.formatStat(amount, true), TextStyle.SUMMARY); + const damageNumber = addTextObject( + target.x, + -(globalScene.game.canvas.height / 6) + target.y - target.getSprite().height / 2, + Utils.formatStat(amount, true), + TextStyle.SUMMARY, + ); damageNumber.setName("text-damage-number"); damageNumber.setOrigin(0.5, 1); damageNumber.setScale(baseScale); - let [ textColor, shadowColor ] : TextAndShadowArr = [ null, null ]; + let [textColor, shadowColor]: TextAndShadowArr = [null, null]; switch (result) { case HitResult.SUPER_EFFECTIVE: - [ textColor, shadowColor ] = [ "#f8d030", "#b8a038" ]; + [textColor, shadowColor] = ["#f8d030", "#b8a038"]; break; case HitResult.NOT_VERY_EFFECTIVE: - [ textColor, shadowColor ] = [ "#f08030", "#c03028" ]; + [textColor, shadowColor] = ["#f08030", "#c03028"]; break; case HitResult.ONE_HIT_KO: - [ textColor, shadowColor ] = [ "#a040a0", "#483850" ]; + [textColor, shadowColor] = ["#a040a0", "#483850"]; break; case HitResult.HEAL: - [ textColor, shadowColor ] = [ "#78c850", "#588040" ]; + [textColor, shadowColor] = ["#78c850", "#588040"]; break; default: - [ textColor, shadowColor ] = [ "#ffffff", "#636363" ]; + [textColor, shadowColor] = ["#ffffff", "#636363"]; break; } @@ -77,7 +87,7 @@ export default class DamageNumberHandler { targets: damageNumber, duration: Utils.fixedInt(750), alpha: 1, - y: "-=32" + y: "-=32", }); globalScene.tweens.add({ delay: 375, @@ -88,7 +98,7 @@ export default class DamageNumberHandler { onComplete: () => { this.damageNumbers.get(battlerIndex)!.splice(this.damageNumbers.get(battlerIndex)!.indexOf(damageNumber), 1); damageNumber.destroy(true); - } + }, }); return; } @@ -104,7 +114,7 @@ export default class DamageNumberHandler { scaleX: 0.75 * baseScale, scaleY: 1.25 * baseScale, y: "-=16", - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(175), @@ -112,69 +122,71 @@ export default class DamageNumberHandler { scaleX: 0.875 * baseScale, scaleY: 1.125 * baseScale, y: "+=16", - ease: "Cubic.easeIn" + ease: "Cubic.easeIn", }, { duration: Utils.fixedInt(100), scaleX: 1.25 * baseScale, scaleY: 0.75 * baseScale, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(175), scaleX: 0.875 * baseScale, scaleY: 1.125 * baseScale, y: "-=8", - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(50), scaleX: 0.925 * baseScale, scaleY: 1.075 * baseScale, y: "+=8", - ease: "Cubic.easeIn" + ease: "Cubic.easeIn", }, { duration: Utils.fixedInt(100), scaleX: 1.125 * baseScale, scaleY: 0.875 * baseScale, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(175), scaleX: 0.925 * baseScale, scaleY: 1.075 * baseScale, y: "-=4", - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(50), scaleX: 0.975 * baseScale, scaleY: 1.025 * baseScale, y: "+=4", - ease: "Cubic.easeIn" + ease: "Cubic.easeIn", }, { duration: Utils.fixedInt(100), scaleX: 1.075 * baseScale, scaleY: 0.925 * baseScale, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { duration: Utils.fixedInt(25), scaleX: baseScale, scaleY: baseScale, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }, { delay: Utils.fixedInt(500), alpha: 0, onComplete: () => { - this.damageNumbers.get(battlerIndex)!.splice(this.damageNumbers.get(battlerIndex)!.indexOf(damageNumber), 1); + this.damageNumbers + .get(battlerIndex)! + .splice(this.damageNumbers.get(battlerIndex)!.indexOf(damageNumber), 1); damageNumber.destroy(true); - } - } - ] + }, + }, + ], }); } } diff --git a/src/field/mystery-encounter-intro.ts b/src/field/mystery-encounter-intro.ts index 1ea8f16e8f7..649a969d415 100644 --- a/src/field/mystery-encounter-intro.ts +++ b/src/field/mystery-encounter-intro.ts @@ -36,7 +36,7 @@ export class MysteryEncounterSpriteConfig { /** The sprite key (which is the image file name). e.g. "ace_trainer_f" */ spriteKey: string; /** Refer to [/public/images](../../public/images) directorty for all folder names */ - fileRoot: KnownFileRoot & string | string; + fileRoot: (KnownFileRoot & string) | string; /** Optional replacement for `spriteKey`/`fileRoot`. Just know this defaults to male/genderless, form 0, no shiny */ species?: Species; /** Enable shadow. Defaults to `false` */ @@ -80,7 +80,10 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con public encounter: MysteryEncounter; public spriteConfigs: MysteryEncounterSpriteConfig[]; public enterFromRight: boolean; - private shinySparkleSprites: { sprite: Phaser.GameObjects.Sprite, variant: Variant }[]; + private shinySparkleSprites: { + sprite: Phaser.GameObjects.Sprite; + variant: Variant; + }[]; constructor(encounter: MysteryEncounter) { super(globalScene, -72, 76); @@ -89,7 +92,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con // Shallow copy configs to allow visual config updates at runtime without dirtying master copy of Encounter this.spriteConfigs = encounter.spriteConfigs.map(config => { const result = { - ...config + ...config, }; if (!isNullOrUndefined(result.species)) { @@ -108,14 +111,22 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con const getSprite = (spriteKey: string, hasShadow?: boolean, yShadow?: number) => { const ret = globalScene.addFieldSprite(0, 0, spriteKey); ret.setOrigin(0.5, 1); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow, yShadowOffset: yShadow ?? 0 }); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: !!hasShadow, + yShadowOffset: yShadow ?? 0, + }); return ret; }; const getItemSprite = (spriteKey: string, hasShadow?: boolean, yShadow?: number) => { const icon = globalScene.add.sprite(-19, 2, "items", spriteKey); icon.setOrigin(0.5, 1); - icon.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow, yShadowOffset: yShadow ?? 0 }); + icon.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: !!hasShadow, + yShadowOffset: yShadow ?? 0, + }); return icon; }; @@ -129,7 +140,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con this.shinySparkleSprites = []; const shinySparkleSprites = globalScene.add.container(0, 0); - this.spriteConfigs?.forEach((config) => { + this.spriteConfigs?.forEach(config => { const { spriteKey, isItem, hasShadow, scale, x, y, yShadow, alpha, isPokemon, isShiny, variant } = config; let sprite: GameObjects.Sprite; @@ -154,7 +165,10 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con pokemonShinySparkle = globalScene.add.sprite(sprite.x, sprite.y, "shiny"); pokemonShinySparkle.setOrigin(0.5, 1); pokemonShinySparkle.setVisible(false); - this.shinySparkleSprites.push({ sprite: pokemonShinySparkle, variant: variant ?? 0 }); + this.shinySparkleSprites.push({ + sprite: pokemonShinySparkle, + variant: variant ?? 0, + }); shinySparkleSprites.add(pokemonShinySparkle); } } @@ -216,7 +230,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con } const shinyPromises: Promise[] = []; - this.spriteConfigs.forEach((config) => { + this.spriteConfigs.forEach(config => { if (config.isPokemon) { globalScene.loadPokemonAtlas(config.spriteKey, config.fileRoot); if (config.isShiny) { @@ -230,7 +244,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con }); globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => { - this.spriteConfigs.every((config) => { + this.spriteConfigs.every(config => { if (config.isItem) { return true; } @@ -238,17 +252,21 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con const originalWarn = console.warn; // Ignore warnings for missing frames, because there will be a lot - console.warn = () => { - }; - const frameNames = globalScene.anims.generateFrameNames(config.spriteKey, { zeroPad: 4, suffix: ".png", start: 1, end: 128 }); + console.warn = () => {}; + const frameNames = globalScene.anims.generateFrameNames(config.spriteKey, { + zeroPad: 4, + suffix: ".png", + start: 1, + end: 128, + }); console.warn = originalWarn; - if (!(globalScene.anims.exists(config.spriteKey))) { + if (!globalScene.anims.exists(config.spriteKey)) { globalScene.anims.create({ key: config.spriteKey, frames: frameNames, frameRate: 10, - repeat: -1 + repeat: -1, }); } @@ -313,7 +331,11 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con * @param animConfig {@linkcode Phaser.Types.Animations.PlayAnimationConfig} to pass to {@linkcode Phaser.GameObjects.Sprite.play} * @returns true if the sprite was able to be animated */ - tryPlaySprite(sprite: Phaser.GameObjects.Sprite, tintSprite: Phaser.GameObjects.Sprite, animConfig: Phaser.Types.Animations.PlayAnimationConfig): boolean { + tryPlaySprite( + sprite: Phaser.GameObjects.Sprite, + tintSprite: Phaser.GameObjects.Sprite, + animConfig: Phaser.Types.Animations.PlayAnimationConfig, + ): boolean { // Show an error in the console if there isn't a texture loaded if (sprite.texture.key === "__MISSING") { console.error(`No texture found for '${animConfig.key}'!`); @@ -359,7 +381,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con const trainerAnimConfig: PlayAnimationConfig = { key: config.spriteKey, repeat: config?.repeat ? -1 : 0, - startFrame: config?.startFrame ?? 0 + startFrame: config?.startFrame ?? 0, }; this.tryPlaySprite(sprites[i], tintSprites[i], trainerAnimConfig); @@ -392,7 +414,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con } const ret: Phaser.GameObjects.Sprite[] = []; - this.spriteConfigs.forEach((config, i) => { + this.spriteConfigs.forEach((_, i) => { ret.push(this.getAt(i * 2)); }); return ret; @@ -407,7 +429,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con } const ret: Phaser.GameObjects.Sprite[] = []; - this.spriteConfigs.forEach((config, i) => { + this.spriteConfigs.forEach((_, i) => { ret.push(this.getAt(i * 2 + 1)); }); @@ -434,7 +456,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con targets: sprite, alpha: alpha || 1, duration: duration, - ease: ease || "Linear" + ease: ease || "Linear", }); } else { sprite.setAlpha(alpha); @@ -471,7 +493,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con onComplete: () => { sprite.setVisible(false); sprite.setAlpha(1); - } + }, }); } else { sprite.setVisible(false); @@ -497,9 +519,9 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con * @param value - true for visible, false for hidden */ setVisible(value: boolean): this { - this.getSprites().forEach(sprite => { + for (const sprite of this.getSprites()) { sprite.setVisible(value); - }); + } return super.setVisible(value); } } diff --git a/src/field/pokemon-sprite-sparkle-handler.ts b/src/field/pokemon-sprite-sparkle-handler.ts index d1803cc036e..0d5dcca7989 100644 --- a/src/field/pokemon-sprite-sparkle-handler.ts +++ b/src/field/pokemon-sprite-sparkle-handler.ts @@ -14,12 +14,14 @@ export default class PokemonSpriteSparkleHandler { to: 1, yoyo: true, repeat: -1, - onRepeat: () => this.onLapse() + onRepeat: () => this.onLapse(), }); } onLapse(): void { - Array.from(this.sprites.values()).filter(s => !s.scene).map(s => this.sprites.delete(s)); + Array.from(this.sprites.values()) + .filter(s => !s.scene) + .map(s => this.sprites.delete(s)); for (const s of this.sprites.values()) { if (!s.pipelineData["teraColor"] || !(s.pipelineData["teraColor"] as number[]).find(c => c)) { continue; @@ -30,17 +32,21 @@ export default class PokemonSpriteSparkleHandler { if (!(s.parentContainer instanceof Pokemon) || !(s.parentContainer as Pokemon).isTerastallized) { continue; } - const pokemon = s.parentContainer instanceof Pokemon ? s.parentContainer as Pokemon : null; + const pokemon = s.parentContainer instanceof Pokemon ? (s.parentContainer as Pokemon) : null; const parent = (pokemon || s).parentContainer; const texture = s.texture; - const [ width, height ] = [ texture.source[0].width, texture.source[0].height ]; - const [ pixelX, pixelY ] = [ Utils.randInt(width), Utils.randInt(height) ]; + const [width, height] = [texture.source[0].width, texture.source[0].height]; + const [pixelX, pixelY] = [Utils.randInt(width), Utils.randInt(height)]; const ratioX = s.width / width; const ratioY = s.height / height; const pixel = texture.manager.getPixel(pixelX, pixelY, texture.key, "__BASE"); if (pixel?.alpha) { - const [ xOffset, yOffset ] = [ -s.originX * s.width, -s.originY * s.height ]; - const sparkle = globalScene.addFieldSprite(((pokemon?.x || 0) + s.x + pixelX * ratioX + xOffset), ((pokemon?.y || 0) + s.y + pixelY * ratioY + yOffset), "tera_sparkle"); + const [xOffset, yOffset] = [-s.originX * s.width, -s.originY * s.height]; + const sparkle = globalScene.addFieldSprite( + (pokemon?.x || 0) + s.x + pixelX * ratioX + xOffset, + (pokemon?.y || 0) + s.y + pixelY * ratioY + yOffset, + "tera_sparkle", + ); sparkle.pipelineData["ignoreTimeTint"] = s.pipelineData["ignoreTimeTint"]; sparkle.setName("sprite-tera-sparkle"); sparkle.play("tera_sparkle"); @@ -52,7 +58,7 @@ export default class PokemonSpriteSparkleHandler { add(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void { if (!Array.isArray(sprites)) { - sprites = [ sprites ]; + sprites = [sprites]; } for (const s of sprites) { if (this.sprites.has(s)) { @@ -64,7 +70,7 @@ export default class PokemonSpriteSparkleHandler { remove(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void { if (!Array.isArray(sprites)) { - sprites = [ sprites ]; + sprites = [sprites]; } for (const s of sprites) { this.sprites.delete(s); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index bc0490372bc..3cd25e4d10a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -5,7 +5,10 @@ import { globalScene } from "#app/global-scene"; import type { Variant, VariantSet } from "#app/data/variant"; import { variantColorCache } from "#app/data/variant"; import { variantData } from "#app/data/variant"; -import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from "#app/ui/battle-info"; +import BattleInfo, { + PlayerBattleInfo, + EnemyBattleInfo, +} from "#app/ui/battle-info"; import type Move from "#app/data/moves/move"; import { HighCritAttr, @@ -37,13 +40,21 @@ import { RespectAttackTypeImmunityAttr, CombinedPledgeStabBoostAttr, VariableMoveTypeChartAttr, - HpSplitAttr + HpSplitAttr, } from "#app/data/moves/move"; import { MoveTarget } from "#enums/MoveTarget"; import { MoveCategory } from "#enums/MoveCategory"; import type { PokemonSpeciesForm } from "#app/data/pokemon-species"; -import { default as PokemonSpecies, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species"; -import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters"; +import { + default as PokemonSpecies, + getFusedSpeciesName, + getPokemonSpecies, + getPokemonSpeciesForm, +} from "#app/data/pokemon-species"; +import { + getStarterValueFriendshipCap, + speciesStarterCosts, +} from "#app/data/balance/starters"; import type { Constructor } from "#app/utils"; import { isNullOrUndefined, randSeedInt, type nil } from "#app/utils"; import * as Utils from "#app/utils"; @@ -51,21 +62,137 @@ import type { TypeDamageMultiplier } from "#app/data/type"; import { getTypeDamageMultiplier, getTypeRgb } from "#app/data/type"; import { PokemonType } from "#enums/pokemon-type"; import { getLevelTotalExp } from "#app/data/exp"; -import { Stat, type PermanentStat, type BattleStat, type EffectiveStat, PERMANENT_STATS, BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat"; -import { DamageMoneyRewardModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, EnemyEndureChanceModifier, EnemyFusionChanceModifier, HiddenAbilityRateBoosterModifier, BaseStatModifier, PokemonFriendshipBoosterModifier, PokemonHeldItemModifier, PokemonNatureWeightModifier, ShinyRateBoosterModifier, SurviveDamageModifier, TempStatStageBoosterModifier, TempCritBoosterModifier, StatBoosterModifier, CritBoosterModifier, PokemonBaseStatFlatModifier, PokemonBaseStatTotalModifier, PokemonIncrementingStatModifier, EvoTrackerModifier, PokemonMultiHitModifier } from "#app/modifier/modifier"; +import { + Stat, + type PermanentStat, + type BattleStat, + type EffectiveStat, + PERMANENT_STATS, + BATTLE_STATS, + EFFECTIVE_STATS, +} from "#enums/stat"; +import { + DamageMoneyRewardModifier, + EnemyDamageBoosterModifier, + EnemyDamageReducerModifier, + EnemyEndureChanceModifier, + EnemyFusionChanceModifier, + HiddenAbilityRateBoosterModifier, + BaseStatModifier, + PokemonFriendshipBoosterModifier, + PokemonHeldItemModifier, + PokemonNatureWeightModifier, + ShinyRateBoosterModifier, + SurviveDamageModifier, + TempStatStageBoosterModifier, + TempCritBoosterModifier, + StatBoosterModifier, + CritBoosterModifier, + PokemonBaseStatFlatModifier, + PokemonBaseStatTotalModifier, + PokemonIncrementingStatModifier, + EvoTrackerModifier, + PokemonMultiHitModifier, +} from "#app/modifier/modifier"; import { PokeballType } from "#enums/pokeball"; import { Gender } from "#app/data/gender"; import { initMoveAnim, loadMoveAnimAssets } from "#app/data/battle-anims"; import { Status, getRandomStatus } from "#app/data/status-effect"; -import type { SpeciesFormEvolution, SpeciesEvolutionCondition } from "#app/data/balance/pokemon-evolutions"; -import { pokemonEvolutions, pokemonPrevolutions, FusionSpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions"; -import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/tms"; -import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags"; +import type { + SpeciesFormEvolution, + SpeciesEvolutionCondition, +} from "#app/data/balance/pokemon-evolutions"; +import { + pokemonEvolutions, + pokemonPrevolutions, + FusionSpeciesFormEvolution, +} from "#app/data/balance/pokemon-evolutions"; +import { + reverseCompatibleTms, + tmSpecies, + tmPoolTiers, +} from "#app/data/balance/tms"; +import { + BattlerTag, + BattlerTagLapseType, + EncoreTag, + GroundedTag, + HighestStatBoostTag, + SubstituteTag, + TypeImmuneTag, + getBattlerTag, + SemiInvulnerableTag, + TypeBoostTag, + MoveRestrictionBattlerTag, + ExposedTag, + DragonCheerTag, + CritBoostTag, + TrappedTag, + TarShotTag, + AutotomizedTag, + PowerTrickTag, +} from "../data/battler-tags"; import { WeatherType } from "#enums/weather-type"; -import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag"; +import { + ArenaTagSide, + NoCritTag, + WeakenMoveScreenTag, +} from "#app/data/arena-tag"; import type { SuppressAbilitiesTag } from "#app/data/arena-tag"; import type { Ability, AbAttr } from "#app/data/ability"; -import { StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, CommanderAbAttr, applyPostItemLostAbAttrs, PostItemLostAbAttr, applyOnGainAbAttrs, PreLeaveFieldAbAttr, applyPreLeaveFieldAbAttrs, applyOnLoseAbAttrs, PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr } from "#app/data/ability"; +import { + StatMultiplierAbAttr, + BlockCritAbAttr, + BonusCritAbAttr, + BypassBurnDamageReductionAbAttr, + FieldPriorityMoveImmunityAbAttr, + IgnoreOpponentStatStagesAbAttr, + MoveImmunityAbAttr, + PreDefendFullHpEndureAbAttr, + ReceivedMoveDamageMultiplierAbAttr, + StabBoostAbAttr, + StatusEffectImmunityAbAttr, + TypeImmunityAbAttr, + WeightMultiplierAbAttr, + allAbilities, + applyAbAttrs, + applyStatMultiplierAbAttrs, + applyPreApplyBattlerTagAbAttrs, + applyPreAttackAbAttrs, + applyPreDefendAbAttrs, + applyPreSetStatusAbAttrs, + UnsuppressableAbilityAbAttr, + NoFusionAbilityAbAttr, + MultCritAbAttr, + IgnoreTypeImmunityAbAttr, + DamageBoostAbAttr, + IgnoreTypeStatusEffectImmunityAbAttr, + ConditionalCritAbAttr, + applyFieldStatMultiplierAbAttrs, + FieldMultiplyStatAbAttr, + AddSecondStrikeAbAttr, + UserFieldStatusEffectImmunityAbAttr, + UserFieldBattlerTagImmunityAbAttr, + BattlerTagImmunityAbAttr, + MoveTypeChangeAbAttr, + FullHpResistTypeAbAttr, + applyCheckTrappedAbAttrs, + CheckTrappedAbAttr, + PostSetStatusAbAttr, + applyPostSetStatusAbAttrs, + InfiltratorAbAttr, + AlliedFieldDamageReductionAbAttr, + PostDamageAbAttr, + applyPostDamageAbAttrs, + CommanderAbAttr, + applyPostItemLostAbAttrs, + PostItemLostAbAttr, + applyOnGainAbAttrs, + PreLeaveFieldAbAttr, + applyPreLeaveFieldAbAttrs, + applyOnLoseAbAttrs, + PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, +} from "#app/data/ability"; import type PokemonData from "#app/system/pokemon-data"; import { BattlerIndex } from "#app/battle"; import { Mode } from "#app/ui/ui"; @@ -73,14 +200,27 @@ 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"; import type { LevelMoves } from "#app/data/balance/pokemon-level-moves"; -import { EVOLVE_MOVE, RELEARN_MOVE } from "#app/data/balance/pokemon-level-moves"; +import { + EVOLVE_MOVE, + RELEARN_MOVE, +} from "#app/data/balance/pokemon-level-moves"; import { DamageAchv, achvs } from "#app/system/achv"; import type { StarterDataEntry, StarterMoveset } from "#app/system/game-data"; import { DexAttr } from "#app/system/game-data"; -import { QuantizerCelebi, argbFromRgba, rgbaFromArgb } from "@material/material-color-utilities"; +import { + QuantizerCelebi, + argbFromRgba, + rgbaFromArgb, +} from "@material/material-color-utilities"; import { getNatureStatMultiplier } from "#app/data/nature"; import type { SpeciesFormChange } from "#app/data/pokemon-forms"; -import { SpeciesFormChangeActiveTrigger, SpeciesFormChangeLapseTeraTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from "#app/data/pokemon-forms"; +import { + SpeciesFormChangeActiveTrigger, + SpeciesFormChangeLapseTeraTrigger, + SpeciesFormChangeMoveLearnedTrigger, + SpeciesFormChangePostMoveTrigger, + SpeciesFormChangeStatusEffectTrigger, +} from "#app/data/pokemon-forms"; import { TerrainType } from "#app/data/terrain"; import type { TrainerSlot } from "#app/data/trainer-config"; import Overrides from "#app/overrides"; @@ -111,7 +251,12 @@ import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { CustomPokemonData } from "#app/data/custom-pokemon-data"; import { SwitchType } from "#enums/switch-type"; import { SpeciesFormKey } from "#enums/species-form-key"; -import { BASE_HIDDEN_ABILITY_CHANCE, BASE_SHINY_CHANCE, SHINY_EPIC_CHANCE, SHINY_VARIANT_CHANCE } from "#app/data/balance/rates"; +import { + BASE_HIDDEN_ABILITY_CHANCE, + BASE_SHINY_CHANCE, + SHINY_EPIC_CHANCE, + SHINY_VARIANT_CHANCE, +} from "#app/data/balance/rates"; import { Nature } from "#enums/nature"; import { StatusEffect } from "#enums/status-effect"; import { doShinySparkleAnim } from "#app/field/anims"; @@ -122,13 +267,13 @@ export enum LearnMoveSituation { RELEARN, EVOLUTION, EVOLUTION_FUSED, // If fusionSpecies has Evolved - EVOLUTION_FUSED_BASE // If fusion's base species has Evolved + EVOLUTION_FUSED_BASE, // If fusion's base species has Evolved } export enum FieldPosition { CENTER, LEFT, - RIGHT + RIGHT, } export default abstract class Pokemon extends Phaser.GameObjects.Container { @@ -197,16 +342,35 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { private shinySparkle: Phaser.GameObjects.Sprite; - constructor(x: number, y: number, species: PokemonSpecies, level: number, abilityIndex?: number, formIndex?: number, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: number[], nature?: Nature, dataSource?: Pokemon | PokemonData) { + constructor( + x: number, + y: number, + species: PokemonSpecies, + level: number, + abilityIndex?: number, + formIndex?: number, + gender?: Gender, + shiny?: boolean, + variant?: Variant, + ivs?: number[], + nature?: Nature, + dataSource?: Pokemon | PokemonData, + ) { super(globalScene, x, y); if (!species.isObtainable() && this.isPlayer()) { throw `Cannot create a player Pokemon for species '${species.getName(formIndex)}'`; } - const hiddenAbilityChance = new Utils.NumberHolder(BASE_HIDDEN_ABILITY_CHANCE); + const hiddenAbilityChance = new Utils.NumberHolder( + BASE_HIDDEN_ABILITY_CHANCE, + ); if (!this.hasTrainer()) { - globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); + globalScene.applyModifiers( + HiddenAbilityRateBoosterModifier, + true, + hiddenAbilityChance, + ); } this.species = species; @@ -226,7 +390,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.abilityIndex = 2; } else { // If there is no hidden ability or species does not have a hidden ability - this.abilityIndex = species.ability2 !== species.ability1 ? randAbilityIndex : 0; // Use random ability index if species has a second ability, otherwise use 0 + this.abilityIndex = + species.ability2 !== species.ability1 ? randAbilityIndex : 0; // Use random ability index if species has a second ability, otherwise use 0 } } if (formIndex !== undefined) { @@ -241,7 +406,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (variant !== undefined) { this.variant = variant; } - this.exp = dataSource?.exp || getLevelTotalExp(this.level, species.growthRate); + this.exp = + dataSource?.exp || getLevelTotalExp(this.level, species.growthRate); this.levelExp = dataSource?.levelExp || 0; if (dataSource) { this.id = dataSource.id; @@ -252,20 +418,32 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.variant === undefined) { this.variant = 0; } - this.nature = dataSource.nature || 0 as Nature; + this.nature = dataSource.nature || (0 as Nature); this.nickname = dataSource.nickname; this.moveset = dataSource.moveset; this.status = dataSource.status!; // TODO: is this bang correct? - this.friendship = dataSource.friendship !== undefined ? dataSource.friendship : this.species.baseFriendship; + this.friendship = + dataSource.friendship !== undefined + ? dataSource.friendship + : this.species.baseFriendship; this.metLevel = dataSource.metLevel || 5; this.luck = dataSource.luck; this.metBiome = dataSource.metBiome; - this.metSpecies = dataSource.metSpecies ?? (this.metBiome !== -1 ? this.species.speciesId : this.species.getRootSpeciesId(true)); + this.metSpecies = + dataSource.metSpecies ?? + (this.metBiome !== -1 + ? this.species.speciesId + : this.species.getRootSpeciesId(true)); this.metWave = dataSource.metWave ?? (this.metBiome === -1 ? -1 : 0); this.pauseEvolutions = dataSource.pauseEvolutions; this.pokerus = !!dataSource.pokerus; this.evoCounter = dataSource.evoCounter ?? 0; - this.fusionSpecies = dataSource.fusionSpecies instanceof PokemonSpecies ? dataSource.fusionSpecies : dataSource.fusionSpecies ? getPokemonSpecies(dataSource.fusionSpecies) : null; + this.fusionSpecies = + dataSource.fusionSpecies instanceof PokemonSpecies + ? dataSource.fusionSpecies + : dataSource.fusionSpecies + ? getPokemonSpecies(dataSource.fusionSpecies) + : null; this.fusionFormIndex = dataSource.fusionFormIndex; this.fusionAbilityIndex = dataSource.fusionAbilityIndex; this.fusionShiny = dataSource.fusionShiny; @@ -275,7 +453,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.fusionCustomPokemonData = dataSource.fusionCustomPokemonData; this.fusionTeraType = dataSource.fusionTeraType; this.usedTMs = dataSource.usedTMs ?? []; - this.customPokemonData = new CustomPokemonData(dataSource.customPokemonData); + this.customPokemonData = new CustomPokemonData( + dataSource.customPokemonData, + ); this.teraType = dataSource.teraType; this.isTerastallized = dataSource.isTerastallized; this.stellarTypesBoosted = dataSource.stellarTypesBoosted ?? []; @@ -288,7 +468,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (this.formIndex === undefined) { - this.formIndex = globalScene.getSpeciesFormIndex(species, this.gender, this.nature, this.isPlayer()); + this.formIndex = globalScene.getSpeciesFormIndex( + species, + this.gender, + this.nature, + this.isPlayer(), + ); } if (this.shiny === undefined) { @@ -309,13 +494,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.friendship = species.baseFriendship; this.metLevel = level; - this.metBiome = globalScene.currentBattle ? globalScene.arena.biomeType : -1; + this.metBiome = globalScene.currentBattle + ? globalScene.arena.biomeType + : -1; this.metSpecies = species.speciesId; - this.metWave = globalScene.currentBattle ? globalScene.currentBattle.waveIndex : -1; + this.metWave = globalScene.currentBattle + ? globalScene.currentBattle.waveIndex + : -1; this.pokerus = false; if (level > 1) { - const fused = new Utils.BooleanHolder(globalScene.gameMode.isSplicedOnly); + const fused = new Utils.BooleanHolder( + globalScene.gameMode.isSplicedOnly, + ); if (!fused.value && !this.isPlayer() && !this.hasTrainer()) { globalScene.applyModifier(EnemyFusionChanceModifier, false, fused); } @@ -325,7 +516,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.generateFusionSpecies(); } } - this.luck = (this.shiny ? this.variant + 1 : 0) + (this.fusionShiny ? this.fusionVariant + 1 : 0); + this.luck = + (this.shiny ? this.variant + 1 : 0) + + (this.fusionShiny ? this.fusionVariant + 1 : 0); this.fusionLuck = this.luck; this.teraType = Utils.randSeedItem(this.getTypes(false, false, true)); @@ -344,7 +537,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - getNameToRender() { try { if (this.nickname) { @@ -365,9 +557,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { globalScene.fieldUI.addAt(this.battleInfo, 0); const getSprite = (hasShadow?: boolean) => { - const ret = globalScene.addPokemonSprite(this, 0, 0, `pkmn__${this.isPlayer() ? "back__" : ""}sub`, undefined, true); + const ret = globalScene.addPokemonSprite( + this, + 0, + 0, + `pkmn__${this.isPlayer() ? "back__" : ""}sub`, + undefined, + true, + ); ret.setOrigin(0.5, 1); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow, teraColor: getTypeRgb(this.getTeraType()), isTerastallized: this.isTerastallized }); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: !!hasShadow, + teraColor: getTypeRgb(this.getTeraType()), + isTerastallized: this.isTerastallized, + }); return ret; }; @@ -404,8 +608,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param checkStatus `true` to also check that the pokemon's status is {@linkcode StatusEffect.FAINT} * @returns `true` if the pokemon is fainted */ - public isFainted(checkStatus: boolean = false): boolean { - return this.hp <= 0 && (!checkStatus || this.status?.effect === StatusEffect.FAINT); + public isFainted(checkStatus = false): boolean { + return ( + this.hp <= 0 && + (!checkStatus || this.status?.effect === StatusEffect.FAINT) + ); } /** @@ -423,7 +630,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ public isAllowedInChallenge(): boolean { const challengeAllowed = new Utils.BooleanHolder(true); - applyChallenges(globalScene.gameMode, ChallengeType.POKEMON_IN_BATTLE, this, challengeAllowed); + applyChallenges( + globalScene.gameMode, + ChallengeType.POKEMON_IN_BATTLE, + this, + challengeAllowed, + ); return challengeAllowed.value; } @@ -432,7 +644,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param onField `true` to also check if the pokemon is currently on the field, defaults to `false` * @returns `true` if the pokemon is "active". Returns `false` if there is no active {@linkcode BattleScene} */ - public isActive(onField: boolean = false): boolean { + public isActive(onField = false): boolean { if (!globalScene) { return false; } @@ -443,7 +655,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { let ret = 0n; ret |= this.gender !== Gender.FEMALE ? DexAttr.MALE : DexAttr.FEMALE; ret |= !this.shiny ? DexAttr.NON_SHINY : DexAttr.SHINY; - ret |= this.variant >= 2 ? DexAttr.VARIANT_3 : this.variant === 1 ? DexAttr.VARIANT_2 : DexAttr.DEFAULT_VARIANT; + ret |= + this.variant >= 2 + ? DexAttr.VARIANT_3 + : this.variant === 1 + ? DexAttr.VARIANT_2 + : DexAttr.DEFAULT_VARIANT; ret |= globalScene.gameData.getFormAttr(this.formIndex); return ret; } @@ -458,7 +675,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.name = this.species.getName(this.formIndex); return; } - this.name = getFusedSpeciesName(this.species.getName(this.formIndex), this.fusionSpecies.getName(this.fusionFormIndex)); + this.name = getFusedSpeciesName( + this.species.getName(this.formIndex), + this.fusionSpecies.getName(this.fusionFormIndex), + ); if (this.battleInfo) { this.updateInfo(true); } @@ -472,74 +692,114 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { abstract getBattlerIndex(): BattlerIndex; - loadAssets(ignoreOverride: boolean = true): Promise { + loadAssets(ignoreOverride = true): Promise { return new Promise(resolve => { const moveIds = this.getMoveset().map(m => m!.getMove().id); // TODO: is this bang correct? - Promise.allSettled(moveIds.map(m => initMoveAnim(m))) - .then(() => { - loadMoveAnimAssets(moveIds); - this.getSpeciesForm().loadAssets(this.getGender() === Gender.FEMALE, this.formIndex, this.shiny, this.variant); - if (this.isPlayer() || this.getFusionSpeciesForm()) { - globalScene.loadPokemonAtlas(this.getBattleSpriteKey(true, ignoreOverride), this.getBattleSpriteAtlasPath(true, ignoreOverride)); - } - if (this.getFusionSpeciesForm()) { - this.getFusionSpeciesForm().loadAssets(this.getFusionGender() === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant); - globalScene.loadPokemonAtlas(this.getFusionBattleSpriteKey(true, ignoreOverride), this.getFusionBattleSpriteAtlasPath(true, ignoreOverride)); - } - globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => { - if (this.isPlayer()) { - const originalWarn = console.warn; - // Ignore warnings for missing frames, because there will be a lot - console.warn = () => {}; - const battleFrameNames = globalScene.anims.generateFrameNames(this.getBattleSpriteKey(), { zeroPad: 4, suffix: ".png", start: 1, end: 400 }); - console.warn = originalWarn; - if (!(globalScene.anims.exists(this.getBattleSpriteKey()))) { - globalScene.anims.create({ - key: this.getBattleSpriteKey(), - frames: battleFrameNames, - frameRate: 10, - repeat: -1 - }); - } + Promise.allSettled(moveIds.map(m => initMoveAnim(m))).then(() => { + loadMoveAnimAssets(moveIds); + this.getSpeciesForm().loadAssets( + this.getGender() === Gender.FEMALE, + this.formIndex, + this.shiny, + this.variant, + ); + if (this.isPlayer() || this.getFusionSpeciesForm()) { + globalScene.loadPokemonAtlas( + this.getBattleSpriteKey(true, ignoreOverride), + this.getBattleSpriteAtlasPath(true, ignoreOverride), + ); + } + if (this.getFusionSpeciesForm()) { + this.getFusionSpeciesForm().loadAssets( + this.getFusionGender() === Gender.FEMALE, + this.fusionFormIndex, + this.fusionShiny, + this.fusionVariant, + ); + globalScene.loadPokemonAtlas( + this.getFusionBattleSpriteKey(true, ignoreOverride), + this.getFusionBattleSpriteAtlasPath(true, ignoreOverride), + ); + } + globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => { + if (this.isPlayer()) { + const originalWarn = console.warn; + // Ignore warnings for missing frames, because there will be a lot + console.warn = () => {}; + const battleFrameNames = globalScene.anims.generateFrameNames( + this.getBattleSpriteKey(), + { zeroPad: 4, suffix: ".png", start: 1, end: 400 }, + ); + console.warn = originalWarn; + if (!globalScene.anims.exists(this.getBattleSpriteKey())) { + globalScene.anims.create({ + key: this.getBattleSpriteKey(), + frames: battleFrameNames, + frameRate: 10, + repeat: -1, + }); } - this.playAnim(); - const updateFusionPaletteAndResolve = () => { - this.updateFusionPalette(); - if (this.summonData?.speciesForm) { - this.updateFusionPalette(true); - } - resolve(); - }; - if (this.shiny) { - const populateVariantColors = (isBackSprite: boolean = false): Promise => { - return new Promise(async resolve => { - const battleSpritePath = this.getBattleSpriteAtlasPath(isBackSprite, ignoreOverride).replace("variant/", "").replace(/_[1-3]$/, ""); - let config = variantData; - const useExpSprite = globalScene.experimentalSprites && globalScene.hasExpSprite(this.getBattleSpriteKey(isBackSprite, ignoreOverride)); - battleSpritePath.split("/").map(p => config ? config = config[p] : null); - const variantSet: VariantSet = config as VariantSet; - if (variantSet && variantSet[this.variant] === 1) { - const cacheKey = this.getBattleSpriteKey(isBackSprite); - if (!variantColorCache.hasOwnProperty(cacheKey)) { - await this.populateVariantColorCache(cacheKey, useExpSprite, battleSpritePath); - } + } + this.playAnim(); + const updateFusionPaletteAndResolve = () => { + this.updateFusionPalette(); + if (this.summonData?.speciesForm) { + this.updateFusionPalette(true); + } + resolve(); + }; + if (this.shiny) { + const populateVariantColors = ( + isBackSprite = false, + ): Promise => { + return new Promise(async resolve => { + const battleSpritePath = this.getBattleSpriteAtlasPath( + isBackSprite, + ignoreOverride, + ) + .replace("variant/", "") + .replace(/_[1-3]$/, ""); + let config = variantData; + const useExpSprite = + globalScene.experimentalSprites && + globalScene.hasExpSprite( + this.getBattleSpriteKey(isBackSprite, ignoreOverride), + ); + battleSpritePath + .split("/") + .map(p => (config ? (config = config[p]) : null)); + const variantSet: VariantSet = config as VariantSet; + if (variantSet && variantSet[this.variant] === 1) { + const cacheKey = this.getBattleSpriteKey(isBackSprite); + if (!variantColorCache.hasOwnProperty(cacheKey)) { + await this.populateVariantColorCache( + cacheKey, + useExpSprite, + battleSpritePath, + ); } - resolve(); - }); - }; - if (this.isPlayer()) { - Promise.all([ populateVariantColors(false), populateVariantColors(true) ]).then(() => updateFusionPaletteAndResolve()); - } else { - populateVariantColors(false).then(() => updateFusionPaletteAndResolve()); - } + } + resolve(); + }); + }; + if (this.isPlayer()) { + Promise.all([ + populateVariantColors(false), + populateVariantColors(true), + ]).then(() => updateFusionPaletteAndResolve()); } else { - updateFusionPaletteAndResolve(); + populateVariantColors(false).then(() => + updateFusionPaletteAndResolve(), + ); } - }); - if (!globalScene.load.isLoading()) { - globalScene.load.start(); + } else { + updateFusionPaletteAndResolve(); } }); + if (!globalScene.load.isLoading()) { + globalScene.load.start(); + } + }); }); } @@ -553,7 +813,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param battleSpritePath the filename of the sprite * @param optionalParams any additional params to log */ - async fallbackVariantColor(cacheKey: string, attemptedSpritePath: string, useExpSprite: boolean, battleSpritePath: string, ...optionalParams: any[]) { + async fallbackVariantColor( + cacheKey: string, + attemptedSpritePath: string, + useExpSprite: boolean, + battleSpritePath: string, + ...optionalParams: any[] + ) { console.warn(`Could not load ${attemptedSpritePath}!`, ...optionalParams); if (useExpSprite) { await this.populateVariantColorCache(cacheKey, false, battleSpritePath); @@ -567,25 +833,49 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param useExpSprite should the experimental sprite be used * @param battleSpritePath the filename of the sprite */ - async populateVariantColorCache(cacheKey: string, useExpSprite: boolean, battleSpritePath: string) { + async populateVariantColorCache( + cacheKey: string, + useExpSprite: boolean, + battleSpritePath: string, + ) { const spritePath = `./images/pokemon/variant/${useExpSprite ? "exp/" : ""}${battleSpritePath}.json`; - return globalScene.cachedFetch(spritePath).then(res => { - // Prevent the JSON from processing if it failed to load - if (!res.ok) { - return this.fallbackVariantColor(cacheKey, res.url, useExpSprite, battleSpritePath, res.status, res.statusText); - } - return res.json(); - }).catch(error => { - return this.fallbackVariantColor(cacheKey, spritePath, useExpSprite, battleSpritePath, error); - }).then(c => { - if (!isNullOrUndefined(c)) { - variantColorCache[cacheKey] = c; - } - }); + return globalScene + .cachedFetch(spritePath) + .then(res => { + // Prevent the JSON from processing if it failed to load + if (!res.ok) { + return this.fallbackVariantColor( + cacheKey, + res.url, + useExpSprite, + battleSpritePath, + res.status, + res.statusText, + ); + } + return res.json(); + }) + .catch(error => { + return this.fallbackVariantColor( + cacheKey, + spritePath, + useExpSprite, + battleSpritePath, + error, + ); + }) + .then(c => { + if (!isNullOrUndefined(c)) { + variantColorCache[cacheKey] = c; + } + }); } getFormKey(): string { - if (!this.species.forms.length || this.species.forms.length <= this.formIndex) { + if ( + !this.species.forms.length || + this.species.forms.length <= this.formIndex + ) { return ""; } return this.species.forms[this.formIndex].formKey; @@ -595,7 +885,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!this.fusionSpecies) { return null; } - if (!this.fusionSpecies.forms.length || this.fusionSpecies.forms.length <= this.fusionFormIndex) { + if ( + !this.fusionSpecies.forms.length || + this.fusionSpecies.forms.length <= this.fusionFormIndex + ) { return ""; } return this.fusionSpecies.forms[this.fusionFormIndex].formKey; @@ -607,23 +900,42 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } getBattleSpriteAtlasPath(back?: boolean, ignoreOverride?: boolean): string { - const spriteId = this.getBattleSpriteId(back, ignoreOverride).replace(/\_{2}/g, "/"); + const spriteId = this.getBattleSpriteId(back, ignoreOverride).replace( + /\_{2}/g, + "/", + ); return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`; } getSpriteId(ignoreOverride?: boolean): string { - return this.getSpeciesForm(ignoreOverride).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant); + return this.getSpeciesForm(ignoreOverride).getSpriteId( + this.getGender(ignoreOverride) === Gender.FEMALE, + this.formIndex, + this.shiny, + this.variant, + ); } getBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) { back = this.isPlayer(); } - return this.getSpeciesForm(ignoreOverride).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant, back); + return this.getSpeciesForm(ignoreOverride).getSpriteId( + this.getGender(ignoreOverride) === Gender.FEMALE, + this.formIndex, + this.shiny, + this.variant, + back, + ); } getSpriteKey(ignoreOverride?: boolean): string { - return this.getSpeciesForm(ignoreOverride).getSpriteKey(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant); + return this.getSpeciesForm(ignoreOverride).getSpriteKey( + this.getGender(ignoreOverride) === Gender.FEMALE, + this.formIndex, + this.shiny, + this.variant, + ); } getBattleSpriteKey(back?: boolean, ignoreOverride?: boolean): string { @@ -631,38 +943,73 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } getFusionSpriteId(ignoreOverride?: boolean): string { - return this.getFusionSpeciesForm(ignoreOverride).getSpriteId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant); + return this.getFusionSpeciesForm(ignoreOverride).getSpriteId( + this.getFusionGender(ignoreOverride) === Gender.FEMALE, + this.fusionFormIndex, + this.fusionShiny, + this.fusionVariant, + ); } getFusionBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) { back = this.isPlayer(); } - return this.getFusionSpeciesForm(ignoreOverride).getSpriteId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant, back); + return this.getFusionSpeciesForm(ignoreOverride).getSpriteId( + this.getFusionGender(ignoreOverride) === Gender.FEMALE, + this.fusionFormIndex, + this.fusionShiny, + this.fusionVariant, + back, + ); } getFusionBattleSpriteKey(back?: boolean, ignoreOverride?: boolean): string { return `pkmn__${this.getFusionBattleSpriteId(back, ignoreOverride)}`; } - getFusionBattleSpriteAtlasPath(back?: boolean, ignoreOverride?: boolean): string { - return this.getFusionBattleSpriteId(back, ignoreOverride).replace(/\_{2}/g, "/"); + getFusionBattleSpriteAtlasPath( + back?: boolean, + ignoreOverride?: boolean, + ): string { + return this.getFusionBattleSpriteId(back, ignoreOverride).replace( + /\_{2}/g, + "/", + ); } getIconAtlasKey(ignoreOverride?: boolean): string { - return this.getSpeciesForm(ignoreOverride).getIconAtlasKey(this.formIndex, this.shiny, this.variant); + return this.getSpeciesForm(ignoreOverride).getIconAtlasKey( + this.formIndex, + this.shiny, + this.variant, + ); } getFusionIconAtlasKey(ignoreOverride?: boolean): string { - return this.getFusionSpeciesForm(ignoreOverride).getIconAtlasKey(this.fusionFormIndex, this.fusionShiny, this.fusionVariant); + return this.getFusionSpeciesForm(ignoreOverride).getIconAtlasKey( + this.fusionFormIndex, + this.fusionShiny, + this.fusionVariant, + ); } getIconId(ignoreOverride?: boolean): string { - return this.getSpeciesForm(ignoreOverride).getIconId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant); + return this.getSpeciesForm(ignoreOverride).getIconId( + this.getGender(ignoreOverride) === Gender.FEMALE, + this.formIndex, + this.shiny, + this.variant, + ); } getFusionIconId(ignoreOverride?: boolean): string { - return this.getFusionSpeciesForm(ignoreOverride).getIconId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant); + return this.getFusionSpeciesForm(ignoreOverride).getIconId( + this.getFusionGender(ignoreOverride) === Gender.FEMALE, + this.fusionFormIndex, + this.fusionShiny, + this.fusionVariant, + ); } getSpeciesForm(ignoreOverride?: boolean): PokemonSpeciesForm { @@ -680,7 +1027,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!ignoreOverride && this.summonData?.speciesForm) { return this.summonData.fusionSpeciesForm; } - if (!this.fusionSpecies?.forms?.length || this.fusionFormIndex >= this.fusionSpecies?.forms.length) { + if ( + !this.fusionSpecies?.forms?.length || + this.fusionFormIndex >= this.fusionSpecies?.forms.length + ) { //@ts-ignore return this.fusionSpecies; // TODO: I don't even know how to fix this... A complete cluster of classes involved + null } @@ -693,15 +1043,23 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getTintSprite(): Phaser.GameObjects.Sprite | null { return !this.maskEnabled - ? this.getAt(1) as Phaser.GameObjects.Sprite + ? (this.getAt(1) as Phaser.GameObjects.Sprite) : this.maskSprite; } getSpriteScale(): number { const formKey = this.getFormKey(); - if (this.isMax() === true || formKey === "segin-starmobile" || formKey === "schedar-starmobile" || formKey === "navi-starmobile" || formKey === "ruchbah-starmobile" || formKey === "caph-starmobile") { + if ( + this.isMax() === true || + formKey === "segin-starmobile" || + formKey === "schedar-starmobile" || + formKey === "navi-starmobile" || + formKey === "ruchbah-starmobile" || + formKey === "caph-starmobile" + ) { return 1.5; - } else if (this.customPokemonData.spriteScale > 0) { + } + if (this.customPokemonData.spriteScale > 0) { return this.customPokemonData.spriteScale; } return 1; @@ -727,7 +1085,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!globalScene) { return []; } - return globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.id, this.isPlayer()) as PokemonHeldItemModifier[]; + return globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.id, + this.isPlayer(), + ) as PokemonHeldItemModifier[]; } updateScale(): void { @@ -735,10 +1096,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } updateSpritePipelineData(): void { - [ this.getSprite(), this.getTintSprite() ].filter(s => !!s).map(s => { - s.pipelineData["teraColor"] = getTypeRgb(this.getTeraType()); - s.pipelineData["isTerastallized"] = this.isTerastallized; - }); + [this.getSprite(), this.getTintSprite()] + .filter(s => !!s) + .map(s => { + s.pipelineData["teraColor"] = getTypeRgb(this.getTeraType()); + s.pipelineData["isTerastallized"] = this.isTerastallized; + }); this.updateInfo(true); } @@ -759,13 +1122,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param animConfig {@linkcode String} to pass to {@linkcode Phaser.GameObjects.Sprite.play} * @returns true if the sprite was able to be animated */ - tryPlaySprite(sprite: Phaser.GameObjects.Sprite, tintSprite: Phaser.GameObjects.Sprite, key: string): boolean { + tryPlaySprite( + sprite: Phaser.GameObjects.Sprite, + tintSprite: Phaser.GameObjects.Sprite, + key: string, + ): boolean { // Catch errors when trying to play an animation that doesn't exist try { sprite.play(key); tintSprite.play(key); } catch (error: unknown) { - console.error(`Couldn't play animation for '${key}'!\nIs the image for this Pokemon missing?\n`, error); + console.error( + `Couldn't play animation for '${key}'!\nIs the image for this Pokemon missing?\n`, + error, + ); return false; } @@ -774,17 +1144,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } playAnim(): void { - this.tryPlaySprite(this.getSprite(), this.getTintSprite()!, this.getBattleSpriteKey()); // TODO: is the bag correct? + this.tryPlaySprite( + this.getSprite(), + this.getTintSprite()!, + this.getBattleSpriteKey(), + ); // TODO: is the bag correct? } - getFieldPositionOffset(): [ number, number ] { + getFieldPositionOffset(): [number, number] { switch (this.fieldPosition) { case FieldPosition.CENTER: - return [ 0, 0 ]; + return [0, 0]; case FieldPosition.LEFT: - return [ -32, -8 ]; + return [-32, -8]; case FieldPosition.RIGHT: - return [ 32, 0 ]; + return [32, 0]; } } @@ -794,8 +1168,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @see {@linkcode SubstituteTag} * @see {@linkcode getFieldPositionOffset} */ - getSubstituteOffset(): [ number, number ] { - return this.isPlayer() ? [ -30, 10 ] : [ 30, -10 ]; + getSubstituteOffset(): [number, number] { + return this.isPlayer() ? [-30, 10] : [30, -10]; } /** @@ -812,7 +1186,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus" const currentPhase = globalScene.getCurrentPhase(); - if (currentPhase instanceof MoveEffectPhase && currentPhase.getPokemon() === this) { + if ( + currentPhase instanceof MoveEffectPhase && + currentPhase.getPokemon() === this + ) { return false; } return true; @@ -829,7 +1206,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - setFieldPosition(fieldPosition: FieldPosition, duration?: number): Promise { + setFieldPosition( + fieldPosition: FieldPosition, + duration?: number, + ): Promise { return new Promise(resolve => { if (fieldPosition === this.fieldPosition) { resolve(); @@ -852,7 +1232,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (duration) { // TODO: can this use stricter typing? - const targets: any[] = [ this ]; + const targets: any[] = [this]; if (subTag?.sprite) { targets.push(subTag.sprite); } @@ -862,7 +1242,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { y: (_target, _key, value: number) => value + relY, duration: duration, ease: "Sine.easeOut", - onComplete: () => resolve() + onComplete: () => resolve(), }); } else { this.x += relX; @@ -880,7 +1260,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param bypassSummonData prefer actual stats (`true` by default) or in-battle overriden stats (`false`) * @returns the numeric values of the {@linkcode Pokemon}'s stats */ - getStats(bypassSummonData: boolean = true): number[] { + getStats(bypassSummonData = true): number[] { if (!bypassSummonData && this.summonData?.stats) { return this.summonData.stats; } @@ -893,8 +1273,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param bypassSummonData prefer actual stats (`true` by default) or in-battle overridden stats (`false`) * @returns the numeric value of the desired {@linkcode Stat} */ - getStat(stat: PermanentStat, bypassSummonData: boolean = true): number { - if (!bypassSummonData && this.summonData && (this.summonData.stats[stat] !== 0)) { + getStat(stat: PermanentStat, bypassSummonData = true): number { + if ( + !bypassSummonData && + this.summonData && + this.summonData.stats[stat] !== 0 + ) { return this.summonData.stats[stat]; } return this.stats[stat]; @@ -908,7 +1292,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param value the desired numeric value * @param bypassSummonData write to actual stats (`true` by default) or in-battle overridden stats (`false`) */ - setStat(stat: PermanentStat, value: number, bypassSummonData: boolean = true): void { + setStat(stat: PermanentStat, value: number, bypassSummonData = true): void { if (value >= 0) { if (!bypassSummonData && this.summonData) { this.summonData.stats[stat] = value; @@ -923,7 +1307,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns the numeric values of the {@linkcode Pokemon}'s in-battle stat stages if available, a fresh stat stage array otherwise */ getStatStages(): number[] { - return this.summonData ? this.summonData.statStages : [ 0, 0, 0, 0, 0, 0, 0 ]; + return this.summonData ? this.summonData.statStages : [0, 0, 0, 0, 0, 0, 0]; } /** @@ -962,11 +1346,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getCritStage(source: Pokemon, move: Move): number { const critStage = new Utils.NumberHolder(0); applyMoveAttrs(HighCritAttr, source, this, move, critStage); - globalScene.applyModifiers(CritBoosterModifier, source.isPlayer(), source, critStage); - globalScene.applyModifiers(TempCritBoosterModifier, source.isPlayer(), critStage); + globalScene.applyModifiers( + CritBoosterModifier, + source.isPlayer(), + source, + critStage, + ); + globalScene.applyModifiers( + TempCritBoosterModifier, + source.isPlayer(), + critStage, + ); const bonusCrit = new Utils.BooleanHolder(false); //@ts-ignore - if (applyAbAttrs(BonusCritAbAttr, source, null, false, bonusCrit)) { // TODO: resolve ts-ignore. This is a promise. Checking a promise is bogus. + if (applyAbAttrs(BonusCritAbAttr, source, null, false, bonusCrit)) { + // TODO: resolve ts-ignore. This is a promise. Checking a promise is bogus. if (bonusCrit.value) { critStage.value += 1; } @@ -974,7 +1368,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const critBoostTag = source.getTag(CritBoostTag); if (critBoostTag) { if (critBoostTag instanceof DragonCheerTag) { - critStage.value += critBoostTag.typesOnAdd.includes(PokemonType.DRAGON) ? 2 : 1; + critStage.value += critBoostTag.typesOnAdd.includes(PokemonType.DRAGON) + ? 2 + : 1; } else { critStage.value += 2; } @@ -998,25 +1394,64 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreHeldItems determines whether this Pokemon's held items should be ignored during the stat calculation, default `false` * @returns the final in-battle value of a stat */ - getEffectiveStat(stat: EffectiveStat, opponent?: Pokemon, move?: Move, ignoreAbility: boolean = false, ignoreOppAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true, ignoreHeldItems: boolean = false): number { + getEffectiveStat( + stat: EffectiveStat, + opponent?: Pokemon, + move?: Move, + ignoreAbility = false, + ignoreOppAbility = false, + isCritical = false, + simulated = true, + ignoreHeldItems = false, + ): number { const statValue = new Utils.NumberHolder(this.getStat(stat, false)); if (!ignoreHeldItems) { - globalScene.applyModifiers(StatBoosterModifier, this.isPlayer(), this, stat, statValue); + globalScene.applyModifiers( + StatBoosterModifier, + this.isPlayer(), + this, + stat, + statValue, + ); } // The Ruin abilities here are never ignored, but they reveal themselves on summon anyway const fieldApplied = new Utils.BooleanHolder(false); for (const pokemon of globalScene.getField(true)) { - applyFieldStatMultiplierAbAttrs(FieldMultiplyStatAbAttr, pokemon, stat, statValue, this, fieldApplied, simulated); + applyFieldStatMultiplierAbAttrs( + FieldMultiplyStatAbAttr, + pokemon, + stat, + statValue, + this, + fieldApplied, + simulated, + ); if (fieldApplied.value) { break; } } if (!ignoreAbility) { - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, this, stat, statValue, simulated); + applyStatMultiplierAbAttrs( + StatMultiplierAbAttr, + this, + stat, + statValue, + simulated, + ); } - let ret = statValue.value * this.getStatStageMultiplier(stat, opponent, move, ignoreOppAbility, isCritical, simulated, ignoreHeldItems); + let ret = + statValue.value * + this.getStatStageMultiplier( + stat, + opponent, + move, + ignoreOppAbility, + isCritical, + simulated, + ignoreHeldItems, + ); switch (stat) { case Stat.ATK: @@ -1025,14 +1460,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } break; case Stat.DEF: - if (this.isOfType(PokemonType.ICE) && globalScene.arena.weather?.weatherType === WeatherType.SNOW) { + if ( + this.isOfType(PokemonType.ICE) && + globalScene.arena.weather?.weatherType === WeatherType.SNOW + ) { ret *= 1.5; } break; case Stat.SPATK: break; case Stat.SPDEF: - if (this.isOfType(PokemonType.ROCK) && globalScene.arena.weather?.weatherType === WeatherType.SANDSTORM) { + if ( + this.isOfType(PokemonType.ROCK) && + globalScene.arena.weather?.weatherType === WeatherType.SANDSTORM + ) { ret *= 1.5; } break; @@ -1041,7 +1482,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (globalScene.arena.getTagOnSide(ArenaTagType.TAILWIND, side)) { ret *= 2; } - if (globalScene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, side)) { + if ( + globalScene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, side) + ) { ret >>= 2; } @@ -1051,13 +1494,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.status && this.status.effect === StatusEffect.PARALYSIS) { ret >>= 1; } - if (this.getTag(BattlerTagType.UNBURDEN) && this.hasAbility(Abilities.UNBURDEN)) { + if ( + this.getTag(BattlerTagType.UNBURDEN) && + this.hasAbility(Abilities.UNBURDEN) + ) { ret *= 2; } break; } - const highestStatBoost = this.findTag(t => t instanceof HighestStatBoostTag && (t as HighestStatBoostTag).stat === stat) as HighestStatBoostTag; + const highestStatBoost = this.findTag( + t => + t instanceof HighestStatBoostTag && + (t as HighestStatBoostTag).stat === stat, + ) as HighestStatBoostTag; if (highestStatBoost) { ret *= highestStatBoost.multiplier; } @@ -1067,17 +1517,25 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { calculateStats(): void { if (!this.stats) { - this.stats = [ 0, 0, 0, 0, 0, 0 ]; + this.stats = [0, 0, 0, 0, 0, 0]; } // Get and manipulate base stats const baseStats = this.calculateBaseStats(); // Using base stats, calculate and store stats one by one for (const s of PERMANENT_STATS) { - const statHolder = new Utils.NumberHolder(Math.floor(((2 * baseStats[s] + this.ivs[s]) * this.level) * 0.01)); + const statHolder = new Utils.NumberHolder( + Math.floor((2 * baseStats[s] + this.ivs[s]) * this.level * 0.01), + ); if (s === Stat.HP) { statHolder.value = statHolder.value + this.level + 10; - globalScene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder); + globalScene.applyModifier( + PokemonIncrementingStatModifier, + this.isPlayer(), + this, + s, + statHolder, + ); if (this.hasAbility(Abilities.WONDER_GUARD, false, true)) { statHolder.value = 1; } @@ -1091,15 +1549,37 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } else { statHolder.value += 5; - const natureStatMultiplier = new Utils.NumberHolder(getNatureStatMultiplier(this.getNature(), s)); - globalScene.applyModifier(PokemonNatureWeightModifier, this.isPlayer(), this, natureStatMultiplier); + const natureStatMultiplier = new Utils.NumberHolder( + getNatureStatMultiplier(this.getNature(), s), + ); + globalScene.applyModifier( + PokemonNatureWeightModifier, + this.isPlayer(), + this, + natureStatMultiplier, + ); if (natureStatMultiplier.value !== 1) { - statHolder.value = Math.max(Math[natureStatMultiplier.value > 1 ? "ceil" : "floor"](statHolder.value * natureStatMultiplier.value), 1); + statHolder.value = Math.max( + Math[natureStatMultiplier.value > 1 ? "ceil" : "floor"]( + statHolder.value * natureStatMultiplier.value, + ), + 1, + ); } - globalScene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder); + globalScene.applyModifier( + PokemonIncrementingStatModifier, + this.isPlayer(), + this, + s, + statHolder, + ); } - statHolder.value = Phaser.Math.Clamp(statHolder.value, 1, Number.MAX_SAFE_INTEGER); + statHolder.value = Phaser.Math.Clamp( + statHolder.value, + 1, + Number.MAX_SAFE_INTEGER, + ); this.setStat(s, statHolder.value); } @@ -1107,14 +1587,34 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { calculateBaseStats(): number[] { const baseStats = this.getSpeciesForm(true).baseStats.slice(0); - applyChallenges(globalScene.gameMode, ChallengeType.FLIP_STAT, this, baseStats); + applyChallenges( + globalScene.gameMode, + ChallengeType.FLIP_STAT, + this, + baseStats, + ); // Shuckle Juice - globalScene.applyModifiers(PokemonBaseStatTotalModifier, this.isPlayer(), this, baseStats); + globalScene.applyModifiers( + PokemonBaseStatTotalModifier, + this.isPlayer(), + this, + baseStats, + ); // Old Gateau - globalScene.applyModifiers(PokemonBaseStatFlatModifier, this.isPlayer(), this, baseStats); + globalScene.applyModifiers( + PokemonBaseStatFlatModifier, + this.isPlayer(), + this, + baseStats, + ); if (this.isFusion()) { const fusionBaseStats = this.getFusionSpeciesForm(true).baseStats; - applyChallenges(globalScene.gameMode, ChallengeType.FLIP_STAT, this, fusionBaseStats); + applyChallenges( + globalScene.gameMode, + ChallengeType.FLIP_STAT, + this, + fusionBaseStats, + ); for (const s of PERMANENT_STATS) { baseStats[s] = Math.ceil((baseStats[s] + fusionBaseStats[s]) / 2); @@ -1125,13 +1625,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } // Vitamins - globalScene.applyModifiers(BaseStatModifier, this.isPlayer(), this, baseStats); + globalScene.applyModifiers( + BaseStatModifier, + this.isPlayer(), + this, + baseStats, + ); return baseStats; } getNature(): Nature { - return this.customPokemonData.nature !== -1 ? this.customPokemonData.nature : this.nature; + return this.customPokemonData.nature !== -1 + ? this.customPokemonData.nature + : this.nature; } setNature(nature: Nature): void { @@ -1165,7 +1672,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.getMaxHp() - this.hp; } - getHpRatio(precise: boolean = false): number { + getHpRatio(precise = false): number { return precise ? this.hp / this.getMaxHp() : Math.round((this.hp / this.getMaxHp()) * 100) / 100; @@ -1203,7 +1710,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } getVariant(): Variant { - return !this.isFusion() ? this.variant : Math.max(this.variant, this.fusionVariant) as Variant; + return !this.isFusion() + ? this.variant + : (Math.max(this.variant, this.fusionVariant) as Variant); } getLuck(): number { @@ -1231,7 +1740,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ hasSpecies(species: Species, formKey?: string): boolean { if (Utils.isNullOrUndefined(formKey)) { - return this.species.speciesId === species || this.fusionSpecies?.speciesId === species; + return ( + this.species.speciesId === species || + this.fusionSpecies?.speciesId === species + ); } return (this.species.speciesId === species && this.getFormKey() === formKey) || (this.fusionSpecies?.speciesId === species && this.getFusionFormKey() === formKey); @@ -1240,14 +1752,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { abstract isBoss(): boolean; getMoveset(ignoreOverride?: boolean): (PokemonMove | null)[] { - const ret = !ignoreOverride && this.summonData?.moveset - ? this.summonData.moveset - : this.moveset; + const ret = + !ignoreOverride && this.summonData?.moveset + ? this.summonData.moveset + : this.moveset; // Overrides moveset based on arrays specified in overrides.ts - let overrideArray: Moves | Array = this.isPlayer() ? Overrides.MOVESET_OVERRIDE : Overrides.OPP_MOVESET_OVERRIDE; + let overrideArray: Moves | Array = this.isPlayer() + ? Overrides.MOVESET_OVERRIDE + : Overrides.OPP_MOVESET_OVERRIDE; if (!Array.isArray(overrideArray)) { - overrideArray = [ overrideArray ]; + overrideArray = [overrideArray]; } if (overrideArray.length > 0) { if (!this.isPlayer()) { @@ -1255,7 +1770,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } overrideArray.forEach((move: Moves, index: number) => { const ppUsed = this.moveset[index]?.ppUsed ?? 0; - this.moveset[index] = new PokemonMove(move, Math.min(ppUsed, allMoves[move].pp)); + this.moveset[index] = new PokemonMove( + move, + Math.min(ppUsed, allMoves[move].pp), + ); }); } @@ -1271,7 +1789,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ getUnlockedEggMoves(): Moves[] { const moves: Moves[] = []; - const species = this.metSpecies in speciesEggMoves ? this.metSpecies : this.getSpeciesForm(true).getRootSpeciesId(true); + const species = + this.metSpecies in speciesEggMoves + ? this.metSpecies + : this.getSpeciesForm(true).getRootSpeciesId(true); if (species in speciesEggMoves) { for (let i = 0; i < 4; i++) { if (globalScene.gameData.starterData[species].eggMoves & (1 << i)) { @@ -1293,13 +1814,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ public getLearnableLevelMoves(): Moves[] { let levelMoves = this.getLevelMoves(1, true, false, true).map(lm => lm[1]); - if (this.metBiome === -1 && !globalScene.gameMode.isFreshStartChallenge() && !globalScene.gameMode.isDaily) { + if ( + this.metBiome === -1 && + !globalScene.gameMode.isFreshStartChallenge() && + !globalScene.gameMode.isDaily + ) { levelMoves = this.getUnlockedEggMoves().concat(levelMoves); } if (Array.isArray(this.usedTMs) && this.usedTMs.length > 0) { - levelMoves = this.usedTMs.filter(m => !levelMoves.includes(m)).concat(levelMoves); + levelMoves = this.usedTMs + .filter(m => !levelMoves.includes(m)) + .concat(levelMoves); } - levelMoves = levelMoves.filter(lm => !this.moveset.some(m => m?.moveId === lm)); + levelMoves = levelMoves.filter( + lm => !this.moveset.some(m => m?.moveId === lm), + ); return levelMoves; } @@ -1310,12 +1839,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false` * @returns array of {@linkcode PokemonType} */ - public getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride: boolean = false): PokemonType[] { + public getTypes( + includeTeraType = false, + forDefend = false, + ignoreOverride = false, + ): PokemonType[] { const types: PokemonType[] = []; if (includeTeraType && this.isTerastallized) { const teraType = this.getTeraType(); - if (this.isTerastallized && !(forDefend && teraType === PokemonType.STELLAR)) { // Stellar tera uses its original types defensively + if (this.isTerastallized && !(forDefend && teraType === PokemonType.STELLAR)) { + // Stellar tera uses its original types defensively types.push(teraType); if (forDefend) { return types; @@ -1324,7 +1858,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (!types.length || !includeTeraType) { - if (!ignoreOverride && this.summonData?.types && this.summonData.types.length > 0) { + if ( + !ignoreOverride && + this.summonData?.types && + this.summonData.types.length > 0 + ) { this.summonData.types.forEach(t => types.push(t)); } else { const speciesForm = this.getSpeciesForm(ignoreOverride); @@ -1332,7 +1870,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const customTypes = this.customPokemonData.types?.length > 0; // First type, checking for "permanently changed" types from ME - const firstType = (customTypes && this.customPokemonData.types[0] !== PokemonType.UNKNOWN) ? this.customPokemonData.types[0] : speciesForm.type1; + const firstType = + customTypes && this.customPokemonData.types[0] !== PokemonType.UNKNOWN + ? this.customPokemonData.types[0] + : speciesForm.type1; types.push(firstType); // Second type @@ -1340,10 +1881,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (fusionSpeciesForm) { // Check if the fusion Pokemon also has permanent changes from ME when determining the fusion types - const fusionType1 = (this.fusionCustomPokemonData?.types && this.fusionCustomPokemonData.types.length > 0 && this.fusionCustomPokemonData.types[0] !== PokemonType.UNKNOWN) - ? this.fusionCustomPokemonData.types[0] : fusionSpeciesForm.type1; - const fusionType2 = (this.fusionCustomPokemonData?.types && this.fusionCustomPokemonData.types.length > 1 && this.fusionCustomPokemonData.types[1] !== PokemonType.UNKNOWN) - ? this.fusionCustomPokemonData.types[1] : fusionSpeciesForm.type2; + const fusionType1 = + this.fusionCustomPokemonData?.types && + this.fusionCustomPokemonData.types.length > 0 && + this.fusionCustomPokemonData.types[0] !== PokemonType.UNKNOWN + ? this.fusionCustomPokemonData.types[0] + : fusionSpeciesForm.type1; + const fusionType2 = + this.fusionCustomPokemonData?.types && + this.fusionCustomPokemonData.types.length > 1 && + this.fusionCustomPokemonData.types[1] !== PokemonType.UNKNOWN + ? this.fusionCustomPokemonData.types[1] + : fusionSpeciesForm.type2; // Assign second type if the fusion can provide one if (fusionType2 !== null && fusionType2 !== types[0]) { @@ -1352,15 +1901,26 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { secondType = fusionType1; } - - if (secondType === PokemonType.UNKNOWN && Utils.isNullOrUndefined(fusionType2)) { // If second pokemon was monotype and shared its primary type - secondType = (customTypes && this.customPokemonData.types.length > 1 && this.customPokemonData.types[1] !== PokemonType.UNKNOWN) - ? this.customPokemonData.types[1] : (speciesForm.type2 ?? PokemonType.UNKNOWN); + if ( + secondType === PokemonType.UNKNOWN && + Utils.isNullOrUndefined(fusionType2) + ) { + // If second pokemon was monotype and shared its primary type + secondType = + customTypes && + this.customPokemonData.types.length > 1 && + this.customPokemonData.types[1] !== PokemonType.UNKNOWN + ? this.customPokemonData.types[1] + : (speciesForm.type2 ?? PokemonType.UNKNOWN); } } else { // If not a fusion, just get the second type from the species, checking for permanent changes from ME - secondType = (customTypes && this.customPokemonData.types.length > 1 && this.customPokemonData.types[1] !== PokemonType.UNKNOWN) - ? this.customPokemonData.types[1] : (speciesForm.type2 ?? PokemonType.UNKNOWN); + secondType = + customTypes && + this.customPokemonData.types.length > 1 && + this.customPokemonData.types[1] !== PokemonType.UNKNOWN + ? this.customPokemonData.types[1] + : (speciesForm.type2 ?? PokemonType.UNKNOWN); } if (secondType !== PokemonType.UNKNOWN) { @@ -1383,7 +1943,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } // the type added to Pokemon from moves like Forest's Curse or Trick Or Treat - if (!ignoreOverride && this.summonData && this.summonData.addedType && !types.includes(this.summonData.addedType)) { + if ( + !ignoreOverride && + this.summonData && + this.summonData.addedType && + !types.includes(this.summonData.addedType) + ) { types.push(this.summonData.addedType); } @@ -1403,8 +1968,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false` * @returns `true` if the Pokemon's type matches */ - public isOfType(type: PokemonType, includeTeraType: boolean = true, forDefend: boolean = false, ignoreOverride: boolean = false): boolean { - return this.getTypes(includeTeraType, forDefend, ignoreOverride).some((t) => t === type); + public isOfType( + type: PokemonType, + includeTeraType = true, + forDefend = false, + ignoreOverride = false, + ): boolean { + return this.getTypes(includeTeraType, forDefend, ignoreOverride).some( + t => t === type, + ); } /** @@ -1415,7 +1987,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride - If `true`, ignore ability changing effects; Default: `false` * @returns The non-passive {@linkcode Ability} of the pokemon */ - public getAbility(ignoreOverride: boolean = false): Ability { + public getAbility(ignoreOverride = false): Ability { if (!ignoreOverride && this.summonData?.ability) { return allAbilities[this.summonData.ability]; } @@ -1426,16 +1998,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return allAbilities[Overrides.OPP_ABILITY_OVERRIDE]; } if (this.isFusion()) { - if (!isNullOrUndefined(this.fusionCustomPokemonData?.ability) && this.fusionCustomPokemonData.ability !== -1) { + if ( + !isNullOrUndefined(this.fusionCustomPokemonData?.ability) && + this.fusionCustomPokemonData.ability !== -1 + ) { return allAbilities[this.fusionCustomPokemonData.ability]; - } else { - return allAbilities[this.getFusionSpeciesForm(ignoreOverride).getAbility(this.fusionAbilityIndex)]; } + return allAbilities[ + this.getFusionSpeciesForm(ignoreOverride).getAbility( + this.fusionAbilityIndex, + ) + ]; } - if (!isNullOrUndefined(this.customPokemonData.ability) && this.customPokemonData.ability !== -1) { + if ( + !isNullOrUndefined(this.customPokemonData.ability) && + this.customPokemonData.ability !== -1 + ) { return allAbilities[this.customPokemonData.ability]; } - let abilityId = this.getSpeciesForm(ignoreOverride).getAbility(this.abilityIndex); + let abilityId = this.getSpeciesForm(ignoreOverride).getAbility( + this.abilityIndex, + ); if (abilityId === Abilities.NONE) { abilityId = this.species.ability1; } @@ -1456,7 +2039,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (Overrides.OPP_PASSIVE_ABILITY_OVERRIDE && !this.isPlayer()) { return allAbilities[Overrides.OPP_PASSIVE_ABILITY_OVERRIDE]; } - if (!isNullOrUndefined(this.customPokemonData.passive) && this.customPokemonData.passive !== -1) { + if ( + !isNullOrUndefined(this.customPokemonData.passive) && + this.customPokemonData.passive !== -1 + ) { return allAbilities[this.customPokemonData.passive]; } @@ -1472,11 +2058,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride - If `true`, it ignores ability changing effects; Default `false` * @returns An array of all the ability attributes on this ability. */ - public getAbilityAttrs(attrType: { new(...args: any[]): T }, canApply: boolean = true, ignoreOverride: boolean = false): T[] { + public getAbilityAttrs( + attrType: { new (...args: any[]): T }, + canApply = true, + ignoreOverride = false, + ): T[] { const abilityAttrs: T[] = []; if (!canApply || this.canApplyAbility()) { - abilityAttrs.push(...this.getAbility(ignoreOverride).getAttrs(attrType)); + abilityAttrs.push( + ...this.getAbility(ignoreOverride).getAttrs(attrType), + ); } if (!canApply || this.canApplyAbility(true)) { @@ -1492,7 +2084,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Also clears primal weather if it is from the ability being changed * @param ability New Ability */ - public setTempAbility(ability: Ability, passive: boolean = false): void { + public setTempAbility(ability: Ability, passive = false): void { applyOnLoseAbAttrs(this, passive); if (passive) { this.summonData.passiveAbility = ability.id; @@ -1506,7 +2098,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Suppresses an ability and calls its onlose attributes */ public suppressAbility() { - [ true, false ].forEach((passive) => applyOnLoseAbAttrs(this, passive)); + [true, false].forEach(passive => applyOnLoseAbAttrs(this, passive)); this.summonData.abilitySuppressed = true; } @@ -1520,14 +2112,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public hasPassive(): boolean { // returns override if valid for current case if ( - (Overrides.HAS_PASSIVE_ABILITY_OVERRIDE === false && this.isPlayer()) - || (Overrides.OPP_HAS_PASSIVE_ABILITY_OVERRIDE === false && !this.isPlayer()) + (Overrides.HAS_PASSIVE_ABILITY_OVERRIDE === false && this.isPlayer()) || + (Overrides.OPP_HAS_PASSIVE_ABILITY_OVERRIDE === false && !this.isPlayer()) ) { return false; } if ( - ((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || Overrides.HAS_PASSIVE_ABILITY_OVERRIDE) && this.isPlayer()) - || ((Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || Overrides.OPP_HAS_PASSIVE_ABILITY_OVERRIDE) && !this.isPlayer()) + ((Overrides.PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || + Overrides.HAS_PASSIVE_ABILITY_OVERRIDE) && + this.isPlayer()) || + ((Overrides.OPP_PASSIVE_ABILITY_OVERRIDE !== Abilities.NONE || + Overrides.OPP_HAS_PASSIVE_ABILITY_OVERRIDE) && + !this.isPlayer()) ) { return true; } @@ -1535,10 +2131,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Classic Final boss and Endless Minor/Major bosses do not have passive const { currentBattle, gameMode } = globalScene; const waveIndex = currentBattle?.waveIndex; - if (this instanceof EnemyPokemon && + if ( + this instanceof EnemyPokemon && (currentBattle?.battleSpec === BattleSpec.FINAL_BOSS || - gameMode.isEndlessMinorBoss(waveIndex) || - gameMode.isEndlessMajorBoss(waveIndex))) { + gameMode.isEndlessMinorBoss(waveIndex) || + gameMode.isEndlessMajorBoss(waveIndex)) + ) { return false; } @@ -1552,34 +2150,58 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param passive If true, check if passive can be applied instead of non-passive * @returns `true` if the ability can be applied */ - public canApplyAbility(passive: boolean = false): boolean { + public canApplyAbility(passive = false): boolean { if (passive && !this.hasPassive()) { return false; } - const ability = (!passive ? this.getAbility() : this.getPassiveAbility()); + const ability = !passive ? this.getAbility() : this.getPassiveAbility(); if (this.isFusion() && ability.hasAttr(NoFusionAbilityAbAttr)) { return false; } const arena = globalScene?.arena; - if (arena.ignoreAbilities && arena.ignoringEffectSource !== this.getBattlerIndex() && ability.isIgnorable) { + if ( + arena.ignoreAbilities && + arena.ignoringEffectSource !== this.getBattlerIndex() && + ability.isIgnorable + ) { return false; } - if (this.summonData?.abilitySuppressed && !ability.hasAttr(UnsuppressableAbilityAbAttr)) { + if ( + this.summonData?.abilitySuppressed && + !ability.hasAttr(UnsuppressableAbilityAbAttr) + ) { return false; } - const suppressAbilitiesTag = arena.getTag(ArenaTagType.NEUTRALIZING_GAS) as SuppressAbilitiesTag; - if (this.isOnField() && suppressAbilitiesTag && !suppressAbilitiesTag.isBeingRemoved()) { - const thisAbilitySuppressing = ability.hasAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr); - const hasSuppressingAbility = this.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false); + const suppressAbilitiesTag = arena.getTag( + ArenaTagType.NEUTRALIZING_GAS, + ) as SuppressAbilitiesTag; + if ( + this.isOnField() && + suppressAbilitiesTag && + !suppressAbilitiesTag.isBeingRemoved() + ) { + const thisAbilitySuppressing = ability.hasAttr( + PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, + ); + const hasSuppressingAbility = this.hasAbilityWithAttr( + PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, + false, + ); // Neutralizing gas is up - suppress abilities unless they are unsuppressable or this pokemon is responsible for the gas // (Balance decided that the other ability of a neutralizing gas pokemon should not be neutralized) // If the ability itself is neutralizing gas, don't suppress it (handled through arena tag) - const unsuppressable = ability.hasAttr(UnsuppressableAbilityAbAttr) || thisAbilitySuppressing || (hasSuppressingAbility && !suppressAbilitiesTag.shouldApplyToSelf()); + const unsuppressable = + ability.hasAttr(UnsuppressableAbilityAbAttr) || + thisAbilitySuppressing || + (hasSuppressingAbility && !suppressAbilitiesTag.shouldApplyToSelf()); if (!unsuppressable) { return false; } } - return (this.hp > 0 || ability.isBypassFaint) && !ability.conditions.find(condition => !condition(this)); + return ( + (this.hp > 0 || ability.isBypassFaint) && + !ability.conditions.find(condition => !condition(this)) + ); } /** @@ -1591,11 +2213,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param {boolean} ignoreOverride If true, it ignores ability changing effects * @returns {boolean} Whether the ability is present and active */ - public hasAbility(ability: Abilities, canApply: boolean = true, ignoreOverride?: boolean): boolean { - if (this.getAbility(ignoreOverride).id === ability && (!canApply || this.canApplyAbility())) { + public hasAbility( + ability: Abilities, + canApply = true, + ignoreOverride?: boolean, + ): boolean { + if ( + this.getAbility(ignoreOverride).id === ability && + (!canApply || this.canApplyAbility()) + ) { return true; } - if (this.getPassiveAbility().id === ability && this.hasPassive() && (!canApply || this.canApplyAbility(true))) { + if ( + this.getPassiveAbility().id === ability && + this.hasPassive() && + (!canApply || this.canApplyAbility(true)) + ) { return true; } return false; @@ -1611,11 +2244,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param {boolean} ignoreOverride If true, it ignores ability changing effects * @returns {boolean} Whether an ability with that attribute is present and active */ - public hasAbilityWithAttr(attrType: Constructor, canApply: boolean = true, ignoreOverride?: boolean): boolean { - if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType)) { + public hasAbilityWithAttr( + attrType: Constructor, + canApply = true, + ignoreOverride?: boolean, + ): boolean { + if ( + (!canApply || this.canApplyAbility()) && + this.getAbility(ignoreOverride).hasAttr(attrType) + ) { return true; } - if (this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().hasAttr(attrType)) { + if ( + this.hasPassive() && + (!canApply || this.canApplyAbility(true)) && + this.getPassiveAbility().hasAttr(attrType) + ) { return true; } return false; @@ -1646,8 +2290,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getTeraType(): PokemonType { if (this.hasSpecies(Species.TERAPAGOS)) { return PokemonType.STELLAR; - } else if (this.hasSpecies(Species.OGERPON)) { - const ogerponForm = this.species.speciesId === Species.OGERPON ? this.formIndex : this.fusionFormIndex; + } + if (this.hasSpecies(Species.OGERPON)) { + const ogerponForm = + this.species.speciesId === Species.OGERPON + ? this.formIndex + : this.fusionFormIndex; switch (ogerponForm) { case 0: case 4: @@ -1662,14 +2310,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { case 7: return PokemonType.ROCK; } - } else if (this.hasSpecies(Species.SHEDINJA)) { + } + if (this.hasSpecies(Species.SHEDINJA)) { return PokemonType.BUG; } return this.teraType; } public isGrounded(): boolean { - return !!this.getTag(GroundedTag) || (!this.isOfType(PokemonType.FLYING, true, true) && !this.hasAbility(Abilities.LEVITATE) && !this.getTag(BattlerTagType.FLOATING) && !this.getTag(SemiInvulnerableTag)); + return ( + !!this.getTag(GroundedTag) || + (!this.isOfType(PokemonType.FLYING, true, true) && + !this.hasAbility(Abilities.LEVITATE) && + !this.getTag(BattlerTagType.FLOATING) && + !this.getTag(SemiInvulnerableTag)) + ); } /** @@ -1680,7 +2335,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param simulated - If `true`, applies abilities via simulated calls. * @returns `true` if the pokemon is trapped */ - public isTrapped(trappedAbMessages: string[] = [], simulated: boolean = true): boolean { + public isTrapped( + trappedAbMessages: string[] = [], + simulated = true, + ): boolean { const commandedTag = this.getTag(BattlerTagType.COMMANDED); if (commandedTag?.getSourcePokemon()?.isActive(true)) { return true; @@ -1695,15 +2353,30 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Contains opposing Pokemon (Enemy/Player Pokemon) depending on perspective * Afterwards, it filters out Pokemon that have been switched out of the field so trapped abilities/moves do not trigger */ - const opposingFieldUnfiltered = this.isPlayer() ? globalScene.getEnemyField() : globalScene.getPlayerField(); - const opposingField = opposingFieldUnfiltered.filter(enemyPkm => enemyPkm.switchOutStatus === false); - - opposingField.forEach((opponent) => - applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated) + const opposingFieldUnfiltered = this.isPlayer() + ? globalScene.getEnemyField() + : globalScene.getPlayerField(); + const opposingField = opposingFieldUnfiltered.filter( + enemyPkm => enemyPkm.switchOutStatus === false, ); + for (const opponent of opposingField) { + applyCheckTrappedAbAttrs( + CheckTrappedAbAttr, + opponent, + trappedByAbility, + this, + trappedAbMessages, + simulated, + ); + } + const side = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; - return (trappedByAbility.value || !!this.getTag(TrappedTag) || !!globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, side)); + return ( + trappedByAbility.value || + !!this.getTag(TrappedTag) || + !!globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, side) + ); } /** @@ -1713,13 +2386,24 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param simulated - If `true`, prevents showing abilities applied in this calculation. * @returns The {@linkcode PokemonType} of the move after attributes are applied */ - public getMoveType(move: Move, simulated: boolean = true): PokemonType { + public getMoveType(move: Move, simulated = true): PokemonType { const moveTypeHolder = new Utils.NumberHolder(move.type); applyMoveAttrs(VariableMoveTypeAttr, this, null, move, moveTypeHolder); - applyPreAttackAbAttrs(MoveTypeChangeAbAttr, this, null, move, simulated, moveTypeHolder); + applyPreAttackAbAttrs( + MoveTypeChangeAbAttr, + this, + null, + move, + simulated, + moveTypeHolder, + ); - globalScene.arena.applyTags(ArenaTagType.ION_DELUGE, simulated, moveTypeHolder); + globalScene.arena.applyTags( + ArenaTagType.ION_DELUGE, + simulated, + moveTypeHolder, + ); if (this.getTag(BattlerTagType.ELECTRIFIED)) { moveTypeHolder.value = PokemonType.ELECTRIC; } @@ -1727,7 +2411,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return moveTypeHolder.value as PokemonType; } - /** * Calculates the effectiveness of a move against the Pokémon. * This includes modifiers from move and ability attributes. @@ -1739,7 +2422,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Currently only used by {@linkcode Pokemon.apply} to determine whether a "No effect" message should be shown. * @returns The type damage multiplier, indicating the effectiveness of the move */ - getMoveEffectiveness(source: Pokemon, move: Move, ignoreAbility: boolean = false, simulated: boolean = true, cancelled?: Utils.BooleanHolder): TypeDamageMultiplier { + getMoveEffectiveness( + source: Pokemon, + move: Move, + ignoreAbility = false, + simulated = true, + cancelled?: Utils.BooleanHolder, + ): TypeDamageMultiplier { if (!Utils.isNullOrUndefined(this.turnData?.moveEffectiveness)) { return this.turnData?.moveEffectiveness; } @@ -1749,36 +2438,84 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } const moveType = source.getMoveType(move); - const typeMultiplier = new Utils.NumberHolder((move.category !== MoveCategory.STATUS || move.hasAttr(RespectAttackTypeImmunityAttr)) - ? this.getAttackTypeEffectiveness(moveType, source, false, simulated, move) - : 1); + const typeMultiplier = new Utils.NumberHolder( + move.category !== MoveCategory.STATUS || + move.hasAttr(RespectAttackTypeImmunityAttr) + ? this.getAttackTypeEffectiveness( + moveType, + source, + false, + simulated, + move, + ) + : 1, + ); - applyMoveAttrs(VariableMoveTypeMultiplierAttr, source, this, move, typeMultiplier); - if (this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t))) { + applyMoveAttrs( + VariableMoveTypeMultiplierAttr, + source, + this, + move, + typeMultiplier, + ); + if ( + this.getTypes(true, true).find(t => move.isTypeImmune(source, this, t)) + ) { typeMultiplier.value = 0; } - if (this.getTag(TarShotTag) && (this.getMoveType(move) === PokemonType.FIRE)) { + if (this.getTag(TarShotTag) && this.getMoveType(move) === PokemonType.FIRE) { typeMultiplier.value *= 2; } const cancelledHolder = cancelled ?? new Utils.BooleanHolder(false); if (!ignoreAbility) { - applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs( + TypeImmunityAbAttr, + this, + source, + move, + cancelledHolder, + simulated, + typeMultiplier, + ); if (!cancelledHolder.value) { - applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs( + MoveImmunityAbAttr, + this, + source, + move, + cancelledHolder, + simulated, + typeMultiplier, + ); } if (!cancelledHolder.value) { - const defendingSidePlayField = this.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); - defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelledHolder)); + const defendingSidePlayField = this.isPlayer() + ? globalScene.getPlayerField() + : globalScene.getEnemyField(); + defendingSidePlayField.forEach(p => + applyPreDefendAbAttrs( + FieldPriorityMoveImmunityAbAttr, + p, + source, + move, + cancelledHolder, + ), + ); } } - const immuneTags = this.findTags(tag => tag instanceof TypeImmuneTag && tag.immuneType === moveType); + const immuneTags = this.findTags( + tag => tag instanceof TypeImmuneTag && tag.immuneType === moveType, + ); for (const tag of immuneTags) { - if (move && !move.getAttrs(HitsTagAttr).some(attr => attr.tagType === tag.tagType)) { + if ( + move && + !move.getAttrs(HitsTagAttr).some(attr => attr.tagType === tag.tagType) + ) { typeMultiplier.value = 0; break; } @@ -1786,14 +2523,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Apply Tera Shell's effect to attacks after all immunities are accounted for if (!ignoreAbility && move.category !== MoveCategory.STATUS) { - applyPreDefendAbAttrs(FullHpResistTypeAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs( + FullHpResistTypeAbAttr, + this, + source, + move, + cancelledHolder, + simulated, + typeMultiplier, + ); } - if (move.category === MoveCategory.STATUS && move.hitsSubstitute(source, this)) { + if ( + move.category === MoveCategory.STATUS && + move.hitsSubstitute(source, this) + ) { typeMultiplier.value = 0; } - return (!cancelledHolder.value ? typeMultiplier.value : 0) as TypeDamageMultiplier; + return ( + !cancelledHolder.value ? typeMultiplier.value : 0 + ) as TypeDamageMultiplier; } /** @@ -1805,7 +2555,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param move (optional) the move whose type effectiveness is to be checked. Used for applying {@linkcode VariableMoveTypeChartAttr} * @returns a multiplier for the type effectiveness */ - getAttackTypeEffectiveness(moveType: PokemonType, source?: Pokemon, ignoreStrongWinds: boolean = false, simulated: boolean = true, move?: Move): TypeDamageMultiplier { + getAttackTypeEffectiveness( + moveType: PokemonType, + source?: Pokemon, + ignoreStrongWinds = false, + simulated = true, + move?: Move, + ): TypeDamageMultiplier { if (moveType === PokemonType.STELLAR) { return this.isTerastallized ? 2 : 1; } @@ -1814,44 +2570,86 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Handle flying v ground type immunity without removing flying type so effective types are still effective // Related to https://github.com/pagefaultgames/pokerogue/issues/524 - if (moveType === PokemonType.GROUND && (this.isGrounded() || arena.hasTag(ArenaTagType.GRAVITY))) { + if ( + moveType === PokemonType.GROUND && + (this.isGrounded() || arena.hasTag(ArenaTagType.GRAVITY)) + ) { const flyingIndex = types.indexOf(PokemonType.FLYING); if (flyingIndex > -1) { types.splice(flyingIndex, 1); } } - let multiplier = types.map(defType => { - const multiplier = new Utils.NumberHolder(getTypeDamageMultiplier(moveType, defType)); - applyChallenges(globalScene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, multiplier); - if (move) { - applyMoveAttrs(VariableMoveTypeChartAttr, null, this, move, multiplier, defType); - } - if (source) { - const ignoreImmunity = new Utils.BooleanHolder(false); - if (source.isActive(true) && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) { - applyAbAttrs(IgnoreTypeImmunityAbAttr, source, ignoreImmunity, simulated, moveType, defType); + let multiplier = types + .map(defType => { + const multiplier = new Utils.NumberHolder( + getTypeDamageMultiplier(moveType, defType), + ); + applyChallenges( + globalScene.gameMode, + ChallengeType.TYPE_EFFECTIVENESS, + multiplier, + ); + if (move) { + applyMoveAttrs( + VariableMoveTypeChartAttr, + null, + this, + move, + multiplier, + defType, + ); } - if (ignoreImmunity.value) { - if (multiplier.value === 0) { - return 1; + if (source) { + const ignoreImmunity = new Utils.BooleanHolder(false); + if ( + source.isActive(true) && + source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr) + ) { + applyAbAttrs( + IgnoreTypeImmunityAbAttr, + source, + ignoreImmunity, + simulated, + moveType, + defType, + ); + } + if (ignoreImmunity.value) { + if (multiplier.value === 0) { + return 1; + } + } + + const exposedTags = this.findTags( + tag => tag instanceof ExposedTag, + ) as ExposedTag[]; + if (exposedTags.some(t => t.ignoreImmunity(defType, moveType))) { + if (multiplier.value === 0) { + return 1; + } } } + return multiplier.value; + }) + .reduce((acc, cur) => acc * cur, 1) as TypeDamageMultiplier; - const exposedTags = this.findTags(tag => tag instanceof ExposedTag) as ExposedTag[]; - if (exposedTags.some(t => t.ignoreImmunity(defType, moveType))) { - if (multiplier.value === 0) { - return 1; - } - } - } - return multiplier.value; - }).reduce((acc, cur) => acc * cur, 1) as TypeDamageMultiplier; - - const typeMultiplierAgainstFlying = new Utils.NumberHolder(getTypeDamageMultiplier(moveType, PokemonType.FLYING)); - applyChallenges(globalScene.gameMode, ChallengeType.TYPE_EFFECTIVENESS, typeMultiplierAgainstFlying); + const typeMultiplierAgainstFlying = new Utils.NumberHolder( + getTypeDamageMultiplier(moveType, PokemonType.FLYING), + ); + applyChallenges( + globalScene.gameMode, + ChallengeType.TYPE_EFFECTIVENESS, + typeMultiplierAgainstFlying, + ); // Handle strong winds lowering effectiveness of types super effective against pure flying - if (!ignoreStrongWinds && arena.weather?.weatherType === WeatherType.STRONG_WINDS && !arena.weather.isEffectSuppressed() && this.isOfType(PokemonType.FLYING) && typeMultiplierAgainstFlying.value === 2) { + if ( + !ignoreStrongWinds && + arena.weather?.weatherType === WeatherType.STRONG_WINDS && + !arena.weather.isEffectSuppressed() && + this.isOfType(PokemonType.FLYING) && + typeMultiplierAgainstFlying.value === 2 + ) { multiplier /= 2; if (!simulated) { globalScene.queueMessage(i18next.t("weather:strongWindsEffectMessage")); @@ -1870,22 +2668,35 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const types = this.getTypes(true); const enemyTypes = opponent.getTypes(true, true); /** Is this Pokemon faster than the opponent? */ - const outspeed = (this.isActive(true) ? this.getEffectiveStat(Stat.SPD, opponent) : this.getStat(Stat.SPD, false)) >= opponent.getEffectiveStat(Stat.SPD, this); + const outspeed = + (this.isActive(true) + ? this.getEffectiveStat(Stat.SPD, opponent) + : this.getStat(Stat.SPD, false)) >= + opponent.getEffectiveStat(Stat.SPD, this); /** * Based on how effective this Pokemon's types are offensively against the opponent's types. * This score is increased by 25 percent if this Pokemon is faster than the opponent. */ - let atkScore = opponent.getAttackTypeEffectiveness(types[0], this) * (outspeed ? 1.25 : 1); + let atkScore = + opponent.getAttackTypeEffectiveness(types[0], this) * + (outspeed ? 1.25 : 1); /** * Based on how effectively this Pokemon defends against the opponent's types. * This score cannot be higher than 4. */ - let defScore = 1 / Math.max(this.getAttackTypeEffectiveness(enemyTypes[0], opponent), 0.25); + let defScore = + 1 / + Math.max(this.getAttackTypeEffectiveness(enemyTypes[0], opponent), 0.25); if (types.length > 1) { atkScore *= opponent.getAttackTypeEffectiveness(types[1], this); } if (enemyTypes.length > 1) { - defScore *= (1 / Math.max(this.getAttackTypeEffectiveness(enemyTypes[1], opponent), 0.25)); + defScore *= + 1 / + Math.max( + this.getAttackTypeEffectiveness(enemyTypes[1], opponent), + 0.25, + ); } /** * Based on this Pokemon's HP ratio compared to that of the opponent. @@ -1903,19 +2714,41 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (pokemonEvolutions.hasOwnProperty(this.species.speciesId)) { const evolutions = pokemonEvolutions[this.species.speciesId]; for (const e of evolutions) { - if (!e.item && this.level >= e.level && (isNullOrUndefined(e.preFormKey) || this.getFormKey() === e.preFormKey)) { - if (e.condition === null || (e.condition as SpeciesEvolutionCondition).predicate(this)) { + if ( + !e.item && + this.level >= e.level && + (isNullOrUndefined(e.preFormKey) || + this.getFormKey() === e.preFormKey) + ) { + if ( + e.condition === null || + (e.condition as SpeciesEvolutionCondition).predicate(this) + ) { return e; } } } } - if (this.isFusion() && this.fusionSpecies && pokemonEvolutions.hasOwnProperty(this.fusionSpecies.speciesId)) { - const fusionEvolutions = pokemonEvolutions[this.fusionSpecies.speciesId].map(e => new FusionSpeciesFormEvolution(this.species.speciesId, e)); + if ( + this.isFusion() && + this.fusionSpecies && + pokemonEvolutions.hasOwnProperty(this.fusionSpecies.speciesId) + ) { + const fusionEvolutions = pokemonEvolutions[ + this.fusionSpecies.speciesId + ].map(e => new FusionSpeciesFormEvolution(this.species.speciesId, e)); for (const fe of fusionEvolutions) { - if (!fe.item && this.level >= fe.level && (isNullOrUndefined(fe.preFormKey) || this.getFusionFormKey() === fe.preFormKey)) { - if (fe.condition === null || (fe.condition as SpeciesEvolutionCondition).predicate(this)) { + if ( + !fe.item && + this.level >= fe.level && + (isNullOrUndefined(fe.preFormKey) || + this.getFusionFormKey() === fe.preFormKey) + ) { + if ( + fe.condition === null || + (fe.condition as SpeciesEvolutionCondition).predicate(this) + ) { return fe; } } @@ -1933,48 +2766,125 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param {boolean} includeRelearnerMoves Whether to include moves that would require a relearner. Note the move relearner inherently allows evolution moves * @returns {LevelMoves} A list of moves and the levels they can be learned at */ - getLevelMoves(startingLevel?: number, includeEvolutionMoves: boolean = false, simulateEvolutionChain: boolean = false, includeRelearnerMoves: boolean = false, learnSituation: LearnMoveSituation = LearnMoveSituation.MISC): LevelMoves { + getLevelMoves( + startingLevel?: number, + includeEvolutionMoves = false, + simulateEvolutionChain = false, + includeRelearnerMoves = false, + learnSituation: LearnMoveSituation = LearnMoveSituation.MISC, + ): LevelMoves { const ret: LevelMoves = []; let levelMoves: LevelMoves = []; if (!startingLevel) { startingLevel = this.level; } - if (learnSituation === LearnMoveSituation.EVOLUTION_FUSED && this.fusionSpecies) { // For fusion evolutions, get ONLY the moves of the component mon that evolved - levelMoves = this.getFusionSpeciesForm(true).getLevelMoves().filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || lm[0] > 0); + if ( + learnSituation === LearnMoveSituation.EVOLUTION_FUSED && + this.fusionSpecies + ) { + // For fusion evolutions, get ONLY the moves of the component mon that evolved + levelMoves = this.getFusionSpeciesForm(true) + .getLevelMoves() + .filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || + lm[0] > 0, + ); } else { if (simulateEvolutionChain) { - const evolutionChain = this.species.getSimulatedEvolutionChain(this.level, this.hasTrainer(), this.isBoss(), this.isPlayer()); + const evolutionChain = this.species.getSimulatedEvolutionChain( + this.level, + this.hasTrainer(), + this.isBoss(), + this.isPlayer(), + ); for (let e = 0; e < evolutionChain.length; e++) { // TODO: Might need to pass specific form index in simulated evolution chain - const speciesLevelMoves = getPokemonSpeciesForm(evolutionChain[e][0], this.formIndex).getLevelMoves(); + const speciesLevelMoves = getPokemonSpeciesForm( + evolutionChain[e][0], + this.formIndex, + ).getLevelMoves(); if (includeRelearnerMoves) { levelMoves.push(...speciesLevelMoves); } else { - levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || ((!e || lm[0] > 1) && (e === evolutionChain.length - 1 || lm[0] <= evolutionChain[e + 1][1])))); + levelMoves.push( + ...speciesLevelMoves.filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + ((!e || lm[0] > 1) && + (e === evolutionChain.length - 1 || + lm[0] <= evolutionChain[e + 1][1])), + ), + ); } } } else { - levelMoves = this.getSpeciesForm(true).getLevelMoves().filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || lm[0] > 0); + levelMoves = this.getSpeciesForm(true) + .getLevelMoves() + .filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || + lm[0] > 0, + ); } - if (this.fusionSpecies && learnSituation !== LearnMoveSituation.EVOLUTION_FUSED_BASE) { // For fusion evolutions, get ONLY the moves of the component mon that evolved + if ( + this.fusionSpecies && + learnSituation !== LearnMoveSituation.EVOLUTION_FUSED_BASE + ) { + // For fusion evolutions, get ONLY the moves of the component mon that evolved if (simulateEvolutionChain) { - const fusionEvolutionChain = this.fusionSpecies.getSimulatedEvolutionChain(this.level, this.hasTrainer(), this.isBoss(), this.isPlayer()); + const fusionEvolutionChain = + this.fusionSpecies.getSimulatedEvolutionChain( + this.level, + this.hasTrainer(), + this.isBoss(), + this.isPlayer(), + ); for (let e = 0; e < fusionEvolutionChain.length; e++) { // TODO: Might need to pass specific form index in simulated evolution chain - const speciesLevelMoves = getPokemonSpeciesForm(fusionEvolutionChain[e][0], this.fusionFormIndex).getLevelMoves(); + const speciesLevelMoves = getPokemonSpeciesForm( + fusionEvolutionChain[e][0], + this.fusionFormIndex, + ).getLevelMoves(); if (includeRelearnerMoves) { - levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || lm[0] !== EVOLVE_MOVE)); + levelMoves.push( + ...speciesLevelMoves.filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + lm[0] !== EVOLVE_MOVE, + ), + ); } else { - levelMoves.push(...speciesLevelMoves.filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || ((!e || lm[0] > 1) && (e === fusionEvolutionChain.length - 1 || lm[0] <= fusionEvolutionChain[e + 1][1])))); + levelMoves.push( + ...speciesLevelMoves.filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + ((!e || lm[0] > 1) && + (e === fusionEvolutionChain.length - 1 || + lm[0] <= fusionEvolutionChain[e + 1][1])), + ), + ); } } } else { - levelMoves.push(...this.getFusionSpeciesForm(true).getLevelMoves().filter(lm => (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || lm[0] > 0)); + levelMoves.push( + ...this.getFusionSpeciesForm(true) + .getLevelMoves() + .filter( + lm => + (includeEvolutionMoves && lm[0] === EVOLVE_MOVE) || + (includeRelearnerMoves && lm[0] === RELEARN_MOVE) || + lm[0] > 0, + ), + ); } } } - levelMoves.sort((lma: [number, number], lmb: [number, number]) => lma[0] > lmb[0] ? 1 : lma[0] < lmb[0] ? -1 : 0); - + levelMoves.sort((lma: [number, number], lmb: [number, number]) => + lma[0] > lmb[0] ? 1 : lma[0] < lmb[0] ? -1 : 0, + ); /** * Filter out moves not within the correct level range(s) @@ -1984,10 +2894,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { levelMoves = levelMoves.filter(lm => { const level = lm[0]; const isRelearner = level < startingLevel; - const allowedEvolutionMove = (level === 0) && includeEvolutionMoves; + const allowedEvolutionMove = level === 0 && includeEvolutionMoves; - return !(level > this.level) - && (includeRelearnerMoves || !isRelearner || allowedEvolutionMove); + return ( + !(level > this.level) && + (includeRelearnerMoves || !isRelearner || allowedEvolutionMove) + ); }); /** @@ -2010,8 +2922,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param levelMoves the input array to search for non-duplicates from * @param ret the output array to be pushed into. */ - private getUniqueMoves(levelMoves: LevelMoves, ret: LevelMoves ): void { - const uniqueMoves : Moves[] = []; + private getUniqueMoves(levelMoves: LevelMoves, ret: LevelMoves): void { + const uniqueMoves: Moves[] = []; for (const lm of levelMoves) { if (!uniqueMoves.find(m => m === lm[1])) { uniqueMoves.push(lm[1]); @@ -2020,13 +2932,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - /** * Get a list of all egg moves * * @returns list of egg moves */ - getEggMoves() : Moves[] | undefined { + getEggMoves(): Moves[] | undefined { return speciesEggMoves[this.getSpeciesForm().getRootSpeciesId()]; } @@ -2051,12 +2962,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ trySetShiny(thresholdOverride?: number): boolean { // Shiny Pokemon should not spawn in the end biome in endless - if (globalScene.gameMode.isEndless && globalScene.arena.biomeType === Biome.END) { + if ( + globalScene.gameMode.isEndless && + globalScene.arena.biomeType === Biome.END + ) { return false; } - const rand1 = (this.id & 0xFFFF0000) >>> 16; - const rand2 = (this.id & 0x0000FFFF); + const rand1 = (this.id & 0xffff0000) >>> 16; + const rand2 = this.id & 0x0000ffff; const E = globalScene.gameData.trainerId ^ globalScene.gameData.secretId; const F = rand1 ^ rand2; @@ -2067,7 +2981,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { shinyThreshold.value *= globalScene.eventManager.getShinyMultiplier(); } if (!this.hasTrainer()) { - globalScene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold); + globalScene.applyModifiers( + ShinyRateBoosterModifier, + true, + shinyThreshold, + ); } } else { shinyThreshold.value = thresholdOverride; @@ -2092,7 +3010,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param applyModifiersToOverride If {@linkcode thresholdOverride} is set and this is true, will apply Shiny Charm and event modifiers to {@linkcode thresholdOverride} * @returns `true` if the Pokemon has been set as a shiny, `false` otherwise */ - public trySetShinySeed(thresholdOverride?: number, applyModifiersToOverride?: boolean): boolean { + public trySetShinySeed( + thresholdOverride?: number, + applyModifiersToOverride?: boolean, + ): boolean { const shinyThreshold = new Utils.NumberHolder(BASE_SHINY_CHANCE); if (thresholdOverride === undefined || applyModifiersToOverride) { if (thresholdOverride !== undefined && applyModifiersToOverride) { @@ -2102,7 +3023,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { shinyThreshold.value *= globalScene.eventManager.getShinyMultiplier(); } if (!this.hasTrainer()) { - globalScene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold); + globalScene.applyModifiers( + ShinyRateBoosterModifier, + true, + shinyThreshold, + ); } } else { shinyThreshold.value = thresholdOverride; @@ -2112,7 +3037,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.shiny) { this.variant = this.generateShinyVariant(); - this.luck = this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0); + this.luck = + this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0); this.initShinySparkle(); } @@ -2136,20 +3062,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } // Checks if there is no variant data for both the index or index with form - if (!this.shiny || (!variantData.hasOwnProperty(variantDataIndex) && !variantData.hasOwnProperty(this.species.speciesId))) { + if ( + !this.shiny || + (!variantData.hasOwnProperty(variantDataIndex) && + !variantData.hasOwnProperty(this.species.speciesId)) + ) { return 0; } const rand = new Utils.NumberHolder(0); - globalScene.executeWithSeedOffset(() => { - rand.value = Utils.randSeedInt(10); - }, this.id, globalScene.waveSeed); + globalScene.executeWithSeedOffset( + () => { + rand.value = Utils.randSeedInt(10); + }, + this.id, + globalScene.waveSeed, + ); if (rand.value >= SHINY_VARIANT_CHANCE) { - return 0; // 6/10 - } else if (rand.value >= SHINY_EPIC_CHANCE) { - return 1; // 3/10 - } else { - return 2; // 1/10 + return 0; // 6/10 } + if (rand.value >= SHINY_EPIC_CHANCE) { + return 1; // 3/10 + } + return 2; // 1/10 } /** @@ -2161,7 +3095,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param applyModifiersToOverride If {@linkcode thresholdOverride} is set and this is true, will apply Ability Charm to {@linkcode thresholdOverride} * @returns `true` if the Pokemon has been set to have its hidden ability, `false` otherwise */ - public tryRerollHiddenAbilitySeed(thresholdOverride?: number, applyModifiersToOverride?: boolean): boolean { + public tryRerollHiddenAbilitySeed( + thresholdOverride?: number, + applyModifiersToOverride?: boolean, + ): boolean { if (!this.species.abilityHidden) { return false; } @@ -2171,7 +3108,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { haThreshold.value = thresholdOverride; } if (!this.hasTrainer()) { - globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, haThreshold); + globalScene.applyModifiers( + HiddenAbilityRateBoosterModifier, + true, + haThreshold, + ); } } else { haThreshold.value = thresholdOverride; @@ -2185,37 +3126,67 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } public generateFusionSpecies(forStarter?: boolean): void { - const hiddenAbilityChance = new Utils.NumberHolder(BASE_HIDDEN_ABILITY_CHANCE); + const hiddenAbilityChance = new Utils.NumberHolder( + BASE_HIDDEN_ABILITY_CHANCE, + ); if (!this.hasTrainer()) { - globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); + globalScene.applyModifiers( + HiddenAbilityRateBoosterModifier, + true, + hiddenAbilityChance, + ); } const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value); const randAbilityIndex = Utils.randSeedInt(2); - const filter = !forStarter ? - this.species.getCompatibleFusionSpeciesFilter() + const filter = !forStarter + ? this.species.getCompatibleFusionSpeciesFilter() : (species: PokemonSpecies) => { - return pokemonEvolutions.hasOwnProperty(species.speciesId) - && !pokemonPrevolutions.hasOwnProperty(species.speciesId) - && !species.subLegendary - && !species.legendary - && !species.mythical - && !species.isTrainerForbidden() - && species.speciesId !== this.species.speciesId - && species.speciesId !== Species.DITTO; - }; + return ( + pokemonEvolutions.hasOwnProperty(species.speciesId) && + !pokemonPrevolutions.hasOwnProperty(species.speciesId) && + !species.subLegendary && + !species.legendary && + !species.mythical && + !species.isTrainerForbidden() && + species.speciesId !== this.species.speciesId && + species.speciesId !== Species.DITTO + ); + }; let fusionOverride: PokemonSpecies | undefined = undefined; - if (forStarter && this instanceof PlayerPokemon && Overrides.STARTER_FUSION_SPECIES_OVERRIDE) { - fusionOverride = getPokemonSpecies(Overrides.STARTER_FUSION_SPECIES_OVERRIDE); - } else if (this instanceof EnemyPokemon && Overrides.OPP_FUSION_SPECIES_OVERRIDE) { + if ( + forStarter && + this instanceof PlayerPokemon && + Overrides.STARTER_FUSION_SPECIES_OVERRIDE + ) { + fusionOverride = getPokemonSpecies( + Overrides.STARTER_FUSION_SPECIES_OVERRIDE, + ); + } else if ( + this instanceof EnemyPokemon && + Overrides.OPP_FUSION_SPECIES_OVERRIDE + ) { fusionOverride = getPokemonSpecies(Overrides.OPP_FUSION_SPECIES_OVERRIDE); } - this.fusionSpecies = fusionOverride ?? globalScene.randomSpecies(globalScene.currentBattle?.waveIndex || 0, this.level, false, filter, true); - this.fusionAbilityIndex = (this.fusionSpecies.abilityHidden && hasHiddenAbility ? 2 : this.fusionSpecies.ability2 !== this.fusionSpecies.ability1 ? randAbilityIndex : 0); + this.fusionSpecies = + fusionOverride ?? + globalScene.randomSpecies( + globalScene.currentBattle?.waveIndex || 0, + this.level, + false, + filter, + true, + ); + this.fusionAbilityIndex = + this.fusionSpecies.abilityHidden && hasHiddenAbility + ? 2 + : this.fusionSpecies.ability2 !== this.fusionSpecies.ability1 + ? randAbilityIndex + : 0; this.fusionShiny = this.shiny; this.fusionVariant = this.variant; @@ -2230,7 +3201,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - this.fusionFormIndex = globalScene.getSpeciesFormIndex(this.fusionSpecies, this.fusionGender, this.getNature(), true); + this.fusionFormIndex = globalScene.getSpeciesFormIndex( + this.fusionSpecies, + this.fusionGender, + this.getNature(), + true, + ); this.fusionLuck = this.luck; this.generateName(); @@ -2256,7 +3232,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { let movePool: [Moves, number][] = []; const allLevelMoves = this.getLevelMoves(1, true, true); if (!allLevelMoves) { - console.warn("Error encountered trying to generate moveset for:", this.species.name); + console.warn( + "Error encountered trying to generate moveset for:", + this.species.name, + ); return; } @@ -2274,34 +3253,55 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (weight === 1 && allMoves[levelMove[1]].power >= 80) { weight = 40; } - if (!movePool.some(m => m[0] === levelMove[1]) && !allMoves[levelMove[1]].name.endsWith(" (N)")) { - movePool.push([ levelMove[1], weight ]); + if ( + !movePool.some(m => m[0] === levelMove[1]) && + !allMoves[levelMove[1]].name.endsWith(" (N)") + ) { + movePool.push([levelMove[1], weight]); } } if (this.hasTrainer()) { const tms = Object.keys(tmSpecies); for (const tm of tms) { - const moveId = parseInt(tm) as Moves; + const moveId = Number.parseInt(tm) as Moves; let compatible = false; for (const p of tmSpecies[tm]) { if (Array.isArray(p)) { - if (p[0] === this.species.speciesId || (this.fusionSpecies && p[0] === this.fusionSpecies.speciesId) && p.slice(1).indexOf(this.species.forms[this.formIndex]) > -1) { + if ( + p[0] === this.species.speciesId || + (this.fusionSpecies && + p[0] === this.fusionSpecies.speciesId && + p.slice(1).indexOf(this.species.forms[this.formIndex]) > -1) + ) { compatible = true; break; } - } else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) { + } else if ( + p === this.species.speciesId || + (this.fusionSpecies && p === this.fusionSpecies.speciesId) + ) { compatible = true; break; } } - if (compatible && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) { + if ( + compatible && + !movePool.some(m => m[0] === moveId) && + !allMoves[moveId].name.endsWith(" (N)") + ) { if (tmPoolTiers[moveId] === ModifierTier.COMMON && this.level >= 15) { - movePool.push([ moveId, 4 ]); - } else if (tmPoolTiers[moveId] === ModifierTier.GREAT && this.level >= 30) { - movePool.push([ moveId, 8 ]); - } else if (tmPoolTiers[moveId] === ModifierTier.ULTRA && this.level >= 50) { - movePool.push([ moveId, 14 ]); + movePool.push([moveId, 4]); + } else if ( + tmPoolTiers[moveId] === ModifierTier.GREAT && + this.level >= 30 + ) { + movePool.push([moveId, 8]); + } else if ( + tmPoolTiers[moveId] === ModifierTier.ULTRA && + this.level >= 50 + ) { + movePool.push([moveId, 14]); } } } @@ -2310,26 +3310,44 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.level >= 60) { for (let i = 0; i < 3; i++) { const moveId = speciesEggMoves[this.species.getRootSpeciesId()][i]; - if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) { - movePool.push([ moveId, 40 ]); + if ( + !movePool.some(m => m[0] === moveId) && + !allMoves[moveId].name.endsWith(" (N)") + ) { + movePool.push([moveId, 40]); } } const moveId = speciesEggMoves[this.species.getRootSpeciesId()][3]; // No rare egg moves before e4 - if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) { - movePool.push([ moveId, 30 ]); + if ( + this.level >= 170 && + !movePool.some(m => m[0] === moveId) && + !allMoves[moveId].name.endsWith(" (N)") && + !this.isBoss() + ) { + movePool.push([moveId, 30]); } if (this.fusionSpecies) { for (let i = 0; i < 3; i++) { - const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][i]; - if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)")) { - movePool.push([ moveId, 40 ]); + const moveId = + speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][i]; + if ( + !movePool.some(m => m[0] === moveId) && + !allMoves[moveId].name.endsWith(" (N)") + ) { + movePool.push([moveId, 40]); } } - const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3]; + const moveId = + speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3]; // No rare egg moves before e4 - if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(" (N)") && !this.isBoss()) { - movePool.push([ moveId, 30 ]); + if ( + this.level >= 170 && + !movePool.some(m => m[0] === moveId) && + !allMoves[moveId].name.endsWith(" (N)") && + !this.isBoss() + ) { + movePool.push([moveId, 30]); } } } @@ -2340,33 +3358,79 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(SacrificialAttr)); movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(HpSplitAttr)); } - movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(SacrificialAttrOnHit)); + movePool = movePool.filter( + m => !allMoves[m[0]].hasAttr(SacrificialAttrOnHit), + ); if (this.hasTrainer()) { // Trainers never get OHKO moves movePool = movePool.filter(m => !allMoves[m[0]].hasAttr(OneHitKOAttr)); // Half the weight of self KO moves - movePool = movePool.map(m => [ m[0], m[1] * (!!allMoves[m[0]].hasAttr(SacrificialAttr) ? 0.5 : 1) ]); - movePool = movePool.map(m => [ m[0], m[1] * (!!allMoves[m[0]].hasAttr(SacrificialAttrOnHit) ? 0.5 : 1) ]); + movePool = movePool.map(m => [ + m[0], + m[1] * (allMoves[m[0]].hasAttr(SacrificialAttr) ? 0.5 : 1), + ]); + movePool = movePool.map(m => [ + m[0], + m[1] * (allMoves[m[0]].hasAttr(SacrificialAttrOnHit) ? 0.5 : 1), + ]); // Trainers get a weight bump to stat buffing moves - movePool = movePool.map(m => [ m[0], m[1] * (allMoves[m[0]].getAttrs(StatStageChangeAttr).some(a => a.stages > 1 && a.selfTarget) ? 1.25 : 1) ]); + movePool = movePool.map(m => [ + m[0], + m[1] * + (allMoves[m[0]] + .getAttrs(StatStageChangeAttr) + .some(a => a.stages > 1 && a.selfTarget) + ? 1.25 + : 1), + ]); // Trainers get a weight decrease to multiturn moves - movePool = movePool.map(m => [ m[0], m[1] * (!!allMoves[m[0]].isChargingMove() || !!allMoves[m[0]].hasAttr(RechargeAttr) ? 0.7 : 1) ]); + movePool = movePool.map(m => [ + m[0], + m[1] * + (!!allMoves[m[0]].isChargingMove() || + !!allMoves[m[0]].hasAttr(RechargeAttr) + ? 0.7 + : 1), + ]); } // Weight towards higher power moves, by reducing the power of moves below the highest power. // Caps max power at 90 to avoid something like hyper beam ruining the stats. // This is a pretty soft weighting factor, although it is scaled with the weight multiplier. - const maxPower = Math.min(movePool.reduce((v, m) => Math.max(allMoves[m[0]].calculateEffectivePower(), v), 40), 90); - movePool = movePool.map(m => [ m[0], m[1] * (allMoves[m[0]].category === MoveCategory.STATUS ? 1 : Math.max(Math.min(allMoves[m[0]].calculateEffectivePower() / maxPower, 1), 0.5)) ]); + const maxPower = Math.min( + movePool.reduce( + (v, m) => Math.max(allMoves[m[0]].calculateEffectivePower(), v), + 40, + ), + 90, + ); + movePool = movePool.map(m => [ + m[0], + m[1] * + (allMoves[m[0]].category === MoveCategory.STATUS + ? 1 + : Math.max( + Math.min(allMoves[m[0]].calculateEffectivePower() / maxPower, 1), + 0.5, + )), + ]); // Weight damaging moves against the lower stat. This uses a non-linear relationship. // If the higher stat is 1 - 1.09x higher, no change. At higher stat ~1.38x lower stat, off-stat moves have half weight. // One third weight at ~1.58x higher, one quarter weight at ~1.73x higher, one fifth at ~1.87x, and one tenth at ~2.35x higher. const atk = this.getStat(Stat.ATK); const spAtk = this.getStat(Stat.SPATK); - const worseCategory: MoveCategory = atk > spAtk ? MoveCategory.SPECIAL : MoveCategory.PHYSICAL; - const statRatio = worseCategory === MoveCategory.PHYSICAL ? atk / spAtk : spAtk / atk; - movePool = movePool.map(m => [ m[0], m[1] * (allMoves[m[0]].category === worseCategory ? Math.min(Math.pow(statRatio, 3) * 1.3, 1) : 1) ]); + const worseCategory: MoveCategory = + atk > spAtk ? MoveCategory.SPECIAL : MoveCategory.PHYSICAL; + const statRatio = + worseCategory === MoveCategory.PHYSICAL ? atk / spAtk : spAtk / atk; + movePool = movePool.map(m => [ + m[0], + m[1] * + (allMoves[m[0]].category === worseCategory + ? Math.min(Math.pow(statRatio, 3) * 1.3, 1) + : 1), + ]); /** The higher this is the more the game weights towards higher level moves. At `0` all moves are equal weight. */ let weightMultiplier = 0.9; @@ -2376,11 +3440,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (this.isBoss()) { weightMultiplier += 0.4; } - const baseWeights: [Moves, number][] = movePool.map(m => [ m[0], Math.ceil(Math.pow(m[1], weightMultiplier) * 100) ]); + const baseWeights: [Moves, number][] = movePool.map(m => [ + m[0], + Math.ceil(Math.pow(m[1], weightMultiplier) * 100), + ]); // Trainers and bosses always force a stab move if (this.hasTrainer() || this.isBoss()) { - const stabMovePool = baseWeights.filter(m => allMoves[m[0]].category !== MoveCategory.STATUS && this.isOfType(allMoves[m[0]].type)); + const stabMovePool = baseWeights.filter( + m => + allMoves[m[0]].category !== MoveCategory.STATUS && + this.isOfType(allMoves[m[0]].type), + ); if (stabMovePool.length) { const totalWeight = stabMovePool.reduce((v, m) => v + m[1], 0); @@ -2391,8 +3462,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } this.moveset.push(new PokemonMove(stabMovePool[index][0], 0, 0)); } - } else { // Normal wild pokemon just force a random damaging move - const attackMovePool = baseWeights.filter(m => allMoves[m[0]].category !== MoveCategory.STATUS); + } else { + // Normal wild pokemon just force a random damaging move + const attackMovePool = baseWeights.filter( + m => allMoves[m[0]].category !== MoveCategory.STATUS, + ); if (attackMovePool.length) { const totalWeight = attackMovePool.reduce((v, m) => v + m[1], 0); let rand = Utils.randSeedInt(totalWeight); @@ -2404,25 +3478,49 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - while (baseWeights.length > this.moveset.length && this.moveset.length < 4) { + while ( + baseWeights.length > this.moveset.length && + this.moveset.length < 4 + ) { if (this.hasTrainer()) { // Sqrt the weight of any damaging moves with overlapping types. This is about a 0.05 - 0.1 multiplier. // Other damaging moves 2x weight if 0-1 damaging moves, 0.5x if 2, 0.125x if 3. These weights get 20x if STAB. // Status moves remain unchanged on weight, this encourages 1-2 - movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId)).map((m) => { - let ret: number; - if (this.moveset.some(mo => mo?.getMove().category !== MoveCategory.STATUS && mo?.getMove().type === allMoves[m[0]].type)) { - ret = Math.ceil(Math.sqrt(m[1])); - } else if (allMoves[m[0]].category !== MoveCategory.STATUS) { - ret = Math.ceil(m[1] / Math.max(Math.pow(4, this.moveset.filter(mo => (mo?.getMove().power ?? 0) > 1).length) / 8, 0.5) * (this.isOfType(allMoves[m[0]].type) ? 20 : 1)); - } else { - ret = m[1]; - } - return [ m[0], ret ]; - }); + movePool = baseWeights + .filter(m => !this.moveset.some(mo => m[0] === mo?.moveId)) + .map(m => { + let ret: number; + if ( + this.moveset.some( + mo => + mo?.getMove().category !== MoveCategory.STATUS && + mo?.getMove().type === allMoves[m[0]].type, + ) + ) { + ret = Math.ceil(Math.sqrt(m[1])); + } else if (allMoves[m[0]].category !== MoveCategory.STATUS) { + ret = Math.ceil( + (m[1] / + Math.max( + Math.pow( + 4, + this.moveset.filter(mo => (mo?.getMove().power ?? 0) > 1) + .length, + ) / 8, + 0.5, + )) * + (this.isOfType(allMoves[m[0]].type) ? 20 : 1), + ); + } else { + ret = m[1]; + } + return [m[0], ret]; + }); } else { // Non-trainer pokemon just use normal weights - movePool = baseWeights.filter(m => !this.moveset.some(mo => m[0] === mo?.moveId)); + movePool = baseWeights.filter( + m => !this.moveset.some(mo => m[0] === mo?.moveId), + ); } const totalWeight = movePool.reduce((v, m) => v + m[1], 0); let rand = Utils.randSeedInt(totalWeight); @@ -2434,37 +3532,56 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } // Trigger FormChange, except for enemy Pokemon during Mystery Encounters, to avoid crashes - if (this.isPlayer() || !globalScene.currentBattle?.isBattleMysteryEncounter() || !globalScene.currentBattle?.mysteryEncounter) { - globalScene.triggerPokemonFormChange(this, SpeciesFormChangeMoveLearnedTrigger); + if ( + this.isPlayer() || + !globalScene.currentBattle?.isBattleMysteryEncounter() || + !globalScene.currentBattle?.mysteryEncounter + ) { + globalScene.triggerPokemonFormChange( + this, + SpeciesFormChangeMoveLearnedTrigger, + ); } } public trySelectMove(moveIndex: number, ignorePp?: boolean): boolean { - const move = this.getMoveset().length > moveIndex - ? this.getMoveset()[moveIndex] - : null; + const move = + this.getMoveset().length > moveIndex + ? this.getMoveset()[moveIndex] + : null; return move?.isUsable(this, ignorePp) ?? false; } showInfo(): void { if (!this.battleInfo.visible) { - const otherBattleInfo = globalScene.fieldUI.getAll().slice(0, 4).filter(ui => ui instanceof BattleInfo && ((ui as BattleInfo) instanceof PlayerBattleInfo) === this.isPlayer()).find(() => true); + const otherBattleInfo = globalScene.fieldUI + .getAll() + .slice(0, 4) + .filter( + ui => + ui instanceof BattleInfo && + (ui as BattleInfo) instanceof PlayerBattleInfo === this.isPlayer(), + ) + .find(() => true); if (!otherBattleInfo || !this.getFieldIndex()) { globalScene.fieldUI.sendToBack(this.battleInfo); globalScene.sendTextToBack(); // Push the top right text objects behind everything else } else { globalScene.fieldUI.moveAbove(this.battleInfo, otherBattleInfo); } - this.battleInfo.setX(this.battleInfo.x + (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198)); + this.battleInfo.setX( + this.battleInfo.x + + (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198), + ); this.battleInfo.setVisible(true); if (this.isPlayer()) { this.battleInfo.expMaskRect.x += 150; } globalScene.tweens.add({ - targets: [ this.battleInfo, this.battleInfo.expMaskRect ], + targets: [this.battleInfo, this.battleInfo.expMaskRect], x: this.isPlayer() ? "-=150" : `+=${!this.isBoss() ? 150 : 246}`, duration: 1000, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }); } } @@ -2473,7 +3590,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return new Promise(resolve => { if (this.battleInfo && this.battleInfo.visible) { globalScene.tweens.add({ - targets: [ this.battleInfo, this.battleInfo.expMaskRect ], + targets: [this.battleInfo, this.battleInfo.expMaskRect], x: this.isPlayer() ? "+=150" : `-=${!this.isBoss() ? 150 : 246}`, duration: 500, ease: "Cubic.easeIn", @@ -2482,9 +3599,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.battleInfo.expMaskRect.x -= 150; } this.battleInfo.setVisible(false); - this.battleInfo.setX(this.battleInfo.x - (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198)); + this.battleInfo.setX( + this.battleInfo.x - + (this.isPlayer() ? 150 : !this.isBoss() ? -150 : -198), + ); resolve(); - } + }, }); } else { resolve(); @@ -2525,18 +3645,29 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param exp The amount of experience to add * @param ignoreLevelCap Whether to ignore level caps when adding experience (defaults to false) */ - addExp(exp: number, ignoreLevelCap: boolean = false) { + addExp(exp: number, ignoreLevelCap = false) { const maxExpLevel = globalScene.getMaxExpLevel(ignoreLevelCap); const initialExp = this.exp; this.exp += exp; - while (this.level < maxExpLevel && this.exp >= getLevelTotalExp(this.level + 1, this.species.growthRate)) { + while ( + this.level < maxExpLevel && + this.exp >= getLevelTotalExp(this.level + 1, this.species.growthRate) + ) { this.level++; } if (this.level >= maxExpLevel) { - console.log(initialExp, this.exp, getLevelTotalExp(this.level, this.species.growthRate)); - this.exp = Math.max(getLevelTotalExp(this.level, this.species.growthRate), initialExp); + console.log( + initialExp, + this.exp, + getLevelTotalExp(this.level, this.species.growthRate), + ); + this.exp = Math.max( + getLevelTotalExp(this.level, this.species.growthRate), + initialExp, + ); } - this.levelExp = this.exp - getLevelTotalExp(this.level, this.species.growthRate); + this.levelExp = + this.exp - getLevelTotalExp(this.level, this.species.growthRate); } /** @@ -2557,7 +3688,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } getOpponents(): Pokemon[] { - return ((this.isPlayer() ? globalScene.getEnemyField() : globalScene.getPlayerField()) as Pokemon[]).filter(p => p.isActive()); + return ( + (this.isPlayer() + ? globalScene.getEnemyField() + : globalScene.getPlayerField()) as Pokemon[] + ).filter(p => p.isActive()); } getOpponentDescriptor(): string { @@ -2565,11 +3700,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (opponents.length === 1) { return opponents[0].name; } - return this.isPlayer() ? i18next.t("arenaTag:opposingTeam") : i18next.t("arenaTag:yourTeam"); + return this.isPlayer() + ? i18next.t("arenaTag:opposingTeam") + : i18next.t("arenaTag:yourTeam"); } getAlly(): Pokemon { - return (this.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField())[this.getFieldIndex() ? 0 : 1]; + return ( + this.isPlayer() + ? globalScene.getPlayerField() + : globalScene.getEnemyField() + )[this.getFieldIndex() ? 0 : 1]; } /** @@ -2578,7 +3719,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns An array of Pokémon on the allied field. */ getAlliedField(): Pokemon[] { - return this instanceof PlayerPokemon ? globalScene.getPlayerField() : globalScene.getEnemyField(); + return this instanceof PlayerPokemon + ? globalScene.getPlayerField() + : globalScene.getEnemyField(); } /** @@ -2595,7 +3738,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreHeldItems determines whether this Pokemon's held items should be ignored during the stat calculation, default `false` * @return the stat stage multiplier to be used for effective stat calculation */ - getStatStageMultiplier(stat: EffectiveStat, opponent?: Pokemon, move?: Move, ignoreOppAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true, ignoreHeldItems: boolean = false): number { + getStatStageMultiplier( + stat: EffectiveStat, + opponent?: Pokemon, + move?: Move, + ignoreOppAbility = false, + isCritical = false, + simulated = true, + ignoreHeldItems = false, + ): number { const statStage = new Utils.NumberHolder(this.getStatStage(stat)); const ignoreStatStage = new Utils.BooleanHolder(false); @@ -2613,17 +3764,37 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } if (!ignoreOppAbility) { - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, opponent, null, simulated, stat, ignoreStatStage); + applyAbAttrs( + IgnoreOpponentStatStagesAbAttr, + opponent, + null, + simulated, + stat, + ignoreStatStage, + ); } if (move) { - applyMoveAttrs(IgnoreOpponentStatStagesAttr, this, opponent, move, ignoreStatStage); + applyMoveAttrs( + IgnoreOpponentStatStagesAttr, + this, + opponent, + move, + ignoreStatStage, + ); } } if (!ignoreStatStage.value) { - const statStageMultiplier = new Utils.NumberHolder(Math.max(2, 2 + statStage.value) / Math.max(2, 2 - statStage.value)); + const statStageMultiplier = new Utils.NumberHolder( + Math.max(2, 2 + statStage.value) / Math.max(2, 2 - statStage.value), + ); if (!ignoreHeldItems) { - globalScene.applyModifiers(TempStatStageBoosterModifier, this.isPlayer(), stat, statStageMultiplier); + globalScene.applyModifiers( + TempStatStageBoosterModifier, + this.isPlayer(), + stat, + statStageMultiplier, + ); } return Math.min(statStageMultiplier.value, 4); } @@ -2647,18 +3818,47 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } const userAccStage = new Utils.NumberHolder(this.getStatStage(Stat.ACC)); - const targetEvaStage = new Utils.NumberHolder(target.getStatStage(Stat.EVA)); + const targetEvaStage = new Utils.NumberHolder( + target.getStatStage(Stat.EVA), + ); const ignoreAccStatStage = new Utils.BooleanHolder(false); const ignoreEvaStatStage = new Utils.BooleanHolder(false); - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, target, null, false, Stat.ACC, ignoreAccStatStage); - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, this, null, false, Stat.EVA, ignoreEvaStatStage); - applyMoveAttrs(IgnoreOpponentStatStagesAttr, this, target, sourceMove, ignoreEvaStatStage); + applyAbAttrs( + IgnoreOpponentStatStagesAbAttr, + target, + null, + false, + Stat.ACC, + ignoreAccStatStage, + ); + applyAbAttrs( + IgnoreOpponentStatStagesAbAttr, + this, + null, + false, + Stat.EVA, + ignoreEvaStatStage, + ); + applyMoveAttrs( + IgnoreOpponentStatStagesAttr, + this, + target, + sourceMove, + ignoreEvaStatStage, + ); - globalScene.applyModifiers(TempStatStageBoosterModifier, this.isPlayer(), Stat.ACC, userAccStage); + globalScene.applyModifiers( + TempStatStageBoosterModifier, + this.isPlayer(), + Stat.ACC, + userAccStage, + ); - userAccStage.value = ignoreAccStatStage.value ? 0 : Math.min(userAccStage.value, 6); + userAccStage.value = ignoreAccStatStage.value + ? 0 + : Math.min(userAccStage.value, 6); targetEvaStage.value = ignoreEvaStatStage.value ? 0 : targetEvaStage.value; if (target.findTag(t => t instanceof ExposedTag)) { @@ -2667,15 +3867,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const accuracyMultiplier = new Utils.NumberHolder(1); if (userAccStage.value !== targetEvaStage.value) { - accuracyMultiplier.value = userAccStage.value > targetEvaStage.value - ? (3 + Math.min(userAccStage.value - targetEvaStage.value, 6)) / 3 - : 3 / (3 + Math.min(targetEvaStage.value - userAccStage.value, 6)); + accuracyMultiplier.value = + userAccStage.value > targetEvaStage.value + ? (3 + Math.min(userAccStage.value - targetEvaStage.value, 6)) / 3 + : 3 / (3 + Math.min(targetEvaStage.value - userAccStage.value, 6)); } - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, this, Stat.ACC, accuracyMultiplier, false, sourceMove); + applyStatMultiplierAbAttrs( + StatMultiplierAbAttr, + this, + Stat.ACC, + accuracyMultiplier, + false, + sourceMove, + ); const evasionMultiplier = new Utils.NumberHolder(1); - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, target, Stat.EVA, evasionMultiplier); + applyStatMultiplierAbAttrs( + StatMultiplierAbAttr, + target, + Stat.EVA, + evasionMultiplier, + ); return accuracyMultiplier.value / evasionMultiplier.value; } @@ -2692,11 +3905,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param simulated if `true`, suppresses changes to game state during calculation (defaults to `true`). * @returns The move's base damage against this Pokemon when used by the source Pokemon. */ - getBaseDamage(source: Pokemon, move: Move, moveCategory: MoveCategory, ignoreAbility: boolean = false, ignoreSourceAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true): number { + getBaseDamage( + source: Pokemon, + move: Move, + moveCategory: MoveCategory, + ignoreAbility = false, + ignoreSourceAbility = false, + isCritical = false, + simulated = true, + ): number { const isPhysical = moveCategory === MoveCategory.PHYSICAL; /** A base damage multiplier based on the source's level */ - const levelMultiplier = (2 * source.level / 5 + 2); + const levelMultiplier = (2 * source.level) / 5 + 2; /** The power of the move after power boosts from abilities, etc. have applied */ const power = move.calculateBattlePower(source, this, simulated); @@ -2705,25 +3926,53 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * The attacker's offensive stat for the given move's category. * Critical hits cause negative stat stages to be ignored. */ - const sourceAtk = new Utils.NumberHolder(source.getEffectiveStat(isPhysical ? Stat.ATK : Stat.SPATK, this, undefined, ignoreSourceAbility, ignoreAbility, isCritical, simulated)); + const sourceAtk = new Utils.NumberHolder( + source.getEffectiveStat( + isPhysical ? Stat.ATK : Stat.SPATK, + this, + undefined, + ignoreSourceAbility, + ignoreAbility, + isCritical, + simulated, + ), + ); applyMoveAttrs(VariableAtkAttr, source, this, move, sourceAtk); /** * This Pokemon's defensive stat for the given move's category. * Critical hits cause positive stat stages to be ignored. */ - const targetDef = new Utils.NumberHolder(this.getEffectiveStat(isPhysical ? Stat.DEF : Stat.SPDEF, source, move, ignoreAbility, ignoreSourceAbility, isCritical, simulated)); + const targetDef = new Utils.NumberHolder( + this.getEffectiveStat( + isPhysical ? Stat.DEF : Stat.SPDEF, + source, + move, + ignoreAbility, + ignoreSourceAbility, + isCritical, + simulated, + ), + ); applyMoveAttrs(VariableDefAttr, source, this, move, targetDef); /** * The attack's base damage, as determined by the source's level, move power * and Attack stat as well as this Pokemon's Defense stat */ - const baseDamage = ((levelMultiplier * power * sourceAtk.value / targetDef.value) / 50) + 2; + const baseDamage = + (levelMultiplier * power * sourceAtk.value) / targetDef.value / 50 + 2; /** Debug message for non-simulated calls (i.e. when damage is actually dealt) */ if (!simulated) { - console.log("base damage", baseDamage, move.name, power, sourceAtk.value, targetDef.value); + console.log( + "base damage", + baseDamage, + move.name, + power, + sourceAtk.value, + targetDef.value, + ); } return baseDamage; @@ -2742,12 +3991,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * - `result`: {@linkcode HitResult} indicates the attack's type effectiveness. * - `damage`: `number` the attack's final damage output. */ - getAttackDamage(source: Pokemon, move: Move, ignoreAbility: boolean = false, ignoreSourceAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true): DamageCalculationResult { + getAttackDamage( + source: Pokemon, + move: Move, + ignoreAbility = false, + ignoreSourceAbility = false, + isCritical = false, + simulated = true, + ): DamageCalculationResult { const damage = new Utils.NumberHolder(0); - const defendingSide = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; + const defendingSide = this.isPlayer() + ? ArenaTagSide.PLAYER + : ArenaTagSide.ENEMY; const variableCategory = new Utils.NumberHolder(move.category); - applyMoveAttrs(VariableMoveCategoryAttr, source, this, move, variableCategory); + applyMoveAttrs( + VariableMoveCategoryAttr, + source, + this, + move, + variableCategory, + ); const moveCategory = variableCategory.value as MoveCategory; /** The move's type after type-changing effects are applied */ @@ -2763,21 +4027,36 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * * Note that the source's abilities are not ignored here */ - const typeMultiplier = this.getMoveEffectiveness(source, move, ignoreAbility, simulated, cancelled); + const typeMultiplier = this.getMoveEffectiveness( + source, + move, + ignoreAbility, + simulated, + cancelled, + ); const isPhysical = moveCategory === MoveCategory.PHYSICAL; /** Combined damage multiplier from field effects such as weather, terrain, etc. */ - const arenaAttackTypeMultiplier = new Utils.NumberHolder(globalScene.arena.getAttackTypeMultiplier(moveType, source.isGrounded())); - applyMoveAttrs(IgnoreWeatherTypeDebuffAttr, source, this, move, arenaAttackTypeMultiplier); + const arenaAttackTypeMultiplier = new Utils.NumberHolder( + globalScene.arena.getAttackTypeMultiplier(moveType, source.isGrounded()), + ); + applyMoveAttrs( + IgnoreWeatherTypeDebuffAttr, + source, + this, + move, + arenaAttackTypeMultiplier, + ); - const isTypeImmune = (typeMultiplier * arenaAttackTypeMultiplier.value) === 0; + const isTypeImmune = typeMultiplier * arenaAttackTypeMultiplier.value === 0; if (cancelled.value || isTypeImmune) { return { cancelled: cancelled.value, - result: move.id === Moves.SHEER_COLD ? HitResult.IMMUNE : HitResult.NO_EFFECT, - damage: 0 + result: + move.id === Moves.SHEER_COLD ? HitResult.IMMUNE : HitResult.NO_EFFECT, + damage: 0, }; } @@ -2786,13 +4065,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs(FixedDamageAttr, source, this, move, fixedDamage); if (fixedDamage.value) { const multiLensMultiplier = new Utils.NumberHolder(1); - globalScene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiLensMultiplier); - fixedDamage.value = Utils.toDmgValue(fixedDamage.value * multiLensMultiplier.value); + globalScene.applyModifiers( + PokemonMultiHitModifier, + source.isPlayer(), + source, + move.id, + null, + multiLensMultiplier, + ); + fixedDamage.value = Utils.toDmgValue( + fixedDamage.value * multiLensMultiplier.value, + ); return { cancelled: false, result: HitResult.EFFECTIVE, - damage: fixedDamage.value + damage: fixedDamage.value, }; } @@ -2803,7 +4091,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return { cancelled: false, result: HitResult.ONE_HIT_KO, - damage: this.hp + damage: this.hp, }; } @@ -2811,18 +4099,41 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * The attack's base damage, as determined by the source's level, move power * and Attack stat as well as this Pokemon's Defense stat */ - const baseDamage = this.getBaseDamage(source, move, moveCategory, ignoreAbility, ignoreSourceAbility, isCritical, simulated); + const baseDamage = this.getBaseDamage( + source, + move, + moveCategory, + ignoreAbility, + ignoreSourceAbility, + isCritical, + simulated, + ); /** 25% damage debuff on moves hitting more than one non-fainted target (regardless of immunities) */ const { targets, multiple } = getMoveTargets(source, move.id); const numTargets = multiple ? targets.length : 1; - const targetMultiplier = (numTargets > 1) ? 0.75 : 1; + const targetMultiplier = numTargets > 1 ? 0.75 : 1; /** Multiplier for moves enhanced by Multi-Lens and/or Parental Bond */ const multiStrikeEnhancementMultiplier = new Utils.NumberHolder(1); - globalScene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiStrikeEnhancementMultiplier); + globalScene.applyModifiers( + PokemonMultiHitModifier, + source.isPlayer(), + source, + move.id, + null, + multiStrikeEnhancementMultiplier, + ); if (!ignoreSourceAbility) { - applyPreAttackAbAttrs(AddSecondStrikeAbAttr, source, this, move, simulated, null, multiStrikeEnhancementMultiplier); + applyPreAttackAbAttrs( + AddSecondStrikeAbAttr, + source, + this, + move, + simulated, + null, + multiStrikeEnhancementMultiplier, + ); } /** Doubles damage if this Pokemon's last move was Glaive Rush */ @@ -2839,7 +4150,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * A multiplier for random damage spread in the range [0.85, 1] * This is always 1 for simulated calls. */ - const randomMultiplier = simulated ? 1 : ((this.randSeedIntRange(85, 100)) / 100); + const randomMultiplier = simulated + ? 1 + : this.randSeedIntRange(85, 100) / 100; const sourceTypes = source.getTypes(); const sourceTeraType = source.getTeraType(); @@ -2854,13 +4167,28 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyAbAttrs(StabBoostAbAttr, source, null, simulated, stabMultiplier); } - applyMoveAttrs(CombinedPledgeStabBoostAttr, source, this, move, stabMultiplier); + applyMoveAttrs( + CombinedPledgeStabBoostAttr, + source, + this, + move, + stabMultiplier, + ); - if (source.isTerastallized && sourceTeraType === moveType && moveType !== PokemonType.STELLAR) { + if ( + source.isTerastallized && + sourceTeraType === moveType && + moveType !== PokemonType.STELLAR + ) { stabMultiplier.value += 0.5; } - if (source.isTerastallized && source.getTeraType() === PokemonType.STELLAR && (!source.stellarTypesBoosted.includes(moveType) || source.hasSpecies(Species.TERAPAGOS))) { + if ( + source.isTerastallized && + source.getTeraType() === PokemonType.STELLAR && + (!source.stellarTypesBoosted.includes(moveType) || + source.hasSpecies(Species.TERAPAGOS)) + ) { if (matchesSourceType) { stabMultiplier.value += 0.5; } else { @@ -2872,11 +4200,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** Halves damage if the attacker is using a physical attack while burned */ const burnMultiplier = new Utils.NumberHolder(1); - if (isPhysical && source.status && source.status.effect === StatusEffect.BURN) { + if ( + isPhysical && + source.status && + source.status.effect === StatusEffect.BURN + ) { if (!move.hasAttr(BypassBurnDamageReductionAttr)) { const burnDamageReductionCancelled = new Utils.BooleanHolder(false); if (!ignoreSourceAbility) { - applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled, simulated); + applyAbAttrs( + BypassBurnDamageReductionAbAttr, + source, + burnDamageReductionCancelled, + simulated, + ); } if (!burnDamageReductionCancelled.value) { burnMultiplier.value = 0.5; @@ -2889,7 +4226,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Critical hits should bypass screens if (!isCritical) { - globalScene.arena.applyTagsForSide(WeakenMoveScreenTag, defendingSide, simulated, source, moveCategory, screenMultiplier); + globalScene.arena.applyTagsForSide( + WeakenMoveScreenTag, + defendingSide, + simulated, + source, + moveCategory, + screenMultiplier, + ); } /** @@ -2899,36 +4243,49 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * The move doubles damage when used against that tag */ const hitsTagMultiplier = new Utils.NumberHolder(1); - move.getAttrs(HitsTagAttr).filter(hta => hta.doubleDamage).forEach(hta => { - if (this.getTag(hta.tagType)) { - hitsTagMultiplier.value *= 2; - } - }); + move + .getAttrs(HitsTagAttr) + .filter(hta => hta.doubleDamage) + .forEach(hta => { + if (this.getTag(hta.tagType)) { + hitsTagMultiplier.value *= 2; + } + }); /** Halves damage if this Pokemon is grounded in Misty Terrain against a Dragon-type attack */ - const mistyTerrainMultiplier = (globalScene.arena.terrain?.terrainType === TerrainType.MISTY && this.isGrounded() && moveType === PokemonType.DRAGON) - ? 0.5 - : 1; + const mistyTerrainMultiplier = + globalScene.arena.terrain?.terrainType === TerrainType.MISTY && + this.isGrounded() && + moveType === PokemonType.DRAGON + ? 0.5 + : 1; damage.value = Utils.toDmgValue( - baseDamage - * targetMultiplier - * multiStrikeEnhancementMultiplier.value - * arenaAttackTypeMultiplier.value - * glaiveRushMultiplier.value - * criticalMultiplier.value - * randomMultiplier - * stabMultiplier.value - * typeMultiplier - * burnMultiplier.value - * screenMultiplier.value - * hitsTagMultiplier.value - * mistyTerrainMultiplier + baseDamage * + targetMultiplier * + multiStrikeEnhancementMultiplier.value * + arenaAttackTypeMultiplier.value * + glaiveRushMultiplier.value * + criticalMultiplier.value * + randomMultiplier * + stabMultiplier.value * + typeMultiplier * + burnMultiplier.value * + screenMultiplier.value * + hitsTagMultiplier.value * + mistyTerrainMultiplier, ); /** Doubles damage if the attacker has Tinted Lens and is using a resisted move */ if (!ignoreSourceAbility) { - applyPreAttackAbAttrs(DamageBoostAbAttr, source, this, move, simulated, damage); + applyPreAttackAbAttrs( + DamageBoostAbAttr, + source, + this, + move, + simulated, + damage, + ); } /** Apply the enemy's Damage and Resistance tokens */ @@ -2939,14 +4296,29 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { globalScene.applyModifiers(EnemyDamageReducerModifier, false, damage); } - /** Apply this Pokemon's post-calc defensive modifiers (e.g. Fur Coat) */ if (!ignoreAbility) { - applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, move, cancelled, simulated, damage); + applyPreDefendAbAttrs( + ReceivedMoveDamageMultiplierAbAttr, + this, + source, + move, + cancelled, + simulated, + damage, + ); /** Additionally apply friend guard damage reduction if ally has it. */ if (globalScene.currentBattle.double && this.getAlly()?.isActive(true)) { - applyPreDefendAbAttrs(AlliedFieldDamageReductionAbAttr, this.getAlly(), source, move, cancelled, simulated, damage); + applyPreDefendAbAttrs( + AlliedFieldDamageReductionAbAttr, + this.getAlly(), + source, + move, + cancelled, + simulated, + damage, + ); } } @@ -2954,7 +4326,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs(ModifiedDamageAttr, source, this, move, damage); if (this.isFullHp() && !ignoreAbility) { - applyPreDefendAbAttrs(PreDefendFullHpEndureAbAttr, this, source, move, cancelled, false, damage); + applyPreDefendAbAttrs( + PreDefendFullHpEndureAbAttr, + this, + source, + move, + cancelled, + false, + damage, + ); } // debug message for when damage is applied (i.e. not simulated) @@ -2974,7 +4354,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return { cancelled: cancelled.value, result: hitResult, - damage: damage.value + damage: damage.value, }; } @@ -2985,139 +4365,211 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns The {@linkcode HitResult} of the attack */ apply(source: Pokemon, move: Move): HitResult { - const defendingSide = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; + const defendingSide = this.isPlayer() + ? ArenaTagSide.PLAYER + : ArenaTagSide.ENEMY; const moveCategory = new Utils.NumberHolder(move.category); applyMoveAttrs(VariableMoveCategoryAttr, source, this, move, moveCategory); if (moveCategory.value === MoveCategory.STATUS) { const cancelled = new Utils.BooleanHolder(false); - const typeMultiplier = this.getMoveEffectiveness(source, move, false, false, cancelled); + const typeMultiplier = this.getMoveEffectiveness( + source, + move, + false, + false, + cancelled, + ); if (!cancelled.value && typeMultiplier === 0) { - globalScene.queueMessage(i18next.t("battle:hitResultNoEffect", { pokemonName: getPokemonNameWithAffix(this) })); + globalScene.queueMessage( + i18next.t("battle:hitResultNoEffect", { + pokemonName: getPokemonNameWithAffix(this), + }), + ); } - return (typeMultiplier === 0) ? HitResult.NO_EFFECT : HitResult.STATUS; + return typeMultiplier === 0 ? HitResult.NO_EFFECT : HitResult.STATUS; + } + /** Determines whether the attack critically hits */ + let isCritical: boolean; + const critOnly = new Utils.BooleanHolder(false); + const critAlways = source.getTag(BattlerTagType.ALWAYS_CRIT); + applyMoveAttrs(CritOnlyAttr, source, this, move, critOnly); + applyAbAttrs( + ConditionalCritAbAttr, + source, + null, + false, + critOnly, + this, + move, + ); + if (critOnly.value || critAlways) { + isCritical = true; } else { - /** Determines whether the attack critically hits */ - let isCritical: boolean; - const critOnly = new Utils.BooleanHolder(false); - const critAlways = source.getTag(BattlerTagType.ALWAYS_CRIT); - applyMoveAttrs(CritOnlyAttr, source, this, move, critOnly); - applyAbAttrs(ConditionalCritAbAttr, source, null, false, critOnly, this, move); - if (critOnly.value || critAlways) { - isCritical = true; - } else { - const critChance = [ 24, 8, 2, 1 ][Math.max(0, Math.min(this.getCritStage(source, move), 3))]; - isCritical = critChance === 1 || !globalScene.randBattleSeedInt(critChance); - } + const critChance = [24, 8, 2, 1][ + Math.max(0, Math.min(this.getCritStage(source, move), 3)) + ]; + isCritical = + critChance === 1 || !globalScene.randBattleSeedInt(critChance); + } - const noCritTag = globalScene.arena.getTagOnSide(NoCritTag, defendingSide); - const blockCrit = new Utils.BooleanHolder(false); - applyAbAttrs(BlockCritAbAttr, this, null, false, blockCrit); - if (noCritTag || blockCrit.value || Overrides.NEVER_CRIT_OVERRIDE) { - isCritical = false; + const noCritTag = globalScene.arena.getTagOnSide(NoCritTag, defendingSide); + const blockCrit = new Utils.BooleanHolder(false); + applyAbAttrs(BlockCritAbAttr, this, null, false, blockCrit); + if (noCritTag || blockCrit.value || Overrides.NEVER_CRIT_OVERRIDE) { + isCritical = false; + } + + /** + * Applies stat changes from {@linkcode move} and gives it to {@linkcode source} + * before damage calculation + */ + applyMoveAttrs(StatChangeBeforeDmgCalcAttr, source, this, move); + + const { + cancelled, + result, + damage: dmg, + } = this.getAttackDamage(source, move, false, false, isCritical, false); + + const typeBoost = source.findTag( + t => + t instanceof TypeBoostTag && t.boostedType === source.getMoveType(move), + ) as TypeBoostTag; + if (typeBoost?.oneUse) { + source.removeTag(typeBoost.tagType); + } + + if ( + cancelled || + result === HitResult.IMMUNE || + result === HitResult.NO_EFFECT + ) { + source.stopMultiHit(this); + + if (!cancelled) { + if (result === HitResult.IMMUNE) { + globalScene.queueMessage( + i18next.t("battle:hitResultImmune", { + pokemonName: getPokemonNameWithAffix(this), + }), + ); + } else { + globalScene.queueMessage( + i18next.t("battle:hitResultNoEffect", { + pokemonName: getPokemonNameWithAffix(this), + }), + ); + } + } + return result; + } + + // In case of fatal damage, this tag would have gotten cleared before we could lapse it. + const destinyTag = this.getTag(BattlerTagType.DESTINY_BOND); + const grudgeTag = this.getTag(BattlerTagType.GRUDGE); + + const isOneHitKo = result === HitResult.ONE_HIT_KO; + + if (dmg) { + this.lapseTags(BattlerTagLapseType.HIT); + + const substitute = this.getTag(SubstituteTag); + const isBlockedBySubstitute = + !!substitute && move.hitsSubstitute(source, this); + if (isBlockedBySubstitute) { + substitute.hp -= dmg; + } + if (!this.isPlayer() && dmg >= this.hp) { + globalScene.applyModifiers(EnemyEndureChanceModifier, false, this); } /** - * Applies stat changes from {@linkcode move} and gives it to {@linkcode source} - * before damage calculation + * We explicitly require to ignore the faint phase here, as we want to show the messages + * about the critical hit and the super effective/not very effective messages before the faint phase. */ - applyMoveAttrs(StatChangeBeforeDmgCalcAttr, source, this, move); + const damage = this.damageAndUpdate( + isBlockedBySubstitute ? 0 : dmg, + result as DamageResult, + isCritical, + isOneHitKo, + isOneHitKo, + true, + source, + ); - const { cancelled, result, damage: dmg } = this.getAttackDamage(source, move, false, false, isCritical, false); - - const typeBoost = source.findTag(t => t instanceof TypeBoostTag && t.boostedType === source.getMoveType(move)) as TypeBoostTag; - if (typeBoost?.oneUse) { - source.removeTag(typeBoost.tagType); - } - - if (cancelled || result === HitResult.IMMUNE || result === HitResult.NO_EFFECT) { - source.stopMultiHit(this); - - if (!cancelled) { - if (result === HitResult.IMMUNE) { - globalScene.queueMessage(i18next.t("battle:hitResultImmune", { pokemonName: getPokemonNameWithAffix(this) })); - } else { - globalScene.queueMessage(i18next.t("battle:hitResultNoEffect", { pokemonName: getPokemonNameWithAffix(this) })); + if (damage > 0) { + if (source.isPlayer()) { + globalScene.validateAchvs(DamageAchv, new Utils.NumberHolder(damage)); + if (damage > globalScene.gameData.gameStats.highestDamage) { + globalScene.gameData.gameStats.highestDamage = damage; } } - return result; - } + source.turnData.totalDamageDealt += damage; + source.turnData.singleHitDamageDealt = damage; + this.turnData.damageTaken += damage; + this.battleData.hitCount++; - // In case of fatal damage, this tag would have gotten cleared before we could lapse it. - const destinyTag = this.getTag(BattlerTagType.DESTINY_BOND); - const grudgeTag = this.getTag(BattlerTagType.GRUDGE); - - const isOneHitKo = result === HitResult.ONE_HIT_KO; - - if (dmg) { - this.lapseTags(BattlerTagLapseType.HIT); - - const substitute = this.getTag(SubstituteTag); - const isBlockedBySubstitute = !!substitute && move.hitsSubstitute(source, this); - if (isBlockedBySubstitute) { - substitute.hp -= dmg; - } - if (!this.isPlayer() && dmg >= this.hp) { - globalScene.applyModifiers(EnemyEndureChanceModifier, false, this); - } - - /** - * We explicitly require to ignore the faint phase here, as we want to show the messages - * about the critical hit and the super effective/not very effective messages before the faint phase. - */ - const damage = this.damageAndUpdate(isBlockedBySubstitute ? 0 : dmg, result as DamageResult, isCritical, isOneHitKo, isOneHitKo, true, source); - - if (damage > 0) { - if (source.isPlayer()) { - globalScene.validateAchvs(DamageAchv, new Utils.NumberHolder(damage)); - if (damage > globalScene.gameData.gameStats.highestDamage) { - globalScene.gameData.gameStats.highestDamage = damage; - } - } - source.turnData.totalDamageDealt += damage; - source.turnData.singleHitDamageDealt = damage; - this.turnData.damageTaken += damage; - this.battleData.hitCount++; - - const attackResult = { move: move.id, result: result as DamageResult, damage: damage, critical: isCritical, sourceId: source.id, sourceBattlerIndex: source.getBattlerIndex() }; - this.turnData.attacksReceived.unshift(attackResult); - if (source.isPlayer() && !this.isPlayer()) { - globalScene.applyModifiers(DamageMoneyRewardModifier, true, source, new Utils.NumberHolder(damage)); - } + const attackResult = { + move: move.id, + result: result as DamageResult, + damage: damage, + critical: isCritical, + sourceId: source.id, + sourceBattlerIndex: source.getBattlerIndex(), + }; + this.turnData.attacksReceived.unshift(attackResult); + if (source.isPlayer() && !this.isPlayer()) { + globalScene.applyModifiers( + DamageMoneyRewardModifier, + true, + source, + new Utils.NumberHolder(damage), + ); } } - - if (isCritical) { - globalScene.queueMessage(i18next.t("battle:hitResultCriticalHit")); - } - - // want to include is.Fainted() in case multi hit move ends early, still want to render message - if (source.turnData.hitsLeft === 1 || this.isFainted()) { - switch (result) { - case HitResult.SUPER_EFFECTIVE: - globalScene.queueMessage(i18next.t("battle:hitResultSuperEffective")); - break; - case HitResult.NOT_VERY_EFFECTIVE: - globalScene.queueMessage(i18next.t("battle:hitResultNotVeryEffective")); - break; - case HitResult.ONE_HIT_KO: - globalScene.queueMessage(i18next.t("battle:hitResultOneHitKO")); - break; - } - } - - if (this.isFainted()) { - // set splice index here, so future scene queues happen before FaintedPhase - globalScene.setPhaseQueueSplice(); - globalScene.unshiftPhase(new FaintPhase(this.getBattlerIndex(), isOneHitKo, destinyTag, grudgeTag, source)); - - this.destroySubstitute(); - this.lapseTag(BattlerTagType.COMMANDED); - this.resetSummonData(); - } - - return result; } + + if (isCritical) { + globalScene.queueMessage(i18next.t("battle:hitResultCriticalHit")); + } + + // want to include is.Fainted() in case multi hit move ends early, still want to render message + if (source.turnData.hitsLeft === 1 || this.isFainted()) { + switch (result) { + case HitResult.SUPER_EFFECTIVE: + globalScene.queueMessage(i18next.t("battle:hitResultSuperEffective")); + break; + case HitResult.NOT_VERY_EFFECTIVE: + globalScene.queueMessage( + i18next.t("battle:hitResultNotVeryEffective"), + ); + break; + case HitResult.ONE_HIT_KO: + globalScene.queueMessage(i18next.t("battle:hitResultOneHitKO")); + break; + } + } + + if (this.isFainted()) { + // set splice index here, so future scene queues happen before FaintedPhase + globalScene.setPhaseQueueSplice(); + globalScene.unshiftPhase( + new FaintPhase( + this.getBattlerIndex(), + isOneHitKo, + destinyTag, + grudgeTag, + source, + ), + ); + + this.destroySubstitute(); + this.lapseTag(BattlerTagType.COMMANDED); + this.resetSummonData(); + } + + return result; } /** @@ -3128,7 +4580,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreFaintPhase flag on wheter to add FaintPhase if pokemon after applying damage faints * @returns integer representing damage */ - damage(damage: number, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false): number { + damage( + damage: number, + _ignoreSegments = false, + preventEndure = false, + ignoreFaintPhase = false, + ): number { if (this.isFainted()) { return 0; } @@ -3143,7 +4600,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { surviveDamage.value = this.lapseTag(BattlerTagType.ENDURE_TOKEN); } if (!surviveDamage.value) { - globalScene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage); + globalScene.applyModifiers( + SurviveDamageModifier, + this.isPlayer(), + this, + surviveDamage, + ); } if (surviveDamage.value) { damage = this.hp - 1; @@ -3161,7 +4623,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Once the MoveEffectPhase is over (and calls it's .end() function, shiftPhase() will reset the PhaseQueueSplice via clearPhaseQueueSplice() ) */ globalScene.setPhaseQueueSplice(); - globalScene.unshiftPhase(new FaintPhase(this.getBattlerIndex(), preventEndure)); + globalScene.unshiftPhase( + new FaintPhase(this.getBattlerIndex(), preventEndure), + ); this.destroySubstitute(); this.lapseTag(BattlerTagType.COMMANDED); this.resetSummonData(); @@ -3179,13 +4643,31 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreFaintPhase boolean to ignore adding a FaintPhase, passsed to damage() * @returns integer of damage done */ - damageAndUpdate(damage: number, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number { - const damagePhase = new DamageAnimPhase(this.getBattlerIndex(), damage, result as DamageResult, critical); + damageAndUpdate( + damage: number, + result?: DamageResult, + critical = false, + ignoreSegments = false, + preventEndure = false, + ignoreFaintPhase = false, + source?: Pokemon, + ): number { + const damagePhase = new DamageAnimPhase( + this.getBattlerIndex(), + damage, + result as DamageResult, + critical, + ); globalScene.unshiftPhase(damagePhase); if (this.switchOutStatus && source) { damage = 0; } - damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); + damage = this.damage( + damage, + ignoreSegments, + preventEndure, + ignoreFaintPhase, + ); // Damage amount may have changed, but needed to be queued before calling damage function damagePhase.updateAmount(damage); /** @@ -3193,7 +4675,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Multi-hits are handled in move-effect-phase.ts for PostDamageAbAttr */ if (!source || source.turnData.hitCount <= 1) { - applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); + applyPostDamageAbAttrs( + PostDamageAbAttr, + this, + damage, + this.hasPassive(), + false, + [], + source, + ); } return damage; } @@ -3226,15 +4716,34 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const stubTag = new BattlerTag(tagType, 0, 0); const cancelled = new Utils.BooleanHolder(false); - applyPreApplyBattlerTagAbAttrs(BattlerTagImmunityAbAttr, this, stubTag, cancelled, true); + applyPreApplyBattlerTagAbAttrs( + BattlerTagImmunityAbAttr, + this, + stubTag, + cancelled, + true, + ); const userField = this.getAlliedField(); - userField.forEach(pokemon => applyPreApplyBattlerTagAbAttrs(UserFieldBattlerTagImmunityAbAttr, pokemon, stubTag, cancelled, true)); + userField.forEach(pokemon => + applyPreApplyBattlerTagAbAttrs( + UserFieldBattlerTagImmunityAbAttr, + pokemon, + stubTag, + cancelled, + true, + ), + ); return !cancelled.value; } - addTag(tagType: BattlerTagType, turnCount: number = 0, sourceMove?: Moves, sourceId?: number): boolean { + addTag( + tagType: BattlerTagType, + turnCount = 0, + sourceMove?: Moves, + sourceId?: number, + ): boolean { const existingTag = this.getTag(tagType); if (existingTag) { existingTag.onOverlap(this); @@ -3244,10 +4753,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const newTag = getBattlerTag(tagType, turnCount, sourceMove!, sourceId!); // TODO: are the bangs correct? const cancelled = new Utils.BooleanHolder(false); - applyPreApplyBattlerTagAbAttrs(BattlerTagImmunityAbAttr, this, newTag, cancelled); + applyPreApplyBattlerTagAbAttrs( + BattlerTagImmunityAbAttr, + this, + newTag, + cancelled, + ); const userField = this.getAlliedField(); - userField.forEach(pokemon => applyPreApplyBattlerTagAbAttrs(UserFieldBattlerTagImmunityAbAttr, pokemon, newTag, cancelled)); + userField.forEach(pokemon => + applyPreApplyBattlerTagAbAttrs( + UserFieldBattlerTagImmunityAbAttr, + pokemon, + newTag, + cancelled, + ), + ); if (!cancelled.value && newTag.canAdd(this)) { this.summonData.tags.push(newTag); @@ -3269,20 +4790,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!this.summonData) { return null; } - return (tagType instanceof Function + return tagType instanceof Function ? this.summonData.tags.find(t => t instanceof tagType) - : this.summonData.tags.find(t => t.tagType === tagType) - ); + : this.summonData.tags.find(t => t.tagType === tagType); } - findTag(tagFilter: ((tag: BattlerTag) => boolean)) { + findTag(tagFilter: (tag: BattlerTag) => boolean) { if (!this.summonData) { return null; } return this.summonData.tags.find(t => tagFilter(t)); } - findTags(tagFilter: ((tag: BattlerTag) => boolean)): BattlerTag[] { + findTags(tagFilter: (tag: BattlerTag) => boolean): BattlerTag[] { if (!this.summonData) { return []; } @@ -3295,7 +4815,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } const tags = this.summonData.tags; const tag = tags.find(t => t.tagType === tagType); - if (tag && !(tag.lapse(this, BattlerTagLapseType.CUSTOM))) { + if (tag && !tag.lapse(this, BattlerTagLapseType.CUSTOM)) { tag.onRemove(this); tags.splice(tags.indexOf(tag), 1); } @@ -3307,10 +4827,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return; } const tags = this.summonData.tags; - tags.filter(t => lapseType === BattlerTagLapseType.FAINT || ((t.lapseTypes.some(lType => lType === lapseType)) && !(t.lapse(this, lapseType)))).forEach(t => { - t.onRemove(this); - tags.splice(tags.indexOf(t), 1); - }); + tags + .filter( + t => + lapseType === BattlerTagLapseType.FAINT || + (t.lapseTypes.some(lType => lType === lapseType) && + !t.lapse(this, lapseType)), + ) + .forEach(t => { + t.onRemove(this); + tags.splice(tags.indexOf(t), 1); + }); } removeTag(tagType: BattlerTagType): boolean { @@ -3326,7 +4853,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return !!tag; } - findAndRemoveTags(tagFilter: ((tag: BattlerTag) => boolean)): boolean { + findAndRemoveTags(tagFilter: (tag: BattlerTag) => boolean): boolean { if (!this.summonData) { return false; } @@ -3349,7 +4876,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return; } const tags = this.summonData.tags; - tags.filter(t => t.sourceId === sourceId).forEach(t => t.sourceId = newSourceId); + tags + .filter(t => t.sourceId === sourceId) + .forEach(t => (t.sourceId = newSourceId)); } /** @@ -3360,14 +4889,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Copy all stat stages for (const s of BATTLE_STATS) { const sourceStage = source.getStatStage(s); - if ((this instanceof PlayerPokemon) && (sourceStage === 6)) { + if (this instanceof PlayerPokemon && sourceStage === 6) { globalScene.validateAchv(achvs.TRANSFER_MAX_STAT_STAGE); } this.setStatStage(s, sourceStage); } for (const tag of source.summonData.tags) { - if (!tag.isBatonPassable || (tag.tagType === BattlerTagType.TELEKINESIS && this.species.speciesId === Species.GENGAR && this.getFormKey() === "mega")) { + if ( + !tag.isBatonPassable || + (tag.tagType === BattlerTagType.TELEKINESIS && + this.species.speciesId === Species.GENGAR && + this.getFormKey() === "mega") + ) { continue; } @@ -3404,10 +4938,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * * @see {@linkcode MoveRestrictionBattlerTag} */ - isMoveTargetRestricted(moveId: Moves, user: Pokemon, target: Pokemon): boolean { - for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) { - if ((tag as MoveRestrictionBattlerTag).isMoveTargetRestricted(moveId, user, target)) { - return (tag as MoveRestrictionBattlerTag !== null); + isMoveTargetRestricted( + moveId: Moves, + user: Pokemon, + target: Pokemon, + ): boolean { + for (const tag of this.findTags( + t => t instanceof MoveRestrictionBattlerTag, + )) { + if ( + (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted( + moveId, + user, + target, + ) + ) { + return (tag as MoveRestrictionBattlerTag) !== null; } } return false; @@ -3421,11 +4967,26 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param {Pokemon} target {@linkcode Pokemon} the target of the move, optional and used when the target is a factor in the move's restricted status * @returns {MoveRestrictionBattlerTag | null} the first tag on this Pokemon that restricts the move, or `null` if the move is not restricted. */ - getRestrictingTag(moveId: Moves, user?: Pokemon, target?: Pokemon): MoveRestrictionBattlerTag | null { - for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) { + getRestrictingTag( + moveId: Moves, + user?: Pokemon, + target?: Pokemon, + ): MoveRestrictionBattlerTag | null { + for (const tag of this.findTags( + t => t instanceof MoveRestrictionBattlerTag, + )) { if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId, user)) { return tag as MoveRestrictionBattlerTag; - } else if (user && target && (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted(moveId, user, target)) { + } + if ( + user && + target && + (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted( + moveId, + user, + target, + ) + ) { return tag as MoveRestrictionBattlerTag; } } @@ -3452,13 +5013,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Default is `1`. * @returns A list of {@linkcode TurnMove}, as specified above. */ - getLastXMoves(moveCount: number = 1): TurnMove[] { + getLastXMoves(moveCount = 1): TurnMove[] { const moveHistory = this.getMoveHistory(); if (moveCount >= 0) { - return moveHistory.slice(Math.max(moveHistory.length - moveCount, 0)).reverse(); - } else { - return moveHistory.slice(0).reverse(); + return moveHistory + .slice(Math.max(moveHistory.length - moveCount, 0)) + .reverse(); } + return moveHistory.slice(0).reverse(); } getMoveQueue(): TurnMove[] { @@ -3471,17 +5033,24 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { */ stopMultiHit(target?: Pokemon): void { const effectPhase = globalScene.getCurrentPhase(); - if (effectPhase instanceof MoveEffectPhase && effectPhase.getUserPokemon() === this) { + if ( + effectPhase instanceof MoveEffectPhase && + effectPhase.getUserPokemon() === this + ) { effectPhase.stopMultiHit(target); } } changeForm(formChange: SpeciesFormChange): Promise { return new Promise(resolve => { - this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); + this.formIndex = Math.max( + this.species.forms.findIndex(f => f.formKey === formChange.formKey), + 0, + ); this.generateName(); const abilityCount = this.getSpeciesForm().getAbilityCount(); - if (this.abilityIndex >= abilityCount) {// Shouldn't happen + if (this.abilityIndex >= abilityCount) { + // Shouldn't happen this.abilityIndex = abilityCount - 1; } globalScene.gameData.setPokemonSeen(this, false); @@ -3489,24 +5058,47 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.loadAssets().then(() => { this.calculateStats(); globalScene.updateModifiers(this.isPlayer(), true); - Promise.all([ this.updateInfo(), globalScene.updateFieldScale() ]).then(() => resolve()); + Promise.all([this.updateInfo(), globalScene.updateFieldScale()]).then( + () => resolve(), + ); }); }); } - cry(soundConfig?: Phaser.Types.Sound.SoundConfig, sceneOverride?: BattleScene): AnySound { + cry( + soundConfig?: Phaser.Types.Sound.SoundConfig, + sceneOverride?: BattleScene, + ): AnySound { const scene = sceneOverride ?? globalScene; // TODO: is `sceneOverride` needed? const cry = this.getSpeciesForm().cry(soundConfig); let duration = cry.totalDuration * 1000; - if (this.fusionSpecies && this.getSpeciesForm() !== this.getFusionSpeciesForm()) { + if ( + this.fusionSpecies && + this.getSpeciesForm() !== this.getFusionSpeciesForm() + ) { let fusionCry = this.getFusionSpeciesForm().cry(soundConfig, true); duration = Math.min(duration, fusionCry.totalDuration * 1000); fusionCry.destroy(); scene.time.delayedCall(Utils.fixedInt(Math.ceil(duration * 0.4)), () => { try { - SoundFade.fadeOut(scene, cry, Utils.fixedInt(Math.ceil(duration * 0.2))); - fusionCry = this.getFusionSpeciesForm().cry(Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, soundConfig)); - SoundFade.fadeIn(scene, fusionCry, Utils.fixedInt(Math.ceil(duration * 0.2)), scene.masterVolume * scene.fieldVolume, 0); + SoundFade.fadeOut( + scene, + cry, + Utils.fixedInt(Math.ceil(duration * 0.2)), + ); + fusionCry = this.getFusionSpeciesForm().cry( + Object.assign( + { seek: Math.max(fusionCry.totalDuration * 0.4, 0) }, + soundConfig, + ), + ); + SoundFade.fadeIn( + scene, + fusionCry, + Utils.fixedInt(Math.ceil(duration * 0.2)), + scene.masterVolume * scene.fieldVolume, + 0, + ); } catch (err) { console.error(err); } @@ -3516,8 +5108,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return cry; } + // biome-ignore lint: there are a ton of issues.. faintCry(callback: Function): void { - if (this.fusionSpecies && this.getSpeciesForm() !== this.getFusionSpeciesForm()) { + if ( + this.fusionSpecies && + this.getSpeciesForm() !== this.getFusionSpeciesForm() + ) { return this.fusionFaintCry(callback); } @@ -3537,31 +5133,32 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { sprite.anims.pause(); tintSprite?.anims.pause(); - let faintCryTimer : Phaser.Time.TimerEvent | null = globalScene.time.addEvent({ - delay: Utils.fixedInt(delay), - repeat: -1, - callback: () => { - frameThreshold = sprite.anims.msPerFrame / rate; - frameProgress += delay; - while (frameProgress > frameThreshold) { - if (sprite.anims.duration) { - sprite.anims.nextFrame(); - tintSprite?.anims.nextFrame(); + let faintCryTimer: Phaser.Time.TimerEvent | null = + globalScene.time.addEvent({ + delay: Utils.fixedInt(delay), + repeat: -1, + callback: () => { + frameThreshold = sprite.anims.msPerFrame / rate; + frameProgress += delay; + while (frameProgress > frameThreshold) { + if (sprite.anims.duration) { + sprite.anims.nextFrame(); + tintSprite?.anims.nextFrame(); + } + frameProgress -= frameThreshold; } - frameProgress -= frameThreshold; - } - if (cry && !cry.pendingRemove) { - rate *= 0.99; - cry.setRate(rate); - } else { - faintCryTimer?.destroy(); - faintCryTimer = null; - if (callback) { - callback(); + if (cry && !cry.pendingRemove) { + rate *= 0.99; + cry.setRate(rate); + } else { + faintCryTimer?.destroy(); + faintCryTimer = null; + if (callback) { + callback(); + } } - } - } - }); + }, + }); // Failsafe globalScene.time.delayedCall(Utils.fixedInt(3000), () => { @@ -3578,6 +5175,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { }); } + // biome-ignore lint/complexity/noBannedTypes: Consider refactoring to change type of Function private fusionFaintCry(callback: Function): void { const key = this.species.getCryKey(this.formIndex); let i = 0; @@ -3588,7 +5186,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { let duration = cry.totalDuration * 1000; const fusionCryKey = this.fusionSpecies!.getCryKey(this.fusionFormIndex); - let fusionCry = globalScene.playSound(fusionCryKey, { rate: rate }) as AnySound; + let fusionCry = globalScene.playSound(fusionCryKey, { + rate: rate, + }) as AnySound; if (!cry || !fusionCry || globalScene.fieldVolume === 0) { return callback(); } @@ -3618,41 +5218,61 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { sprite.anims.pause(); tintSprite?.anims.pause(); - let faintCryTimer: Phaser.Time.TimerEvent | null = globalScene.time.addEvent({ - delay: Utils.fixedInt(delay), - repeat: -1, - callback: () => { - ++i; - frameThreshold = sprite.anims.msPerFrame / rate; - frameProgress += delay; - while (frameProgress > frameThreshold) { - if (sprite.anims.duration) { - sprite.anims.nextFrame(); - tintSprite?.anims.nextFrame(); + let faintCryTimer: Phaser.Time.TimerEvent | null = + globalScene.time.addEvent({ + delay: Utils.fixedInt(delay), + repeat: -1, + callback: () => { + ++i; + frameThreshold = sprite.anims.msPerFrame / rate; + frameProgress += delay; + while (frameProgress > frameThreshold) { + if (sprite.anims.duration) { + sprite.anims.nextFrame(); + tintSprite?.anims.nextFrame(); + } + frameProgress -= frameThreshold; } - frameProgress -= frameThreshold; - } - if (i === transitionIndex && fusionCryKey) { - SoundFade.fadeOut(globalScene, cry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2))); - fusionCry = globalScene.playSound(fusionCryKey, Object.assign({ seek: Math.max(fusionCry.totalDuration * 0.4, 0), rate: rate })); - SoundFade.fadeIn(globalScene, fusionCry, Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), globalScene.masterVolume * globalScene.fieldVolume, 0); - } - rate *= 0.99; - if (cry && !cry.pendingRemove) { - cry.setRate(rate); - } - if (fusionCry && !fusionCry.pendingRemove) { - fusionCry.setRate(rate); - } - if ((!cry || cry.pendingRemove) && (!fusionCry || fusionCry.pendingRemove)) { - faintCryTimer?.destroy(); - faintCryTimer = null; - if (callback) { - callback(); + if (i === transitionIndex && fusionCryKey) { + SoundFade.fadeOut( + globalScene, + cry, + Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), + ); + fusionCry = globalScene.playSound( + fusionCryKey, + Object.assign({ + seek: Math.max(fusionCry.totalDuration * 0.4, 0), + rate: rate, + }), + ); + SoundFade.fadeIn( + globalScene, + fusionCry, + Utils.fixedInt(Math.ceil((duration / rate) * 0.2)), + globalScene.masterVolume * globalScene.fieldVolume, + 0, + ); } - } - } - }); + rate *= 0.99; + if (cry && !cry.pendingRemove) { + cry.setRate(rate); + } + if (fusionCry && !fusionCry.pendingRemove) { + fusionCry.setRate(rate); + } + if ( + (!cry || cry.pendingRemove) && + (!fusionCry || fusionCry.pendingRemove) + ) { + faintCryTimer?.destroy(); + faintCryTimer = null; + if (callback) { + callback(); + } + } + }, + }); // Failsafe globalScene.time.delayedCall(Utils.fixedInt(3000), () => { @@ -3673,7 +5293,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } isOppositeGender(pokemon: Pokemon): boolean { - return this.gender !== Gender.GENDERLESS && pokemon.gender === (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE); + return ( + this.gender !== Gender.GENDERLESS && + pokemon.gender === + (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE) + ); } /** @@ -3685,17 +5309,31 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param sourcePokemon The Pokemon that is setting the status effect * @param ignoreField Whether any field effects (weather, terrain, etc.) should be considered */ - canSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null, ignoreField: boolean = false): boolean { + canSetStatus( + effect: StatusEffect | undefined, + quiet = false, + overrideStatus = false, + sourcePokemon: Pokemon | null = null, + ignoreField = false, + ): boolean { if (effect !== StatusEffect.FAINT) { if (overrideStatus ? this.status?.effect === effect : this.status) { return false; } - if (this.isGrounded() && (!ignoreField && globalScene.arena.terrain?.terrainType === TerrainType.MISTY)) { + if ( + this.isGrounded() && + !ignoreField && + globalScene.arena.terrain?.terrainType === TerrainType.MISTY + ) { return false; } } - if (sourcePokemon && sourcePokemon !== this && this.isSafeguarded(sourcePokemon)) { + if ( + sourcePokemon && + sourcePokemon !== this && + this.isSafeguarded(sourcePokemon) + ) { return false; } @@ -3704,9 +5342,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { switch (effect) { case StatusEffect.POISON: case StatusEffect.TOXIC: - // Check if the Pokemon is immune to Poison/Toxic or if the source pokemon is canceling the immunity + // Check if the Pokemon is immune to Poison/Toxic or if the source pokemon is canceling the immunity const poisonImmunity = types.map(defType => { - // Check if the Pokemon is not immune to Poison/Toxic + // Check if the Pokemon is not immune to Poison/Toxic if (defType !== PokemonType.POISON && defType !== PokemonType.STEEL) { return false; } @@ -3714,7 +5352,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Check if the source Pokemon has an ability that cancels the Poison/Toxic immunity const cancelImmunity = new Utils.BooleanHolder(false); if (sourcePokemon) { - applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, false, effect, defType); + applyAbAttrs( + IgnoreTypeStatusEffectImmunityAbAttr, + sourcePokemon, + cancelImmunity, + false, + effect, + defType, + ); if (cancelImmunity.value) { return false; } @@ -3735,12 +5380,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } break; case StatusEffect.SLEEP: - if (this.isGrounded() && globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC) { + if ( + this.isGrounded() && + globalScene.arena.terrain?.terrainType === TerrainType.ELECTRIC + ) { return false; } break; case StatusEffect.FREEZE: - if (this.isOfType(PokemonType.ICE) || (!ignoreField && (globalScene?.arena?.weather?.weatherType && [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(globalScene.arena.weather.weatherType)))) { + if ( + this.isOfType(PokemonType.ICE) || + (!ignoreField && + globalScene?.arena?.weather?.weatherType && + [WeatherType.SUNNY, WeatherType.HARSH_SUN].includes( + globalScene.arena.weather.weatherType, + )) + ) { return false; } break; @@ -3752,10 +5407,24 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } const cancelled = new Utils.BooleanHolder(false); - applyPreSetStatusAbAttrs(StatusEffectImmunityAbAttr, this, effect, cancelled, quiet); + applyPreSetStatusAbAttrs( + StatusEffectImmunityAbAttr, + this, + effect, + cancelled, + quiet, + ); const userField = this.getAlliedField(); - userField.forEach(pokemon => applyPreSetStatusAbAttrs(UserFieldStatusEffectImmunityAbAttr, pokemon, effect, cancelled, quiet)); + userField.forEach(pokemon => + applyPreSetStatusAbAttrs( + UserFieldStatusEffectImmunityAbAttr, + pokemon, + effect, + cancelled, + quiet, + ), + ); if (cancelled.value) { return false; @@ -3764,7 +5433,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return true; } - trySetStatus(effect?: StatusEffect, asPhase: boolean = false, sourcePokemon: Pokemon | null = null, turnsRemaining: number = 0, sourceText: string | null = null): boolean { + trySetStatus( + effect?: StatusEffect, + asPhase = false, + sourcePokemon: Pokemon | null = null, + turnsRemaining = 0, + sourceText: string | null = null, + ): boolean { if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) { return false; } @@ -3781,7 +5456,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (asPhase) { - globalScene.unshiftPhase(new ObtainStatusEffectPhase(this.getBattlerIndex(), effect, turnsRemaining, sourceText, sourcePokemon)); + globalScene.unshiftPhase( + new ObtainStatusEffectPhase( + this.getBattlerIndex(), + effect, + turnsRemaining, + sourceText, + sourcePokemon, + ), + ); return true; } @@ -3797,10 +5480,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { BattlerTagType.UNDERGROUND, BattlerTagType.UNDERWATER, BattlerTagType.HIDDEN, - BattlerTagType.FLYING + BattlerTagType.FLYING, ]; - const tag = invulnerableTags.find((t) => this.getTag(t)); + const tag = invulnerableTags.find(t => this.getTag(t)); if (tag) { this.removeTag(tag); @@ -3813,20 +5496,29 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.status = new Status(effect, 0, sleepTurnsRemaining?.value); if (effect !== StatusEffect.FAINT) { - globalScene.triggerPokemonFormChange(this, SpeciesFormChangeStatusEffectTrigger, true); - applyPostSetStatusAbAttrs(PostSetStatusAbAttr, this, effect, sourcePokemon); + globalScene.triggerPokemonFormChange( + this, + SpeciesFormChangeStatusEffectTrigger, + true, + ); + applyPostSetStatusAbAttrs( + PostSetStatusAbAttr, + this, + effect, + sourcePokemon, + ); } return true; } /** - * Resets the status of a pokemon. - * @param revive Whether revive should be cured; defaults to true. - * @param confusion Whether resetStatus should include confusion or not; defaults to false. - * @param reloadAssets Whether to reload the assets or not; defaults to false. - */ - resetStatus(revive: boolean = true, confusion: boolean = false, reloadAssets: boolean = false): void { + * Resets the status of a pokemon. + * @param revive Whether revive should be cured; defaults to true. + * @param confusion Whether resetStatus should include confusion or not; defaults to false. + * @param reloadAssets Whether to reload the assets or not; defaults to false. + */ + resetStatus(revive = true, confusion = false, reloadAssets = false): void { const lastStatus = this.status?.effect; if (!revive && lastStatus === StatusEffect.FAINT) { return; @@ -3854,7 +5546,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns `true` if this Pokemon is protected by Safeguard; `false` otherwise. */ isSafeguarded(attacker: Pokemon): boolean { - const defendingSide = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; + const defendingSide = this.isPlayer() + ? ArenaTagSide.PLAYER + : ArenaTagSide.ENEMY; if (globalScene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, defendingSide)) { const bypassed = new Utils.BooleanHolder(false); if (attacker) { @@ -3888,14 +5582,19 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } // If this Pokemon has a Substitute when loading in, play an animation to add its sprite if (this.getTag(SubstituteTag)) { - globalScene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD); + globalScene.triggerPokemonBattleAnim( + this, + PokemonAnimType.SUBSTITUTE_ADD, + ); this.getTag(SubstituteTag)!.sourceInFocus = false; } // If this Pokemon has Commander and Dondozo as an active ally, hide this Pokemon's sprite. - if (this.hasAbilityWithAttr(CommanderAbAttr) - && globalScene.currentBattle.double - && this.getAlly()?.species.speciesId === Species.DONDOZO) { + if ( + this.hasAbilityWithAttr(CommanderAbAttr) && + globalScene.currentBattle.double && + this.getAlly()?.species.speciesId === Species.DONDOZO + ) { this.setVisible(false); } this.summonDataPrimer = null; @@ -3913,7 +5612,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.lapseTag(BattlerTagType.SEEDED); } if (globalScene) { - globalScene.triggerPokemonFormChange(this, SpeciesFormChangePostMoveTrigger, true); + globalScene.triggerPokemonFormChange( + this, + SpeciesFormChangePostMoveTrigger, + true, + ); } } @@ -3923,7 +5626,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.stellarTypesBoosted = []; if (wasTerastallized) { this.updateSpritePipelineData(); - globalScene.triggerPokemonFormChange(this, SpeciesFormChangeLapseTeraTrigger); + globalScene.triggerPokemonFormChange( + this, + SpeciesFormChangeLapseTeraTrigger, + ); } } @@ -3933,7 +5639,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getExpValue(): number { // Logic to factor in victor level has been removed for balancing purposes, so the player doesn't have to focus on EXP maxxing - return ((this.getSpeciesForm().getBaseExp() * this.level) / 5 + 1); + return (this.getSpeciesForm().getBaseExp() * this.level) / 5 + 1; } setFrameRate(frameRate: number) { @@ -3941,12 +5647,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { try { this.getSprite().play(this.getBattleSpriteKey()); } catch (err: unknown) { - console.error(`Failed to play animation for ${this.getBattleSpriteKey()}`, err); + console.error( + `Failed to play animation for ${this.getBattleSpriteKey()}`, + err, + ); } try { this.getTintSprite()?.play(this.getBattleSpriteKey()); } catch (err: unknown) { - console.error(`Failed to play animation for ${this.getBattleSpriteKey()}`, err); + console.error( + `Failed to play animation for ${this.getBattleSpriteKey()}`, + err, + ); } } @@ -3962,7 +5674,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { targets: tintSprite, alpha: alpha || 1, duration: duration, - ease: ease || "Linear" + ease: ease || "Linear", }); } else { tintSprite?.setAlpha(alpha); @@ -3981,7 +5693,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { onComplete: () => { tintSprite?.setVisible(false); tintSprite?.setAlpha(1); - } + }, }); } else { tintSprite?.setVisible(false); @@ -3993,9 +5705,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (!this.maskEnabled) { this.maskSprite = this.getTintSprite(); this.maskSprite?.setVisible(true); - this.maskSprite?.setPosition(this.x * this.parentContainer.scale + this.parentContainer.x, - this.y * this.parentContainer.scale + this.parentContainer.y); - this.maskSprite?.setScale(this.getSpriteScale() * this.parentContainer.scale); + this.maskSprite?.setPosition( + this.x * this.parentContainer.scale + this.parentContainer.x, + this.y * this.parentContainer.scale + this.parentContainer.y, + ); + this.maskSprite?.setScale( + this.getSpriteScale() * this.parentContainer.scale, + ); this.maskEnabled = true; } } @@ -4018,28 +5734,68 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { updateFusionPalette(ignoreOveride?: boolean): void { if (!this.getFusionSpeciesForm(ignoreOveride)) { - [ this.getSprite(), this.getTintSprite() ].filter(s => !!s).map(s => { - s.pipelineData[`spriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}`] = []; - s.pipelineData[`fusionSpriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}`] = []; - }); + [this.getSprite(), this.getTintSprite()] + .filter(s => !!s) + .map(s => { + s.pipelineData[ + `spriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}` + ] = []; + s.pipelineData[ + `fusionSpriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}` + ] = []; + }); return; } const speciesForm = this.getSpeciesForm(ignoreOveride); const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOveride); - const spriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.formIndex, this.shiny, this.variant); - const backSpriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.formIndex, this.shiny, this.variant).replace("pkmn__", "pkmn__back__"); - const fusionSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.formIndex, this.fusionShiny, this.fusionVariant); - const fusionBackSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.formIndex, this.fusionShiny, this.fusionVariant).replace("pkmn__", "pkmn__back__"); + const spriteKey = speciesForm.getSpriteKey( + this.getGender(ignoreOveride) === Gender.FEMALE, + speciesForm.formIndex, + this.shiny, + this.variant, + ); + const backSpriteKey = speciesForm + .getSpriteKey( + this.getGender(ignoreOveride) === Gender.FEMALE, + speciesForm.formIndex, + this.shiny, + this.variant, + ) + .replace("pkmn__", "pkmn__back__"); + const fusionSpriteKey = fusionSpeciesForm.getSpriteKey( + this.getFusionGender(ignoreOveride) === Gender.FEMALE, + fusionSpeciesForm.formIndex, + this.fusionShiny, + this.fusionVariant, + ); + const fusionBackSpriteKey = fusionSpeciesForm + .getSpriteKey( + this.getFusionGender(ignoreOveride) === Gender.FEMALE, + fusionSpeciesForm.formIndex, + this.fusionShiny, + this.fusionVariant, + ) + .replace("pkmn__", "pkmn__back__"); const sourceTexture = globalScene.textures.get(spriteKey); const sourceBackTexture = globalScene.textures.get(backSpriteKey); const fusionTexture = globalScene.textures.get(fusionSpriteKey); const fusionBackTexture = globalScene.textures.get(fusionBackSpriteKey); - const [ sourceFrame, sourceBackFrame, fusionFrame, fusionBackFrame ] = [ sourceTexture, sourceBackTexture, fusionTexture, fusionBackTexture ].map(texture => texture.frames[texture.firstFrame]); - const [ sourceImage, sourceBackImage, fusionImage, fusionBackImage ] = [ sourceTexture, sourceBackTexture, fusionTexture, fusionBackTexture ].map(i => i.getSourceImage() as HTMLImageElement); + const [sourceFrame, sourceBackFrame, fusionFrame, fusionBackFrame] = [ + sourceTexture, + sourceBackTexture, + fusionTexture, + fusionBackTexture, + ].map(texture => texture.frames[texture.firstFrame]); + const [sourceImage, sourceBackImage, fusionImage, fusionBackImage] = [ + sourceTexture, + sourceBackTexture, + fusionTexture, + fusionBackTexture, + ].map(i => i.getSourceImage() as HTMLImageElement); const canvas = document.createElement("canvas"); const backCanvas = document.createElement("canvas"); @@ -4049,43 +5805,70 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const spriteColors: number[][] = []; const pixelData: Uint8ClampedArray[] = []; - [ canvas, backCanvas, fusionCanvas, fusionBackCanvas ].forEach((canv: HTMLCanvasElement, c: number) => { - const context = canv.getContext("2d"); - const frame = [ sourceFrame, sourceBackFrame, fusionFrame, fusionBackFrame ][c]; - canv.width = frame.width; - canv.height = frame.height; + [canvas, backCanvas, fusionCanvas, fusionBackCanvas].forEach( + (canv: HTMLCanvasElement, c: number) => { + const context = canv.getContext("2d"); + const frame = [ + sourceFrame, + sourceBackFrame, + fusionFrame, + fusionBackFrame, + ][c]; + canv.width = frame.width; + canv.height = frame.height; - if (context) { - context.drawImage([ sourceImage, sourceBackImage, fusionImage, fusionBackImage ][c], frame.cutX, frame.cutY, frame.width, frame.height, 0, 0, frame.width, frame.height); - const imageData = context.getImageData(frame.cutX, frame.cutY, frame.width, frame.height); - pixelData.push(imageData.data); - } - }); + if (context) { + context.drawImage( + [sourceImage, sourceBackImage, fusionImage, fusionBackImage][c], + frame.cutX, + frame.cutY, + frame.width, + frame.height, + 0, + 0, + frame.width, + frame.height, + ); + const imageData = context.getImageData( + frame.cutX, + frame.cutY, + frame.width, + frame.height, + ); + pixelData.push(imageData.data); + } + }, + ); for (let f = 0; f < 2; f++) { const variantColors = variantColorCache[!f ? spriteKey : backSpriteKey]; const variantColorSet = new Map(); if (this.shiny && variantColors && variantColors[this.variant]) { Object.keys(variantColors[this.variant]).forEach(k => { - variantColorSet.set(Utils.rgbaToInt(Array.from(Object.values(Utils.rgbHexToRgba(k)))), Array.from(Object.values(Utils.rgbHexToRgba(variantColors[this.variant][k])))); + variantColorSet.set( + Utils.rgbaToInt(Array.from(Object.values(Utils.rgbHexToRgba(k)))), + Array.from( + Object.values(Utils.rgbHexToRgba(variantColors[this.variant][k])), + ), + ); }); } for (let i = 0; i < pixelData[f].length; i += 4) { if (pixelData[f][i + 3]) { const pixel = pixelData[f].slice(i, i + 4); - let [ r, g, b, a ] = pixel; + let [r, g, b, a] = pixel; if (variantColors) { - const color = Utils.rgbaToInt([ r, g, b, a ]); + const color = Utils.rgbaToInt([r, g, b, a]); if (variantColorSet.has(color)) { const mappedPixel = variantColorSet.get(color); if (mappedPixel) { - [ r, g, b, a ] = mappedPixel; + [r, g, b, a] = mappedPixel; } } } if (!spriteColors.find(c => c[0] === r && c[1] === g && c[2] === b)) { - spriteColors.push([ r, g, b, a ]); + spriteColors.push([r, g, b, a]); } } } @@ -4096,35 +5879,63 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const pixelColors: number[] = []; for (let f = 0; f < 2; f++) { for (let i = 0; i < pixelData[f].length; i += 4) { - const total = pixelData[f].slice(i, i + 3).reduce((total: number, value: number) => total + value, 0); + const total = pixelData[f] + .slice(i, i + 3) + .reduce((total: number, value: number) => total + value, 0); if (!total) { continue; } - pixelColors.push(argbFromRgba({ r: pixelData[f][i], g: pixelData[f][i + 1], b: pixelData[f][i + 2], a: pixelData[f][i + 3] })); + pixelColors.push( + argbFromRgba({ + r: pixelData[f][i], + g: pixelData[f][i + 1], + b: pixelData[f][i + 2], + a: pixelData[f][i + 3], + }), + ); } } - const fusionPixelColors : number[] = []; + const fusionPixelColors: number[] = []; for (let f = 0; f < 2; f++) { - const variantColors = variantColorCache[!f ? fusionSpriteKey : fusionBackSpriteKey]; + const variantColors = + variantColorCache[!f ? fusionSpriteKey : fusionBackSpriteKey]; const variantColorSet = new Map(); - if (this.fusionShiny && variantColors && variantColors[this.fusionVariant]) { - Object.keys(variantColors[this.fusionVariant]).forEach(k => { - variantColorSet.set(Utils.rgbaToInt(Array.from(Object.values(Utils.rgbHexToRgba(k)))), Array.from(Object.values(Utils.rgbHexToRgba(variantColors[this.fusionVariant][k])))); - }); + if ( + this.fusionShiny && + variantColors && + variantColors[this.fusionVariant] + ) { + for (const k of Object.keys(variantColors[this.fusionVariant])) { + variantColorSet.set( + Utils.rgbaToInt(Array.from(Object.values(Utils.rgbHexToRgba(k)))), + Array.from( + Object.values( + Utils.rgbHexToRgba(variantColors[this.fusionVariant][k]), + ), + ), + ); + } } for (let i = 0; i < pixelData[2 + f].length; i += 4) { - const total = pixelData[2 + f].slice(i, i + 3).reduce((total: number, value: number) => total + value, 0); + const total = pixelData[2 + f] + .slice(i, i + 3) + .reduce((total: number, value: number) => total + value, 0); if (!total) { continue; } - let [ r, g, b, a ] = [ pixelData[2 + f][i], pixelData[2 + f][i + 1], pixelData[2 + f][i + 2], pixelData[2 + f][i + 3] ]; + let [r, g, b, a] = [ + pixelData[2 + f][i], + pixelData[2 + f][i + 1], + pixelData[2 + f][i + 2], + pixelData[2 + f][i + 3], + ]; if (variantColors) { - const color = Utils.rgbaToInt([ r, g, b, a ]); + const color = Utils.rgbaToInt([r, g, b, a]); if (variantColorSet.has(color)) { const mappedPixel = variantColorSet.get(color); if (mappedPixel) { - [ r, g, b, a ] = mappedPixel; + [r, g, b, a] = mappedPixel; } } } @@ -4132,7 +5943,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - if (fusionPixelColors.length === 0) { // ERROR HANDLING IS NOT OPTIONAL BUDDY + if (fusionPixelColors.length === 0) { + // ERROR HANDLING IS NOT OPTIONAL BUDDY console.log("Failed to create fusion palette"); return; } @@ -4143,18 +5955,25 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const originalRandom = Math.random; Math.random = () => Phaser.Math.RND.realInRange(0, 1); - globalScene.executeWithSeedOffset(() => { - paletteColors = QuantizerCelebi.quantize(pixelColors, 4); - fusionPaletteColors = QuantizerCelebi.quantize(fusionPixelColors, 4); - }, 0, "This result should not vary"); + globalScene.executeWithSeedOffset( + () => { + paletteColors = QuantizerCelebi.quantize(pixelColors, 4); + fusionPaletteColors = QuantizerCelebi.quantize(fusionPixelColors, 4); + }, + 0, + "This result should not vary", + ); Math.random = originalRandom; paletteColors = paletteColors!; // erroneously tell TS compiler that paletteColors is defined! fusionPaletteColors = fusionPaletteColors!; // mischievously misinform TS compiler that fusionPaletteColors is defined! - const [ palette, fusionPalette ] = [ paletteColors, fusionPaletteColors ] - .map(paletteColors => { - let keys = Array.from(paletteColors.keys()).sort((a: number, b: number) => paletteColors.get(a)! < paletteColors.get(b)! ? 1 : -1); + const [palette, fusionPalette] = [paletteColors, fusionPaletteColors].map( + paletteColors => { + let keys = Array.from(paletteColors.keys()).sort( + (a: number, b: number) => + paletteColors.get(a)! < paletteColors.get(b)! ? 1 : -1, + ); let rgbaColors: Map; let hsvColors: Map; @@ -4164,13 +5983,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { mappedColors.clear(); rgbaColors = keys.reduce((map: Map, k: number) => { - map.set(k, Object.values(rgbaFromArgb(k))); return map; - }, new Map()); - hsvColors = Array.from(rgbaColors.keys()).reduce((map: Map, k: number) => { - const rgb = rgbaColors.get(k)!.slice(0, 3); - map.set(k, Utils.rgbToHsv(rgb[0], rgb[1], rgb[2])); + map.set(k, Object.values(rgbaFromArgb(k))); return map; }, new Map()); + hsvColors = Array.from(rgbaColors.keys()).reduce( + (map: Map, k: number) => { + const rgb = rgbaColors.get(k)!.slice(0, 3); + map.set(k, Utils.rgbToHsv(rgb[0], rgb[1], rgb[2])); + return map; + }, + new Map(), + ); for (let c = keys.length - 1; c >= 0; c--) { const hsv = hsvColors.get(keys[c])!; @@ -4181,7 +6004,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (mappedColors.has(keys[c])) { mappedColors.get(keys[c])!.push(keys[c2]); } else { - mappedColors.set(keys[c], [ keys[c2] ]); + mappedColors.set(keys[c], [keys[c2]]); } break; } @@ -4202,7 +6025,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } for (let c = 0; c < 3; c++) { - color[c] *= (paletteColors.get(key)! / count); + color[c] *= paletteColors.get(key)! / count; values.forEach((value: number, i: number) => { if (paletteColors.has(value)) { const valueCount = paletteColors.get(value)!; @@ -4220,15 +6043,26 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - paletteColors.set(argbFromRgba({ r: color[0], g: color[1], b: color[2], a: color[3] }), count); + paletteColors.set( + argbFromRgba({ + r: color[0], + g: color[1], + b: color[2], + a: color[3], + }), + count, + ); }); - keys = Array.from(paletteColors.keys()).sort((a: number, b: number) => paletteColors.get(a)! < paletteColors.get(b)! ? 1 : -1); + keys = Array.from(paletteColors.keys()).sort( + (a: number, b: number) => + paletteColors.get(a)! < paletteColors.get(b)! ? 1 : -1, + ); } while (mappedColors.size); return keys.map(c => Object.values(rgbaFromArgb(c))); - } - ); + }, + ); const paletteDeltas: number[][] = []; @@ -4243,21 +6077,33 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { for (let sc = 0; sc < spriteColors.length; sc++) { const delta = Math.min(...paletteDeltas[sc]); - const paletteIndex = Math.min(paletteDeltas[sc].findIndex(pd => pd === delta), fusionPalette.length - 1); + const paletteIndex = Math.min( + paletteDeltas[sc].findIndex(pd => pd === delta), + fusionPalette.length - 1, + ); if (delta < 255) { const ratio = easeFunc(delta / 255); - const color = [ 0, 0, 0, fusionSpriteColors[sc][3] ]; + const color = [0, 0, 0, fusionSpriteColors[sc][3]]; for (let c = 0; c < 3; c++) { - color[c] = Math.round((fusionSpriteColors[sc][c] * ratio) + (fusionPalette[paletteIndex][c] * (1 - ratio))); + color[c] = Math.round( + fusionSpriteColors[sc][c] * ratio + + fusionPalette[paletteIndex][c] * (1 - ratio), + ); } fusionSpriteColors[sc] = color; } } - [ this.getSprite(), this.getTintSprite() ].filter(s => !!s).map(s => { - s.pipelineData[`spriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}`] = spriteColors; - s.pipelineData[`fusionSpriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}`] = fusionSpriteColors; - }); + [this.getSprite(), this.getTintSprite()] + .filter(s => !!s) + .map(s => { + s.pipelineData[ + `spriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}` + ] = spriteColors; + s.pipelineData[ + `fusionSpriteColors${ignoreOveride && this.summonData?.speciesForm ? "Base" : ""}` + ] = fusionSpriteColors; + }); canvas.remove(); fusionCanvas.remove(); @@ -4275,7 +6121,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param min The minimum integer to pick, default `0` * @returns A random integer between {@linkcode min} and ({@linkcode min} + {@linkcode range} - 1) */ - randSeedInt(range: number, min: number = 0): number { + randSeedInt(range: number, min = 0): number { return globalScene.currentBattle ? globalScene.randBattleSeedInt(range, min) : Utils.randSeedInt(range, min); @@ -4288,7 +6134,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns a random integer between {@linkcode min} and {@linkcode max} inclusive */ randSeedIntRange(min: number, max: number): number { - return this.randSeedInt((max - min) + 1, min); + return this.randSeedInt(max - min + 1, min); } /** @@ -4298,10 +6144,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param hideInfo Indicates if this should also play the animation to hide the Pokemon's * info container. */ - leaveField(clearEffects: boolean = true, hideInfo: boolean = true, destroy: boolean = false) { + leaveField(clearEffects = true, hideInfo = true, destroy = false) { this.resetSprite(); this.resetTurnData(); - globalScene.getField(true).filter(p => p !== this).forEach(p => p.removeTagsBySourceId(this.id)); + globalScene + .getField(true) + .filter(p => p !== this) + .forEach(p => p.removeTagsBySourceId(this.id)); if (clearEffects) { this.destroySubstitute(); @@ -4313,7 +6162,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Trigger abilities that activate upon leaving the field applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, this); this.setSwitchOutStatus(true); - globalScene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true); + globalScene.triggerPokemonFormChange( + this, + SpeciesFormChangeActiveTrigger, + true, + ); globalScene.field.remove(this, destroy); } @@ -4335,7 +6188,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { hasSameAbilityInRootForm(abilityIndex: number): boolean { const currentAbilityIndex = this.abilityIndex; const rootForm = getPokemonSpecies(this.species.getRootSpeciesId()); - return rootForm.getAbility(abilityIndex) === rootForm.getAbility(currentAbilityIndex); + return ( + rootForm.getAbility(abilityIndex) === + rootForm.getAbility(currentAbilityIndex) + ); } /** @@ -4364,7 +6220,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param forBattle If `false`, do not trigger in-battle effects (such as Unburden) from losing the item. For example, set this to `false` if the Pokemon is giving away the held item for a Mystery Encounter. Default is `true`. * @returns `true` if the item was removed successfully, `false` otherwise. */ - public loseHeldItem(heldItem: PokemonHeldItemModifier, forBattle: boolean = true): boolean { + public loseHeldItem( + heldItem: PokemonHeldItemModifier, + forBattle = true, + ): boolean { if (heldItem.pokemonId === -1 || heldItem.pokemonId === this.id) { heldItem.stackCount--; if (heldItem.stackCount <= 0) { @@ -4383,8 +6242,32 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { export class PlayerPokemon extends Pokemon { public compatibleTms: Moves[]; - constructor(species: PokemonSpecies, level: number, abilityIndex?: number, formIndex?: number, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: number[], nature?: Nature, dataSource?: Pokemon | PokemonData) { - super(106, 148, species, level, abilityIndex, formIndex, gender, shiny, variant, ivs, nature, dataSource); + constructor( + species: PokemonSpecies, + level: number, + abilityIndex?: number, + formIndex?: number, + gender?: Gender, + shiny?: boolean, + variant?: Variant, + ivs?: number[], + nature?: Nature, + dataSource?: Pokemon | PokemonData, + ) { + super( + 106, + 148, + species, + level, + abilityIndex, + formIndex, + gender, + shiny, + variant, + ivs, + nature, + dataSource, + ); if (Overrides.STATUS_OVERRIDE) { this.status = new Status(Overrides.STATUS_OVERRIDE, 0, 4); @@ -4441,16 +6324,23 @@ export class PlayerPokemon extends Pokemon { const tms = Object.keys(tmSpecies); for (const tm of tms) { - const moveId = parseInt(tm) as Moves; + const moveId = Number.parseInt(tm) as Moves; let compatible = false; for (const p of tmSpecies[tm]) { if (Array.isArray(p)) { - const [ pkm, form ] = p; - if ((pkm === this.species.speciesId || this.fusionSpecies && pkm === this.fusionSpecies.speciesId) && form === this.getFormKey()) { + const [pkm, form] = p; + if ( + (pkm === this.species.speciesId || + (this.fusionSpecies && pkm === this.fusionSpecies.speciesId)) && + form === this.getFormKey() + ) { compatible = true; break; } - } else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) { + } else if ( + p === this.species.speciesId || + (this.fusionSpecies && p === this.fusionSpecies.speciesId) + ) { compatible = true; break; } @@ -4465,7 +6355,13 @@ export class PlayerPokemon extends Pokemon { } tryPopulateMoveset(moveset: StarterMoveset): boolean { - if (!this.getSpeciesForm().validateStarterMoveset(moveset, globalScene.gameData.starterData[this.species.getRootSpeciesId()].eggMoves)) { + if ( + !this.getSpeciesForm().validateStarterMoveset( + moveset, + globalScene.gameData.starterData[this.species.getRootSpeciesId()] + .eggMoves, + ) + ) { return false; } @@ -4485,31 +6381,65 @@ export class PlayerPokemon extends Pokemon { return new Promise(resolve => { this.leaveField(switchType === SwitchType.SWITCH); - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.FAINT_SWITCH, this.getFieldIndex(), (slotIndex: number, option: PartyOption) => { - if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) { - globalScene.prependToPhase(new SwitchSummonPhase(switchType, this.getFieldIndex(), slotIndex, false), MoveEndPhase); - } - globalScene.ui.setMode(Mode.MESSAGE).then(resolve); - }, PartyUiHandler.FilterNonFainted); + globalScene.ui.setMode( + Mode.PARTY, + PartyUiMode.FAINT_SWITCH, + this.getFieldIndex(), + (slotIndex: number, option: PartyOption) => { + if ( + slotIndex >= globalScene.currentBattle.getBattlerCount() && + slotIndex < 6 + ) { + globalScene.prependToPhase( + new SwitchSummonPhase( + switchType, + this.getFieldIndex(), + slotIndex, + false, + ), + MoveEndPhase, + ); + } + globalScene.ui.setMode(Mode.MESSAGE).then(resolve); + }, + PartyUiHandler.FilterNonFainted, + ); }); } addFriendship(friendship: number): void { if (friendship > 0) { const starterSpeciesId = this.species.getRootSpeciesId(); - const fusionStarterSpeciesId = this.isFusion() && this.fusionSpecies ? this.fusionSpecies.getRootSpeciesId() : 0; + const fusionStarterSpeciesId = + this.isFusion() && this.fusionSpecies + ? this.fusionSpecies.getRootSpeciesId() + : 0; const starterData = [ globalScene.gameData.starterData[starterSpeciesId], - fusionStarterSpeciesId ? globalScene.gameData.starterData[fusionStarterSpeciesId] : null + fusionStarterSpeciesId + ? globalScene.gameData.starterData[fusionStarterSpeciesId] + : null, ].filter(d => !!d); const amount = new Utils.NumberHolder(friendship); - globalScene.applyModifier(PokemonFriendshipBoosterModifier, true, this, amount); - const candyFriendshipMultiplier = globalScene.gameMode.isClassic ? globalScene.eventManager.getClassicFriendshipMultiplier() : 1; + globalScene.applyModifier( + PokemonFriendshipBoosterModifier, + true, + this, + amount, + ); + const candyFriendshipMultiplier = globalScene.gameMode.isClassic + ? globalScene.eventManager.getClassicFriendshipMultiplier() + : 1; const fusionReduction = fusionStarterSpeciesId - ? globalScene.eventManager.areFusionsBoosted() ? 1.5 // Divide candy gain for fusions by 1.5 during events - : 2 // 2 for fusions outside events - : 1; // 1 for non-fused mons - const starterAmount = new Utils.NumberHolder(Math.floor(amount.value * candyFriendshipMultiplier / fusionReduction)); + ? globalScene.eventManager.areFusionsBoosted() + ? 1.5 // Divide candy gain for fusions by 1.5 during events + : 2 // 2 for fusions outside events + : 1; // 1 for non-fused mons + const starterAmount = new Utils.NumberHolder( + Math.floor( + (amount.value * candyFriendshipMultiplier) / fusionReduction, + ), + ); // Add friendship to this PlayerPokemon this.friendship = Math.min(this.friendship + amount.value, 255); @@ -4518,9 +6448,14 @@ export class PlayerPokemon extends Pokemon { } // Add to candy progress for this mon's starter species and its fused species (if it has one) starterData.forEach((sd: StarterDataEntry, i: number) => { - const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species; + const speciesId = !i + ? starterSpeciesId + : (fusionStarterSpeciesId as Species); sd.friendship = (sd.friendship || 0) + starterAmount.value; - if (sd.friendship >= getStarterValueFriendshipCap(speciesStarterCosts[speciesId])) { + if ( + sd.friendship >= + getStarterValueFriendshipCap(speciesStarterCosts[speciesId]) + ) { globalScene.gameData.addStarterCandy(getPokemonSpecies(speciesId), 1); sd.friendship = 0; } @@ -4531,7 +6466,9 @@ export class PlayerPokemon extends Pokemon { } } - getPossibleEvolution(evolution: SpeciesFormEvolution | null): Promise { + getPossibleEvolution( + evolution: SpeciesFormEvolution | null, + ): Promise { if (!evolution) { return new Promise(resolve => resolve(this)); } @@ -4543,19 +6480,60 @@ export class PlayerPokemon extends Pokemon { const originalFusionSpecies = this.fusionSpecies; const originalFusionFormIndex = this.fusionFormIndex; this.fusionSpecies = evolutionSpecies; - this.fusionFormIndex = evolution.evoFormKey !== null ? Math.max(evolutionSpecies.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0) : this.fusionFormIndex; - ret = globalScene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); + this.fusionFormIndex = + evolution.evoFormKey !== null + ? Math.max( + evolutionSpecies.forms.findIndex( + f => f.formKey === evolution.evoFormKey, + ), + 0, + ) + : this.fusionFormIndex; + ret = globalScene.addPlayerPokemon( + this.species, + this.level, + this.abilityIndex, + this.formIndex, + this.gender, + this.shiny, + this.variant, + this.ivs, + this.nature, + this, + ); this.fusionSpecies = originalFusionSpecies; this.fusionFormIndex = originalFusionFormIndex; } else { - const formIndex = evolution.evoFormKey !== null && !isFusion ? Math.max(evolutionSpecies.forms.findIndex(f => f.formKey === evolution.evoFormKey), 0) : this.formIndex; - ret = globalScene.addPlayerPokemon(!isFusion ? evolutionSpecies : this.species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); + const formIndex = + evolution.evoFormKey !== null && !isFusion + ? Math.max( + evolutionSpecies.forms.findIndex( + f => f.formKey === evolution.evoFormKey, + ), + 0, + ) + : this.formIndex; + ret = globalScene.addPlayerPokemon( + !isFusion ? evolutionSpecies : this.species, + this.level, + this.abilityIndex, + formIndex, + this.gender, + this.shiny, + this.variant, + this.ivs, + this.nature, + this, + ); } ret.loadAssets().then(() => resolve(ret)); }); } - evolve(evolution: SpeciesFormEvolution | null, preEvolution: PokemonSpeciesForm): Promise { + evolve( + evolution: SpeciesFormEvolution | null, + preEvolution: PokemonSpeciesForm, + ): Promise { if (!evolution) { return new Promise(resolve => resolve()); } @@ -4570,7 +6548,13 @@ export class PlayerPokemon extends Pokemon { this.fusionSpecies = getPokemonSpecies(evolution.speciesId); } if (evolution.preFormKey !== null) { - const formIndex = Math.max((!isFusion || !this.fusionSpecies ? this.species : this.fusionSpecies).forms.findIndex(f => f.formKey === evolution.evoFormKey), 0); + const formIndex = Math.max( + (!isFusion || !this.fusionSpecies + ? this.species + : this.fusionSpecies + ).forms.findIndex(f => f.formKey === evolution.evoFormKey), + 0, + ); if (!isFusion) { this.formIndex = formIndex; } else { @@ -4581,25 +6565,39 @@ export class PlayerPokemon extends Pokemon { if (!isFusion) { const abilityCount = this.getSpeciesForm().getAbilityCount(); const preEvoAbilityCount = preEvolution.getAbilityCount(); - if ([ 0, 1, 2 ].includes(this.abilityIndex)) { + if ([0, 1, 2].includes(this.abilityIndex)) { // Handles cases where a Pokemon with 3 abilities evolves into a Pokemon with 2 abilities (ie: Eevee -> any Eeveelution) - if (this.abilityIndex === 2 && preEvoAbilityCount === 3 && abilityCount === 2) { + if ( + this.abilityIndex === 2 && + preEvoAbilityCount === 3 && + abilityCount === 2 + ) { this.abilityIndex = 1; } - } else { // Prevent pokemon with an illegal ability value from breaking things - console.warn("this.abilityIndex is somehow an illegal value, please report this"); + } else { + // Prevent pokemon with an illegal ability value from breaking things + console.warn( + "this.abilityIndex is somehow an illegal value, please report this", + ); console.warn(this.abilityIndex); this.abilityIndex = 0; } - } else { // Do the same as above, but for fusions + } else { + // Do the same as above, but for fusions const abilityCount = this.getFusionSpeciesForm().getAbilityCount(); const preEvoAbilityCount = preEvolution.getAbilityCount(); - if ([ 0, 1, 2 ].includes(this.fusionAbilityIndex)) { - if (this.fusionAbilityIndex === 2 && preEvoAbilityCount === 3 && abilityCount === 2) { + if ([0, 1, 2].includes(this.fusionAbilityIndex)) { + if ( + this.fusionAbilityIndex === 2 && + preEvoAbilityCount === 3 && + abilityCount === 2 + ) { this.fusionAbilityIndex = 1; } } else { - console.warn("this.fusionAbilityIndex is somehow an illegal value, please report this"); + console.warn( + "this.fusionAbilityIndex is somehow an illegal value, please report this", + ); console.warn(this.fusionAbilityIndex); this.fusionAbilityIndex = 0; } @@ -4613,15 +6611,22 @@ export class PlayerPokemon extends Pokemon { }); }; if (preEvolution.speciesId === Species.GIMMIGHOUL) { - const evotracker = this.getHeldItems().filter(m => m instanceof EvoTrackerModifier)[0] ?? null; + const evotracker = + this.getHeldItems().filter(m => m instanceof EvoTrackerModifier)[0] ?? + null; if (evotracker) { globalScene.removeModifier(evotracker); } } if (!globalScene.gameMode.isDaily || this.metBiome > -1) { - globalScene.gameData.updateSpeciesDexIvs(this.species.speciesId, this.ivs); + globalScene.gameData.updateSpeciesDexIvs( + this.species.speciesId, + this.ivs, + ); globalScene.gameData.setPokemonSeen(this, false); - globalScene.gameData.setPokemonCaught(this, false).then(() => updateAndResolve()); + globalScene.gameData + .setPokemonCaught(this, false) + .then(() => updateAndResolve()); } else { updateAndResolve(); } @@ -4631,12 +6636,25 @@ export class PlayerPokemon extends Pokemon { private handleSpecialEvolutions(evolution: SpeciesFormEvolution) { const isFusion = evolution instanceof FusionSpeciesFormEvolution; - const evoSpecies = (!isFusion ? this.species : this.fusionSpecies); - if (evoSpecies?.speciesId === Species.NINCADA && evolution.speciesId === Species.NINJASK) { + const evoSpecies = !isFusion ? this.species : this.fusionSpecies; + if ( + evoSpecies?.speciesId === Species.NINCADA && + evolution.speciesId === Species.NINJASK + ) { const newEvolution = pokemonEvolutions[evoSpecies.speciesId][1]; if (newEvolution.condition?.predicate(this)) { - const newPokemon = globalScene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, undefined, this.shiny, this.variant, this.ivs, this.nature); + const newPokemon = globalScene.addPlayerPokemon( + this.species, + this.level, + this.abilityIndex, + this.formIndex, + undefined, + this.shiny, + this.variant, + this.ivs, + this.nature, + ); newPokemon.passive = this.passive; newPokemon.moveset = this.moveset.slice(); newPokemon.moveset = this.copyMoveset(); @@ -4658,9 +6676,16 @@ export class PlayerPokemon extends Pokemon { newPokemon.evoCounter = this.evoCounter; globalScene.getPlayerParty().push(newPokemon); - newPokemon.evolve((!isFusion ? newEvolution : new FusionSpeciesFormEvolution(this.id, newEvolution)), evoSpecies); - const modifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === this.id, true) as PokemonHeldItemModifier[]; + newPokemon.evolve( + !isFusion + ? newEvolution + : new FusionSpeciesFormEvolution(this.id, newEvolution), + evoSpecies, + ); + const modifiers = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.id, + true, + ) as PokemonHeldItemModifier[]; modifiers.forEach(m => { const clonedModifier = m.clone() as PokemonHeldItemModifier; clonedModifier.pokemonId = newPokemon.id; @@ -4673,18 +6698,36 @@ export class PlayerPokemon extends Pokemon { getPossibleForm(formChange: SpeciesFormChange): Promise { return new Promise(resolve => { - const formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); - const ret = globalScene.addPlayerPokemon(this.species, this.level, this.abilityIndex, formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); + const formIndex = Math.max( + this.species.forms.findIndex(f => f.formKey === formChange.formKey), + 0, + ); + const ret = globalScene.addPlayerPokemon( + this.species, + this.level, + this.abilityIndex, + formIndex, + this.gender, + this.shiny, + this.variant, + this.ivs, + this.nature, + this, + ); ret.loadAssets().then(() => resolve(ret)); }); } changeForm(formChange: SpeciesFormChange): Promise { return new Promise(resolve => { - this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0); + this.formIndex = Math.max( + this.species.forms.findIndex(f => f.formKey === formChange.formKey), + 0, + ); this.generateName(); const abilityCount = this.getSpeciesForm().getAbilityCount(); - if (this.abilityIndex >= abilityCount) { // Shouldn't happen + if (this.abilityIndex >= abilityCount) { + // Shouldn't happen this.abilityIndex = abilityCount - 1; } @@ -4699,7 +6742,9 @@ export class PlayerPokemon extends Pokemon { }; if (!globalScene.gameMode.isDaily || this.metBiome > -1) { globalScene.gameData.setPokemonSeen(this, false); - globalScene.gameData.setPokemonCaught(this, false).then(() => updateAndResolve()); + globalScene.gameData + .setPokemonCaught(this, false) + .then(() => updateAndResolve()); } else { updateAndResolve(); } @@ -4734,7 +6779,8 @@ export class PlayerPokemon extends Pokemon { // Store the average HP% that each Pokemon has const maxHp = this.getMaxHp(); - const newHpPercent = (pokemon.hp / pokemon.getMaxHp() + this.hp / maxHp) / 2; + const newHpPercent = + (pokemon.hp / pokemon.getMaxHp() + this.hp / maxHp) / 2; this.generateName(); this.calculateStats(); @@ -4758,15 +6804,32 @@ export class PlayerPokemon extends Pokemon { if (partyMemberIndex > fusedPartyMemberIndex) { partyMemberIndex--; } - const fusedPartyMemberHeldModifiers = globalScene.findModifiers((m) => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const fusedPartyMemberHeldModifiers = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id, + true, + ) as PokemonHeldItemModifier[]; for (const modifier of fusedPartyMemberHeldModifiers) { - globalScene.tryTransferHeldItemModifier(modifier, this, false, modifier.getStackCount(), true, true, false); + globalScene.tryTransferHeldItemModifier( + modifier, + this, + false, + modifier.getStackCount(), + true, + true, + false, + ); } globalScene.updateModifiers(true, true); globalScene.removePartyMemberModifiers(fusedPartyMemberIndex); globalScene.getPlayerParty().splice(fusedPartyMemberIndex, 1)[0]; const newPartyMemberIndex = globalScene.getPlayerParty().indexOf(this); - pokemon.getMoveset(true).map((m: PokemonMove) => globalScene.unshiftPhase(new LearnMovePhase(newPartyMemberIndex, m.getMove().id))); + pokemon + .getMoveset(true) + .map((m: PokemonMove) => + globalScene.unshiftPhase( + new LearnMovePhase(newPartyMemberIndex, m.getMove().id), + ), + ); pokemon.destroy(); this.updateFusionPalette(); } @@ -4782,11 +6845,19 @@ export class PlayerPokemon extends Pokemon { /** Returns a deep copy of this Pokemon's moveset array */ copyMoveset(): PokemonMove[] { - const newMoveset : PokemonMove[] = []; - this.moveset.forEach((move) => { + const newMoveset: PokemonMove[] = []; + this.moveset.forEach(move => { // TODO: refactor `moveset` to not accept `null`s if (move) { - newMoveset.push(new PokemonMove(move.moveId, 0, move.ppUp, move.virtual, move.maxPpOverride)); + newMoveset.push( + new PokemonMove( + move.moveId, + 0, + move.ppUp, + move.virtual, + move.maxPpOverride, + ), + ); } }); @@ -4803,10 +6874,28 @@ export class EnemyPokemon extends Pokemon { /** To indicate if the instance was populated with a dataSource -> e.g. loaded & populated from session data */ public readonly isPopulatedFromDataSource: boolean; - constructor(species: PokemonSpecies, level: number, trainerSlot: TrainerSlot, boss: boolean, shinyLock: boolean = false, dataSource?: PokemonData) { - super(236, 84, species, level, dataSource?.abilityIndex, dataSource?.formIndex, dataSource?.gender, - (!shinyLock && dataSource) ? dataSource.shiny : false, (!shinyLock && dataSource) ? dataSource.variant : undefined, - undefined, dataSource ? dataSource.nature : undefined, dataSource); + constructor( + species: PokemonSpecies, + level: number, + trainerSlot: TrainerSlot, + boss: boolean, + shinyLock = false, + dataSource?: PokemonData, + ) { + super( + 236, + 84, + species, + level, + dataSource?.abilityIndex, + dataSource?.formIndex, + dataSource?.gender, + !shinyLock && dataSource ? dataSource.shiny : false, + !shinyLock && dataSource ? dataSource.variant : undefined, + undefined, + dataSource ? dataSource.nature : undefined, + dataSource, + ); this.trainerSlot = trainerSlot; this.initialTeamIndex = globalScene.currentBattle?.enemyParty.length ?? 0; @@ -4826,9 +6915,9 @@ export class EnemyPokemon extends Pokemon { const speciesId = this.species.speciesId; if ( - speciesId in Overrides.OPP_FORM_OVERRIDES - && Overrides.OPP_FORM_OVERRIDES[speciesId] - && this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]] + speciesId in Overrides.OPP_FORM_OVERRIDES && + Overrides.OPP_FORM_OVERRIDES[speciesId] && + this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]] ) { this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId] ?? 0; } @@ -4854,12 +6943,18 @@ export class EnemyPokemon extends Pokemon { } } - this.luck = (this.shiny ? this.variant + 1 : 0) + (this.fusionShiny ? this.fusionVariant + 1 : 0); + this.luck = + (this.shiny ? this.variant + 1 : 0) + + (this.fusionShiny ? this.fusionVariant + 1 : 0); let prevolution: Species; let speciesId = species.speciesId; while ((prevolution = pokemonPrevolutions[speciesId])) { - const evolution = pokemonEvolutions[prevolution].find(pe => pe.speciesId === speciesId && (!pe.evoFormKey || pe.evoFormKey === this.getFormKey())); + const evolution = pokemonEvolutions[prevolution].find( + pe => + pe.speciesId === speciesId && + (!pe.evoFormKey || pe.evoFormKey === this.getFormKey()), + ); if (evolution?.condition?.enforceFunc) { evolution.condition.enforceFunc(this); } @@ -4867,7 +6962,8 @@ export class EnemyPokemon extends Pokemon { } } - this.aiType = boss || this.hasTrainer() ? AiType.SMART : AiType.SMART_RANDOM; + this.aiType = + boss || this.hasTrainer() ? AiType.SMART : AiType.SMART_RANDOM; } initBattleInfo(): void { @@ -4887,9 +6983,16 @@ export class EnemyPokemon extends Pokemon { * @param boss if the pokemon is a boss * @param bossSegments amount of boss segments (health-bar segments) */ - setBoss(boss: boolean = true, bossSegments: number = 0): void { + setBoss(boss = true, bossSegments = 0): void { if (boss) { - this.bossSegments = bossSegments || globalScene.getEncounterBossSegments(globalScene.currentBattle.waveIndex, this.level, this.species, true); + this.bossSegments = + bossSegments || + globalScene.getEncounterBossSegments( + globalScene.currentBattle.waveIndex, + this.level, + this.species, + true, + ); this.bossSegmentIndex = this.bossSegments - 1; } else { this.bossSegments = 0; @@ -4899,28 +7002,28 @@ export class EnemyPokemon extends Pokemon { generateAndPopulateMoveset(formIndex?: number): void { switch (true) { - case (this.species.speciesId === Species.SMEARGLE): + case this.species.speciesId === Species.SMEARGLE: this.moveset = [ new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH), - new PokemonMove(Moves.SKETCH) + new PokemonMove(Moves.SKETCH), ]; break; - case (this.species.speciesId === Species.ETERNATUS): + case this.species.speciesId === Species.ETERNATUS: this.moveset = (formIndex !== undefined ? formIndex : this.formIndex) ? [ - new PokemonMove(Moves.DYNAMAX_CANNON), - new PokemonMove(Moves.CROSS_POISON), - new PokemonMove(Moves.FLAMETHROWER), - new PokemonMove(Moves.RECOVER, 0, -4) - ] + new PokemonMove(Moves.DYNAMAX_CANNON), + new PokemonMove(Moves.CROSS_POISON), + new PokemonMove(Moves.FLAMETHROWER), + new PokemonMove(Moves.RECOVER, 0, -4), + ] : [ - new PokemonMove(Moves.ETERNABEAM), - new PokemonMove(Moves.SLUDGE_BOMB), - new PokemonMove(Moves.FLAMETHROWER), - new PokemonMove(Moves.COSMIC_POWER) - ]; + new PokemonMove(Moves.ETERNABEAM), + new PokemonMove(Moves.SLUDGE_BOMB), + new PokemonMove(Moves.FLAMETHROWER), + new PokemonMove(Moves.COSMIC_POWER), + ]; if (globalScene.gameMode.hasChallenge(Challenges.INVERSE_BATTLE)) { this.moveset[2] = new PokemonMove(Moves.THUNDERBOLT); } @@ -4942,8 +7045,17 @@ export class EnemyPokemon extends Pokemon { if (moveQueue.length !== 0) { const queuedMove = moveQueue[0]; if (queuedMove) { - const moveIndex = this.getMoveset().findIndex(m => m?.moveId === queuedMove.move); - if ((moveIndex > -1 && this.getMoveset()[moveIndex]!.isUsable(this, queuedMove.ignorePP)) || queuedMove.virtual) { + const moveIndex = this.getMoveset().findIndex( + m => m?.moveId === queuedMove.move, + ); + if ( + (moveIndex > -1 && + this.getMoveset()[moveIndex]!.isUsable( + this, + queuedMove.ignorePP, + )) || + queuedMove.virtual + ) { return queuedMove; } else { this.getMoveQueue().shift(); @@ -4958,27 +7070,34 @@ export class EnemyPokemon extends Pokemon { if (movePool.length) { // If there's only 1 move in the move pool, use it. if (movePool.length === 1) { - return { move: movePool[0]!.moveId, targets: this.getNextTargets(movePool[0]!.moveId) }; // TODO: are the bangs correct? + return { + move: movePool[0]!.moveId, + targets: this.getNextTargets(movePool[0]!.moveId), + }; // TODO: are the bangs correct? } // If a move is forced because of Encore, use it. const encoreTag = this.getTag(EncoreTag) as EncoreTag; if (encoreTag) { const encoreMove = movePool.find(m => m?.moveId === encoreTag.moveId); if (encoreMove) { - return { move: encoreMove.moveId, targets: this.getNextTargets(encoreMove.moveId) }; + return { + move: encoreMove.moveId, + targets: this.getNextTargets(encoreMove.moveId), + }; } } switch (this.aiType) { case AiType.RANDOM: // No enemy should spawn with this AI type in-game - const moveId = movePool[globalScene.randBattleSeedInt(movePool.length)]!.moveId; // TODO: is the bang correct? + const moveId = + movePool[globalScene.randBattleSeedInt(movePool.length)]!.moveId; // TODO: is the bang correct? return { move: moveId, targets: this.getNextTargets(moveId) }; case AiType.SMART_RANDOM: case AiType.SMART: - /** - * Search this Pokemon's move pool for moves that will KO an opposing target. - * If there are any moves that can KO an opponent (i.e. a player Pokemon), - * those moves are the only ones considered for selection on this turn. - */ + /** + * Search this Pokemon's move pool for moves that will KO an opposing target. + * If there are any moves that can KO an opponent (i.e. a player Pokemon), + * those moves are the only ones considered for selection on this turn. + */ const koMoves = movePool.filter(pkmnMove => { if (!pkmnMove) { return false; @@ -4990,17 +7109,36 @@ export class EnemyPokemon extends Pokemon { } const fieldPokemon = globalScene.getField(); - const moveTargets = getMoveTargets(this, move.id).targets - .map(ind => fieldPokemon[ind]) + const moveTargets = getMoveTargets(this, move.id) + .targets.map(ind => fieldPokemon[ind]) .filter(p => this.isPlayer() !== p.isPlayer()); // Only considers critical hits for crit-only moves or when this Pokemon is under the effect of Laser Focus - const isCritical = move.hasAttr(CritOnlyAttr) || !!this.getTag(BattlerTagType.ALWAYS_CRIT); + const isCritical = + move.hasAttr(CritOnlyAttr) || + !!this.getTag(BattlerTagType.ALWAYS_CRIT); - return move.category !== MoveCategory.STATUS - && moveTargets.some(p => { - const doesNotFail = move.applyConditions(this, p, move) || [ Moves.SUCKER_PUNCH, Moves.UPPER_HAND, Moves.THUNDERCLAP ].includes(move.id); - return doesNotFail && p.getAttackDamage(this, move, !p.battleData.abilityRevealed, false, isCritical).damage >= p.hp; - }); + return ( + move.category !== MoveCategory.STATUS && + moveTargets.some(p => { + const doesNotFail = + move.applyConditions(this, p, move) || + [ + Moves.SUCKER_PUNCH, + Moves.UPPER_HAND, + Moves.THUNDERCLAP, + ].includes(move.id); + return ( + doesNotFail && + p.getAttackDamage( + this, + move, + !p.battleData.abilityRevealed, + false, + isCritical, + ).damage >= p.hp + ); + }) + ); }, this); if (koMoves.length > 0) { @@ -5008,12 +7146,14 @@ export class EnemyPokemon extends Pokemon { } /** - * Move selection is based on the move's calculated "benefit score" against the - * best possible target(s) (as determined by {@linkcode getNextTargets}). - * For more information on how benefit scores are calculated, see `docs/enemy-ai.md`. - */ + * Move selection is based on the move's calculated "benefit score" against the + * best possible target(s) (as determined by {@linkcode getNextTargets}). + * For more information on how benefit scores are calculated, see `docs/enemy-ai.md`. + */ const moveScores = movePool.map(() => 0); - const moveTargets = Object.fromEntries(movePool.map(m => [ m!.moveId, this.getNextTargets(m!.moveId) ])); // TODO: are those bangs correct? + const moveTargets = Object.fromEntries( + movePool.map(m => [m!.moveId, this.getNextTargets(m!.moveId)]), + ); // TODO: are those bangs correct? for (const m in movePool) { const pokemonMove = movePool[m]!; // TODO: is the bang correct? const move = pokemonMove.getMove(); @@ -5022,33 +7162,48 @@ export class EnemyPokemon extends Pokemon { const targetScores: number[] = []; for (const mt of moveTargets[move.id]) { - // Prevent a target score from being calculated when the target is whoever attacks the user + // Prevent a target score from being calculated when the target is whoever attacks the user if (mt === BattlerIndex.ATTACKER) { break; } const target = globalScene.getField()[mt]; /** - * The "target score" of a move is given by the move's user benefit score + the move's target benefit score. - * If the target is an ally, the target benefit score is multiplied by -1. - */ - let targetScore = move.getUserBenefitScore(this, target, move) + move.getTargetBenefitScore(this, target, move) * (mt < BattlerIndex.ENEMY === this.isPlayer() ? 1 : -1); + * The "target score" of a move is given by the move's user benefit score + the move's target benefit score. + * If the target is an ally, the target benefit score is multiplied by -1. + */ + let targetScore = + move.getUserBenefitScore(this, target, move) + + move.getTargetBenefitScore(this, target, move) * + (mt < BattlerIndex.ENEMY === this.isPlayer() ? 1 : -1); if (Number.isNaN(targetScore)) { console.error(`Move ${move.name} returned score of NaN`); targetScore = 0; } /** - * If this move is unimplemented, or the move is known to fail when used, set its - * target score to -20 - */ - if ((move.name.endsWith(" (N)") || !move.applyConditions(this, target, move)) && ![ Moves.SUCKER_PUNCH, Moves.UPPER_HAND, Moves.THUNDERCLAP ].includes(move.id)) { + * If this move is unimplemented, or the move is known to fail when used, set its + * target score to -20 + */ + if ( + (move.name.endsWith(" (N)") || + !move.applyConditions(this, target, move)) && + ![ + Moves.SUCKER_PUNCH, + Moves.UPPER_HAND, + Moves.THUNDERCLAP, + ].includes(move.id) + ) { targetScore = -20; } else if (move instanceof AttackMove) { - /** - * Attack moves are given extra multipliers to their base benefit score based on - * the move's type effectiveness against the target and whether the move is a STAB move. - */ - const effectiveness = target.getMoveEffectiveness(this, move, !target.battleData?.abilityRevealed); + /** + * Attack moves are given extra multipliers to their base benefit score based on + * the move's type effectiveness against the target and whether the move is a STAB move. + */ + const effectiveness = target.getMoveEffectiveness( + this, + move, + !target.battleData?.abilityRevealed, + ); if (target.isPlayer() !== this.isPlayer()) { targetScore *= effectiveness; if (this.isOfType(move.type)) { @@ -5085,23 +7240,47 @@ export class EnemyPokemon extends Pokemon { }); let r = 0; if (this.aiType === AiType.SMART_RANDOM) { - // Has a 5/8 chance to select the best move, and a 3/8 chance to advance to the next best move (and repeat this roll) - while (r < sortedMovePool.length - 1 && globalScene.randBattleSeedInt(8) >= 5) { + // Has a 5/8 chance to select the best move, and a 3/8 chance to advance to the next best move (and repeat this roll) + while ( + r < sortedMovePool.length - 1 && + globalScene.randBattleSeedInt(8) >= 5 + ) { r++; } } else if (this.aiType === AiType.SMART) { - // The chance to advance to the next best move increases when the compared moves' scores are closer to each other. - while (r < sortedMovePool.length - 1 && (moveScores[movePool.indexOf(sortedMovePool[r + 1])] / moveScores[movePool.indexOf(sortedMovePool[r])]) >= 0 - && globalScene.randBattleSeedInt(100) < Math.round((moveScores[movePool.indexOf(sortedMovePool[r + 1])] / moveScores[movePool.indexOf(sortedMovePool[r])]) * 50)) { + // The chance to advance to the next best move increases when the compared moves' scores are closer to each other. + while ( + r < sortedMovePool.length - 1 && + moveScores[movePool.indexOf(sortedMovePool[r + 1])] / + moveScores[movePool.indexOf(sortedMovePool[r])] >= + 0 && + globalScene.randBattleSeedInt(100) < + Math.round( + (moveScores[movePool.indexOf(sortedMovePool[r + 1])] / + moveScores[movePool.indexOf(sortedMovePool[r])]) * + 50, + ) + ) { r++; } } - console.log(movePool.map(m => m!.getName()), moveScores, r, sortedMovePool.map(m => m!.getName())); // TODO: are those bangs correct? - return { move: sortedMovePool[r]!.moveId, targets: moveTargets[sortedMovePool[r]!.moveId] }; + console.log( + movePool.map(m => m!.getName()), + moveScores, + r, + sortedMovePool.map(m => m!.getName()), + ); // TODO: are those bangs correct? + return { + move: sortedMovePool[r]!.moveId, + targets: moveTargets[sortedMovePool[r]!.moveId], + }; } } - return { move: Moves.STRUGGLE, targets: this.getNextTargets(Moves.STRUGGLE) }; + return { + move: Moves.STRUGGLE, + targets: this.getNextTargets(Moves.STRUGGLE), + }; } /** @@ -5111,7 +7290,9 @@ export class EnemyPokemon extends Pokemon { */ getNextTargets(moveId: Moves): BattlerIndex[] { const moveTargets = getMoveTargets(this, moveId); - const targets = globalScene.getField(true).filter(p => moveTargets.targets.indexOf(p.getBattlerIndex()) > -1); + const targets = globalScene + .getField(true) + .filter(p => moveTargets.targets.indexOf(p.getBattlerIndex()) > -1); // If the move is multi-target, return all targets' indexes if (moveTargets.multiple) { return targets.map(p => p.getBattlerIndex()); @@ -5123,8 +7304,11 @@ export class EnemyPokemon extends Pokemon { * Get the move's target benefit score against each potential target. * For allies, this score is multiplied by -1. */ - const benefitScores = targets - .map(p => [ p.getBattlerIndex(), move.getTargetBenefitScore(this, p, move) * (p.isPlayer() === this.isPlayer() ? 1 : -1) ]); + const benefitScores = targets.map(p => [ + p.getBattlerIndex(), + move.getTargetBenefitScore(this, p, move) * + (p.isPlayer() === this.isPlayer() ? 1 : -1), + ]); const sortedBenefitScores = benefitScores.slice(0); sortedBenefitScores.sort((a, b) => { @@ -5137,7 +7321,7 @@ export class EnemyPokemon extends Pokemon { // Set target to BattlerIndex.ATTACKER when using a counter move // This is the same as when the player does so if (move.hasAttr(CounterDamageAttr)) { - return [ BattlerIndex.ATTACKER ]; + return [BattlerIndex.ATTACKER]; } return []; @@ -5154,13 +7338,15 @@ export class EnemyPokemon extends Pokemon { } // Remove any targets whose weights are less than half the max of the target weights from consideration - const benefitCutoffIndex = targetWeights.findIndex(s => s < targetWeights[0] / 2); + const benefitCutoffIndex = targetWeights.findIndex( + s => s < targetWeights[0] / 2, + ); if (benefitCutoffIndex > -1) { targetWeights = targetWeights.slice(0, benefitCutoffIndex); } const thresholds: number[] = []; - let totalWeight: number = 0; + let totalWeight = 0; targetWeights.reduce((total: number, w: number) => { total += w; thresholds.push(total); @@ -5174,7 +7360,7 @@ export class EnemyPokemon extends Pokemon { * is greater than that random number. */ const randValue = globalScene.randBattleSeedInt(totalWeight); - let targetIndex: number = 0; + let targetIndex = 0; thresholds.every((t, i) => { if (randValue >= t) { @@ -5185,7 +7371,7 @@ export class EnemyPokemon extends Pokemon { return false; }); - return [ sortedBenefitScores[targetIndex][0] ]; + return [sortedBenefitScores[targetIndex][0]]; } isPlayer() { @@ -5213,14 +7399,17 @@ export class EnemyPokemon extends Pokemon { return 0; } - damage(damage: number, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false): number { + damage( + damage: number, + ignoreSegments = false, + preventEndure = false, + ignoreFaintPhase = false, + ): number { if (this.isFainted()) { return 0; } - let clearedBossSegmentIndex = this.isBoss() - ? this.bossSegmentIndex + 1 - : 0; + let clearedBossSegmentIndex = this.isBoss() ? this.bossSegmentIndex + 1 : 0; if (this.isBoss() && !ignoreSegments) { const segmentSize = this.getMaxHp() / this.bossSegments; @@ -5231,12 +7420,19 @@ export class EnemyPokemon extends Pokemon { if (this.hp - damage <= roundedHpThreshold) { const hpRemainder = this.hp - roundedHpThreshold; let segmentsBypassed = 0; - while (segmentsBypassed < this.bossSegmentIndex && this.canBypassBossSegments(segmentsBypassed + 1) && (damage - hpRemainder) >= Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))) { + while ( + segmentsBypassed < this.bossSegmentIndex && + this.canBypassBossSegments(segmentsBypassed + 1) && + damage - hpRemainder >= + Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1)) + ) { segmentsBypassed++; //console.log('damage', damage, 'segment', segmentsBypassed + 1, 'segment size', segmentSize, 'damage needed', Math.round(segmentSize * Math.pow(2, segmentsBypassed + 1))); } - damage = Utils.toDmgValue(this.hp - hpThreshold + segmentSize * segmentsBypassed); + damage = Utils.toDmgValue( + this.hp - hpThreshold + segmentSize * segmentsBypassed, + ); clearedBossSegmentIndex = s - segmentsBypassed; } break; @@ -5251,7 +7447,12 @@ export class EnemyPokemon extends Pokemon { } } - const ret = super.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase); + const ret = super.damage( + damage, + ignoreSegments, + preventEndure, + ignoreFaintPhase, + ); if (this.isBoss()) { if (ignoreSegments) { @@ -5267,9 +7468,9 @@ export class EnemyPokemon extends Pokemon { return ret; } - canBypassBossSegments(segmentCount: number = 1): boolean { + canBypassBossSegments(segmentCount = 1): boolean { if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) { - if (!this.formIndex && (this.bossSegmentIndex - segmentCount) < 1) { + if (!this.formIndex && this.bossSegmentIndex - segmentCount < 1) { return false; } } @@ -5285,10 +7486,17 @@ export class EnemyPokemon extends Pokemon { * @param segmentIndex index of the segment to get down to (0 = no shield left, 1 = 1 shield left, etc.) */ handleBossSegmentCleared(segmentIndex: number): void { - while (this.bossSegmentIndex > 0 && segmentIndex - 1 < this.bossSegmentIndex) { + while ( + this.bossSegmentIndex > 0 && + segmentIndex - 1 < this.bossSegmentIndex + ) { // Filter out already maxed out stat stages and weigh the rest based on existing stats - const leftoverStats = EFFECTIVE_STATS.filter((s: EffectiveStat) => this.getStatStage(s) < 6); - const statWeights = leftoverStats.map((s: EffectiveStat) => this.getStat(s, false)); + const leftoverStats = EFFECTIVE_STATS.filter( + (s: EffectiveStat) => this.getStatStage(s) < 6, + ); + const statWeights = leftoverStats.map((s: EffectiveStat) => + this.getStat(s, false), + ); let boostedStat: EffectiveStat; const statThresholds: number[] = []; @@ -5319,7 +7527,16 @@ export class EnemyPokemon extends Pokemon { stages++; } - globalScene.unshiftPhase(new StatStageChangePhase(this.getBattlerIndex(), true, [ boostedStat! ], stages, true, true)); + globalScene.unshiftPhase( + new StatStageChangePhase( + this.getBattlerIndex(), + true, + [boostedStat!], + stages, + true, + true, + ), + ); this.bossSegmentIndex--; } } @@ -5339,7 +7556,7 @@ export class EnemyPokemon extends Pokemon { * @param slotIndex an optional index to place the pokemon in the party * @returns the pokemon that was added or null if the pokemon could not be added */ - addToParty(pokeballType: PokeballType, slotIndex: number = -1) { + addToParty(pokeballType: PokeballType, slotIndex = -1) { const party = globalScene.getPlayerParty(); let ret: PlayerPokemon | null = null; @@ -5349,7 +7566,18 @@ export class EnemyPokemon extends Pokemon { this.metBiome = globalScene.arena.biomeType; this.metWave = globalScene.currentBattle.waveIndex; this.metSpecies = this.species.speciesId; - const newPokemon = globalScene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); + const newPokemon = globalScene.addPlayerPokemon( + this.species, + this.level, + this.abilityIndex, + this.formIndex, + this.gender, + this.shiny, + this.variant, + this.ivs, + this.nature, + this, + ); if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) { party.splice(slotIndex, 0, newPokemon); @@ -5361,7 +7589,11 @@ export class EnemyPokemon extends Pokemon { newPokemon.setVisible(false); ret = newPokemon; - globalScene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true); + globalScene.triggerPokemonFormChange( + newPokemon, + SpeciesFormChangeActiveTrigger, + true, + ); } return ret; @@ -5388,10 +7620,10 @@ export interface AttackMoveResult { export class PokemonSummonData { /** [Atk, Def, SpAtk, SpDef, Spd, Acc, Eva] */ - public statStages: number[] = [ 0, 0, 0, 0, 0, 0, 0 ]; + public statStages: number[] = [0, 0, 0, 0, 0, 0, 0]; public moveQueue: TurnMove[] = []; public tags: BattlerTag[] = []; - public abilitySuppressed: boolean = false; + public abilitySuppressed = false; public abilitiesApplied: Abilities[] = []; public speciesForm: PokemonSpeciesForm | null; public fusionSpeciesForm: PokemonSpeciesForm; @@ -5399,7 +7631,7 @@ export class PokemonSummonData { public passiveAbility: Abilities = Abilities.NONE; public gender: Gender; public fusionGender: Gender; - public stats: number[] = [ 0, 0, 0, 0, 0, 0 ]; + public stats: number[] = [0, 0, 0, 0, 0, 0]; public moveset: (PokemonMove | null)[]; // If not initialized this value will not be populated from save data. public types: PokemonType[] = []; @@ -5408,57 +7640,57 @@ export class PokemonSummonData { export class PokemonBattleData { /** counts the hits the pokemon received */ - public hitCount: number = 0; + public hitCount = 0; /** used for {@linkcode Moves.RAGE_FIST} in order to save hit Counts received before Rage Fist is applied */ - public prevHitCount: number = 0; - public endured: boolean = false; + public prevHitCount = 0; + public endured = false; public berriesEaten: BerryType[] = []; public abilitiesApplied: Abilities[] = []; - public abilityRevealed: boolean = false; + public abilityRevealed = false; } export class PokemonBattleSummonData { /** The number of turns the pokemon has passed since entering the battle */ - public turnCount: number = 1; + public turnCount = 1; /** The number of turns the pokemon has passed since the start of the wave */ - public waveTurnCount: number = 1; + public waveTurnCount = 1; /** The list of moves the pokemon has used since entering the battle */ public moveHistory: TurnMove[] = []; } export class PokemonTurnData { - public flinched: boolean = false; - public acted: boolean = false; + public flinched = false; + public acted = false; /** How many times the move should hit the target(s) */ - public hitCount: number = 0; + public hitCount = 0; /** * - `-1` = Calculate how many hits are left * - `0` = Move is finished */ - public hitsLeft: number = -1; - public totalDamageDealt: number = 0; - public singleHitDamageDealt: number = 0; - public damageTaken: number = 0; + public hitsLeft = -1; + public totalDamageDealt = 0; + public singleHitDamageDealt = 0; + public damageTaken = 0; public attacksReceived: AttackMoveResult[] = []; public order: number; - public statStagesIncreased: boolean = false; - public statStagesDecreased: boolean = false; + public statStagesIncreased = false; + public statStagesDecreased = false; public moveEffectiveness: TypeDamageMultiplier | null = null; public combiningPledge?: Moves; - public switchedInThisTurn: boolean = false; - public failedRunAway: boolean = false; - public joinedRound: boolean = false; + public switchedInThisTurn = false; + public failedRunAway = false; + public joinedRound = false; /** * Used to make sure multi-hits occur properly when the user is * forced to act again in the same turn */ - public extraTurns: number = 0; + public extraTurns = 0; } export enum AiType { RANDOM, SMART_RANDOM, - SMART + SMART, } export enum MoveResult { @@ -5466,7 +7698,7 @@ export enum MoveResult { SUCCESS, FAIL, MISS, - OTHER + OTHER, } export enum HitResult { @@ -5480,10 +7712,15 @@ export enum HitResult { FAIL, MISS, OTHER, - IMMUNE + IMMUNE, } -export type DamageResult = HitResult.EFFECTIVE | HitResult.SUPER_EFFECTIVE | HitResult.NOT_VERY_EFFECTIVE | HitResult.ONE_HIT_KO | HitResult.OTHER; +export type DamageResult = + | HitResult.EFFECTIVE + | HitResult.SUPER_EFFECTIVE + | HitResult.NOT_VERY_EFFECTIVE + | HitResult.ONE_HIT_KO + | HitResult.OTHER; /** Interface containing the results of a damage calculation for a given move */ export interface DamageCalculationResult { @@ -5520,7 +7757,13 @@ export class PokemonMove { */ public maxPpOverride?: number; - constructor(moveId: Moves, ppUsed: number = 0, ppUp: number = 0, virtual: boolean = false, maxPpOverride?: number) { + constructor( + moveId: Moves, + ppUsed = 0, + ppUp = 0, + virtual = false, + maxPpOverride?: number, + ) { this.moveId = moveId; this.ppUsed = ppUsed; this.ppUp = ppUp; @@ -5537,8 +7780,16 @@ export class PokemonMove { * @param {boolean} ignoreRestrictionTags If `true`, skips the check for move restriction tags (see {@link MoveRestrictionBattlerTag}) * @returns `true` if the move can be selected and used by the Pokemon, otherwise `false`. */ - isUsable(pokemon: Pokemon, ignorePp: boolean = false, ignoreRestrictionTags: boolean = false): boolean { - if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)) { + isUsable( + pokemon: Pokemon, + ignorePp = false, + ignoreRestrictionTags = false, + ): boolean { + if ( + this.moveId && + !ignoreRestrictionTags && + pokemon.isMoveRestricted(this.moveId, pokemon) + ) { return false; } @@ -5546,7 +7797,9 @@ export class PokemonMove { return false; } - return (ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1); + return ( + ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1 + ); } getMove(): Move { @@ -5557,16 +7810,19 @@ export class PokemonMove { * Sets {@link ppUsed} for this move and ensures the value does not exceed {@link getMovePp} * @param {number} count Amount of PP to use */ - usePp(count: number = 1) { + usePp(count = 1) { this.ppUsed = Math.min(this.ppUsed + count, this.getMovePp()); } getMovePp(): number { - return this.maxPpOverride || (this.getMove().pp + this.ppUp * Utils.toDmgValue(this.getMove().pp / 5)); + return ( + this.maxPpOverride || + this.getMove().pp + this.ppUp * Utils.toDmgValue(this.getMove().pp / 5) + ); } getPpRatio(): number { - return 1 - (this.ppUsed / this.getMovePp()); + return 1 - this.ppUsed / this.getMovePp(); } getName(): string { @@ -5574,11 +7830,17 @@ export class PokemonMove { } /** - * Copies an existing move or creates a valid PokemonMove object from json representing one - * @param {PokemonMove | any} source The data for the move to copy - * @return {PokemonMove} A valid pokemonmove object - */ + * Copies an existing move or creates a valid PokemonMove object from json representing one + * @param {PokemonMove | any} source The data for the move to copy + * @return {PokemonMove} A valid pokemonmove object + */ static loadMove(source: PokemonMove | any): PokemonMove { - return new PokemonMove(source.moveId, source.ppUsed, source.ppUp, source.virtual, source.maxPpOverride); + return new PokemonMove( + source.moveId, + source.ppUsed, + source.ppUp, + source.virtual, + source.maxPpOverride, + ); } } diff --git a/src/field/trainer.ts b/src/field/trainer.ts index ab247716e15..4325b54a783 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -2,9 +2,7 @@ import { globalScene } from "#app/global-scene"; import { pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; -import type { - TrainerConfig, - TrainerPartyTemplate } from "#app/data/trainer-config"; +import type { TrainerConfig, TrainerPartyTemplate } from "#app/data/trainer-config"; import { TrainerPartyCompoundTemplate, TrainerPoolTier, @@ -12,7 +10,7 @@ import { trainerConfigs, trainerPartyTemplates, signatureSpecies, - TeraAIMode + TeraAIMode, } from "#app/data/trainer-config"; import type { EnemyPokemon } from "#app/field/pokemon"; import * as Utils from "#app/utils"; @@ -26,9 +24,9 @@ import { Species } from "#enums/species"; import { TrainerType } from "#enums/trainer-type"; export enum TrainerVariant { - DEFAULT, - FEMALE, - DOUBLE + DEFAULT, + FEMALE, + DOUBLE, } export default class Trainer extends Phaser.GameObjects.Container { @@ -39,7 +37,14 @@ export default class Trainer extends Phaser.GameObjects.Container { public partnerName: string; public originalIndexes: { [key: number]: number } = {}; - constructor(trainerType: TrainerType, variant: TrainerVariant, partyTemplateIndex?: number, name?: string, partnerName?: string, trainerConfigOverride?: TrainerConfig) { + constructor( + trainerType: TrainerType, + variant: TrainerVariant, + partyTemplateIndex?: number, + name?: string, + partnerName?: string, + trainerConfigOverride?: TrainerConfig, + ) { super(globalScene, -72, 80); this.config = trainerConfigs.hasOwnProperty(trainerType) ? trainerConfigs[trainerType] @@ -50,17 +55,23 @@ export default class Trainer extends Phaser.GameObjects.Container { } this.variant = variant; - this.partyTemplateIndex = Math.min(partyTemplateIndex !== undefined ? partyTemplateIndex : Utils.randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)), - this.config.partyTemplates.length - 1); + this.partyTemplateIndex = Math.min( + partyTemplateIndex !== undefined + ? partyTemplateIndex + : Utils.randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)), + this.config.partyTemplates.length - 1, + ); if (trainerNamePools.hasOwnProperty(trainerType)) { const namePool = trainerNamePools[trainerType]; - this.name = name || Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[variant === TrainerVariant.FEMALE ? 1 : 0] : namePool); + this.name = + name || + Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[variant === TrainerVariant.FEMALE ? 1 : 0] : namePool); if (variant === TrainerVariant.DOUBLE) { if (this.config.doubleOnly) { if (partnerName) { this.partnerName = partnerName; } else { - [ this.name, this.partnerName ] = this.name.split(" & "); + [this.name, this.partnerName] = this.name.split(" & "); } } else { this.partnerName = partnerName || Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[1] : namePool); @@ -81,12 +92,21 @@ export default class Trainer extends Phaser.GameObjects.Container { break; } - console.log(Object.keys(trainerPartyTemplates)[Object.values(trainerPartyTemplates).indexOf(this.getPartyTemplate())]); + console.log( + Object.keys(trainerPartyTemplates)[Object.values(trainerPartyTemplates).indexOf(this.getPartyTemplate())], + ); const getSprite = (hasShadow?: boolean, forceFemale?: boolean) => { - const ret = globalScene.addFieldSprite(0, 0, this.config.getSpriteKey(variant === TrainerVariant.FEMALE || forceFemale, this.isDouble())); + const ret = globalScene.addFieldSprite( + 0, + 0, + this.config.getSpriteKey(variant === TrainerVariant.FEMALE || forceFemale, this.isDouble()), + ); ret.setOrigin(0.5, 1); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow }); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: !!hasShadow, + }); return ret; }; @@ -124,13 +144,13 @@ export default class Trainer extends Phaser.GameObjects.Container { * @param {boolean} includeTitle - Whether to include the title in the returned name. Defaults to false. * @returns {string} - The formatted name of the trainer. **/ - getName(trainerSlot: TrainerSlot = TrainerSlot.NONE, includeTitle: boolean = false): string { + getName(trainerSlot: TrainerSlot = TrainerSlot.NONE, includeTitle = false): string { // Get the base title based on the trainer slot and variant. let name = this.config.getTitle(trainerSlot, this.variant); // Determine the title to include based on the configuration and includeTitle flag. let title = includeTitle && this.config.title ? this.config.title : null; - const evilTeamTitles = [ "grunt" ]; + const evilTeamTitles = ["grunt"]; if (this.name === "" && evilTeamTitles.some(t => name.toLocaleLowerCase().includes(t))) { // This is a evil team grunt so we localize it by only using the "name" as the title title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`); @@ -180,7 +200,6 @@ export default class Trainer extends Phaser.GameObjects.Container { return title ? `${title} ${name}` : name; } - isDouble(): boolean { return this.config.doubleOnly || this.variant === TrainerVariant.DOUBLE; } @@ -194,19 +213,34 @@ export default class Trainer extends Phaser.GameObjects.Container { } getEncounterBgm(): string { - return !this.variant ? this.config.encounterBgm : (this.variant === TrainerVariant.DOUBLE ? this.config.doubleEncounterBgm : this.config.femaleEncounterBgm) || this.config.encounterBgm; + return !this.variant + ? this.config.encounterBgm + : (this.variant === TrainerVariant.DOUBLE ? this.config.doubleEncounterBgm : this.config.femaleEncounterBgm) || + this.config.encounterBgm; } getEncounterMessages(): string[] { - return !this.variant ? this.config.encounterMessages : (this.variant === TrainerVariant.DOUBLE ? this.config.doubleEncounterMessages : this.config.femaleEncounterMessages) || this.config.encounterMessages; + return !this.variant + ? this.config.encounterMessages + : (this.variant === TrainerVariant.DOUBLE + ? this.config.doubleEncounterMessages + : this.config.femaleEncounterMessages) || this.config.encounterMessages; } getVictoryMessages(): string[] { - return !this.variant ? this.config.victoryMessages : (this.variant === TrainerVariant.DOUBLE ? this.config.doubleVictoryMessages : this.config.femaleVictoryMessages) || this.config.victoryMessages; + return !this.variant + ? this.config.victoryMessages + : (this.variant === TrainerVariant.DOUBLE + ? this.config.doubleVictoryMessages + : this.config.femaleVictoryMessages) || this.config.victoryMessages; } getDefeatMessages(): string[] { - return !this.variant ? this.config.defeatMessages : (this.variant === TrainerVariant.DOUBLE ? this.config.doubleDefeatMessages : this.config.femaleDefeatMessages) || this.config.defeatMessages; + return !this.variant + ? this.config.defeatMessages + : (this.variant === TrainerVariant.DOUBLE + ? this.config.doubleDefeatMessages + : this.config.femaleDefeatMessages) || this.config.defeatMessages; } getPartyTemplate(): TrainerPartyTemplate { @@ -270,119 +304,136 @@ export default class Trainer extends Phaser.GameObjects.Container { let ret: EnemyPokemon; - globalScene.executeWithSeedOffset(() => { - const template = this.getPartyTemplate(); - const strength: PartyMemberStrength = template.getStrength(index); + globalScene.executeWithSeedOffset( + () => { + const template = this.getPartyTemplate(); + const strength: PartyMemberStrength = template.getStrength(index); - - // If the battle is not one of the named trainer doubles - if (!(this.config.trainerTypeDouble && this.isDouble() && !this.config.doubleOnly)) { - - if (this.config.partyMemberFuncs.hasOwnProperty(index)) { - ret = this.config.partyMemberFuncs[index](level, strength); - return; - } - if (this.config.partyMemberFuncs.hasOwnProperty(index - template.size)) { - ret = this.config.partyMemberFuncs[index - template.size](level, template.getStrength(index)); - return; - } - } - let offset = 0; - - if (template instanceof TrainerPartyCompoundTemplate) { - for (const innerTemplate of template.templates) { - if (offset + innerTemplate.size > index) { - break; + // If the battle is not one of the named trainer doubles + if (!(this.config.trainerTypeDouble && this.isDouble() && !this.config.doubleOnly)) { + if (this.config.partyMemberFuncs.hasOwnProperty(index)) { + ret = this.config.partyMemberFuncs[index](level, strength); + return; + } + if (this.config.partyMemberFuncs.hasOwnProperty(index - template.size)) { + ret = this.config.partyMemberFuncs[index - template.size](level, template.getStrength(index)); + return; } - offset += innerTemplate.size; } - } + let offset = 0; - // Create an empty species pool (which will be set to one of the species pools based on the index) - let newSpeciesPool: Species[] = []; - let useNewSpeciesPool = false; - - // If we are in a double battle of named trainers, we need to use alternate species pools (generate half the party from each trainer) - if (this.config.trainerTypeDouble && this.isDouble() && !this.config.doubleOnly) { - - // Use the new species pool for this party generation - useNewSpeciesPool = true; - - - // Get the species pool for the partner trainer and the current trainer - const speciesPoolPartner = signatureSpecies[TrainerType[this.config.trainerTypeDouble]]; - const speciesPool = signatureSpecies[TrainerType[this.config.trainerType]]; - - - // Get the species that are already in the enemy party so we dont generate the same species twice - const AlreadyUsedSpecies = battle.enemyParty.map(p => p.species.speciesId); - - // Filter out the species that are already in the enemy party from the main trainer species pool - const speciesPoolFiltered = speciesPool.filter(species => { - // Since some species pools have arrays in them (use either of those species), we need to check if one of the species is already in the party and filter the whole array if it is - if (Array.isArray(species)) { - return !species.some(s => AlreadyUsedSpecies.includes(s)); + if (template instanceof TrainerPartyCompoundTemplate) { + for (const innerTemplate of template.templates) { + if (offset + innerTemplate.size > index) { + break; + } + offset += innerTemplate.size; } - return !AlreadyUsedSpecies.includes(species); - }).flat(); + } - // Filter out the species that are already in the enemy party from the partner trainer species pool - const speciesPoolPartnerFiltered = speciesPoolPartner.filter(species => { - // Since some species pools have arrays in them (use either of those species), we need to check if one of the species is already in the party and filter the whole array if it is - if (Array.isArray(species)) { - return !species.some(s => AlreadyUsedSpecies.includes(s)); - } - return !AlreadyUsedSpecies.includes(species); - }).flat(); + // Create an empty species pool (which will be set to one of the species pools based on the index) + let newSpeciesPool: Species[] = []; + let useNewSpeciesPool = false; + // If we are in a double battle of named trainers, we need to use alternate species pools (generate half the party from each trainer) + if (this.config.trainerTypeDouble && this.isDouble() && !this.config.doubleOnly) { + // Use the new species pool for this party generation + useNewSpeciesPool = true; - // If the index is even, use the species pool for the main trainer (that way he only uses his own pokemon in battle) - if (!(index % 2)) { - // Since the only currently allowed double battle with named trainers is Tate & Liza, we need to make sure that Solrock is the first pokemon in the party for Tate and Lunatone for Liza - if (index === 0 && (TrainerType[this.config.trainerType] === TrainerType[TrainerType.TATE])) { - newSpeciesPool = [ Species.SOLROCK ]; - } else if (index === 0 && (TrainerType[this.config.trainerType] === TrainerType[TrainerType.LIZA])) { - newSpeciesPool = [ Species.LUNATONE ]; + // Get the species pool for the partner trainer and the current trainer + const speciesPoolPartner = signatureSpecies[TrainerType[this.config.trainerTypeDouble]]; + const speciesPool = signatureSpecies[TrainerType[this.config.trainerType]]; + + // Get the species that are already in the enemy party so we dont generate the same species twice + const AlreadyUsedSpecies = battle.enemyParty.map(p => p.species.speciesId); + + // Filter out the species that are already in the enemy party from the main trainer species pool + const speciesPoolFiltered = speciesPool + .filter(species => { + // Since some species pools have arrays in them (use either of those species), we need to check if one of the species is already in the party and filter the whole array if it is + if (Array.isArray(species)) { + return !species.some(s => AlreadyUsedSpecies.includes(s)); + } + return !AlreadyUsedSpecies.includes(species); + }) + .flat(); + + // Filter out the species that are already in the enemy party from the partner trainer species pool + const speciesPoolPartnerFiltered = speciesPoolPartner + .filter(species => { + // Since some species pools have arrays in them (use either of those species), we need to check if one of the species is already in the party and filter the whole array if it is + if (Array.isArray(species)) { + return !species.some(s => AlreadyUsedSpecies.includes(s)); + } + return !AlreadyUsedSpecies.includes(species); + }) + .flat(); + + // If the index is even, use the species pool for the main trainer (that way he only uses his own pokemon in battle) + if (!(index % 2)) { + // Since the only currently allowed double battle with named trainers is Tate & Liza, we need to make sure that Solrock is the first pokemon in the party for Tate and Lunatone for Liza + if (index === 0 && TrainerType[this.config.trainerType] === TrainerType[TrainerType.TATE]) { + newSpeciesPool = [Species.SOLROCK]; + } else if (index === 0 && TrainerType[this.config.trainerType] === TrainerType[TrainerType.LIZA]) { + newSpeciesPool = [Species.LUNATONE]; + } else { + newSpeciesPool = speciesPoolFiltered; + } } else { - newSpeciesPool = speciesPoolFiltered; + // If the index is odd, use the species pool for the partner trainer (that way he only uses his own pokemon in battle) + // Since the only currently allowed double battle with named trainers is Tate & Liza, we need to make sure that Solrock is the first pokemon in the party for Tate and Lunatone for Liza + if (index === 1 && TrainerType[this.config.trainerTypeDouble] === TrainerType[TrainerType.TATE]) { + newSpeciesPool = [Species.SOLROCK]; + } else if (index === 1 && TrainerType[this.config.trainerTypeDouble] === TrainerType[TrainerType.LIZA]) { + newSpeciesPool = [Species.LUNATONE]; + } else { + newSpeciesPool = speciesPoolPartnerFiltered; + } } - } else { - // If the index is odd, use the species pool for the partner trainer (that way he only uses his own pokemon in battle) - // Since the only currently allowed double battle with named trainers is Tate & Liza, we need to make sure that Solrock is the first pokemon in the party for Tate and Lunatone for Liza - if (index === 1 && (TrainerType[this.config.trainerTypeDouble] === TrainerType[TrainerType.TATE])) { - newSpeciesPool = [ Species.SOLROCK ]; - } else if (index === 1 && (TrainerType[this.config.trainerTypeDouble] === TrainerType[TrainerType.LIZA])) { - newSpeciesPool = [ Species.LUNATONE ]; - } else { - newSpeciesPool = speciesPoolPartnerFiltered; + // Fallback for when the species pool is empty + if (newSpeciesPool.length === 0) { + // If all pokemon from this pool are already in the party, generate a random species + useNewSpeciesPool = false; } } - // Fallback for when the species pool is empty - if (newSpeciesPool.length === 0) { - // If all pokemon from this pool are already in the party, generate a random species - useNewSpeciesPool = false; + + // If useNewSpeciesPool is true, we need to generate a new species from the new species pool, otherwise we generate a random species + let species = useNewSpeciesPool + ? getPokemonSpecies(newSpeciesPool[Math.floor(Utils.randSeedInt(newSpeciesPool.length))]) + : template.isSameSpecies(index) && index > offset + ? getPokemonSpecies( + battle.enemyParty[offset].species.getTrainerSpeciesForLevel( + level, + false, + template.getStrength(offset), + globalScene.currentBattle.waveIndex, + ), + ) + : this.genNewPartyMemberSpecies(level, strength); + + // If the species is from newSpeciesPool, we need to adjust it based on the level and strength + if (newSpeciesPool) { + species = getPokemonSpecies( + species.getSpeciesForLevel(level, true, true, strength, globalScene.currentBattle.waveIndex), + ); } - } - // If useNewSpeciesPool is true, we need to generate a new species from the new species pool, otherwise we generate a random species - let species = useNewSpeciesPool - ? getPokemonSpecies(newSpeciesPool[Math.floor(Utils.randSeedInt(newSpeciesPool.length))]) - : template.isSameSpecies(index) && index > offset - ? getPokemonSpecies(battle.enemyParty[offset].species.getTrainerSpeciesForLevel(level, false, template.getStrength(offset), globalScene.currentBattle.waveIndex)) - : this.genNewPartyMemberSpecies(level, strength); - - // If the species is from newSpeciesPool, we need to adjust it based on the level and strength - if (newSpeciesPool) { - species = getPokemonSpecies(species.getSpeciesForLevel(level, true, true, strength, globalScene.currentBattle.waveIndex)); - } - - ret = globalScene.addEnemyPokemon(species, level, !this.isDouble() || !(index % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER); - }, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : globalScene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1) << 8)); + ret = globalScene.addEnemyPokemon( + species, + level, + !this.isDouble() || !(index % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ); + }, + this.config.hasStaticParty + ? this.config.getDerivedType() + ((index + 1) << 8) + : globalScene.currentBattle.waveIndex + + (this.config.getDerivedType() << 10) + + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1) << 8), + ); return ret!; // TODO: is this bang correct? } - genNewPartyMemberSpecies(level: number, strength: PartyMemberStrength, attempt?: number): PokemonSpecies { const battle = globalScene.currentBattle; const template = this.getPartyTemplate(); @@ -390,10 +441,21 @@ export default class Trainer extends Phaser.GameObjects.Container { let baseSpecies: PokemonSpecies; if (this.config.speciesPools) { const tierValue = Utils.randSeedInt(512); - let tier = tierValue >= 156 ? TrainerPoolTier.COMMON : tierValue >= 32 ? TrainerPoolTier.UNCOMMON : tierValue >= 6 ? TrainerPoolTier.RARE : tierValue >= 1 ? TrainerPoolTier.SUPER_RARE : TrainerPoolTier.ULTRA_RARE; + let tier = + tierValue >= 156 + ? TrainerPoolTier.COMMON + : tierValue >= 32 + ? TrainerPoolTier.UNCOMMON + : tierValue >= 6 + ? TrainerPoolTier.RARE + : tierValue >= 1 + ? TrainerPoolTier.SUPER_RARE + : TrainerPoolTier.ULTRA_RARE; console.log(TrainerPoolTier[tier]); while (!this.config.speciesPools.hasOwnProperty(tier) || !this.config.speciesPools[tier].length) { - console.log(`Downgraded trainer Pokemon rarity tier from ${TrainerPoolTier[tier]} to ${TrainerPoolTier[tier - 1]}`); + console.log( + `Downgraded trainer Pokemon rarity tier from ${TrainerPoolTier[tier]} to ${TrainerPoolTier[tier - 1]}`, + ); tier--; } const tierPool = this.config.speciesPools[tier]; @@ -402,7 +464,9 @@ export default class Trainer extends Phaser.GameObjects.Container { baseSpecies = globalScene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter); } - let ret = getPokemonSpecies(baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex)); + let ret = getPokemonSpecies( + baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex), + ); let retry = false; console.log(ret.getName()); @@ -410,8 +474,11 @@ export default class Trainer extends Phaser.GameObjects.Container { if (pokemonPrevolutions.hasOwnProperty(baseSpecies.speciesId) && ret.speciesId !== baseSpecies.speciesId) { retry = true; } else if (template.isBalanced(battle.enemyParty.length)) { - const partyMemberTypes = battle.enemyParty.map(p => p.getTypes(true)).flat(); - if (partyMemberTypes.indexOf(ret.type1) > -1 || (ret.type2 !== null && partyMemberTypes.indexOf(ret.type2) > -1)) { + const partyMemberTypes = battle.enemyParty.flatMap(p => p.getTypes(true)); + if ( + partyMemberTypes.indexOf(ret.type1) > -1 || + (ret.type2 !== null && partyMemberTypes.indexOf(ret.type2) > -1) + ) { retry = true; } } @@ -423,7 +490,9 @@ export default class Trainer extends Phaser.GameObjects.Container { console.log("Attempting reroll of species evolution to fit specialty type..."); let evoAttempt = 0; while (retry && evoAttempt++ < 10) { - ret = getPokemonSpecies(baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex)); + ret = getPokemonSpecies( + baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex), + ); console.log(ret.name); if (ret.isOfType(this.config.specialtyType)) { retry = false; @@ -466,13 +535,16 @@ export default class Trainer extends Phaser.GameObjects.Container { return currentSpecies.includes(baseSpecies) || staticSpecies.includes(baseSpecies); } - getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch: boolean = false): [number, number][] { + getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch = false): [number, number][] { if (trainerSlot && !this.isDouble()) { trainerSlot = TrainerSlot.NONE; } const party = globalScene.getEnemyParty(); - const nonFaintedLegalPartyMembers = party.slice(globalScene.currentBattle.getBattlerCount()).filter(p => p.isAllowedInBattle()).filter(p => !trainerSlot || p.trainerSlot === trainerSlot); + const nonFaintedLegalPartyMembers = party + .slice(globalScene.currentBattle.getBattlerCount()) + .filter(p => p.isAllowedInBattle()) + .filter(p => !trainerSlot || p.trainerSlot === trainerSlot); const partyMemberScores = nonFaintedLegalPartyMembers.map(p => { const playerField = globalScene.getPlayerField().filter(p => p.isAllowedInBattle()); let score = 0; @@ -486,11 +558,13 @@ export default class Trainer extends Phaser.GameObjects.Container { } score /= playerField.length; if (forSwitch && !p.isOnField()) { - globalScene.arena.findTagsOnSide(t => t instanceof ArenaTrapTag, ArenaTagSide.ENEMY).map(t => score *= (t as ArenaTrapTag).getMatchupScoreMultiplier(p)); + globalScene.arena + .findTagsOnSide(t => t instanceof ArenaTrapTag, ArenaTagSide.ENEMY) + .map(t => (score *= (t as ArenaTrapTag).getMatchupScoreMultiplier(p))); } } - return [ party.indexOf(p), score ]; + return [party.indexOf(p), score]; }) as [number, number][]; return partyMemberScores; @@ -507,18 +581,26 @@ export default class Trainer extends Phaser.GameObjects.Container { return sortedPartyMemberScores; } - getNextSummonIndex(trainerSlot: TrainerSlot = TrainerSlot.NONE, partyMemberScores: [number, number][] = this.getPartyMemberMatchupScores(trainerSlot)): number { + getNextSummonIndex( + trainerSlot: TrainerSlot = TrainerSlot.NONE, + partyMemberScores: [number, number][] = this.getPartyMemberMatchupScores(trainerSlot), + ): number { if (trainerSlot && !this.isDouble()) { trainerSlot = TrainerSlot.NONE; } const sortedPartyMemberScores = this.getSortedPartyMemberMatchupScores(partyMemberScores); - const maxScorePartyMemberIndexes = partyMemberScores.filter(pms => pms[1] === sortedPartyMemberScores[0][1]).map(pms => pms[0]); + const maxScorePartyMemberIndexes = partyMemberScores + .filter(pms => pms[1] === sortedPartyMemberScores[0][1]) + .map(pms => pms[0]); if (maxScorePartyMemberIndexes.length > 1) { let rand: number; - globalScene.executeWithSeedOffset(() => rand = Utils.randSeedInt(maxScorePartyMemberIndexes.length), globalScene.currentBattle.turn << 2); + globalScene.executeWithSeedOffset( + () => (rand = Utils.randSeedInt(maxScorePartyMemberIndexes.length)), + globalScene.currentBattle.turn << 2, + ); return maxScorePartyMemberIndexes[rand!]; } @@ -574,7 +656,11 @@ export default class Trainer extends Phaser.GameObjects.Container { * @param animConfig {@linkcode Phaser.Types.Animations.PlayAnimationConfig} to pass to {@linkcode Phaser.GameObjects.Sprite.play} * @returns true if the sprite was able to be animated */ - tryPlaySprite(sprite: Phaser.GameObjects.Sprite, tintSprite: Phaser.GameObjects.Sprite, animConfig: Phaser.Types.Animations.PlayAnimationConfig): boolean { + tryPlaySprite( + sprite: Phaser.GameObjects.Sprite, + tintSprite: Phaser.GameObjects.Sprite, + animConfig: Phaser.Types.Animations.PlayAnimationConfig, + ): boolean { // Show an error in the console if there isn't a texture loaded if (sprite.texture.key === "__MISSING") { console.error(`No texture found for '${animConfig.key}'!`); @@ -598,7 +684,7 @@ export default class Trainer extends Phaser.GameObjects.Container { const trainerAnimConfig = { key: this.getKey(), repeat: 0, - startFrame: 0 + startFrame: 0, }; const sprites = this.getSprites(); const tintSprites = this.getTintSprites(); @@ -610,7 +696,7 @@ export default class Trainer extends Phaser.GameObjects.Container { const partnerTrainerAnimConfig = { key: this.getKey(true), repeat: 0, - startFrame: 0 + startFrame: 0, }; this.tryPlaySprite(sprites[1], tintSprites[1], partnerTrainerAnimConfig); @@ -618,9 +704,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } getSprites(): Phaser.GameObjects.Sprite[] { - const ret: Phaser.GameObjects.Sprite[] = [ - this.getAt(0) - ]; + const ret: Phaser.GameObjects.Sprite[] = [this.getAt(0)]; if (this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) { ret.push(this.getAt(2)); } @@ -628,9 +712,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } getTintSprites(): Phaser.GameObjects.Sprite[] { - const ret: Phaser.GameObjects.Sprite[] = [ - this.getAt(1) - ]; + const ret: Phaser.GameObjects.Sprite[] = [this.getAt(1)]; if (this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) { ret.push(this.getAt(3)); } @@ -650,7 +732,7 @@ export default class Trainer extends Phaser.GameObjects.Container { targets: tintSprite, alpha: alpha || 1, duration: duration, - ease: ease || "Linear" + ease: ease || "Linear", }); } else { tintSprite.setAlpha(alpha); @@ -670,7 +752,7 @@ export default class Trainer extends Phaser.GameObjects.Container { onComplete: () => { tintSprite.setVisible(false); tintSprite.setAlpha(1); - } + }, }); } else { tintSprite.setVisible(false); diff --git a/src/game-mode.ts b/src/game-mode.ts index 1da125ea55a..9ab1674bcce 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -19,7 +19,7 @@ export enum GameModes { ENDLESS, SPLICED_ENDLESS, DAILY, - CHALLENGE + CHALLENGE, } interface GameModeConfig { @@ -37,8 +37,8 @@ interface GameModeConfig { } // Describes min and max waves for MEs in specific game modes -export const CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES: [number, number] = [ 10, 180 ]; -export const CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES: [number, number] = [ 10, 180 ]; +export const CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES: [number, number] = [10, 180]; +export const CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES: [number, number] = [10, 180]; export class GameMode implements GameModeConfig { public modeId: GameModes; @@ -127,7 +127,7 @@ export class GameMode implements GameModeConfig { } } - getWaveForDifficulty(waveIndex: number, ignoreCurveChanges: boolean = false): number { + getWaveForDifficulty(waveIndex: number, ignoreCurveChanges = false): number { switch (this.modeId) { case GameModes.DAILY: return waveIndex + 30 + (!ignoreCurveChanges ? Math.floor(waveIndex / 5) : 0); @@ -149,9 +149,10 @@ export class GameMode implements GameModeConfig { if (this.isDaily) { return waveIndex % 10 === 5 || (!(waveIndex % 10) && waveIndex > 10 && !this.isWaveFinal(waveIndex)); } - if ((waveIndex % 30) === (globalScene.offsetGym ? 0 : 20) && !this.isWaveFinal(waveIndex)) { + if (waveIndex % 30 === (globalScene.offsetGym ? 0 : 20) && !this.isWaveFinal(waveIndex)) { return true; - } else if (waveIndex % 10 !== 1 && waveIndex % 10) { + } + if (waveIndex % 10 !== 1 && waveIndex % 10) { /** * Do not check X1 floors since there's a bug that stops trainer sprites from appearing * after a X0 full party heal @@ -165,10 +166,11 @@ export class GameMode implements GameModeConfig { if (w === waveIndex) { continue; } - if ((w % 30) === (globalScene.offsetGym ? 0 : 20) || this.isFixedBattle(w)) { + if (w % 30 === (globalScene.offsetGym ? 0 : 20) || this.isFixedBattle(w)) { allowTrainerBattle = false; break; - } else if (w < waveIndex) { + } + if (w < waveIndex) { globalScene.executeWithSeedOffset(() => { const waveTrainerChance = arena.getTrainerChance(); if (!Utils.randSeedInt(waveTrainerChance)) { @@ -191,14 +193,22 @@ export class GameMode implements GameModeConfig { case GameModes.DAILY: return waveIndex > 10 && waveIndex < 50 && !(waveIndex % 10); default: - return (waveIndex % 30) === (offsetGym ? 0 : 20) && (biomeType !== Biome.END || this.isClassic || this.isWaveFinal(waveIndex)); + return ( + waveIndex % 30 === (offsetGym ? 0 : 20) && + (biomeType !== Biome.END || this.isClassic || this.isWaveFinal(waveIndex)) + ); } } getOverrideSpecies(waveIndex: number): PokemonSpecies | null { if (this.isDaily && this.isWaveFinal(waveIndex)) { - const allFinalBossSpecies = allSpecies.filter(s => (s.subLegendary || s.legendary || s.mythical) - && s.baseTotal >= 600 && s.speciesId !== Species.ETERNATUS && s.speciesId !== Species.ARCEUS); + const allFinalBossSpecies = allSpecies.filter( + s => + (s.subLegendary || s.legendary || s.mythical) && + s.baseTotal >= 600 && + s.speciesId !== Species.ETERNATUS && + s.speciesId !== Species.ARCEUS, + ); return Utils.randSeedItem(allFinalBossSpecies); } @@ -225,9 +235,9 @@ export class GameMode implements GameModeConfig { } /** - * Every 10 waves is a boss battle - * @returns true if waveIndex is a multiple of 10 - */ + * Every 10 waves is a boss battle + * @returns true if waveIndex is a multiple of 10 + */ isBoss(waveIndex: number): boolean { return waveIndex % 10 === 0; } @@ -240,33 +250,30 @@ export class GameMode implements GameModeConfig { } /** - * Every 50 waves of an Endless mode is a boss - * At this time it is paradox pokemon - * @returns true if waveIndex is a multiple of 50 in Endless - */ + * Every 50 waves of an Endless mode is a boss + * At this time it is paradox pokemon + * @returns true if waveIndex is a multiple of 50 in Endless + */ isEndlessBoss(waveIndex: number): boolean { - return waveIndex % 50 === 0 && - (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); + return waveIndex % 50 === 0 && (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); } /** - * Every 250 waves of an Endless mode is a minor boss - * At this time it is Eternatus - * @returns true if waveIndex is a multiple of 250 in Endless - */ + * Every 250 waves of an Endless mode is a minor boss + * At this time it is Eternatus + * @returns true if waveIndex is a multiple of 250 in Endless + */ isEndlessMinorBoss(waveIndex: number): boolean { - return waveIndex % 250 === 0 && - (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); + return waveIndex % 250 === 0 && (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); } /** - * Every 1000 waves of an Endless mode is a major boss - * At this time it is Eternamax Eternatus - * @returns true if waveIndex is a multiple of 1000 in Endless - */ + * Every 1000 waves of an Endless mode is a major boss + * At this time it is Eternamax Eternatus + * @returns true if waveIndex is a multiple of 1000 in Endless + */ isEndlessMajorBoss(waveIndex: number): boolean { - return waveIndex % 1000 === 0 && - (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); + return waveIndex % 1000 === 0 && (this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS); } /** @@ -276,7 +283,10 @@ export class GameMode implements GameModeConfig { */ isFixedBattle(waveIndex: number): boolean { const dummyConfig = new FixedBattleConfig(); - return this.battleConfig.hasOwnProperty(waveIndex) || applyChallenges(this, ChallengeType.FIXED_BATTLES, waveIndex, dummyConfig); + return ( + this.battleConfig.hasOwnProperty(waveIndex) || + applyChallenges(this, ChallengeType.FIXED_BATTLES, waveIndex, dummyConfig) + ); } /** @@ -288,12 +298,10 @@ export class GameMode implements GameModeConfig { const challengeConfig = new FixedBattleConfig(); if (applyChallenges(this, ChallengeType.FIXED_BATTLES, waveIndex, challengeConfig)) { return challengeConfig; - } else { - return this.battleConfig[waveIndex]; } + return this.battleConfig[waveIndex]; } - getClearScoreBonus(): number { switch (this.modeId) { case GameModes.CLASSIC: @@ -338,12 +346,12 @@ export class GameMode implements GameModeConfig { */ getMysteryEncounterLegalWaves(): [number, number] { switch (this.modeId) { - default: - return [ 0, 0 ]; case GameModes.CLASSIC: return CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES; case GameModes.CHALLENGE: return CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES; + default: + return [0, 0]; } } @@ -366,14 +374,40 @@ export class GameMode implements GameModeConfig { export function getGameMode(gameMode: GameModes): GameMode { switch (gameMode) { case GameModes.CLASSIC: - return new GameMode(GameModes.CLASSIC, { isClassic: true, hasTrainers: true, hasMysteryEncounters: true }, classicFixedBattles); + return new GameMode( + GameModes.CLASSIC, + { isClassic: true, hasTrainers: true, hasMysteryEncounters: true }, + classicFixedBattles, + ); case GameModes.ENDLESS: - return new GameMode(GameModes.ENDLESS, { isEndless: true, hasShortBiomes: true, hasRandomBosses: true }); + return new GameMode(GameModes.ENDLESS, { + isEndless: true, + hasShortBiomes: true, + hasRandomBosses: true, + }); case GameModes.SPLICED_ENDLESS: - return new GameMode(GameModes.SPLICED_ENDLESS, { isEndless: true, hasShortBiomes: true, hasRandomBosses: true, isSplicedOnly: true }); + return new GameMode(GameModes.SPLICED_ENDLESS, { + isEndless: true, + hasShortBiomes: true, + hasRandomBosses: true, + isSplicedOnly: true, + }); case GameModes.DAILY: - return new GameMode(GameModes.DAILY, { isDaily: true, hasTrainers: true, hasNoShop: true }); + return new GameMode(GameModes.DAILY, { + isDaily: true, + hasTrainers: true, + hasNoShop: true, + }); case GameModes.CHALLENGE: - return new GameMode(GameModes.CHALLENGE, { isClassic: true, hasTrainers: true, isChallenge: true, hasMysteryEncounters: true }, classicFixedBattles); + return new GameMode( + GameModes.CHALLENGE, + { + isClassic: true, + hasTrainers: true, + isChallenge: true, + hasMysteryEncounters: true, + }, + classicFixedBattles, + ); } } diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 392761cf8e4..fb4555084ee 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -10,11 +10,7 @@ import { Mode } from "./ui/ui"; 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"; -import { - assign, - getButtonWithKeycode, - getIconForLatestInput, swap, -} from "#app/configs/inputs/configHandler"; +import { assign, getButtonWithKeycode, getIconForLatestInput, swap } from "#app/configs/inputs/configHandler"; import { globalScene } from "#app/global-scene"; import type { SettingGamepad } from "#app/system/settings/settings-gamepad"; import type { SettingKeyboard } from "#app/system/settings/settings-keyboard"; @@ -24,29 +20,29 @@ import { Device } from "#enums/devices"; import MoveTouchControlsHandler from "./ui/settings/move-touch-controls-handler"; export interface DeviceMapping { - [key: string]: number; + [key: string]: number; } export interface IconsMapping { - [key: string]: string; + [key: string]: string; } export interface SettingMapping { - [key: string]: Button; + [key: string]: Button; } export interface MappingLayout { - [key: string]: SettingGamepad | SettingKeyboard | number; + [key: string]: SettingGamepad | SettingKeyboard | number; } export interface InterfaceConfig { - padID: string; - padType: string; - deviceMapping: DeviceMapping; - icons: IconsMapping; - settings: SettingMapping; - default: MappingLayout; - custom?: MappingLayout; + padID: string; + padType: string; + deviceMapping: DeviceMapping; + icons: IconsMapping; + settings: SettingMapping; + default: MappingLayout; + custom?: MappingLayout; } const repeatInputDelayMillis = 250; @@ -81,30 +77,29 @@ export class InputsController { private interactions: Map> = new Map(); private configs: Map = new Map(); - public gamepadSupport: boolean = true; + public gamepadSupport = true; public selectedDevice; - private disconnectedGamepads: Array = new Array(); + private disconnectedGamepads: Array = new Array(); - - public lastSource: string = "keyboard"; + public lastSource = "keyboard"; private inputInterval: NodeJS.Timeout[] = new Array(); private touchControls: TouchControl; public moveTouchControlsHandler: MoveTouchControlsHandler; /** - * Initializes a new instance of the game control system, setting up initial state and configurations. - * - * @remarks - * This constructor initializes the game control system with necessary setups for handling inputs. - * It prepares an interactions array indexed by button identifiers and configures default states for each button. - * Specific buttons like MENU and STATS are set not to repeat their actions. - * It concludes by calling the `init` method to complete the setup. - */ + * Initializes a new instance of the game control system, setting up initial state and configurations. + * + * @remarks + * This constructor initializes the game control system with necessary setups for handling inputs. + * It prepares an interactions array indexed by button identifiers and configures default states for each button. + * Specific buttons like MENU and STATS are set not to repeat their actions. + * It concludes by calling the `init` method to complete the setup. + */ constructor() { this.selectedDevice = { [Device.GAMEPAD]: null, - [Device.KEYBOARD]: "default" + [Device.KEYBOARD]: "default", }; for (const b of Utils.getEnumValues(Button)) { @@ -121,13 +116,13 @@ export class InputsController { } /** - * Sets up event handlers and initializes gamepad and keyboard controls. - * - * @remarks - * This method configures event listeners for both gamepad and keyboard inputs. - * It handles gamepad connections/disconnections and button press events, and ensures keyboard controls are set up. - * Additionally, it manages the game's behavior when it loses focus to prevent unwanted game actions during this state. - */ + * Sets up event handlers and initializes gamepad and keyboard controls. + * + * @remarks + * This method configures event listeners for both gamepad and keyboard inputs. + * It handles gamepad connections/disconnections and button press events, and ensures keyboard controls are set up. + * Additionally, it manages the game's behavior when it loses focus to prevent unwanted game actions during this state. + */ init(): void { this.events = globalScene.game.events; @@ -136,18 +131,26 @@ export class InputsController { }); if (typeof globalScene.input.gamepad !== "undefined") { - globalScene.input.gamepad?.on("connected", function (thisGamepad) { - if (!thisGamepad) { - return; - } - this.refreshGamepads(); - this.setupGamepad(thisGamepad); - this.onReconnect(thisGamepad); - }, this); + globalScene.input.gamepad?.on( + "connected", + function (thisGamepad) { + if (!thisGamepad) { + return; + } + this.refreshGamepads(); + this.setupGamepad(thisGamepad); + this.onReconnect(thisGamepad); + }, + this, + ); - globalScene.input.gamepad?.on("disconnected", function (thisGamepad) { - this.onDisconnect(thisGamepad); // when a gamepad is disconnected - }, this); + globalScene.input.gamepad?.on( + "disconnected", + function (thisGamepad) { + this.onDisconnect(thisGamepad); // when a gamepad is disconnected + }, + this, + ); // Check to see if the gamepad has already been setup by the browser globalScene.input.gamepad?.refreshPads(); @@ -168,24 +171,24 @@ export class InputsController { } /** - * Handles actions to take when the game loses focus, such as deactivating pressed keys. - * - * @remarks - * This method is triggered when the game or the browser tab loses focus. It ensures that any keys pressed are deactivated to prevent stuck keys affecting gameplay when the game is not active. - */ + * Handles actions to take when the game loses focus, such as deactivating pressed keys. + * + * @remarks + * This method is triggered when the game or the browser tab loses focus. It ensures that any keys pressed are deactivated to prevent stuck keys affecting gameplay when the game is not active. + */ loseFocus(): void { this.deactivatePressedKey(); this.touchControls.deactivatePressedKey(); } /** - * Enables or disables support for gamepad input. - * - * @param value - A boolean indicating whether gamepad support should be enabled (true) or disabled (false). - * - * @remarks - * This method toggles gamepad support. If disabled, it also ensures that all currently pressed gamepad buttons are deactivated to avoid stuck inputs. - */ + * Enables or disables support for gamepad input. + * + * @param value - A boolean indicating whether gamepad support should be enabled (true) or disabled (false). + * + * @remarks + * This method toggles gamepad support. If disabled, it also ensures that all currently pressed gamepad buttons are deactivated to avoid stuck inputs. + */ setGamepadSupport(value: boolean): void { if (value) { this.gamepadSupport = true; @@ -196,92 +199,92 @@ export class InputsController { } /** - * Sets the currently chosen gamepad and initializes related settings. - * This method first deactivates any active key presses and then initializes the gamepad settings. - * - * @param gamepad - The identifier of the gamepad to set as chosen. - */ - setChosenGamepad(gamepad: String): void { + * Sets the currently chosen gamepad and initializes related settings. + * This method first deactivates any active key presses and then initializes the gamepad settings. + * + * @param gamepad - The identifier of the gamepad to set as chosen. + */ + setChosenGamepad(gamepad: string): void { this.deactivatePressedKey(); this.initChosenGamepad(gamepad); } /** - * Sets the currently chosen keyboard layout and initializes related settings. - * - * @param layoutKeyboard - The identifier of the keyboard layout to set as chosen. - */ - setChosenKeyboardLayout(layoutKeyboard: String): void { + * Sets the currently chosen keyboard layout and initializes related settings. + * + * @param layoutKeyboard - The identifier of the keyboard layout to set as chosen. + */ + setChosenKeyboardLayout(layoutKeyboard: string): void { this.deactivatePressedKey(); this.initChosenLayoutKeyboard(layoutKeyboard); } /** - * Retrieves the identifiers of all connected gamepads, excluding any that are currently marked as disconnected. - * @returns Array An array of strings representing the IDs of the connected gamepads. - */ - getGamepadsName(): Array { + * Retrieves the identifiers of all connected gamepads, excluding any that are currently marked as disconnected. + * @returns Array An array of strings representing the IDs of the connected gamepads. + */ + getGamepadsName(): Array { return this.gamepads.filter(g => !this.disconnectedGamepads.includes(g.id)).map(g => g.id); } /** - * Initializes the chosen gamepad by setting its identifier in the local storage and updating the UI to reflect the chosen gamepad. - * If a gamepad name is provided, it uses that as the chosen gamepad; otherwise, it defaults to the currently chosen gamepad. - * @param gamepadName Optional parameter to specify the name of the gamepad to initialize as chosen. - */ - initChosenGamepad(gamepadName?: String): void { + * Initializes the chosen gamepad by setting its identifier in the local storage and updating the UI to reflect the chosen gamepad. + * If a gamepad name is provided, it uses that as the chosen gamepad; otherwise, it defaults to the currently chosen gamepad. + * @param gamepadName Optional parameter to specify the name of the gamepad to initialize as chosen. + */ + initChosenGamepad(gamepadName?: string): void { if (gamepadName) { this.selectedDevice[Device.GAMEPAD] = gamepadName.toLowerCase(); } const handler = globalScene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; - handler && handler.updateChosenGamepadDisplay(); + handler?.updateChosenGamepadDisplay(); } /** - * Initializes the chosen keyboard layout by setting its identifier in the local storage and updating the UI to reflect the chosen layout. - * If a layout name is provided, it uses that as the chosen layout; otherwise, it defaults to the currently chosen layout. - * @param layoutKeyboard Optional parameter to specify the name of the keyboard layout to initialize as chosen. - */ - initChosenLayoutKeyboard(layoutKeyboard?: String): void { + * Initializes the chosen keyboard layout by setting its identifier in the local storage and updating the UI to reflect the chosen layout. + * If a layout name is provided, it uses that as the chosen layout; otherwise, it defaults to the currently chosen layout. + * @param layoutKeyboard Optional parameter to specify the name of the keyboard layout to initialize as chosen. + */ + initChosenLayoutKeyboard(layoutKeyboard?: string): void { if (layoutKeyboard) { this.selectedDevice[Device.KEYBOARD] = layoutKeyboard.toLowerCase(); } const handler = globalScene.ui?.handlers[Mode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler; - handler && handler.updateChosenKeyboardDisplay(); + handler?.updateChosenKeyboardDisplay(); } /** - * Handles the disconnection of a gamepad by adding its identifier to a list of disconnected gamepads. - * This is necessary because Phaser retains memory of previously connected gamepads, and without tracking - * disconnections, it would be impossible to determine the connection status of gamepads. This method ensures - * that disconnected gamepads are recognized and can be appropriately hidden in the gamepad selection menu. - * - * @param thisGamepad The gamepad that has been disconnected. - */ + * Handles the disconnection of a gamepad by adding its identifier to a list of disconnected gamepads. + * This is necessary because Phaser retains memory of previously connected gamepads, and without tracking + * disconnections, it would be impossible to determine the connection status of gamepads. This method ensures + * that disconnected gamepads are recognized and can be appropriately hidden in the gamepad selection menu. + * + * @param thisGamepad The gamepad that has been disconnected. + */ onDisconnect(thisGamepad: Phaser.Input.Gamepad.Gamepad): void { this.disconnectedGamepads.push(thisGamepad.id); } /** - * Updates the tracking of disconnected gamepads when a gamepad is reconnected. - * It removes the reconnected gamepad's identifier from the `disconnectedGamepads` array, - * effectively updating its status to connected. - * - * @param thisGamepad The gamepad that has been reconnected. - */ + * Updates the tracking of disconnected gamepads when a gamepad is reconnected. + * It removes the reconnected gamepad's identifier from the `disconnectedGamepads` array, + * effectively updating its status to connected. + * + * @param thisGamepad The gamepad that has been reconnected. + */ onReconnect(thisGamepad: Phaser.Input.Gamepad.Gamepad): void { this.disconnectedGamepads = this.disconnectedGamepads.filter(g => g !== thisGamepad.id); } /** - * Initializes or updates configurations for connected gamepads. - * It retrieves the names of all connected gamepads, sets up their configurations according to stored or default settings, - * and ensures these configurations are saved. If the connected gamepad is the currently chosen one, - * it reinitializes the chosen gamepad settings. - * - * @param thisGamepad The gamepad that is being set up. - */ - setupGamepad(thisGamepad: Phaser.Input.Gamepad.Gamepad): void { + * Initializes or updates configurations for connected gamepads. + * It retrieves the names of all connected gamepads, sets up their configurations according to stored or default settings, + * and ensures these configurations are saved. If the connected gamepad is the currently chosen one, + * it reinitializes the chosen gamepad settings. + * + * @param thisGamepad The gamepad that is being set up. + */ + setupGamepad(_thisGamepad: Phaser.Input.Gamepad.Gamepad): void { const allGamepads = this.getGamepadsName(); for (const gamepad of allGamepads) { const gamepadID = gamepad.toLowerCase(); @@ -295,14 +298,14 @@ export class InputsController { } this.lastSource = "gamepad"; const handler = globalScene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler; - handler && handler.updateChosenGamepadDisplay(); + handler?.updateChosenGamepadDisplay(); } /** - * Initializes or updates configurations for connected keyboards. - */ + * Initializes or updates configurations for connected keyboards. + */ setupKeyboard(): void { - for (const layout of [ "default" ]) { + for (const layout of ["default"]) { const config = deepCopy(this.getConfigKeyboard(layout)) as InterfaceConfig; config.custom = this.configs[layout]?.custom || { ...config.default }; this.configs[layout] = config; @@ -312,28 +315,26 @@ export class InputsController { } /** - * Refreshes and re-indexes the list of connected gamepads. - * - * @remarks - * This method updates the list of gamepads to exclude any that are undefined. - * It corrects the index of each gamepad to account for any previously undefined entries, - * ensuring that all gamepads are properly indexed and can be accurately referenced within the game. - */ + * Refreshes and re-indexes the list of connected gamepads. + * + * @remarks + * This method updates the list of gamepads to exclude any that are undefined. + * It corrects the index of each gamepad to account for any previously undefined entries, + * ensuring that all gamepads are properly indexed and can be accurately referenced within the game. + */ refreshGamepads(): void { // Sometimes, gamepads are undefined. For some reason. - this.gamepads = globalScene.input.gamepad?.gamepads.filter(function (el) { - return el !== null; - }) ?? []; + this.gamepads = globalScene.input.gamepad?.gamepads.filter(el => el !== null) ?? []; - for (const [ index, thisGamepad ] of this.gamepads.entries()) { + for (const [index, thisGamepad] of this.gamepads.entries()) { thisGamepad.index = index; // Overwrite the gamepad index, in case we had undefined gamepads earlier } } /** - * Ensures the keyboard is initialized by checking if there is an active configuration for the keyboard. - * If not, it sets up the keyboard with default configurations. - */ + * Ensures the keyboard is initialized by checking if there is an active configuration for the keyboard. + * If not, it sets up the keyboard with default configurations. + */ ensureKeyboardIsInit(): void { if (!this.getActiveConfig(Device.KEYBOARD)?.padID) { this.setupKeyboard(); @@ -341,10 +342,10 @@ export class InputsController { } /** - * Handles the keydown event for the keyboard. - * - * @param event The keyboard event. - */ + * Handles the keydown event for the keyboard. + * + * @param event The keyboard event. + */ keyboardKeyDown(event): void { this.lastSource = "keyboard"; this.ensureKeyboardIsInit(); @@ -369,10 +370,10 @@ export class InputsController { } /** - * Handles the keyup event for the keyboard. - * - * @param event The keyboard event. - */ + * Handles the keyup event for the keyboard. + * + * @param event The keyboard event. + */ keyboardKeyUp(event): void { this.lastSource = "keyboard"; const buttonUp = getButtonWithKeycode(this.getActiveConfig(Device.KEYBOARD), event.keyCode); @@ -388,15 +389,15 @@ export class InputsController { } /** - * Handles button press events on a gamepad. This method sets the gamepad as chosen on the first input if no gamepad is currently chosen. - * It checks if gamepad support is enabled and if the event comes from the chosen gamepad. If so, it maps the button press to a specific - * action using a custom configuration, emits an event for the button press, and records the time of the action. - * - * @param pad The gamepad on which the button was pressed. - * @param button The specific button that was pressed. - * @param value The intensity or value of the button press, if applicable. - */ - gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { + * Handles button press events on a gamepad. This method sets the gamepad as chosen on the first input if no gamepad is currently chosen. + * It checks if gamepad support is enabled and if the event comes from the chosen gamepad. If so, it maps the button press to a specific + * action using a custom configuration, emits an event for the button press, and records the time of the action. + * + * @param pad The gamepad on which the button was pressed. + * @param button The specific button that was pressed. + * @param value The intensity or value of the button press, if applicable. + */ + gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, _value: number): void { if (!this.configs[this.selectedDevice[Device.KEYBOARD]]?.padID) { this.setupKeyboard(); } @@ -404,7 +405,11 @@ export class InputsController { return; } this.lastSource = "gamepad"; - if (!this.selectedDevice[Device.GAMEPAD] || (globalScene.ui.getMode() !== Mode.GAMEPAD_BINDING && this.selectedDevice[Device.GAMEPAD] !== pad.id.toLowerCase())) { + if ( + !this.selectedDevice[Device.GAMEPAD] || + (globalScene.ui.getMode() !== Mode.GAMEPAD_BINDING && + this.selectedDevice[Device.GAMEPAD] !== pad.id.toLowerCase()) + ) { this.setChosenGamepad(pad.id); } if (!this.gamepadSupport || pad.id.toLowerCase() !== this.selectedDevice[Device.GAMEPAD].toLowerCase()) { @@ -436,15 +441,15 @@ export class InputsController { } /** - * Responds to a button release event on a gamepad by checking if the gamepad is supported and currently chosen. - * If conditions are met, it identifies the configured action for the button, emits an event signaling the button release, - * and clears the record of the button. - * - * @param pad The gamepad from which the button was released. - * @param button The specific button that was released. - * @param value The intensity or value of the button release, if applicable. - */ - gamepadButtonUp(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { + * Responds to a button release event on a gamepad by checking if the gamepad is supported and currently chosen. + * If conditions are met, it identifies the configured action for the button, emits an event signaling the button release, + * and clears the record of the button. + * + * @param pad The gamepad from which the button was released. + * @param button The specific button that was released. + * @param value The intensity or value of the button release, if applicable. + */ + gamepadButtonUp(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, _value: number): void { if (!pad) { return; } @@ -465,23 +470,26 @@ export class InputsController { } /** - * Retrieves the configuration object for a gamepad based on its identifier. The method identifies specific gamepad models - * based on substrings in the identifier and returns predefined configurations for recognized models. - * If no specific configuration matches, it defaults to a generic gamepad configuration. - * - * @param id The identifier string of the gamepad. - * @returns InterfaceConfig The configuration object corresponding to the identified gamepad type. - */ + * Retrieves the configuration object for a gamepad based on its identifier. The method identifies specific gamepad models + * based on substrings in the identifier and returns predefined configurations for recognized models. + * If no specific configuration matches, it defaults to a generic gamepad configuration. + * + * @param id The identifier string of the gamepad. + * @returns InterfaceConfig The configuration object corresponding to the identified gamepad type. + */ getConfig(id: string): InterfaceConfig { id = id.toLowerCase(); if (id.includes("081f") && id.includes("e401")) { return pad_unlicensedSNES; - } else if (id.includes("xbox") && id.includes("360")) { + } + if (id.includes("xbox") && id.includes("360")) { return pad_xbox360; - } else if (id.includes("054c")) { + } + if (id.includes("054c")) { return pad_dualshock; - } else if (id.includes("057e") && id.includes("2009")) { + } + if (id.includes("057e") && id.includes("2009")) { return pad_procon; } @@ -489,11 +497,11 @@ export class InputsController { } /** - * Retrieves the configuration object for a keyboard layout based on its identifier. - * - * @param id The identifier string of the keyboard layout. - * @returns InterfaceConfig The configuration object corresponding to the identified keyboard layout. - */ + * Retrieves the configuration object for a keyboard layout based on its identifier. + * + * @param id The identifier string of the keyboard layout. + * @returns InterfaceConfig The configuration object corresponding to the identified keyboard layout. + */ getConfigKeyboard(id: string): InterfaceConfig { if (id === "default") { return cfg_keyboard_qwerty; @@ -503,8 +511,8 @@ export class InputsController { } /** - * Deactivates all currently pressed keys. - */ + * Deactivates all currently pressed keys. + */ deactivatePressedKey(): void { for (const key of Object.keys(this.inputInterval)) { clearInterval(this.inputInterval[key]); @@ -513,11 +521,11 @@ export class InputsController { } /** - * Retrieves the active configuration for the currently chosen device. - * It checks if a specific device ID is stored in configurations and returns it. - * - * @returns InterfaceConfig The configuration object for the active gamepad, or null if not set. - */ + * Retrieves the active configuration for the currently chosen device. + * It checks if a specific device ID is stored in configurations and returns it. + * + * @returns InterfaceConfig The configuration object for the active gamepad, or null if not set. + */ getActiveConfig(device: Device) { if (this.configs[this.selectedDevice[device]]?.padID) { return this.configs[this.selectedDevice[device]]; @@ -535,9 +543,8 @@ export class InputsController { getLastSourceDevice(): Device { if (this.lastSource === "gamepad") { return Device.GAMEPAD; - } else { - return Device.KEYBOARD; } + return Device.KEYBOARD; } getLastSourceConfig() { @@ -554,19 +561,19 @@ export class InputsController { } /** - * Injects a custom mapping configuration into the configuration for a specific gamepad. - * If the device does not have an existing configuration, it initializes one first. - * - * @param selectedDevice The identifier of the device to configure. - * @param mappingConfigs The mapping configuration to apply to the device. - */ + * Injects a custom mapping configuration into the configuration for a specific gamepad. + * If the device does not have an existing configuration, it initializes one first. + * + * @param selectedDevice The identifier of the device to configure. + * @param mappingConfigs The mapping configuration to apply to the device. + */ injectConfig(selectedDevice: string, mappingConfigs): void { if (!this.configs[selectedDevice]) { this.configs[selectedDevice] = {}; } // A proper way of handling migrating keybinds would be much better const mappingOverrides = { - "BUTTON_CYCLE_VARIANT": "BUTTON_CYCLE_TERA", + BUTTON_CYCLE_VARIANT: "BUTTON_CYCLE_TERA", }; for (const key in mappingConfigs.custom) { if (mappingConfigs.custom[key] in mappingOverrides) { @@ -585,18 +592,17 @@ export class InputsController { } /** - * Swaps a binding in the configuration. - * - * @param config The configuration object. - * @param settingName The name of the setting to swap. - * @param pressedButton The button that was pressed. - */ + * Swaps a binding in the configuration. + * + * @param config The configuration object. + * @param settingName The name of the setting to swap. + * @param pressedButton The button that was pressed. + */ assignBinding(config, settingName, pressedButton): boolean { this.deactivatePressedKey(); if (config.padType === "keyboard") { return assign(config, settingName, pressedButton); - } else { - return swap(config, settingName, pressedButton); } + return swap(config, settingName, pressedButton); } } diff --git a/src/interfaces/locales.ts b/src/interfaces/locales.ts index 4405095e0fe..2d26911f82f 100644 --- a/src/interfaces/locales.ts +++ b/src/interfaces/locales.ts @@ -1,93 +1,93 @@ export interface Localizable { - localize(): void; - } + localize(): void; +} export interface TranslationEntries { - [key: string]: string | { [key: string]: string } + [key: string]: string | { [key: string]: string }; } export interface SimpleTranslationEntries { - [key: string]: string - } + [key: string]: string; +} export interface MoveTranslationEntry { - name: string, - effect: string - } + name: string; + effect: string; +} export interface MoveTranslationEntries { - [key: string]: MoveTranslationEntry - } + [key: string]: MoveTranslationEntry; +} export interface AbilityTranslationEntry { - name: string, - description: string - } + name: string; + description: string; +} export interface AbilityTranslationEntries { - [key: string]: AbilityTranslationEntry - } + [key: string]: AbilityTranslationEntry; +} export interface ModifierTypeTranslationEntry { - name?: string, - description?: string, - extra?: SimpleTranslationEntries - } + name?: string; + description?: string; + extra?: SimpleTranslationEntries; +} export interface ModifierTypeTranslationEntries { - ModifierType: { [key: string]: ModifierTypeTranslationEntry }, - SpeciesBoosterItem: { [key: string]: ModifierTypeTranslationEntry }, - AttackTypeBoosterItem: SimpleTranslationEntries, - TempStatStageBoosterItem: SimpleTranslationEntries, - BaseStatBoosterItem: SimpleTranslationEntries, - EvolutionItem: SimpleTranslationEntries, - FormChangeItem: SimpleTranslationEntries, - } + ModifierType: { [key: string]: ModifierTypeTranslationEntry }; + SpeciesBoosterItem: { [key: string]: ModifierTypeTranslationEntry }; + AttackTypeBoosterItem: SimpleTranslationEntries; + TempStatStageBoosterItem: SimpleTranslationEntries; + BaseStatBoosterItem: SimpleTranslationEntries; + EvolutionItem: SimpleTranslationEntries; + FormChangeItem: SimpleTranslationEntries; +} export interface PokemonInfoTranslationEntries { - Stat: SimpleTranslationEntries, - Type: SimpleTranslationEntries, - } + Stat: SimpleTranslationEntries; + Type: SimpleTranslationEntries; +} export interface BerryTranslationEntry { - name: string, - effect: string, - } + name: string; + effect: string; +} export interface BerryTranslationEntries { - [key: string]: BerryTranslationEntry - } + [key: string]: BerryTranslationEntry; +} export interface StatusEffectTranslationEntries { - [key: string]: StatusEffectTranslationEntry + [key: string]: StatusEffectTranslationEntry; } export interface StatusEffectTranslationEntry { - name: string, - obtain: string, - obtainSource: string, - activation: string, - overlap: string, - heal: string - description: string, + name: string; + obtain: string; + obtainSource: string; + activation: string; + overlap: string; + heal: string; + description: string; } export interface AchievementTranslationEntry { - name?: string, - description?: string, - } + name?: string; + description?: string; +} export interface AchievementTranslationEntries { - [key: string]: AchievementTranslationEntry; - } + [key: string]: AchievementTranslationEntry; +} export interface DialogueTranslationEntry { - [key: number]: string; - } + [key: number]: string; +} export interface DialogueTranslationCategory { - [category: string]: DialogueTranslationEntry; - } + [category: string]: DialogueTranslationEntry; +} export interface DialogueTranslationEntries { - [trainertype: string]: DialogueTranslationCategory; - } + [trainertype: string]: DialogueTranslationCategory; +} diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 02bd849f66c..1e98c175487 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -138,10 +138,10 @@ export class LoadingScene extends SceneBase { this.loadImage("summary_bg", "ui"); this.loadImage("summary_overlay_shiny", "ui"); this.loadImage("summary_profile", "ui"); - this.loadImage("summary_profile_prompt_z", "ui"); // The pixel Z button prompt - this.loadImage("summary_profile_prompt_a", "ui"); // The pixel A button prompt - this.loadImage("summary_profile_ability", "ui"); // Pixel text 'ABILITY' - this.loadImage("summary_profile_passive", "ui"); // Pixel text 'PASSIVE' + this.loadImage("summary_profile_prompt_z", "ui"); // The pixel Z button prompt + this.loadImage("summary_profile_prompt_a", "ui"); // The pixel A button prompt + this.loadImage("summary_profile_ability", "ui"); // Pixel text 'ABILITY' + this.loadImage("summary_profile_passive", "ui"); // Pixel text 'PASSIVE' this.loadImage("summary_status", "ui"); this.loadImage("summary_stats", "ui"); this.loadImage("summary_stats_overlay_exp", "ui"); @@ -193,7 +193,7 @@ export class LoadingScene extends SceneBase { } if (getBiomeHasProps(bt)) { for (let p = 1; p <= 3; p++) { - const isPropAnimated = p === 3 && [ "power_plant", "end" ].find(b => b === btKey); + const isPropAnimated = p === 3 && ["power_plant", "end"].find(b => b === btKey); const propKey = `${btKey}_b_${p}`; if (!isPropAnimated) { this.loadImage(propKey, "arenas"); @@ -249,9 +249,9 @@ export class LoadingScene extends SceneBase { this.loadAtlas("statuses", ""); this.loadAtlas("types", ""); } - const availableLangs = [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ]; + const availableLangs = ["en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN"]; if (lang && availableLangs.includes(lang)) { - this.loadImage("pkmnday2025event-" + lang, "events"); + this.loadImage(`pkmnday2025event-${lang}`, "events"); } else { this.loadImage("pkmnday2025event-en", "events"); } @@ -264,11 +264,11 @@ export class LoadingScene extends SceneBase { this.loadAtlas("egg_icons", "egg"); this.loadAtlas("egg_shard", "egg"); this.loadAtlas("egg_lightrays", "egg"); - Utils.getEnumKeys(GachaType).forEach(gt => { + for (const gt of Utils.getEnumKeys(GachaType)) { const key = gt.toLowerCase(); this.loadImage(`gacha_${key}`, "egg"); this.loadAtlas(`gacha_underlay_${key}`, "egg"); - }); + } this.loadImage("gacha_glass", "egg"); this.loadImage("gacha_eggs", "egg"); this.loadAtlas("gacha_hatch", "egg"); @@ -351,7 +351,11 @@ export class LoadingScene extends SceneBase { this.loadBgm("evolution", "bw/evolution.mp3"); this.loadBgm("evolution_fanfare", "bw/evolution_fanfare.mp3"); - this.load.plugin("rextexteditplugin", "https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rextexteditplugin.min.js", true); + this.load.plugin( + "rextexteditplugin", + "https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rextexteditplugin.min.js", + true, + ); this.loadLoadingScreen(); @@ -441,12 +445,22 @@ export class LoadingScene extends SceneBase { style: { font: "48px emerald", color: "#ffffff", - align: "center" + align: "center", }, }); disclaimerDescriptionText.setOrigin(0.5, 0.5); - loadingGraphics.push(bg, graphics, progressBar, progressBox, logo, percentText, assetText, disclaimerText, disclaimerDescriptionText); + loadingGraphics.push( + bg, + graphics, + progressBar, + progressBox, + logo, + percentText, + assetText, + disclaimerText, + disclaimerDescriptionText, + ); if (!mobile) { loadingGraphics.map(g => g.setVisible(false)); @@ -461,7 +475,9 @@ export class LoadingScene extends SceneBase { ease: "Sine.easeIn", onComplete: () => video.destroy(), }); - loadingGraphics.forEach(g => g.setVisible(true)); + for (const g of loadingGraphics) { + g.setVisible(true); + } }); intro.setOrigin(0, 0); intro.setScale(3); @@ -502,7 +518,9 @@ export class LoadingScene extends SceneBase { }); this.load.on(this.LOAD_EVENTS.COMPLETE, () => { - loadingGraphics.forEach(go => go.destroy()); + for (const go of loadingGraphics) { + go.destroy(); + } intro.destroy(); }); } diff --git a/src/main.ts b/src/main.ts index 993bd1018ae..3d3965cad08 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,9 +7,8 @@ import InputTextPlugin from "phaser3-rex-plugins/plugins/inputtext-plugin"; import TransitionImagePackPlugin from "phaser3-rex-plugins/templates/transitionimagepack/transitionimagepack-plugin"; import { initI18n } from "./plugins/i18n"; - // Catch global errors and display them in an alert so users can report the issue. -window.onerror = function (message, source, lineno, colno, error) { +window.onerror = (_message, _source, _lineno, _colno, error) => { console.error(error); // const errorString = `Received unhandled error. Open browser console and click OK to see details.\nError: ${message}\nSource: ${source}\nLine: ${lineno}\nColumn: ${colno}\nStack: ${error.stack}`; //alert(errorString); @@ -18,7 +17,7 @@ window.onerror = function (message, source, lineno, colno, error) { }; // Catch global promise rejections and display them in an alert so users can report the issue. -window.addEventListener("unhandledrejection", (event) => { +window.addEventListener("unhandledrejection", event => { // const errorString = `Received unhandled promise rejection. Open browser console and click OK to see details.\nReason: ${event.reason}`; console.error(event.reason); //alert(errorString); @@ -41,7 +40,7 @@ Phaser.GameObjects.Text.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative; document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems")); - +// biome-ignore lint/suspicious/noImplicitAnyLet: TODO let game; const startGame = async (manifest?: any) => { @@ -54,44 +53,50 @@ const startGame = async (manifest?: any) => { scale: { width: 1920, height: 1080, - mode: Phaser.Scale.FIT + mode: Phaser.Scale.FIT, }, plugins: { - global: [{ - key: "rexInputTextPlugin", - plugin: InputTextPlugin, - start: true - }, { - key: "rexBBCodeTextPlugin", - plugin: BBCodeTextPlugin, - start: true - }, { - key: "rexTransitionImagePackPlugin", - plugin: TransitionImagePackPlugin, - start: true - }], - scene: [{ - key: "rexUI", - plugin: UIPlugin, - mapping: "rexUI" - }] + global: [ + { + key: "rexInputTextPlugin", + plugin: InputTextPlugin, + start: true, + }, + { + key: "rexBBCodeTextPlugin", + plugin: BBCodeTextPlugin, + start: true, + }, + { + key: "rexTransitionImagePackPlugin", + plugin: TransitionImagePackPlugin, + start: true, + }, + ], + scene: [ + { + key: "rexUI", + plugin: UIPlugin, + mapping: "rexUI", + }, + ], }, input: { mouse: { - target: "app" + target: "app", }, touch: { - target: "app" + target: "app", }, - gamepad: true + gamepad: true, }, dom: { - createContainer: true + createContainer: true, }, pixelArt: true, - pipeline: [ InvertPostFX ] as unknown as Phaser.Types.Core.PipelineConfig, - scene: [ LoadingScene, BattleScene ], - version: version + pipeline: [InvertPostFX] as unknown as Phaser.Types.Core.PipelineConfig, + scene: [LoadingScene, BattleScene], + version: version, }); game.sound.pauseOnBlur = false; if (manifest) { @@ -103,7 +108,8 @@ fetch("/manifest.json") .then(res => res.json()) .then(jsonResponse => { startGame(jsonResponse.manifest); - }).catch(() => { + }) + .catch(() => { // Manifest not found (likely local build) startGame(); }); diff --git a/src/messages.ts b/src/messages.ts index 26fd3353cc6..e35b48f7226 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -18,15 +18,17 @@ export function getPokemonNameWithAffix(pokemon: Pokemon | undefined): string { return !pokemon.isPlayer() ? pokemon.hasTrainer() ? i18next.t("battle:foePokemonWithAffix", { - pokemonName: pokemon.getNameToRender(), - }) + pokemonName: pokemon.getNameToRender(), + }) : i18next.t("battle:wildPokemonWithAffix", { - pokemonName: pokemon.getNameToRender(), - }) + pokemonName: pokemon.getNameToRender(), + }) : pokemon.getNameToRender(); case BattleSpec.FINAL_BOSS: return !pokemon.isPlayer() - ? i18next.t("battle:foePokemonWithAffix", { pokemonName: pokemon.getNameToRender() }) + ? i18next.t("battle:foePokemonWithAffix", { + pokemonName: pokemon.getNameToRender(), + }) : pokemon.getNameToRender(); default: return pokemon.getNameToRender(); diff --git a/src/modifier/modifier-tier.ts b/src/modifier/modifier-tier.ts index 81bb1ad8ae5..d8a75e41b0a 100644 --- a/src/modifier/modifier-tier.ts +++ b/src/modifier/modifier-tier.ts @@ -4,5 +4,5 @@ export enum ModifierTier { ULTRA, ROGUE, MASTER, - LUXURY + LUXURY, } diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 6cb8051518d..7ceba13440d 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -5,13 +5,99 @@ import { getBerryEffectDescription, getBerryName } from "#app/data/berry"; import { allMoves, AttackMove } from "#app/data/moves/move"; import { getNatureName, getNatureStatMultiplier } from "#app/data/nature"; import { getPokeballCatchMultiplier, getPokeballName, MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball"; -import { FormChangeItem, pokemonFormChanges, SpeciesFormChangeCondition, SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms"; +import { + FormChangeItem, + pokemonFormChanges, + SpeciesFormChangeCondition, + SpeciesFormChangeItemTrigger, +} from "#app/data/pokemon-forms"; import { getStatusEffectDescriptor } from "#app/data/status-effect"; import { PokemonType } from "#enums/pokemon-type"; import type { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; -import { AddPokeballModifier, AddVoucherModifier, AttackTypeBoosterModifier, BaseStatModifier, BerryModifier, BoostBugSpawnModifier, BypassSpeedChanceModifier, ContactHeldItemTransferChanceModifier, CritBoosterModifier, DamageMoneyRewardModifier, DoubleBattleChanceBoosterModifier, EnemyAttackStatusEffectChanceModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, EnemyEndureChanceModifier, EnemyFusionChanceModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, EvolutionItemModifier, EvolutionStatBoosterModifier, EvoTrackerModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, FusePokemonModifier, GigantamaxAccessModifier, HealingBoosterModifier, HealShopCostModifier, HiddenAbilityRateBoosterModifier, HitHealModifier, IvScannerModifier, LevelIncrementBoosterModifier, LockModifierTiersModifier, MapModifier, MegaEvolutionAccessModifier, MoneyInterestModifier, MoneyMultiplierModifier, MoneyRewardModifier, MultipleParticipantExpBonusModifier, PokemonAllMovePpRestoreModifier, PokemonBaseStatFlatModifier, PokemonBaseStatTotalModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonFriendshipBoosterModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, PokemonInstantReviveModifier, PokemonLevelIncrementModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PokemonNatureChangeModifier, PokemonNatureWeightModifier, PokemonPpRestoreModifier, PokemonPpUpModifier, PokemonStatusHealModifier, PreserveBerryModifier, RememberMoveModifier, ResetNegativeStatStageModifier, ShinyRateBoosterModifier, SpeciesCritBoosterModifier, SpeciesStatBoosterModifier, SurviveDamageModifier, SwitchEffectTransferModifier, TempCritBoosterModifier, TempStatStageBoosterModifier, TerastallizeAccessModifier, TerrastalizeModifier, TmModifier, TurnHealModifier, TurnHeldItemTransferModifier, TurnStatusEffectModifier, type EnemyPersistentModifier, type Modifier, type PersistentModifier, TempExtraModifierModifier, CriticalCatchChanceBoosterModifier } from "#app/modifier/modifier"; +import { + AddPokeballModifier, + AddVoucherModifier, + AttackTypeBoosterModifier, + BaseStatModifier, + BerryModifier, + BoostBugSpawnModifier, + BypassSpeedChanceModifier, + ContactHeldItemTransferChanceModifier, + CritBoosterModifier, + DamageMoneyRewardModifier, + DoubleBattleChanceBoosterModifier, + EnemyAttackStatusEffectChanceModifier, + EnemyDamageBoosterModifier, + EnemyDamageReducerModifier, + EnemyEndureChanceModifier, + EnemyFusionChanceModifier, + EnemyStatusEffectHealChanceModifier, + EnemyTurnHealModifier, + EvolutionItemModifier, + EvolutionStatBoosterModifier, + EvoTrackerModifier, + ExpBalanceModifier, + ExpBoosterModifier, + ExpShareModifier, + ExtraModifierModifier, + FlinchChanceModifier, + FusePokemonModifier, + GigantamaxAccessModifier, + HealingBoosterModifier, + HealShopCostModifier, + HiddenAbilityRateBoosterModifier, + HitHealModifier, + IvScannerModifier, + LevelIncrementBoosterModifier, + LockModifierTiersModifier, + MapModifier, + MegaEvolutionAccessModifier, + MoneyInterestModifier, + MoneyMultiplierModifier, + MoneyRewardModifier, + MultipleParticipantExpBonusModifier, + PokemonAllMovePpRestoreModifier, + PokemonBaseStatFlatModifier, + PokemonBaseStatTotalModifier, + PokemonExpBoosterModifier, + PokemonFormChangeItemModifier, + PokemonFriendshipBoosterModifier, + PokemonHeldItemModifier, + PokemonHpRestoreModifier, + PokemonIncrementingStatModifier, + PokemonInstantReviveModifier, + PokemonLevelIncrementModifier, + PokemonMoveAccuracyBoosterModifier, + PokemonMultiHitModifier, + PokemonNatureChangeModifier, + PokemonNatureWeightModifier, + PokemonPpRestoreModifier, + PokemonPpUpModifier, + PokemonStatusHealModifier, + PreserveBerryModifier, + RememberMoveModifier, + ResetNegativeStatStageModifier, + ShinyRateBoosterModifier, + SpeciesCritBoosterModifier, + SpeciesStatBoosterModifier, + SurviveDamageModifier, + SwitchEffectTransferModifier, + TempCritBoosterModifier, + TempStatStageBoosterModifier, + TerastallizeAccessModifier, + TerrastalizeModifier, + TmModifier, + TurnHealModifier, + TurnHeldItemTransferModifier, + TurnStatusEffectModifier, + type EnemyPersistentModifier, + type Modifier, + type PersistentModifier, + TempExtraModifierModifier, + CriticalCatchChanceBoosterModifier, +} from "#app/modifier/modifier"; import { ModifierTier } from "#app/modifier/modifier-tier"; import Overrides from "#app/overrides"; import { Unlockables } from "#app/system/unlockables"; @@ -19,7 +105,15 @@ import { getVoucherTypeIcon, getVoucherTypeName, VoucherType } from "#app/system import type { PokemonMoveSelectFilter, PokemonSelectFilter } from "#app/ui/party-ui-handler"; import PartyUiHandler from "#app/ui/party-ui-handler"; import { getModifierTierTextTint } from "#app/ui/text"; -import { formatMoney, getEnumKeys, getEnumValues, isNullOrUndefined, NumberHolder, padInt, randSeedInt } from "#app/utils"; +import { + formatMoney, + getEnumKeys, + getEnumValues, + isNullOrUndefined, + NumberHolder, + padInt, + randSeedInt, +} from "#app/utils"; import { Abilities } from "#enums/abilities"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; @@ -41,7 +135,7 @@ export enum ModifierPoolType { WILD, TRAINER, ENEMY_BUFF, - DAILY_STARTER + DAILY_STARTER, } type NewModifierFunc = (type: ModifierType, args: any[]) => Modifier; @@ -55,7 +149,13 @@ export class ModifierType { public tier: ModifierTier; protected newModifierFunc: NewModifierFunc | null; - constructor(localeKey: string | null, iconImage: string | null, newModifierFunc: NewModifierFunc | null, group?: string, soundName?: string) { + constructor( + localeKey: string | null, + iconImage: string | null, + newModifierFunc: NewModifierFunc | null, + group?: string, + soundName?: string, + ) { this.localeKey = localeKey!; // TODO: is this bang correct? this.iconImage = iconImage!; // TODO: is this bang correct? this.group = group!; // TODO: is this bang correct? @@ -85,16 +185,16 @@ export class ModifierType { let poolTypes: ModifierPoolType[]; switch (poolType) { case ModifierPoolType.PLAYER: - poolTypes = [ poolType, ModifierPoolType.TRAINER, ModifierPoolType.WILD ]; + poolTypes = [poolType, ModifierPoolType.TRAINER, ModifierPoolType.WILD]; break; case ModifierPoolType.WILD: - poolTypes = [ poolType, ModifierPoolType.PLAYER, ModifierPoolType.TRAINER ]; + poolTypes = [poolType, ModifierPoolType.PLAYER, ModifierPoolType.TRAINER]; break; case ModifierPoolType.TRAINER: - poolTypes = [ poolType, ModifierPoolType.PLAYER, ModifierPoolType.WILD ]; + poolTypes = [poolType, ModifierPoolType.PLAYER, ModifierPoolType.WILD]; break; default: - poolTypes = [ poolType ]; + poolTypes = [poolType]; break; } // Try multiple pool types in case of stolen items @@ -133,7 +233,11 @@ export class ModifierType { * if not provided or empty, the weight check will be ignored * @param rerollCount Default `0`. Used to check the weight of modifiers with conditional weight (see {@linkcode WeightedModifierTypeWeightFunc}) */ - withTierFromPool(poolType: ModifierPoolType = ModifierPoolType.PLAYER, party?: PlayerPokemon[], rerollCount: number = 0): ModifierType { + withTierFromPool( + poolType: ModifierPoolType = ModifierPoolType.PLAYER, + party?: PlayerPokemon[], + rerollCount = 0, + ): ModifierType { let defaultTier: undefined | ModifierTier; for (const tier of Object.values(getModifierPoolForType(poolType))) { for (const modifier of tier) { @@ -147,7 +251,8 @@ export class ModifierType { if (weight > 0) { this.tier = modifier.modifierType.tier; return this; - } else if (isNullOrUndefined(defaultTier)) { + } + if (isNullOrUndefined(defaultTier)) { // If weight is 0, keep track of the first tier where the item was found defaultTier = modifier.modifierType.tier; } @@ -164,6 +269,7 @@ export class ModifierType { } newModifier(...args: any[]): Modifier | null { + // biome-ignore lint/complexity/useOptionalChain: Changing to optional would coerce null return into undefined return this.newModifierFunc && this.newModifierFunc(this, args); } } @@ -171,7 +277,7 @@ export class ModifierType { type ModifierTypeGeneratorFunc = (party: Pokemon[], pregenArgs?: any[]) => ModifierType | null; export class ModifierTypeGenerator extends ModifierType { - private genTypeFunc: ModifierTypeGeneratorFunc; + private genTypeFunc: ModifierTypeGeneratorFunc; constructor(genTypeFunc: ModifierTypeGeneratorFunc) { super(null, null, null); @@ -204,17 +310,20 @@ class AddPokeballModifierType extends ModifierType { get name(): string { return i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", { - "modifierCount": this.count, - "pokeballName": getPokeballName(this.pokeballType), + modifierCount: this.count, + pokeballName: getPokeballName(this.pokeballType), }); } getDescription(): string { return i18next.t("modifierType:ModifierType.AddPokeballModifierType.description", { - "modifierCount": this.count, - "pokeballName": getPokeballName(this.pokeballType), - "catchRate": getPokeballCatchMultiplier(this.pokeballType) > -1 ? `${getPokeballCatchMultiplier(this.pokeballType)}x` : "100%", - "pokeballAmount": `${globalScene.pokeballCounts[this.pokeballType]}`, + modifierCount: this.count, + pokeballName: getPokeballName(this.pokeballType), + catchRate: + getPokeballCatchMultiplier(this.pokeballType) > -1 + ? `${getPokeballCatchMultiplier(this.pokeballType)}x` + : "100%", + pokeballAmount: `${globalScene.pokeballCounts[this.pokeballType]}`, }); } } @@ -224,22 +333,27 @@ class AddVoucherModifierType extends ModifierType { private count: number; constructor(voucherType: VoucherType, count: number) { - super("", getVoucherTypeIcon(voucherType), (_type, _args) => new AddVoucherModifier(this, voucherType, count), "voucher"); + super( + "", + getVoucherTypeIcon(voucherType), + (_type, _args) => new AddVoucherModifier(this, voucherType, count), + "voucher", + ); this.count = count; this.voucherType = voucherType; } get name(): string { return i18next.t("modifierType:ModifierType.AddVoucherModifierType.name", { - "modifierCount": this.count, - "voucherTypeName": getVoucherTypeName(this.voucherType), + modifierCount: this.count, + voucherTypeName: getVoucherTypeName(this.voucherType), }); } getDescription(): string { return i18next.t("modifierType:ModifierType.AddVoucherModifierType.description", { - "modifierCount": this.count, - "voucherTypeName": getVoucherTypeName(this.voucherType), + modifierCount: this.count, + voucherTypeName: getVoucherTypeName(this.voucherType), }); } } @@ -247,7 +361,14 @@ class AddVoucherModifierType extends ModifierType { export class PokemonModifierType extends ModifierType { public selectFilter: PokemonSelectFilter | undefined; - constructor(localeKey: string, iconImage: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, group?: string, soundName?: string) { + constructor( + localeKey: string, + iconImage: string, + newModifierFunc: NewModifierFunc, + selectFilter?: PokemonSelectFilter, + group?: string, + soundName?: string, + ) { super(localeKey, iconImage, newModifierFunc, group, soundName); this.selectFilter = selectFilter; @@ -255,19 +376,38 @@ export class PokemonModifierType extends ModifierType { } export class PokemonHeldItemModifierType extends PokemonModifierType { - constructor(localeKey: string, iconImage: string, newModifierFunc: NewModifierFunc, group?: string, soundName?: string) { - super(localeKey, iconImage, newModifierFunc, (pokemon: PlayerPokemon) => { - const dummyModifier = this.newModifier(pokemon); - const matchingModifier = globalScene.findModifier(m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(dummyModifier)) as PokemonHeldItemModifier; - const maxStackCount = dummyModifier.getMaxStackCount(); - if (!maxStackCount) { - return i18next.t("modifierType:ModifierType.PokemonHeldItemModifierType.extra.inoperable", { "pokemonName": getPokemonNameWithAffix(pokemon) }); - } - if (matchingModifier && matchingModifier.stackCount === maxStackCount) { - return i18next.t("modifierType:ModifierType.PokemonHeldItemModifierType.extra.tooMany", { "pokemonName": getPokemonNameWithAffix(pokemon) }); - } - return null; - }, group, soundName); + constructor( + localeKey: string, + iconImage: string, + newModifierFunc: NewModifierFunc, + group?: string, + soundName?: string, + ) { + super( + localeKey, + iconImage, + newModifierFunc, + (pokemon: PlayerPokemon) => { + const dummyModifier = this.newModifier(pokemon); + const matchingModifier = globalScene.findModifier( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(dummyModifier), + ) as PokemonHeldItemModifier; + const maxStackCount = dummyModifier.getMaxStackCount(); + if (!maxStackCount) { + return i18next.t("modifierType:ModifierType.PokemonHeldItemModifierType.extra.inoperable", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); + } + if (matchingModifier && matchingModifier.stackCount === maxStackCount) { + return i18next.t("modifierType:ModifierType.PokemonHeldItemModifierType.extra.tooMany", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); + } + return null; + }, + group, + soundName, + ); } newModifier(...args: any[]): PokemonHeldItemModifier { @@ -275,33 +415,44 @@ export class PokemonHeldItemModifierType extends PokemonModifierType { } } - export class TerastallizeModifierType extends PokemonModifierType { private teraType: PokemonType; constructor(teraType: PokemonType) { - super("", `${PokemonType[teraType].toLowerCase()}_tera_shard`, (type, args) => new TerrastalizeModifier(type as TerastallizeModifierType, (args[0] as Pokemon).id, teraType), + super( + "", + `${PokemonType[teraType].toLowerCase()}_tera_shard`, + (type, args) => new TerrastalizeModifier(type as TerastallizeModifierType, (args[0] as Pokemon).id, teraType), (pokemon: PlayerPokemon) => { - if ([ pokemon.species.speciesId, pokemon.fusionSpecies?.speciesId ].filter(s => s === Species.TERAPAGOS || s === Species.OGERPON || s === Species.SHEDINJA).length > 0) { + if ( + [pokemon.species.speciesId, pokemon.fusionSpecies?.speciesId].filter( + s => s === Species.TERAPAGOS || s === Species.OGERPON || s === Species.SHEDINJA, + ).length > 0 + ) { return PartyUiHandler.NoEffectMessage; } return null; }, - "tera_shard"); + "tera_shard", + ); this.teraType = teraType; } get name(): string { - return i18next.t("modifierType:ModifierType.TerastallizeModifierType.name", { teraType: i18next.t(`pokemonInfo:Type.${PokemonType[this.teraType]}`) }); + return i18next.t("modifierType:ModifierType.TerastallizeModifierType.name", { + teraType: i18next.t(`pokemonInfo:Type.${PokemonType[this.teraType]}`), + }); } getDescription(): string { - return i18next.t("modifierType:ModifierType.TerastallizeModifierType.description", { teraType: i18next.t(`pokemonInfo:Type.${PokemonType[this.teraType]}`) }); + return i18next.t("modifierType:ModifierType.TerastallizeModifierType.description", { + teraType: i18next.t(`pokemonInfo:Type.${PokemonType[this.teraType]}`), + }); } getPregenArgs(): any[] { - return [ this.teraType ]; + return [this.teraType]; } } @@ -310,14 +461,41 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType { protected restorePercent: number; protected healStatus: boolean; - constructor(localeKey: string, iconImage: string, restorePoints: number, restorePercent: number, healStatus: boolean = false, newModifierFunc?: NewModifierFunc, selectFilter?: PokemonSelectFilter, group?: string) { - super(localeKey, iconImage, newModifierFunc || ((_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints, this.restorePercent, this.healStatus, false)), - selectFilter || ((pokemon: PlayerPokemon) => { - if (!pokemon.hp || (pokemon.isFullHp() && (!this.healStatus || (!pokemon.status && !pokemon.getTag(BattlerTagType.CONFUSED))))) { - return PartyUiHandler.NoEffectMessage; - } - return null; - }), group || "potion"); + constructor( + localeKey: string, + iconImage: string, + restorePoints: number, + restorePercent: number, + healStatus = false, + newModifierFunc?: NewModifierFunc, + selectFilter?: PokemonSelectFilter, + group?: string, + ) { + super( + localeKey, + iconImage, + newModifierFunc || + ((_type, args) => + new PokemonHpRestoreModifier( + this, + (args[0] as PlayerPokemon).id, + this.restorePoints, + this.restorePercent, + this.healStatus, + false, + )), + selectFilter || + ((pokemon: PlayerPokemon) => { + if ( + !pokemon.hp || + (pokemon.isFullHp() && (!this.healStatus || (!pokemon.status && !pokemon.getTag(BattlerTagType.CONFUSED)))) + ) { + return PartyUiHandler.NoEffectMessage; + } + return null; + }), + group || "potion", + ); this.restorePoints = restorePoints; this.restorePercent = restorePercent; @@ -327,9 +505,9 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType { getDescription(): string { return this.restorePoints ? i18next.t("modifierType:ModifierType.PokemonHpRestoreModifierType.description", { - restorePoints: this.restorePoints, - restorePercent: this.restorePercent, - }) + restorePoints: this.restorePoints, + restorePercent: this.restorePercent, + }) : this.healStatus ? i18next.t("modifierType:ModifierType.PokemonHpRestoreModifierType.extra.fullyWithStatus") : i18next.t("modifierType:ModifierType.PokemonHpRestoreModifierType.extra.fully"); @@ -338,13 +516,22 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType { export class PokemonReviveModifierType extends PokemonHpRestoreModifierType { constructor(localeKey: string, iconImage: string, restorePercent: number) { - super(localeKey, iconImage, 0, restorePercent, false, (_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, 0, this.restorePercent, false, true), - ((pokemon: PlayerPokemon) => { + super( + localeKey, + iconImage, + 0, + restorePercent, + false, + (_type, args) => + new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, 0, this.restorePercent, false, true), + (pokemon: PlayerPokemon) => { if (!pokemon.isFainted()) { return PartyUiHandler.NoEffectMessage; } return null; - }), "revive"); + }, + "revive", + ); this.selectFilter = (pokemon: PlayerPokemon) => { if (pokemon.hp) { @@ -355,19 +542,25 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType { } getDescription(): string { - return i18next.t("modifierType:ModifierType.PokemonReviveModifierType.description", { restorePercent: this.restorePercent }); + return i18next.t("modifierType:ModifierType.PokemonReviveModifierType.description", { + restorePercent: this.restorePercent, + }); } } export class PokemonStatusHealModifierType extends PokemonModifierType { constructor(localeKey: string, iconImage: string) { - super(localeKey, iconImage, ((_type, args) => new PokemonStatusHealModifier(this, (args[0] as PlayerPokemon).id)), - ((pokemon: PlayerPokemon) => { + super( + localeKey, + iconImage, + (_type, args) => new PokemonStatusHealModifier(this, (args[0] as PlayerPokemon).id), + (pokemon: PlayerPokemon) => { if (!pokemon.hp || (!pokemon.status && !pokemon.getTag(BattlerTagType.CONFUSED))) { return PartyUiHandler.NoEffectMessage; } return null; - })); + }, + ); } getDescription(): string { @@ -378,7 +571,14 @@ export class PokemonStatusHealModifierType extends PokemonModifierType { export abstract class PokemonMoveModifierType extends PokemonModifierType { public moveSelectFilter: PokemonMoveSelectFilter | undefined; - constructor(localeKey: string, iconImage: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, moveSelectFilter?: PokemonMoveSelectFilter, group?: string) { + constructor( + localeKey: string, + iconImage: string, + newModifierFunc: NewModifierFunc, + selectFilter?: PokemonSelectFilter, + moveSelectFilter?: PokemonMoveSelectFilter, + group?: string, + ) { super(localeKey, iconImage, newModifierFunc, selectFilter, group); this.moveSelectFilter = moveSelectFilter; @@ -389,24 +589,32 @@ export class PokemonPpRestoreModifierType extends PokemonMoveModifierType { protected restorePoints: number; constructor(localeKey: string, iconImage: string, restorePoints: number) { - super(localeKey, iconImage, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, (args[1] as number), this.restorePoints), + super( + localeKey, + iconImage, + (_type, args) => + new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, args[1] as number, this.restorePoints), (_pokemon: PlayerPokemon) => { return null; - }, (pokemonMove: PokemonMove) => { + }, + (pokemonMove: PokemonMove) => { if (!pokemonMove.ppUsed) { return PartyUiHandler.NoEffectMessage; } return null; - }, "ether"); + }, + "ether", + ); this.restorePoints = restorePoints; } getDescription(): string { return this.restorePoints > -1 - ? i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.description", { restorePoints: this.restorePoints }) - : i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.extra.fully") - ; + ? i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.description", { + restorePoints: this.restorePoints, + }) + : i18next.t("modifierType:ModifierType.PokemonPpRestoreModifierType.extra.fully"); } } @@ -414,22 +622,28 @@ export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType { protected restorePoints: number; constructor(localeKey: string, iconImage: string, restorePoints: number) { - super(localeKey, iconImage, (_type, args) => new PokemonAllMovePpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints), + super( + localeKey, + iconImage, + (_type, args) => new PokemonAllMovePpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints), (pokemon: PlayerPokemon) => { if (!pokemon.getMoveset().filter(m => m?.ppUsed).length) { return PartyUiHandler.NoEffectMessage; } return null; - }, "elixir"); + }, + "elixir", + ); this.restorePoints = restorePoints; } getDescription(): string { return this.restorePoints > -1 - ? i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.description", { restorePoints: this.restorePoints }) - : i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.extra.fully") - ; + ? i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.description", { + restorePoints: this.restorePoints, + }) + : i18next.t("modifierType:ModifierType.PokemonAllMovePpRestoreModifierType.extra.fully"); } } @@ -437,15 +651,21 @@ export class PokemonPpUpModifierType extends PokemonMoveModifierType { protected upPoints: number; constructor(localeKey: string, iconImage: string, upPoints: number) { - super(localeKey, iconImage, (_type, args) => new PokemonPpUpModifier(this, (args[0] as PlayerPokemon).id, (args[1] as number), this.upPoints), + super( + localeKey, + iconImage, + (_type, args) => new PokemonPpUpModifier(this, (args[0] as PlayerPokemon).id, args[1] as number, this.upPoints), (_pokemon: PlayerPokemon) => { return null; - }, (pokemonMove: PokemonMove) => { + }, + (pokemonMove: PokemonMove) => { if (pokemonMove.getMove().pp < 5 || pokemonMove.ppUp >= 3 || pokemonMove.maxPpOverride) { return PartyUiHandler.NoEffectMessage; } return null; - }, "ppUp"); + }, + "ppUp", + ); this.upPoints = upPoints; } @@ -459,35 +679,53 @@ export class PokemonNatureChangeModifierType extends PokemonModifierType { protected nature: Nature; constructor(nature: Nature) { - super("", `mint_${getEnumKeys(Stat).find(s => getNatureStatMultiplier(nature, Stat[s]) > 1)?.toLowerCase() || "neutral" }`, ((_type, args) => new PokemonNatureChangeModifier(this, (args[0] as PlayerPokemon).id, this.nature)), - ((pokemon: PlayerPokemon) => { + super( + "", + `mint_${ + getEnumKeys(Stat) + .find(s => getNatureStatMultiplier(nature, Stat[s]) > 1) + ?.toLowerCase() || "neutral" + }`, + (_type, args) => new PokemonNatureChangeModifier(this, (args[0] as PlayerPokemon).id, this.nature), + (pokemon: PlayerPokemon) => { if (pokemon.getNature() === this.nature) { return PartyUiHandler.NoEffectMessage; } return null; - }), "mint"); + }, + "mint", + ); this.nature = nature; } get name(): string { - return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.name", { natureName: getNatureName(this.nature) }); + return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.name", { + natureName: getNatureName(this.nature), + }); } getDescription(): string { - return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.description", { natureName: getNatureName(this.nature, true, true, true) }); + return i18next.t("modifierType:ModifierType.PokemonNatureChangeModifierType.description", { + natureName: getNatureName(this.nature, true, true, true), + }); } } export class RememberMoveModifierType extends PokemonModifierType { constructor(localeKey: string, iconImage: string, group?: string) { - super(localeKey, iconImage, (type, args) => new RememberMoveModifier(type, (args[0] as PlayerPokemon).id, (args[1] as number)), + super( + localeKey, + iconImage, + (type, args) => new RememberMoveModifier(type, (args[0] as PlayerPokemon).id, args[1] as number), (pokemon: PlayerPokemon) => { if (!pokemon.getLearnableLevelMoves().length) { return PartyUiHandler.NoEffectMessage; } return null; - }, group); + }, + group, + ); } } @@ -502,7 +740,7 @@ export class DoubleBattleChanceBoosterModifierType extends ModifierType { getDescription(): string { return i18next.t("modifierType:ModifierType.DoubleBattleChanceBoosterModifierType.description", { - battleCount: this.maxBattles + battleCount: this.maxBattles, }); } } @@ -518,7 +756,7 @@ export class TempStatStageBoosterModifierType extends ModifierType implements Ge this.stat = stat; this.nameKey = nameKey; - this.quantityKey = (stat !== Stat.ACC) ? "percentage" : "stage"; + this.quantityKey = stat !== Stat.ACC ? "percentage" : "stage"; } get name(): string { @@ -528,12 +766,12 @@ export class TempStatStageBoosterModifierType extends ModifierType implements Ge getDescription(): string { return i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.description", { stat: i18next.t(getStatKey(this.stat)), - amount: i18next.t(`modifierType:ModifierType.TempStatStageBoosterModifierType.extra.${this.quantityKey}`) + amount: i18next.t(`modifierType:ModifierType.TempStatStageBoosterModifierType.extra.${this.quantityKey}`), }); } getPregenArgs(): any[] { - return [ this.stat ]; + return [this.stat]; } } @@ -541,7 +779,12 @@ export class BerryModifierType extends PokemonHeldItemModifierType implements Ge private berryType: BerryType; constructor(berryType: BerryType) { - super("", `${BerryType[berryType].toLowerCase()}_berry`, (type, args) => new BerryModifier(type, (args[0] as Pokemon).id, berryType), "berry"); + super( + "", + `${BerryType[berryType].toLowerCase()}_berry`, + (type, args) => new BerryModifier(type, (args[0] as Pokemon).id, berryType), + "berry", + ); this.berryType = berryType; } @@ -555,7 +798,7 @@ export class BerryModifierType extends PokemonHeldItemModifierType implements Ge } getPregenArgs(): any[] { - return [ this.berryType ]; + return [this.berryType]; } } @@ -577,16 +820,22 @@ enum AttackTypeBoosterItem { NEVER_MELT_ICE, DRAGON_FANG, BLACK_GLASSES, - FAIRY_FEATHER + FAIRY_FEATHER, } -export class AttackTypeBoosterModifierType extends PokemonHeldItemModifierType implements GeneratedPersistentModifierType { +export class AttackTypeBoosterModifierType + extends PokemonHeldItemModifierType + implements GeneratedPersistentModifierType +{ public moveType: PokemonType; public boostPercent: number; constructor(moveType: PokemonType, boostPercent: number) { - super("", `${AttackTypeBoosterItem[moveType]?.toLowerCase()}`, - (_type, args) => new AttackTypeBoosterModifier(this, (args[0] as Pokemon).id, moveType, boostPercent)); + super( + "", + `${AttackTypeBoosterItem[moveType]?.toLowerCase()}`, + (_type, args) => new AttackTypeBoosterModifier(this, (args[0] as Pokemon).id, moveType, boostPercent), + ); this.moveType = moveType; this.boostPercent = boostPercent; @@ -598,11 +847,13 @@ export class AttackTypeBoosterModifierType extends PokemonHeldItemModifierType i getDescription(): string { // TODO: Need getTypeName? - return i18next.t("modifierType:ModifierType.AttackTypeBoosterModifierType.description", { moveType: i18next.t(`pokemonInfo:Type.${PokemonType[this.moveType]}`) }); + return i18next.t("modifierType:ModifierType.AttackTypeBoosterModifierType.description", { + moveType: i18next.t(`pokemonInfo:Type.${PokemonType[this.moveType]}`), + }); } getPregenArgs(): any[] { - return [ this.moveType ]; + return [this.moveType]; } } @@ -613,24 +864,37 @@ export type SpeciesStatBoosterItem = keyof typeof SpeciesStatBoosterModifierType * @extends PokemonHeldItemModifierType * @implements GeneratedPersistentModifierType */ -export class SpeciesStatBoosterModifierType extends PokemonHeldItemModifierType implements GeneratedPersistentModifierType { +export class SpeciesStatBoosterModifierType + extends PokemonHeldItemModifierType + implements GeneratedPersistentModifierType +{ private key: SpeciesStatBoosterItem; constructor(key: SpeciesStatBoosterItem) { const item = SpeciesStatBoosterModifierTypeGenerator.items[key]; - super(`modifierType:SpeciesBoosterItem.${key}`, key.toLowerCase(), (type, args) => new SpeciesStatBoosterModifier(type, (args[0] as Pokemon).id, item.stats, item.multiplier, item.species)); + super( + `modifierType:SpeciesBoosterItem.${key}`, + key.toLowerCase(), + (type, args) => + new SpeciesStatBoosterModifier(type, (args[0] as Pokemon).id, item.stats, item.multiplier, item.species), + ); this.key = key; } getPregenArgs(): any[] { - return [ this.key ]; + return [this.key]; } } export class PokemonLevelIncrementModifierType extends PokemonModifierType { constructor(localeKey: string, iconImage: string) { - super(localeKey, iconImage, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), (_pokemon: PlayerPokemon) => null); + super( + localeKey, + iconImage, + (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), + (_pokemon: PlayerPokemon) => null, + ); } getDescription(): string { @@ -658,7 +922,10 @@ export class AllPokemonLevelIncrementModifierType extends ModifierType { } } -export class BaseStatBoosterModifierType extends PokemonHeldItemModifierType implements GeneratedPersistentModifierType { +export class BaseStatBoosterModifierType + extends PokemonHeldItemModifierType + implements GeneratedPersistentModifierType +{ private stat: PermanentStat; private key: string; @@ -675,47 +942,71 @@ export class BaseStatBoosterModifierType extends PokemonHeldItemModifierType imp } getDescription(): string { - return i18next.t("modifierType:ModifierType.BaseStatBoosterModifierType.description", { stat: i18next.t(getStatKey(this.stat)) }); + return i18next.t("modifierType:ModifierType.BaseStatBoosterModifierType.description", { + stat: i18next.t(getStatKey(this.stat)), + }); } getPregenArgs(): any[] { - return [ this.stat ]; + return [this.stat]; } } /** * Shuckle Juice item */ -export class PokemonBaseStatTotalModifierType extends PokemonHeldItemModifierType implements GeneratedPersistentModifierType { +export class PokemonBaseStatTotalModifierType + extends PokemonHeldItemModifierType + implements GeneratedPersistentModifierType +{ private readonly statModifier: number; constructor(statModifier: number) { - super("modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE", "berry_juice", (_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, this.statModifier)); + super( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE", + "berry_juice", + (_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, this.statModifier), + ); this.statModifier = statModifier; } override getDescription(): string { return i18next.t("modifierType:ModifierType.PokemonBaseStatTotalModifierType.description", { - increaseDecrease: i18next.t(this.statModifier >= 0 ? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.increase" : "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.decrease"), - blessCurse: i18next.t(this.statModifier >= 0 ? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.blessed" : "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.cursed"), + increaseDecrease: i18next.t( + this.statModifier >= 0 + ? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.increase" + : "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.decrease", + ), + blessCurse: i18next.t( + this.statModifier >= 0 + ? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.blessed" + : "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.cursed", + ), statValue: this.statModifier, }); } public getPregenArgs(): any[] { - return [ this.statModifier ]; + return [this.statModifier]; } } /** * Old Gateau item */ -export class PokemonBaseStatFlatModifierType extends PokemonHeldItemModifierType implements GeneratedPersistentModifierType { +export class PokemonBaseStatFlatModifierType + extends PokemonHeldItemModifierType + implements GeneratedPersistentModifierType +{ private readonly statModifier: number; private readonly stats: Stat[]; constructor(statModifier: number, stats: Stat[]) { - super("modifierType:ModifierType.MYSTERY_ENCOUNTER_OLD_GATEAU", "old_gateau", (_type, args) => new PokemonBaseStatFlatModifier(this, (args[0] as Pokemon).id, this.statModifier, this.stats)); + super( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_OLD_GATEAU", + "old_gateau", + (_type, args) => new PokemonBaseStatFlatModifier(this, (args[0] as Pokemon).id, this.statModifier, this.stats), + ); this.statModifier = statModifier; this.stats = stats; } @@ -728,7 +1019,7 @@ export class PokemonBaseStatFlatModifierType extends PokemonHeldItemModifierType } public getPregenArgs(): any[] { - return [ this.statModifier, this.stats ]; + return [this.statModifier, this.stats]; } } @@ -736,19 +1027,30 @@ class AllPokemonFullHpRestoreModifierType extends ModifierType { private descriptionKey: string; constructor(localeKey: string, iconImage: string, descriptionKey?: string, newModifierFunc?: NewModifierFunc) { - super(localeKey, iconImage, newModifierFunc || ((_type, _args) => new PokemonHpRestoreModifier(this, -1, 0, 100, false))); + super( + localeKey, + iconImage, + newModifierFunc || ((_type, _args) => new PokemonHpRestoreModifier(this, -1, 0, 100, false)), + ); this.descriptionKey = descriptionKey!; // TODO: is this bang correct? } getDescription(): string { - return i18next.t(`${this.descriptionKey || "modifierType:ModifierType.AllPokemonFullHpRestoreModifierType"}.description` as any); + return i18next.t( + `${this.descriptionKey || "modifierType:ModifierType.AllPokemonFullHpRestoreModifierType"}.description` as any, + ); } } class AllPokemonFullReviveModifierType extends AllPokemonFullHpRestoreModifierType { constructor(localeKey: string, iconImage: string) { - super(localeKey, iconImage, "modifierType:ModifierType.AllPokemonFullReviveModifierType", (_type, _args) => new PokemonHpRestoreModifier(this, -1, 0, 100, false, true)); + super( + localeKey, + iconImage, + "modifierType:ModifierType.AllPokemonFullReviveModifierType", + (_type, _args) => new PokemonHpRestoreModifier(this, -1, 0, 100, false, true), + ); } } @@ -785,7 +1087,9 @@ export class ExpBoosterModifierType extends ModifierType { } getDescription(): string { - return i18next.t("modifierType:ModifierType.ExpBoosterModifierType.description", { boostPercent: this.boostPercent }); + return i18next.t("modifierType:ModifierType.ExpBoosterModifierType.description", { + boostPercent: this.boostPercent, + }); } } @@ -793,13 +1097,19 @@ export class PokemonExpBoosterModifierType extends PokemonHeldItemModifierType { private boostPercent: number; constructor(localeKey: string, iconImage: string, boostPercent: number) { - super(localeKey, iconImage, (_type, args) => new PokemonExpBoosterModifier(this, (args[0] as Pokemon).id, boostPercent)); + super( + localeKey, + iconImage, + (_type, args) => new PokemonExpBoosterModifier(this, (args[0] as Pokemon).id, boostPercent), + ); this.boostPercent = boostPercent; } getDescription(): string { - return i18next.t("modifierType:ModifierType.PokemonExpBoosterModifierType.description", { boostPercent: this.boostPercent }); + return i18next.t("modifierType:ModifierType.PokemonExpBoosterModifierType.description", { + boostPercent: this.boostPercent, + }); } } @@ -817,19 +1127,31 @@ export class PokemonMoveAccuracyBoosterModifierType extends PokemonHeldItemModif private amount: number; constructor(localeKey: string, iconImage: string, amount: number, group?: string, soundName?: string) { - super(localeKey, iconImage, (_type, args) => new PokemonMoveAccuracyBoosterModifier(this, (args[0] as Pokemon).id, amount), group, soundName); + super( + localeKey, + iconImage, + (_type, args) => new PokemonMoveAccuracyBoosterModifier(this, (args[0] as Pokemon).id, amount), + group, + soundName, + ); this.amount = amount; } getDescription(): string { - return i18next.t("modifierType:ModifierType.PokemonMoveAccuracyBoosterModifierType.description", { accuracyAmount: this.amount }); + return i18next.t("modifierType:ModifierType.PokemonMoveAccuracyBoosterModifierType.description", { + accuracyAmount: this.amount, + }); } } export class PokemonMultiHitModifierType extends PokemonHeldItemModifierType { constructor(localeKey: string, iconImage: string) { - super(localeKey, iconImage, (type, args) => new PokemonMultiHitModifier(type as PokemonMultiHitModifierType, (args[0] as Pokemon).id)); + super( + localeKey, + iconImage, + (type, args) => new PokemonMultiHitModifier(type as PokemonMultiHitModifierType, (args[0] as Pokemon).id), + ); } getDescription(): string { @@ -841,13 +1163,21 @@ export class TmModifierType extends PokemonModifierType { public moveId: Moves; constructor(moveId: Moves) { - super("", `tm_${PokemonType[allMoves[moveId].type].toLowerCase()}`, (_type, args) => new TmModifier(this, (args[0] as PlayerPokemon).id), + super( + "", + `tm_${PokemonType[allMoves[moveId].type].toLowerCase()}`, + (_type, args) => new TmModifier(this, (args[0] as PlayerPokemon).id), (pokemon: PlayerPokemon) => { - if (pokemon.compatibleTms.indexOf(moveId) === -1 || pokemon.getMoveset().filter(m => m?.moveId === moveId).length) { + if ( + pokemon.compatibleTms.indexOf(moveId) === -1 || + pokemon.getMoveset().filter(m => m?.moveId === moveId).length + ) { return PartyUiHandler.NoEffectMessage; } return null; - }, "tm"); + }, + "tm", + ); this.moveId = moveId; } @@ -860,7 +1190,12 @@ export class TmModifierType extends PokemonModifierType { } getDescription(): string { - return i18next.t(globalScene.enableMoveInfo ? "modifierType:ModifierType.TmModifierTypeWithInfo.description" : "modifierType:ModifierType.TmModifierType.description", { moveName: allMoves[this.moveId].name }); + return i18next.t( + globalScene.enableMoveInfo + ? "modifierType:ModifierType.TmModifierTypeWithInfo.description" + : "modifierType:ModifierType.TmModifierType.description", + { moveName: allMoves[this.moveId].name }, + ); } } @@ -868,18 +1203,41 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge public evolutionItem: EvolutionItem; constructor(evolutionItem: EvolutionItem) { - super("", EvolutionItem[evolutionItem].toLowerCase(), (_type, args) => new EvolutionItemModifier(this, (args[0] as PlayerPokemon).id), + super( + "", + EvolutionItem[evolutionItem].toLowerCase(), + (_type, args) => new EvolutionItemModifier(this, (args[0] as PlayerPokemon).id), (pokemon: PlayerPokemon) => { - if (pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) && pokemonEvolutions[pokemon.species.speciesId].filter(e => e.item === this.evolutionItem - && (!e.condition || e.condition.predicate(pokemon)) && (e.preFormKey === null || e.preFormKey === pokemon.getFormKey())).length && (pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX)) { + if ( + pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) && + pokemonEvolutions[pokemon.species.speciesId].filter( + e => + e.item === this.evolutionItem && + (!e.condition || e.condition.predicate(pokemon)) && + (e.preFormKey === null || e.preFormKey === pokemon.getFormKey()), + ).length && + pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX + ) { return null; - } else if (pokemon.isFusion() && pokemon.fusionSpecies && pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) && pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(e => e.item === this.evolutionItem - && (!e.condition || e.condition.predicate(pokemon)) && (e.preFormKey === null || e.preFormKey === pokemon.getFusionFormKey())).length && (pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX)) { + } + if ( + pokemon.isFusion() && + pokemon.fusionSpecies && + pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) && + pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter( + e => + e.item === this.evolutionItem && + (!e.condition || e.condition.predicate(pokemon)) && + (e.preFormKey === null || e.preFormKey === pokemon.getFusionFormKey()), + ).length && + pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX + ) { return null; } return PartyUiHandler.NoEffectMessage; - }); + }, + ); this.evolutionItem = evolutionItem; } @@ -893,7 +1251,7 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge } getPregenArgs(): any[] { - return [ this.evolutionItem ]; + return [this.evolutionItem]; } } @@ -904,21 +1262,30 @@ export class FormChangeItemModifierType extends PokemonModifierType implements G public formChangeItem: FormChangeItem; constructor(formChangeItem: FormChangeItem) { - super("", FormChangeItem[formChangeItem].toLowerCase(), (_type, args) => new PokemonFormChangeItemModifier(this, (args[0] as PlayerPokemon).id, formChangeItem, true), + super( + "", + FormChangeItem[formChangeItem].toLowerCase(), + (_type, args) => new PokemonFormChangeItemModifier(this, (args[0] as PlayerPokemon).id, formChangeItem, true), (pokemon: PlayerPokemon) => { // Make sure the Pokemon has alternate forms - if (pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) + if ( + pokemonFormChanges.hasOwnProperty(pokemon.species.speciesId) && // Get all form changes for this species with an item trigger, including any compound triggers - && pokemonFormChanges[pokemon.species.speciesId].filter(fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger) && (fc.preFormKey === pokemon.getFormKey())) - // Returns true if any form changes match this item - .map(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) - .flat().flatMap(fc => fc.item).includes(this.formChangeItem) + pokemonFormChanges[pokemon.species.speciesId] + .filter( + fc => fc.trigger.hasTriggerType(SpeciesFormChangeItemTrigger) && fc.preFormKey === pokemon.getFormKey(), + ) + // Returns true if any form changes match this item + .flatMap(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) + .flatMap(fc => fc.item) + .includes(this.formChangeItem) ) { return null; } return PartyUiHandler.NoEffectMessage; - }); + }, + ); this.formChangeItem = formChangeItem; } @@ -932,19 +1299,23 @@ export class FormChangeItemModifierType extends PokemonModifierType implements G } getPregenArgs(): any[] { - return [ this.formChangeItem ]; + return [this.formChangeItem]; } } export class FusePokemonModifierType extends PokemonModifierType { constructor(localeKey: string, iconImage: string) { - super(localeKey, iconImage, (_type, args) => new FusePokemonModifier(this, (args[0] as PlayerPokemon).id, (args[1] as PlayerPokemon).id), + super( + localeKey, + iconImage, + (_type, args) => new FusePokemonModifier(this, (args[0] as PlayerPokemon).id, (args[1] as PlayerPokemon).id), (pokemon: PlayerPokemon) => { if (pokemon.isFusion()) { return PartyUiHandler.NoEffectMessage; } return null; - }); + }, + ); } getDescription(): string { @@ -955,11 +1326,17 @@ export class FusePokemonModifierType extends PokemonModifierType { class AttackTypeBoosterModifierTypeGenerator extends ModifierTypeGenerator { constructor() { super((party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in PokemonType)) { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in PokemonType) { return new AttackTypeBoosterModifierType(pregenArgs[0] as PokemonType, 20); } - const attackMoveTypes = party.map(p => p.getMoveset().map(m => m?.getMove()).filter(m => m instanceof AttackMove).map(m => m.type)).flat(); + const attackMoveTypes = party.flatMap(p => + p + .getMoveset() + .map(m => m?.getMove()) + .filter(m => m instanceof AttackMove) + .map(m => m.type), + ); if (!attackMoveTypes.length) { return null; } @@ -968,7 +1345,8 @@ class AttackTypeBoosterModifierTypeGenerator extends ModifierTypeGenerator { let totalWeight = 0; for (const t of attackMoveTypes) { if (attackMoveTypeWeights.has(t)) { - if (attackMoveTypeWeights.get(t)! < 3) { // attackMoveTypeWeights.has(t) was checked before + if (attackMoveTypeWeights.get(t)! < 3) { + // attackMoveTypeWeights.has(t) was checked before attackMoveTypeWeights.set(t, attackMoveTypeWeights.get(t)! + 1); } else { continue; @@ -1009,7 +1387,7 @@ class BaseStatBoosterModifierTypeGenerator extends ModifierTypeGenerator { [Stat.DEF]: "iron", [Stat.SPATK]: "calcium", [Stat.SPDEF]: "zinc", - [Stat.SPD]: "carbos" + [Stat.SPD]: "carbos", }; constructor() { @@ -1030,12 +1408,12 @@ class TempStatStageBoosterModifierTypeGenerator extends ModifierTypeGenerator { [Stat.SPATK]: "x_sp_atk", [Stat.SPDEF]: "x_sp_def", [Stat.SPD]: "x_speed", - [Stat.ACC]: "x_accuracy" + [Stat.ACC]: "x_accuracy", }; constructor() { super((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && TEMP_BATTLE_STATS.includes(pregenArgs[0])) { + if (pregenArgs && pregenArgs.length === 1 && TEMP_BATTLE_STATS.includes(pregenArgs[0])) { return new TempStatStageBoosterModifierType(pregenArgs[0]); } const randStat: TempBattleStat = randSeedInt(Stat.ACC, Stat.ATK); @@ -1053,16 +1431,32 @@ class TempStatStageBoosterModifierTypeGenerator extends ModifierTypeGenerator { class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator { /** Object comprised of the currently available species-based stat boosting held items */ public static readonly items = { - LIGHT_BALL: { stats: [ Stat.ATK, Stat.SPATK ], multiplier: 2, species: [ Species.PIKACHU ]}, - THICK_CLUB: { stats: [ Stat.ATK ], multiplier: 2, species: [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ]}, - METAL_POWDER: { stats: [ Stat.DEF ], multiplier: 2, species: [ Species.DITTO ]}, - QUICK_POWDER: { stats: [ Stat.SPD ], multiplier: 2, species: [ Species.DITTO ]}, + LIGHT_BALL: { + stats: [Stat.ATK, Stat.SPATK], + multiplier: 2, + species: [Species.PIKACHU], + }, + THICK_CLUB: { + stats: [Stat.ATK], + multiplier: 2, + species: [Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK], + }, + METAL_POWDER: { + stats: [Stat.DEF], + multiplier: 2, + species: [Species.DITTO], + }, + QUICK_POWDER: { + stats: [Stat.SPD], + multiplier: 2, + species: [Species.DITTO], + }, }; constructor() { super((party: Pokemon[], pregenArgs?: any[]) => { const items = SpeciesStatBoosterModifierTypeGenerator.items; - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in items)) { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in items) { return new SpeciesStatBoosterModifierType(pregenArgs[0] as SpeciesStatBoosterItem); } @@ -1081,8 +1475,13 @@ class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator { const checkedStats = values[i].stats; // If party member already has the item being weighted currently, skip to the next item - const hasItem = p.getHeldItems().some(m => m instanceof SpeciesStatBoosterModifier - && (m as SpeciesStatBoosterModifier).contains(checkedSpecies[0], checkedStats[0])); + const hasItem = p + .getHeldItems() + .some( + m => + m instanceof SpeciesStatBoosterModifier && + (m as SpeciesStatBoosterModifier).contains(checkedSpecies[0], checkedStats[0]), + ); if (!hasItem) { if (checkedSpecies.includes(speciesId) || (!!fusionSpeciesId && checkedSpecies.includes(fusionSpeciesId))) { @@ -1124,14 +1523,20 @@ class SpeciesStatBoosterModifierTypeGenerator extends ModifierTypeGenerator { class TmModifierTypeGenerator extends ModifierTypeGenerator { constructor(tier: ModifierTier) { super((party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in Moves)) { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in Moves) { return new TmModifierType(pregenArgs[0] as Moves); } const partyMemberCompatibleTms = party.map(p => { const previousLevelMoves = p.getLearnableLevelMoves(); - return (p as PlayerPokemon).compatibleTms.filter(tm => !p.moveset.find(m => m?.moveId === tm) && !previousLevelMoves.find(lm=>lm === tm)); + return (p as PlayerPokemon).compatibleTms.filter( + tm => !p.moveset.find(m => m?.moveId === tm) && !previousLevelMoves.find(lm => lm === tm), + ); }); - const tierUniqueCompatibleTms = partyMemberCompatibleTms.flat().filter(tm => tmPoolTiers[tm] === tier).filter(tm => !allMoves[tm].name.endsWith(" (N)")).filter((tm, i, array) => array.indexOf(tm) === i); + const tierUniqueCompatibleTms = partyMemberCompatibleTms + .flat() + .filter(tm => tmPoolTiers[tm] === tier) + .filter(tm => !allMoves[tm].name.endsWith(" (N)")) + .filter((tm, i, array) => array.indexOf(tm) === i); if (!tierUniqueCompatibleTms.length) { return null; } @@ -1144,20 +1549,49 @@ class TmModifierTypeGenerator extends ModifierTypeGenerator { class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator { constructor(rare: boolean) { super((party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in EvolutionItem)) { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in EvolutionItem) { return new EvolutionItemModifierType(pregenArgs[0] as EvolutionItem); } const evolutionItemPool = [ - party.filter(p => pokemonEvolutions.hasOwnProperty(p.species.speciesId) && (!p.pauseEvolutions || p.species.speciesId === Species.SLOWPOKE || p.species.speciesId === Species.EEVEE)).map(p => { - const evolutions = pokemonEvolutions[p.species.speciesId]; - return evolutions.filter(e => e.item !== EvolutionItem.NONE && (e.evoFormKey === null || (e.preFormKey || "") === p.getFormKey()) && (!e.condition || e.condition.predicate(p))); - }).flat(), - party.filter(p => p.isFusion() && p.fusionSpecies && pokemonEvolutions.hasOwnProperty(p.fusionSpecies.speciesId) && (!p.pauseEvolutions || p.fusionSpecies.speciesId === Species.SLOWPOKE || p.fusionSpecies.speciesId === Species.EEVEE)).map(p => { - const evolutions = pokemonEvolutions[p.fusionSpecies!.speciesId]; - return evolutions.filter(e => e.item !== EvolutionItem.NONE && (e.evoFormKey === null || (e.preFormKey || "") === p.getFusionFormKey()) && (!e.condition || e.condition.predicate(p))); - }).flat() - ].flat().flatMap(e => e.item).filter(i => (!!i && i > 50) === rare); + party + .filter( + p => + pokemonEvolutions.hasOwnProperty(p.species.speciesId) && + (!p.pauseEvolutions || p.species.speciesId === Species.SLOWPOKE || p.species.speciesId === Species.EEVEE), + ) + .flatMap(p => { + const evolutions = pokemonEvolutions[p.species.speciesId]; + return evolutions.filter( + e => + e.item !== EvolutionItem.NONE && + (e.evoFormKey === null || (e.preFormKey || "") === p.getFormKey()) && + (!e.condition || e.condition.predicate(p)), + ); + }), + party + .filter( + p => + p.isFusion() && + p.fusionSpecies && + pokemonEvolutions.hasOwnProperty(p.fusionSpecies.speciesId) && + (!p.pauseEvolutions || + p.fusionSpecies.speciesId === Species.SLOWPOKE || + p.fusionSpecies.speciesId === Species.EEVEE), + ) + .flatMap(p => { + const evolutions = pokemonEvolutions[p.fusionSpecies!.speciesId]; + return evolutions.filter( + e => + e.item !== EvolutionItem.NONE && + (e.evoFormKey === null || (e.preFormKey || "") === p.getFusionFormKey()) && + (!e.condition || e.condition.predicate(p)), + ); + }), + ] + .flat() + .flatMap(e => e.item) + .filter(i => (!!i && i > 50) === rare); if (!evolutionItemPool.length) { return null; @@ -1171,48 +1605,77 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator { class FormChangeItemModifierTypeGenerator extends ModifierTypeGenerator { constructor(isRareFormChangeItem: boolean) { super((party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in FormChangeItem)) { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in FormChangeItem) { return new FormChangeItemModifierType(pregenArgs[0] as FormChangeItem); } - const formChangeItemPool = [ ...new Set(party.filter(p => pokemonFormChanges.hasOwnProperty(p.species.speciesId)).map(p => { - const formChanges = pokemonFormChanges[p.species.speciesId]; - let formChangeItemTriggers = formChanges.filter(fc => ((fc.formKey.indexOf(SpeciesFormKey.MEGA) === -1 && fc.formKey.indexOf(SpeciesFormKey.PRIMAL) === -1) || globalScene.getModifiers(MegaEvolutionAccessModifier).length) - && ((fc.formKey.indexOf(SpeciesFormKey.GIGANTAMAX) === -1 && fc.formKey.indexOf(SpeciesFormKey.ETERNAMAX) === -1) || globalScene.getModifiers(GigantamaxAccessModifier).length) - && (!fc.conditions.length || fc.conditions.filter(cond => cond instanceof SpeciesFormChangeCondition && cond.predicate(p)).length) - && (fc.preFormKey === p.getFormKey())) - .map(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) - .filter(t => t && t.active && !globalScene.findModifier(m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === p.id && m.formChangeItem === t.item)); + const formChangeItemPool = [ + ...new Set( + party + .filter(p => pokemonFormChanges.hasOwnProperty(p.species.speciesId)) + .flatMap(p => { + const formChanges = pokemonFormChanges[p.species.speciesId]; + let formChangeItemTriggers = formChanges + .filter( + fc => + ((fc.formKey.indexOf(SpeciesFormKey.MEGA) === -1 && + fc.formKey.indexOf(SpeciesFormKey.PRIMAL) === -1) || + globalScene.getModifiers(MegaEvolutionAccessModifier).length) && + ((fc.formKey.indexOf(SpeciesFormKey.GIGANTAMAX) === -1 && + fc.formKey.indexOf(SpeciesFormKey.ETERNAMAX) === -1) || + globalScene.getModifiers(GigantamaxAccessModifier).length) && + (!fc.conditions.length || + fc.conditions.filter(cond => cond instanceof SpeciesFormChangeCondition && cond.predicate(p)) + .length) && + fc.preFormKey === p.getFormKey(), + ) + .map(fc => fc.findTrigger(SpeciesFormChangeItemTrigger) as SpeciesFormChangeItemTrigger) + .filter( + t => + t?.active && + !globalScene.findModifier( + m => + m instanceof PokemonFormChangeItemModifier && + m.pokemonId === p.id && + m.formChangeItem === t.item, + ), + ); - if (p.species.speciesId === Species.NECROZMA) { - // technically we could use a simplified version and check for formChanges.length > 3, but in case any code changes later, this might break... - let foundULTRA_Z = false, - foundN_LUNA = false, - foundN_SOLAR = false; - formChangeItemTriggers.forEach((fc, _i) => { - console.log("Checking ", fc.item); - switch (fc.item) { - case FormChangeItem.ULTRANECROZIUM_Z: - foundULTRA_Z = true; - break; - case FormChangeItem.N_LUNARIZER: - foundN_LUNA = true; - break; - case FormChangeItem.N_SOLARIZER: - foundN_SOLAR = true; - break; - } - }); - if (foundULTRA_Z && foundN_LUNA && foundN_SOLAR) { - // all three items are present -> user hasn't acquired any of the N_*ARIZERs -> block ULTRANECROZIUM_Z acquisition. - formChangeItemTriggers = formChangeItemTriggers.filter(fc => fc.item !== FormChangeItem.ULTRANECROZIUM_Z); - } else { - console.log("DID NOT FIND "); - } - } - return formChangeItemTriggers; - }).flat()) - ].flat().flatMap(fc => fc.item).filter(i => (i && i < 100) === isRareFormChangeItem); + if (p.species.speciesId === Species.NECROZMA) { + // technically we could use a simplified version and check for formChanges.length > 3, but in case any code changes later, this might break... + let foundULTRA_Z = false, + foundN_LUNA = false, + foundN_SOLAR = false; + formChangeItemTriggers.forEach((fc, _i) => { + console.log("Checking ", fc.item); + switch (fc.item) { + case FormChangeItem.ULTRANECROZIUM_Z: + foundULTRA_Z = true; + break; + case FormChangeItem.N_LUNARIZER: + foundN_LUNA = true; + break; + case FormChangeItem.N_SOLARIZER: + foundN_SOLAR = true; + break; + } + }); + if (foundULTRA_Z && foundN_LUNA && foundN_SOLAR) { + // all three items are present -> user hasn't acquired any of the N_*ARIZERs -> block ULTRANECROZIUM_Z acquisition. + formChangeItemTriggers = formChangeItemTriggers.filter( + fc => fc.item !== FormChangeItem.ULTRANECROZIUM_Z, + ); + } else { + console.log("DID NOT FIND "); + } + } + return formChangeItemTriggers; + }), + ), + ] + .flat() + .flatMap(fc => fc.item) + .filter(i => (i && i < 100) === isRareFormChangeItem); // convert it into a set to remove duplicate values, which can appear when the same species with a potential form change is in the party. if (!formChangeItemPool.length) { @@ -1228,19 +1691,33 @@ export class ContactHeldItemTransferChanceModifierType extends PokemonHeldItemMo private chancePercent: number; constructor(localeKey: string, iconImage: string, chancePercent: number, group?: string, soundName?: string) { - super(localeKey, iconImage, (type, args) => new ContactHeldItemTransferChanceModifier(type, (args[0] as Pokemon).id, chancePercent), group, soundName); + super( + localeKey, + iconImage, + (type, args) => new ContactHeldItemTransferChanceModifier(type, (args[0] as Pokemon).id, chancePercent), + group, + soundName, + ); this.chancePercent = chancePercent; } getDescription(): string { - return i18next.t("modifierType:ModifierType.ContactHeldItemTransferChanceModifierType.description", { chancePercent: this.chancePercent }); + return i18next.t("modifierType:ModifierType.ContactHeldItemTransferChanceModifierType.description", { + chancePercent: this.chancePercent, + }); } } export class TurnHeldItemTransferModifierType extends PokemonHeldItemModifierType { constructor(localeKey: string, iconImage: string, group?: string, soundName?: string) { - super(localeKey, iconImage, (type, args) => new TurnHeldItemTransferModifier(type, (args[0] as Pokemon).id), group, soundName); + super( + localeKey, + iconImage, + (type, args) => new TurnHeldItemTransferModifier(type, (args[0] as Pokemon).id), + group, + soundName, + ); } getDescription(): string { @@ -1253,7 +1730,12 @@ export class EnemyAttackStatusEffectChanceModifierType extends ModifierType { private effect: StatusEffect; constructor(localeKey: string, iconImage: string, chancePercent: number, effect: StatusEffect, stackCount?: number) { - super(localeKey, iconImage, (type, _args) => new EnemyAttackStatusEffectChanceModifier(type, effect, chancePercent, stackCount), "enemy_status_chance"); + super( + localeKey, + iconImage, + (type, _args) => new EnemyAttackStatusEffectChanceModifier(type, effect, chancePercent, stackCount), + "enemy_status_chance", + ); this.chancePercent = chancePercent; this.effect = effect; @@ -1277,7 +1759,9 @@ export class EnemyEndureChanceModifierType extends ModifierType { } getDescription(): string { - return i18next.t("modifierType:ModifierType.EnemyEndureChanceModifierType.description", { chancePercent: this.chancePercent }); + return i18next.t("modifierType:ModifierType.EnemyEndureChanceModifierType.description", { + chancePercent: this.chancePercent, + }); } } @@ -1293,7 +1777,7 @@ type WeightedModifierTypeWeightFunc = (party: Pokemon[], rerollCount?: number) = */ function skipInClassicAfterWave(wave: number, defaultWeight: number): WeightedModifierTypeWeightFunc { return () => { - const gameMode = globalScene.gameMode; + const gameMode = globalScene.gameMode; const currentWave = globalScene.currentBattle.waveIndex; return gameMode.isClassic && currentWave >= wave ? 0 : defaultWeight; }; @@ -1305,7 +1789,7 @@ function skipInClassicAfterWave(wave: number, defaultWeight: number): WeightedMo * @param defaultWeight ModifierType default weight * @returns A WeightedModifierTypeWeightFunc */ -function skipInLastClassicWaveOrDefault(defaultWeight: number) : WeightedModifierTypeWeightFunc { +function skipInLastClassicWaveOrDefault(defaultWeight: number): WeightedModifierTypeWeightFunc { return skipInClassicAfterWave(199, defaultWeight); } @@ -1319,7 +1803,11 @@ function skipInLastClassicWaveOrDefault(defaultWeight: number) : WeightedModifie function lureWeightFunc(maxBattles: number, weight: number): WeightedModifierTypeWeightFunc { return () => { const lures = globalScene.getModifiers(DoubleBattleChanceBoosterModifier); - return !(globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex === 199) && (lures.length === 0 || lures.filter(m => m.getMaxBattles() === maxBattles && m.getBattleCount() >= maxBattles * 0.6).length === 0) ? weight : 0; + return !(globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex === 199) && + (lures.length === 0 || + lures.filter(m => m.getMaxBattles() === maxBattles && m.getBattleCount() >= maxBattles * 0.6).length === 0) + ? weight + : 0; }; } class WeightedModifierType { @@ -1327,7 +1815,11 @@ class WeightedModifierType { public weight: number | WeightedModifierTypeWeightFunc; public maxWeight: number | WeightedModifierTypeWeightFunc; - constructor(modifierTypeFunc: ModifierTypeFunc, weight: number | WeightedModifierTypeWeightFunc, maxWeight?: number | WeightedModifierTypeWeightFunc) { + constructor( + modifierTypeFunc: ModifierTypeFunc, + weight: number | WeightedModifierTypeWeightFunc, + maxWeight?: number | WeightedModifierTypeWeightFunc, + ) { this.modifierType = modifierTypeFunc(); this.modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc)!; // TODO: is this bang correct? this.weight = weight; @@ -1406,20 +1898,42 @@ export const modifierTypes = { FORM_CHANGE_ITEM: () => new FormChangeItemModifierTypeGenerator(false), RARE_FORM_CHANGE_ITEM: () => new FormChangeItemModifierTypeGenerator(true), - EVOLUTION_TRACKER_GIMMIGHOUL: () => new PokemonHeldItemModifierType("modifierType:ModifierType.EVOLUTION_TRACKER_GIMMIGHOUL", "relic_gold", - (type, args) => new EvoTrackerModifier(type, (args[0] as Pokemon).id, Species.GIMMIGHOUL, 10)), + EVOLUTION_TRACKER_GIMMIGHOUL: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.EVOLUTION_TRACKER_GIMMIGHOUL", + "relic_gold", + (type, args) => new EvoTrackerModifier(type, (args[0] as Pokemon).id, Species.GIMMIGHOUL, 10), + ), - MEGA_BRACELET: () => new ModifierType("modifierType:ModifierType.MEGA_BRACELET", "mega_bracelet", (type, _args) => new MegaEvolutionAccessModifier(type)), - DYNAMAX_BAND: () => new ModifierType("modifierType:ModifierType.DYNAMAX_BAND", "dynamax_band", (type, _args) => new GigantamaxAccessModifier(type)), - TERA_ORB: () => new ModifierType("modifierType:ModifierType.TERA_ORB", "tera_orb", (type, _args) => new TerastallizeAccessModifier(type)), + MEGA_BRACELET: () => + new ModifierType( + "modifierType:ModifierType.MEGA_BRACELET", + "mega_bracelet", + (type, _args) => new MegaEvolutionAccessModifier(type), + ), + DYNAMAX_BAND: () => + new ModifierType( + "modifierType:ModifierType.DYNAMAX_BAND", + "dynamax_band", + (type, _args) => new GigantamaxAccessModifier(type), + ), + TERA_ORB: () => + new ModifierType( + "modifierType:ModifierType.TERA_ORB", + "tera_orb", + (type, _args) => new TerastallizeAccessModifier(type), + ), MAP: () => new ModifierType("modifierType:ModifierType.MAP", "map", (type, _args) => new MapModifier(type)), POTION: () => new PokemonHpRestoreModifierType("modifierType:ModifierType.POTION", "potion", 20, 10), - SUPER_POTION: () => new PokemonHpRestoreModifierType("modifierType:ModifierType.SUPER_POTION", "super_potion", 50, 25), - HYPER_POTION: () => new PokemonHpRestoreModifierType("modifierType:ModifierType.HYPER_POTION", "hyper_potion", 200, 50), + SUPER_POTION: () => + new PokemonHpRestoreModifierType("modifierType:ModifierType.SUPER_POTION", "super_potion", 50, 25), + HYPER_POTION: () => + new PokemonHpRestoreModifierType("modifierType:ModifierType.HYPER_POTION", "hyper_potion", 200, 50), MAX_POTION: () => new PokemonHpRestoreModifierType("modifierType:ModifierType.MAX_POTION", "max_potion", 0, 100), - FULL_RESTORE: () => new PokemonHpRestoreModifierType("modifierType:ModifierType.FULL_RESTORE", "full_restore", 0, 100, true), + FULL_RESTORE: () => + new PokemonHpRestoreModifierType("modifierType:ModifierType.FULL_RESTORE", "full_restore", 0, 100, true), REVIVE: () => new PokemonReviveModifierType("modifierType:ModifierType.REVIVE", "revive", 50), MAX_REVIVE: () => new PokemonReviveModifierType("modifierType:ModifierType.MAX_REVIVE", "max_revive", 100), @@ -1428,8 +1942,18 @@ export const modifierTypes = { SACRED_ASH: () => new AllPokemonFullReviveModifierType("modifierType:ModifierType.SACRED_ASH", "sacred_ash"), - REVIVER_SEED: () => new PokemonHeldItemModifierType("modifierType:ModifierType.REVIVER_SEED", "reviver_seed", (type, args) => new PokemonInstantReviveModifier(type, (args[0] as Pokemon).id)), - WHITE_HERB: () => new PokemonHeldItemModifierType("modifierType:ModifierType.WHITE_HERB", "white_herb", (type, args) => new ResetNegativeStatStageModifier(type, (args[0] as Pokemon).id)), + REVIVER_SEED: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.REVIVER_SEED", + "reviver_seed", + (type, args) => new PokemonInstantReviveModifier(type, (args[0] as Pokemon).id), + ), + WHITE_HERB: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.WHITE_HERB", + "white_herb", + (type, args) => new ResetNegativeStatStageModifier(type, (args[0] as Pokemon).id), + ), ETHER: () => new PokemonPpRestoreModifierType("modifierType:ModifierType.ETHER", "ether", 10), MAX_ETHER: () => new PokemonPpRestoreModifierType("modifierType:ModifierType.MAX_ETHER", "max_ether", -1), @@ -1452,68 +1976,72 @@ export const modifierTypes = { TEMP_STAT_STAGE_BOOSTER: () => new TempStatStageBoosterModifierTypeGenerator(), - DIRE_HIT: () => new class extends ModifierType { - getDescription(): string { - return i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.description", { - stat: i18next.t("modifierType:ModifierType.DIRE_HIT.extra.raises"), - amount: i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.extra.stage") - }); - } - }("modifierType:ModifierType.DIRE_HIT", "dire_hit", (type, _args) => new TempCritBoosterModifier(type, 5)), + DIRE_HIT: () => + new (class extends ModifierType { + getDescription(): string { + return i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.description", { + stat: i18next.t("modifierType:ModifierType.DIRE_HIT.extra.raises"), + amount: i18next.t("modifierType:ModifierType.TempStatStageBoosterModifierType.extra.stage"), + }); + } + })("modifierType:ModifierType.DIRE_HIT", "dire_hit", (type, _args) => new TempCritBoosterModifier(type, 5)), BASE_STAT_BOOSTER: () => new BaseStatBoosterModifierTypeGenerator(), ATTACK_TYPE_BOOSTER: () => new AttackTypeBoosterModifierTypeGenerator(), - MINT: () => new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in Nature)) { - return new PokemonNatureChangeModifierType(pregenArgs[0] as Nature); - } - return new PokemonNatureChangeModifierType(randSeedInt(getEnumValues(Nature).length) as Nature); - }), - - TERA_SHARD: () => new ModifierTypeGenerator((party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in PokemonType)) { - return new TerastallizeModifierType(pregenArgs[0] as PokemonType); - } - if (!globalScene.getModifiers(TerastallizeAccessModifier).length) { - return null; - } - const teraTypes: PokemonType[] = []; - party.forEach(p => { - if (!(p.hasSpecies(Species.TERAPAGOS) || p.hasSpecies(Species.OGERPON) || p.hasSpecies(Species.SHEDINJA))) { - teraTypes.push(p.teraType); + MINT: () => + new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in Nature) { + return new PokemonNatureChangeModifierType(pregenArgs[0] as Nature); } - }); - let excludedType = PokemonType.UNKNOWN; - if (teraTypes.length > 0 && teraTypes.filter(t => t === teraTypes[0]).length === teraTypes.length) { - excludedType = teraTypes[0]; - } - let shardType = randSeedInt(64) ? randSeedInt(18) as PokemonType : PokemonType.STELLAR; - while (shardType === excludedType) { - shardType = randSeedInt(64) ? randSeedInt(18) as PokemonType : PokemonType.STELLAR; - } - return new TerastallizeModifierType(shardType); - }), + return new PokemonNatureChangeModifierType(randSeedInt(getEnumValues(Nature).length) as Nature); + }), - BERRY: () => new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs && (pregenArgs.length === 1) && (pregenArgs[0] in BerryType)) { - return new BerryModifierType(pregenArgs[0] as BerryType); - } - const berryTypes = getEnumValues(BerryType); - let randBerryType: BerryType; - const rand = randSeedInt(12); - if (rand < 2) { - randBerryType = BerryType.SITRUS; - } else if (rand < 4) { - randBerryType = BerryType.LUM; - } else if (rand < 6) { - randBerryType = BerryType.LEPPA; - } else { - randBerryType = berryTypes[randSeedInt(berryTypes.length - 3) + 2]; - } - return new BerryModifierType(randBerryType); - }), + TERA_SHARD: () => + new ModifierTypeGenerator((party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in PokemonType) { + return new TerastallizeModifierType(pregenArgs[0] as PokemonType); + } + if (!globalScene.getModifiers(TerastallizeAccessModifier).length) { + return null; + } + const teraTypes: PokemonType[] = []; + for (const p of party) { + if (!(p.hasSpecies(Species.TERAPAGOS) || p.hasSpecies(Species.OGERPON) || p.hasSpecies(Species.SHEDINJA))) { + teraTypes.push(p.teraType); + } + } + let excludedType = PokemonType.UNKNOWN; + if (teraTypes.length > 0 && teraTypes.filter(t => t === teraTypes[0]).length === teraTypes.length) { + excludedType = teraTypes[0]; + } + let shardType = randSeedInt(64) ? (randSeedInt(18) as PokemonType) : PokemonType.STELLAR; + while (shardType === excludedType) { + shardType = randSeedInt(64) ? (randSeedInt(18) as PokemonType) : PokemonType.STELLAR; + } + return new TerastallizeModifierType(shardType); + }), + + BERRY: () => + new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in BerryType) { + return new BerryModifierType(pregenArgs[0] as BerryType); + } + const berryTypes = getEnumValues(BerryType); + let randBerryType: BerryType; + const rand = randSeedInt(12); + if (rand < 2) { + randBerryType = BerryType.SITRUS; + } else if (rand < 4) { + randBerryType = BerryType.LUM; + } else if (rand < 6) { + randBerryType = BerryType.LEPPA; + } else { + randBerryType = berryTypes[randSeedInt(berryTypes.length - 3) + 2]; + } + return new BerryModifierType(randBerryType); + }), TM_COMMON: () => new TmModifierTypeGenerator(ModifierTier.COMMON), TM_GREAT: () => new TmModifierTypeGenerator(ModifierTier.GREAT), @@ -1521,113 +2049,343 @@ export const modifierTypes = { MEMORY_MUSHROOM: () => new RememberMoveModifierType("modifierType:ModifierType.MEMORY_MUSHROOM", "big_mushroom"), - EXP_SHARE: () => new ModifierType("modifierType:ModifierType.EXP_SHARE", "exp_share", (type, _args) => new ExpShareModifier(type)), - EXP_BALANCE: () => new ModifierType("modifierType:ModifierType.EXP_BALANCE", "exp_balance", (type, _args) => new ExpBalanceModifier(type)), + EXP_SHARE: () => + new ModifierType("modifierType:ModifierType.EXP_SHARE", "exp_share", (type, _args) => new ExpShareModifier(type)), + EXP_BALANCE: () => + new ModifierType( + "modifierType:ModifierType.EXP_BALANCE", + "exp_balance", + (type, _args) => new ExpBalanceModifier(type), + ), - OVAL_CHARM: () => new ModifierType("modifierType:ModifierType.OVAL_CHARM", "oval_charm", (type, _args) => new MultipleParticipantExpBonusModifier(type)), + OVAL_CHARM: () => + new ModifierType( + "modifierType:ModifierType.OVAL_CHARM", + "oval_charm", + (type, _args) => new MultipleParticipantExpBonusModifier(type), + ), EXP_CHARM: () => new ExpBoosterModifierType("modifierType:ModifierType.EXP_CHARM", "exp_charm", 25), SUPER_EXP_CHARM: () => new ExpBoosterModifierType("modifierType:ModifierType.SUPER_EXP_CHARM", "super_exp_charm", 60), - GOLDEN_EXP_CHARM: () => new ExpBoosterModifierType("modifierType:ModifierType.GOLDEN_EXP_CHARM", "golden_exp_charm", 100), + GOLDEN_EXP_CHARM: () => + new ExpBoosterModifierType("modifierType:ModifierType.GOLDEN_EXP_CHARM", "golden_exp_charm", 100), LUCKY_EGG: () => new PokemonExpBoosterModifierType("modifierType:ModifierType.LUCKY_EGG", "lucky_egg", 40), GOLDEN_EGG: () => new PokemonExpBoosterModifierType("modifierType:ModifierType.GOLDEN_EGG", "golden_egg", 100), SOOTHE_BELL: () => new PokemonFriendshipBoosterModifierType("modifierType:ModifierType.SOOTHE_BELL", "soothe_bell"), - SCOPE_LENS: () => new PokemonHeldItemModifierType("modifierType:ModifierType.SCOPE_LENS", "scope_lens", (type, args) => new CritBoosterModifier(type, (args[0] as Pokemon).id, 1)), - LEEK: () => new PokemonHeldItemModifierType("modifierType:ModifierType.LEEK", "leek", (type, args) => new SpeciesCritBoosterModifier(type, (args[0] as Pokemon).id, 2, [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ])), + SCOPE_LENS: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.SCOPE_LENS", + "scope_lens", + (type, args) => new CritBoosterModifier(type, (args[0] as Pokemon).id, 1), + ), + LEEK: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.LEEK", + "leek", + (type, args) => + new SpeciesCritBoosterModifier(type, (args[0] as Pokemon).id, 2, [ + Species.FARFETCHD, + Species.GALAR_FARFETCHD, + Species.SIRFETCHD, + ]), + ), - EVIOLITE: () => new PokemonHeldItemModifierType("modifierType:ModifierType.EVIOLITE", "eviolite", (type, args) => new EvolutionStatBoosterModifier(type, (args[0] as Pokemon).id, [ Stat.DEF, Stat.SPDEF ], 1.5)), + EVIOLITE: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.EVIOLITE", + "eviolite", + (type, args) => new EvolutionStatBoosterModifier(type, (args[0] as Pokemon).id, [Stat.DEF, Stat.SPDEF], 1.5), + ), - SOUL_DEW: () => new PokemonHeldItemModifierType("modifierType:ModifierType.SOUL_DEW", "soul_dew", (type, args) => new PokemonNatureWeightModifier(type, (args[0] as Pokemon).id)), + SOUL_DEW: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.SOUL_DEW", + "soul_dew", + (type, args) => new PokemonNatureWeightModifier(type, (args[0] as Pokemon).id), + ), - NUGGET: () => new MoneyRewardModifierType("modifierType:ModifierType.NUGGET", "nugget", 1, "modifierType:ModifierType.MoneyRewardModifierType.extra.small"), - BIG_NUGGET: () => new MoneyRewardModifierType("modifierType:ModifierType.BIG_NUGGET", "big_nugget", 2.5, "modifierType:ModifierType.MoneyRewardModifierType.extra.moderate"), - RELIC_GOLD: () => new MoneyRewardModifierType("modifierType:ModifierType.RELIC_GOLD", "relic_gold", 10, "modifierType:ModifierType.MoneyRewardModifierType.extra.large"), + NUGGET: () => + new MoneyRewardModifierType( + "modifierType:ModifierType.NUGGET", + "nugget", + 1, + "modifierType:ModifierType.MoneyRewardModifierType.extra.small", + ), + BIG_NUGGET: () => + new MoneyRewardModifierType( + "modifierType:ModifierType.BIG_NUGGET", + "big_nugget", + 2.5, + "modifierType:ModifierType.MoneyRewardModifierType.extra.moderate", + ), + RELIC_GOLD: () => + new MoneyRewardModifierType( + "modifierType:ModifierType.RELIC_GOLD", + "relic_gold", + 10, + "modifierType:ModifierType.MoneyRewardModifierType.extra.large", + ), - AMULET_COIN: () => new ModifierType("modifierType:ModifierType.AMULET_COIN", "amulet_coin", (type, _args) => new MoneyMultiplierModifier(type)), - GOLDEN_PUNCH: () => new PokemonHeldItemModifierType("modifierType:ModifierType.GOLDEN_PUNCH", "golden_punch", (type, args) => new DamageMoneyRewardModifier(type, (args[0] as Pokemon).id)), - COIN_CASE: () => new ModifierType("modifierType:ModifierType.COIN_CASE", "coin_case", (type, _args) => new MoneyInterestModifier(type)), + AMULET_COIN: () => + new ModifierType( + "modifierType:ModifierType.AMULET_COIN", + "amulet_coin", + (type, _args) => new MoneyMultiplierModifier(type), + ), + GOLDEN_PUNCH: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.GOLDEN_PUNCH", + "golden_punch", + (type, args) => new DamageMoneyRewardModifier(type, (args[0] as Pokemon).id), + ), + COIN_CASE: () => + new ModifierType( + "modifierType:ModifierType.COIN_CASE", + "coin_case", + (type, _args) => new MoneyInterestModifier(type), + ), - LOCK_CAPSULE: () => new ModifierType("modifierType:ModifierType.LOCK_CAPSULE", "lock_capsule", (type, _args) => new LockModifierTiersModifier(type)), + LOCK_CAPSULE: () => + new ModifierType( + "modifierType:ModifierType.LOCK_CAPSULE", + "lock_capsule", + (type, _args) => new LockModifierTiersModifier(type), + ), - GRIP_CLAW: () => new ContactHeldItemTransferChanceModifierType("modifierType:ModifierType.GRIP_CLAW", "grip_claw", 10), + GRIP_CLAW: () => + new ContactHeldItemTransferChanceModifierType("modifierType:ModifierType.GRIP_CLAW", "grip_claw", 10), WIDE_LENS: () => new PokemonMoveAccuracyBoosterModifierType("modifierType:ModifierType.WIDE_LENS", "wide_lens", 5), MULTI_LENS: () => new PokemonMultiHitModifierType("modifierType:ModifierType.MULTI_LENS", "zoom_lens"), - HEALING_CHARM: () => new ModifierType("modifierType:ModifierType.HEALING_CHARM", "healing_charm", (type, _args) => new HealingBoosterModifier(type, 1.1)), - CANDY_JAR: () => new ModifierType("modifierType:ModifierType.CANDY_JAR", "candy_jar", (type, _args) => new LevelIncrementBoosterModifier(type)), + HEALING_CHARM: () => + new ModifierType( + "modifierType:ModifierType.HEALING_CHARM", + "healing_charm", + (type, _args) => new HealingBoosterModifier(type, 1.1), + ), + CANDY_JAR: () => + new ModifierType( + "modifierType:ModifierType.CANDY_JAR", + "candy_jar", + (type, _args) => new LevelIncrementBoosterModifier(type), + ), - BERRY_POUCH: () => new ModifierType("modifierType:ModifierType.BERRY_POUCH", "berry_pouch", (type, _args) => new PreserveBerryModifier(type)), + BERRY_POUCH: () => + new ModifierType( + "modifierType:ModifierType.BERRY_POUCH", + "berry_pouch", + (type, _args) => new PreserveBerryModifier(type), + ), - FOCUS_BAND: () => new PokemonHeldItemModifierType("modifierType:ModifierType.FOCUS_BAND", "focus_band", (type, args) => new SurviveDamageModifier(type, (args[0] as Pokemon).id)), + FOCUS_BAND: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.FOCUS_BAND", + "focus_band", + (type, args) => new SurviveDamageModifier(type, (args[0] as Pokemon).id), + ), - QUICK_CLAW: () => new PokemonHeldItemModifierType("modifierType:ModifierType.QUICK_CLAW", "quick_claw", (type, args) => new BypassSpeedChanceModifier(type, (args[0] as Pokemon).id)), + QUICK_CLAW: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.QUICK_CLAW", + "quick_claw", + (type, args) => new BypassSpeedChanceModifier(type, (args[0] as Pokemon).id), + ), - KINGS_ROCK: () => new PokemonHeldItemModifierType("modifierType:ModifierType.KINGS_ROCK", "kings_rock", (type, args) => new FlinchChanceModifier(type, (args[0] as Pokemon).id)), + KINGS_ROCK: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.KINGS_ROCK", + "kings_rock", + (type, args) => new FlinchChanceModifier(type, (args[0] as Pokemon).id), + ), - LEFTOVERS: () => new PokemonHeldItemModifierType("modifierType:ModifierType.LEFTOVERS", "leftovers", (type, args) => new TurnHealModifier(type, (args[0] as Pokemon).id)), - SHELL_BELL: () => new PokemonHeldItemModifierType("modifierType:ModifierType.SHELL_BELL", "shell_bell", (type, args) => new HitHealModifier(type, (args[0] as Pokemon).id)), + LEFTOVERS: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.LEFTOVERS", + "leftovers", + (type, args) => new TurnHealModifier(type, (args[0] as Pokemon).id), + ), + SHELL_BELL: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.SHELL_BELL", + "shell_bell", + (type, args) => new HitHealModifier(type, (args[0] as Pokemon).id), + ), - TOXIC_ORB: () => new PokemonHeldItemModifierType("modifierType:ModifierType.TOXIC_ORB", "toxic_orb", (type, args) => new TurnStatusEffectModifier(type, (args[0] as Pokemon).id)), - FLAME_ORB: () => new PokemonHeldItemModifierType("modifierType:ModifierType.FLAME_ORB", "flame_orb", (type, args) => new TurnStatusEffectModifier(type, (args[0] as Pokemon).id)), + TOXIC_ORB: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.TOXIC_ORB", + "toxic_orb", + (type, args) => new TurnStatusEffectModifier(type, (args[0] as Pokemon).id), + ), + FLAME_ORB: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.FLAME_ORB", + "flame_orb", + (type, args) => new TurnStatusEffectModifier(type, (args[0] as Pokemon).id), + ), - BATON: () => new PokemonHeldItemModifierType("modifierType:ModifierType.BATON", "baton", (type, args) => new SwitchEffectTransferModifier(type, (args[0] as Pokemon).id)), + BATON: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.BATON", + "baton", + (type, args) => new SwitchEffectTransferModifier(type, (args[0] as Pokemon).id), + ), - SHINY_CHARM: () => new ModifierType("modifierType:ModifierType.SHINY_CHARM", "shiny_charm", (type, _args) => new ShinyRateBoosterModifier(type)), - ABILITY_CHARM: () => new ModifierType("modifierType:ModifierType.ABILITY_CHARM", "ability_charm", (type, _args) => new HiddenAbilityRateBoosterModifier(type)), - CATCHING_CHARM: () => new ModifierType("modifierType:ModifierType.CATCHING_CHARM", "catching_charm", (type, _args) => new CriticalCatchChanceBoosterModifier(type)), + SHINY_CHARM: () => + new ModifierType( + "modifierType:ModifierType.SHINY_CHARM", + "shiny_charm", + (type, _args) => new ShinyRateBoosterModifier(type), + ), + ABILITY_CHARM: () => + new ModifierType( + "modifierType:ModifierType.ABILITY_CHARM", + "ability_charm", + (type, _args) => new HiddenAbilityRateBoosterModifier(type), + ), + CATCHING_CHARM: () => + new ModifierType( + "modifierType:ModifierType.CATCHING_CHARM", + "catching_charm", + (type, _args) => new CriticalCatchChanceBoosterModifier(type), + ), - IV_SCANNER: () => new ModifierType("modifierType:ModifierType.IV_SCANNER", "scanner", (type, _args) => new IvScannerModifier(type)), + IV_SCANNER: () => + new ModifierType("modifierType:ModifierType.IV_SCANNER", "scanner", (type, _args) => new IvScannerModifier(type)), DNA_SPLICERS: () => new FusePokemonModifierType("modifierType:ModifierType.DNA_SPLICERS", "dna_splicers"), - MINI_BLACK_HOLE: () => new TurnHeldItemTransferModifierType("modifierType:ModifierType.MINI_BLACK_HOLE", "mini_black_hole"), + MINI_BLACK_HOLE: () => + new TurnHeldItemTransferModifierType("modifierType:ModifierType.MINI_BLACK_HOLE", "mini_black_hole"), VOUCHER: () => new AddVoucherModifierType(VoucherType.REGULAR, 1), VOUCHER_PLUS: () => new AddVoucherModifierType(VoucherType.PLUS, 1), VOUCHER_PREMIUM: () => new AddVoucherModifierType(VoucherType.PREMIUM, 1), - GOLDEN_POKEBALL: () => new ModifierType("modifierType:ModifierType.GOLDEN_POKEBALL", "pb_gold", (type, _args) => new ExtraModifierModifier(type), undefined, "se/pb_bounce_1"), - SILVER_POKEBALL: () => new ModifierType("modifierType:ModifierType.SILVER_POKEBALL", "pb_silver", (type, _args) => new TempExtraModifierModifier(type, 100), undefined, "se/pb_bounce_1"), + GOLDEN_POKEBALL: () => + new ModifierType( + "modifierType:ModifierType.GOLDEN_POKEBALL", + "pb_gold", + (type, _args) => new ExtraModifierModifier(type), + undefined, + "se/pb_bounce_1", + ), + SILVER_POKEBALL: () => + new ModifierType( + "modifierType:ModifierType.SILVER_POKEBALL", + "pb_silver", + (type, _args) => new TempExtraModifierModifier(type, 100), + undefined, + "se/pb_bounce_1", + ), - ENEMY_DAMAGE_BOOSTER: () => new ModifierType("modifierType:ModifierType.ENEMY_DAMAGE_BOOSTER", "wl_item_drop", (type, _args) => new EnemyDamageBoosterModifier(type, 5)), - ENEMY_DAMAGE_REDUCTION: () => new ModifierType("modifierType:ModifierType.ENEMY_DAMAGE_REDUCTION", "wl_guard_spec", (type, _args) => new EnemyDamageReducerModifier(type, 2.5)), + ENEMY_DAMAGE_BOOSTER: () => + new ModifierType( + "modifierType:ModifierType.ENEMY_DAMAGE_BOOSTER", + "wl_item_drop", + (type, _args) => new EnemyDamageBoosterModifier(type, 5), + ), + ENEMY_DAMAGE_REDUCTION: () => + new ModifierType( + "modifierType:ModifierType.ENEMY_DAMAGE_REDUCTION", + "wl_guard_spec", + (type, _args) => new EnemyDamageReducerModifier(type, 2.5), + ), //ENEMY_SUPER_EFFECT_BOOSTER: () => new ModifierType('Type Advantage Token', 'Increases damage of super effective attacks by 30%', (type, _args) => new EnemySuperEffectiveDamageBoosterModifier(type, 30), 'wl_custom_super_effective'), - ENEMY_HEAL: () => new ModifierType("modifierType:ModifierType.ENEMY_HEAL", "wl_potion", (type, _args) => new EnemyTurnHealModifier(type, 2, 10)), - ENEMY_ATTACK_POISON_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType("modifierType:ModifierType.ENEMY_ATTACK_POISON_CHANCE", "wl_antidote", 5, StatusEffect.POISON, 10), - ENEMY_ATTACK_PARALYZE_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType("modifierType:ModifierType.ENEMY_ATTACK_PARALYZE_CHANCE", "wl_paralyze_heal", 2.5, StatusEffect.PARALYSIS, 10), - ENEMY_ATTACK_BURN_CHANCE: () => new EnemyAttackStatusEffectChanceModifierType("modifierType:ModifierType.ENEMY_ATTACK_BURN_CHANCE", "wl_burn_heal", 5, StatusEffect.BURN, 10), - ENEMY_STATUS_EFFECT_HEAL_CHANCE: () => new ModifierType("modifierType:ModifierType.ENEMY_STATUS_EFFECT_HEAL_CHANCE", "wl_full_heal", (type, _args) => new EnemyStatusEffectHealChanceModifier(type, 2.5, 10)), - ENEMY_ENDURE_CHANCE: () => new EnemyEndureChanceModifierType("modifierType:ModifierType.ENEMY_ENDURE_CHANCE", "wl_reset_urge", 2), - ENEMY_FUSED_CHANCE: () => new ModifierType("modifierType:ModifierType.ENEMY_FUSED_CHANCE", "wl_custom_spliced", (type, _args) => new EnemyFusionChanceModifier(type, 1)), + ENEMY_HEAL: () => + new ModifierType( + "modifierType:ModifierType.ENEMY_HEAL", + "wl_potion", + (type, _args) => new EnemyTurnHealModifier(type, 2, 10), + ), + ENEMY_ATTACK_POISON_CHANCE: () => + new EnemyAttackStatusEffectChanceModifierType( + "modifierType:ModifierType.ENEMY_ATTACK_POISON_CHANCE", + "wl_antidote", + 5, + StatusEffect.POISON, + 10, + ), + ENEMY_ATTACK_PARALYZE_CHANCE: () => + new EnemyAttackStatusEffectChanceModifierType( + "modifierType:ModifierType.ENEMY_ATTACK_PARALYZE_CHANCE", + "wl_paralyze_heal", + 2.5, + StatusEffect.PARALYSIS, + 10, + ), + ENEMY_ATTACK_BURN_CHANCE: () => + new EnemyAttackStatusEffectChanceModifierType( + "modifierType:ModifierType.ENEMY_ATTACK_BURN_CHANCE", + "wl_burn_heal", + 5, + StatusEffect.BURN, + 10, + ), + ENEMY_STATUS_EFFECT_HEAL_CHANCE: () => + new ModifierType( + "modifierType:ModifierType.ENEMY_STATUS_EFFECT_HEAL_CHANCE", + "wl_full_heal", + (type, _args) => new EnemyStatusEffectHealChanceModifier(type, 2.5, 10), + ), + ENEMY_ENDURE_CHANCE: () => + new EnemyEndureChanceModifierType("modifierType:ModifierType.ENEMY_ENDURE_CHANCE", "wl_reset_urge", 2), + ENEMY_FUSED_CHANCE: () => + new ModifierType( + "modifierType:ModifierType.ENEMY_FUSED_CHANCE", + "wl_custom_spliced", + (type, _args) => new EnemyFusionChanceModifier(type, 1), + ), - MYSTERY_ENCOUNTER_SHUCKLE_JUICE: () => new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs) { - return new PokemonBaseStatTotalModifierType(pregenArgs[0] as number); - } - return new PokemonBaseStatTotalModifierType(randSeedInt(20, 1)); - }), - MYSTERY_ENCOUNTER_OLD_GATEAU: () => new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs) { - return new PokemonBaseStatFlatModifierType(pregenArgs[0] as number, pregenArgs[1] as Stat[]); - } - return new PokemonBaseStatFlatModifierType(randSeedInt(20, 1), [ Stat.HP, Stat.ATK, Stat.DEF ]); - }), - MYSTERY_ENCOUNTER_BLACK_SLUDGE: () => new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { - if (pregenArgs) { - return new ModifierType("modifierType:ModifierType.MYSTERY_ENCOUNTER_BLACK_SLUDGE", "black_sludge", (type, _args) => new HealShopCostModifier(type, pregenArgs[0] as number)); - } - return new ModifierType("modifierType:ModifierType.MYSTERY_ENCOUNTER_BLACK_SLUDGE", "black_sludge", (type, _args) => new HealShopCostModifier(type, 2.5)); - }), - MYSTERY_ENCOUNTER_MACHO_BRACE: () => new PokemonHeldItemModifierType("modifierType:ModifierType.MYSTERY_ENCOUNTER_MACHO_BRACE", "macho_brace", (type, args) => new PokemonIncrementingStatModifier(type, (args[0] as Pokemon).id)), - MYSTERY_ENCOUNTER_GOLDEN_BUG_NET: () => new ModifierType("modifierType:ModifierType.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET", "golden_net", (type, _args) => new BoostBugSpawnModifier(type)), + MYSTERY_ENCOUNTER_SHUCKLE_JUICE: () => + new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs) { + return new PokemonBaseStatTotalModifierType(pregenArgs[0] as number); + } + return new PokemonBaseStatTotalModifierType(randSeedInt(20, 1)); + }), + MYSTERY_ENCOUNTER_OLD_GATEAU: () => + new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs) { + return new PokemonBaseStatFlatModifierType(pregenArgs[0] as number, pregenArgs[1] as Stat[]); + } + return new PokemonBaseStatFlatModifierType(randSeedInt(20, 1), [Stat.HP, Stat.ATK, Stat.DEF]); + }), + MYSTERY_ENCOUNTER_BLACK_SLUDGE: () => + new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => { + if (pregenArgs) { + return new ModifierType( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_BLACK_SLUDGE", + "black_sludge", + (type, _args) => new HealShopCostModifier(type, pregenArgs[0] as number), + ); + } + return new ModifierType( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_BLACK_SLUDGE", + "black_sludge", + (type, _args) => new HealShopCostModifier(type, 2.5), + ); + }), + MYSTERY_ENCOUNTER_MACHO_BRACE: () => + new PokemonHeldItemModifierType( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_MACHO_BRACE", + "macho_brace", + (type, args) => new PokemonIncrementingStatModifier(type, (args[0] as Pokemon).id), + ), + MYSTERY_ENCOUNTER_GOLDEN_BUG_NET: () => + new ModifierType( + "modifierType:ModifierType.MYSTERY_ENCOUNTER_GOLDEN_BUG_NET", + "golden_net", + (type, _args) => new BoostBugSpawnModifier(type), + ), }; interface ModifierPool { - [tier: string]: WeightedModifierType[] + [tier: string]: WeightedModifierType[]; } /** @@ -1636,220 +2394,422 @@ interface ModifierPool { * @returns boolean: true if the player has the maximum of a given ball type */ function hasMaximumBalls(ballType: PokeballType): boolean { - return (globalScene.gameMode.isClassic && globalScene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS); + return globalScene.gameMode.isClassic && globalScene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS; } const modifierPool: ModifierPool = { [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.POKEBALL, () => (hasMaximumBalls(PokeballType.POKEBALL)) ? 0 : 6, 6), + new WeightedModifierType(modifierTypes.POKEBALL, () => (hasMaximumBalls(PokeballType.POKEBALL) ? 0 : 6), 6), new WeightedModifierType(modifierTypes.RARE_CANDY, 2), - new WeightedModifierType(modifierTypes.POTION, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875) && !p.isFainted()).length, 3); - return thresholdPartyMemberCount * 3; - }, 9), - new WeightedModifierType(modifierTypes.SUPER_POTION, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75) && !p.isFainted()).length, 3); - return thresholdPartyMemberCount; - }, 3), - new WeightedModifierType(modifierTypes.ETHER, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) - && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3); - return thresholdPartyMemberCount * 3; - }, 9), - new WeightedModifierType(modifierTypes.MAX_ETHER, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) - && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3); - return thresholdPartyMemberCount; - }, 3), + new WeightedModifierType( + modifierTypes.POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.SUPER_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.ETHER, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_ETHER, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), new WeightedModifierType(modifierTypes.LURE, lureWeightFunc(10, 2)), new WeightedModifierType(modifierTypes.TEMP_STAT_STAGE_BOOSTER, 4), new WeightedModifierType(modifierTypes.BERRY, 2), new WeightedModifierType(modifierTypes.TM_COMMON, 2), ].map(m => { - m.setTier(ModifierTier.COMMON); return m; + m.setTier(ModifierTier.COMMON); + return m; }), [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.GREAT_BALL, () => (hasMaximumBalls(PokeballType.GREAT_BALL)) ? 0 : 6, 6), + new WeightedModifierType(modifierTypes.GREAT_BALL, () => (hasMaximumBalls(PokeballType.GREAT_BALL) ? 0 : 6), 6), new WeightedModifierType(modifierTypes.PP_UP, 2), - new WeightedModifierType(modifierTypes.FULL_HEAL, (party: Pokemon[]) => { - const statusEffectPartyMemberCount = Math.min(party.filter(p => p.hp && !!p.status && !p.getHeldItems().some(i => { - if (i instanceof TurnStatusEffectModifier) { - return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; - } - return false; - })).length, 3); - return statusEffectPartyMemberCount * 6; - }, 18), - new WeightedModifierType(modifierTypes.REVIVE, (party: Pokemon[]) => { - const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); - return faintedPartyMemberCount * 9; - }, 27), - new WeightedModifierType(modifierTypes.MAX_REVIVE, (party: Pokemon[]) => { - const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); - return faintedPartyMemberCount * 3; - }, 9), - new WeightedModifierType(modifierTypes.SACRED_ASH, (party: Pokemon[]) => { - return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0; - }, 1), - new WeightedModifierType(modifierTypes.HYPER_POTION, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625) && !p.isFainted()).length, 3); - return thresholdPartyMemberCount * 3; - }, 9), - new WeightedModifierType(modifierTypes.MAX_POTION, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3); - return thresholdPartyMemberCount; - }, 3), - new WeightedModifierType(modifierTypes.FULL_RESTORE, (party: Pokemon[]) => { - const statusEffectPartyMemberCount = Math.min(party.filter(p => p.hp && !!p.status && !p.getHeldItems().some(i => { - if (i instanceof TurnStatusEffectModifier) { - return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; - } - return false; - })).length, 3); - const thresholdPartyMemberCount = Math.floor((Math.min(party.filter(p => (p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5) && !p.isFainted()).length, 3) + statusEffectPartyMemberCount) / 2); - return thresholdPartyMemberCount; - }, 3), - new WeightedModifierType(modifierTypes.ELIXIR, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) - && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3); - return thresholdPartyMemberCount * 3; - }, 9), - new WeightedModifierType(modifierTypes.MAX_ELIXIR, (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min(party.filter(p => p.hp && !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) - && p.getMoveset().filter(m => m?.ppUsed && (m.getMovePp() - m.ppUsed) <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)).length).length, 3); - return thresholdPartyMemberCount; - }, 3), + new WeightedModifierType( + modifierTypes.FULL_HEAL, + (party: Pokemon[]) => { + const statusEffectPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !!p.status && + !p.getHeldItems().some(i => { + if (i instanceof TurnStatusEffectModifier) { + return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; + } + return false; + }), + ).length, + 3, + ); + return statusEffectPartyMemberCount * 6; + }, + 18, + ), + new WeightedModifierType( + modifierTypes.REVIVE, + (party: Pokemon[]) => { + const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); + return faintedPartyMemberCount * 9; + }, + 27, + ), + new WeightedModifierType( + modifierTypes.MAX_REVIVE, + (party: Pokemon[]) => { + const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); + return faintedPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.SACRED_ASH, + (party: Pokemon[]) => { + return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0; + }, + 1, + ), + new WeightedModifierType( + modifierTypes.HYPER_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.FULL_RESTORE, + (party: Pokemon[]) => { + const statusEffectPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !!p.status && + !p.getHeldItems().some(i => { + if (i instanceof TurnStatusEffectModifier) { + return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; + } + return false; + }), + ).length, + 3, + ); + const thresholdPartyMemberCount = Math.floor( + (Math.min(party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, 3) + + statusEffectPartyMemberCount) / + 2, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.ELIXIR, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_ELIXIR, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m?.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), new WeightedModifierType(modifierTypes.DIRE_HIT, 4), new WeightedModifierType(modifierTypes.SUPER_LURE, lureWeightFunc(15, 4)), new WeightedModifierType(modifierTypes.NUGGET, skipInLastClassicWaveOrDefault(5)), - new WeightedModifierType(modifierTypes.EVOLUTION_ITEM, () => { - return Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15), 8); - }, 8), - new WeightedModifierType(modifierTypes.MAP, () => globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex < 180 ? 2 : 0, 2), + new WeightedModifierType( + modifierTypes.EVOLUTION_ITEM, + () => { + return Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15), 8); + }, + 8, + ), + new WeightedModifierType( + modifierTypes.MAP, + () => (globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex < 180 ? 2 : 0), + 2, + ), new WeightedModifierType(modifierTypes.SOOTHE_BELL, 2), new WeightedModifierType(modifierTypes.TM_GREAT, 3), - new WeightedModifierType(modifierTypes.MEMORY_MUSHROOM, (party: Pokemon[]) => { - if (!party.find(p => p.getLearnableLevelMoves().length)) { - return 0; - } - const highestPartyLevel = party.map(p => p.level).reduce((highestLevel: number, level: number) => Math.max(highestLevel, level), 1); - return Math.min(Math.ceil(highestPartyLevel / 20), 4); - }, 4), - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), - new WeightedModifierType(modifierTypes.TERA_SHARD, (party: Pokemon[]) => party.filter(p => !(p.hasSpecies(Species.TERAPAGOS) || p.hasSpecies(Species.OGERPON) || p.hasSpecies(Species.SHEDINJA))).length > 0 ? 1 : 0), - new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => { - if (party.filter(p => !p.fusionSpecies).length > 1) { - if (globalScene.gameMode.isSplicedOnly) { - return 4; - } else if (globalScene.gameMode.isClassic && globalScene.eventManager.areFusionsBoosted()) { - return 2; + new WeightedModifierType( + modifierTypes.MEMORY_MUSHROOM, + (party: Pokemon[]) => { + if (!party.find(p => p.getLearnableLevelMoves().length)) { + return 0; } - } - return 0; - }, 4), - new WeightedModifierType(modifierTypes.VOUCHER, (_party: Pokemon[], rerollCount: number) => !globalScene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0, 1), + const highestPartyLevel = party + .map(p => p.level) + .reduce((highestLevel: number, level: number) => Math.max(highestLevel, level), 1); + return Math.min(Math.ceil(highestPartyLevel / 20), 4); + }, + 4, + ), + new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), + new WeightedModifierType(modifierTypes.TERA_SHARD, (party: Pokemon[]) => + party.filter( + p => !(p.hasSpecies(Species.TERAPAGOS) || p.hasSpecies(Species.OGERPON) || p.hasSpecies(Species.SHEDINJA)), + ).length > 0 + ? 1 + : 0, + ), + new WeightedModifierType( + modifierTypes.DNA_SPLICERS, + (party: Pokemon[]) => { + if (party.filter(p => !p.fusionSpecies).length > 1) { + if (globalScene.gameMode.isSplicedOnly) { + return 4; + } + if (globalScene.gameMode.isClassic && globalScene.eventManager.areFusionsBoosted()) { + return 2; + } + } + return 0; + }, + 4, + ), + new WeightedModifierType( + modifierTypes.VOUCHER, + (_party: Pokemon[], rerollCount: number) => (!globalScene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0), + 1, + ), ].map(m => { - m.setTier(ModifierTier.GREAT); return m; + m.setTier(ModifierTier.GREAT); + return m; }), [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ULTRA_BALL, () => (hasMaximumBalls(PokeballType.ULTRA_BALL)) ? 0 : 15, 15), + new WeightedModifierType(modifierTypes.ULTRA_BALL, () => (hasMaximumBalls(PokeballType.ULTRA_BALL) ? 0 : 15), 15), new WeightedModifierType(modifierTypes.MAX_LURE, lureWeightFunc(30, 4)), new WeightedModifierType(modifierTypes.BIG_NUGGET, skipInLastClassicWaveOrDefault(12)), new WeightedModifierType(modifierTypes.PP_MAX, 3), new WeightedModifierType(modifierTypes.MINT, 4), - new WeightedModifierType(modifierTypes.RARE_EVOLUTION_ITEM, () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15) * 4, 32), 32), - new WeightedModifierType(modifierTypes.FORM_CHANGE_ITEM, () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, 24), + new WeightedModifierType( + modifierTypes.RARE_EVOLUTION_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15) * 4, 32), + 32, + ), + new WeightedModifierType( + modifierTypes.FORM_CHANGE_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, + 24, + ), new WeightedModifierType(modifierTypes.AMULET_COIN, skipInLastClassicWaveOrDefault(3)), new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { const { gameMode, gameData } = globalScene; if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) { return party.some(p => { // Check if Pokemon's species (or fusion species, if applicable) can evolve or if they're G-Max'd - if (!p.isMax() && ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)))) { + if ( + !p.isMax() && + (p.getSpeciesForm(true).speciesId in pokemonEvolutions || + (p.isFusion() && p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)) + ) { // Check if Pokemon is already holding an Eviolite return !p.getHeldItems().some(i => i.type.id === "EVIOLITE"); } return false; - }) ? 10 : 0; + }) + ? 10 + : 0; } return 0; }), new WeightedModifierType(modifierTypes.SPECIES_STAT_BOOSTER, 12), - new WeightedModifierType(modifierTypes.LEEK, (party: Pokemon[]) => { - const checkedSpecies = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; - // If a party member doesn't already have a Leek and is one of the relevant species, Leek can appear - return party.some(p => !p.getHeldItems().some(i => i instanceof SpeciesCritBoosterModifier) - && (checkedSpecies.includes(p.getSpeciesForm(true).speciesId) - || (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId)))) ? 12 : 0; - }, 12), - new WeightedModifierType(modifierTypes.TOXIC_ORB, (party: Pokemon[]) => { - return party.some(p => { - const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); + new WeightedModifierType( + modifierTypes.LEEK, + (party: Pokemon[]) => { + const checkedSpecies = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD]; + // If a party member doesn't already have a Leek and is one of the relevant species, Leek can appear + return party.some( + p => + !p.getHeldItems().some(i => i instanceof SpeciesCritBoosterModifier) && + (checkedSpecies.includes(p.getSpeciesForm(true).speciesId) || + (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId))), + ) + ? 12 + : 0; + }, + 12, + ), + new WeightedModifierType( + modifierTypes.TOXIC_ORB, + (party: Pokemon[]) => { + return party.some(p => { + const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); - if (!isHoldingOrb) { - const moveset = p.getMoveset(true).filter(m => !isNullOrUndefined(m)).map(m => m.moveId); - const canSetStatus = p.canSetStatus(StatusEffect.TOXIC, true, true, null, true); + if (!isHoldingOrb) { + const moveset = p + .getMoveset(true) + .filter(m => !isNullOrUndefined(m)) + .map(m => m.moveId); + const canSetStatus = p.canSetStatus(StatusEffect.TOXIC, true, true, null, true); - // Moves that take advantage of obtaining the actual status effect - const hasStatusMoves = [ Moves.FACADE, Moves.PSYCHO_SHIFT ] - .some(m => moveset.includes(m)); - // Moves that take advantage of being able to give the target a status orb - // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented - const hasItemMoves = [ /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ ] - .some(m => moveset.includes(m)); + // Moves that take advantage of obtaining the actual status effect + const hasStatusMoves = [Moves.FACADE, Moves.PSYCHO_SHIFT].some(m => moveset.includes(m)); + // Moves that take advantage of being able to give the target a status orb + // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented + const hasItemMoves = [ + /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ + ].some(m => moveset.includes(m)); - if (canSetStatus) { - // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb - const hasGeneralAbility = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.MAGIC_GUARD ] - .some(a => p.hasAbility(a, false, true)); - const hasSpecificAbility = [ Abilities.TOXIC_BOOST, Abilities.POISON_HEAL ] - .some(a => p.hasAbility(a, false, true)); - const hasOppositeAbility = [ Abilities.FLARE_BOOST ] - .some(a => p.hasAbility(a, false, true)); + if (canSetStatus) { + // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb + const hasGeneralAbility = [ + Abilities.QUICK_FEET, + Abilities.GUTS, + Abilities.MARVEL_SCALE, + Abilities.MAGIC_GUARD, + ].some(a => p.hasAbility(a, false, true)); + const hasSpecificAbility = [Abilities.TOXIC_BOOST, Abilities.POISON_HEAL].some(a => + p.hasAbility(a, false, true), + ); + const hasOppositeAbility = [Abilities.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); - return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; - } else { + return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; + } return hasItemMoves; } - } - return false; - }) ? 10 : 0; - }, 10), - new WeightedModifierType(modifierTypes.FLAME_ORB, (party: Pokemon[]) => { - return party.some(p => { - const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); + return false; + }) + ? 10 + : 0; + }, + 10, + ), + new WeightedModifierType( + modifierTypes.FLAME_ORB, + (party: Pokemon[]) => { + return party.some(p => { + const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); - if (!isHoldingOrb) { - const moveset = p.getMoveset(true).filter(m => !isNullOrUndefined(m)).map(m => m.moveId); - const canSetStatus = p.canSetStatus(StatusEffect.BURN, true, true, null, true); + if (!isHoldingOrb) { + const moveset = p + .getMoveset(true) + .filter(m => !isNullOrUndefined(m)) + .map(m => m.moveId); + const canSetStatus = p.canSetStatus(StatusEffect.BURN, true, true, null, true); - // Moves that take advantage of obtaining the actual status effect - const hasStatusMoves = [ Moves.FACADE, Moves.PSYCHO_SHIFT ] - .some(m => moveset.includes(m)); - // Moves that take advantage of being able to give the target a status orb - // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented - const hasItemMoves = [ /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ ] - .some(m => moveset.includes(m)); + // Moves that take advantage of obtaining the actual status effect + const hasStatusMoves = [Moves.FACADE, Moves.PSYCHO_SHIFT].some(m => moveset.includes(m)); + // Moves that take advantage of being able to give the target a status orb + // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented + const hasItemMoves = [ + /* Moves.TRICK, Moves.FLING, Moves.SWITCHEROO */ + ].some(m => moveset.includes(m)); - if (canSetStatus) { - // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb - const hasGeneralAbility = [ Abilities.QUICK_FEET, Abilities.GUTS, Abilities.MARVEL_SCALE, Abilities.MAGIC_GUARD ] - .some(a => p.hasAbility(a, false, true)); - const hasSpecificAbility = [ Abilities.FLARE_BOOST ] - .some(a => p.hasAbility(a, false, true)); - const hasOppositeAbility = [ Abilities.TOXIC_BOOST, Abilities.POISON_HEAL ] - .some(a => p.hasAbility(a, false, true)); + if (canSetStatus) { + // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb + const hasGeneralAbility = [ + Abilities.QUICK_FEET, + Abilities.GUTS, + Abilities.MARVEL_SCALE, + Abilities.MAGIC_GUARD, + ].some(a => p.hasAbility(a, false, true)); + const hasSpecificAbility = [Abilities.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); + const hasOppositeAbility = [Abilities.TOXIC_BOOST, Abilities.POISON_HEAL].some(a => + p.hasAbility(a, false, true), + ); - return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; - } else { + return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; + } return hasItemMoves; } - } - return false; - }) ? 10 : 0; - }, 10), + return false; + }) + ? 10 + : 0; + }, + 10, + ), new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), new WeightedModifierType(modifierTypes.CANDY_JAR, skipInLastClassicWaveOrDefault(5)), new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 9), @@ -1859,14 +2819,22 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.IV_SCANNER, skipInLastClassicWaveOrDefault(4)), new WeightedModifierType(modifierTypes.EXP_CHARM, skipInLastClassicWaveOrDefault(8)), new WeightedModifierType(modifierTypes.EXP_SHARE, skipInLastClassicWaveOrDefault(10)), - new WeightedModifierType(modifierTypes.TERA_ORB, () => !globalScene.gameMode.isClassic ? Math.min(Math.max(Math.floor(globalScene.currentBattle.waveIndex / 50) * 2, 1), 4) : 0, 4), + new WeightedModifierType( + modifierTypes.TERA_ORB, + () => + !globalScene.gameMode.isClassic + ? Math.min(Math.max(Math.floor(globalScene.currentBattle.waveIndex / 50) * 2, 1), 4) + : 0, + 4, + ), new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), new WeightedModifierType(modifierTypes.WIDE_LENS, 7), ].map(m => { - m.setTier(ModifierTier.ULTRA); return m; + m.setTier(ModifierTier.ULTRA); + return m; }), [ModifierTier.ROGUE]: [ - new WeightedModifierType(modifierTypes.ROGUE_BALL, () => (hasMaximumBalls(PokeballType.ROGUE_BALL)) ? 0 : 16, 16), + new WeightedModifierType(modifierTypes.ROGUE_BALL, () => (hasMaximumBalls(PokeballType.ROGUE_BALL) ? 0 : 16), 16), new WeightedModifierType(modifierTypes.RELIC_GOLD, skipInLastClassicWaveOrDefault(2)), new WeightedModifierType(modifierTypes.LEFTOVERS, 3), new WeightedModifierType(modifierTypes.SHELL_BELL, 3), @@ -1875,79 +2843,119 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.SCOPE_LENS, 4), new WeightedModifierType(modifierTypes.BATON, 2), new WeightedModifierType(modifierTypes.SOUL_DEW, 7), - new WeightedModifierType(modifierTypes.CATCHING_CHARM, () => !globalScene.gameMode.isClassic ? 4 : 0, 4), + new WeightedModifierType(modifierTypes.CATCHING_CHARM, () => (!globalScene.gameMode.isClassic ? 4 : 0), 4), new WeightedModifierType(modifierTypes.ABILITY_CHARM, skipInClassicAfterWave(189, 6)), new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), - new WeightedModifierType(modifierTypes.LOCK_CAPSULE, () => globalScene.gameMode.isClassic ? 0 : 3), + new WeightedModifierType(modifierTypes.LOCK_CAPSULE, () => (globalScene.gameMode.isClassic ? 0 : 3)), new WeightedModifierType(modifierTypes.SUPER_EXP_CHARM, skipInLastClassicWaveOrDefault(8)), - new WeightedModifierType(modifierTypes.RARE_FORM_CHANGE_ITEM, () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, 24), - new WeightedModifierType(modifierTypes.MEGA_BRACELET, () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, 36), - new WeightedModifierType(modifierTypes.DYNAMAX_BAND, () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, 36), - new WeightedModifierType(modifierTypes.VOUCHER_PLUS, (_party: Pokemon[], rerollCount: number) => !globalScene.gameMode.isDaily ? Math.max(3 - rerollCount * 1, 0) : 0, 3), + new WeightedModifierType( + modifierTypes.RARE_FORM_CHANGE_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, + 24, + ), + new WeightedModifierType( + modifierTypes.MEGA_BRACELET, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, + 36, + ), + new WeightedModifierType( + modifierTypes.DYNAMAX_BAND, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, + 36, + ), + new WeightedModifierType( + modifierTypes.VOUCHER_PLUS, + (_party: Pokemon[], rerollCount: number) => + !globalScene.gameMode.isDaily ? Math.max(3 - rerollCount * 1, 0) : 0, + 3, + ), ].map(m => { - m.setTier(ModifierTier.ROGUE); return m; + m.setTier(ModifierTier.ROGUE); + return m; }), [ModifierTier.MASTER]: [ - new WeightedModifierType(modifierTypes.MASTER_BALL, () => (hasMaximumBalls(PokeballType.MASTER_BALL)) ? 0 : 24, 24), + new WeightedModifierType(modifierTypes.MASTER_BALL, () => (hasMaximumBalls(PokeballType.MASTER_BALL) ? 0 : 24), 24), new WeightedModifierType(modifierTypes.SHINY_CHARM, 14), new WeightedModifierType(modifierTypes.HEALING_CHARM, 18), new WeightedModifierType(modifierTypes.MULTI_LENS, 18), - new WeightedModifierType(modifierTypes.VOUCHER_PREMIUM, (_party: Pokemon[], rerollCount: number) => - !globalScene.gameMode.isDaily && !globalScene.gameMode.isEndless && !globalScene.gameMode.isSplicedOnly ? Math.max(5 - rerollCount * 2, 0) : 0, 5), - new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => !(globalScene.gameMode.isClassic && globalScene.eventManager.areFusionsBoosted()) && !globalScene.gameMode.isSplicedOnly && party.filter(p => !p.fusionSpecies).length > 1 ? 24 : 0, 24), - new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, () => (globalScene.gameMode.isDaily || (!globalScene.gameMode.isFreshStartChallenge() && globalScene.gameData.isUnlocked(Unlockables.MINI_BLACK_HOLE))) ? 1 : 0, 1), + new WeightedModifierType( + modifierTypes.VOUCHER_PREMIUM, + (_party: Pokemon[], rerollCount: number) => + !globalScene.gameMode.isDaily && !globalScene.gameMode.isEndless && !globalScene.gameMode.isSplicedOnly + ? Math.max(5 - rerollCount * 2, 0) + : 0, + 5, + ), + new WeightedModifierType( + modifierTypes.DNA_SPLICERS, + (party: Pokemon[]) => + !(globalScene.gameMode.isClassic && globalScene.eventManager.areFusionsBoosted()) && + !globalScene.gameMode.isSplicedOnly && + party.filter(p => !p.fusionSpecies).length > 1 + ? 24 + : 0, + 24, + ), + new WeightedModifierType( + modifierTypes.MINI_BLACK_HOLE, + () => + globalScene.gameMode.isDaily || + (!globalScene.gameMode.isFreshStartChallenge() && globalScene.gameData.isUnlocked(Unlockables.MINI_BLACK_HOLE)) + ? 1 + : 0, + 1, + ), ].map(m => { - m.setTier(ModifierTier.MASTER); return m; - }) + m.setTier(ModifierTier.MASTER); + return m; + }), }; const wildModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.BERRY, 1) - ].map(m => { - m.setTier(ModifierTier.COMMON); return m; + [ModifierTier.COMMON]: [new WeightedModifierType(modifierTypes.BERRY, 1)].map(m => { + m.setTier(ModifierTier.COMMON); + return m; }), - [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1) - ].map(m => { - m.setTier(ModifierTier.GREAT); return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), - new WeightedModifierType(modifierTypes.WHITE_HERB, 0) - ].map(m => { - m.setTier(ModifierTier.ULTRA); return m; - }), - [ModifierTier.ROGUE]: [ - new WeightedModifierType(modifierTypes.LUCKY_EGG, 4), - ].map(m => { - m.setTier(ModifierTier.ROGUE); return m; - }), - [ModifierTier.MASTER]: [ - new WeightedModifierType(modifierTypes.GOLDEN_EGG, 1) - ].map(m => { - m.setTier(ModifierTier.MASTER); return m; - }) -}; - -const trainerModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.BERRY, 8), - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3) - ].map(m => { - m.setTier(ModifierTier.COMMON); return m; - }), - [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), - ].map(m => { - m.setTier(ModifierTier.GREAT); return m; + [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1)].map(m => { + m.setTier(ModifierTier.GREAT); + return m; }), [ModifierTier.ULTRA]: [ new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), new WeightedModifierType(modifierTypes.WHITE_HERB, 0), ].map(m => { - m.setTier(ModifierTier.ULTRA); return m; + m.setTier(ModifierTier.ULTRA); + return m; + }), + [ModifierTier.ROGUE]: [new WeightedModifierType(modifierTypes.LUCKY_EGG, 4)].map(m => { + m.setTier(ModifierTier.ROGUE); + return m; + }), + [ModifierTier.MASTER]: [new WeightedModifierType(modifierTypes.GOLDEN_EGG, 1)].map(m => { + m.setTier(ModifierTier.MASTER); + return m; + }), +}; + +const trainerModifierPool: ModifierPool = { + [ModifierTier.COMMON]: [ + new WeightedModifierType(modifierTypes.BERRY, 8), + new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), + ].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }), + [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)].map(m => { + m.setTier(ModifierTier.GREAT); + return m; + }), + [ModifierTier.ULTRA]: [ + new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), + new WeightedModifierType(modifierTypes.WHITE_HERB, 0), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; }), [ModifierTier.ROGUE]: [ new WeightedModifierType(modifierTypes.FOCUS_BAND, 2), @@ -1956,7 +2964,8 @@ const trainerModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.GRIP_CLAW, 1), new WeightedModifierType(modifierTypes.WIDE_LENS, 1), ].map(m => { - m.setTier(ModifierTier.ROGUE); return m; + m.setTier(ModifierTier.ROGUE); + return m; }), [ModifierTier.MASTER]: [ new WeightedModifierType(modifierTypes.KINGS_ROCK, 1), @@ -1964,8 +2973,9 @@ const trainerModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.SHELL_BELL, 1), new WeightedModifierType(modifierTypes.SCOPE_LENS, 1), ].map(m => { - m.setTier(ModifierTier.MASTER); return m; - }) + m.setTier(ModifierTier.MASTER); + return m; + }), }; const enemyBuffModifierPool: ModifierPool = { @@ -1977,18 +2987,20 @@ const enemyBuffModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.ENEMY_ATTACK_BURN_CHANCE, 3), new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 9), new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 4), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1) + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), ].map(m => { - m.setTier(ModifierTier.COMMON); return m; + m.setTier(ModifierTier.COMMON); + return m; }), [ModifierTier.GREAT]: [ new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 5), new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 5), new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 5), new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 5), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1) + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), ].map(m => { - m.setTier(ModifierTier.GREAT); return m; + m.setTier(ModifierTier.GREAT); + return m; }), [ModifierTier.ULTRA]: [ new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 10), @@ -1996,16 +3008,19 @@ const enemyBuffModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.ENEMY_HEAL, 10), new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 10), new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 10), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 5) + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 5), ].map(m => { - m.setTier(ModifierTier.ULTRA); return m; + m.setTier(ModifierTier.ULTRA); + return m; }), - [ModifierTier.ROGUE]: [ ].map((m: WeightedModifierType) => { - m.setTier(ModifierTier.ROGUE); return m; + [ModifierTier.ROGUE]: [].map((m: WeightedModifierType) => { + m.setTier(ModifierTier.ROGUE); + return m; + }), + [ModifierTier.MASTER]: [].map((m: WeightedModifierType) => { + m.setTier(ModifierTier.MASTER); + return m; }), - [ModifierTier.MASTER]: [ ].map((m: WeightedModifierType) => { - m.setTier(ModifierTier.MASTER); return m; - }) }; const dailyStarterModifierPool: ModifierPool = { @@ -2013,12 +3028,12 @@ const dailyStarterModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1), new WeightedModifierType(modifierTypes.BERRY, 3), ].map(m => { - m.setTier(ModifierTier.COMMON); return m; + m.setTier(ModifierTier.COMMON); + return m; }), - [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5), - ].map(m => { - m.setTier(ModifierTier.GREAT); return m; + [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5)].map(m => { + m.setTier(ModifierTier.GREAT); + return m; }), [ModifierTier.ULTRA]: [ new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), @@ -2026,7 +3041,8 @@ const dailyStarterModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.SOUL_DEW, 1), new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, 1), ].map(m => { - m.setTier(ModifierTier.ULTRA); return m; + m.setTier(ModifierTier.ULTRA); + return m; }), [ModifierTier.ROGUE]: [ new WeightedModifierType(modifierTypes.GRIP_CLAW, 5), @@ -2035,14 +3051,16 @@ const dailyStarterModifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), ].map(m => { - m.setTier(ModifierTier.ROGUE); return m; + m.setTier(ModifierTier.ROGUE); + return m; }), [ModifierTier.MASTER]: [ new WeightedModifierType(modifierTypes.LEFTOVERS, 1), new WeightedModifierType(modifierTypes.SHELL_BELL, 1), ].map(m => { - m.setTier(ModifierTier.MASTER); return m; - }) + m.setTier(ModifierTier.MASTER); + return m; + }), }; export function getModifierType(modifierTypeFunc: ModifierTypeFunc): ModifierType { @@ -2057,13 +3075,16 @@ let modifierPoolThresholds = {}; let ignoredPoolIndexes = {}; let dailyStarterModifierPoolThresholds = {}; -let ignoredDailyStarterPoolIndexes = {}; // eslint-disable-line @typescript-eslint/no-unused-vars +// biome-ignore lint/correctness/noUnusedVariables: TODO explain why this is marked as OK +let ignoredDailyStarterPoolIndexes = {}; let enemyModifierPoolThresholds = {}; -let enemyIgnoredPoolIndexes = {}; // eslint-disable-line @typescript-eslint/no-unused-vars +// biome-ignore lint/correctness/noUnusedVariables: TODO explain why this is marked as OK +let enemyIgnoredPoolIndexes = {}; let enemyBuffModifierPoolThresholds = {}; -let enemyBuffIgnoredPoolIndexes = {}; // eslint-disable-line @typescript-eslint/no-unused-vars +// biome-ignore lint/correctness/noUnusedVariables: TODO explain why this is marked as OK +let enemyBuffIgnoredPoolIndexes = {}; export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool { let pool: ModifierPool; @@ -2087,13 +3108,13 @@ export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool return pool; } -const tierWeights = [ 768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024 ]; +const tierWeights = [768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024]; /** * Allows a unit test to check if an item exists in the Modifier Pool. Checks the pool directly, rather than attempting to reroll for the item. */ export const itemPoolChecks: Map = new Map(); -export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount: number = 0) { +export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount = 0) { const pool = getModifierPoolForType(poolType); itemPoolChecks.forEach((_v, k) => { itemPoolChecks.set(k, false); @@ -2101,52 +3122,68 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: Mod const ignoredIndexes = {}; const modifierTableData = {}; - const thresholds = Object.fromEntries(new Map(Object.keys(pool).map(t => { - ignoredIndexes[t] = []; - const thresholds = new Map(); - const tierModifierIds: string[] = []; - let tierMaxWeight = 0; - let i = 0; - pool[t].reduce((total: number, modifierType: WeightedModifierType) => { - const weightedModifierType = modifierType as WeightedModifierType; - const existingModifiers = globalScene.findModifiers(m => m.type.id === weightedModifierType.modifierType.id, poolType === ModifierPoolType.PLAYER); - const itemModifierType = weightedModifierType.modifierType instanceof ModifierTypeGenerator - ? weightedModifierType.modifierType.generateType(party) - : weightedModifierType.modifierType; - const weight = !existingModifiers.length - || itemModifierType instanceof PokemonHeldItemModifierType - || itemModifierType instanceof FormChangeItemModifierType - || existingModifiers.find(m => m.stackCount < m.getMaxStackCount(true)) - ? weightedModifierType.weight instanceof Function - ? (weightedModifierType.weight as Function)(party, rerollCount) - : weightedModifierType.weight as number - : 0; - if (weightedModifierType.maxWeight) { - const modifierId = weightedModifierType.modifierType.id; - tierModifierIds.push(modifierId); - const outputWeight = useMaxWeightForOutput ? weightedModifierType.maxWeight : weight; - modifierTableData[modifierId] = { weight: outputWeight, tier: parseInt(t), tierPercent: 0, totalPercent: 0 }; - tierMaxWeight += outputWeight; - } - if (weight) { - total += weight; - } else { - ignoredIndexes[t].push(i++); - return total; - } - if (itemPoolChecks.has(modifierType.modifierType.id as ModifierTypeKeys)) { - itemPoolChecks.set(modifierType.modifierType.id as ModifierTypeKeys, true); - } - thresholds.set(total, i++); - return total; - }, 0); - for (const id of tierModifierIds) { - modifierTableData[id].tierPercent = Math.floor((modifierTableData[id].weight / tierMaxWeight) * 10000) / 100; - } - return [ t, Object.fromEntries(thresholds) ]; - }))); + const thresholds = Object.fromEntries( + new Map( + Object.keys(pool).map(t => { + ignoredIndexes[t] = []; + const thresholds = new Map(); + const tierModifierIds: string[] = []; + let tierMaxWeight = 0; + let i = 0; + pool[t].reduce((total: number, modifierType: WeightedModifierType) => { + const weightedModifierType = modifierType as WeightedModifierType; + const existingModifiers = globalScene.findModifiers( + m => m.type.id === weightedModifierType.modifierType.id, + poolType === ModifierPoolType.PLAYER, + ); + const itemModifierType = + weightedModifierType.modifierType instanceof ModifierTypeGenerator + ? weightedModifierType.modifierType.generateType(party) + : weightedModifierType.modifierType; + const weight = + !existingModifiers.length || + itemModifierType instanceof PokemonHeldItemModifierType || + itemModifierType instanceof FormChangeItemModifierType || + existingModifiers.find(m => m.stackCount < m.getMaxStackCount(true)) + ? weightedModifierType.weight instanceof Function + ? // biome-ignore lint/complexity/noBannedTypes: TODO: refactor to not use Function type + (weightedModifierType.weight as Function)(party, rerollCount) + : (weightedModifierType.weight as number) + : 0; + if (weightedModifierType.maxWeight) { + const modifierId = weightedModifierType.modifierType.id; + tierModifierIds.push(modifierId); + const outputWeight = useMaxWeightForOutput ? weightedModifierType.maxWeight : weight; + modifierTableData[modifierId] = { + weight: outputWeight, + tier: Number.parseInt(t), + tierPercent: 0, + totalPercent: 0, + }; + tierMaxWeight += outputWeight; + } + if (weight) { + total += weight; + } else { + ignoredIndexes[t].push(i++); + return total; + } + if (itemPoolChecks.has(modifierType.modifierType.id as ModifierTypeKeys)) { + itemPoolChecks.set(modifierType.modifierType.id as ModifierTypeKeys, true); + } + thresholds.set(total, i++); + return total; + }, 0); + for (const id of tierModifierIds) { + modifierTableData[id].tierPercent = Math.floor((modifierTableData[id].weight / tierMaxWeight) * 10000) / 100; + } + return [t, Object.fromEntries(thresholds)]; + }), + ), + ); for (const id of Object.keys(modifierTableData)) { - modifierTableData[id].totalPercent = Math.floor(modifierTableData[id].tierPercent * tierWeights[modifierTableData[id].tier] * 100) / 100; + modifierTableData[id].totalPercent = + Math.floor(modifierTableData[id].tierPercent * tierWeights[modifierTableData[id].tier] * 100) / 100; modifierTableData[id].tier = ModifierTier[modifierTableData[id].tier]; } if (outputModifierData) { @@ -2203,21 +3240,39 @@ export function getModifierTypeFuncById(id: string): ModifierTypeFunc { * - `rerollMultiplier?: number` If specified, can adjust the amount of money required for a shop reroll. If set to a negative value, the shop will not allow rerolls at all. * - `allowLuckUpgrades?: boolean` Default `true`, if `false` will prevent set item tiers from upgrading via luck */ -export function getPlayerModifierTypeOptions(count: number, party: PlayerPokemon[], modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings): ModifierTypeOption[] { +export function getPlayerModifierTypeOptions( + count: number, + party: PlayerPokemon[], + modifierTiers?: ModifierTier[], + customModifierSettings?: CustomModifierSettings, +): ModifierTypeOption[] { const options: ModifierTypeOption[] = []; const retryCount = Math.min(count * 5, 50); if (!customModifierSettings) { new Array(count).fill(0).map((_, i) => { - options.push(getModifierTypeOptionWithRetry(options, retryCount, party, modifierTiers && modifierTiers.length > i ? modifierTiers[i] : undefined)); + options.push( + getModifierTypeOptionWithRetry( + options, + retryCount, + party, + modifierTiers && modifierTiers.length > i ? modifierTiers[i] : undefined, + ), + ); }); } else { // Guaranteed mod options first - if (customModifierSettings?.guaranteedModifierTypeOptions && customModifierSettings.guaranteedModifierTypeOptions.length > 0) { + if ( + customModifierSettings?.guaranteedModifierTypeOptions && + customModifierSettings.guaranteedModifierTypeOptions.length > 0 + ) { options.push(...customModifierSettings.guaranteedModifierTypeOptions!); } // Guaranteed mod functions second - if (customModifierSettings.guaranteedModifierTypeFuncs && customModifierSettings.guaranteedModifierTypeFuncs.length > 0) { + if ( + customModifierSettings.guaranteedModifierTypeFuncs && + customModifierSettings.guaranteedModifierTypeFuncs.length > 0 + ) { customModifierSettings.guaranteedModifierTypeFuncs!.forEach((mod, _i) => { const modifierId = Object.keys(modifierTypes).find(k => modifierTypes[k] === mod) as string; let guaranteedMod: ModifierType = modifierTypes[modifierId]?.(); @@ -2227,7 +3282,8 @@ export function getPlayerModifierTypeOptions(count: number, party: PlayerPokemon .withIdFromFunc(modifierTypes[modifierId]) .withTierFromPool(ModifierPoolType.PLAYER, party); - const modType = guaranteedMod instanceof ModifierTypeGenerator ? guaranteedMod.generateType(party) : guaranteedMod; + const modType = + guaranteedMod instanceof ModifierTypeGenerator ? guaranteedMod.generateType(party) : guaranteedMod; if (modType) { const option = new ModifierTypeOption(modType, 0); options.push(option); @@ -2238,9 +3294,9 @@ export function getPlayerModifierTypeOptions(count: number, party: PlayerPokemon // Guaranteed tiers third if (customModifierSettings.guaranteedModifierTiers && customModifierSettings.guaranteedModifierTiers.length > 0) { const allowLuckUpgrades = customModifierSettings.allowLuckUpgrades ?? true; - customModifierSettings.guaranteedModifierTiers.forEach((tier) => { + for (const tier of customModifierSettings.guaranteedModifierTiers) { options.push(getModifierTypeOptionWithRetry(options, retryCount, party, tier, allowLuckUpgrades)); - }); + } } // Fill remaining @@ -2264,12 +3320,29 @@ export function getPlayerModifierTypeOptions(count: number, party: PlayerPokemon * @param tier If specified will generate item of tier * @param allowLuckUpgrades `true` to allow items to upgrade tiers (the little animation that plays and is affected by luck) */ -function getModifierTypeOptionWithRetry(existingOptions: ModifierTypeOption[], retryCount: number, party: PlayerPokemon[], tier?: ModifierTier, allowLuckUpgrades?: boolean): ModifierTypeOption { +function getModifierTypeOptionWithRetry( + existingOptions: ModifierTypeOption[], + retryCount: number, + party: PlayerPokemon[], + tier?: ModifierTier, + allowLuckUpgrades?: boolean, +): ModifierTypeOption { allowLuckUpgrades = allowLuckUpgrades ?? true; let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades); let r = 0; - while (existingOptions.length && ++r < retryCount && existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length) { - candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, candidate?.type.tier ?? tier, candidate?.upgradeCount, 0, allowLuckUpgrades); + while ( + existingOptions.length && + ++r < retryCount && + existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length + ) { + candidate = getNewModifierTypeOption( + party, + ModifierPoolType.PLAYER, + candidate?.type.tier ?? tier, + candidate?.upgradeCount, + 0, + allowLuckUpgrades, + ); } return candidate!; } @@ -2289,7 +3362,7 @@ export function overridePlayerModifierTypeOptions(options: ModifierTypeOption[], let modifierType: ModifierType | null = modifierFunc(); if (modifierType instanceof ModifierTypeGenerator) { - const pregenArgs = ("type" in override) && (override.type !== null) ? [ override.type ] : undefined; + const pregenArgs = "type" in override && override.type !== null ? [override.type] : undefined; modifierType = modifierType.generateType(party, pregenArgs); } @@ -2308,7 +3381,7 @@ export function getPlayerShopModifierTypeOptionsForWave(waveIndex: number, baseC [ new ModifierTypeOption(modifierTypes.POTION(), 0, baseCost * 0.2), new ModifierTypeOption(modifierTypes.ETHER(), 0, baseCost * 0.4), - new ModifierTypeOption(modifierTypes.REVIVE(), 0, baseCost * 2) + new ModifierTypeOption(modifierTypes.REVIVE(), 0, baseCost * 2), ], [ new ModifierTypeOption(modifierTypes.SUPER_POTION(), 0, baseCost * 0.45), @@ -2316,28 +3389,27 @@ export function getPlayerShopModifierTypeOptionsForWave(waveIndex: number, baseC ], [ new ModifierTypeOption(modifierTypes.ELIXIR(), 0, baseCost), - new ModifierTypeOption(modifierTypes.MAX_ETHER(), 0, baseCost) + new ModifierTypeOption(modifierTypes.MAX_ETHER(), 0, baseCost), ], [ new ModifierTypeOption(modifierTypes.HYPER_POTION(), 0, baseCost * 0.8), new ModifierTypeOption(modifierTypes.MAX_REVIVE(), 0, baseCost * 2.75), - new ModifierTypeOption(modifierTypes.MEMORY_MUSHROOM(), 0, baseCost * 4) + new ModifierTypeOption(modifierTypes.MEMORY_MUSHROOM(), 0, baseCost * 4), ], [ new ModifierTypeOption(modifierTypes.MAX_POTION(), 0, baseCost * 1.5), - new ModifierTypeOption(modifierTypes.MAX_ELIXIR(), 0, baseCost * 2.5) + new ModifierTypeOption(modifierTypes.MAX_ELIXIR(), 0, baseCost * 2.5), ], - [ - new ModifierTypeOption(modifierTypes.FULL_RESTORE(), 0, baseCost * 2.25) - ], - [ - new ModifierTypeOption(modifierTypes.SACRED_ASH(), 0, baseCost * 10) - ] + [new ModifierTypeOption(modifierTypes.FULL_RESTORE(), 0, baseCost * 2.25)], + [new ModifierTypeOption(modifierTypes.SACRED_ASH(), 0, baseCost * 10)], ]; return options.slice(0, Math.ceil(Math.max(waveIndex + 10, 0) / 30)).flat(); } -export function getEnemyBuffModifierForWave(tier: ModifierTier, enemyModifiers: PersistentModifier[]): EnemyPersistentModifier { +export function getEnemyBuffModifierForWave( + tier: ModifierTier, + enemyModifiers: PersistentModifier[], +): EnemyPersistentModifier { let tierStackCount: number; switch (tier) { case ModifierTier.ULTRA: @@ -2355,7 +3427,11 @@ export function getEnemyBuffModifierForWave(tier: ModifierTier, enemyModifiers: let candidate = getNewModifierTypeOption([], ModifierPoolType.ENEMY_BUFF, tier); let r = 0; let matchingModifier: PersistentModifier | undefined; - while (++r < retryCount && (matchingModifier = enemyModifiers.find(m => m.type.id === candidate?.type?.id)) && matchingModifier.getMaxStackCount() < matchingModifier.stackCount + (r < 10 ? tierStackCount : 1)) { + while ( + ++r < retryCount && + (matchingModifier = enemyModifiers.find(m => m.type.id === candidate?.type?.id)) && + matchingModifier.getMaxStackCount() < matchingModifier.stackCount + (r < 10 ? tierStackCount : 1) + ) { candidate = getNewModifierTypeOption([], ModifierPoolType.ENEMY_BUFF, tier); } @@ -2365,8 +3441,20 @@ export function getEnemyBuffModifierForWave(tier: ModifierTier, enemyModifiers: return modifier; } -export function getEnemyModifierTypesForWave(waveIndex: number, count: number, party: EnemyPokemon[], poolType: ModifierPoolType.WILD | ModifierPoolType.TRAINER, upgradeChance: number = 0): PokemonHeldItemModifierType[] { - const ret = new Array(count).fill(0).map(() => getNewModifierTypeOption(party, poolType, undefined, upgradeChance && !randSeedInt(upgradeChance) ? 1 : 0)?.type as PokemonHeldItemModifierType); +export function getEnemyModifierTypesForWave( + waveIndex: number, + count: number, + party: EnemyPokemon[], + poolType: ModifierPoolType.WILD | ModifierPoolType.TRAINER, + upgradeChance = 0, +): PokemonHeldItemModifierType[] { + const ret = new Array(count) + .fill(0) + .map( + () => + getNewModifierTypeOption(party, poolType, undefined, upgradeChance && !randSeedInt(upgradeChance) ? 1 : 0) + ?.type as PokemonHeldItemModifierType, + ); if (!(waveIndex % 1000)) { ret.push(getModifierType(modifierTypes.MINI_BLACK_HOLE) as PokemonHeldItemModifierType); } @@ -2392,7 +3480,9 @@ export function getDailyRunStarterModifiers(party: PlayerPokemon[]): PokemonHeld tier = ModifierTier.MASTER; } - const modifier = getNewModifierTypeOption(party, ModifierPoolType.DAILY_STARTER, tier)?.type?.newModifier(p) as PokemonHeldItemModifier; + const modifier = getNewModifierTypeOption(party, ModifierPoolType.DAILY_STARTER, tier)?.type?.newModifier( + p, + ) as PokemonHeldItemModifier; ret.push(modifier); } } @@ -2409,7 +3499,14 @@ export function getDailyRunStarterModifiers(party: PlayerPokemon[]): PokemonHeld * @param retryCount Max allowed tries before the next tier down is checked for a valid ModifierType * @param allowLuckUpgrades Default true. If false, will not allow ModifierType to randomly upgrade to next tier */ -function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, tier?: ModifierTier, upgradeCount?: number, retryCount: number = 0, allowLuckUpgrades: boolean = true): ModifierTypeOption | null { +function getNewModifierTypeOption( + party: Pokemon[], + poolType: ModifierPoolType, + tier?: ModifierTier, + upgradeCount?: number, + retryCount = 0, + allowLuckUpgrades = true, +): ModifierTypeOption | null { const player = !poolType; const pool = getModifierPoolForType(poolType); let thresholds: object; @@ -2486,11 +3583,11 @@ function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, } const tierThresholds = Object.keys(thresholds[tier]); - const totalWeight = parseInt(tierThresholds[tierThresholds.length - 1]); + const totalWeight = Number.parseInt(tierThresholds[tierThresholds.length - 1]); const value = randSeedInt(totalWeight); let index: number | undefined; for (const t of tierThresholds) { - const threshold = parseInt(t); + const threshold = Number.parseInt(t); if (value < threshold) { index = thresholds[tier][threshold]; break; @@ -2504,7 +3601,7 @@ function getNewModifierTypeOption(party: Pokemon[], poolType: ModifierPoolType, if (player) { console.log(index, ignoredPoolIndexes[tier].filter(i => i <= index).length, ignoredPoolIndexes[tier]); } - let modifierType: ModifierType | null = (pool[tier][index]).modifierType; + let modifierType: ModifierType | null = pool[tier][index].modifierType; if (modifierType instanceof ModifierTypeGenerator) { modifierType = (modifierType as ModifierTypeGenerator).generateType(party); if (modifierType === null) { @@ -2533,7 +3630,7 @@ export class ModifierTypeOption { public upgradeCount: number; public cost: number; - constructor(type: ModifierType, upgradeCount: number, cost: number = 0) { + constructor(type: ModifierType, upgradeCount: number, cost = 0) { this.type = type; this.upgradeCount = upgradeCount; this.cost = Math.min(Math.round(cost), Number.MAX_SAFE_INTEGER); @@ -2548,19 +3645,28 @@ export class ModifierTypeOption { export function getPartyLuckValue(party: Pokemon[]): number { if (globalScene.gameMode.isDaily) { const DailyLuck = new NumberHolder(0); - globalScene.executeWithSeedOffset(() => { - DailyLuck.value = randSeedInt(15); // Random number between 0 and 14 - }, 0, globalScene.seed); + globalScene.executeWithSeedOffset( + () => { + DailyLuck.value = randSeedInt(15); // Random number between 0 and 14 + }, + 0, + globalScene.seed, + ); return DailyLuck.value; } const eventSpecies = globalScene.eventManager.getEventLuckBoostedSpecies(); - const luck = Phaser.Math.Clamp(party.map(p => p.isAllowedInBattle() ? p.getLuck() + (eventSpecies.includes(p.species.speciesId) ? 1 : 0) : 0) - .reduce((total: number, value: number) => total += value, 0), 0, 14); + const luck = Phaser.Math.Clamp( + party + .map(p => (p.isAllowedInBattle() ? p.getLuck() + (eventSpecies.includes(p.species.speciesId) ? 1 : 0) : 0)) + .reduce((total: number, value: number) => (total += value), 0), + 0, + 14, + ); return Math.min(globalScene.eventManager.getEventLuckBoost() + (luck ?? 0), 14); } export function getLuckString(luckValue: number): string { - return [ "D", "C", "C+", "B-", "B", "B+", "A-", "A", "A+", "A++", "S", "S+", "SS", "SS+", "SSS" ][luckValue]; + return ["D", "C", "C+", "B-", "B", "B+", "A-", "A", "A+", "A++", "S", "S+", "SS", "SS+", "SSS"][luckValue]; } export function getLuckTextTint(luckValue: number): number { diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 1f8d1eb0322..a084474ddac 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -27,7 +27,25 @@ import { type PermanentStat, type TempBattleStat, BATTLE_STATS, Stat, TEMP_BATTL import { StatusEffect } from "#enums/status-effect"; import type { PokemonType } from "#enums/pokemon-type"; import i18next from "i18next"; -import { type DoubleBattleChanceBoosterModifierType, type EvolutionItemModifierType, type FormChangeItemModifierType, type ModifierOverride, type ModifierType, type PokemonBaseStatTotalModifierType, type PokemonExpBoosterModifierType, type PokemonFriendshipBoosterModifierType, type PokemonMoveAccuracyBoosterModifierType, type PokemonMultiHitModifierType, type TerastallizeModifierType, type TmModifierType, getModifierType, ModifierPoolType, ModifierTypeGenerator, modifierTypes, PokemonHeldItemModifierType } from "./modifier-type"; +import { + type DoubleBattleChanceBoosterModifierType, + type EvolutionItemModifierType, + type FormChangeItemModifierType, + type ModifierOverride, + type ModifierType, + type PokemonBaseStatTotalModifierType, + type PokemonExpBoosterModifierType, + type PokemonFriendshipBoosterModifierType, + type PokemonMoveAccuracyBoosterModifierType, + type PokemonMultiHitModifierType, + type TerastallizeModifierType, + type TmModifierType, + getModifierType, + ModifierPoolType, + ModifierTypeGenerator, + modifierTypes, + PokemonHeldItemModifierType, +} from "./modifier-type"; import { Color, ShadowColor } from "#enums/color"; import { FRIENDSHIP_GAIN_FROM_RARE_CANDY } from "#app/data/balance/starters"; import { applyAbAttrs, CommanderAbAttr } from "#app/data/ability"; @@ -46,19 +64,19 @@ export const modifierSortFunc = (a: Modifier, b: Modifier): number => { //First sort by pokemonID if (aId < bId) { return 1; - } else if (aId > bId) { + } + if (aId > bId) { return -1; - } else if (aId === bId) { + } + if (aId === bId) { //Then sort by item type if (typeNameMatch === 0) { return itemNameMatch; //Finally sort by item name - } else { - return typeNameMatch; } - } else { - return 0; + return typeNameMatch; } + return 0; }; export class ModifierBar extends Phaser.GameObjects.Container { @@ -77,16 +95,20 @@ export class ModifierBar extends Phaser.GameObjects.Container { * @param {PersistentModifier[]} modifiers - The list of modifiers to be displayed in the {@linkcode ModifierBar} * @param {boolean} hideHeldItems - If set to "true", only modifiers not assigned to a Pokémon are displayed */ - updateModifiers(modifiers: PersistentModifier[], hideHeldItems: boolean = false) { + updateModifiers(modifiers: PersistentModifier[], hideHeldItems = false) { this.removeAll(true); const visibleIconModifiers = modifiers.filter(m => m.isIconVisible()); - const nonPokemonSpecificModifiers = visibleIconModifiers.filter(m => !(m as PokemonHeldItemModifier).pokemonId).sort(modifierSortFunc); - const pokemonSpecificModifiers = visibleIconModifiers.filter(m => (m as PokemonHeldItemModifier).pokemonId).sort(modifierSortFunc); + const nonPokemonSpecificModifiers = visibleIconModifiers + .filter(m => !(m as PokemonHeldItemModifier).pokemonId) + .sort(modifierSortFunc); + const pokemonSpecificModifiers = visibleIconModifiers + .filter(m => (m as PokemonHeldItemModifier).pokemonId) + .sort(modifierSortFunc); - const sortedVisibleIconModifiers = hideHeldItems ? nonPokemonSpecificModifiers : nonPokemonSpecificModifiers.concat(pokemonSpecificModifiers); - - const thisArg = this; + const sortedVisibleIconModifiers = hideHeldItems + ? nonPokemonSpecificModifiers + : nonPokemonSpecificModifiers.concat(pokemonSpecificModifiers); sortedVisibleIconModifiers.forEach((modifier: PersistentModifier, i: number) => { const icon = modifier.getIcon(); @@ -99,13 +121,13 @@ export class ModifierBar extends Phaser.GameObjects.Container { icon.on("pointerover", () => { globalScene.ui.showTooltip(modifier.type.name, modifier.type.getDescription()); if (this.modifierCache && this.modifierCache.length > iconOverflowIndex) { - thisArg.updateModifierOverflowVisibility(true); + this.updateModifierOverflowVisibility(true); } }); icon.on("pointerout", () => { globalScene.ui.hideTooltip(); if (this.modifierCache && this.modifierCache.length > iconOverflowIndex) { - thisArg.updateModifierOverflowVisibility(false); + this.updateModifierOverflowVisibility(false); } }); }); @@ -125,9 +147,9 @@ export class ModifierBar extends Phaser.GameObjects.Container { } setModifierIconPosition(icon: Phaser.GameObjects.Container, modifierCount: number) { - const rowIcons: number = 12 + 6 * Math.max((Math.ceil(Math.min(modifierCount, 24) / 12) - 2), 0); + const rowIcons: number = 12 + 6 * Math.max(Math.ceil(Math.min(modifierCount, 24) / 12) - 2, 0); - const x = (this.getIndex(icon) % rowIcons) * 26 / (rowIcons / 12); + const x = ((this.getIndex(icon) % rowIcons) * 26) / (rowIcons / 12); const y = Math.floor(this.getIndex(icon) / rowIcons) * 20; icon.setPosition(this.player ? x : -x, y); @@ -165,7 +187,7 @@ export abstract class PersistentModifier extends Modifier { public stackCount: number; public virtualStackCount: number; - constructor(type: ModifierType, stackCount: number = 1) { + constructor(type: ModifierType, stackCount = 1) { super(type); this.stackCount = stackCount; this.virtualStackCount = 0; @@ -215,7 +237,7 @@ export abstract class PersistentModifier extends Modifier { return true; } - getIcon(forSummary?: boolean): Phaser.GameObjects.Container { + getIcon(_forSummary?: boolean): Phaser.GameObjects.Container { const container = globalScene.add.container(0, 0); const item = globalScene.add.sprite(0, 12, "items"); @@ -253,10 +275,6 @@ export abstract class PersistentModifier extends Modifier { } export abstract class ConsumableModifier extends Modifier { - constructor(type: ModifierType) { - super(type); - } - add(_modifiers: Modifier[]): boolean { return true; } @@ -280,7 +298,10 @@ export class AddPokeballModifier extends ConsumableModifier { */ override apply(): boolean { const pokeballCounts = globalScene.pokeballCounts; - pokeballCounts[this.pokeballType] = Math.min(pokeballCounts[this.pokeballType] + this.count, MAX_PER_TYPE_POKEBALLS); + pokeballCounts[this.pokeballType] = Math.min( + pokeballCounts[this.pokeballType] + this.count, + MAX_PER_TYPE_POKEBALLS, + ); return true; } @@ -418,7 +439,7 @@ export abstract class LapsingPersistentModifier extends PersistentModifier { } getArgs(): any[] { - return [ this.maxBattles, this.battleCount ]; + return [this.maxBattles, this.battleCount]; } getMaxStackCount(_forThreshold?: boolean): number { @@ -436,16 +457,17 @@ export abstract class LapsingPersistentModifier extends PersistentModifier { export class DoubleBattleChanceBoosterModifier extends LapsingPersistentModifier { public override type: DoubleBattleChanceBoosterModifierType; - constructor(type: ModifierType, maxBattles:number, battleCount?: number, stackCount?: number) { - super(type, maxBattles, battleCount, stackCount); - } - match(modifier: Modifier): boolean { - return (modifier instanceof DoubleBattleChanceBoosterModifier) && (modifier.getMaxBattles() === this.getMaxBattles()); + return modifier instanceof DoubleBattleChanceBoosterModifier && modifier.getMaxBattles() === this.getMaxBattles(); } clone(): DoubleBattleChanceBoosterModifier { - return new DoubleBattleChanceBoosterModifier(this.type, this.getMaxBattles(), this.getBattleCount(), this.stackCount); + return new DoubleBattleChanceBoosterModifier( + this.type, + this.getMaxBattles(), + this.getBattleCount(), + this.stackCount, + ); } /** @@ -481,23 +503,29 @@ export class TempStatStageBoosterModifier extends LapsingPersistentModifier { this.stat = stat; // Note that, because we want X Accuracy to maintain its original behavior, // it will increment as it did previously, directly to the stat stage. - this.boost = (stat !== Stat.ACC) ? 0.3 : 1; + this.boost = stat !== Stat.ACC ? 0.3 : 1; } match(modifier: Modifier): boolean { if (modifier instanceof TempStatStageBoosterModifier) { const modifierInstance = modifier as TempStatStageBoosterModifier; - return (modifierInstance.stat === this.stat); + return modifierInstance.stat === this.stat; } return false; } clone() { - return new TempStatStageBoosterModifier(this.type, this.stat, this.getMaxBattles(), this.getBattleCount(), this.stackCount); + return new TempStatStageBoosterModifier( + this.type, + this.stat, + this.getMaxBattles(), + this.getBattleCount(), + this.stackCount, + ); } getArgs(): any[] { - return [ this.stat, ...super.getArgs() ]; + return [this.stat, ...super.getArgs()]; } /** @@ -508,7 +536,9 @@ export class TempStatStageBoosterModifier extends LapsingPersistentModifier { * @returns `true` if the modifier can be applied, false otherwise */ override shouldApply(tempBattleStat?: TempBattleStat, statLevel?: NumberHolder): boolean { - return !!tempBattleStat && !!statLevel && TEMP_BATTLE_STATS.includes(tempBattleStat) && (tempBattleStat === this.stat); + return ( + !!tempBattleStat && !!statLevel && TEMP_BATTLE_STATS.includes(tempBattleStat) && tempBattleStat === this.stat + ); } /** @@ -529,16 +559,12 @@ export class TempStatStageBoosterModifier extends LapsingPersistentModifier { * @see {@linkcode apply} */ export class TempCritBoosterModifier extends LapsingPersistentModifier { - constructor(type: ModifierType, maxBattles: number, battleCount?: number, stackCount?: number) { - super(type, maxBattles, battleCount, stackCount); - } - clone() { return new TempCritBoosterModifier(this.type, this.getMaxBattles(), this.getBattleCount(), this.stackCount); } match(modifier: Modifier): boolean { - return (modifier instanceof TempCritBoosterModifier); + return modifier instanceof TempCritBoosterModifier; } /** @@ -562,10 +588,6 @@ export class TempCritBoosterModifier extends LapsingPersistentModifier { } export class MapModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - clone(): MapModifier { return new MapModifier(this.type, this.stackCount); } @@ -580,10 +602,6 @@ export class MapModifier extends PersistentModifier { } export class MegaEvolutionAccessModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - clone(): MegaEvolutionAccessModifier { return new MegaEvolutionAccessModifier(this.type, this.stackCount); } @@ -598,10 +616,6 @@ export class MegaEvolutionAccessModifier extends PersistentModifier { } export class GigantamaxAccessModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - clone(): GigantamaxAccessModifier { return new GigantamaxAccessModifier(this.type, this.stackCount); } @@ -621,10 +635,6 @@ export class GigantamaxAccessModifier extends PersistentModifier { } export class TerastallizeAccessModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - clone(): TerastallizeAccessModifier { return new TerastallizeAccessModifier(this.type, this.stackCount); } @@ -645,7 +655,7 @@ export class TerastallizeAccessModifier extends PersistentModifier { export abstract class PokemonHeldItemModifier extends PersistentModifier { public pokemonId: number; - public isTransferable: boolean = true; + public isTransferable = true; constructor(type: ModifierType, pokemonId: number, stackCount?: number) { super(type, stackCount); @@ -660,7 +670,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { } getArgs(): any[] { - return [ this.pokemonId ]; + return [this.pokemonId]; } /** @@ -681,7 +691,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { } isIconVisible(): boolean { - return !!(this.getPokemon()?.isOnField()); + return !!this.getPokemon()?.isOnField(); } getIcon(forSummary?: boolean): Phaser.GameObjects.Container { @@ -718,7 +728,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { } getPokemon(): Pokemon | undefined { - return this.pokemonId ? globalScene.getPokemonById(this.pokemonId) ?? undefined : undefined; + return this.pokemonId ? (globalScene.getPokemonById(this.pokemonId) ?? undefined) : undefined; } getScoreMultiplier(): number { @@ -731,7 +741,10 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { return 0; } if (pokemon.isPlayer() && forThreshold) { - return globalScene.getPlayerParty().map(p => this.getMaxHeldItemCount(p)).reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0); + return globalScene + .getPlayerParty() + .map(p => this.getMaxHeldItemCount(p)) + .reduce((stackCount: number, maxStackCount: number) => Math.max(stackCount, maxStackCount), 0); } return this.getMaxHeldItemCount(pokemon); } @@ -741,7 +754,7 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModifier { protected battlesLeft: number; - public isTransferable: boolean = false; + public isTransferable = false; constructor(type: ModifierType, pokemonId: number, battlesLeft?: number, stackCount?: number) { super(type, pokemonId, stackCount); @@ -767,7 +780,10 @@ export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModi const container = super.getIcon(forSummary); if (this.getPokemon()?.isPlayer()) { - const battleCountText = addTextObject(27, 0, this.battlesLeft.toString(), TextStyle.PARTY, { fontSize: "66px", color: Color.PINK }); + const battleCountText = addTextObject(27, 0, this.battlesLeft.toString(), TextStyle.PARTY, { + fontSize: "66px", + color: Color.PINK, + }); battleCountText.setShadow(0, 0); battleCountText.setStroke(ShadowColor.RED, 16); battleCountText.setOrigin(1, 0); @@ -781,7 +797,7 @@ export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModi return this.battlesLeft; } - getMaxStackCount(forThreshold?: boolean): number { + getMaxStackCount(_forThreshold?: boolean): number { return 1; } } @@ -794,7 +810,7 @@ export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModi */ export class BaseStatModifier extends PokemonHeldItemModifier { protected stat: PermanentStat; - public isTransferable: boolean = false; + public isTransferable = false; constructor(type: ModifierType, pokemonId: number, stat: PermanentStat, stackCount?: number) { super(type, pokemonId, stackCount); @@ -849,7 +865,7 @@ export class BaseStatModifier extends PokemonHeldItemModifier { export class EvoTrackerModifier extends PokemonHeldItemModifier { protected species: Species; protected required: number; - public isTransferable: boolean = false; + public isTransferable = false; constructor(type: ModifierType, pokemonId: number, species: Species, required: number, stackCount?: number) { super(type, pokemonId, stackCount); @@ -858,7 +874,9 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier { } matchType(modifier: Modifier): boolean { - return modifier instanceof EvoTrackerModifier && modifier.species === this.species && modifier.required === this.required; + return ( + modifier instanceof EvoTrackerModifier && modifier.species === this.species && modifier.required === this.required + ); } clone(): PersistentModifier { @@ -866,7 +884,7 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier { } getArgs(): any[] { - return super.getArgs().concat([ this.species, this.required ]); + return super.getArgs().concat([this.species, this.required]); } /** @@ -885,8 +903,14 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier { const pokemon = globalScene.getPokemonById(this.pokemonId); this.stackCount = pokemon - ? pokemon.evoCounter + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length - + globalScene.findModifiers(m => m instanceof MoneyMultiplierModifier || m instanceof ExtraModifierModifier || m instanceof TempExtraModifierModifier).length + ? pokemon.evoCounter + + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length + + globalScene.findModifiers( + m => + m instanceof MoneyMultiplierModifier || + m instanceof ExtraModifierModifier || + m instanceof TempExtraModifierModifier, + ).length : this.stackCount; const text = globalScene.add.bitmapText(10, 15, "item-count", this.stackCount.toString(), 11); @@ -900,8 +924,15 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier { } getMaxHeldItemCount(pokemon: Pokemon): number { - this.stackCount = pokemon.evoCounter + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length - + globalScene.findModifiers(m => m instanceof MoneyMultiplierModifier || m instanceof ExtraModifierModifier || m instanceof TempExtraModifierModifier).length; + this.stackCount = + pokemon.evoCounter + + pokemon.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length + + globalScene.findModifiers( + m => + m instanceof MoneyMultiplierModifier || + m instanceof ExtraModifierModifier || + m instanceof TempExtraModifierModifier, + ).length; return 999; } } @@ -911,7 +942,7 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier { */ export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier { public override type: PokemonBaseStatTotalModifierType; - public isTransferable: boolean = false; + public isTransferable = false; private statModifier: number; @@ -963,7 +994,7 @@ export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier { return 1.2; } - override getMaxHeldItemCount(pokemon: Pokemon): number { + override getMaxHeldItemCount(_pokemon: Pokemon): number { return 2; } } @@ -974,9 +1005,9 @@ export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier { export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier { private statModifier: number; private stats: Stat[]; - public isTransferable: boolean = false; + public isTransferable = false; - constructor (type: ModifierType, pokemonId: number, statModifier: number, stats: Stat[], stackCount?: number) { + constructor(type: ModifierType, pokemonId: number, statModifier: number, stats: Stat[], stackCount?: number) { super(type, pokemonId, stackCount); this.statModifier = statModifier; @@ -984,7 +1015,11 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier { } override matchType(modifier: Modifier): boolean { - return modifier instanceof PokemonBaseStatFlatModifier && modifier.statModifier === this.statModifier && this.stats.every(s => modifier.stats.some(stat => s === stat)); + return ( + modifier instanceof PokemonBaseStatFlatModifier && + modifier.statModifier === this.statModifier && + this.stats.every(s => modifier.stats.some(stat => s === stat)) + ); } override clone(): PersistentModifier { @@ -992,7 +1027,7 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier { } override getArgs(): any[] { - return [ ...super.getArgs(), this.statModifier, this.stats ]; + return [...super.getArgs(), this.statModifier, this.stats]; } /** @@ -1027,7 +1062,7 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier { return 1.1; } - override getMaxHeldItemCount(pokemon: Pokemon): number { + override getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } } @@ -1036,11 +1071,7 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier { * Currently used by Macho Brace item */ export class PokemonIncrementingStatModifier extends PokemonHeldItemModifier { - public isTransferable: boolean = false; - - constructor (type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } + public isTransferable = false; matchType(modifier: Modifier): boolean { return modifier instanceof PokemonIncrementingStatModifier; @@ -1096,7 +1127,7 @@ export class PokemonIncrementingStatModifier extends PokemonHeldItemModifier { return 1.2; } - getMaxHeldItemCount(pokemon?: Pokemon): number { + getMaxHeldItemCount(_pokemon?: Pokemon): number { return 50; } } @@ -1125,13 +1156,13 @@ export class StatBoosterModifier extends PokemonHeldItemModifier { } getArgs(): any[] { - return [ ...super.getArgs(), this.stats, this.multiplier ]; + return [...super.getArgs(), this.stats, this.multiplier]; } matchType(modifier: Modifier): boolean { if (modifier instanceof StatBoosterModifier) { const modifierInstance = modifier as StatBoosterModifier; - if ((modifierInstance.multiplier === this.multiplier) && (modifierInstance.stats.length === this.stats.length)) { + if (modifierInstance.multiplier === this.multiplier && modifierInstance.stats.length === this.stats.length) { return modifierInstance.stats.every((e, i) => e === this.stats[i]); } } @@ -1211,11 +1242,12 @@ export class EvolutionStatBoosterModifier extends StatBoosterModifier { override apply(pokemon: Pokemon, stat: Stat, statValue: NumberHolder): boolean { const isUnevolved = pokemon.getSpeciesForm(true).speciesId in pokemonEvolutions; - if (pokemon.isFusion() && (pokemon.getFusionSpeciesForm(true).speciesId in pokemonEvolutions) !== isUnevolved) { + if (pokemon.isFusion() && pokemon.getFusionSpeciesForm(true).speciesId in pokemonEvolutions !== isUnevolved) { // Half boost applied if pokemon is fused and either part of fusion is fully evolved statValue.value *= 1 + (this.multiplier - 1) / 2; return true; - } else if (isUnevolved) { + } + if (isUnevolved) { // Full boost applied if holder is unfused and unevolved or, if fused, both parts of fusion are unevolved return super.apply(pokemon, stat, statValue); } @@ -1234,18 +1266,32 @@ export class SpeciesStatBoosterModifier extends StatBoosterModifier { /** The species that the held item's stat boost(s) apply to */ private species: Species[]; - constructor(type: ModifierType, pokemonId: number, stats: Stat[], multiplier: number, species: Species[], stackCount?: number) { + constructor( + type: ModifierType, + pokemonId: number, + stats: Stat[], + multiplier: number, + species: Species[], + stackCount?: number, + ) { super(type, pokemonId, stats, multiplier, stackCount); this.species = species; } clone() { - return new SpeciesStatBoosterModifier(this.type, this.pokemonId, this.stats, this.multiplier, this.species, this.stackCount); + return new SpeciesStatBoosterModifier( + this.type, + this.pokemonId, + this.stats, + this.multiplier, + this.species, + this.stackCount, + ); } getArgs(): any[] { - return [ ...super.getArgs(), this.species ]; + return [...super.getArgs(), this.species]; } matchType(modifier: Modifier): boolean { @@ -1268,7 +1314,11 @@ export class SpeciesStatBoosterModifier extends StatBoosterModifier { * @returns `true` if the stat could be boosted, false otherwise */ override shouldApply(pokemon: Pokemon, stat: Stat, statValue: NumberHolder): boolean { - return super.shouldApply(pokemon, stat, statValue) && (this.species.includes(pokemon.getSpeciesForm(true).speciesId) || (pokemon.isFusion() && this.species.includes(pokemon.getFusionSpeciesForm(true).speciesId))); + return ( + super.shouldApply(pokemon, stat, statValue) && + (this.species.includes(pokemon.getSpeciesForm(true).speciesId) || + (pokemon.isFusion() && this.species.includes(pokemon.getFusionSpeciesForm(true).speciesId))) + ); } /** @@ -1346,11 +1396,17 @@ export class SpeciesCritBoosterModifier extends CritBoosterModifier { } clone() { - return new SpeciesCritBoosterModifier(this.type, this.pokemonId, this.stageIncrement, this.species, this.stackCount); + return new SpeciesCritBoosterModifier( + this.type, + this.pokemonId, + this.stageIncrement, + this.species, + this.stackCount, + ); } getArgs(): any[] { - return [ ...super.getArgs(), this.species ]; + return [...super.getArgs(), this.species]; } matchType(modifier: Modifier): boolean { @@ -1365,7 +1421,11 @@ export class SpeciesCritBoosterModifier extends CritBoosterModifier { * @returns `true` if the critical-hit level can be incremented, false otherwise */ override shouldApply(pokemon: Pokemon, critStage: NumberHolder): boolean { - return super.shouldApply(pokemon, critStage) && (this.species.includes(pokemon.getSpeciesForm(true).speciesId) || (pokemon.isFusion() && this.species.includes(pokemon.getFusionSpeciesForm(true).speciesId))); + return ( + super.shouldApply(pokemon, critStage) && + (this.species.includes(pokemon.getSpeciesForm(true).speciesId) || + (pokemon.isFusion() && this.species.includes(pokemon.getFusionSpeciesForm(true).speciesId))) + ); } } @@ -1386,18 +1446,27 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { matchType(modifier: Modifier): boolean { if (modifier instanceof AttackTypeBoosterModifier) { const attackTypeBoosterModifier = modifier as AttackTypeBoosterModifier; - return attackTypeBoosterModifier.moveType === this.moveType && attackTypeBoosterModifier.boostMultiplier === this.boostMultiplier; + return ( + attackTypeBoosterModifier.moveType === this.moveType && + attackTypeBoosterModifier.boostMultiplier === this.boostMultiplier + ); } return false; } clone() { - return new AttackTypeBoosterModifier(this.type, this.pokemonId, this.moveType, this.boostMultiplier * 100, this.stackCount); + return new AttackTypeBoosterModifier( + this.type, + this.pokemonId, + this.moveType, + this.boostMultiplier * 100, + this.stackCount, + ); } getArgs(): any[] { - return super.getArgs().concat([ this.moveType, this.boostMultiplier * 100 ]); + return super.getArgs().concat([this.moveType, this.boostMultiplier * 100]); } /** @@ -1408,7 +1477,11 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { * @returns `true` if boosts should be applied to the move. */ override shouldApply(pokemon?: Pokemon, moveType?: PokemonType, movePower?: NumberHolder): boolean { - return super.shouldApply(pokemon, moveType, movePower) && typeof moveType === "number" && movePower instanceof NumberHolder; + return ( + super.shouldApply(pokemon, moveType, movePower) && + typeof moveType === "number" && + movePower instanceof NumberHolder + ); } /** @@ -1420,7 +1493,9 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { */ override apply(_pokemon: Pokemon, moveType: PokemonType, movePower: NumberHolder): boolean { if (moveType === this.moveType && movePower.value >= 1) { - (movePower as NumberHolder).value = Math.floor((movePower as NumberHolder).value * (1 + (this.getStackCount() * this.boostMultiplier))); + (movePower as NumberHolder).value = Math.floor( + (movePower as NumberHolder).value * (1 + this.getStackCount() * this.boostMultiplier), + ); return true; } @@ -1431,16 +1506,12 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier { return 1.2; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 99; } } export class SurviveDamageModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof SurviveDamageModifier; } @@ -1469,23 +1540,24 @@ export class SurviveDamageModifier extends PokemonHeldItemModifier { if (!surviveDamage.value && pokemon.randSeedInt(10) < this.getStackCount()) { surviveDamage.value = true; - globalScene.queueMessage(i18next.t("modifier:surviveDamageApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name })); + globalScene.queueMessage( + i18next.t("modifier:surviveDamageApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }), + ); return true; } return false; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 5; } } export class BypassSpeedChanceModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier) { return modifier instanceof BypassSpeedChanceModifier; } @@ -1513,11 +1585,17 @@ export class BypassSpeedChanceModifier extends PokemonHeldItemModifier { override apply(pokemon: Pokemon, doBypassSpeed: BooleanHolder): boolean { if (!doBypassSpeed.value && pokemon.randSeedInt(10) < this.getStackCount()) { doBypassSpeed.value = true; - const isCommandFight = globalScene.currentBattle.turnCommands[pokemon.getBattlerIndex()]?.command === Command.FIGHT; + const isCommandFight = + globalScene.currentBattle.turnCommands[pokemon.getBattlerIndex()]?.command === Command.FIGHT; const hasQuickClaw = this.type instanceof PokemonHeldItemModifierType && this.type.id === "QUICK_CLAW"; if (isCommandFight && hasQuickClaw) { - globalScene.queueMessage(i18next.t("modifier:bypassSpeedChanceApply", { pokemonName: getPokemonNameWithAffix(pokemon), itemName: i18next.t("modifierType:ModifierType.QUICK_CLAW.name") })); + globalScene.queueMessage( + i18next.t("modifier:bypassSpeedChanceApply", { + pokemonName: getPokemonNameWithAffix(pokemon), + itemName: i18next.t("modifierType:ModifierType.QUICK_CLAW.name"), + }), + ); } return true; } @@ -1525,7 +1603,7 @@ export class BypassSpeedChanceModifier extends PokemonHeldItemModifier { return false; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 3; } } @@ -1568,7 +1646,7 @@ export class FlinchChanceModifier extends PokemonHeldItemModifier { */ override apply(pokemon: Pokemon, flinched: BooleanHolder): boolean { // The check for pokemon.battleSummonData is to ensure that a crash doesn't occur when a Pokemon with King's Rock procs a flinch - if (pokemon.battleSummonData && !flinched.value && pokemon.randSeedInt(100) < (this.getStackCount() * this.chance)) { + if (pokemon.battleSummonData && !flinched.value && pokemon.randSeedInt(100) < this.getStackCount() * this.chance) { flinched.value = true; return true; } @@ -1582,10 +1660,6 @@ export class FlinchChanceModifier extends PokemonHeldItemModifier { } export class TurnHealModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier) { return modifier instanceof TurnHealModifier; } @@ -1601,15 +1675,24 @@ export class TurnHealModifier extends PokemonHeldItemModifier { */ override apply(pokemon: Pokemon): boolean { if (!pokemon.isFullHp()) { - globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), - toDmgValue(pokemon.getMaxHp() / 16) * this.stackCount, i18next.t("modifier:turnHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + pokemon.getBattlerIndex(), + toDmgValue(pokemon.getMaxHp() / 16) * this.stackCount, + i18next.t("modifier:turnHealApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }), + true, + ), + ); return true; } return false; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 4; } } @@ -1624,7 +1707,7 @@ export class TurnStatusEffectModifier extends PokemonHeldItemModifier { /** The status effect to be applied by the held item */ private effect: StatusEffect; - constructor (type: ModifierType, pokemonId: number, stackCount?: number) { + constructor(type: ModifierType, pokemonId: number, stackCount?: number) { super(type, pokemonId, stackCount); switch (type.id) { @@ -1664,7 +1747,7 @@ export class TurnStatusEffectModifier extends PokemonHeldItemModifier { return pokemon.trySetStatus(this.effect, true, undefined, undefined, this.type.name); } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } @@ -1674,10 +1757,6 @@ export class TurnStatusEffectModifier extends PokemonHeldItemModifier { } export class HitHealModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier) { return modifier instanceof HitHealModifier; } @@ -1693,23 +1772,28 @@ export class HitHealModifier extends PokemonHeldItemModifier { */ override apply(pokemon: Pokemon): boolean { if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) { - globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), - toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + pokemon.getBattlerIndex(), + toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, + i18next.t("modifier:hitHealApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }), + true, + ), + ); } return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 4; } } export class LevelIncrementBoosterModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier) { return modifier instanceof LevelIncrementBoosterModifier; } @@ -1738,7 +1822,7 @@ export class LevelIncrementBoosterModifier extends PersistentModifier { return true; } - getMaxStackCount(forThreshold?: boolean): number { + getMaxStackCount(_forThreshold?: boolean): number { return 99; } } @@ -1792,8 +1876,8 @@ export class BerryModifier extends PokemonHeldItemModifier { return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { - if ([ BerryType.LUM, BerryType.LEPPA, BerryType.SITRUS, BerryType.ENIGMA ].includes(this.berryType)) { + getMaxHeldItemCount(_pokemon: Pokemon): number { + if ([BerryType.LUM, BerryType.LEPPA, BerryType.SITRUS, BerryType.ENIGMA].includes(this.berryType)) { return 2; } return 3; @@ -1801,10 +1885,6 @@ export class BerryModifier extends PokemonHeldItemModifier { } export class PreserveBerryModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier) { return modifier instanceof PreserveBerryModifier; } @@ -1843,10 +1923,6 @@ export class PreserveBerryModifier extends PersistentModifier { } export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier) { return modifier instanceof PokemonInstantReviveModifier; } @@ -1862,19 +1938,32 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { */ override apply(pokemon: Pokemon): boolean { // Restore the Pokemon to half HP - globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), - toDmgValue(pokemon.getMaxHp() / 2), i18next.t("modifier:pokemonInstantReviveApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), false, false, true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + pokemon.getBattlerIndex(), + toDmgValue(pokemon.getMaxHp() / 2), + i18next.t("modifier:pokemonInstantReviveApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }), + false, + false, + true, + ), + ); // Remove the Pokemon's FAINT status pokemon.resetStatus(true, false, true); // Reapply Commander on the Pokemon's side of the field, if applicable const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); - field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false)); + for (const p of field) { + applyAbAttrs(CommanderAbAttr, p, null, false); + } return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } } @@ -1886,10 +1975,6 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { * @see {@linkcode apply} */ export class ResetNegativeStatStageModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier) { return modifier instanceof ResetNegativeStatStageModifier; } @@ -1915,7 +2000,12 @@ export class ResetNegativeStatStageModifier extends PokemonHeldItemModifier { } if (statRestored) { - globalScene.queueMessage(i18next.t("modifier:resetNegativeStatStageApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name })); + globalScene.queueMessage( + i18next.t("modifier:resetNegativeStatStageApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }), + ); } return statRestored; } @@ -1972,7 +2062,12 @@ export class TerrastalizeModifier extends ConsumablePokemonModifier { * @returns `true` if the {@linkcode TerrastalizeModifier} should be applied */ override shouldApply(playerPokemon?: PlayerPokemon): boolean { - return super.shouldApply(playerPokemon) && [ playerPokemon?.species.speciesId, playerPokemon?.fusionSpecies?.speciesId ].filter(s => s === Species.TERAPAGOS || s === Species.OGERPON || s === Species.SHEDINJA).length === 0; + return ( + super.shouldApply(playerPokemon) && + [playerPokemon?.species.speciesId, playerPokemon?.fusionSpecies?.speciesId].filter( + s => s === Species.TERAPAGOS || s === Species.OGERPON || s === Species.SHEDINJA, + ).length === 0 + ); } /** @@ -1992,7 +2087,14 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { private healStatus: boolean; public fainted: boolean; - constructor(type: ModifierType, pokemonId: number, restorePoints: number, restorePercent: number, healStatus: boolean, fainted?: boolean) { + constructor( + type: ModifierType, + pokemonId: number, + restorePoints: number, + restorePercent: number, + healStatus: boolean, + fainted?: boolean, + ) { super(type, pokemonId); this.restorePoints = restorePoints; @@ -2008,7 +2110,10 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { * @returns `true` if the {@linkcode PokemonHpRestoreModifier} should be applied */ override shouldApply(playerPokemon?: PlayerPokemon, multiplier?: number): boolean { - return super.shouldApply(playerPokemon) && (this.fainted || (!isNullOrUndefined(multiplier) && typeof(multiplier) === "number")); + return ( + super.shouldApply(playerPokemon) && + (this.fainted || (!isNullOrUndefined(multiplier) && typeof multiplier === "number")) + ); } /** @@ -2026,7 +2131,11 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { if (this.fainted || this.healStatus) { pokemon.resetStatus(true, true); } - pokemon.hp = Math.min(pokemon.hp + Math.max(Math.ceil(Math.max(Math.floor((this.restorePercent * 0.01) * pokemon.getMaxHp()), restorePoints)), 1), pokemon.getMaxHp()); + pokemon.hp = Math.min( + pokemon.hp + + Math.max(Math.ceil(Math.max(Math.floor(this.restorePercent * 0.01 * pokemon.getMaxHp()), restorePoints)), 1), + pokemon.getMaxHp(), + ); return true; } return false; @@ -2034,10 +2143,6 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { } export class PokemonStatusHealModifier extends ConsumablePokemonModifier { - constructor(type: ModifierType, pokemonId: number) { - super(type, pokemonId); - } - /** * Applies {@linkcode PokemonStatusHealModifier} * @param playerPokemon The {@linkcode PlayerPokemon} that gets healed from the status @@ -2157,10 +2262,6 @@ export class PokemonNatureChangeModifier extends ConsumablePokemonModifier { } export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier { - constructor(type: ModifierType, pokemonId: number) { - super(type, pokemonId); - } - /** * Applies {@linkcode PokemonLevelIncrementModifier} * @param playerPokemon The {@linkcode PlayerPokemon} that should get levels incremented @@ -2178,7 +2279,13 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier { playerPokemon.addFriendship(FRIENDSHIP_GAIN_FROM_RARE_CANDY); - globalScene.unshiftPhase(new LevelUpPhase(globalScene.getPlayerParty().indexOf(playerPokemon), playerPokemon.level - levelCount.value, playerPokemon.level)); + globalScene.unshiftPhase( + new LevelUpPhase( + globalScene.getPlayerParty().indexOf(playerPokemon), + playerPokemon.level - levelCount.value, + playerPokemon.level, + ), + ); return true; } @@ -2187,18 +2294,15 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier { export class TmModifier extends ConsumablePokemonModifier { public override type: TmModifierType; - constructor(type: TmModifierType, pokemonId: number) { - super(type, pokemonId); - } - /** * Applies {@linkcode TmModifier} * @param playerPokemon The {@linkcode PlayerPokemon} that should learn the TM * @returns always `true` */ override apply(playerPokemon: PlayerPokemon): boolean { - - globalScene.unshiftPhase(new LearnMovePhase(globalScene.getPlayerParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM)); + globalScene.unshiftPhase( + new LearnMovePhase(globalScene.getPlayerParty().indexOf(playerPokemon), this.type.moveId, LearnMoveType.TM), + ); return true; } @@ -2219,8 +2323,14 @@ export class RememberMoveModifier extends ConsumablePokemonModifier { * @returns always `true` */ override apply(playerPokemon: PlayerPokemon, cost?: number): boolean { - - globalScene.unshiftPhase(new LearnMovePhase(globalScene.getPlayerParty().indexOf(playerPokemon), playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], LearnMoveType.MEMORY, cost)); + globalScene.unshiftPhase( + new LearnMovePhase( + globalScene.getPlayerParty().indexOf(playerPokemon), + playerPokemon.getLearnableLevelMoves()[this.levelMoveIndex], + LearnMoveType.MEMORY, + cost, + ), + ); return true; } @@ -2228,11 +2338,6 @@ export class RememberMoveModifier extends ConsumablePokemonModifier { export class EvolutionItemModifier extends ConsumablePokemonModifier { public override type: EvolutionItemModifierType; - - constructor(type: EvolutionItemModifierType, pokemonId: number) { - super(type, pokemonId); - } - /** * Applies {@linkcode EvolutionItemModifier} * @param playerPokemon The {@linkcode PlayerPokemon} that should evolve via item @@ -2240,15 +2345,21 @@ export class EvolutionItemModifier extends ConsumablePokemonModifier { */ override apply(playerPokemon: PlayerPokemon): boolean { let matchingEvolution = pokemonEvolutions.hasOwnProperty(playerPokemon.species.speciesId) - ? pokemonEvolutions[playerPokemon.species.speciesId].find(e => e.item === this.type.evolutionItem - && (e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFormKey()) - && (!e.condition || e.condition.predicate(playerPokemon))) + ? pokemonEvolutions[playerPokemon.species.speciesId].find( + e => + e.item === this.type.evolutionItem && + (e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFormKey()) && + (!e.condition || e.condition.predicate(playerPokemon)), + ) : null; if (!matchingEvolution && playerPokemon.isFusion()) { - matchingEvolution = pokemonEvolutions[playerPokemon.fusionSpecies!.speciesId].find(e => e.item === this.type.evolutionItem // TODO: is the bang correct? - && (e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFusionFormKey()) - && (!e.condition || e.condition.predicate(playerPokemon))); + matchingEvolution = pokemonEvolutions[playerPokemon.fusionSpecies!.speciesId].find( + e => + e.item === this.type.evolutionItem && // TODO: is the bang correct? + (e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFusionFormKey()) && + (!e.condition || e.condition.predicate(playerPokemon)), + ); if (matchingEvolution) { matchingEvolution = new FusionSpeciesFormEvolution(playerPokemon.species.speciesId, matchingEvolution); } @@ -2279,7 +2390,9 @@ export class FusePokemonModifier extends ConsumablePokemonModifier { * @returns `true` if {@linkcode FusePokemonModifier} should be applied */ override shouldApply(playerPokemon?: PlayerPokemon, playerPokemon2?: PlayerPokemon): boolean { - return super.shouldApply(playerPokemon, playerPokemon2) && !!playerPokemon2 && this.fusePokemonId === playerPokemon2.id; + return ( + super.shouldApply(playerPokemon, playerPokemon2) && !!playerPokemon2 && this.fusePokemonId === playerPokemon2.id + ); } /** @@ -2295,10 +2408,6 @@ export class FusePokemonModifier extends ConsumablePokemonModifier { } export class MultipleParticipantExpBonusModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof MultipleParticipantExpBonusModifier; } @@ -2338,7 +2447,7 @@ export class HealingBoosterModifier extends PersistentModifier { } getArgs(): any[] { - return [ this.multiplier ]; + return [this.multiplier]; } /** @@ -2347,7 +2456,7 @@ export class HealingBoosterModifier extends PersistentModifier { * @returns always `true` */ override apply(healingMultiplier: NumberHolder): boolean { - healingMultiplier.value *= 1 + ((this.multiplier - 1) * this.getStackCount()); + healingMultiplier.value *= 1 + (this.multiplier - 1) * this.getStackCount(); return true; } @@ -2379,7 +2488,7 @@ export class ExpBoosterModifier extends PersistentModifier { } getArgs(): any[] { - return [ this.boostMultiplier * 100 ]; + return [this.boostMultiplier * 100]; } /** @@ -2388,13 +2497,13 @@ export class ExpBoosterModifier extends PersistentModifier { * @returns always `true` */ override apply(boost: NumberHolder): boolean { - boost.value = Math.floor(boost.value * (1 + (this.getStackCount() * this.boostMultiplier))); + boost.value = Math.floor(boost.value * (1 + this.getStackCount() * this.boostMultiplier)); return true; } - getMaxStackCount(forThreshold?: boolean): number { - return this.boostMultiplier < 1 ? this.boostMultiplier < 0.6 ? 99 : 30 : 10; + getMaxStackCount(_forThreshold?: boolean): number { + return this.boostMultiplier < 1 ? (this.boostMultiplier < 0.6 ? 99 : 30) : 10; } } @@ -2441,21 +2550,17 @@ export class PokemonExpBoosterModifier extends PokemonHeldItemModifier { * @returns always `true` */ override apply(_pokemon: Pokemon, boost: NumberHolder): boolean { - boost.value = Math.floor(boost.value * (1 + (this.getStackCount() * this.boostMultiplier))); + boost.value = Math.floor(boost.value * (1 + this.getStackCount() * this.boostMultiplier)); return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 99; } } export class ExpShareModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof ExpShareModifier; } @@ -2478,10 +2583,6 @@ export class ExpShareModifier extends PersistentModifier { } export class ExpBalanceModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof ExpBalanceModifier; } @@ -2506,10 +2607,6 @@ export class ExpBalanceModifier extends PersistentModifier { export class PokemonFriendshipBoosterModifier extends PokemonHeldItemModifier { public override type: PokemonFriendshipBoosterModifierType; - constructor(type: PokemonFriendshipBoosterModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof PokemonFriendshipBoosterModifier; } @@ -2530,16 +2627,12 @@ export class PokemonFriendshipBoosterModifier extends PokemonHeldItemModifier { return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 3; } } export class PokemonNatureWeightModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof PokemonNatureWeightModifier; } @@ -2563,7 +2656,7 @@ export class PokemonNatureWeightModifier extends PokemonHeldItemModifier { return false; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 10; } } @@ -2615,7 +2708,7 @@ export class PokemonMoveAccuracyBoosterModifier extends PokemonHeldItemModifier return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 3; } } @@ -2623,10 +2716,6 @@ export class PokemonMoveAccuracyBoosterModifier extends PokemonHeldItemModifier export class PokemonMultiHitModifier extends PokemonHeldItemModifier { public override type: PokemonMultiHitModifierType; - constructor(type: PokemonMultiHitModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof PokemonMultiHitModifier; } @@ -2643,7 +2732,12 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier { * @param damageMultiplier {@linkcode NumberHolder} holding a damage multiplier applied to a strike of this move * @returns always `true` */ - override apply(pokemon: Pokemon, moveId: Moves, count: NumberHolder | null = null, damageMultiplier: NumberHolder | null = null): boolean { + override apply( + pokemon: Pokemon, + moveId: Moves, + count: NumberHolder | null = null, + damageMultiplier: NumberHolder | null = null, + ): boolean { const move = allMoves[moveId]; /** * The move must meet Parental Bond's restrictions for this item @@ -2660,7 +2754,8 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier { if (!isNullOrUndefined(count)) { return this.applyHitCountBoost(count); - } else if (!isNullOrUndefined(damageMultiplier)) { + } + if (!isNullOrUndefined(damageMultiplier)) { return this.applyDamageModifier(pokemon, damageMultiplier); } @@ -2683,17 +2778,17 @@ export class PokemonMultiHitModifier extends PokemonHeldItemModifier { // Reduce first hit by 25% for each stack count damageMultiplier.value *= 1 - 0.25 * this.getStackCount(); return true; - } else if (pokemon.turnData.hitCount - pokemon.turnData.hitsLeft !== this.getStackCount() + 1) { + } + if (pokemon.turnData.hitCount - pokemon.turnData.hitsLeft !== this.getStackCount() + 1) { // Deal 25% damage for each remaining Multi Lens hit damageMultiplier.value *= 0.25; return true; - } else { - // An extra hit not caused by Multi Lens -- assume it is Parental Bond - return false; } + // An extra hit not caused by Multi Lens -- assume it is Parental Bond + return false; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 2; } } @@ -2702,9 +2797,15 @@ export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier { public override type: FormChangeItemModifierType; public formChangeItem: FormChangeItem; public active: boolean; - public isTransferable: boolean = false; + public isTransferable = false; - constructor(type: FormChangeItemModifierType, pokemonId: number, formChangeItem: FormChangeItem, active: boolean, stackCount?: number) { + constructor( + type: FormChangeItemModifierType, + pokemonId: number, + formChangeItem: FormChangeItem, + active: boolean, + stackCount?: number, + ) { super(type, pokemonId, stackCount); this.formChangeItem = formChangeItem; this.active = active; @@ -2715,7 +2816,13 @@ export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier { } clone(): PersistentModifier { - return new PokemonFormChangeItemModifier(this.type, this.pokemonId, this.formChangeItem, this.active, this.stackCount); + return new PokemonFormChangeItemModifier( + this.type, + this.pokemonId, + this.formChangeItem, + this.active, + this.stackCount, + ); } getArgs(): any[] { @@ -2744,7 +2851,7 @@ export class PokemonFormChangeItemModifier extends PokemonHeldItemModifier { return ret; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } } @@ -2771,8 +2878,12 @@ export class MoneyRewardModifier extends ConsumableModifier { globalScene.getPlayerParty().map(p => { if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) { - p.evoCounter ? p.evoCounter += Math.min(Math.floor(this.moneyMultiplier), 3) : p.evoCounter = Math.min(Math.floor(this.moneyMultiplier), 3); - const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier; + p.evoCounter + ? (p.evoCounter += Math.min(Math.floor(this.moneyMultiplier), 3)) + : (p.evoCounter = Math.min(Math.floor(this.moneyMultiplier), 3)); + const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier( + p, + ) as EvoTrackerModifier; globalScene.addModifier(modifier); } }); @@ -2782,10 +2893,6 @@ export class MoneyRewardModifier extends ConsumableModifier { } export class MoneyMultiplierModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof MoneyMultiplierModifier; } @@ -2811,10 +2918,6 @@ export class MoneyMultiplierModifier extends PersistentModifier { } export class DamageMoneyRewardModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof DamageMoneyRewardModifier; } @@ -2829,7 +2932,7 @@ export class DamageMoneyRewardModifier extends PokemonHeldItemModifier { * @param multiplier {@linkcode NumberHolder} holding the multiplier value * @returns always `true` */ - override apply(pokemon: Pokemon, multiplier: NumberHolder): boolean { + override apply(_pokemon: Pokemon, multiplier: NumberHolder): boolean { const moneyAmount = new NumberHolder(Math.floor(multiplier.value * (0.5 * this.getStackCount()))); globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); globalScene.addMoney(moneyAmount.value); @@ -2837,16 +2940,12 @@ export class DamageMoneyRewardModifier extends PokemonHeldItemModifier { return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 5; } } export class MoneyInterestModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof MoneyInterestModifier; } @@ -2861,7 +2960,10 @@ export class MoneyInterestModifier extends PersistentModifier { const userLocale = navigator.language || "en-US"; const formattedMoneyAmount = interestAmount.toLocaleString(userLocale); - const message = i18next.t("modifier:moneyInterestApply", { moneyAmount: formattedMoneyAmount, typeName: this.type.name }); + const message = i18next.t("modifier:moneyInterestApply", { + moneyAmount: formattedMoneyAmount, + typeName: this.type.name, + }); globalScene.queueMessage(message, undefined, true); return true; @@ -2877,10 +2979,6 @@ export class MoneyInterestModifier extends PersistentModifier { } export class HiddenAbilityRateBoosterModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof HiddenAbilityRateBoosterModifier; } @@ -2906,10 +3004,6 @@ export class HiddenAbilityRateBoosterModifier extends PersistentModifier { } export class ShinyRateBoosterModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof ShinyRateBoosterModifier; } @@ -2935,10 +3029,6 @@ export class ShinyRateBoosterModifier extends PersistentModifier { } export class CriticalCatchChanceBoosterModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof CriticalCatchChanceBoosterModifier; } @@ -2967,10 +3057,6 @@ export class CriticalCatchChanceBoosterModifier extends PersistentModifier { } export class LockModifierTiersModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof LockModifierTiersModifier; } @@ -3033,10 +3119,6 @@ export class HealShopCostModifier extends PersistentModifier { } export class BoostBugSpawnModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof BoostBugSpawnModifier; } @@ -3059,10 +3141,6 @@ export class BoostBugSpawnModifier extends PersistentModifier { } export class SwitchEffectTransferModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - matchType(modifier: Modifier): boolean { return modifier instanceof SwitchEffectTransferModifier; } @@ -3079,7 +3157,7 @@ export class SwitchEffectTransferModifier extends PokemonHeldItemModifier { return true; } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } } @@ -3090,10 +3168,6 @@ export class SwitchEffectTransferModifier extends PokemonHeldItemModifier { * @see {@linkcode ContactHeldItemTransferChanceModifier} */ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } - /** * Determines the targets to transfer items from when this applies. * @param pokemon the {@linkcode Pokemon} holding this item @@ -3101,9 +3175,7 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { * @returns the opponents of the source {@linkcode Pokemon} */ getTargets(pokemon?: Pokemon, ..._args: unknown[]): Pokemon[] { - return pokemon instanceof Pokemon - ? pokemon.getOpponents() - : []; + return pokemon instanceof Pokemon ? pokemon.getOpponents() : []; } /** @@ -3128,12 +3200,20 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { return false; } - const poolType = pokemon.isPlayer() ? ModifierPoolType.PLAYER : pokemon.hasTrainer() ? ModifierPoolType.TRAINER : ModifierPoolType.WILD; + const poolType = pokemon.isPlayer() + ? ModifierPoolType.PLAYER + : pokemon.hasTrainer() + ? ModifierPoolType.TRAINER + : ModifierPoolType.WILD; const transferredModifierTypes: ModifierType[] = []; - const itemModifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === targetPokemon.id && m.isTransferable, targetPokemon.isPlayer()) as PokemonHeldItemModifier[]; - let highestItemTier = itemModifiers.map(m => m.type.getOrInferTier(poolType)).reduce((highestTier, tier) => Math.max(tier!, highestTier), 0); // TODO: is this bang correct? + const itemModifiers = globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === targetPokemon.id && m.isTransferable, + targetPokemon.isPlayer(), + ) as PokemonHeldItemModifier[]; + let highestItemTier = itemModifiers + .map(m => m.type.getOrInferTier(poolType)) + .reduce((highestTier, tier) => Math.max(tier!, highestTier), 0); // TODO: is this bang correct? let tierItemModifiers = itemModifiers.filter(m => m.type.getOrInferTier(poolType) === highestItemTier); for (let i = 0; i < transferredItemCount; i++) { @@ -3171,10 +3251,7 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { * @see {@linkcode modifierTypes[MINI_BLACK_HOLE]} */ export class TurnHeldItemTransferModifier extends HeldItemTransferModifier { - isTransferable: boolean = true; - constructor(type: ModifierType, pokemonId: number, stackCount?: number) { - super(type, pokemonId, stackCount); - } + isTransferable = true; matchType(modifier: Modifier): boolean { return modifier instanceof TurnHeldItemTransferModifier; @@ -3189,10 +3266,15 @@ export class TurnHeldItemTransferModifier extends HeldItemTransferModifier { } getTransferMessage(pokemon: Pokemon, targetPokemon: Pokemon, item: ModifierType): string { - return i18next.t("modifier:turnHeldItemTransferApply", { pokemonNameWithAffix: getPokemonNameWithAffix(targetPokemon), itemName: item.name, pokemonName: pokemon.getNameToRender(), typeName: this.type.name }); + return i18next.t("modifier:turnHeldItemTransferApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(targetPokemon), + itemName: item.name, + pokemonName: pokemon.getNameToRender(), + typeName: this.type.name, + }); } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 1; } @@ -3223,7 +3305,7 @@ export class ContactHeldItemTransferChanceModifier extends HeldItemTransferModif * @returns The target {@linkcode Pokemon} as array for further use in `apply` implementations */ override getTargets(_holderPokemon: Pokemon, targetPokemon: Pokemon): Pokemon[] { - return !!targetPokemon ? [ targetPokemon ] : []; + return targetPokemon ? [targetPokemon] : []; } matchType(modifier: Modifier): boolean { @@ -3239,20 +3321,25 @@ export class ContactHeldItemTransferChanceModifier extends HeldItemTransferModif } getTransferredItemCount(): number { - return Phaser.Math.RND.realInRange(0, 1) < (this.chance * this.getStackCount()) ? 1 : 0; + return Phaser.Math.RND.realInRange(0, 1) < this.chance * this.getStackCount() ? 1 : 0; } getTransferMessage(pokemon: Pokemon, targetPokemon: Pokemon, item: ModifierType): string { - return i18next.t("modifier:contactHeldItemTransferApply", { pokemonNameWithAffix: getPokemonNameWithAffix(targetPokemon), itemName: item.name, pokemonName: getPokemonNameWithAffix(pokemon), typeName: this.type.name }); + return i18next.t("modifier:contactHeldItemTransferApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(targetPokemon), + itemName: item.name, + pokemonName: getPokemonNameWithAffix(pokemon), + typeName: this.type.name, + }); } - getMaxHeldItemCount(pokemon: Pokemon): number { + getMaxHeldItemCount(_pokemon: Pokemon): number { return 5; } } export class IvScannerModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { + constructor(type: ModifierType, _stackCount?: number) { super(type); } @@ -3278,10 +3365,6 @@ export class IvScannerModifier extends PersistentModifier { } export class ExtraModifierModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - match(modifier: Modifier): boolean { return modifier instanceof ExtraModifierModifier; } @@ -3312,10 +3395,6 @@ export class ExtraModifierModifier extends PersistentModifier { * @see {@linkcode apply} */ export class TempExtraModifierModifier extends LapsingPersistentModifier { - constructor(type: ModifierType, maxBattles: number, battleCount?: number, stackCount?: number) { - super(type, maxBattles, battleCount, stackCount); - } - /** * Goes through existing modifiers for any that match Silver Pokeball, * which will then add the max count of the new item to the existing count of the current item. @@ -3345,7 +3424,7 @@ export class TempExtraModifierModifier extends LapsingPersistentModifier { } match(modifier: Modifier): boolean { - return (modifier instanceof TempExtraModifierModifier); + return modifier instanceof TempExtraModifierModifier; } /** @@ -3360,10 +3439,6 @@ export class TempExtraModifierModifier extends LapsingPersistentModifier { } export abstract class EnemyPersistentModifier extends PersistentModifier { - constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); - } - getMaxStackCount(): number { return 5; } @@ -3395,7 +3470,7 @@ abstract class EnemyDamageMultiplierModifier extends EnemyPersistentModifier { } export class EnemyDamageBoosterModifier extends EnemyDamageMultiplierModifier { - constructor(type: ModifierType, boostPercent: number, stackCount?: number) { + constructor(type: ModifierType, _boostPercent: number, stackCount?: number) { //super(type, 1 + ((boostPercent || 10) * 0.01), stackCount); super(type, 1.05, stackCount); // Hardcode multiplier temporarily } @@ -3409,7 +3484,7 @@ export class EnemyDamageBoosterModifier extends EnemyDamageMultiplierModifier { } getArgs(): any[] { - return [ (this.damageMultiplier - 1) * 100 ]; + return [(this.damageMultiplier - 1) * 100]; } getMaxStackCount(): number { @@ -3418,7 +3493,7 @@ export class EnemyDamageBoosterModifier extends EnemyDamageMultiplierModifier { } export class EnemyDamageReducerModifier extends EnemyDamageMultiplierModifier { - constructor(type: ModifierType, reductionPercent: number, stackCount?: number) { + constructor(type: ModifierType, _reductionPercent: number, stackCount?: number) { //super(type, 1 - ((reductionPercent || 5) * 0.01), stackCount); super(type, 0.975, stackCount); // Hardcode multiplier temporarily } @@ -3432,7 +3507,7 @@ export class EnemyDamageReducerModifier extends EnemyDamageMultiplierModifier { } getArgs(): any[] { - return [ (1 - this.damageMultiplier) * 100 ]; + return [(1 - this.damageMultiplier) * 100]; } getMaxStackCount(): number { @@ -3443,7 +3518,7 @@ export class EnemyDamageReducerModifier extends EnemyDamageMultiplierModifier { export class EnemyTurnHealModifier extends EnemyPersistentModifier { public healPercent: number; - constructor(type: ModifierType, healPercent: number, stackCount?: number) { + constructor(type: ModifierType, _healPercent: number, stackCount?: number) { super(type, stackCount); // Hardcode temporarily @@ -3459,7 +3534,7 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier { } getArgs(): any[] { - return [ this.healPercent ]; + return [this.healPercent]; } /** @@ -3469,8 +3544,20 @@ export class EnemyTurnHealModifier extends EnemyPersistentModifier { */ override apply(enemyPokemon: Pokemon): boolean { if (!enemyPokemon.isFullHp()) { - globalScene.unshiftPhase(new PokemonHealPhase(enemyPokemon.getBattlerIndex(), - Math.max(Math.floor(enemyPokemon.getMaxHp() / (100 / this.healPercent)) * this.stackCount, 1), i18next.t("modifier:enemyTurnHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(enemyPokemon) }), true, false, false, false, true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + enemyPokemon.getBattlerIndex(), + Math.max(Math.floor(enemyPokemon.getMaxHp() / (100 / this.healPercent)) * this.stackCount, 1), + i18next.t("modifier:enemyTurnHealApply", { + pokemonNameWithAffix: getPokemonNameWithAffix(enemyPokemon), + }), + true, + false, + false, + false, + true, + ), + ); return true; } @@ -3486,12 +3573,12 @@ export class EnemyAttackStatusEffectChanceModifier extends EnemyPersistentModifi public effect: StatusEffect; public chance: number; - constructor(type: ModifierType, effect: StatusEffect, chancePercent: number, stackCount?: number) { + constructor(type: ModifierType, effect: StatusEffect, _chancePercent: number, stackCount?: number) { super(type, stackCount); this.effect = effect; //Hardcode temporarily - this.chance = .025 * ((this.effect === StatusEffect.BURN || this.effect === StatusEffect.POISON) ? 2 : 1); + this.chance = 0.025 * (this.effect === StatusEffect.BURN || this.effect === StatusEffect.POISON ? 2 : 1); } match(modifier: Modifier): boolean { @@ -3503,7 +3590,7 @@ export class EnemyAttackStatusEffectChanceModifier extends EnemyPersistentModifi } getArgs(): any[] { - return [ this.effect, this.chance * 100 ]; + return [this.effect, this.chance * 100]; } /** @@ -3512,7 +3599,7 @@ export class EnemyAttackStatusEffectChanceModifier extends EnemyPersistentModifi * @returns `true` if the {@linkcode Pokemon} was affected */ override apply(enemyPokemon: Pokemon): boolean { - if (Phaser.Math.RND.realInRange(0, 1) < (this.chance * this.getStackCount())) { + if (Phaser.Math.RND.realInRange(0, 1) < this.chance * this.getStackCount()) { return enemyPokemon.trySetStatus(this.effect, true); } @@ -3527,11 +3614,11 @@ export class EnemyAttackStatusEffectChanceModifier extends EnemyPersistentModifi export class EnemyStatusEffectHealChanceModifier extends EnemyPersistentModifier { public chance: number; - constructor(type: ModifierType, chancePercent: number, stackCount?: number) { + constructor(type: ModifierType, _chancePercent: number, stackCount?: number) { super(type, stackCount); //Hardcode temporarily - this.chance = .025; + this.chance = 0.025; } match(modifier: Modifier): boolean { @@ -3543,7 +3630,7 @@ export class EnemyStatusEffectHealChanceModifier extends EnemyPersistentModifier } getArgs(): any[] { - return [ this.chance * 100 ]; + return [this.chance * 100]; } /** @@ -3552,8 +3639,10 @@ export class EnemyStatusEffectHealChanceModifier extends EnemyPersistentModifier * @returns `true` if the {@linkcode Pokemon} was healed */ override apply(enemyPokemon: Pokemon): boolean { - if (enemyPokemon.status && Phaser.Math.RND.realInRange(0, 1) < (this.chance * this.getStackCount())) { - globalScene.queueMessage(getStatusEffectHealText(enemyPokemon.status.effect, getPokemonNameWithAffix(enemyPokemon))); + if (enemyPokemon.status && Phaser.Math.RND.realInRange(0, 1) < this.chance * this.getStackCount()) { + globalScene.queueMessage( + getStatusEffectHealText(enemyPokemon.status.effect, getPokemonNameWithAffix(enemyPokemon)), + ); enemyPokemon.resetStatus(); enemyPokemon.updateInfo(); return true; @@ -3570,7 +3659,7 @@ export class EnemyStatusEffectHealChanceModifier extends EnemyPersistentModifier export class EnemyEndureChanceModifier extends EnemyPersistentModifier { public chance: number; - constructor(type: ModifierType, chancePercent?: number, stackCount?: number) { + constructor(type: ModifierType, _chancePercent?: number, stackCount?: number) { super(type, stackCount || 10); //Hardcode temporarily @@ -3586,7 +3675,7 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier { } getArgs(): any[] { - return [ this.chance ]; + return [this.chance]; } /** @@ -3595,7 +3684,7 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier { * @returns `true` if {@linkcode Pokemon} endured */ override apply(target: Pokemon): boolean { - if (target.battleData.endured || target.randSeedInt(100) >= (this.chance * this.getStackCount())) { + if (target.battleData.endured || target.randSeedInt(100) >= this.chance * this.getStackCount()) { return false; } @@ -3629,7 +3718,7 @@ export class EnemyFusionChanceModifier extends EnemyPersistentModifier { } getArgs(): any[] { - return [ this.chance * 100 ]; + return [this.chance * 100]; } /** @@ -3638,7 +3727,7 @@ export class EnemyFusionChanceModifier extends EnemyPersistentModifier { * @returns `true` if the {@linkcode EnemyPokemon} is a fusion */ override apply(isFusion: BooleanHolder): boolean { - if (Phaser.Math.RND.realInRange(0, 1) >= (this.chance * this.getStackCount())) { + if (Phaser.Math.RND.realInRange(0, 1) >= this.chance * this.getStackCount()) { return false; } @@ -3658,8 +3747,10 @@ export class EnemyFusionChanceModifier extends EnemyPersistentModifier { * - The enemy * @param isPlayer {@linkcode boolean} for whether the player (`true`) or enemy (`false`) is being overridden */ -export function overrideModifiers(isPlayer: boolean = true): void { - const modifiersOverride: ModifierOverride[] = isPlayer ? Overrides.STARTING_MODIFIER_OVERRIDE : Overrides.OPP_MODIFIER_OVERRIDE; +export function overrideModifiers(isPlayer = true): void { + const modifiersOverride: ModifierOverride[] = isPlayer + ? Overrides.STARTING_MODIFIER_OVERRIDE + : Overrides.OPP_MODIFIER_OVERRIDE; if (!modifiersOverride || modifiersOverride.length === 0 || !globalScene) { return; } @@ -3669,16 +3760,16 @@ export function overrideModifiers(isPlayer: boolean = true): void { globalScene.clearEnemyModifiers(); } - modifiersOverride.forEach(item => { + for (const item of modifiersOverride) { const modifierFunc = modifierTypes[item.name]; let modifierType: ModifierType | null = modifierFunc(); if (modifierType instanceof ModifierTypeGenerator) { - const pregenArgs = ("type" in item) && (item.type !== null) ? [ item.type ] : undefined; + const pregenArgs = "type" in item && item.type !== null ? [item.type] : undefined; modifierType = modifierType.generateType([], pregenArgs); } - const modifier = modifierType && modifierType.withIdFromFunc(modifierFunc).newModifier() as PersistentModifier; + const modifier = modifierType && (modifierType.withIdFromFunc(modifierFunc).newModifier() as PersistentModifier); if (modifier) { modifier.stackCount = item.count || 1; @@ -3688,7 +3779,7 @@ export function overrideModifiers(isPlayer: boolean = true): void { globalScene.addEnemyModifier(modifier, true, true); } } - }); + } } /** @@ -3698,8 +3789,10 @@ export function overrideModifiers(isPlayer: boolean = true): void { * @param pokemon {@linkcode Pokemon} whose held items are being overridden * @param isPlayer {@linkcode boolean} for whether the {@linkcode pokemon} is the player's (`true`) or an enemy (`false`) */ -export function overrideHeldItems(pokemon: Pokemon, isPlayer: boolean = true): void { - const heldItemsOverride: ModifierOverride[] = isPlayer ? Overrides.STARTING_HELD_ITEMS_OVERRIDE : Overrides.OPP_HELD_ITEMS_OVERRIDE; +export function overrideHeldItems(pokemon: Pokemon, isPlayer = true): void { + const heldItemsOverride: ModifierOverride[] = isPlayer + ? Overrides.STARTING_HELD_ITEMS_OVERRIDE + : Overrides.OPP_HELD_ITEMS_OVERRIDE; if (!heldItemsOverride || heldItemsOverride.length === 0 || !globalScene) { return; } @@ -3708,17 +3801,18 @@ export function overrideHeldItems(pokemon: Pokemon, isPlayer: boolean = true): v globalScene.clearEnemyHeldItemModifiers(pokemon); } - heldItemsOverride.forEach(item => { + for (const item of heldItemsOverride) { const modifierFunc = modifierTypes[item.name]; let modifierType: ModifierType | null = modifierFunc(); const qty = item.count || 1; if (modifierType instanceof ModifierTypeGenerator) { - const pregenArgs = ("type" in item) && (item.type !== null) ? [ item.type ] : undefined; + const pregenArgs = "type" in item && item.type !== null ? [item.type] : undefined; modifierType = modifierType.generateType([], pregenArgs); } - const heldItemModifier = modifierType && modifierType.withIdFromFunc(modifierFunc).newModifier(pokemon) as PokemonHeldItemModifier; + const heldItemModifier = + modifierType && (modifierType.withIdFromFunc(modifierFunc).newModifier(pokemon) as PokemonHeldItemModifier); if (heldItemModifier) { heldItemModifier.pokemonId = pokemon.id; heldItemModifier.stackCount = qty; @@ -3728,5 +3822,5 @@ export function overrideHeldItems(pokemon: Pokemon, isPlayer: boolean = true): v globalScene.addEnemyModifier(heldItemModifier, true, true); } } - }); + } } diff --git a/src/phases/add-enemy-buff-modifier-phase.ts b/src/phases/add-enemy-buff-modifier-phase.ts index f504fd0aaa2..7d91e64382a 100644 --- a/src/phases/add-enemy-buff-modifier-phase.ts +++ b/src/phases/add-enemy-buff-modifier-phase.ts @@ -1,5 +1,9 @@ import { ModifierTier } from "#app/modifier/modifier-tier"; -import { regenerateModifierPoolThresholds, ModifierPoolType, getEnemyBuffModifierForWave } from "#app/modifier/modifier-type"; +import { + regenerateModifierPoolThresholds, + ModifierPoolType, + getEnemyBuffModifierForWave, +} from "#app/modifier/modifier-type"; import { EnemyPersistentModifier } from "#app/modifier/modifier"; import { Phase } from "#app/phase"; import { globalScene } from "#app/global-scene"; @@ -13,13 +17,24 @@ export class AddEnemyBuffModifierPhase extends Phase { super.start(); const waveIndex = globalScene.currentBattle.waveIndex; - const tier = !(waveIndex % 1000) ? ModifierTier.ULTRA : !(waveIndex % 250) ? ModifierTier.GREAT : ModifierTier.COMMON; + const tier = !(waveIndex % 1000) + ? ModifierTier.ULTRA + : !(waveIndex % 250) + ? ModifierTier.GREAT + : ModifierTier.COMMON; regenerateModifierPoolThresholds(globalScene.getEnemyParty(), ModifierPoolType.ENEMY_BUFF); const count = Math.ceil(waveIndex / 250); for (let i = 0; i < count; i++) { - globalScene.addEnemyModifier(getEnemyBuffModifierForWave(tier, globalScene.findModifiers(m => m instanceof EnemyPersistentModifier, false)), true, true); + globalScene.addEnemyModifier( + getEnemyBuffModifierForWave( + tier, + globalScene.findModifiers(m => m instanceof EnemyPersistentModifier, false), + ), + true, + true, + ); } globalScene.updateModifiers(false, true); this.end(); diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 77a8043aee9..6b905c2a07f 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -1,7 +1,13 @@ import { BattlerIndex } from "#app/battle"; import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { SubstituteTag } from "#app/data/battler-tags"; -import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, getCriticalCaptureChance } from "#app/data/pokeball"; +import { + doPokeballBounceAnim, + getPokeballAtlasKey, + getPokeballCatchMultiplier, + getPokeballTintColor, + getCriticalCaptureChance, +} from "#app/data/pokeball"; import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; import { addPokeballCaptureStars, addPokeballOpenParticles } from "#app/field/anims"; import type { EnemyPokemon } from "#app/field/pokemon"; @@ -54,7 +60,7 @@ export class AttemptCapturePhase extends PokemonPhase { const pokeballMultiplier = getPokeballCatchMultiplier(this.pokeballType); const statusMultiplier = pokemon.status ? getStatusEffectCatchRateMultiplier(pokemon.status.effect) : 1; const modifiedCatchRate = Math.round((((_3m - _2h) * catchRate * pokeballMultiplier) / _3m) * statusMultiplier); - const shakeProbability = Math.round(65536 / Math.pow((255 / modifiedCatchRate), 0.1875)); // Formula taken from gen 6 + const shakeProbability = Math.round(65536 / Math.pow(255 / modifiedCatchRate, 0.1875)); // Formula taken from gen 6 const criticalCaptureChance = getCriticalCaptureChance(modifiedCatchRate); const isCritical = pokemon.randSeedInt(256) < criticalCaptureChance; const fpOffset = pokemon.getFieldPositionOffset(); @@ -124,7 +130,12 @@ export class AttemptCapturePhase extends PokemonPhase { this.failCatch(shakeCount); } else if (shakeCount++ < (isCritical ? 1 : 3)) { // Shake check (skip check for critical or guaranteed captures, but still play the sound) - if (pokeballMultiplier === -1 || isCritical || modifiedCatchRate >= 255 || pokemon.randSeedInt(65536) < shakeProbability) { + if ( + pokeballMultiplier === -1 || + isCritical || + modifiedCatchRate >= 255 || + pokemon.randSeedInt(65536) < shakeProbability + ) { globalScene.playSound("se/pb_move"); } else { shakeCounter.stop(); @@ -154,27 +165,29 @@ export class AttemptCapturePhase extends PokemonPhase { alpha: 0, duration: 200, easing: "Sine.easeIn", - onComplete: () => pbTint.destroy() + onComplete: () => pbTint.destroy(), }); - } + }, }); } }, onComplete: () => { this.catch(); - } + }, }); }; // Ball bounces (handled in pokemon.ts) - globalScene.time.delayedCall(250, () => doPokeballBounceAnim(this.pokeball, 16, 72, 350, doShake, isCritical)); - } + globalScene.time.delayedCall(250, () => + doPokeballBounceAnim(this.pokeball, 16, 72, 350, doShake, isCritical), + ); + }, }); - } + }, }); } - failCatch(shakeCount: number) { + failCatch(_shakeCount: number) { const pokemon = this.getPokemon(); globalScene.playSound("se/pb_rel"); @@ -199,7 +212,7 @@ export class AttemptCapturePhase extends PokemonPhase { targets: pokemon, duration: 250, ease: "Sine.easeOut", - scale: 1 + scale: 1, }); globalScene.currentBattle.lastUsedPokeball = this.pokeballType; @@ -212,7 +225,10 @@ export class AttemptCapturePhase extends PokemonPhase { const speciesForm = !pokemon.fusionSpecies ? pokemon.getSpeciesForm() : pokemon.getFusionSpeciesForm(); - if (speciesForm.abilityHidden && (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1) { + if ( + speciesForm.abilityHidden && + (pokemon.fusionSpecies ? pokemon.fusionAbilityIndex : pokemon.abilityIndex) === speciesForm.getAbilityCount() - 1 + ) { globalScene.validateAchv(achvs.HIDDEN_ABILITY); } @@ -232,72 +248,115 @@ export class AttemptCapturePhase extends PokemonPhase { globalScene.gameData.updateSpeciesDexIvs(pokemon.species.getRootSpeciesId(true), pokemon.ivs); - globalScene.ui.showText(i18next.t("battle:pokemonCaught", { pokemonName: getPokemonNameWithAffix(pokemon) }), null, () => { - const end = () => { - globalScene.unshiftPhase(new VictoryPhase(this.battlerIndex)); - globalScene.pokemonInfoContainer.hide(); - this.removePb(); - this.end(); - }; - const removePokemon = () => { - globalScene.addFaintedEnemyScore(pokemon); - pokemon.hp = 0; - pokemon.trySetStatus(StatusEffect.FAINT); - globalScene.clearEnemyHeldItemModifiers(); - pokemon.leaveField(true, true, true); - }; - const addToParty = (slotIndex?: number) => { - const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex); - const modifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier, false); - if (globalScene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) { - globalScene.validateAchv(achvs.SHINY_PARTY); - } - Promise.all(modifiers.map(m => globalScene.addModifier(m, true))).then(() => { - globalScene.updateModifiers(true); - removePokemon(); - if (newPokemon) { - newPokemon.loadAssets().then(end); + globalScene.ui.showText( + i18next.t("battle:pokemonCaught", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + null, + () => { + const end = () => { + globalScene.unshiftPhase(new VictoryPhase(this.battlerIndex)); + globalScene.pokemonInfoContainer.hide(); + this.removePb(); + this.end(); + }; + const removePokemon = () => { + globalScene.addFaintedEnemyScore(pokemon); + pokemon.hp = 0; + pokemon.trySetStatus(StatusEffect.FAINT); + globalScene.clearEnemyHeldItemModifiers(); + pokemon.leaveField(true, true, true); + }; + const addToParty = (slotIndex?: number) => { + const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex); + const modifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier, false); + if (globalScene.getPlayerParty().filter(p => p.isShiny()).length === PLAYER_PARTY_MAX_SIZE) { + globalScene.validateAchv(achvs.SHINY_PARTY); + } + Promise.all(modifiers.map(m => globalScene.addModifier(m, true))).then(() => { + globalScene.updateModifiers(true); + removePokemon(); + if (newPokemon) { + newPokemon.loadAssets().then(end); + } else { + end(); + } + }); + }; + Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => { + if (globalScene.getPlayerParty().length === PLAYER_PARTY_MAX_SIZE) { + const promptRelease = () => { + globalScene.ui.showText( + i18next.t("battle:partyFull", { + pokemonName: pokemon.getNameToRender(), + }), + null, + () => { + globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); + globalScene.ui.setMode( + Mode.CONFIRM, + () => { + const newPokemon = globalScene.addPlayerPokemon( + pokemon.species, + pokemon.level, + pokemon.abilityIndex, + pokemon.formIndex, + pokemon.gender, + pokemon.shiny, + pokemon.variant, + pokemon.ivs, + pokemon.nature, + pokemon, + ); + globalScene.ui.setMode( + Mode.SUMMARY, + newPokemon, + 0, + SummaryUiMode.DEFAULT, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + promptRelease(); + }); + }, + false, + ); + }, + () => { + globalScene.ui.setMode( + Mode.PARTY, + PartyUiMode.RELEASE, + this.fieldIndex, + (slotIndex: number, _option: PartyOption) => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + if (slotIndex < 6) { + addToParty(slotIndex); + } else { + promptRelease(); + } + }); + }, + ); + }, + () => { + globalScene.ui.setMode(Mode.MESSAGE).then(() => { + removePokemon(); + end(); + }); + }, + "fullParty", + ); + }, + ); + }; + promptRelease(); } else { - end(); + addToParty(); } }); - }; - Promise.all([ pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon) ]).then(() => { - if (globalScene.getPlayerParty().length === PLAYER_PARTY_MAX_SIZE) { - const promptRelease = () => { - globalScene.ui.showText(i18next.t("battle:partyFull", { pokemonName: pokemon.getNameToRender() }), null, () => { - globalScene.pokemonInfoContainer.makeRoomForConfirmUi(1, true); - globalScene.ui.setMode(Mode.CONFIRM, () => { - const newPokemon = globalScene.addPlayerPokemon(pokemon.species, pokemon.level, pokemon.abilityIndex, pokemon.formIndex, pokemon.gender, pokemon.shiny, pokemon.variant, pokemon.ivs, pokemon.nature, pokemon); - globalScene.ui.setMode(Mode.SUMMARY, newPokemon, 0, SummaryUiMode.DEFAULT, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - promptRelease(); - }); - }, false); - }, () => { - globalScene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: number, _option: PartyOption) => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - if (slotIndex < 6) { - addToParty(slotIndex); - } else { - promptRelease(); - } - }); - }); - }, () => { - globalScene.ui.setMode(Mode.MESSAGE).then(() => { - removePokemon(); - end(); - }); - }, "fullParty"); - }); - }; - promptRelease(); - } else { - addToParty(); - } - }); - }, 0, true); + }, + 0, + true, + ); } removePb() { @@ -307,7 +366,7 @@ export class AttemptCapturePhase extends PokemonPhase { delay: 250, ease: "Sine.easeIn", alpha: 0, - onComplete: () => this.pokeball.destroy() + onComplete: () => this.pokeball.destroy(), }); } } diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 72a108c1991..c9c0e23dabb 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -11,14 +11,9 @@ import { PokemonPhase } from "./pokemon-phase"; import { globalScene } from "#app/global-scene"; export class AttemptRunPhase extends PokemonPhase { - /** For testing purposes: this is to force the pokemon to fail and escape */ public forceFailEscape = false; - constructor(fieldIndex: number) { - super(fieldIndex); - } - start() { super.start(); @@ -38,15 +33,18 @@ export class AttemptRunPhase extends PokemonPhase { globalScene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500); globalScene.tweens.add({ - targets: [ globalScene.arenaEnemy, enemyField ].flat(), + targets: [globalScene.arenaEnemy, enemyField].flat(), alpha: 0, duration: 250, ease: "Sine.easeIn", - onComplete: () => enemyField.forEach(enemyPokemon => enemyPokemon.destroy()) + onComplete: () => + // biome-ignore lint/complexity/noForEach: TODO + enemyField.forEach(enemyPokemon => enemyPokemon.destroy()), }); globalScene.clearEnemyHeldItemModifiers(); + // biome-ignore lint/complexity/noForEach: TODO enemyField.forEach(enemyPokemon => { enemyPokemon.hideInfo().then(() => enemyPokemon.destroy()); enemyPokemon.hp = 0; @@ -65,9 +63,15 @@ export class AttemptRunPhase extends PokemonPhase { attemptRunAway(playerField: PlayerPokemon[], enemyField: EnemyPokemon[], escapeChance: Utils.NumberHolder) { /** Sum of the speed of all enemy pokemon on the field */ - const enemySpeed = enemyField.reduce((total: number, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD), 0); + const enemySpeed = enemyField.reduce( + (total: number, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD), + 0, + ); /** Sum of the speed of all player pokemon on the field */ - const playerSpeed = playerField.reduce((total: number, playerPokemon: Pokemon) => total + playerPokemon.getStat(Stat.SPD), 0); + const playerSpeed = playerField.reduce( + (total: number, playerPokemon: Pokemon) => total + playerPokemon.getStat(Stat.SPD), + 0, + ); /* The way the escape chance works is by looking at the difference between your speed and the enemy field's average speed as a ratio. The higher this ratio, the higher your chance of success. * However, there is a cap for the ratio of your speed vs enemy speed which beyond that point, you won't gain any advantage. It also looks at how many times you've tried to escape. @@ -104,6 +108,10 @@ export class AttemptRunPhase extends PokemonPhase { const escapeSlope = (maxChance - minChance) / speedCap; // This will calculate the escape chance given all of the above and clamp it to the range of [`minChance`, `maxChance`] - escapeChance.value = Phaser.Math.Clamp(Math.round((escapeSlope * speedRatio) + minChance + (escapeBonus * globalScene.currentBattle.escapeAttempts++)), minChance, maxChance); + escapeChance.value = Phaser.Math.Clamp( + Math.round(escapeSlope * speedRatio + minChance + escapeBonus * globalScene.currentBattle.escapeAttempts++), + minChance, + maxChance, + ); } } diff --git a/src/phases/battle-end-phase.ts b/src/phases/battle-end-phase.ts index c0922b91809..a7158264ab7 100644 --- a/src/phases/battle-end-phase.ts +++ b/src/phases/battle-end-phase.ts @@ -18,7 +18,10 @@ export class BattleEndPhase extends BattlePhase { super.start(); globalScene.gameData.gameStats.battles++; - if (globalScene.gameMode.isEndless && globalScene.currentBattle.waveIndex + 1 > globalScene.gameData.gameStats.highestEndlessWave) { + if ( + globalScene.gameMode.isEndless && + globalScene.currentBattle.waveIndex + 1 > globalScene.gameData.gameStats.highestEndlessWave + ) { globalScene.gameData.gameStats.highestEndlessWave = globalScene.currentBattle.waveIndex + 1; } @@ -37,7 +40,7 @@ export class BattleEndPhase extends BattlePhase { } for (const pokemon of globalScene.getField()) { - if (pokemon && pokemon.battleSummonData) { + if (pokemon?.battleSummonData) { pokemon.battleSummonData.waveTurnCount = 1; } } @@ -52,7 +55,9 @@ export class BattleEndPhase extends BattlePhase { globalScene.clearEnemyHeldItemModifiers(); - const lapsingModifiers = globalScene.findModifiers(m => m instanceof LapsingPersistentModifier || m instanceof LapsingPokemonHeldItemModifier) as (LapsingPersistentModifier | LapsingPokemonHeldItemModifier)[]; + const lapsingModifiers = globalScene.findModifiers( + m => m instanceof LapsingPersistentModifier || m instanceof LapsingPokemonHeldItemModifier, + ) as (LapsingPersistentModifier | LapsingPokemonHeldItemModifier)[]; for (const m of lapsingModifiers) { const args: any[] = []; if (m instanceof LapsingPokemonHeldItemModifier) { diff --git a/src/phases/battle-phase.ts b/src/phases/battle-phase.ts index 4fc826b7957..3fc2b9c0467 100644 --- a/src/phases/battle-phase.ts +++ b/src/phases/battle-phase.ts @@ -12,7 +12,7 @@ export class BattlePhase extends Phase { const tintSprites = globalScene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct? for (let i = 0; i < sprites.length; i++) { const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2; - [ sprites[i], tintSprites[i] ].map(sprite => { + [sprites[i], tintSprites[i]].map(sprite => { if (visible) { sprite.x = trainerSlot || sprites.length < 2 ? 0 : i ? 16 : -16; } @@ -30,7 +30,7 @@ export class BattlePhase extends Phase { y: "+=16", alpha: 1, ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); } @@ -41,7 +41,7 @@ export class BattlePhase extends Phase { y: "-=16", alpha: 0, ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); } } diff --git a/src/phases/berry-phase.ts b/src/phases/berry-phase.ts index dd56e8b37d7..0048f8cd2f2 100644 --- a/src/phases/berry-phase.ts +++ b/src/phases/berry-phase.ts @@ -14,20 +14,24 @@ export class BerryPhase extends FieldPhase { start() { super.start(); - this.executeForAll((pokemon) => { - const hasUsableBerry = !!globalScene.findModifier((m) => { + this.executeForAll(pokemon => { + const hasUsableBerry = !!globalScene.findModifier(m => { return m instanceof BerryModifier && m.shouldApply(pokemon); }, pokemon.isPlayer()); if (hasUsableBerry) { const cancelled = new Utils.BooleanHolder(false); - pokemon.getOpponents().map((opp) => applyAbAttrs(PreventBerryUseAbAttr, opp, cancelled)); + pokemon.getOpponents().map(opp => applyAbAttrs(PreventBerryUseAbAttr, opp, cancelled)); if (cancelled.value) { - globalScene.queueMessage(i18next.t("abilityTriggers:preventBerryUse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage( + i18next.t("abilityTriggers:preventBerryUse", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + ); } else { globalScene.unshiftPhase( - new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.USE_ITEM) + new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.USE_ITEM), ); for (const berryModifier of globalScene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) { diff --git a/src/phases/check-status-effect-phase.ts b/src/phases/check-status-effect-phase.ts index 683c1ea1cd2..f59dfea9f02 100644 --- a/src/phases/check-status-effect-phase.ts +++ b/src/phases/check-status-effect-phase.ts @@ -4,8 +4,8 @@ import type { BattlerIndex } from "#app/battle"; import { globalScene } from "#app/global-scene"; export class CheckStatusEffectPhase extends Phase { - private order : BattlerIndex[]; - constructor(order : BattlerIndex[]) { + private order: BattlerIndex[]; + constructor(order: BattlerIndex[]) { super(); this.order = order; } @@ -13,7 +13,7 @@ export class CheckStatusEffectPhase extends Phase { start() { const field = globalScene.getField(); for (const o of this.order) { - if (field[o].status && field[o].status.isPostTurn()) { + if (field[o].status?.isPostTurn()) { globalScene.unshiftPhase(new PostTurnStatusEffectPhase(o)); } } diff --git a/src/phases/check-switch-phase.ts b/src/phases/check-switch-phase.ts index ea16e91b990..ba4837fd7cc 100644 --- a/src/phases/check-switch-phase.ts +++ b/src/phases/check-switch-phase.ts @@ -39,26 +39,43 @@ export class CheckSwitchPhase extends BattlePhase { } // ...if there are no other allowed Pokemon in the player's party to switch with - if (!globalScene.getPlayerParty().slice(1).filter(p => p.isActive()).length) { + if ( + !globalScene + .getPlayerParty() + .slice(1) + .filter(p => p.isActive()).length + ) { return super.end(); } // ...or if any player Pokemon has an effect that prevents the checked Pokemon from switching - if (pokemon.getTag(BattlerTagType.FRENZY) - || pokemon.isTrapped() - || globalScene.getPlayerField().some(p => p.getTag(BattlerTagType.COMMANDED))) { + if ( + pokemon.getTag(BattlerTagType.FRENZY) || + pokemon.isTrapped() || + globalScene.getPlayerField().some(p => p.getTag(BattlerTagType.COMMANDED)) + ) { return super.end(); } - globalScene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => { - globalScene.ui.setMode(Mode.CONFIRM, () => { - globalScene.ui.setMode(Mode.MESSAGE); - globalScene.unshiftPhase(new SwitchPhase(SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true)); - this.end(); - }, () => { - globalScene.ui.setMode(Mode.MESSAGE); - this.end(); - }); - }); + globalScene.ui.showText( + i18next.t("battle:switchQuestion", { + pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon"), + }), + null, + () => { + globalScene.ui.setMode( + Mode.CONFIRM, + () => { + globalScene.ui.setMode(Mode.MESSAGE); + globalScene.unshiftPhase(new SwitchPhase(SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true)); + this.end(); + }, + () => { + globalScene.ui.setMode(Mode.MESSAGE); + this.end(); + }, + ); + }, + ); } } diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 5f4466d942c..055d52e7a8b 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -41,12 +41,16 @@ export class CommandPhase extends FieldPhase { const commandUiHandler = globalScene.ui.handlers[Mode.COMMAND]; // If one of these conditions is true, we always reset the cursor to Command.FIGHT - const cursorResetEvent = globalScene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER || - globalScene.currentBattle.battleType === BattleType.TRAINER || - globalScene.arena.biomeType === Biome.END; + const cursorResetEvent = + globalScene.currentBattle.battleType === BattleType.MYSTERY_ENCOUNTER || + globalScene.currentBattle.battleType === BattleType.TRAINER || + globalScene.arena.biomeType === Biome.END; if (commandUiHandler) { - if ((globalScene.currentBattle.turn === 1 && (!globalScene.commandCursorMemory || cursorResetEvent)) || commandUiHandler.getCursor() === Command.POKEMON) { + if ( + (globalScene.currentBattle.turn === 1 && (!globalScene.commandCursorMemory || cursorResetEvent)) || + commandUiHandler.getCursor() === Command.POKEMON + ) { commandUiHandler.setCursor(Command.FIGHT); } else { commandUiHandler.setCursor(commandUiHandler.getCursor()); @@ -61,14 +65,24 @@ export class CommandPhase extends FieldPhase { } else { const allyCommand = globalScene.currentBattle.turnCommands[this.fieldIndex - 1]; if (allyCommand?.command === Command.BALL || allyCommand?.command === Command.RUN) { - globalScene.currentBattle.turnCommands[this.fieldIndex] = { command: allyCommand?.command, skip: true }; + globalScene.currentBattle.turnCommands[this.fieldIndex] = { + command: allyCommand?.command, + skip: true, + }; } } } // If the Pokemon has applied Commander's effects to its ally, skip this command - if (globalScene.currentBattle?.double && this.getPokemon().getAlly()?.getTag(BattlerTagType.COMMANDED)?.getSourcePokemon() === this.getPokemon()) { - globalScene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.FIGHT, move: { move: Moves.NONE, targets: []}, skip: true }; + if ( + globalScene.currentBattle?.double && + this.getPokemon().getAlly()?.getTag(BattlerTagType.COMMANDED)?.getSourcePokemon() === this.getPokemon() + ) { + globalScene.currentBattle.turnCommands[this.fieldIndex] = { + command: Command.FIGHT, + move: { move: Moves.NONE, targets: [] }, + skip: true, + }; } // Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP. @@ -85,9 +99,20 @@ export class CommandPhase extends FieldPhase { const moveQueue = playerPokemon.getMoveQueue(); - while (moveQueue.length && moveQueue[0] - && moveQueue[0].move && !moveQueue[0].virtual && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move) - || !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct? + while ( + moveQueue.length && + moveQueue[0] && + moveQueue[0].move && + !moveQueue[0].virtual && + (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move) || + !playerPokemon + .getMoveset() + [playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable( + playerPokemon, + moveQueue[0].ignorePP, + )) + ) { + // TODO: is the bang correct? moveQueue.shift(); } @@ -97,14 +122,21 @@ export class CommandPhase extends FieldPhase { this.handleCommand(Command.FIGHT, -1); } else { const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move); - if ((moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) || queuedMove.virtual) { // TODO: is the bang correct? + if ( + (moveIndex > -1 && playerPokemon.getMoveset()[moveIndex]!.isUsable(playerPokemon, queuedMove.ignorePP)) || + queuedMove.virtual + ) { + // TODO: is the bang correct? this.handleCommand(Command.FIGHT, moveIndex, queuedMove.ignorePP, queuedMove); } else { globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); } } } else { - if (globalScene.currentBattle.isBattleMysteryEncounter() && globalScene.currentBattle.mysteryEncounter?.skipToFightInput) { + if ( + globalScene.currentBattle.isBattleMysteryEncounter() && + globalScene.currentBattle.mysteryEncounter?.skipToFightInput + ) { globalScene.ui.clearText(); globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex); } else { @@ -115,17 +147,18 @@ export class CommandPhase extends FieldPhase { handleCommand(command: Command, cursor: number, ...args: any[]): boolean { const playerPokemon = globalScene.getPlayerField()[this.fieldIndex]; - let success: boolean = false; + let success = false; switch (command) { case Command.TERA: case Command.FIGHT: let useStruggle = false; - const turnMove: TurnMove | undefined = (args.length === 2 ? (args[1] as TurnMove) : undefined); - if (cursor === -1 || - playerPokemon.trySelectMove(cursor, args[0] as boolean) || - (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) { - + const turnMove: TurnMove | undefined = args.length === 2 ? (args[1] as TurnMove) : undefined; + if ( + cursor === -1 || + playerPokemon.trySelectMove(cursor, args[0] as boolean) || + (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length) + ) { let moveId: Moves; if (useStruggle) { moveId = Moves.STRUGGLE; @@ -137,11 +170,26 @@ export class CommandPhase extends FieldPhase { moveId = Moves.NONE; } - const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args }; - const preTurnCommand: TurnCommand = { command: command, targets: [ this.fieldIndex ], skip: command === Command.FIGHT }; - const moveTargets: MoveTargetSet = turnMove === undefined ? getMoveTargets(playerPokemon, moveId) : { targets: turnMove.targets, multiple: turnMove.targets.length > 1 }; + const turnCommand: TurnCommand = { + command: Command.FIGHT, + cursor: cursor, + move: { move: moveId, targets: [], ignorePP: args[0] }, + args: args, + }; + const preTurnCommand: TurnCommand = { + command: command, + targets: [this.fieldIndex], + skip: command === Command.FIGHT, + }; + const moveTargets: MoveTargetSet = + turnMove === undefined + ? getMoveTargets(playerPokemon, moveId) + : { + targets: turnMove.targets, + multiple: turnMove.targets.length > 1, + }; if (!moveId) { - turnCommand.targets = [ this.fieldIndex ]; + turnCommand.targets = [this.fieldIndex]; } console.log(moveTargets, getPokemonNameWithAffix(playerPokemon)); if (moveTargets.targets.length > 1 && moveTargets.multiple) { @@ -162,61 +210,122 @@ export class CommandPhase extends FieldPhase { globalScene.ui.setMode(Mode.MESSAGE); // Decides between a Disabled, Not Implemented, or No PP translation message - const errorMessage = - playerPokemon.isMoveRestricted(move.moveId, playerPokemon) - ? playerPokemon.getRestrictingTag(move.moveId, playerPokemon)!.selectionDeniedText(playerPokemon, move.moveId) - : move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP"; + const errorMessage = playerPokemon.isMoveRestricted(move.moveId, playerPokemon) + ? playerPokemon + .getRestrictingTag(move.moveId, playerPokemon)! + .selectionDeniedText(playerPokemon, move.moveId) + : move.getName().endsWith(" (N)") + ? "battle:moveNotImplemented" + : "battle:moveNoPP"; const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator - globalScene.ui.showText(i18next.t(errorMessage, { moveName: moveName }), null, () => { - globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex); - }, null, true); + globalScene.ui.showText( + i18next.t(errorMessage, { moveName: moveName }), + null, + () => { + globalScene.ui.clearText(); + globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex); + }, + null, + true, + ); } break; case Command.BALL: - const notInDex = (globalScene.getEnemyField().filter(p => p.isActive(true)).some(p => !globalScene.gameData.dexData[p.species.speciesId].caughtAttr) && globalScene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarterCosts).length - 1); - if (globalScene.arena.biomeType === Biome.END && (!globalScene.gameMode.isClassic || globalScene.gameMode.isFreshStartChallenge() || notInDex )) { + const notInDex = + globalScene + .getEnemyField() + .filter(p => p.isActive(true)) + .some(p => !globalScene.gameData.dexData[p.species.speciesId].caughtAttr) && + globalScene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarterCosts).length - 1; + if ( + 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.showText(i18next.t("battle:noPokeballForce"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); + globalScene.ui.showText( + i18next.t("battle:noPokeballForce"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.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.showText(i18next.t("battle:noPokeballTrainer"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); - } else if (globalScene.currentBattle.isBattleMysteryEncounter() && !globalScene.currentBattle.mysteryEncounter!.catchAllowed) { + globalScene.ui.showText( + i18next.t("battle:noPokeballTrainer"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + }, + null, + true, + ); + } else if ( + globalScene.currentBattle.isBattleMysteryEncounter() && + !globalScene.currentBattle.mysteryEncounter!.catchAllowed + ) { globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(i18next.t("battle:noPokeballMysteryEncounter"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); + globalScene.ui.showText( + i18next.t("battle:noPokeballMysteryEncounter"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + }, + null, + true, + ); } else { - const targets = globalScene.getEnemyField().filter(p => p.isActive(true)).map(p => p.getBattlerIndex()); + const targets = globalScene + .getEnemyField() + .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.showText(i18next.t("battle:noPokeballMulti"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); - } else if (cursor < 5) { - const targetPokemon = globalScene.getEnemyField().find(p => p.isActive(true)); - if (targetPokemon?.isBoss() && targetPokemon?.bossSegmentIndex >= 1 && !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.showText(i18next.t("battle:noPokeballStrong"), null, () => { + globalScene.ui.showText( + i18next.t("battle:noPokeballMulti"), + null, + () => { globalScene.ui.showText("", 0); globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); + }, + null, + true, + ); + } else if (cursor < 5) { + const targetPokemon = globalScene.getEnemyField().find(p => p.isActive(true)); + if ( + targetPokemon?.isBoss() && + targetPokemon?.bossSegmentIndex >= 1 && + !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.showText( + i18next.t("battle:noPokeballStrong"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + }, + null, + true, + ); } else { - globalScene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.BALL, cursor: cursor }; + globalScene.currentBattle.turnCommands[this.fieldIndex] = { + command: Command.BALL, + cursor: cursor, + }; globalScene.currentBattle.turnCommands[this.fieldIndex]!.targets = targets; if (this.fieldIndex) { globalScene.currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; @@ -231,22 +340,42 @@ export class CommandPhase extends FieldPhase { const isSwitch = command === Command.POKEMON; const { currentBattle, arena } = globalScene; const mysteryEncounterFleeAllowed = currentBattle.mysteryEncounter?.fleeAllowed; - if (!isSwitch && (arena.biomeType === Biome.END || (!isNullOrUndefined(mysteryEncounterFleeAllowed) && !mysteryEncounterFleeAllowed))) { + if ( + !isSwitch && + (arena.biomeType === Biome.END || + (!isNullOrUndefined(mysteryEncounterFleeAllowed) && !mysteryEncounterFleeAllowed)) + ) { globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(i18next.t("battle:noEscapeForce"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); - } else if (!isSwitch && (currentBattle.battleType === BattleType.TRAINER || currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE)) { + globalScene.ui.showText( + i18next.t("battle:noEscapeForce"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + }, + null, + true, + ); + } else if ( + !isSwitch && + (currentBattle.battleType === BattleType.TRAINER || + currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) + ) { globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(i18next.t("battle:noEscapeTrainer"), null, () => { - globalScene.ui.showText("", 0); - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - }, null, true); + globalScene.ui.showText( + i18next.t("battle:noEscapeTrainer"), + null, + () => { + globalScene.ui.showText("", 0); + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + }, + null, + true, + ); } else { - const batonPass = isSwitch && args[0] as boolean; + const batonPass = isSwitch && (args[0] as boolean); const trappedAbMessages: string[] = []; if (batonPass || !playerPokemon.isTrapped(trappedAbMessages)) { currentBattle.turnCommands[this.fieldIndex] = isSwitch @@ -254,18 +383,24 @@ export class CommandPhase extends FieldPhase { : { command: Command.RUN }; success = true; if (!isSwitch && this.fieldIndex) { - currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; + currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; } } else if (trappedAbMessages.length > 0) { if (!isSwitch) { globalScene.ui.setMode(Mode.MESSAGE); } - globalScene.ui.showText(trappedAbMessages[0], null, () => { - globalScene.ui.showText("", 0); - if (!isSwitch) { - globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); - } - }, null, true); + globalScene.ui.showText( + trappedAbMessages[0], + null, + () => { + globalScene.ui.showText("", 0); + if (!isSwitch) { + globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex); + } + }, + null, + true, + ); } else { const trapTag = playerPokemon.getTag(TrappedTag); const fairyLockTag = globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER); @@ -281,9 +416,12 @@ export class CommandPhase extends FieldPhase { const showNoEscapeText = (tag: any) => { globalScene.ui.showText( i18next.t("battle:noEscapePokemon", { - pokemonName: tag.sourceId && globalScene.getPokemonById(tag.sourceId) ? getPokemonNameWithAffix(globalScene.getPokemonById(tag.sourceId)!) : "", + pokemonName: + tag.sourceId && globalScene.getPokemonById(tag.sourceId) + ? getPokemonNameWithAffix(globalScene.getPokemonById(tag.sourceId)!) + : "", moveName: tag.getMoveName(), - escapeVerb: isSwitch ? i18next.t("battle:escapeVerbSwitch") : i18next.t("battle:escapeVerbFlee") + escapeVerb: isSwitch ? i18next.t("battle:escapeVerbSwitch") : i18next.t("battle:escapeVerbFlee"), }), null, () => { @@ -293,7 +431,7 @@ export class CommandPhase extends FieldPhase { } }, null, - true + true, ); }; diff --git a/src/phases/common-anim-phase.ts b/src/phases/common-anim-phase.ts index 9ca74ed5a77..d32e93ea6aa 100644 --- a/src/phases/common-anim-phase.ts +++ b/src/phases/common-anim-phase.ts @@ -9,7 +9,7 @@ export class CommonAnimPhase extends PokemonPhase { private targetIndex: number | undefined; private playOnEmptyField: boolean; - constructor(battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim?: CommonAnim, playOnEmptyField: boolean = false) { + constructor(battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim?: CommonAnim, playOnEmptyField = false) { super(battlerIndex); this.anim = anim!; // TODO: is this bang correct? @@ -22,7 +22,10 @@ export class CommonAnimPhase extends PokemonPhase { } start() { - const target = this.targetIndex !== undefined ? (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField())[this.targetIndex] : this.getPokemon(); + const target = + this.targetIndex !== undefined + ? (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField())[this.targetIndex] + : this.getPokemon(); new CommonBattleAnim(this.anim, this.getPokemon(), target).play(false, () => { this.end(); }); diff --git a/src/phases/damage-anim-phase.ts b/src/phases/damage-anim-phase.ts index a21d9d4622a..e31fe8c9475 100644 --- a/src/phases/damage-anim-phase.ts +++ b/src/phases/damage-anim-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { type BattlerIndex } from "#app/battle"; +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"; @@ -10,7 +10,7 @@ export class DamageAnimPhase extends PokemonPhase { private damageResult: DamageResult; private critical: boolean; - constructor(battlerIndex: BattlerIndex, amount: number, damageResult?: DamageResult, critical: boolean = false) { + constructor(battlerIndex: BattlerIndex, amount: number, damageResult?: DamageResult, critical = false) { super(battlerIndex); this.amount = amount; @@ -63,14 +63,20 @@ export class DamageAnimPhase extends PokemonPhase { repeat: 5, startAt: 200, callback: () => { - this.getPokemon().getSprite().setVisible(flashTimer.repeatCount % 2 === 0); + this.getPokemon() + .getSprite() + .setVisible(flashTimer.repeatCount % 2 === 0); if (!flashTimer.repeatCount) { - this.getPokemon().updateInfo().then(() => this.end()); + this.getPokemon() + .updateInfo() + .then(() => this.end()); } - } + }, }); } else { - this.getPokemon().updateInfo().then(() => this.end()); + this.getPokemon() + .updateInfo() + .then(() => this.end()); } } diff --git a/src/phases/egg-hatch-phase.ts b/src/phases/egg-hatch-phase.ts index b2844591e33..49a408e8699 100644 --- a/src/phases/egg-hatch-phase.ts +++ b/src/phases/egg-hatch-phase.ts @@ -16,7 +16,6 @@ import type { EggLapsePhase } from "./egg-lapse-phase"; import type { EggHatchData } from "#app/data/egg-hatch-data"; import { doShinySparkleAnim } from "#app/field/anims"; - /** * Class that represents egg hatching */ @@ -78,7 +77,6 @@ export class EggHatchPhase extends Phase { super.start(); globalScene.ui.setModeForceTransition(Mode.EGG_HATCH_SCENE).then(() => { - if (!this.egg) { return this.end(); } @@ -101,13 +99,21 @@ export class EggHatchPhase extends Phase { this.eggHatchBg.setOrigin(0, 0); this.eggHatchContainer.add(this.eggHatchBg); - this.eggContainer = globalScene.add.container(this.eggHatchBg.displayWidth / 2, this.eggHatchBg.displayHeight / 2); + this.eggContainer = globalScene.add.container( + this.eggHatchBg.displayWidth / 2, + this.eggHatchBg.displayHeight / 2, + ); this.eggSprite = globalScene.add.sprite(0, 0, "egg", `egg_${this.egg.getKey()}`); this.eggCrackSprite = globalScene.add.sprite(0, 0, "egg_crack", "0"); this.eggCrackSprite.setVisible(false); - this.eggLightraysOverlay = globalScene.add.sprite((-this.eggHatchBg.displayWidth / 2) + 4, -this.eggHatchBg.displayHeight / 2, "egg_lightrays", "3"); + this.eggLightraysOverlay = globalScene.add.sprite( + -this.eggHatchBg.displayWidth / 2 + 4, + -this.eggHatchBg.displayHeight / 2, + "egg_lightrays", + "3", + ); this.eggLightraysOverlay.setOrigin(0, 0); this.eggLightraysOverlay.setVisible(false); @@ -120,8 +126,15 @@ export class EggHatchPhase extends Phase { this.eggHatchContainer.add(this.eggCounterContainer); const getPokemonSprite = () => { - const ret = globalScene.add.sprite(this.eggHatchBg.displayWidth / 2, this.eggHatchBg.displayHeight / 2, "pkmn__sub"); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + const ret = globalScene.add.sprite( + this.eggHatchBg.displayWidth / 2, + this.eggHatchBg.displayHeight / 2, + "pkmn__sub", + ); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); return ret; }; @@ -132,7 +145,13 @@ export class EggHatchPhase extends Phase { this.eggHatchContainer.add(this.pokemonShinySparkle); - this.eggHatchOverlay = globalScene.add.rectangle(0, -globalScene.game.canvas.height / 6, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0xFFFFFF); + this.eggHatchOverlay = globalScene.add.rectangle( + 0, + -globalScene.game.canvas.height / 6, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0xffffff, + ); this.eggHatchOverlay.setOrigin(0, 0); this.eggHatchOverlay.setAlpha(0); globalScene.fieldUI.add(this.eggHatchOverlay); @@ -205,7 +224,7 @@ export class EggHatchPhase extends Phase { } end() { - if (globalScene.findPhase((p) => p instanceof EggHatchPhase)) { + if (globalScene.findPhase(p => p instanceof EggHatchPhase)) { this.eggHatchHandler.clear(); } else { globalScene.time.delayedCall(250, () => globalScene.setModifiersVisible(true)); @@ -242,7 +261,8 @@ export class EggHatchPhase extends Phase { duration: 250, onComplete: () => { count!++; - if (count! < repeatCount!) { // we know they are defined + if (count! < repeatCount!) { + // we know they are defined return this.doEggShake(intensity, repeatCount, count).then(() => resolve()); } globalScene.tweens.add({ @@ -250,11 +270,11 @@ export class EggHatchPhase extends Phase { x: `-=${intensity / 2}`, ease: "Sine.easeInOut", duration: 125, - onComplete: () => resolve() + onComplete: () => resolve(), }); - } + }, }); - } + }, }); }); } @@ -289,7 +309,9 @@ export class EggHatchPhase extends Phase { SoundFade.fadeOut(globalScene, this.evolutionBgm, Utils.fixedInt(100)); } for (let e = 0; e < 5; e++) { - globalScene.time.delayedCall(Utils.fixedInt(375 * e), () => globalScene.playSound("se/egg_hatch", { volume: 1 - (e * 0.2) })); + globalScene.time.delayedCall(Utils.fixedInt(375 * e), () => + globalScene.playSound("se/egg_hatch", { volume: 1 - e * 0.2 }), + ); } this.eggLightraysOverlay.setVisible(true); this.eggLightraysOverlay.play("egg_lightrays"); @@ -301,7 +323,7 @@ export class EggHatchPhase extends Phase { onComplete: () => { this.skipped = false; this.canSkip = true; - } + }, }); globalScene.time.delayedCall(Utils.fixedInt(1500), () => { this.canSkip = false; @@ -350,28 +372,40 @@ export class EggHatchPhase extends Phase { doShinySparkleAnim(this.pokemonShinySparkle, this.pokemon.variant); }); } - globalScene.time.delayedCall(Utils.fixedInt(!this.skipped ? !isShiny ? 1250 : 1750 : !isShiny ? 250 : 750), () => { - this.infoContainer.show(this.pokemon, false, this.skipped ? 2 : 1); + globalScene.time.delayedCall( + Utils.fixedInt(!this.skipped ? (!isShiny ? 1250 : 1750) : !isShiny ? 250 : 750), + () => { + this.infoContainer.show(this.pokemon, false, this.skipped ? 2 : 1); - globalScene.playSoundWithoutBgm("evolution_fanfare"); + globalScene.playSoundWithoutBgm("evolution_fanfare"); - globalScene.ui.showText(i18next.t("egg:hatchFromTheEgg", { pokemonName: this.pokemon.species.getExpandedSpeciesName() }), null, () => { - globalScene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs); - globalScene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => { - globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then((value) => { - this.eggHatchData.setEggMoveUnlocked(value); - globalScene.ui.showText("", 0); - this.end(); - }); - }); - }, null, true, 3000); - }); + globalScene.ui.showText( + i18next.t("egg:hatchFromTheEgg", { + pokemonName: this.pokemon.species.getExpandedSpeciesName(), + }), + null, + () => { + globalScene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs); + globalScene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => { + globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then(value => { + this.eggHatchData.setEggMoveUnlocked(value); + globalScene.ui.showText("", 0); + this.end(); + }); + }); + }, + null, + true, + 3000, + ); + }, + ); }); globalScene.tweens.add({ duration: Utils.fixedInt(this.skipped ? 500 : 3000), targets: this.eggHatchOverlay, alpha: 0, - ease: "Cubic.easeOut" + ease: "Cubic.easeOut", }); } @@ -396,7 +430,7 @@ export class EggHatchPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { this.doSprayParticle(Utils.randInt(8), offsetY || 0); - } + }, }); } @@ -422,7 +456,7 @@ export class EggHatchPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -432,7 +466,7 @@ export class EggHatchPhase extends Phase { particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset); particle.y += -this.sin(trigIndex, amp); if (f > 108) { - particle.setScale((1 - (f - 108) / 20)); + particle.setScale(1 - (f - 108) / 20); } trigIndex += 2 * speedMultiplier; f += speedMultiplier; @@ -445,7 +479,6 @@ export class EggHatchPhase extends Phase { updateParticle(); } - /** * Generates a Pokemon to be hatched by the egg * Also stores the generated pokemon in this.eggHatchData diff --git a/src/phases/egg-lapse-phase.ts b/src/phases/egg-lapse-phase.ts index 62da0edf5b7..397eb970fec 100644 --- a/src/phases/egg-lapse-phase.ts +++ b/src/phases/egg-lapse-phase.ts @@ -16,12 +16,8 @@ import { EggHatchData } from "#app/data/egg-hatch-data"; * Also handles prompts for skipping animation, and calling the egg summary phase */ export class EggLapsePhase extends Phase { - private eggHatchData: EggHatchData[] = []; private readonly minEggsToSkip: number = 2; - constructor() { - super(); - } start() { super.start(); @@ -33,19 +29,37 @@ export class EggLapsePhase extends Phase { if (eggsToHatchCount > 0) { if (eggsToHatchCount >= this.minEggsToSkip && globalScene.eggSkipPreference === 1) { - globalScene.ui.showText(i18next.t("battle:eggHatching"), 0, () => { - // show prompt for skip, blocking inputs for 1 second - globalScene.ui.showText(i18next.t("battle:eggSkipPrompt", { eggsToHatch: eggsToHatchCount }), 0); - globalScene.ui.setModeWithoutClear(Mode.CONFIRM, () => { - this.hatchEggsSkipped(eggsToHatch); - this.showSummary(); - }, () => { - this.hatchEggsRegular(eggsToHatch); - this.end(); + globalScene.ui.showText( + i18next.t("battle:eggHatching"), + 0, + () => { + // show prompt for skip, blocking inputs for 1 second + globalScene.ui.showText( + i18next.t("battle:eggSkipPrompt", { + eggsToHatch: eggsToHatchCount, + }), + 0, + ); + globalScene.ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + this.hatchEggsSkipped(eggsToHatch); + this.showSummary(); + }, + () => { + this.hatchEggsRegular(eggsToHatch); + this.end(); + }, + null, + null, + null, + 1000, + true, + ); }, - null, null, null, 1000, true - ); - }, 100, true); + 100, + true, + ); } else if (eggsToHatchCount >= this.minEggsToSkip && globalScene.eggSkipPreference === 2) { globalScene.queueMessage(i18next.t("battle:eggHatching")); this.hatchEggsSkipped(eggsToHatch); @@ -118,7 +132,6 @@ export class EggLapsePhase extends Phase { if (pokemon.isShiny()) { globalScene.validateAchv(achvs.HATCH_SHINY); } - } /** @@ -129,14 +142,16 @@ export class EggLapsePhase extends Phase { generatePokemon(egg: Egg): EggHatchData { let ret: PlayerPokemon; let newHatchData: EggHatchData; - globalScene.executeWithSeedOffset(() => { - ret = egg.generatePlayerPokemon(); - newHatchData = new EggHatchData(ret, egg.eggMoveIndex); - newHatchData.setDex(); - this.eggHatchData.push(newHatchData); - - }, egg.id, EGG_SEED.toString()); + globalScene.executeWithSeedOffset( + () => { + ret = egg.generatePlayerPokemon(); + newHatchData = new EggHatchData(ret, egg.eggMoveIndex); + newHatchData.setDex(); + this.eggHatchData.push(newHatchData); + }, + egg.id, + EGG_SEED.toString(), + ); return newHatchData!; } - } diff --git a/src/phases/egg-summary-phase.ts b/src/phases/egg-summary-phase.ts index 56741c5820f..9d9259d1e67 100644 --- a/src/phases/egg-summary-phase.ts +++ b/src/phases/egg-summary-phase.ts @@ -25,7 +25,6 @@ export class EggSummaryPhase extends Phase { globalScene.ui.setModeForceTransition(Mode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => { globalScene.fadeOutBgm(undefined, false); }); - } else { this.eggHatchData[i].setDex(); this.eggHatchData[i].updatePokemon().then(() => { @@ -36,7 +35,6 @@ export class EggSummaryPhase extends Phase { } }; updateNextPokemon(0); - } end() { diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index ea8e43faeeb..5decab522b5 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -88,7 +88,9 @@ export class EncounterPhase extends BattlePhase { // Add any special encounter animations to load if (mysteryEncounter.encounterAnimations && mysteryEncounter.encounterAnimations.length > 0) { - loadEnemyAssets.push(initEncounterAnims(mysteryEncounter.encounterAnimations).then(() => loadEncounterAnimAssets(true))); + loadEnemyAssets.push( + initEncounterAnims(mysteryEncounter.encounterAnimations).then(() => loadEncounterAnimAssets(true)), + ); } // Add intro visuals for mystery encounter @@ -115,19 +117,31 @@ export class EncounterPhase extends BattlePhase { } else { let enemySpecies = globalScene.randomSpecies(battle.waveIndex, level, true); // If player has golden bug net, rolls 10% chance to replace non-boss wave wild species from the golden bug net bug pool - if (globalScene.findModifier(m => m instanceof BoostBugSpawnModifier) - && !globalScene.gameMode.isBoss(battle.waveIndex) - && globalScene.arena.biomeType !== Biome.END - && randSeedInt(10) === 0) { + if ( + globalScene.findModifier(m => m instanceof BoostBugSpawnModifier) && + !globalScene.gameMode.isBoss(battle.waveIndex) && + globalScene.arena.biomeType !== Biome.END && + randSeedInt(10) === 0 + ) { enemySpecies = getGoldenBugNetSpecies(level); } - battle.enemyParty[e] = globalScene.addEnemyPokemon(enemySpecies, level, TrainerSlot.NONE, !!globalScene.getEncounterBossSegments(battle.waveIndex, level, enemySpecies)); + battle.enemyParty[e] = globalScene.addEnemyPokemon( + enemySpecies, + level, + TrainerSlot.NONE, + !!globalScene.getEncounterBossSegments(battle.waveIndex, level, enemySpecies), + ); if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) { battle.enemyParty[e].ivs = new Array(6).fill(31); } - globalScene.getPlayerParty().slice(0, !battle.double ? 1 : 2).reverse().forEach(playerPokemon => { - applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]); - }); + // biome-ignore lint/complexity/noForEach: Improves readability + globalScene + .getPlayerParty() + .slice(0, !battle.double ? 1 : 2) + .reverse() + .forEach(playerPokemon => { + applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]); + }); } } const enemyPokemon = globalScene.getEnemyParty()[e]; @@ -137,11 +151,19 @@ export class EncounterPhase extends BattlePhase { } if (!this.loaded) { - globalScene.gameData.setPokemonSeen(enemyPokemon, true, battle.battleType === BattleType.TRAINER || battle?.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE); + globalScene.gameData.setPokemonSeen( + enemyPokemon, + true, + battle.battleType === BattleType.TRAINER || + battle?.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE, + ); } if (enemyPokemon.species.speciesId === Species.ETERNATUS) { - if (globalScene.gameMode.isClassic && (battle.battleSpec === BattleSpec.FINAL_BOSS || globalScene.gameMode.isWaveFinal(battle.waveIndex))) { + if ( + globalScene.gameMode.isClassic && + (battle.battleSpec === BattleSpec.FINAL_BOSS || globalScene.gameMode.isWaveFinal(battle.waveIndex)) + ) { if (battle.battleSpec !== BattleSpec.FINAL_BOSS) { enemyPokemon.formIndex = 1; enemyPokemon.updateScale(); @@ -166,9 +188,9 @@ export class EncounterPhase extends BattlePhase { ` Spd: ${enemyPokemon.stats[5]} (${enemyPokemon.ivs[5]})`, ]; const moveset: string[] = []; - enemyPokemon.getMoveset().forEach((move) => { + for (const move of enemyPokemon.getMoveset()) { moveset.push(move!.getName()); // TODO: remove `!` after moveset-null removal PR - }); + } console.log( `Pokemon: ${getPokemonNameWithAffix(enemyPokemon)}`, @@ -179,7 +201,7 @@ export class EncounterPhase extends BattlePhase { console.log( `Ability: ${enemyPokemon.getAbility().name}`, `| Passive Ability${enemyPokemon.hasPassive() ? "" : " (inactive)"}: ${enemyPokemon.getPassiveAbility().name}`, - `${enemyPokemon.isBoss() ? `| Boss Bars: ${enemyPokemon.bossSegments}` : ""}` + `${enemyPokemon.isBoss() ? `| Boss Bars: ${enemyPokemon.bossSegments}` : ""}`, ); console.log("Moveset:", moveset); return true; @@ -193,20 +215,26 @@ export class EncounterPhase extends BattlePhase { loadEnemyAssets.push(battle.trainer?.loadAssets().then(() => battle.trainer?.initSprite())!); // TODO: is this bang correct? } else if (battle.isBattleMysteryEncounter()) { if (battle.mysteryEncounter?.introVisuals) { - loadEnemyAssets.push(battle.mysteryEncounter.introVisuals.loadAssets().then(() => battle.mysteryEncounter!.introVisuals!.initSprite())); + loadEnemyAssets.push( + battle.mysteryEncounter.introVisuals + .loadAssets() + .then(() => battle.mysteryEncounter!.introVisuals!.initSprite()), + ); } if (battle.mysteryEncounter?.loadAssets && battle.mysteryEncounter.loadAssets.length > 0) { loadEnemyAssets.push(...battle.mysteryEncounter.loadAssets); } // Load Mystery Encounter Exclamation bubble and sfx - loadEnemyAssets.push(new Promise(resolve => { - globalScene.loadSe("GEN8- Exclaim", "battle_anims", "GEN8- Exclaim.wav"); - globalScene.loadImage("encounter_exclaim", "mystery-encounters"); - globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => resolve()); - if (!globalScene.load.isLoading()) { - globalScene.load.start(); - } - })); + loadEnemyAssets.push( + new Promise(resolve => { + globalScene.loadSe("GEN8- Exclaim", "battle_anims", "GEN8- Exclaim.wav"); + globalScene.loadImage("encounter_exclaim", "mystery-encounters"); + globalScene.load.once(Phaser.Loader.Events.COMPLETE, () => resolve()); + if (!globalScene.load.isLoading()) { + globalScene.load.start(); + } + }), + ); } else { const overridedBossSegments = Overrides.OPP_HEALTH_SEGMENTS_OVERRIDE > 1; // for double battles, reduce the health segments for boss Pokemon unless there is an override @@ -214,7 +242,10 @@ export class EncounterPhase extends BattlePhase { for (const enemyPokemon of battle.enemyParty) { // If the enemy pokemon is a boss and wasn't populated from data source, then update the number of segments if (enemyPokemon.isBoss() && !enemyPokemon.isPopulatedFromDataSource) { - enemyPokemon.setBoss(true, Math.ceil(enemyPokemon.bossSegments * (enemyPokemon.getSpeciesForm().baseTotal / totalBst))); + enemyPokemon.setBoss( + true, + Math.ceil(enemyPokemon.bossSegments * (enemyPokemon.getSpeciesForm().baseTotal / totalBst)), + ); enemyPokemon.initBattleInfo(); } } @@ -247,12 +278,16 @@ export class EncounterPhase extends BattlePhase { }); if (!this.loaded && battle.battleType !== BattleType.MYSTERY_ENCOUNTER) { - regenerateModifierPoolThresholds(globalScene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD); + regenerateModifierPoolThresholds( + globalScene.getEnemyField(), + battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD, + ); globalScene.generateEnemyModifiers(); overrideModifiers(false); - globalScene.getEnemyField().forEach(enemy => { + + for (const enemy of globalScene.getEnemyField()) { overrideHeldItems(enemy, false); - }); + } } if (battle.battleType === BattleType.TRAINER) { @@ -263,14 +298,16 @@ export class EncounterPhase extends BattlePhase { 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) - globalScene.gameData.saveAll(true, battle.waveIndex % 5 === 1 || (globalScene.lastSavePlayTime ?? 0) >= 300).then(success => { - globalScene.disableMenu = false; - if (!success) { - return globalScene.reset(true); - } - this.doEncounter(); - globalScene.resetSeed(); - }); + globalScene.gameData + .saveAll(true, battle.waveIndex % 5 === 1 || (globalScene.lastSavePlayTime ?? 0) >= 300) + .then(success => { + globalScene.disableMenu = false; + if (!success) { + return globalScene.reset(true); + } + this.doEncounter(); + globalScene.resetSeed(); + }); } else { this.doEncounter(); globalScene.resetSeed(); @@ -285,7 +322,10 @@ export class EncounterPhase extends BattlePhase { globalScene.setFieldScale(1); const { battleType, waveIndex } = globalScene.currentBattle; - if (globalScene.isMysteryEncounterValidForWave(battleType, waveIndex) && !globalScene.currentBattle.isBattleMysteryEncounter()) { + if ( + globalScene.isMysteryEncounterValidForWave(battleType, waveIndex) && + !globalScene.currentBattle.isBattleMysteryEncounter() + ) { // Increment ME spawn chance if an ME could have spawned but did not // Only do this AFTER session has been saved to avoid duplicating increments globalScene.mysteryEncounterSaveData.encounterSpawnChance += WEIGHT_INCREMENT_ON_SPAWN_MISS; @@ -299,14 +339,20 @@ export class EncounterPhase extends BattlePhase { const enemyField = globalScene.getEnemyField(); globalScene.tweens.add({ - targets: [ globalScene.arenaEnemy, globalScene.currentBattle.trainer, enemyField, globalScene.arenaPlayer, globalScene.trainer ].flat(), - x: (_target, _key, value, fieldIndex: number) => fieldIndex < 2 + (enemyField.length) ? value + 300 : value - 300, + targets: [ + globalScene.arenaEnemy, + globalScene.currentBattle.trainer, + enemyField, + globalScene.arenaPlayer, + globalScene.trainer, + ].flat(), + x: (_target, _key, value, fieldIndex: number) => (fieldIndex < 2 + enemyField.length ? value + 300 : value - 300), duration: 2000, onComplete: () => { if (!this.tryOverrideForBattleSpec()) { this.doEncounterCommon(); } - } + }, }); const encounterIntroVisuals = globalScene.currentBattle?.mysteryEncounter?.introVisuals; @@ -318,7 +364,7 @@ export class EncounterPhase extends BattlePhase { globalScene.tweens.add({ targets: encounterIntroVisuals, x: enterFromRight ? "-=200" : "+=300", - duration: 2000 + duration: 2000, }); } } @@ -327,35 +373,44 @@ export class EncounterPhase extends BattlePhase { const enemyField = globalScene.getEnemyField(); if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) { - return i18next.t("battle:bossAppeared", { bossName: getPokemonNameWithAffix(enemyField[0]) }); + return i18next.t("battle:bossAppeared", { + bossName: getPokemonNameWithAffix(enemyField[0]), + }); } if (globalScene.currentBattle.battleType === BattleType.TRAINER) { if (globalScene.currentBattle.double) { - return i18next.t("battle:trainerAppearedDouble", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }); - - } else { - return i18next.t("battle:trainerAppeared", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }); + return i18next.t("battle:trainerAppearedDouble", { + trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true), + }); } + return i18next.t("battle:trainerAppeared", { + trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true), + }); } return enemyField.length === 1 - ? i18next.t("battle:singleWildAppeared", { pokemonName: enemyField[0].getNameToRender() }) - : i18next.t("battle:multiWildAppeared", { pokemonName1: enemyField[0].getNameToRender(), pokemonName2: enemyField[1].getNameToRender() }); + ? i18next.t("battle:singleWildAppeared", { + pokemonName: enemyField[0].getNameToRender(), + }) + : i18next.t("battle:multiWildAppeared", { + pokemonName1: enemyField[0].getNameToRender(), + pokemonName2: enemyField[1].getNameToRender(), + }); } - doEncounterCommon(showEncounterMessage: boolean = true) { + doEncounterCommon(showEncounterMessage = true) { const enemyField = globalScene.getEnemyField(); if (globalScene.currentBattle.battleType === BattleType.WILD) { - enemyField.forEach(enemyPokemon => { + for (const enemyPokemon of enemyField) { enemyPokemon.untint(100, "Sine.easeOut"); enemyPokemon.cry(); enemyPokemon.showInfo(); if (enemyPokemon.isShiny()) { globalScene.validateAchv(achvs.SEE_SHINY); } - }); + } globalScene.updateFieldScale(); if (showEncounterMessage) { globalScene.ui.showText(this.getEncounterMessage(), null, () => this.end(), 1500); @@ -394,7 +449,10 @@ export class EncounterPhase extends BattlePhase { doSummon(); } else { let message: string; - globalScene.executeWithSeedOffset(() => message = randSeedItem(encounterMessages), globalScene.currentBattle.waveIndex); + globalScene.executeWithSeedOffset( + () => (message = randSeedItem(encounterMessages)), + globalScene.currentBattle.waveIndex, + ); message = message!; // tell TS compiler it's defined now const showDialogueAndSummon = () => { globalScene.ui.showDialogue(message, trainer?.getName(TrainerSlot.NONE, true), null, () => { @@ -402,7 +460,13 @@ export class EncounterPhase extends BattlePhase { }); }; if (globalScene.currentBattle.trainer?.config.hasCharSprite && !globalScene.ui.shouldSkipDialogue(message)) { - globalScene.showFieldOverlay(500).then(() => globalScene.charSprite.showCharacter(trainer?.getKey()!, getCharVariantFromDialogue(encounterMessages[0])).then(() => showDialogueAndSummon())); // TODO: is this bang correct? + globalScene + .showFieldOverlay(500) + .then(() => + globalScene.charSprite + .showCharacter(trainer?.getKey()!, getCharVariantFromDialogue(encounterMessages[0])) + .then(() => showDialogueAndSummon()), + ); // TODO: is this bang correct? } else { showDialogueAndSummon(); } @@ -442,7 +506,14 @@ export class EncounterPhase extends BattlePhase { const text = getEncounterText(dialogue.text)!; i++; if (title) { - globalScene.ui.showDialogue(text, title, null, nextAction, 0, i === 1 ? FIRST_DIALOGUE_PROMPT_DELAY : 0); + globalScene.ui.showDialogue( + text, + title, + null, + nextAction, + 0, + i === 1 ? FIRST_DIALOGUE_PROMPT_DELAY : 0, + ); } else { globalScene.ui.showText(text, null, nextAction, i === 1 ? FIRST_DIALOGUE_PROMPT_DELAY : 0, true); } @@ -478,8 +549,15 @@ export class EncounterPhase extends BattlePhase { globalScene.unshiftPhase(new ShinySparklePhase(BattlerIndex.ENEMY + e)); } /** This sets Eternatus' held item to be untransferrable, preventing it from being stolen */ - if (enemyPokemon.species.speciesId === Species.ETERNATUS && (globalScene.gameMode.isBattleClassicFinalBoss(globalScene.currentBattle.waveIndex) || globalScene.gameMode.isEndlessMajorBoss(globalScene.currentBattle.waveIndex))) { - const enemyMBH = globalScene.findModifier(m => m instanceof TurnHeldItemTransferModifier, false) as TurnHeldItemTransferModifier; + if ( + enemyPokemon.species.speciesId === Species.ETERNATUS && + (globalScene.gameMode.isBattleClassicFinalBoss(globalScene.currentBattle.waveIndex) || + globalScene.gameMode.isEndlessMajorBoss(globalScene.currentBattle.waveIndex)) + ) { + const enemyMBH = globalScene.findModifier( + m => m instanceof TurnHeldItemTransferModifier, + false, + ) as TurnHeldItemTransferModifier; if (enemyMBH) { globalScene.removeModifier(enemyMBH, true); enemyMBH.setTransferrableFalse(); @@ -488,22 +566,24 @@ export class EncounterPhase extends BattlePhase { } }); - if (![ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(globalScene.currentBattle.battleType)) { - enemyField.map(p => globalScene.pushConditionalPhase(new PostSummonPhase(p.getBattlerIndex()), () => { - // if there is not a player party, we can't continue - if (!globalScene.getPlayerParty().length) { - return false; - } - // how many player pokemon are on the field ? - const pokemonsOnFieldCount = globalScene.getPlayerParty().filter(p => p.isOnField()).length; - // if it's a 2vs1, there will never be a 2nd pokemon on our field even - const requiredPokemonsOnField = Math.min(globalScene.getPlayerParty().filter((p) => !p.isFainted()).length, 2); - // if it's a double, there should be 2, otherwise 1 - if (globalScene.currentBattle.double) { - return pokemonsOnFieldCount === requiredPokemonsOnField; - } - return pokemonsOnFieldCount === 1; - })); + if (![BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER].includes(globalScene.currentBattle.battleType)) { + enemyField.map(p => + globalScene.pushConditionalPhase(new PostSummonPhase(p.getBattlerIndex()), () => { + // if there is not a player party, we can't continue + if (!globalScene.getPlayerParty().length) { + return false; + } + // how many player pokemon are on the field ? + const pokemonsOnFieldCount = globalScene.getPlayerParty().filter(p => p.isOnField()).length; + // if it's a 2vs1, there will never be a 2nd pokemon on our field even + const requiredPokemonsOnField = Math.min(globalScene.getPlayerParty().filter(p => !p.isFainted()).length, 2); + // if it's a double, there should be 2, otherwise 1 + if (globalScene.currentBattle.double) { + return pokemonsOnFieldCount === requiredPokemonsOnField; + } + return pokemonsOnFieldCount === 1; + }), + ); const ivScannerModifier = globalScene.findModifier(m => m instanceof IvScannerModifier); if (ivScannerModifier) { enemyField.map(p => globalScene.pushPhase(new ScanIvsPhase(p.getBattlerIndex()))); @@ -531,7 +611,10 @@ export class EncounterPhase extends BattlePhase { globalScene.pushPhase(new ToggleDoublePositionPhase(false)); } - if (globalScene.currentBattle.battleType !== BattleType.TRAINER && (globalScene.currentBattle.waveIndex > 1 || !globalScene.gameMode.isDaily)) { + if ( + globalScene.currentBattle.battleType !== BattleType.TRAINER && + (globalScene.currentBattle.waveIndex > 1 || !globalScene.gameMode.isDaily) + ) { const minPartySize = globalScene.currentBattle.double ? 2 : 1; if (availablePartyMembers.length > minPartySize) { globalScene.pushPhase(new CheckSwitchPhase(0, globalScene.currentBattle.double)); @@ -546,31 +629,47 @@ export class EncounterPhase extends BattlePhase { tryOverrideForBattleSpec(): boolean { switch (globalScene.currentBattle.battleSpec) { - case BattleSpec.FINAL_BOSS: + case BattleSpec.FINAL_BOSS: { const enemy = globalScene.getEnemyPokemon(); - globalScene.ui.showText(this.getEncounterMessage(), null, () => { - const localizationKey = "battleSpecDialogue:encounter"; - if (globalScene.ui.shouldSkipDialogue(localizationKey)) { - // Logging mirrors logging found in dialogue-ui-handler - console.log(`Dialogue ${localizationKey} skipped`); - this.doEncounterCommon(false); - } else { - const count = 5643853 + globalScene.gameData.gameStats.classicSessionsPlayed; - // The line below checks if an English ordinal is necessary or not based on whether an entry for encounterLocalizationKey exists in the language or not. - const ordinalUsed = !i18next.exists(localizationKey, { fallbackLng: []}) || i18next.resolvedLanguage === "en" ? i18next.t("battleSpecDialogue:key", { count: count, ordinal: true }) : ""; - const cycleCount = count.toLocaleString() + ordinalUsed; - const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; - const genderStr = PlayerGender[genderIndex].toLowerCase(); - const encounterDialogue = i18next.t(localizationKey, { context: genderStr, cycleCount: cycleCount }); - if (!globalScene.gameData.getSeenDialogues()[localizationKey]) { - globalScene.gameData.saveSeenDialogue(localizationKey); - } - globalScene.ui.showDialogue(encounterDialogue, enemy?.species.name, null, () => { + globalScene.ui.showText( + this.getEncounterMessage(), + null, + () => { + const localizationKey = "battleSpecDialogue:encounter"; + if (globalScene.ui.shouldSkipDialogue(localizationKey)) { + // Logging mirrors logging found in dialogue-ui-handler + console.log(`Dialogue ${localizationKey} skipped`); this.doEncounterCommon(false); - }); - } - }, 1500, true); + } else { + const count = 5643853 + globalScene.gameData.gameStats.classicSessionsPlayed; + // The line below checks if an English ordinal is necessary or not based on whether an entry for encounterLocalizationKey exists in the language or not. + const ordinalUsed = + !i18next.exists(localizationKey, { fallbackLng: [] }) || i18next.resolvedLanguage === "en" + ? i18next.t("battleSpecDialogue:key", { + count: count, + ordinal: true, + }) + : ""; + const cycleCount = count.toLocaleString() + ordinalUsed; + const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; + const genderStr = PlayerGender[genderIndex].toLowerCase(); + const encounterDialogue = i18next.t(localizationKey, { + context: genderStr, + cycleCount: cycleCount, + }); + if (!globalScene.gameData.getSeenDialogues()[localizationKey]) { + globalScene.gameData.saveSeenDialogue(localizationKey); + } + globalScene.ui.showDialogue(encounterDialogue, enemy?.species.name, null, () => { + this.doEncounterCommon(false); + }); + } + }, + 1500, + true, + ); return true; + } } return false; } diff --git a/src/phases/end-card-phase.ts b/src/phases/end-card-phase.ts index 4615a60e661..41775248b67 100644 --- a/src/phases/end-card-phase.ts +++ b/src/phases/end-card-phase.ts @@ -7,34 +7,44 @@ import i18next from "i18next"; export class EndCardPhase extends Phase { public endCard: Phaser.GameObjects.Image; public text: Phaser.GameObjects.Text; - - constructor() { - super(); - } - start(): void { super.start(); globalScene.ui.getMessageHandler().bg.setVisible(false); globalScene.ui.getMessageHandler().nameBoxContainer.setVisible(false); - this.endCard = globalScene.add.image(0, 0, `end_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}`); + this.endCard = globalScene.add.image( + 0, + 0, + `end_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}`, + ); this.endCard.setOrigin(0); this.endCard.setScale(0.5); globalScene.field.add(this.endCard); - this.text = addTextObject(globalScene.game.canvas.width / 12, (globalScene.game.canvas.height / 6) - 16, i18next.t("battle:congratulations"), TextStyle.SUMMARY, { fontSize: "128px" }); + this.text = addTextObject( + globalScene.game.canvas.width / 12, + globalScene.game.canvas.height / 6 - 16, + i18next.t("battle:congratulations"), + TextStyle.SUMMARY, + { fontSize: "128px" }, + ); this.text.setOrigin(0.5); globalScene.field.add(this.text); globalScene.ui.clearText(); globalScene.ui.fadeIn(1000).then(() => { - - globalScene.ui.showText("", null, () => { - globalScene.ui.getMessageHandler().bg.setVisible(true); - this.end(); - }, null, true); + globalScene.ui.showText( + "", + null, + () => { + globalScene.ui.getMessageHandler().bg.setVisible(true); + this.end(); + }, + null, + true, + ); }); } } diff --git a/src/phases/end-evolution-phase.ts b/src/phases/end-evolution-phase.ts index 58e2e203482..e0bdc7e0d68 100644 --- a/src/phases/end-evolution-phase.ts +++ b/src/phases/end-evolution-phase.ts @@ -3,11 +3,6 @@ import { Phase } from "#app/phase"; import { Mode } from "#app/ui/ui"; export class EndEvolutionPhase extends Phase { - - constructor() { - super(); - } - start() { super.start(); diff --git a/src/phases/enemy-command-phase.ts b/src/phases/enemy-command-phase.ts index 429674e7786..2e4861aacfc 100644 --- a/src/phases/enemy-command-phase.ts +++ b/src/phases/enemy-command-phase.ts @@ -16,7 +16,7 @@ import { BattlerTagType } from "#enums/battler-tag-type"; */ export class EnemyCommandPhase extends FieldPhase { protected fieldIndex: number; - protected skipTurn: boolean = false; + protected skipTurn = false; constructor(fieldIndex: number) { super(); @@ -36,20 +36,23 @@ export class EnemyCommandPhase extends FieldPhase { const trainer = battle.trainer; - if (battle.double && enemyPokemon.hasAbility(Abilities.COMMANDER) - && enemyPokemon.getAlly().getTag(BattlerTagType.COMMANDED)) { + if ( + battle.double && + enemyPokemon.hasAbility(Abilities.COMMANDER) && + enemyPokemon.getAlly().getTag(BattlerTagType.COMMANDED) + ) { this.skipTurn = true; } /** - * If the enemy has a trainer, decide whether or not the enemy should switch - * to another member in its party. - * - * This block compares the active enemy Pokemon's {@linkcode Pokemon.getMatchupScore | matchup score} - * against the active player Pokemon with the enemy party's other non-fainted Pokemon. If a party - * member's matchup score is 3x the active enemy's score (or 2x for "boss" trainers), - * the enemy will switch to that Pokemon. - */ + * If the enemy has a trainer, decide whether or not the enemy should switch + * to another member in its party. + * + * This block compares the active enemy Pokemon's {@linkcode Pokemon.getMatchupScore | matchup score} + * against the active player Pokemon with the enemy party's other non-fainted Pokemon. If a party + * member's matchup score is 3x the active enemy's score (or 2x for "boss" trainers), + * the enemy will switch to that Pokemon. + */ if (trainer && !enemyPokemon.getMoveQueue().length) { const opponents = enemyPokemon.getOpponents(); @@ -58,17 +61,21 @@ export class EnemyCommandPhase extends FieldPhase { if (partyMemberScores.length) { const matchupScores = opponents.map(opp => enemyPokemon.getMatchupScore(opp)); - const matchupScore = matchupScores.reduce((total, score) => total += score, 0) / matchupScores.length; + const matchupScore = matchupScores.reduce((total, score) => (total += score), 0) / matchupScores.length; const sortedPartyMemberScores = trainer.getSortedPartyMemberMatchupScores(partyMemberScores); - const switchMultiplier = 1 - (battle.enemySwitchCounter ? Math.pow(0.1, (1 / battle.enemySwitchCounter)) : 0); + const switchMultiplier = 1 - (battle.enemySwitchCounter ? Math.pow(0.1, 1 / battle.enemySwitchCounter) : 0); if (sortedPartyMemberScores[0][1] * switchMultiplier >= matchupScore * (trainer.config.isBoss ? 2 : 3)) { const index = trainer.getNextSummonIndex(enemyPokemon.trainerSlot, partyMemberScores); - battle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = - { command: Command.POKEMON, cursor: index, args: [ false ], skip: this.skipTurn }; + battle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = { + command: Command.POKEMON, + cursor: index, + args: [false], + skip: this.skipTurn, + }; battle.enemySwitchCounter++; @@ -81,12 +88,15 @@ export class EnemyCommandPhase extends FieldPhase { /** Select a move to use (and a target to use it against, if applicable) */ const nextMove = enemyPokemon.getNextMove(); - if (trainer && trainer.shouldTera(enemyPokemon)) { + if (trainer?.shouldTera(enemyPokemon)) { globalScene.currentBattle.preTurnCommands[this.fieldIndex + BattlerIndex.ENEMY] = { command: Command.TERA }; } - globalScene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = - { command: Command.FIGHT, move: nextMove, skip: this.skipTurn }; + globalScene.currentBattle.turnCommands[this.fieldIndex + BattlerIndex.ENEMY] = { + command: Command.FIGHT, + move: nextMove, + skip: this.skipTurn, + }; globalScene.currentBattle.enemySwitchCounter = Math.max(globalScene.currentBattle.enemySwitchCounter - 1, 0); diff --git a/src/phases/evolution-phase.ts b/src/phases/evolution-phase.ts index ea857cac8ba..bb283fa8139 100644 --- a/src/phases/evolution-phase.ts +++ b/src/phases/evolution-phase.ts @@ -60,7 +60,6 @@ export class EvolutionPhase extends Phase { super.start(); this.setMode().then(() => { - if (!this.validate()) { return this.end(); } @@ -81,14 +80,28 @@ export class EvolutionPhase extends Phase { this.evolutionBg.setVisible(false); this.evolutionContainer.add(this.evolutionBg); - this.evolutionBgOverlay = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x262626); + this.evolutionBgOverlay = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0x262626, + ); this.evolutionBgOverlay.setOrigin(0, 0); this.evolutionBgOverlay.setAlpha(0); this.evolutionContainer.add(this.evolutionBgOverlay); const getPokemonSprite = () => { - const ret = globalScene.addPokemonSprite(this.pokemon, this.evolutionBaseBg.displayWidth / 2, this.evolutionBaseBg.displayHeight / 2, "pkmn__sub"); - ret.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + const ret = globalScene.addPokemonSprite( + this.pokemon, + this.evolutionBaseBg.displayWidth / 2, + this.evolutionBaseBg.displayHeight / 2, + "pkmn__sub", + ); + ret.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); return ret; }; @@ -98,17 +111,23 @@ export class EvolutionPhase extends Phase { this.evolutionContainer.add((this.pokemonEvoTintSprite = getPokemonSprite())); this.pokemonTintSprite.setAlpha(0); - this.pokemonTintSprite.setTintFill(0xFFFFFF); + this.pokemonTintSprite.setTintFill(0xffffff); this.pokemonEvoSprite.setVisible(false); this.pokemonEvoTintSprite.setVisible(false); - this.pokemonEvoTintSprite.setTintFill(0xFFFFFF); + this.pokemonEvoTintSprite.setTintFill(0xffffff); - this.evolutionOverlay = globalScene.add.rectangle(0, -globalScene.game.canvas.height / 6, globalScene.game.canvas.width / 6, (globalScene.game.canvas.height / 6) - 48, 0xFFFFFF); + this.evolutionOverlay = globalScene.add.rectangle( + 0, + -globalScene.game.canvas.height / 6, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6 - 48, + 0xffffff, + ); this.evolutionOverlay.setOrigin(0, 0); this.evolutionOverlay.setAlpha(0); globalScene.ui.add(this.evolutionOverlay); - [ this.pokemonSprite, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { + [this.pokemonSprite, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite].map(sprite => { const spriteKey = this.pokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -116,12 +135,17 @@ export class EvolutionPhase extends Phase { console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()), isTerastallized: this.pokemon.isTerastallized }); + sprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: false, + teraColor: getTypeRgb(this.pokemon.getTeraType()), + isTerastallized: this.pokemon.isTerastallized, + }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey()); sprite.setPipelineData("shiny", this.pokemon.shiny); sprite.setPipelineData("variant", this.pokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (this.pokemon.summonData?.speciesForm) { k += "Base"; } @@ -134,83 +158,87 @@ export class EvolutionPhase extends Phase { } doEvolution(): void { - globalScene.ui.showText(i18next.t("menu:evolving", { pokemonName: this.preEvolvedPokemonName }), null, () => { - this.pokemon.cry(); + globalScene.ui.showText( + i18next.t("menu:evolving", { pokemonName: this.preEvolvedPokemonName }), + null, + () => { + this.pokemon.cry(); - this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => { - - [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { - const spriteKey = evolvedPokemon.getSpriteKey(true); - try { - sprite.play(spriteKey); - } catch (err: unknown) { - console.error(`Failed to play animation for ${spriteKey}`, err); - } - - sprite.setPipelineData("ignoreTimeTint", true); - sprite.setPipelineData("spriteKey", evolvedPokemon.getSpriteKey()); - sprite.setPipelineData("shiny", evolvedPokemon.shiny); - sprite.setPipelineData("variant", evolvedPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { - if (evolvedPokemon.summonData?.speciesForm) { - k += "Base"; + this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => { + [this.pokemonEvoSprite, this.pokemonEvoTintSprite].map(sprite => { + const spriteKey = evolvedPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k]; - }); - }); - globalScene.time.delayedCall(1000, () => { - this.evolutionBgm = globalScene.playSoundWithoutBgm("evolution"); - globalScene.tweens.add({ - targets: this.evolutionBgOverlay, - alpha: 1, - delay: 500, - duration: 1500, - ease: "Sine.easeOut", - onComplete: () => { - globalScene.time.delayedCall(1000, () => { - globalScene.tweens.add({ - targets: this.evolutionBgOverlay, - alpha: 0, - duration: 250 + sprite.setPipelineData("ignoreTimeTint", true); + sprite.setPipelineData("spriteKey", evolvedPokemon.getSpriteKey()); + sprite.setPipelineData("shiny", evolvedPokemon.shiny); + sprite.setPipelineData("variant", evolvedPokemon.variant); + ["spriteColors", "fusionSpriteColors"].map(k => { + if (evolvedPokemon.summonData?.speciesForm) { + k += "Base"; + } + sprite.pipelineData[k] = evolvedPokemon.getSprite().pipelineData[k]; + }); + }); + + globalScene.time.delayedCall(1000, () => { + this.evolutionBgm = globalScene.playSoundWithoutBgm("evolution"); + globalScene.tweens.add({ + targets: this.evolutionBgOverlay, + alpha: 1, + delay: 500, + duration: 1500, + ease: "Sine.easeOut", + onComplete: () => { + globalScene.time.delayedCall(1000, () => { + globalScene.tweens.add({ + targets: this.evolutionBgOverlay, + alpha: 0, + duration: 250, + }); + this.evolutionBg.setVisible(true); + this.evolutionBg.play(); }); - this.evolutionBg.setVisible(true); - this.evolutionBg.play(); - }); - globalScene.playSound("se/charge"); - this.doSpiralUpward(); - globalScene.tweens.addCounter({ - from: 0, - to: 1, - duration: 2000, - onUpdate: t => { - this.pokemonTintSprite.setAlpha(t.getValue()); - }, - onComplete: () => { - this.pokemonSprite.setVisible(false); - globalScene.time.delayedCall(1100, () => { - globalScene.playSound("se/beam"); - this.doArcDownward(); - globalScene.time.delayedCall(1500, () => { - this.pokemonEvoTintSprite.setScale(0.25); - this.pokemonEvoTintSprite.setVisible(true); - this.evolutionHandler.canCancel = true; - this.doCycle(1).then(success => { - if (success) { - this.handleSuccessEvolution(evolvedPokemon); - } else { - this.handleFailedEvolution(evolvedPokemon); - } + globalScene.playSound("se/charge"); + this.doSpiralUpward(); + globalScene.tweens.addCounter({ + from: 0, + to: 1, + duration: 2000, + onUpdate: t => { + this.pokemonTintSprite.setAlpha(t.getValue()); + }, + onComplete: () => { + this.pokemonSprite.setVisible(false); + globalScene.time.delayedCall(1100, () => { + globalScene.playSound("se/beam"); + this.doArcDownward(); + globalScene.time.delayedCall(1500, () => { + this.pokemonEvoTintSprite.setScale(0.25); + this.pokemonEvoTintSprite.setVisible(true); + this.evolutionHandler.canCancel = true; + this.doCycle(1).then(success => { + if (success) { + this.handleSuccessEvolution(evolvedPokemon); + } else { + this.handleFailedEvolution(evolvedPokemon); + } + }); }); }); - }); - } - }); - } + }, + }); + }, + }); }); }); - }); - }, 1000); + }, + 1000, + ); } /** @@ -221,36 +249,61 @@ export class EvolutionPhase extends Phase { this.pokemonSprite.setVisible(true); this.pokemonTintSprite.setScale(1); globalScene.tweens.add({ - targets: [ this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ], + targets: [this.evolutionBg, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite], alpha: 0, duration: 250, onComplete: () => { this.evolutionBg.setVisible(false); - } + }, }); SoundFade.fadeOut(globalScene, this.evolutionBgm, 100); globalScene.unshiftPhase(new EndEvolutionPhase()); - globalScene.ui.showText(i18next.t("menu:stoppedEvolving", { pokemonName: this.preEvolvedPokemonName }), null, () => { - globalScene.ui.showText(i18next.t("menu:pauseEvolutionsQuestion", { pokemonName: this.preEvolvedPokemonName }), null, () => { - const end = () => { - globalScene.ui.showText("", 0); - globalScene.playBgm(); - evolvedPokemon.destroy(); - this.end(); - }; - globalScene.ui.setOverlayMode(Mode.CONFIRM, () => { - globalScene.ui.revertMode(); - this.pokemon.pauseEvolutions = true; - globalScene.ui.showText(i18next.t("menu:evolutionsPaused", { pokemonName: this.preEvolvedPokemonName }), null, end, 3000); - }, () => { - globalScene.ui.revertMode(); - globalScene.time.delayedCall(3000, end); - }); - }); - }, null, true); + globalScene.ui.showText( + i18next.t("menu:stoppedEvolving", { + pokemonName: this.preEvolvedPokemonName, + }), + null, + () => { + globalScene.ui.showText( + i18next.t("menu:pauseEvolutionsQuestion", { + pokemonName: this.preEvolvedPokemonName, + }), + null, + () => { + const end = () => { + globalScene.ui.showText("", 0); + globalScene.playBgm(); + evolvedPokemon.destroy(); + this.end(); + }; + globalScene.ui.setOverlayMode( + Mode.CONFIRM, + () => { + globalScene.ui.revertMode(); + this.pokemon.pauseEvolutions = true; + globalScene.ui.showText( + i18next.t("menu:evolutionsPaused", { + pokemonName: this.preEvolvedPokemonName, + }), + null, + end, + 3000, + ); + }, + () => { + globalScene.ui.revertMode(); + globalScene.time.delayedCall(3000, end); + }, + ); + }, + ); + }, + null, + true, + ); } /** @@ -270,7 +323,17 @@ export class EvolutionPhase extends Phase { globalScene.playSoundWithoutBgm("evolution_fanfare"); evolvedPokemon.destroy(); - globalScene.ui.showText(i18next.t("menu:evolutionDone", { pokemonName: this.preEvolvedPokemonName, evolvedPokemonName: this.pokemon.species.getExpandedSpeciesName() }), null, () => this.end(), null, true, Utils.fixedInt(4000)); + globalScene.ui.showText( + i18next.t("menu:evolutionDone", { + pokemonName: this.preEvolvedPokemonName, + evolvedPokemonName: this.pokemon.species.getExpandedSpeciesName(), + }), + null, + () => this.end(), + null, + true, + Utils.fixedInt(4000), + ); globalScene.time.delayedCall(Utils.fixedInt(4250), () => globalScene.playBgm()); }); }); @@ -280,8 +343,14 @@ export class EvolutionPhase extends Phase { this.evolutionHandler.canCancel = false; this.pokemon.evolve(this.evolution, this.pokemon.species).then(() => { - const learnSituation: LearnMoveSituation = this.fusionSpeciesEvolved ? LearnMoveSituation.EVOLUTION_FUSED : this.pokemon.fusionSpecies ? LearnMoveSituation.EVOLUTION_FUSED_BASE : LearnMoveSituation.EVOLUTION; - const levelMoves = this.pokemon.getLevelMoves(this.lastLevel + 1, true, false, false, learnSituation).filter(lm => lm[0] === EVOLVE_MOVE); + const learnSituation: LearnMoveSituation = this.fusionSpeciesEvolved + ? LearnMoveSituation.EVOLUTION_FUSED + : this.pokemon.fusionSpecies + ? LearnMoveSituation.EVOLUTION_FUSED_BASE + : LearnMoveSituation.EVOLUTION; + const levelMoves = this.pokemon + .getLevelMoves(this.lastLevel + 1, true, false, false, learnSituation) + .filter(lm => lm[0] === EVOLVE_MOVE); for (const lm of levelMoves) { globalScene.unshiftPhase(new LearnMovePhase(globalScene.getPlayerParty().indexOf(this.pokemon), lm[1])); } @@ -298,7 +367,7 @@ export class EvolutionPhase extends Phase { this.evolutionBgOverlay.setAlpha(1); this.evolutionBg.setVisible(false); globalScene.tweens.add({ - targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ], + targets: [this.evolutionOverlay, this.pokemonEvoTintSprite], alpha: 0, duration: 2000, delay: 150, @@ -308,11 +377,11 @@ export class EvolutionPhase extends Phase { targets: this.evolutionBgOverlay, alpha: 0, duration: 250, - onComplete: onEvolutionComplete + onComplete: onEvolutionComplete, }); - } + }, }); - } + }, }); }); }); @@ -333,7 +402,7 @@ export class EvolutionPhase extends Phase { } f++; } - } + }, }); } @@ -352,11 +421,11 @@ export class EvolutionPhase extends Phase { } f++; } - } + }, }); } - doCycle(l: number, lastCycle: number = 15): Promise { + doCycle(l: number, lastCycle = 15): Promise { return new Promise(resolve => { const isLastCycle = l === lastCycle; globalScene.tweens.add({ @@ -364,7 +433,7 @@ export class EvolutionPhase extends Phase { scale: 0.25, ease: "Cubic.easeInOut", duration: 500 / l, - yoyo: !isLastCycle + yoyo: !isLastCycle, }); globalScene.tweens.add({ targets: this.pokemonEvoTintSprite, @@ -382,7 +451,7 @@ export class EvolutionPhase extends Phase { this.pokemonTintSprite.setVisible(false); resolve(true); } - } + }, }); }); } @@ -404,7 +473,7 @@ export class EvolutionPhase extends Phase { } } f++; - } + }, }); } @@ -423,7 +492,7 @@ export class EvolutionPhase extends Phase { this.doSprayParticle(Utils.randInt(8)); } f++; - } + }, }); } @@ -440,7 +509,7 @@ export class EvolutionPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -448,7 +517,7 @@ export class EvolutionPhase extends Phase { particle.setPosition(initialX, 88 - (f * f) / 80); particle.y += sin(trigIndex, amp) / 4; particle.x += cos(trigIndex, amp); - particle.setScale(1 - (f / 80)); + particle.setScale(1 - f / 80); trigIndex += 4; if (f & 1) { amp--; @@ -477,7 +546,7 @@ export class EvolutionPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -509,7 +578,7 @@ export class EvolutionPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -544,7 +613,7 @@ export class EvolutionPhase extends Phase { duration: Utils.getFrameMs(1), onRepeat: () => { updateParticle(); - } + }, }); const updateParticle = () => { @@ -555,7 +624,7 @@ export class EvolutionPhase extends Phase { particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset); particle.y += -sin(trigIndex, amp); if (f > 108) { - particle.setScale((1 - (f - 108) / 20)); + particle.setScale(1 - (f - 108) / 20); } trigIndex++; f++; diff --git a/src/phases/exp-phase.ts b/src/phases/exp-phase.ts index 7cf953851a1..092482d4c18 100644 --- a/src/phases/exp-phase.ts +++ b/src/phases/exp-phase.ts @@ -22,14 +22,23 @@ export class ExpPhase extends PlayerPartyMemberPokemonPhase { const exp = new Utils.NumberHolder(this.expValue); globalScene.applyModifiers(ExpBoosterModifier, true, exp); exp.value = Math.floor(exp.value); - globalScene.ui.showText(i18next.t("battle:expGain", { pokemonName: getPokemonNameWithAffix(pokemon), exp: exp.value }), null, () => { - const lastLevel = pokemon.level; - pokemon.addExp(exp.value); - const newLevel = pokemon.level; - if (newLevel > lastLevel) { - globalScene.unshiftPhase(new LevelUpPhase(this.partyMemberIndex, lastLevel, newLevel)); - } - pokemon.updateInfo().then(() => this.end()); - }, null, true); + globalScene.ui.showText( + i18next.t("battle:expGain", { + pokemonName: getPokemonNameWithAffix(pokemon), + exp: exp.value, + }), + null, + () => { + const lastLevel = pokemon.level; + pokemon.addExp(exp.value); + const newLevel = pokemon.level; + if (newLevel > lastLevel) { + globalScene.unshiftPhase(new LevelUpPhase(this.partyMemberIndex, lastLevel, newLevel)); + } + pokemon.updateInfo().then(() => this.end()); + }, + null, + true, + ); } } diff --git a/src/phases/faint-phase.ts b/src/phases/faint-phase.ts index a6b9a482ba0..7fc7a517853 100644 --- a/src/phases/faint-phase.ts +++ b/src/phases/faint-phase.ts @@ -1,7 +1,14 @@ import type { BattlerIndex } from "#app/battle"; import { BattleType } from "#app/battle"; import { globalScene } from "#app/global-scene"; -import { applyPostFaintAbAttrs, applyPostKnockOutAbAttrs, applyPostVictoryAbAttrs, PostFaintAbAttr, PostKnockOutAbAttr, PostVictoryAbAttr } from "#app/data/ability"; +import { + applyPostFaintAbAttrs, + applyPostKnockOutAbAttrs, + applyPostVictoryAbAttrs, + PostFaintAbAttr, + PostKnockOutAbAttr, + PostVictoryAbAttr, +} from "#app/data/ability"; import type { DestinyBondTag, GrudgeTag } from "#app/data/battler-tags"; import { BattlerTagLapseType } from "#app/data/battler-tags"; import { battleSpecDialogue } from "#app/data/dialogue"; @@ -47,7 +54,13 @@ export class FaintPhase extends PokemonPhase { */ private source?: Pokemon; - constructor(battlerIndex: BattlerIndex, preventEndure: boolean = false, destinyTag?: DestinyBondTag | null, grudgeTag?: GrudgeTag | null, source?: Pokemon) { + constructor( + battlerIndex: BattlerIndex, + preventEndure = false, + destinyTag?: DestinyBondTag | null, + grudgeTag?: GrudgeTag | null, + source?: Pokemon, + ) { super(battlerIndex); this.preventEndure = preventEndure; @@ -70,7 +83,11 @@ export class FaintPhase extends PokemonPhase { } if (!this.preventEndure) { - const instantReviveModifier = globalScene.applyModifier(PokemonInstantReviveModifier, this.player, faintPokemon) as PokemonInstantReviveModifier; + const instantReviveModifier = globalScene.applyModifier( + PokemonInstantReviveModifier, + this.player, + faintPokemon, + ) as PokemonInstantReviveModifier; if (instantReviveModifier) { faintPokemon.loseHeldItem(instantReviveModifier); @@ -80,13 +97,11 @@ export class FaintPhase extends PokemonPhase { } /** In case the current pokemon was just switched in, make sure it is counted as participating in the combat */ - globalScene.getPlayerField().forEach((pokemon, i) => { - if (pokemon?.isActive(true)) { - if (pokemon.isPlayer()) { - globalScene.currentBattle.addParticipant(pokemon as PlayerPokemon); - } + for (const pokemon of globalScene.getPlayerField()) { + if (pokemon?.isActive(true) && pokemon.isPlayer()) { + globalScene.currentBattle.addParticipant(pokemon as PlayerPokemon); } - }); + } if (!this.tryOverrideForBattleSpec()) { this.doFaint(); @@ -99,26 +114,47 @@ export class FaintPhase extends PokemonPhase { // Track total times pokemon have been KO'd for Last Respects/Supreme Overlord if (pokemon.isPlayer()) { globalScene.arena.playerFaints += 1; - globalScene.currentBattle.playerFaintsHistory.push({ pokemon: pokemon, turn: globalScene.currentBattle.turn }); + globalScene.currentBattle.playerFaintsHistory.push({ + pokemon: pokemon, + turn: globalScene.currentBattle.turn, + }); } else { globalScene.currentBattle.enemyFaints += 1; - globalScene.currentBattle.enemyFaintsHistory.push({ pokemon: pokemon, turn: globalScene.currentBattle.turn }); + globalScene.currentBattle.enemyFaintsHistory.push({ + pokemon: pokemon, + turn: globalScene.currentBattle.turn, + }); } - globalScene.queueMessage(i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), null, true); + globalScene.queueMessage( + i18next.t("battle:fainted", { + pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), + }), + null, + true, + ); globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true); pokemon.resetTera(); if (pokemon.turnData?.attacksReceived?.length) { const lastAttack = pokemon.turnData.attacksReceived[0]; - applyPostFaintAbAttrs(PostFaintAbAttr, pokemon, globalScene.getPokemonById(lastAttack.sourceId)!, new PokemonMove(lastAttack.move).getMove(), lastAttack.result); // TODO: is this bang correct? - } else { //If killed by indirect damage, apply post-faint abilities without providing a last move + applyPostFaintAbAttrs( + PostFaintAbAttr, + pokemon, + globalScene.getPokemonById(lastAttack.sourceId)!, + new PokemonMove(lastAttack.move).getMove(), + lastAttack.result, + ); // TODO: is this bang correct? + } else { + //If killed by indirect damage, apply post-faint abilities without providing a last move applyPostFaintAbAttrs(PostFaintAbAttr, pokemon); } const alivePlayField = globalScene.getField(true); - alivePlayField.forEach(p => applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon)); + for (const p of alivePlayField) { + applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon); + } if (pokemon.turnData?.attacksReceived?.length) { const defeatSource = this.source; @@ -142,7 +178,11 @@ export class FaintPhase extends PokemonPhase { if (!legalPlayerPokemon.length) { /** If the player doesn't have any legal Pokemon, end the game */ globalScene.unshiftPhase(new GameOverPhase()); - } else if (globalScene.currentBattle.double && legalPlayerPokemon.length === 1 && legalPlayerPartyPokemon.length === 0) { + } else if ( + globalScene.currentBattle.double && + legalPlayerPokemon.length === 1 && + legalPlayerPartyPokemon.length === 0 + ) { /** * If the player has exactly one Pokemon in total at this point in a double battle, and that Pokemon * is already on the field, unshift a phase that moves that Pokemon to center position. @@ -157,8 +197,11 @@ export class FaintPhase extends PokemonPhase { } } else { globalScene.unshiftPhase(new VictoryPhase(this.battlerIndex)); - if ([ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(globalScene.currentBattle.battleType)) { - const hasReservePartyMember = !!globalScene.getEnemyParty().filter(p => p.isActive() && !p.isOnField() && p.trainerSlot === (pokemon as EnemyPokemon).trainerSlot).length; + if ([BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER].includes(globalScene.currentBattle.battleType)) { + const hasReservePartyMember = !!globalScene + .getEnemyParty() + .filter(p => p.isActive() && !p.isOnField() && p.trainerSlot === (pokemon as EnemyPokemon).trainerSlot) + .length; if (hasReservePartyMember) { globalScene.pushPhase(new SwitchSummonPhase(SwitchType.SWITCH, this.fieldIndex, -1, false, false)); } @@ -195,7 +238,7 @@ export class FaintPhase extends PokemonPhase { } pokemon.leaveField(); this.end(); - } + }, }); }); } @@ -206,9 +249,14 @@ export class FaintPhase extends PokemonPhase { if (!this.player) { const enemy = this.getPokemon(); if (enemy.formIndex) { - globalScene.ui.showDialogue(battleSpecDialogue[BattleSpec.FINAL_BOSS].secondStageWin, enemy.species.name, null, () => this.doFaint()); + globalScene.ui.showDialogue( + battleSpecDialogue[BattleSpec.FINAL_BOSS].secondStageWin, + enemy.species.name, + null, + () => this.doFaint(), + ); } else { - // Final boss' HP threshold has been bypassed; cancel faint and force check for 2nd phase + // Final boss' HP threshold has been bypassed; cancel faint and force check for 2nd phase enemy.hp++; globalScene.unshiftPhase(new DamageAnimPhase(enemy.getBattlerIndex(), 0, HitResult.OTHER)); this.end(); diff --git a/src/phases/field-phase.ts b/src/phases/field-phase.ts index 0836d1171c0..98c1ced510f 100644 --- a/src/phases/field-phase.ts +++ b/src/phases/field-phase.ts @@ -7,6 +7,8 @@ type PokemonFunc = (pokemon: Pokemon) => void; export abstract class FieldPhase extends BattlePhase { executeForAll(func: PokemonFunc): void { const field = globalScene.getField(true).filter(p => p.summonData); - field.forEach(pokemon => func(pokemon)); + for (const pokemon of field) { + func(pokemon); + } } } diff --git a/src/phases/form-change-phase.ts b/src/phases/form-change-phase.ts index 353fed7b76c..e0ec4e87600 100644 --- a/src/phases/form-change-phase.ts +++ b/src/phases/form-change-phase.ts @@ -38,8 +38,7 @@ export class FormChangePhase extends EvolutionPhase { const preName = getPokemonNameWithAffix(this.pokemon); this.pokemon.getPossibleForm(this.formChange).then(transformedPokemon => { - - [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { + [this.pokemonEvoSprite, this.pokemonEvoTintSprite].map(sprite => { const spriteKey = transformedPokemon.getSpriteKey(true); try { sprite.play(spriteKey); @@ -51,7 +50,7 @@ export class FormChangePhase extends EvolutionPhase { sprite.setPipelineData("spriteKey", transformedPokemon.getSpriteKey()); sprite.setPipelineData("shiny", transformedPokemon.shiny); sprite.setPipelineData("variant", transformedPokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { if (transformedPokemon.summonData?.speciesForm) { k += "Base"; } @@ -71,7 +70,7 @@ export class FormChangePhase extends EvolutionPhase { globalScene.tweens.add({ targets: this.evolutionBgOverlay, alpha: 0, - duration: 250 + duration: 250, }); this.evolutionBg.setVisible(true); this.evolutionBg.play(); @@ -114,7 +113,7 @@ export class FormChangePhase extends EvolutionPhase { this.evolutionBgOverlay.setAlpha(1); this.evolutionBg.setVisible(false); globalScene.tweens.add({ - targets: [ this.evolutionOverlay, this.pokemonEvoTintSprite ], + targets: [this.evolutionOverlay, this.pokemonEvoTintSprite], alpha: 0, duration: 2000, delay: 150, @@ -132,33 +131,47 @@ export class FormChangePhase extends EvolutionPhase { if (this.formChange.formKey.indexOf(SpeciesFormKey.MEGA) > -1) { globalScene.validateAchv(achvs.MEGA_EVOLVE); playEvolutionFanfare = true; - } else if (this.formChange.formKey.indexOf(SpeciesFormKey.GIGANTAMAX) > -1 || this.formChange.formKey.indexOf(SpeciesFormKey.ETERNAMAX) > -1) { + } else if ( + this.formChange.formKey.indexOf(SpeciesFormKey.GIGANTAMAX) > -1 || + this.formChange.formKey.indexOf(SpeciesFormKey.ETERNAMAX) > -1 + ) { globalScene.validateAchv(achvs.GIGANTAMAX); playEvolutionFanfare = true; } const delay = playEvolutionFanfare ? 4000 : 1750; - globalScene.playSoundWithoutBgm(playEvolutionFanfare ? "evolution_fanfare" : "minor_fanfare"); + globalScene.playSoundWithoutBgm( + playEvolutionFanfare ? "evolution_fanfare" : "minor_fanfare", + ); transformedPokemon.destroy(); - globalScene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), null, true, Utils.fixedInt(delay)); - globalScene.time.delayedCall(Utils.fixedInt(delay + 250), () => globalScene.playBgm()); + globalScene.ui.showText( + getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), + null, + () => this.end(), + null, + true, + Utils.fixedInt(delay), + ); + globalScene.time.delayedCall(Utils.fixedInt(delay + 250), () => + globalScene.playBgm(), + ); }); }); - } + }, }); - } + }, }); - } + }, }); }); }); }); }); }); - } + }, }); - } + }, }); }); }); diff --git a/src/phases/game-over-modifier-reward-phase.ts b/src/phases/game-over-modifier-reward-phase.ts index 93f53bf38c0..f3f2aebd67d 100644 --- a/src/phases/game-over-modifier-reward-phase.ts +++ b/src/phases/game-over-modifier-reward-phase.ts @@ -5,10 +5,6 @@ import i18next from "i18next"; import { ModifierRewardPhase } from "./modifier-reward-phase"; export class GameOverModifierRewardPhase extends ModifierRewardPhase { - constructor(modifierTypeFunc: ModifierTypeFunc) { - super(modifierTypeFunc); - } - doReward(): Promise { return new Promise(resolve => { const newModifier = this.modifierType.newModifier(); @@ -18,7 +14,9 @@ export class GameOverModifierRewardPhase extends ModifierRewardPhase { globalScene.ui.setMode(Mode.MESSAGE); globalScene.ui.fadeIn(250).then(() => { globalScene.ui.showText( - i18next.t("battle:rewardGain", { modifierName: newModifier?.type.name }), + i18next.t("battle:rewardGain", { + modifierName: newModifier?.type.name, + }), null, () => { globalScene.time.delayedCall(1500, () => globalScene.arenaBg.setVisible(true)); diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index d4b529fe00e..af948ad0632 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -36,7 +36,7 @@ export class GameOverPhase extends BattlePhase { private isVictory: boolean; private firstRibbons: PokemonSpecies[] = []; - constructor(isVictory: boolean = false) { + constructor(isVictory = false) { super(); this.isVictory = isVictory; @@ -52,7 +52,11 @@ export class GameOverPhase extends BattlePhase { // Handle Mystery Encounter special Game Over cases // Situations such as when player lost a battle, but it isn't treated as full Game Over - if (!this.isVictory && globalScene.currentBattle.mysteryEncounter?.onGameOver && !globalScene.currentBattle.mysteryEncounter.onGameOver()) { + if ( + !this.isVictory && + globalScene.currentBattle.mysteryEncounter?.onGameOver && + !globalScene.currentBattle.mysteryEncounter.onGameOver() + ) { // Do not end the game return this.end(); } @@ -61,36 +65,52 @@ export class GameOverPhase extends BattlePhase { if (this.isVictory && globalScene.gameMode.isEndless) { const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; const genderStr = PlayerGender[genderIndex].toLowerCase(); - globalScene.ui.showDialogue(i18next.t("miscDialogue:ending_endless", { context: genderStr }), i18next.t("miscDialogue:ending_name"), 0, () => this.handleGameOver()); + globalScene.ui.showDialogue( + i18next.t("miscDialogue:ending_endless", { context: genderStr }), + i18next.t("miscDialogue:ending_name"), + 0, + () => this.handleGameOver(), + ); } else if (this.isVictory || !globalScene.enableRetries) { this.handleGameOver(); } else { globalScene.ui.showText(i18next.t("battle:retryBattle"), null, () => { - globalScene.ui.setMode(Mode.CONFIRM, () => { - globalScene.ui.fadeOut(1250).then(() => { - globalScene.reset(); - globalScene.clearPhaseQueue(); - globalScene.gameData.loadSession(globalScene.sessionSlotId).then(() => { - globalScene.pushPhase(new EncounterPhase(true)); + globalScene.ui.setMode( + Mode.CONFIRM, + () => { + globalScene.ui.fadeOut(1250).then(() => { + globalScene.reset(); + globalScene.clearPhaseQueue(); + globalScene.gameData.loadSession(globalScene.sessionSlotId).then(() => { + globalScene.pushPhase(new EncounterPhase(true)); - const availablePartyMembers = globalScene.getPokemonAllowedInBattle().length; + const availablePartyMembers = globalScene.getPokemonAllowedInBattle().length; - globalScene.pushPhase(new SummonPhase(0)); - if (globalScene.currentBattle.double && availablePartyMembers > 1) { - globalScene.pushPhase(new SummonPhase(1)); - } - if (globalScene.currentBattle.waveIndex > 1 && globalScene.currentBattle.battleType !== BattleType.TRAINER) { - globalScene.pushPhase(new CheckSwitchPhase(0, globalScene.currentBattle.double)); + globalScene.pushPhase(new SummonPhase(0)); if (globalScene.currentBattle.double && availablePartyMembers > 1) { - globalScene.pushPhase(new CheckSwitchPhase(1, globalScene.currentBattle.double)); + globalScene.pushPhase(new SummonPhase(1)); + } + if ( + globalScene.currentBattle.waveIndex > 1 && + globalScene.currentBattle.battleType !== BattleType.TRAINER + ) { + globalScene.pushPhase(new CheckSwitchPhase(0, globalScene.currentBattle.double)); + if (globalScene.currentBattle.double && availablePartyMembers > 1) { + globalScene.pushPhase(new CheckSwitchPhase(1, globalScene.currentBattle.double)); + } } - } - globalScene.ui.fadeIn(1250); - this.end(); + globalScene.ui.fadeIn(1250); + this.end(); + }); }); - }); - }, () => this.handleGameOver(), false, 0, 0, 1000); + }, + () => this.handleGameOver(), + false, + 0, + 0, + 1000, + ); }); } } @@ -158,17 +178,29 @@ export class GameOverPhase extends BattlePhase { const genderStr = PlayerGender[genderIndex].toLowerCase(); // Dialogue has to be retrieved so that the rival's expressions can be loaded and shown via getCharVariantFromDialogue const dialogue = i18next.t(dialogueKey, { context: genderStr }); - globalScene.charSprite.showCharacter(`rival_${globalScene.gameData.gender === PlayerGender.FEMALE ? "m" : "f"}`, getCharVariantFromDialogue(dialogue)).then(() => { - globalScene.ui.showDialogue(dialogueKey, globalScene.gameData.gender === PlayerGender.FEMALE ? trainerConfigs[TrainerType.RIVAL].name : trainerConfigs[TrainerType.RIVAL].nameFemale, null, () => { - globalScene.ui.fadeOut(500).then(() => { - globalScene.charSprite.hide().then(() => { - const endCardPhase = new EndCardPhase(); - globalScene.unshiftPhase(endCardPhase); - clear(endCardPhase); - }); - }); + globalScene.charSprite + .showCharacter( + `rival_${globalScene.gameData.gender === PlayerGender.FEMALE ? "m" : "f"}`, + getCharVariantFromDialogue(dialogue), + ) + .then(() => { + globalScene.ui.showDialogue( + dialogueKey, + globalScene.gameData.gender === PlayerGender.FEMALE + ? trainerConfigs[TrainerType.RIVAL].name + : trainerConfigs[TrainerType.RIVAL].nameFemale, + null, + () => { + globalScene.ui.fadeOut(500).then(() => { + globalScene.charSprite.hide().then(() => { + const endCardPhase = new EndCardPhase(); + globalScene.unshiftPhase(endCardPhase); + clear(endCardPhase); + }); + }); + }, + ); }); - }); }); } else { const endCardPhase = new EndCardPhase(); @@ -186,8 +218,13 @@ export class GameOverPhase extends BattlePhase { If Online, execute apiFetch as intended If Offline, execute offlineNewClear() only for victory, a localStorage implementation of newClear daily run checks */ if (!Utils.isLocal || Utils.isLocalServerConnected) { - pokerogueApi.savedata.session.newclear({ slot: globalScene.sessionSlotId, isVictory: this.isVictory, clientSessionId: clientSessionId }) - .then((success) => doGameOver(!!success)); + pokerogueApi.savedata.session + .newclear({ + slot: globalScene.sessionSlotId, + isVictory: this.isVictory, + clientSessionId: clientSessionId, + }) + .then(success => doGameOver(!!success)); } else if (this.isVictory) { globalScene.gameData.offlineNewClear().then(result => { doGameOver(result); @@ -202,19 +239,25 @@ export class GameOverPhase extends BattlePhase { if (!globalScene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { globalScene.unshiftPhase(new UnlockPhase(Unlockables.ENDLESS_MODE)); } - if (globalScene.getPlayerParty().filter(p => p.fusionSpecies).length && !globalScene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { + if ( + globalScene.getPlayerParty().filter(p => p.fusionSpecies).length && + !globalScene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE] + ) { globalScene.unshiftPhase(new UnlockPhase(Unlockables.SPLICED_ENDLESS_MODE)); } if (!globalScene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) { globalScene.unshiftPhase(new UnlockPhase(Unlockables.MINI_BLACK_HOLE)); } - if (!globalScene.gameData.unlocks[Unlockables.EVIOLITE] && globalScene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)) { + if ( + !globalScene.gameData.unlocks[Unlockables.EVIOLITE] && + globalScene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions) + ) { globalScene.unshiftPhase(new UnlockPhase(Unlockables.EVIOLITE)); } } } - awardRibbon(pokemon: Pokemon, forStarter: boolean = false): void { + awardRibbon(pokemon: Pokemon, forStarter = false): void { const speciesId = getPokemonSpecies(pokemon.species.speciesId); const speciesRibbonCount = globalScene.gameData.incrementRibbonCount(speciesId, forStarter); // first time classic win, award voucher @@ -236,8 +279,12 @@ export class GameOverPhase extends BattlePhase { gameMode: globalScene.gameMode.modeId, party: globalScene.getPlayerParty().map(p => new PokemonData(p)), enemyParty: globalScene.getEnemyParty().map(p => new PokemonData(p)), - modifiers: preWaveSessionData ? preWaveSessionData.modifiers : globalScene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)), - enemyModifiers: preWaveSessionData ? preWaveSessionData.enemyModifiers : globalScene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)), + modifiers: preWaveSessionData + ? preWaveSessionData.modifiers + : globalScene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)), + enemyModifiers: preWaveSessionData + ? preWaveSessionData.enemyModifiers + : globalScene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)), arena: new ArenaData(globalScene.arena), pokeballCounts: globalScene.pokeballCounts, money: Math.floor(globalScene.money), @@ -250,8 +297,7 @@ export class GameOverPhase extends BattlePhase { challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)), mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData, - playerFaints: globalScene.arena.playerFaints + playerFaints: globalScene.arena.playerFaints, } as SessionSaveData; } } - diff --git a/src/phases/hide-party-exp-bar-phase.ts b/src/phases/hide-party-exp-bar-phase.ts index 0dce41044c0..52cfd1f71d6 100644 --- a/src/phases/hide-party-exp-bar-phase.ts +++ b/src/phases/hide-party-exp-bar-phase.ts @@ -2,10 +2,6 @@ import { globalScene } from "#app/global-scene"; import { BattlePhase } from "./battle-phase"; export class HidePartyExpBarPhase extends BattlePhase { - constructor() { - super(); - } - start() { super.start(); diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index 5d3c4078fa1..7bed71b3363 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -20,7 +20,7 @@ export enum LearnMoveType { /** For learning a move via Memory Mushroom */ MEMORY, /** For learning a move via TM */ - TM + TM, } export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { @@ -29,7 +29,12 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { private learnMoveType: LearnMoveType; private cost: number; - constructor(partyMemberIndex: number, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) { + constructor( + partyMemberIndex: number, + moveId: Moves, + learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, + cost = -1, + ) { super(partyMemberIndex); this.moveId = moveId; this.learnMoveType = learnMoveType; @@ -49,7 +54,8 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { return this.end(); } - this.messageMode = globalScene.ui.getHandler() instanceof EvolutionSceneHandler ? Mode.EVOLUTION_SCENE : Mode.MESSAGE; + this.messageMode = + globalScene.ui.getHandler() instanceof EvolutionSceneHandler ? Mode.EVOLUTION_SCENE : Mode.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. @@ -70,18 +76,27 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { * @param Pokemon The Pokemon learning the move */ async replaceMoveCheck(move: Move, pokemon: Pokemon) { - const learnMovePrompt = i18next.t("battle:learnMovePrompt", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }); - const moveLimitReached = i18next.t("battle:learnMoveLimitReached", { pokemonName: getPokemonNameWithAffix(pokemon) }); - const shouldReplaceQ = i18next.t("battle:learnMoveReplaceQuestion", { moveName: move.name }); - const preQText = [ learnMovePrompt, moveLimitReached ].join("$"); + const learnMovePrompt = i18next.t("battle:learnMovePrompt", { + pokemonName: getPokemonNameWithAffix(pokemon), + moveName: move.name, + }); + const moveLimitReached = i18next.t("battle:learnMoveLimitReached", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); + const shouldReplaceQ = i18next.t("battle:learnMoveReplaceQuestion", { + moveName: move.name, + }); + const preQText = [learnMovePrompt, moveLimitReached].join("$"); await globalScene.ui.showTextPromise(preQText); await globalScene.ui.showTextPromise(shouldReplaceQ, undefined, false); - await globalScene.ui.setModeWithoutClear(Mode.CONFIRM, + await globalScene.ui.setModeWithoutClear( + Mode.CONFIRM, () => this.forgetMoveProcess(move, pokemon), // Yes - () => { // No + () => { + // No globalScene.ui.setMode(this.messageMode); this.rejectMoveAndEnd(move, pokemon); - } + }, ); } @@ -99,15 +114,26 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { async forgetMoveProcess(move: Move, pokemon: Pokemon) { globalScene.ui.setMode(this.messageMode); await globalScene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true); - await globalScene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: number) => { - if (moveIndex === 4) { - globalScene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon)); - return; - } - const forgetSuccessText = i18next.t("battle:learnMoveForgetSuccess", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: pokemon.moveset[moveIndex]!.getName() }); - const fullText = [ i18next.t("battle:countdownPoof"), forgetSuccessText, i18next.t("battle:learnMoveAnd") ].join("$"); - globalScene.ui.setMode(this.messageMode).then(() => this.learnMove(moveIndex, move, pokemon, fullText)); - }); + await globalScene.ui.setModeWithoutClear( + Mode.SUMMARY, + pokemon, + SummaryUiMode.LEARN_MOVE, + move, + (moveIndex: number) => { + if (moveIndex === 4) { + globalScene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon)); + return; + } + const forgetSuccessText = i18next.t("battle:learnMoveForgetSuccess", { + pokemonName: getPokemonNameWithAffix(pokemon), + moveName: pokemon.moveset[moveIndex]!.getName(), + }); + const fullText = [i18next.t("battle:countdownPoof"), forgetSuccessText, i18next.t("battle:learnMoveAnd")].join( + "$", + ); + globalScene.ui.setMode(this.messageMode).then(() => this.learnMove(moveIndex, move, pokemon, fullText)); + }, + ); } /** @@ -121,16 +147,30 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { * @param Pokemon The Pokemon learning the move */ async rejectMoveAndEnd(move: Move, pokemon: Pokemon) { - await globalScene.ui.showTextPromise(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), undefined, false); - globalScene.ui.setModeWithoutClear(Mode.CONFIRM, + await globalScene.ui.showTextPromise( + i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), + undefined, + false, + ); + globalScene.ui.setModeWithoutClear( + Mode.CONFIRM, () => { globalScene.ui.setMode(this.messageMode); - globalScene.ui.showTextPromise(i18next.t("battle:learnMoveNotLearned", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }), undefined, true).then(() => this.end()); + globalScene.ui + .showTextPromise( + i18next.t("battle:learnMoveNotLearned", { + pokemonName: getPokemonNameWithAffix(pokemon), + moveName: move.name, + }), + undefined, + true, + ) + .then(() => this.end()); }, () => { globalScene.ui.setMode(this.messageMode); this.replaceMoveCheck(move, pokemon); - } + }, ); } @@ -155,7 +195,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { pokemon.usedTMs = []; } pokemon.usedTMs.push(this.moveId); - globalScene.tryRemovePhase((phase) => phase instanceof SelectModifierPhase); + globalScene.tryRemovePhase(phase => phase instanceof SelectModifierPhase); } else if (this.learnMoveType === LearnMoveType.MEMORY) { if (this.cost !== -1) { if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) { @@ -165,22 +205,31 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { } globalScene.playSound("se/buy"); } else { - globalScene.tryRemovePhase((phase) => phase instanceof SelectModifierPhase); + globalScene.tryRemovePhase(phase => phase instanceof SelectModifierPhase); } } pokemon.setMove(index, this.moveId); initMoveAnim(this.moveId).then(() => { - loadMoveAnimAssets([ this.moveId ], true); + loadMoveAnimAssets([this.moveId], true); }); globalScene.ui.setMode(this.messageMode); - const learnMoveText = i18next.t("battle:learnMove", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }); + const learnMoveText = i18next.t("battle:learnMove", { + pokemonName: getPokemonNameWithAffix(pokemon), + moveName: move.name, + }); if (textMessage) { await globalScene.ui.showTextPromise(textMessage); } globalScene.playSound("level_up_fanfare"); // Sound loaded into game as is - globalScene.ui.showText(learnMoveText, null, () => { - globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeMoveLearnedTrigger, true); - this.end(); - }, this.messageMode === Mode.EVOLUTION_SCENE ? 1000 : undefined, true); + globalScene.ui.showText( + learnMoveText, + null, + () => { + globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeMoveLearnedTrigger, true); + this.end(); + }, + this.messageMode === Mode.EVOLUTION_SCENE ? 1000 : undefined, + true, + ); } } diff --git a/src/phases/level-cap-phase.ts b/src/phases/level-cap-phase.ts index d75bc3be6d4..567ac922124 100644 --- a/src/phases/level-cap-phase.ts +++ b/src/phases/level-cap-phase.ts @@ -4,17 +4,21 @@ import i18next from "i18next"; import { FieldPhase } from "./field-phase"; export class LevelCapPhase extends FieldPhase { - constructor() { - super(); - } - start(): void { super.start(); globalScene.ui.setMode(Mode.MESSAGE).then(() => { // Sound loaded into game as is globalScene.playSound("level_up_fanfare"); - globalScene.ui.showText(i18next.t("battle:levelCapUp", { levelCap: globalScene.getMaxExpLevel() }), null, () => this.end(), null, true); + globalScene.ui.showText( + i18next.t("battle:levelCapUp", { + levelCap: globalScene.getMaxExpLevel(), + }), + null, + () => this.end(), + null, + true, + ); this.executeForAll(pokemon => pokemon.updateInfo(true)); }); } diff --git a/src/phases/level-up-phase.ts b/src/phases/level-up-phase.ts index 450ecca0c70..31c7fabf451 100644 --- a/src/phases/level-up-phase.ts +++ b/src/phases/level-up-phase.ts @@ -36,20 +36,33 @@ export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { if (globalScene.expParty === ExpNotification.DEFAULT) { globalScene.playSound("level_up_fanfare"); globalScene.ui.showText( - i18next.t("battle:levelUp", { pokemonName: getPokemonNameWithAffix(this.pokemon), level: this.level }), + i18next.t("battle:levelUp", { + pokemonName: getPokemonNameWithAffix(this.pokemon), + level: this.level, + }), null, - () => globalScene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false) - .then(() => this.end()), null, true); + () => + globalScene.ui + .getMessageHandler() + .promptLevelUpStats(this.partyMemberIndex, prevStats, false) + .then(() => this.end()), + null, + true, + ); } else if (globalScene.expParty === ExpNotification.SKIP) { this.end(); } else { // we still want to display the stats if activated - globalScene.ui.getMessageHandler().promptLevelUpStats(this.partyMemberIndex, prevStats, false).then(() => this.end()); + globalScene.ui + .getMessageHandler() + .promptLevelUpStats(this.partyMemberIndex, prevStats, false) + .then(() => this.end()); } } public override end() { - if (this.lastLevel < 100) { // this feels like an unnecessary optimization + if (this.lastLevel < 100) { + // this feels like an unnecessary optimization const levelMoves = this.getPokemon().getLevelMoves(this.lastLevel + 1); for (const lm of levelMoves) { globalScene.unshiftPhase(new LearnMovePhase(this.partyMemberIndex, lm[1])); diff --git a/src/phases/load-move-anim-phase.ts b/src/phases/load-move-anim-phase.ts index 66cb90744e0..3d914f738a7 100644 --- a/src/phases/load-move-anim-phase.ts +++ b/src/phases/load-move-anim-phase.ts @@ -14,7 +14,7 @@ export class LoadMoveAnimPhase extends Phase { public override start(): void { initMoveAnim(this.moveId) - .then(() => loadMoveAnimAssets([ this.moveId ], true)) + .then(() => loadMoveAnimAssets([this.moveId], true)) .then(() => this.end()); } } diff --git a/src/phases/login-phase.ts b/src/phases/login-phase.ts index 0ed8b6feb88..5cce6ca0298 100644 --- a/src/phases/login-phase.ts +++ b/src/phases/login-phase.ts @@ -23,7 +23,7 @@ export class LoginPhase extends Phase { const hasSession = !!Utils.getCookie(Utils.sessionIdKey); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: []}); + globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); Utils.executeIf(bypassLogin || hasSession, updateUserInfo).then(response => { const success = response ? response[0] : false; const statusCode = response ? response[1] : null; @@ -51,7 +51,8 @@ export class LoginPhase extends Phase { () => { globalScene.ui.playSelect(); loadData(); - }, () => { + }, + () => { globalScene.playSound("menu_open"); globalScene.ui.setMode(Mode.REGISTRATION_FORM, { buttonActions: [ @@ -64,25 +65,28 @@ export class LoginPhase extends Phase { return; } this.end(); - } ); - }, () => { + }); + }, + () => { globalScene.unshiftPhase(new LoginPhase(false)); this.end(); - } - ] + }, + ], }); - }, () => { + }, + () => { const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/discord/callback`); const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify&prompt=none`; window.open(discordUrl, "_self"); - }, () => { + }, + () => { const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/google/callback`); const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`; window.open(googleUrl, "_self"); - } - ] + }, + ], }); } else if (statusCode === 401) { Utils.removeCookie(Utils.sessionIdKey); @@ -92,16 +96,15 @@ export class LoginPhase extends Phase { super.end(); } return null; - } else { - globalScene.gameData.loadSystem().then(success => { - if (success || bypassLogin) { - this.end(); - } else { - globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(t("menu:failedToLoadSaveData")); - } - }); } + globalScene.gameData.loadSystem().then(success => { + if (success || bypassLogin) { + this.end(); + } else { + globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.showText(t("menu:failedToLoadSaveData")); + } + }); }); } diff --git a/src/phases/message-phase.ts b/src/phases/message-phase.ts index 366fd324376..af4e63c6916 100644 --- a/src/phases/message-phase.ts +++ b/src/phases/message-phase.ts @@ -8,7 +8,13 @@ export class MessagePhase extends Phase { private promptDelay: number | null; private speaker?: string; - constructor(text: string, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null, speaker?: string) { + constructor( + text: string, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + speaker?: string, + ) { super(); this.text = text; @@ -23,14 +29,36 @@ export class MessagePhase extends Phase { if (this.text.indexOf("$") > -1) { const pageIndex = this.text.indexOf("$"); - globalScene.unshiftPhase(new MessagePhase(this.text.slice(pageIndex + 1), this.callbackDelay, this.prompt, this.promptDelay, this.speaker)); + globalScene.unshiftPhase( + new MessagePhase( + this.text.slice(pageIndex + 1), + this.callbackDelay, + this.prompt, + this.promptDelay, + this.speaker, + ), + ); this.text = this.text.slice(0, pageIndex).trim(); } if (this.speaker) { - globalScene.ui.showDialogue(this.text, this.speaker, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.promptDelay ?? 0); + globalScene.ui.showDialogue( + this.text, + this.speaker, + null, + () => this.end(), + this.callbackDelay || (this.prompt ? 0 : 1500), + this.promptDelay ?? 0, + ); } else { - globalScene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt, this.promptDelay); + globalScene.ui.showText( + this.text, + null, + () => this.end(), + this.callbackDelay || (this.prompt ? 0 : 1500), + this.prompt, + this.promptDelay, + ); } } diff --git a/src/phases/modifier-reward-phase.ts b/src/phases/modifier-reward-phase.ts index e4fac33767f..c94c4deb819 100644 --- a/src/phases/modifier-reward-phase.ts +++ b/src/phases/modifier-reward-phase.ts @@ -24,7 +24,15 @@ export class ModifierRewardPhase extends BattlePhase { const newModifier = this.modifierType.newModifier(); globalScene.addModifier(newModifier); globalScene.playSound("item_fanfare"); - globalScene.ui.showText(i18next.t("battle:rewardGain", { modifierName: newModifier?.type.name }), null, () => resolve(), null, true); + globalScene.ui.showText( + i18next.t("battle:rewardGain", { + modifierName: newModifier?.type.name, + }), + null, + () => resolve(), + null, + true, + ); }); } } diff --git a/src/phases/money-reward-phase.ts b/src/phases/money-reward-phase.ts index f460f89a72a..56f46d25f77 100644 --- a/src/phases/money-reward-phase.ts +++ b/src/phases/money-reward-phase.ts @@ -27,7 +27,9 @@ export class MoneyRewardPhase extends BattlePhase { const userLocale = navigator.language || "en-US"; const formattedMoneyAmount = moneyAmount.value.toLocaleString(userLocale); - const message = i18next.t("battle:moneyWon", { moneyAmount: formattedMoneyAmount }); + const message = i18next.t("battle:moneyWon", { + moneyAmount: formattedMoneyAmount, + }); globalScene.ui.showText(message, null, () => this.end(), null, true); } diff --git a/src/phases/move-anim-phase.ts b/src/phases/move-anim-phase.ts index 005445924a0..830e72cb8be 100644 --- a/src/phases/move-anim-phase.ts +++ b/src/phases/move-anim-phase.ts @@ -7,7 +7,7 @@ import { Phase } from "#app/phase"; export class MoveAnimPhase extends Phase { constructor( protected anim: Anim, - protected onSubstitute: boolean = false, + protected onSubstitute = false, ) { super(); } diff --git a/src/phases/move-anim-test-phase.ts b/src/phases/move-anim-test-phase.ts index 871d6188237..e8b7c0c8fa7 100644 --- a/src/phases/move-anim-test-phase.ts +++ b/src/phases/move-anim-test-phase.ts @@ -24,23 +24,27 @@ export class MoveAnimTestPhase extends BattlePhase { if (moveId === undefined) { this.playMoveAnim(this.moveQueue.slice(0), true); return; - } else if (player) { + } + if (player) { console.log(Moves[moveId]); } initMoveAnim(moveId).then(() => { - loadMoveAnimAssets([ moveId ], true) - .then(() => { - const user = player ? globalScene.getPlayerPokemon()! : globalScene.getEnemyPokemon()!; - const target = (player !== (allMoves[moveId] instanceof SelfStatusMove)) ? globalScene.getEnemyPokemon()! : globalScene.getPlayerPokemon()!; - new MoveAnim(moveId, user, target.getBattlerIndex()).play(allMoves[moveId].hitsSubstitute(user, target), () => { // TODO: are the bangs correct here? - if (player) { - this.playMoveAnim(moveQueue, false); - } else { - this.playMoveAnim(moveQueue, true); - } - }); + loadMoveAnimAssets([moveId], true).then(() => { + const user = player ? globalScene.getPlayerPokemon()! : globalScene.getEnemyPokemon()!; + const target = + player !== allMoves[moveId] instanceof SelfStatusMove + ? globalScene.getEnemyPokemon()! + : globalScene.getPlayerPokemon()!; + new MoveAnim(moveId, user, target.getBattlerIndex()).play(allMoves[moveId].hitsSubstitute(user, target), () => { + // TODO: are the bangs correct here? + if (player) { + this.playMoveAnim(moveQueue, false); + } else { + this.playMoveAnim(moveQueue, true); + } }); + }); }); } } diff --git a/src/phases/move-charge-phase.ts b/src/phases/move-charge-phase.ts index 3989221504d..26ad85bbe03 100644 --- a/src/phases/move-charge-phase.ts +++ b/src/phases/move-charge-phase.ts @@ -36,7 +36,7 @@ export class MoveChargePhase extends PokemonPhase { // If the target is somehow not defined, or the move is somehow not a ChargingMove, // immediately end this phase. - if (!target || !(move.isChargingMove())) { + if (!target || !move.isChargingMove()) { console.warn("Invalid parameters for MoveChargePhase"); return super.end(); } @@ -62,15 +62,19 @@ export class MoveChargePhase extends PokemonPhase { if (instantCharge.value) { // this MoveEndPhase will be duplicated by the queued MovePhase if not removed - globalScene.tryRemovePhase((phase) => phase instanceof MoveEndPhase && phase.getPokemon() === user); + globalScene.tryRemovePhase(phase => phase instanceof MoveEndPhase && phase.getPokemon() === user); // queue a new MovePhase for this move's attack phase - globalScene.unshiftPhase(new MovePhase(user, [ this.targetIndex ], this.move, false)); + globalScene.unshiftPhase(new MovePhase(user, [this.targetIndex], this.move, false)); } else { - user.getMoveQueue().push({ move: move.id, targets: [ this.targetIndex ]}); + user.getMoveQueue().push({ move: move.id, targets: [this.targetIndex] }); } // Add this move's charging phase to the user's move history - user.pushMoveHistory({ move: this.move.moveId, targets: [ this.targetIndex ], result: MoveResult.OTHER }); + user.pushMoveHistory({ + move: this.move.moveId, + targets: [this.targetIndex], + result: MoveResult.OTHER, + }); } super.end(); } @@ -80,6 +84,6 @@ export class MoveChargePhase extends PokemonPhase { } public getTargetPokemon(): Pokemon | undefined { - return globalScene.getField(true).find((p) => this.targetIndex === p.getBattlerIndex()); + return globalScene.getField(true).find(p => this.targetIndex === p.getBattlerIndex()); } } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index c382c6aa4c4..4152fc243f0 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -24,8 +24,7 @@ import { SemiInvulnerableTag, SubstituteTag, } from "#app/data/battler-tags"; -import type { - MoveAttr } from "#app/data/moves/move"; +import type { MoveAttr } from "#app/data/moves/move"; import { applyFilteredMoveAttrs, applyMoveAttrs, @@ -62,7 +61,7 @@ import { } 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 type { nil } from "#app/utils"; import { BattlerTagType } from "#enums/battler-tag-type"; import type { Moves } from "#enums/moves"; import i18next from "i18next"; @@ -74,12 +73,12 @@ import { MoveEndPhase } from "./move-end-phase"; export class MoveEffectPhase extends PokemonPhase { public move: PokemonMove; protected targets: BattlerIndex[]; - protected reflected: boolean = false; + protected reflected = false; /** * @param reflected Indicates that the move was reflected by the user due to magic coat or magic bounce */ - constructor(battlerIndex: BattlerIndex, targets: BattlerIndex[], move: PokemonMove, reflected: boolean = false) { + constructor(battlerIndex: BattlerIndex, targets: BattlerIndex[], move: PokemonMove, reflected = false) { super(battlerIndex); this.move = move; this.reflected = reflected; @@ -183,31 +182,52 @@ export class MoveEffectPhase extends PokemonPhase { * Note that `result` (a {@linkcode MoveResult}) logs whether the move was successfully * used in the sense of "Does it have an effect on the user?". */ - const moveHistoryEntry = { move: this.move.moveId, targets: this.targets, result: MoveResult.PENDING, virtual: this.move.virtual }; + const moveHistoryEntry = { + move: this.move.moveId, + targets: this.targets, + result: MoveResult.PENDING, + virtual: this.move.virtual, + }; /** * Stores results of hit checks of the invoked move against all targets, organized by battler index. * @see {@linkcode hitCheck} */ - const targetHitChecks = Object.fromEntries(targets.map(p => [ p.getBattlerIndex(), this.hitCheck(p) ])); + const targetHitChecks = Object.fromEntries(targets.map(p => [p.getBattlerIndex(), this.hitCheck(p)])); const hasActiveTargets = targets.some(t => t.isActive(true)); /** Check if the target is immune via ability to the attacking move, and NOT in semi invulnerable state */ - const isImmune = targets[0]?.hasAbilityWithAttr(TypeImmunityAbAttr) - && (targets[0]?.getAbility()?.getAttrs(TypeImmunityAbAttr)?.[0]?.getImmuneType() === user.getMoveType(move)) - && !targets[0]?.getTag(SemiInvulnerableTag); + const isImmune = + targets[0]?.hasAbilityWithAttr(TypeImmunityAbAttr) && + targets[0]?.getAbility()?.getAttrs(TypeImmunityAbAttr)?.[0]?.getImmuneType() === user.getMoveType(move) && + !targets[0]?.getTag(SemiInvulnerableTag); - const mayBounce = move.hasFlag(MoveFlags.REFLECTABLE) && !this.reflected && targets.some(t => t.hasAbilityWithAttr(ReflectStatusMoveAbAttr) || !!t.getTag(BattlerTagType.MAGIC_COAT)); + const mayBounce = + move.hasFlag(MoveFlags.REFLECTABLE) && + !this.reflected && + targets.some(t => t.hasAbilityWithAttr(ReflectStatusMoveAbAttr) || !!t.getTag(BattlerTagType.MAGIC_COAT)); /** * If no targets are left for the move to hit (FAIL), or the invoked move is non-reflectable, single-target * (and not random target) and failed the hit check against its target (MISS), log the move * as FAILed or MISSed (depending on the conditions above) and end this phase. */ - if (!hasActiveTargets || (!mayBounce && !move.hasAttr(VariableTargetAttr) && !move.isMultiTarget() && !targetHitChecks[this.targets[0]] && !targets[0].getTag(ProtectedTag) && !isImmune)) { + if ( + !hasActiveTargets || + (!mayBounce && + !move.hasAttr(VariableTargetAttr) && + !move.isMultiTarget() && + !targetHitChecks[this.targets[0]] && + !targets[0].getTag(ProtectedTag) && + !isImmune) + ) { this.stopMultiHit(); if (hasActiveTargets) { - globalScene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: this.getFirstTarget() ? getPokemonNameWithAffix(this.getFirstTarget()!) : "" })); + globalScene.queueMessage( + i18next.t("battle:attackMissed", { + pokemonNameWithAffix: this.getFirstTarget() ? getPokemonNameWithAffix(this.getFirstTarget()!) : "", + }), + ); moveHistoryEntry.result = MoveResult.MISS; applyMoveAttrs(MissEffectAttr, user, null, this.move.getMove()); } else { @@ -224,19 +244,24 @@ export class MoveEffectPhase extends PokemonPhase { move.hitsSubstitute(user, this.getFirstTarget()!), () => { /** Has the move successfully hit a target (for damage) yet? */ - let hasHit: boolean = false; + let hasHit = false; // Prevent ENEMY_SIDE targeted moves from occurring twice in double battles // and check which target will magic bounce. - const trueTargets: Pokemon[] = move.moveTarget !== MoveTarget.ENEMY_SIDE ? targets : (() => { - const magicCoatTargets = targets.filter(t => t.getTag(BattlerTagType.MAGIC_COAT) || t.hasAbilityWithAttr(ReflectStatusMoveAbAttr)); + const trueTargets: Pokemon[] = + move.moveTarget !== MoveTarget.ENEMY_SIDE + ? targets + : (() => { + const magicCoatTargets = targets.filter( + t => t.getTag(BattlerTagType.MAGIC_COAT) || t.hasAbilityWithAttr(ReflectStatusMoveAbAttr), + ); - // only magic coat effect cares about order - if (!mayBounce || magicCoatTargets.length === 0) { - return [ targets[0] ]; - } - return [ magicCoatTargets[0] ]; - })(); + // only magic coat effect cares about order + if (!mayBounce || magicCoatTargets.length === 0) { + return [targets[0]]; + } + return [magicCoatTargets[0]]; + })(); const queuedPhases: Phase[] = []; for (const target of trueTargets) { @@ -248,61 +273,95 @@ export class MoveEffectPhase extends PokemonPhase { const bypassIgnoreProtect = new BooleanHolder(false); /** If the move is not targeting a Pokemon on the user's side, try to apply conditional protection effects */ if (!this.move.getMove().isAllyTarget()) { - globalScene.arena.applyTagsForSide(ConditionalProtectTag, targetSide, false, hasConditionalProtectApplied, user, target, move.id, bypassIgnoreProtect); + globalScene.arena.applyTagsForSide( + ConditionalProtectTag, + targetSide, + false, + hasConditionalProtectApplied, + user, + target, + move.id, + bypassIgnoreProtect, + ); } /** Is the target protected by Protect, etc. or a relevant conditional protection effect? */ - const isProtected = !([ MoveTarget.ENEMY_SIDE, MoveTarget.BOTH_SIDES ].includes(this.move.getMove().moveTarget)) && ( - bypassIgnoreProtect.value - || !this.move.getMove().checkFlag(MoveFlags.IGNORE_PROTECT, user, target)) - && (hasConditionalProtectApplied.value - || (!target.findTags(t => t instanceof DamageProtectedTag).length - && target.findTags(t => t instanceof ProtectedTag).find(t => target.lapseTag(t.tagType))) - || (this.move.getMove().category !== MoveCategory.STATUS - && target.findTags(t => t instanceof DamageProtectedTag).find(t => target.lapseTag(t.tagType)))); + const isProtected = + ![MoveTarget.ENEMY_SIDE, MoveTarget.BOTH_SIDES].includes(this.move.getMove().moveTarget) && + (bypassIgnoreProtect.value || !this.move.getMove().checkFlag(MoveFlags.IGNORE_PROTECT, user, target)) && + (hasConditionalProtectApplied.value || + (!target.findTags(t => t instanceof DamageProtectedTag).length && + target.findTags(t => t instanceof ProtectedTag).find(t => target.lapseTag(t.tagType))) || + (this.move.getMove().category !== MoveCategory.STATUS && + target.findTags(t => t instanceof DamageProtectedTag).find(t => target.lapseTag(t.tagType)))); /** Is the target hidden by the effects of its Commander ability? */ - const isCommanding = globalScene.currentBattle.double && target.getAlly()?.getTag(BattlerTagType.COMMANDED)?.getSourcePokemon() === target; + const isCommanding = + globalScene.currentBattle.double && + target.getAlly()?.getTag(BattlerTagType.COMMANDED)?.getSourcePokemon() === target; /** Is the target reflecting status moves from the magic coat move? */ const isReflecting = !!target.getTag(BattlerTagType.MAGIC_COAT); /** Is the target's magic bounce ability not ignored and able to reflect this move? */ - const canMagicBounce = !isReflecting && !move.checkFlag(MoveFlags.IGNORE_ABILITIES, user, target) && target.hasAbilityWithAttr(ReflectStatusMoveAbAttr); + const canMagicBounce = + !isReflecting && + !move.checkFlag(MoveFlags.IGNORE_ABILITIES, user, target) && + target.hasAbilityWithAttr(ReflectStatusMoveAbAttr); const semiInvulnerableTag = target.getTag(SemiInvulnerableTag); /** Is the target reflecting the effect, not protected, and not in an semi-invulnerable state?*/ - const willBounce = (!isProtected && !this.reflected && !isCommanding - && move.hasFlag(MoveFlags.REFLECTABLE) - && (isReflecting || canMagicBounce) - && !semiInvulnerableTag); + const willBounce = + !isProtected && + !this.reflected && + !isCommanding && + move.hasFlag(MoveFlags.REFLECTABLE) && + (isReflecting || canMagicBounce) && + !semiInvulnerableTag; // If the move will bounce, then queue the bounce and move on to the next target if (!target.switchOutStatus && willBounce) { - const newTargets = move.isMultiTarget() ? getMoveTargets(target, move.id).targets : [ user.getBattlerIndex() ]; + const newTargets = move.isMultiTarget() + ? getMoveTargets(target, move.id).targets + : [user.getBattlerIndex()]; if (!isReflecting) { - queuedPhases.push(new ShowAbilityPhase(target.getBattlerIndex(), target.getPassiveAbility().hasAttr(ReflectStatusMoveAbAttr))); + queuedPhases.push( + new ShowAbilityPhase( + target.getBattlerIndex(), + target.getPassiveAbility().hasAttr(ReflectStatusMoveAbAttr), + ), + ); } - queuedPhases.push(new MovePhase(target, newTargets, new PokemonMove(move.id, 0, 0, true), true, true, true)); + queuedPhases.push( + new MovePhase(target, newTargets, new PokemonMove(move.id, 0, 0, true), true, true, true), + ); continue; } /** Is the pokemon immune due to an ablility, and also not in a semi invulnerable state? */ - const isImmune = target.hasAbilityWithAttr(TypeImmunityAbAttr) - && (target.getAbility()?.getAttrs(TypeImmunityAbAttr)?.[0]?.getImmuneType() === user.getMoveType(move)) - && !semiInvulnerableTag; - + const isImmune = + target.hasAbilityWithAttr(TypeImmunityAbAttr) && + target.getAbility()?.getAttrs(TypeImmunityAbAttr)?.[0]?.getImmuneType() === user.getMoveType(move) && + !semiInvulnerableTag; /** * If the move missed a target, stop all future hits against that target * and move on to the next target (if there is one). */ - if (target.switchOutStatus || isCommanding || (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()])) { + if ( + target.switchOutStatus || + isCommanding || + (!isImmune && !isProtected && !targetHitChecks[target.getBattlerIndex()]) + ) { this.stopMultiHit(target); if (!target.switchOutStatus) { - globalScene.queueMessage(i18next.t("battle:attackMissed", { pokemonNameWithAffix: getPokemonNameWithAffix(target) })); + globalScene.queueMessage( + i18next.t("battle:attackMissed", { + pokemonNameWithAffix: getPokemonNameWithAffix(target), + }), + ); } if (moveHistoryEntry.result === MoveResult.PENDING) { moveHistoryEntry.result = MoveResult.MISS; @@ -345,7 +404,7 @@ export class MoveEffectPhase extends PokemonPhase { HitResult.EFFECTIVE, HitResult.SUPER_EFFECTIVE, HitResult.NOT_VERY_EFFECTIVE, - HitResult.ONE_HIT_KO + HitResult.ONE_HIT_KO, ].includes(hitResult); /** Is this target the first one hit by the move on its current strike? */ @@ -425,7 +484,7 @@ export class MoveEffectPhase extends PokemonPhase { * after all targeted effects have applied. * This prevents blocked effects from applying until after this hit resolves. */ - targets.forEach((target) => { + targets.forEach(target => { const substitute = target.getTag(SubstituteTag); if (substitute && substitute.hp <= 0) { target.lapseTag(BattlerTagType.SUBSTITUTE); @@ -464,7 +523,7 @@ export class MoveEffectPhase extends PokemonPhase { } globalScene.applyModifiers(HitHealModifier, this.player, user); // Clear all cached move effectiveness values among targets - this.getTargets().forEach((target) => target.turnData.moveEffectiveness = null); + this.getTargets().forEach(target => (target.turnData.moveEffectiveness = null)); } } @@ -481,12 +540,17 @@ export class MoveEffectPhase extends PokemonPhase { * @returns a function intended to be passed into a `then()` call. */ protected applySelfTargetEffects(user: Pokemon, target: Pokemon, firstHit: boolean, lastHit: boolean): void { - applyFilteredMoveAttrs((attr: MoveAttr) => - attr instanceof MoveEffectAttr - && attr.trigger === MoveEffectTrigger.POST_APPLY - && attr.selfTarget - && (!attr.firstHitOnly || firstHit) - && (!attr.lastHitOnly || lastHit), user, target, this.move.getMove()); + applyFilteredMoveAttrs( + (attr: MoveAttr) => + attr instanceof MoveEffectAttr && + attr.trigger === MoveEffectTrigger.POST_APPLY && + attr.selfTarget && + (!attr.firstHitOnly || firstHit) && + (!attr.lastHitOnly || lastHit), + user, + target, + this.move.getMove(), + ); } /** @@ -499,12 +563,17 @@ export class MoveEffectPhase extends PokemonPhase { * @returns a function intended to be passed into a `then()` call. */ protected applyPostApplyEffects(user: Pokemon, target: Pokemon, firstHit: boolean, lastHit: boolean): void { - applyFilteredMoveAttrs((attr: MoveAttr) => - attr instanceof MoveEffectAttr - && attr.trigger === MoveEffectTrigger.POST_APPLY - && !attr.selfTarget - && (!attr.firstHitOnly || firstHit) - && (!attr.lastHitOnly || lastHit), user, target, this.move.getMove()); + applyFilteredMoveAttrs( + (attr: MoveAttr) => + attr instanceof MoveEffectAttr && + attr.trigger === MoveEffectTrigger.POST_APPLY && + !attr.selfTarget && + (!attr.firstHitOnly || firstHit) && + (!attr.lastHitOnly || lastHit), + user, + target, + this.move.getMove(), + ); } /** @@ -517,13 +586,24 @@ export class MoveEffectPhase extends PokemonPhase { * @param firstTarget - `true` if {@linkcode target} is the first target hit by this strike of {@linkcode move} * @returns a function intended to be passed into a `then()` call. */ - protected applyOnHitEffects(user: Pokemon, target: Pokemon, firstHit : boolean, lastHit: boolean, firstTarget: boolean): void { - applyFilteredMoveAttrs((attr: MoveAttr) => - attr instanceof MoveEffectAttr - && attr.trigger === MoveEffectTrigger.HIT - && (!attr.firstHitOnly || firstHit) - && (!attr.lastHitOnly || lastHit) - && (!attr.firstTargetOnly || firstTarget), user, target, this.move.getMove()); + protected applyOnHitEffects( + user: Pokemon, + target: Pokemon, + firstHit: boolean, + lastHit: boolean, + firstTarget: boolean, + ): void { + applyFilteredMoveAttrs( + (attr: MoveAttr) => + attr instanceof MoveEffectAttr && + attr.trigger === MoveEffectTrigger.HIT && + (!attr.firstHitOnly || firstHit) && + (!attr.lastHitOnly || lastHit) && + (!attr.firstTargetOnly || firstTarget), + user, + target, + this.move.getMove(), + ); } /** @@ -560,7 +640,15 @@ export class MoveEffectPhase extends PokemonPhase { * @param firstTarget - `true` if {@linkcode target} is the first target hit by this strike of {@linkcode move} * @returns a function intended to be passed into a `then()` call. */ - protected applySuccessfulAttackEffects(user: Pokemon, target: Pokemon, firstHit: boolean, lastHit: boolean, isProtected: boolean, hitResult: HitResult, firstTarget: boolean): void { + protected applySuccessfulAttackEffects( + user: Pokemon, + target: Pokemon, + firstHit: boolean, + lastHit: boolean, + isProtected: boolean, + hitResult: HitResult, + firstTarget: boolean, + ): void { if (!isProtected) { this.applyOnHitEffects(user, target, firstHit, lastHit, firstTarget); this.applyOnGetHitAbEffects(user, target, hitResult); @@ -578,12 +666,16 @@ export class MoveEffectPhase extends PokemonPhase { * @param dealsDamage - `true` if the attempted move successfully dealt damage * @returns a function intended to be passed into a `then()` call. */ - protected applyHeldItemFlinchCheck(user: Pokemon, target: Pokemon, dealsDamage: boolean) : void { + protected applyHeldItemFlinchCheck(user: Pokemon, target: Pokemon, dealsDamage: boolean): void { if (this.move.getMove().hasAttr(FlinchAttr)) { return; } - if (dealsDamage && !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !this.move.getMove().hitsSubstitute(user, target)) { + if ( + dealsDamage && + !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && + !this.move.getMove().hitsSubstitute(user, target) + ) { const flinched = new BooleanHolder(false); globalScene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched); if (flinched.value) { @@ -599,7 +691,7 @@ export class MoveEffectPhase extends PokemonPhase { */ public hitCheck(target: Pokemon): boolean { // Moves targeting the user and entry hazards can't miss - if ([ MoveTarget.USER, MoveTarget.ENEMY_SIDE ].includes(this.move.getMove().moveTarget)) { + if ([MoveTarget.USER, MoveTarget.ENEMY_SIDE].includes(this.move.getMove().moveTarget)) { return true; } @@ -627,7 +719,11 @@ export class MoveEffectPhase extends PokemonPhase { } const semiInvulnerableTag = target.getTag(SemiInvulnerableTag); - if (target.getTag(BattlerTagType.TELEKINESIS) && !semiInvulnerableTag && !this.move.getMove().hasAttr(OneHitKOAttr)) { + if ( + target.getTag(BattlerTagType.TELEKINESIS) && + !semiInvulnerableTag && + !this.move.getMove().hasAttr(OneHitKOAttr) + ) { return true; } @@ -644,7 +740,7 @@ export class MoveEffectPhase extends PokemonPhase { const accuracyMultiplier = user.getAccuracyMultiplier(target, this.move.getMove()); const rand = user.randSeedInt(100); - return rand < (moveAccuracy * accuracyMultiplier); + return rand < moveAccuracy * accuracyMultiplier; } /** @@ -671,11 +767,14 @@ export class MoveEffectPhase extends PokemonPhase { if (user.hasAbilityWithAttr(AlwaysHitAbAttr) || target.hasAbilityWithAttr(AlwaysHitAbAttr)) { return true; } - if ((this.move.getMove().hasAttr(ToxicAccuracyAttr) && user.isOfType(PokemonType.POISON))) { + if (this.move.getMove().hasAttr(ToxicAccuracyAttr) && user.isOfType(PokemonType.POISON)) { return true; } // TODO: Fix lock on / mind reader check. - if (user.getTag(BattlerTagType.IGNORE_ACCURACY) && (user.getLastXMoves().find(() => true)?.targets || []).indexOf(target.getBattlerIndex()) !== -1) { + if ( + user.getTag(BattlerTagType.IGNORE_ACCURACY) && + (user.getLastXMoves().find(() => true)?.targets || []).indexOf(target.getBattlerIndex()) !== -1 + ) { return true; } } @@ -718,7 +817,10 @@ export class MoveEffectPhase extends PokemonPhase { protected removeTarget(target: Pokemon): void { const targetIndex = this.targets.findIndex(ind => ind === target.getBattlerIndex()); if (targetIndex !== -1) { - this.targets.splice(this.targets.findIndex(ind => ind === target.getBattlerIndex()), 1); + this.targets.splice( + this.targets.findIndex(ind => ind === target.getBattlerIndex()), + 1, + ); } } @@ -737,7 +839,7 @@ export class MoveEffectPhase extends PokemonPhase { } // If no target specified, or the specified target was the last of this move's // targets, completely cancel all subsequent strikes. - if (!target || this.targets.length === 0 ) { + if (!target || this.targets.length === 0) { user.turnData.hitCount = 1; user.turnData.hitsLeft = 1; } diff --git a/src/phases/move-end-phase.ts b/src/phases/move-end-phase.ts index 428dacd639a..4716370cc4e 100644 --- a/src/phases/move-end-phase.ts +++ b/src/phases/move-end-phase.ts @@ -4,10 +4,6 @@ import { BattlerTagLapseType } from "#app/data/battler-tags"; import { PokemonPhase } from "./pokemon-phase"; export class MoveEndPhase extends PokemonPhase { - constructor(battlerIndex: BattlerIndex) { - super(battlerIndex); - } - start() { super.start(); diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 7e454d654d0..16802f8e0ff 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -58,9 +58,9 @@ export class MovePhase extends BattlePhase { protected followUp: boolean; protected ignorePp: boolean; protected forcedLast: boolean; - protected failed: boolean = false; - protected cancelled: boolean = false; - protected reflected: boolean = false; + protected failed = false; + protected cancelled = false; + protected reflected = false; public get pokemon(): Pokemon { return this._pokemon; @@ -93,7 +93,15 @@ export class MovePhase extends BattlePhase { * Reflected moves cannot be reflected again and will not trigger Dancer. */ - constructor(pokemon: Pokemon, targets: BattlerIndex[], move: PokemonMove, followUp: boolean = false, ignorePp: boolean = false, reflected: boolean = false, forcedLast: boolean = false) { + constructor( + pokemon: Pokemon, + targets: BattlerIndex[], + move: PokemonMove, + followUp = false, + ignorePp = false, + reflected = false, + forcedLast = false, + ) { super(); this.pokemon = pokemon; @@ -110,8 +118,12 @@ export class MovePhase extends BattlePhase { * @param ignoreDisableTags `true` to not check if the move is disabled * @returns `true` if all the checks pass */ - public canMove(ignoreDisableTags: boolean = false): boolean { - return this.pokemon.isActive(true) && this.move.isUsable(this.pokemon, this.ignorePp, ignoreDisableTags) && !!this.targets.length; + public canMove(ignoreDisableTags = false): boolean { + return ( + this.pokemon.isActive(true) && + this.move.isUsable(this.pokemon, this.ignorePp, ignoreDisableTags) && + !!this.targets.length + ); } /**Signifies the current move should fail but still use PP */ @@ -132,7 +144,6 @@ export class MovePhase extends BattlePhase { return this.forcedLast; } - public start(): void { super.start(); @@ -213,24 +224,34 @@ export class MovePhase extends BattlePhase { switch (this.pokemon.status.effect) { case StatusEffect.PARALYSIS: - activated = (!this.pokemon.randSeedInt(4) || Overrides.STATUS_ACTIVATION_OVERRIDE === true) && Overrides.STATUS_ACTIVATION_OVERRIDE !== false; + activated = + (!this.pokemon.randSeedInt(4) || Overrides.STATUS_ACTIVATION_OVERRIDE === true) && + Overrides.STATUS_ACTIVATION_OVERRIDE !== false; break; case StatusEffect.SLEEP: applyMoveAttrs(BypassSleepAttr, this.pokemon, null, this.move.getMove()); const turnsRemaining = new NumberHolder(this.pokemon.status.sleepTurnsRemaining ?? 0); - applyAbAttrs(ReduceStatusEffectDurationAbAttr, this.pokemon, null, false, this.pokemon.status.effect, turnsRemaining); + applyAbAttrs( + ReduceStatusEffectDurationAbAttr, + this.pokemon, + null, + false, + this.pokemon.status.effect, + turnsRemaining, + ); this.pokemon.status.sleepTurnsRemaining = turnsRemaining.value; healed = this.pokemon.status.sleepTurnsRemaining <= 0; activated = !healed && !this.pokemon.getTag(BattlerTagType.BYPASS_SLEEP); break; case StatusEffect.FREEZE: healed = - !!this.move.getMove().findAttr((attr) => - attr instanceof HealStatusEffectAttr - && attr.selfTarget - && attr.isOfEffect(StatusEffect.FREEZE)) - || (!this.pokemon.randSeedInt(5) && Overrides.STATUS_ACTIVATION_OVERRIDE !== true) - || Overrides.STATUS_ACTIVATION_OVERRIDE === false; + !!this.move + .getMove() + .findAttr( + attr => attr instanceof HealStatusEffectAttr && attr.selfTarget && attr.isOfEffect(StatusEffect.FREEZE), + ) || + (!this.pokemon.randSeedInt(5) && Overrides.STATUS_ACTIVATION_OVERRIDE !== true) || + Overrides.STATUS_ACTIVATION_OVERRIDE === false; activated = !healed; break; @@ -238,10 +259,20 @@ export class MovePhase extends BattlePhase { if (activated) { this.cancel(); - globalScene.queueMessage(getStatusEffectActivationText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon))); - globalScene.unshiftPhase(new CommonAnimPhase(this.pokemon.getBattlerIndex(), undefined, CommonAnim.POISON + (this.pokemon.status.effect - 1))); + globalScene.queueMessage( + getStatusEffectActivationText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon)), + ); + globalScene.unshiftPhase( + new CommonAnimPhase( + this.pokemon.getBattlerIndex(), + undefined, + CommonAnim.POISON + (this.pokemon.status.effect - 1), + ), + ); } else if (healed) { - globalScene.queueMessage(getStatusEffectHealText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon))); + globalScene.queueMessage( + getStatusEffectHealText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon)), + ); this.pokemon.resetStatus(); this.pokemon.updateInfo(); } @@ -271,7 +302,7 @@ export class MovePhase extends BattlePhase { const isDelayedAttack = this.move.getMove().hasAttr(DelayedAttackAttr); if (isDelayedAttack) { // Check the player side arena if future sight is active - const futureSightTags = globalScene.arena.findTags(t => t.tagType === ArenaTagType.FUTURE_SIGHT); + const futureSightTags = globalScene.arena.findTags(t => t.tagType === ArenaTagType.FUTURE_SIGHT); const doomDesireTags = globalScene.arena.findTags(t => t.tagType === ArenaTagType.DOOM_DESIRE); let fail = false; const currentTargetIndex = targets[0].getBattlerIndex(); @@ -294,7 +325,7 @@ export class MovePhase extends BattlePhase { } } - let success: boolean = true; + let success = true; // Check if there are any attributes that can interrupt the move, overriding the fail message. for (const move of this.move.getMove().getAttrs(PreUseInterruptAttr)) { if (move.apply(this.pokemon, targets[0], this.move.getMove())) { @@ -341,8 +372,8 @@ export class MovePhase extends BattlePhase { * Move conditions assume the move has a single target * TODO: is this sustainable? */ - let failedDueToTerrain: boolean = false; - let failedDueToWeather: boolean = false; + let failedDueToTerrain = false; + let failedDueToWeather = false; if (success) { const passesConditions = move.applyConditions(this.pokemon, targets[0], move); failedDueToWeather = globalScene.arena.isMoveWeatherCancelled(this.pokemon, move); @@ -350,7 +381,6 @@ export class MovePhase extends BattlePhase { success = passesConditions && !failedDueToWeather && !failedDueToTerrain; } - // Update the battle's "last move" pointer, unless we're currently mimicking a move. if (!allMoves[this.move.moveId].hasAttr(CopyMoveAttr)) { // The last move used is unaffected by moves that fail @@ -367,14 +397,20 @@ export class MovePhase extends BattlePhase { */ if (success) { applyPreAttackAbAttrs(PokemonTypeChangeAbAttr, this.pokemon, null, this.move.getMove()); - globalScene.unshiftPhase(new MoveEffectPhase(this.pokemon.getBattlerIndex(), this.targets, this.move, this.reflected)); - + globalScene.unshiftPhase( + new MoveEffectPhase(this.pokemon.getBattlerIndex(), this.targets, this.move, this.reflected), + ); } else { - if ([ Moves.ROAR, Moves.WHIRLWIND, Moves.TRICK_OR_TREAT, Moves.FORESTS_CURSE ].includes(this.move.moveId)) { + if ([Moves.ROAR, Moves.WHIRLWIND, Moves.TRICK_OR_TREAT, Moves.FORESTS_CURSE].includes(this.move.moveId)) { applyPreAttackAbAttrs(PokemonTypeChangeAbAttr, this.pokemon, null, this.move.getMove()); } - this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual }); + this.pokemon.pushMoveHistory({ + move: this.move.moveId, + targets: this.targets, + result: MoveResult.FAIL, + virtual: this.move.virtual, + }); const failureMessage = move.getFailedText(this.pokemon, targets[0], move); let failedText: string | undefined; @@ -413,7 +449,12 @@ export class MovePhase extends BattlePhase { this.showMoveText(); globalScene.unshiftPhase(new MoveChargePhase(this.pokemon.getBattlerIndex(), this.targets[0], this.move)); } else { - this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual }); + this.pokemon.pushMoveHistory({ + move: this.move.moveId, + targets: this.targets, + result: MoveResult.FAIL, + virtual: this.move.virtual, + }); const failureMessage = move.getFailedText(this.pokemon, targets[0], move); this.showMoveText(); @@ -443,7 +484,9 @@ export class MovePhase extends BattlePhase { * TODO: This hardcodes the PP increase at 1 per opponent, rather than deferring to the ability. */ public getPpIncreaseFromPressure(targets: Pokemon[]): number { - const foesWithPressure = this.pokemon.getOpponents().filter(o => targets.includes(o) && o.isActive(true) && o.hasAbilityWithAttr(IncreasePpAbAttr)); + const foesWithPressure = this.pokemon + .getOpponents() + .filter(o => targets.includes(o) && o.isActive(true) && o.hasAbilityWithAttr(IncreasePpAbAttr)); return foesWithPressure.length; } @@ -458,10 +501,13 @@ export class MovePhase extends BattlePhase { const redirectTarget = new NumberHolder(currentTarget); // check move redirection abilities of every pokemon *except* the user. - globalScene.getField(true).filter(p => p !== this.pokemon).forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, false, this.move.moveId, redirectTarget)); + globalScene + .getField(true) + .filter(p => p !== this.pokemon) + .forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, false, this.move.moveId, redirectTarget)); /** `true` if an Ability is responsible for redirecting the move to another target; `false` otherwise */ - let redirectedByAbility = (currentTarget !== redirectTarget.value); + let redirectedByAbility = currentTarget !== redirectTarget.value; // check for center-of-attention tags (note that this will override redirect abilities) this.pokemon.getOpponents().forEach(p => { @@ -469,7 +515,11 @@ export class MovePhase extends BattlePhase { // TODO: don't hardcode this interaction. // Handle interaction between the rage powder center-of-attention tag and moves used by grass types/overcoat-havers (which are immune to RP's redirect) - if (redirectTag && (!redirectTag.powder || (!this.pokemon.isOfType(PokemonType.GRASS) && !this.pokemon.hasAbility(Abilities.OVERCOAT)))) { + if ( + redirectTag && + (!redirectTag.powder || + (!this.pokemon.isOfType(PokemonType.GRASS) && !this.pokemon.hasAbility(Abilities.OVERCOAT))) + ) { redirectTarget.value = p.getBattlerIndex(); redirectedByAbility = false; } @@ -477,7 +527,7 @@ export class MovePhase extends BattlePhase { if (currentTarget !== redirectTarget.value) { const bypassRedirectAttrs = this.move.getMove().getAttrs(BypassRedirectAttr); - bypassRedirectAttrs.forEach((attr) => { + bypassRedirectAttrs.forEach(attr => { if (!attr.abilitiesOnly || redirectedByAbility) { redirectTarget.value = currentTarget; } @@ -485,7 +535,12 @@ export class MovePhase extends BattlePhase { if (this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr)) { redirectTarget.value = currentTarget; - globalScene.unshiftPhase(new ShowAbilityPhase(this.pokemon.getBattlerIndex(), this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr))); + globalScene.unshiftPhase( + new ShowAbilityPhase( + this.pokemon.getBattlerIndex(), + this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), + ), + ); } this.targets[0] = redirectTarget.value; @@ -554,7 +609,11 @@ export class MovePhase extends BattlePhase { frenzyMissFunc(this.pokemon, this.move.getMove()); } - this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL, targets: this.targets }); + this.pokemon.pushMoveHistory({ + move: Moves.NONE, + result: MoveResult.FAIL, + targets: this.targets, + }); this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); this.pokemon.lapseTags(BattlerTagLapseType.AFTER_MOVE); @@ -576,10 +635,13 @@ export class MovePhase extends BattlePhase { return; } - globalScene.queueMessage(i18next.t(this.reflected ? "battle:magicCoatActivated" : "battle:useMove", { - pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), - moveName: this.move.getName() - }), 500); + globalScene.queueMessage( + i18next.t(this.reflected ? "battle:magicCoatActivated" : "battle:useMove", { + pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), + moveName: this.move.getName(), + }), + 500, + ); applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents()[0], this.move.getMove()); } diff --git a/src/phases/mystery-encounter-phases.ts b/src/phases/mystery-encounter-phases.ts index da78f59535f..26012df191d 100644 --- a/src/phases/mystery-encounter-phases.ts +++ b/src/phases/mystery-encounter-phases.ts @@ -67,7 +67,9 @@ export class MysteryEncounterPhase extends Phase { if (!this.optionSelectSettings) { // Sets flag that ME was encountered, only if this is not a followup option select phase // Can be used in later MEs to check for requirements to spawn, run history, etc. - globalScene.mysteryEncounterSaveData.encounteredEvents.push(new SeenEncounterData(encounter.encounterType, encounter.encounterTier, globalScene.currentBattle.waveIndex)); + globalScene.mysteryEncounterSaveData.encounteredEvents.push( + new SeenEncounterData(encounter.encounterType, encounter.encounterTier, globalScene.currentBattle.waveIndex), + ); } // Initiates encounter dialogue window and option select @@ -86,7 +88,10 @@ export class MysteryEncounterPhase extends Phase { if (!this.optionSelectSettings) { // Saves the selected option in the ME save data, only if this is not a followup option select phase // Can be used for analytics purposes to track what options are popular on certain encounters - const encounterSaveData = globalScene.mysteryEncounterSaveData.encounteredEvents[globalScene.mysteryEncounterSaveData.encounteredEvents.length - 1]; + const encounterSaveData = + globalScene.mysteryEncounterSaveData.encounteredEvents[ + globalScene.mysteryEncounterSaveData.encounteredEvents.length - 1 + ]; if (encounterSaveData.type === globalScene.currentBattle.mysteryEncounter?.encounterType) { encounterSaveData.selectedOption = index; } @@ -101,12 +106,11 @@ export class MysteryEncounterPhase extends Phase { if (option.onPreOptionPhase) { globalScene.executeWithSeedOffset(async () => { - return await option.onPreOptionPhase!() - .then((result) => { - if (isNullOrUndefined(result) || result) { - this.continueEncounter(); - } - }); + return await option.onPreOptionPhase!().then(result => { + if (isNullOrUndefined(result) || result) { + this.continueEncounter(); + } + }); }, globalScene.currentBattle.mysteryEncounter?.getSeedOffset()); } else { this.continueEncounter(); @@ -141,7 +145,14 @@ export class MysteryEncounterPhase extends Phase { i++; if (title) { - globalScene.ui.showDialogue(text ?? "", title, null, nextAction, 0, i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0); + globalScene.ui.showDialogue( + text ?? "", + title, + null, + nextAction, + 0, + i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0, + ); } else { globalScene.ui.showText(text ?? "", null, nextAction, i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0, true); } @@ -210,10 +221,6 @@ export class MysteryEncounterOptionSelectedPhase extends Phase { * See {@linkcode TurnEndPhase} for more details */ export class MysteryEncounterBattleStartCleanupPhase extends Phase { - constructor() { - super(); - } - /** * Cleans up `TURN_END` tags, any {@linkcode PostTurnStatusEffectPhase}s, checks for Pokemon switches, then continues */ @@ -221,20 +228,25 @@ export class MysteryEncounterBattleStartCleanupPhase extends Phase { super.start(); // Lapse any residual flinches/endures but ignore all other turn-end battle tags - const includedLapseTags = [ BattlerTagType.FLINCHED, BattlerTagType.ENDURING ]; + const includedLapseTags = [BattlerTagType.FLINCHED, BattlerTagType.ENDURING]; const field = globalScene.getField(true).filter(p => p.summonData); field.forEach(pokemon => { const tags = pokemon.summonData.tags; - tags.filter(t => includedLapseTags.includes(t.tagType) - && t.lapseTypes.includes(BattlerTagLapseType.TURN_END) - && !(t.lapse(pokemon, BattlerTagLapseType.TURN_END))).forEach(t => { - t.onRemove(pokemon); - tags.splice(tags.indexOf(t), 1); - }); + tags + .filter( + t => + includedLapseTags.includes(t.tagType) && + t.lapseTypes.includes(BattlerTagLapseType.TURN_END) && + !t.lapse(pokemon, BattlerTagLapseType.TURN_END), + ) + .forEach(t => { + t.onRemove(pokemon); + tags.splice(tags.indexOf(t), 1); + }); }); // Remove any status tick phases - while (!!globalScene.findPhase(p => p instanceof PostTurnStatusEffectPhase)) { + while (globalScene.findPhase(p => p instanceof PostTurnStatusEffectPhase)) { globalScene.tryRemovePhase(p => p instanceof PostTurnStatusEffectPhase); } @@ -303,16 +315,23 @@ export class MysteryEncounterBattlePhase extends Phase { if (encounterMode === MysteryEncounterMode.TRAINER_BATTLE) { if (globalScene.currentBattle.double) { - return i18next.t("battle:trainerAppearedDouble", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }); - - } else { - return i18next.t("battle:trainerAppeared", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }); + return i18next.t("battle:trainerAppearedDouble", { + trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true), + }); } + return i18next.t("battle:trainerAppeared", { + trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true), + }); } return enemyField.length === 1 - ? i18next.t("battle:singleWildAppeared", { pokemonName: enemyField[0].name }) - : i18next.t("battle:multiWildAppeared", { pokemonName1: enemyField[0].name, pokemonName2: enemyField[1].name }); + ? i18next.t("battle:singleWildAppeared", { + pokemonName: enemyField[0].name, + }) + : i18next.t("battle:multiWildAppeared", { + pokemonName1: enemyField[0].name, + pokemonName2: enemyField[1].name, + }); } /** @@ -367,7 +386,10 @@ export class MysteryEncounterBattlePhase extends Phase { } else { const trainer = globalScene.currentBattle.trainer; let message: string; - globalScene.executeWithSeedOffset(() => message = Utils.randSeedItem(encounterMessages), globalScene.currentBattle.mysteryEncounter?.getSeedOffset()); + globalScene.executeWithSeedOffset( + () => (message = Utils.randSeedItem(encounterMessages)), + globalScene.currentBattle.mysteryEncounter?.getSeedOffset(), + ); message = message!; // tell TS compiler it's defined now const showDialogueAndSummon = () => { globalScene.ui.showDialogue(message, trainer?.getName(TrainerSlot.NONE, true), null, () => { @@ -375,7 +397,13 @@ export class MysteryEncounterBattlePhase extends Phase { }); }; if (globalScene.currentBattle.trainer?.config.hasCharSprite && !globalScene.ui.shouldSkipDialogue(message)) { - globalScene.showFieldOverlay(500).then(() => globalScene.charSprite.showCharacter(trainer?.getKey()!, getCharVariantFromDialogue(encounterMessages[0])).then(() => showDialogueAndSummon())); // TODO: is this bang correct? + globalScene + .showFieldOverlay(500) + .then(() => + globalScene.charSprite + .showCharacter(trainer?.getKey()!, getCharVariantFromDialogue(encounterMessages[0])) + .then(() => showDialogueAndSummon()), + ); // TODO: is this bang correct? } else { showDialogueAndSummon(); } @@ -415,7 +443,7 @@ export class MysteryEncounterBattlePhase extends Phase { } } else { if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) { - globalScene.getPlayerField().forEach((pokemon) => pokemon.lapseTag(BattlerTagType.COMMANDED)); + globalScene.getPlayerField().forEach(pokemon => pokemon.lapseTag(BattlerTagType.COMMANDED)); globalScene.pushPhase(new ReturnPhase(1)); } globalScene.pushPhase(new ToggleDoublePositionPhase(false)); @@ -458,7 +486,7 @@ export class MysteryEncounterBattlePhase extends Phase { onComplete: () => { trainer.untint(100, "Sine.easeOut"); trainer.playAnim(); - } + }, }); } @@ -469,7 +497,7 @@ export class MysteryEncounterBattlePhase extends Phase { y: "-=16", alpha: 0, ease: "Sine.easeInOut", - duration: 750 + duration: 750, }); } } @@ -488,7 +516,7 @@ export class MysteryEncounterBattlePhase extends Phase { export class MysteryEncounterRewardsPhase extends Phase { addHealPhase: boolean; - constructor(addHealPhase: boolean = false) { + constructor(addHealPhase = false) { super(); this.addHealPhase = addHealPhase; } @@ -532,7 +560,12 @@ export class MysteryEncounterRewardsPhase extends Phase { encounter.doEncounterRewards(); } else if (this.addHealPhase) { globalScene.tryRemovePhase(p => p instanceof SelectModifierPhase); - globalScene.unshiftPhase(new SelectModifierPhase(0, undefined, { fillRemaining: false, rerollMultiplier: -1 })); + globalScene.unshiftPhase( + new SelectModifierPhase(0, undefined, { + fillRemaining: false, + rerollMultiplier: -1, + }), + ); } globalScene.pushPhase(new PostMysteryEncounterPhase()); @@ -564,12 +597,11 @@ export class PostMysteryEncounterPhase extends Phase { if (this.onPostOptionSelect) { globalScene.executeWithSeedOffset(async () => { - return await this.onPostOptionSelect!() - .then((result) => { - if (isNullOrUndefined(result) || result) { - this.continueEncounter(); - } - }); + return await this.onPostOptionSelect!().then(result => { + if (isNullOrUndefined(result) || result) { + this.continueEncounter(); + } + }); }, globalScene.currentBattle.mysteryEncounter?.getSeedOffset() * 2000); } else { this.continueEncounter(); @@ -600,7 +632,14 @@ export class PostMysteryEncounterPhase extends Phase { i++; globalScene.ui.setMode(Mode.MESSAGE); if (title) { - globalScene.ui.showDialogue(text ?? "", title, null, nextAction, 0, i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0); + globalScene.ui.showDialogue( + text ?? "", + title, + null, + nextAction, + 0, + i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0, + ); } else { globalScene.ui.showText(text ?? "", null, nextAction, i === 1 ? this.FIRST_DIALOGUE_PROMPT_DELAY : 0, true); } diff --git a/src/phases/new-biome-encounter-phase.ts b/src/phases/new-biome-encounter-phase.ts index 2de9a4300c5..ed768742aac 100644 --- a/src/phases/new-biome-encounter-phase.ts +++ b/src/phases/new-biome-encounter-phase.ts @@ -23,7 +23,7 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase { } const enemyField = globalScene.getEnemyField(); - const moveTargets: any[] = [ globalScene.arenaEnemy, enemyField ]; + const moveTargets: any[] = [globalScene.arenaEnemy, enemyField]; const mysteryEncounter = globalScene.currentBattle?.mysteryEncounter?.introVisuals; if (mysteryEncounter) { moveTargets.push(mysteryEncounter); @@ -37,7 +37,7 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase { if (!this.tryOverrideForBattleSpec()) { this.doEncounterCommon(); } - } + }, }); } diff --git a/src/phases/next-encounter-phase.ts b/src/phases/next-encounter-phase.ts index 229d37f9a69..e53f775f083 100644 --- a/src/phases/next-encounter-phase.ts +++ b/src/phases/next-encounter-phase.ts @@ -23,7 +23,13 @@ export class NextEncounterPhase extends EncounterPhase { globalScene.arenaNextEnemy.setVisible(true); const enemyField = globalScene.getEnemyField(); - const moveTargets: any[] = [ globalScene.arenaEnemy, globalScene.arenaNextEnemy, globalScene.currentBattle.trainer, enemyField, globalScene.lastEnemyTrainer ]; + const moveTargets: any[] = [ + globalScene.arenaEnemy, + globalScene.arenaNextEnemy, + globalScene.currentBattle.trainer, + enemyField, + globalScene.lastEnemyTrainer, + ]; const lastEncounterVisuals = globalScene.lastMysteryEncounter?.introVisuals; if (lastEncounterVisuals) { moveTargets.push(lastEncounterVisuals); @@ -36,7 +42,7 @@ export class NextEncounterPhase extends EncounterPhase { globalScene.tweens.add({ targets: nextEncounterVisuals, x: "-=200", - duration: 2000 + duration: 2000, }); } else { moveTargets.push(nextEncounterVisuals); @@ -64,13 +70,12 @@ export class NextEncounterPhase extends EncounterPhase { if (!this.tryOverrideForBattleSpec()) { this.doEncounterCommon(); } - } + }, }); } /** * Do nothing (since this is simply the next wave in the same biome). */ - trySetWeatherIfNewBiome(): void { - } + trySetWeatherIfNewBiome(): void {} } diff --git a/src/phases/obtain-status-effect-phase.ts b/src/phases/obtain-status-effect-phase.ts index b01a90bd235..a0c0c14e93f 100644 --- a/src/phases/obtain-status-effect-phase.ts +++ b/src/phases/obtain-status-effect-phase.ts @@ -13,7 +13,13 @@ export class ObtainStatusEffectPhase extends PokemonPhase { private sourceText?: string | null; private sourcePokemon?: Pokemon | null; - constructor(battlerIndex: BattlerIndex, statusEffect?: StatusEffect, turnsRemaining?: number, sourceText?: string | null, sourcePokemon?: Pokemon | null) { + constructor( + battlerIndex: BattlerIndex, + statusEffect?: StatusEffect, + turnsRemaining?: number, + sourceText?: string | null, + sourcePokemon?: Pokemon | null, + ) { super(battlerIndex); this.statusEffect = statusEffect; @@ -31,13 +37,21 @@ export class ObtainStatusEffectPhase extends PokemonPhase { } pokemon.updateInfo(true); new CommonBattleAnim(CommonAnim.POISON + (this.statusEffect! - 1), pokemon).play(false, () => { - globalScene.queueMessage(getStatusEffectObtainText(this.statusEffect, getPokemonNameWithAffix(pokemon), this.sourceText ?? undefined)); + globalScene.queueMessage( + getStatusEffectObtainText( + this.statusEffect, + getPokemonNameWithAffix(pokemon), + this.sourceText ?? undefined, + ), + ); this.end(); }); return; } } else if (pokemon.status?.effect === this.statusEffect) { - globalScene.queueMessage(getStatusEffectOverlapText(this.statusEffect ?? StatusEffect.NONE, getPokemonNameWithAffix(pokemon))); + globalScene.queueMessage( + getStatusEffectOverlapText(this.statusEffect ?? StatusEffect.NONE, getPokemonNameWithAffix(pokemon)), + ); } this.end(); } diff --git a/src/phases/party-heal-phase.ts b/src/phases/party-heal-phase.ts index c87c5d00be5..d95400a3f48 100644 --- a/src/phases/party-heal-phase.ts +++ b/src/phases/party-heal-phase.ts @@ -23,7 +23,7 @@ export class PartyHealPhase extends BattlePhase { pokemon.hp = pokemon.getMaxHp(); pokemon.resetStatus(); for (const move of pokemon.moveset) { - move!.ppUsed = 0; // TODO: is this bang correct? + move!.ppUsed = 0; // TODO: is this bang correct? } pokemon.updateInfo(true); } diff --git a/src/phases/party-member-pokemon-phase.ts b/src/phases/party-member-pokemon-phase.ts index 592f35834aa..a782eabda38 100644 --- a/src/phases/party-member-pokemon-phase.ts +++ b/src/phases/party-member-pokemon-phase.ts @@ -11,9 +11,7 @@ export abstract class PartyMemberPokemonPhase extends FieldPhase { super(); this.partyMemberIndex = partyMemberIndex; - this.fieldIndex = partyMemberIndex < globalScene.currentBattle.getBattlerCount() - ? partyMemberIndex - : -1; + this.fieldIndex = partyMemberIndex < globalScene.currentBattle.getBattlerCount() ? partyMemberIndex : -1; this.player = player; } diff --git a/src/phases/pokemon-anim-phase.ts b/src/phases/pokemon-anim-phase.ts index 54140ec96b5..b9c91508b5a 100644 --- a/src/phases/pokemon-anim-phase.ts +++ b/src/phases/pokemon-anim-phase.ts @@ -6,7 +6,6 @@ import { isNullOrUndefined } from "#app/utils"; import { PokemonAnimType } from "#enums/pokemon-anim-type"; import { Species } from "#enums/species"; - export class PokemonAnimPhase extends BattlePhase { /** The type of animation to play in this phase */ private key: PokemonAnimType; @@ -60,19 +59,19 @@ export class PokemonAnimPhase extends BattlePhase { const sprite = globalScene.addFieldSprite( this.pokemon.x + this.pokemon.getSprite().x, this.pokemon.y + this.pokemon.getSprite().y, - `pkmn${this.pokemon.isPlayer() ? "__back" : ""}__sub` + `pkmn${this.pokemon.isPlayer() ? "__back" : ""}__sub`, ); sprite.setOrigin(0.5, 1); globalScene.field.add(sprite); return sprite; }; - const [ subSprite, subTintSprite ] = [ getSprite(), getSprite() ]; + const [subSprite, subTintSprite] = [getSprite(), getSprite()]; const subScale = this.pokemon.getSpriteScale() * (this.pokemon.isPlayer() ? 0.5 : 1); subSprite.setVisible(false); subSprite.setScale(subScale); - subTintSprite.setTintFill(0xFFFFFF); + subTintSprite.setTintFill(0xffffff); subTintSprite.setScale(0.01); if (this.pokemon.isPlayer()) { @@ -87,7 +86,7 @@ export class PokemonAnimPhase extends BattlePhase { x: this.pokemon.x + this.pokemon.getSubstituteOffset()[0], y: this.pokemon.y + this.pokemon.getSubstituteOffset()[1], alpha: 0.5, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); globalScene.tweens.add({ @@ -108,9 +107,9 @@ export class PokemonAnimPhase extends BattlePhase { subTintSprite.destroy(); substitute.sprite = subSprite; this.end(); - } + }, }); - } + }, }); } @@ -128,7 +127,7 @@ export class PokemonAnimPhase extends BattlePhase { targets: subSprite, alpha: 0, ease: "Sine.easeInOut", - duration: 500 + duration: 500, }); globalScene.tweens.add({ @@ -139,7 +138,7 @@ export class PokemonAnimPhase extends BattlePhase { ease: "Sine.easeInOut", delay: 250, duration: 500, - onComplete: () => this.end() + onComplete: () => this.end(), }); } @@ -159,7 +158,7 @@ export class PokemonAnimPhase extends BattlePhase { y: subSprite.y + this.pokemon.getSubstituteOffset()[1], alpha: 0.5, ease: "Sine.easeInOut", - duration: 500 + duration: 500, }); globalScene.tweens.add({ @@ -168,7 +167,7 @@ export class PokemonAnimPhase extends BattlePhase { ease: "Sine.easeInOut", delay: 250, duration: 500, - onComplete: () => this.end() + onComplete: () => this.end(), }); } @@ -186,7 +185,7 @@ export class PokemonAnimPhase extends BattlePhase { const sprite = globalScene.addFieldSprite( subSprite.x, subSprite.y, - `pkmn${this.pokemon.isPlayer() ? "__back" : ""}__sub` + `pkmn${this.pokemon.isPlayer() ? "__back" : ""}__sub`, ); sprite.setOrigin(0.5, 1); globalScene.field.add(sprite); @@ -196,7 +195,7 @@ export class PokemonAnimPhase extends BattlePhase { const subTintSprite = getSprite(); const subScale = this.pokemon.getSpriteScale() * (this.pokemon.isPlayer() ? 0.5 : 1); subTintSprite.setAlpha(0); - subTintSprite.setTintFill(0xFFFFFF); + subTintSprite.setTintFill(0xffffff); subTintSprite.setScale(subScale); globalScene.tweens.add({ @@ -219,7 +218,7 @@ export class PokemonAnimPhase extends BattlePhase { targets: subTintSprite, scale: 0.01, ease: "Sine.cubicEaseIn", - duration: 500 + duration: 500, }); globalScene.tweens.add({ @@ -233,12 +232,12 @@ export class PokemonAnimPhase extends BattlePhase { onComplete: () => { subTintSprite.destroy(); this.end(); - } + }, }); } - } + }, }); - } + }, }); } @@ -256,8 +255,17 @@ export class PokemonAnimPhase extends BattlePhase { const tatsugiriY = this.pokemon.y + this.pokemon.getSprite().y; const getSourceSprite = () => { - const sprite = globalScene.addPokemonSprite(this.pokemon, tatsugiriX, tatsugiriY, this.pokemon.getSprite().texture, this.pokemon.getSprite()!.frame.name, true); - [ "spriteColors", "fusionSpriteColors" ].map(k => sprite.pipelineData[k] = this.pokemon.getSprite().pipelineData[k]); + const sprite = globalScene.addPokemonSprite( + this.pokemon, + tatsugiriX, + tatsugiriY, + this.pokemon.getSprite().texture, + this.pokemon.getSprite()!.frame.name, + true, + ); + ["spriteColors", "fusionSpriteColors"].map( + k => (sprite.pipelineData[k] = this.pokemon.getSprite().pipelineData[k]), + ); sprite.setPipelineData("spriteKey", this.pokemon.getBattleSpriteKey()); sprite.setPipelineData("shiny", this.pokemon.shiny); sprite.setPipelineData("variant", this.pokemon.variant); @@ -281,8 +289,14 @@ export class PokemonAnimPhase extends BattlePhase { targets: sourceSprite, duration: 375, scale: 0.5, - x: { value: tatsugiriX + (dondozoFpOffset[0] - sourceFpOffset[0]) / 2, ease: "Linear" }, - y: { value: (this.pokemon.isPlayer() ? 100 : 65) + sourceFpOffset[1], ease: "Sine.easeOut" }, + x: { + value: tatsugiriX + (dondozoFpOffset[0] - sourceFpOffset[0]) / 2, + ease: "Linear", + }, + y: { + value: (this.pokemon.isPlayer() ? 100 : 65) + sourceFpOffset[1], + ease: "Sine.easeOut", + }, onComplete: () => { globalScene.field.bringToTop(dondozo); globalScene.tweens.add({ @@ -300,11 +314,11 @@ export class PokemonAnimPhase extends BattlePhase { ease: "Sine.easeInOut", scale: 0.85, yoyo: true, - onComplete: () => this.end() + onComplete: () => this.end(), }); - } + }, }); - } + }, }); } @@ -323,9 +337,11 @@ export class PokemonAnimPhase extends BattlePhase { this.pokemon.y + this.pokemon.getSprite().y + this.pokemon.height / 2, tatsugiri.getSprite().texture, tatsugiri.getSprite()!.frame.name, - true + true, + ); + ["spriteColors", "fusionSpriteColors"].map( + k => (tatsuSprite.pipelineData[k] = tatsugiri.getSprite().pipelineData[k]), ); - [ "spriteColors", "fusionSpriteColors" ].map(k => tatsuSprite.pipelineData[k] = tatsugiri.getSprite().pipelineData[k]); tatsuSprite.setPipelineData("spriteKey", tatsugiri.getBattleSpriteKey()); tatsuSprite.setPipelineData("shiny", tatsugiri.shiny); tatsuSprite.setPipelineData("variant", tatsugiri.variant); @@ -352,14 +368,17 @@ export class PokemonAnimPhase extends BattlePhase { duration: 500, scale: 1, x: { value: tatsugiri.x + tatsugiri.getSprite().x, ease: "Linear" }, - y: { value: tatsugiri.y + tatsugiri.getSprite().y, ease: "Sine.easeIn" }, + y: { + value: tatsugiri.y + tatsugiri.getSprite().y, + ease: "Sine.easeIn", + }, onComplete: () => { tatsugiri.setVisible(true); tatsuSprite.destroy(); this.end(); - } + }, }); - } + }, }); } } diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index 6d0621b8f48..ab49def5a3d 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -24,7 +24,17 @@ export class PokemonHealPhase extends CommonAnimPhase { private preventFullHeal: boolean; private fullRestorePP: boolean; - constructor(battlerIndex: BattlerIndex, hpHealed: number, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false, fullRestorePP: boolean = false) { + constructor( + battlerIndex: BattlerIndex, + hpHealed: number, + message: string | null, + showFullHpMessage: boolean, + skipAnim = false, + revive = false, + healStatus = false, + preventFullHeal = false, + fullRestorePP = false, + ) { super(battlerIndex, undefined, CommonAnim.HEALTH_UP); this.hpHealed = hpHealed; @@ -53,7 +63,7 @@ export class PokemonHealPhase extends CommonAnimPhase { } const hasMessage = !!this.message; - const healOrDamage = (!pokemon.isFullHp() || this.hpHealed < 0); + const healOrDamage = !pokemon.isFullHp() || this.hpHealed < 0; const healBlock = pokemon.getTag(BattlerTagType.HEAL_BLOCK) as HealBlockTag; let lastStatusEffect = StatusEffect.NONE; @@ -61,7 +71,8 @@ export class PokemonHealPhase extends CommonAnimPhase { globalScene.queueMessage(healBlock.onActivation(pokemon)); this.message = null; return super.end(); - } else if (healOrDamage) { + } + if (healOrDamage) { const hpRestoreMultiplier = new Utils.NumberHolder(1); if (!this.revive) { globalScene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier); @@ -73,7 +84,7 @@ export class PokemonHealPhase extends CommonAnimPhase { } // Prevent healing to full if specified (in case of healing tokens so Sturdy doesn't cause a softlock) if (this.preventFullHeal && pokemon.hp + healAmount.value >= pokemon.getMaxHp()) { - healAmount.value = (pokemon.getMaxHp() - pokemon.hp) - 1; + healAmount.value = pokemon.getMaxHp() - pokemon.hp - 1; } healAmount.value = pokemon.heal(healAmount.value); if (healAmount.value) { @@ -102,7 +113,9 @@ export class PokemonHealPhase extends CommonAnimPhase { pokemon.resetStatus(); pokemon.updateInfo().then(() => super.end()); } else if (this.showFullHpMessage) { - this.message = i18next.t("battle:hpIsFull", { pokemonName: getPokemonNameWithAffix(pokemon) }); + this.message = i18next.t("battle:hpIsFull", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } if (this.message) { diff --git a/src/phases/pokemon-phase.ts b/src/phases/pokemon-phase.ts index bf4193adb6d..3ca5f09f953 100644 --- a/src/phases/pokemon-phase.ts +++ b/src/phases/pokemon-phase.ts @@ -12,7 +12,10 @@ export abstract class PokemonPhase extends FieldPhase { super(); if (battlerIndex === undefined) { - battlerIndex = globalScene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here? + battlerIndex = globalScene + .getField() + .find(p => p?.isActive())! + .getBattlerIndex(); // TODO: is the bang correct here? } this.battlerIndex = battlerIndex; diff --git a/src/phases/pokemon-transform-phase.ts b/src/phases/pokemon-transform-phase.ts index d67f758b1fd..70b390dc6de 100644 --- a/src/phases/pokemon-transform-phase.ts +++ b/src/phases/pokemon-transform-phase.ts @@ -14,7 +14,7 @@ export class PokemonTransformPhase extends PokemonPhase { protected targetIndex: BattlerIndex; private playSound: boolean; - constructor(userIndex: BattlerIndex, targetIndex: BattlerIndex, playSound: boolean = false) { + constructor(userIndex: BattlerIndex, targetIndex: BattlerIndex, playSound = false) { super(userIndex); this.targetIndex = targetIndex; @@ -23,7 +23,7 @@ export class PokemonTransformPhase extends PokemonPhase { public override start(): void { const user = this.getPokemon(); - const target = globalScene.getField(true).find((p) => p.getBattlerIndex() === this.targetIndex); + const target = globalScene.getField(true).find(p => p.getBattlerIndex() === this.targetIndex); if (!target) { return this.end(); @@ -46,18 +46,17 @@ export class PokemonTransformPhase extends PokemonPhase { user.setStatStage(s, target.getStatStage(s)); } - user.summonData.moveset = target.getMoveset().map((m) => { + user.summonData.moveset = target.getMoveset().map(m => { if (m) { // If PP value is less than 5, do nothing. If greater, we need to reduce the value to 5. return new PokemonMove(m.moveId, 0, 0, false, Math.min(m.getMove().pp, 5)); - } else { - console.warn(`Transform: somehow iterating over a ${m} value when copying moveset!`); - return new PokemonMove(Moves.NONE); } + console.warn(`Transform: somehow iterating over a ${m} value when copying moveset!`); + return new PokemonMove(Moves.NONE); }); user.summonData.types = target.getTypes(); - const promises = [ user.updateInfo() ]; + const promises = [user.updateInfo()]; if (this.playSound) { globalScene.playSound("battle_anims/PRSFX- Transform"); diff --git a/src/phases/post-game-over-phase.ts b/src/phases/post-game-over-phase.ts index 4643d4d1bef..f86ec8496e0 100644 --- a/src/phases/post-game-over-phase.ts +++ b/src/phases/post-game-over-phase.ts @@ -20,14 +20,16 @@ export class PostGameOverPhase extends Phase { if (!success) { return globalScene.reset(true); } - globalScene.gameData.tryClearSession(globalScene.sessionSlotId).then((success: boolean | [boolean, boolean]) => { - if (!success[0]) { - return globalScene.reset(true); - } - globalScene.reset(); - globalScene.unshiftPhase(new TitlePhase()); - this.end(); - }); + globalScene.gameData + .tryClearSession(globalScene.sessionSlotId) + .then((success: boolean | [boolean, boolean]) => { + if (!success[0]) { + return globalScene.reset(true); + } + globalScene.reset(); + globalScene.unshiftPhase(new TitlePhase()); + this.end(); + }); }); }; diff --git a/src/phases/post-summon-phase.ts b/src/phases/post-summon-phase.ts index b92d79501d4..a7aa9389505 100644 --- a/src/phases/post-summon-phase.ts +++ b/src/phases/post-summon-phase.ts @@ -8,10 +8,6 @@ import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags"; import { BattlerTagType } from "#enums/battler-tag-type"; export class PostSummonPhase extends PokemonPhase { - constructor(battlerIndex: BattlerIndex) { - super(battlerIndex); - } - start() { super.start(); @@ -23,13 +19,18 @@ export class PostSummonPhase extends PokemonPhase { globalScene.arena.applyTags(ArenaTrapTag, false, pokemon); // If this is mystery encounter and has post summon phase tag, apply post summon effects - if (globalScene.currentBattle.isBattleMysteryEncounter() && pokemon.findTags(t => t instanceof MysteryEncounterPostSummonTag).length > 0) { + if ( + globalScene.currentBattle.isBattleMysteryEncounter() && + pokemon.findTags(t => t instanceof MysteryEncounterPostSummonTag).length > 0 + ) { pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON); } applyPostSummonAbAttrs(PostSummonAbAttr, pokemon); const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); - field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false)); + for (const p of field) { + applyAbAttrs(CommanderAbAttr, p, null, false); + } this.end(); } diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index 13cac6eed7c..f6341666e7e 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -1,6 +1,13 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; -import { applyAbAttrs, applyPostDamageAbAttrs, BlockNonDirectDamageAbAttr, BlockStatusDamageAbAttr, PostDamageAbAttr, ReduceBurnDamageAbAttr } from "#app/data/ability"; +import { + applyAbAttrs, + applyPostDamageAbAttrs, + BlockNonDirectDamageAbAttr, + BlockStatusDamageAbAttr, + PostDamageAbAttr, + ReduceBurnDamageAbAttr, +} from "#app/data/ability"; import { CommonBattleAnim, CommonAnim } from "#app/data/battle-anims"; import { getStatusEffectActivationText } from "#app/data/status-effect"; import { BattleSpec } from "#app/enums/battle-spec"; @@ -10,6 +17,7 @@ import * as Utils from "#app/utils"; import { PokemonPhase } from "./pokemon-phase"; export class PostTurnStatusEffectPhase extends PokemonPhase { + // biome-ignore lint/complexity/noUselessConstructor: Not unnecessary as it makes battlerIndex required constructor(battlerIndex: BattlerIndex) { super(battlerIndex); } @@ -23,7 +31,9 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { applyAbAttrs(BlockStatusDamageAbAttr, pokemon, cancelled); if (!cancelled.value) { - globalScene.queueMessage(getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon))); + globalScene.queueMessage( + getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon)), + ); const damage = new Utils.NumberHolder(0); switch (pokemon.status.effect) { case StatusEffect.POISON: diff --git a/src/phases/quiet-form-change-phase.ts b/src/phases/quiet-form-change-phase.ts index 81a39f53a76..1512609abf9 100644 --- a/src/phases/quiet-form-change-phase.ts +++ b/src/phases/quiet-form-change-phase.ts @@ -11,7 +11,12 @@ import { getPokemonNameWithAffix } from "#app/messages"; import { BattlePhase } from "./battle-phase"; import { MovePhase } from "./move-phase"; import { PokemonHealPhase } from "./pokemon-heal-phase"; -import { applyAbAttrs, ClearTerrainAbAttr, ClearWeatherAbAttr, PostTeraFormChangeStatChangeAbAttr } from "#app/data/ability"; +import { + applyAbAttrs, + ClearTerrainAbAttr, + ClearWeatherAbAttr, + PostTeraFormChangeStatChangeAbAttr, +} from "#app/data/ability"; export class QuietFormChangePhase extends BattlePhase { protected pokemon: Pokemon; @@ -35,7 +40,12 @@ export class QuietFormChangePhase extends BattlePhase { if (!this.pokemon.isOnField() || this.pokemon.getTag(SemiInvulnerableTag) || this.pokemon.isFainted()) { if (this.pokemon.isPlayer() || this.pokemon.isActive()) { this.pokemon.changeForm(this.formChange).then(() => { - globalScene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), 1500); + globalScene.ui.showText( + getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), + null, + () => this.end(), + 1500, + ); }); } else { this.end(); @@ -44,7 +54,12 @@ export class QuietFormChangePhase extends BattlePhase { } const getPokemonSprite = () => { - const sprite = globalScene.addPokemonSprite(this.pokemon, this.pokemon.x + this.pokemon.getSprite().x, this.pokemon.y + this.pokemon.getSprite().y, "pkmn__sub"); + const sprite = globalScene.addPokemonSprite( + this.pokemon, + this.pokemon.x + this.pokemon.getSprite().x, + this.pokemon.y + this.pokemon.getSprite().y, + "pkmn__sub", + ); sprite.setOrigin(0.5, 1); const spriteKey = this.pokemon.getBattleSpriteKey(); try { @@ -52,8 +67,13 @@ export class QuietFormChangePhase extends BattlePhase { } catch (err: unknown) { console.error(`Failed to play animation for ${spriteKey}`, err); } - sprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()), isTerastallized: this.pokemon.isTerastallized }); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + sprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + hasShadow: false, + teraColor: getTypeRgb(this.pokemon.getTeraType()), + isTerastallized: this.pokemon.isTerastallized, + }); + ["spriteColors", "fusionSpriteColors"].map(k => { if (this.pokemon.summonData?.speciesForm) { k += "Base"; } @@ -63,7 +83,7 @@ export class QuietFormChangePhase extends BattlePhase { return sprite; }; - const [ pokemonTintSprite, pokemonFormTintSprite ] = [ getPokemonSprite(), getPokemonSprite() ]; + const [pokemonTintSprite, pokemonFormTintSprite] = [getPokemonSprite(), getPokemonSprite()]; this.pokemon.getSprite().on("animationupdate", (_anim, frame) => { if (frame.textureKey === pokemonTintSprite.texture.key) { @@ -74,9 +94,9 @@ export class QuietFormChangePhase extends BattlePhase { }); pokemonTintSprite.setAlpha(0); - pokemonTintSprite.setTintFill(0xFFFFFF); + pokemonTintSprite.setTintFill(0xffffff); pokemonFormTintSprite.setVisible(false); - pokemonFormTintSprite.setTintFill(0xFFFFFF); + pokemonFormTintSprite.setTintFill(0xffffff); globalScene.playSound("battle_anims/PRSFX- Transform"); @@ -102,7 +122,7 @@ export class QuietFormChangePhase extends BattlePhase { scale: 0.01, ease: "Cubic.easeInOut", duration: 500, - onComplete: () => pokemonTintSprite.destroy() + onComplete: () => pokemonTintSprite.destroy(), }); globalScene.tweens.add({ targets: pokemonFormTintSprite, @@ -120,13 +140,18 @@ export class QuietFormChangePhase extends BattlePhase { duration: 1000, onComplete: () => { pokemonTintSprite.setVisible(false); - globalScene.ui.showText(getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), null, () => this.end(), 1500); - } + globalScene.ui.showText( + getSpeciesFormChangeMessage(this.pokemon, this.formChange, preName), + null, + () => this.end(), + 1500, + ); + }, }); - } + }, }); }); - } + }, }); } @@ -134,7 +159,9 @@ export class QuietFormChangePhase extends BattlePhase { this.pokemon.findAndRemoveTags(t => t.tagType === BattlerTagType.AUTOTOMIZED); if (globalScene?.currentBattle.battleSpec === BattleSpec.FINAL_BOSS && this.pokemon instanceof EnemyPokemon) { globalScene.playBgm(); - globalScene.unshiftPhase(new PokemonHealPhase(this.pokemon.getBattlerIndex(), this.pokemon.getMaxHp(), null, false, false, false, true)); + globalScene.unshiftPhase( + new PokemonHealPhase(this.pokemon.getBattlerIndex(), this.pokemon.getMaxHp(), null, false, false, false, true), + ); this.pokemon.findAndRemoveTags(() => true); this.pokemon.bossSegments = 5; this.pokemon.bossSegmentIndex = 4; diff --git a/src/phases/reload-session-phase.ts b/src/phases/reload-session-phase.ts index a88cb1b1de3..3a4a4e0e3a5 100644 --- a/src/phases/reload-session-phase.ts +++ b/src/phases/reload-session-phase.ts @@ -28,12 +28,14 @@ export class ReloadSessionPhase extends Phase { globalScene.gameData.clearLocalData(); - (this.systemDataStr ? globalScene.gameData.initSystem(this.systemDataStr) : globalScene.gameData.loadSystem()).then(() => { - if (delayElapsed) { - this.end(); - } else { - loaded = true; - } - }); + (this.systemDataStr ? globalScene.gameData.initSystem(this.systemDataStr) : globalScene.gameData.loadSystem()).then( + () => { + if (delayElapsed) { + this.end(); + } else { + loaded = true; + } + }, + ); } } diff --git a/src/phases/return-phase.ts b/src/phases/return-phase.ts index 8a876268c8e..6dee982a4f0 100644 --- a/src/phases/return-phase.ts +++ b/src/phases/return-phase.ts @@ -12,7 +12,7 @@ export class ReturnPhase extends SwitchSummonPhase { this.end(); } - summon(): void { } + summon(): void {} onEnd(): void { const pokemon = this.getPokemon(); diff --git a/src/phases/revival-blessing-phase.ts b/src/phases/revival-blessing-phase.ts index a063e325a31..1ed63f76b64 100644 --- a/src/phases/revival-blessing-phase.ts +++ b/src/phases/revival-blessing-phase.ts @@ -24,7 +24,7 @@ export class RevivalBlessingPhase extends BattlePhase { Mode.PARTY, PartyUiMode.REVIVAL_BLESSING, this.user.getFieldIndex(), - (slotIndex: integer, option: PartyOption) => { + (slotIndex: integer, _option: PartyOption) => { if (slotIndex >= 0 && slotIndex < 6) { const pokemon = globalScene.getPlayerParty()[slotIndex]; if (!pokemon || !pokemon.isFainted()) { @@ -34,7 +34,13 @@ export class RevivalBlessingPhase extends BattlePhase { pokemon.resetTurnData(); pokemon.resetStatus(); pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp())); - globalScene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: pokemon.name }), 0, true); + globalScene.queueMessage( + i18next.t("moveTriggers:revivalBlessing", { + pokemonName: pokemon.name, + }), + 0, + true, + ); if (globalScene.currentBattle.double && globalScene.getPlayerParty().length > 1) { const allyPokemon = this.user.getAlly(); diff --git a/src/phases/ribbon-modifier-reward-phase.ts b/src/phases/ribbon-modifier-reward-phase.ts index 72a8f4bf37c..0ee38250ce1 100644 --- a/src/phases/ribbon-modifier-reward-phase.ts +++ b/src/phases/ribbon-modifier-reward-phase.ts @@ -20,13 +20,20 @@ export class RibbonModifierRewardPhase extends ModifierRewardPhase { globalScene.addModifier(newModifier); globalScene.playSound("level_up_fanfare"); globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(i18next.t("battle:beatModeFirstTime", { - speciesName: this.species.name, - gameMode: globalScene.gameMode.getName(), - newModifier: newModifier?.type.name, - }), null, () => { - resolve(); - }, null, true, 1500); + globalScene.ui.showText( + i18next.t("battle:beatModeFirstTime", { + speciesName: this.species.name, + gameMode: globalScene.gameMode.getName(), + newModifier: newModifier?.type.name, + }), + null, + () => { + resolve(); + }, + null, + true, + 1500, + ); }); } } diff --git a/src/phases/scan-ivs-phase.ts b/src/phases/scan-ivs-phase.ts index 9230844ff9b..2a2d68591ca 100644 --- a/src/phases/scan-ivs-phase.ts +++ b/src/phases/scan-ivs-phase.ts @@ -8,7 +8,6 @@ import i18next from "i18next"; import { PokemonPhase } from "./pokemon-phase"; export class ScanIvsPhase extends PokemonPhase { - constructor(battlerIndex: BattlerIndex) { super(battlerIndex); } @@ -25,13 +24,16 @@ export class ScanIvsPhase extends PokemonPhase { const uiTheme = globalScene.uiTheme; // Assuming uiTheme is accessible for (let e = 0; e < enemyField.length; e++) { enemyIvs = enemyField[e].ivs; - const currentIvs = globalScene.gameData.dexData[enemyField[e].species.getRootSpeciesId()].ivs; // we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists + const currentIvs = globalScene.gameData.dexData[enemyField[e].species.getRootSpeciesId()].ivs; // we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists statsContainer = enemyField[e].getBattleInfo().getStatsValueContainer().list as Phaser.GameObjects.Sprite[]; statsContainerLabels = statsContainer.filter(m => m.name.indexOf("icon_stat_label") >= 0); for (let s = 0; s < statsContainerLabels.length; s++) { const ivStat = Stat[statsContainerLabels[s].frame.name]; if (enemyIvs[ivStat] > currentIvs[ivStat] && PERMANENT_STATS.indexOf(Number(ivStat)) >= 0) { - const hexColour = enemyIvs[ivStat] === 31 ? getTextColor(TextStyle.PERFECT_IV, false, uiTheme) : getTextColor(TextStyle.SUMMARY_GREEN, false, uiTheme); + const hexColour = + enemyIvs[ivStat] === 31 + ? getTextColor(TextStyle.PERFECT_IV, false, uiTheme) + : getTextColor(TextStyle.SUMMARY_GREEN, false, uiTheme); const hexTextColour = Phaser.Display.Color.HexStringToColor(hexColour).color; statsContainerLabels[s].setTint(hexTextColour); } @@ -40,17 +42,30 @@ export class ScanIvsPhase extends PokemonPhase { } if (!globalScene.hideIvs) { - globalScene.ui.showText(i18next.t("battle:ivScannerUseQuestion", { pokemonName: getPokemonNameWithAffix(pokemon) }), null, () => { - globalScene.ui.setMode(Mode.CONFIRM, () => { - globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.clearText(); - globalScene.ui.getMessageHandler().promptIvs(pokemon.id, pokemon.ivs).then(() => this.end()); - }, () => { - globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.clearText(); - this.end(); - }); - }); + globalScene.ui.showText( + i18next.t("battle:ivScannerUseQuestion", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + null, + () => { + globalScene.ui.setMode( + Mode.CONFIRM, + () => { + globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.clearText(); + globalScene.ui + .getMessageHandler() + .promptIvs(pokemon.id, pokemon.ivs) + .then(() => this.end()); + }, + () => { + globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.clearText(); + this.end(); + }, + ); + }, + ); } else { this.end(); } diff --git a/src/phases/select-biome-phase.ts b/src/phases/select-biome-phase.ts index ea4dcc4274b..6a11967832a 100644 --- a/src/phases/select-biome-phase.ts +++ b/src/phases/select-biome-phase.ts @@ -28,9 +28,11 @@ export class SelectBiomePhase extends BattlePhase { this.end(); }; - if ((globalScene.gameMode.isClassic && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex + 9)) - || (globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) - || (globalScene.gameMode.hasShortBiomes && !(globalScene.currentBattle.waveIndex % 50))) { + if ( + (globalScene.gameMode.isClassic && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex + 9)) || + (globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) || + (globalScene.gameMode.hasShortBiomes && !(globalScene.currentBattle.waveIndex % 50)) + ) { setNextBiome(Biome.END); } else if (globalScene.gameMode.hasRandomBiomes) { setNextBiome(this.generateNextBiome()); @@ -39,16 +41,18 @@ export class SelectBiomePhase extends BattlePhase { globalScene.executeWithSeedOffset(() => { biomes = (biomeLinks[currentBiome] as (Biome | [Biome, number])[]) .filter(b => !Array.isArray(b) || !Utils.randSeedInt(b[1])) - .map(b => !Array.isArray(b) ? b : b[0]); + .map(b => (!Array.isArray(b) ? b : b[0])); }, globalScene.currentBattle.waveIndex); if (biomes.length > 1 && globalScene.findModifier(m => m instanceof MapModifier)) { let biomeChoices: Biome[] = []; globalScene.executeWithSeedOffset(() => { - biomeChoices = (!Array.isArray(biomeLinks[currentBiome]) - ? [ biomeLinks[currentBiome] as Biome ] - : biomeLinks[currentBiome] as (Biome | [Biome, number])[]) - .filter((b, i) => !Array.isArray(b) || !Utils.randSeedInt(b[1])) - .map(b => Array.isArray(b) ? b[0] : b); + biomeChoices = ( + !Array.isArray(biomeLinks[currentBiome]) + ? [biomeLinks[currentBiome] as Biome] + : (biomeLinks[currentBiome] as (Biome | [Biome, number])[]) + ) + .filter((b, _i) => !Array.isArray(b) || !Utils.randSeedInt(b[1])) + .map(b => (Array.isArray(b) ? b[0] : b)); }, globalScene.currentBattle.waveIndex); const biomeSelectItems = biomeChoices.map(b => { const ret: OptionSelectItem = { @@ -57,13 +61,13 @@ export class SelectBiomePhase extends BattlePhase { globalScene.ui.setMode(Mode.MESSAGE); setNextBiome(b); return true; - } + }, }; return ret; }); globalScene.ui.setMode(Mode.OPTION_SELECT, { options: biomeSelectItems, - delay: 1000 + delay: 1000, }); } else { setNextBiome(biomes[Utils.randSeedInt(biomes.length)]); diff --git a/src/phases/select-gender-phase.ts b/src/phases/select-gender-phase.ts index 45cbb70dcac..1c86536de53 100644 --- a/src/phases/select-gender-phase.ts +++ b/src/phases/select-gender-phase.ts @@ -23,7 +23,7 @@ export class SelectGenderPhase extends Phase { globalScene.gameData.saveSetting(SettingKeys.Player_Gender, 0); globalScene.gameData.saveSystem().then(() => this.end()); return true; - } + }, }, { label: i18next.t("settings:girl"), @@ -32,9 +32,9 @@ export class SelectGenderPhase extends Phase { globalScene.gameData.saveSetting(SettingKeys.Player_Gender, 1); globalScene.gameData.saveSystem().then(() => this.end()); return true; - } - } - ] + }, + }, + ], }); }); } diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 36f18a8d64d..11d448876d3 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -1,9 +1,26 @@ import { globalScene } from "#app/global-scene"; import type { ModifierTier } from "#app/modifier/modifier-tier"; import type { ModifierTypeOption, ModifierType } from "#app/modifier/modifier-type"; -import { regenerateModifierPoolThresholds, getPlayerShopModifierTypeOptionsForWave, PokemonModifierType, FusePokemonModifierType, PokemonMoveModifierType, TmModifierType, RememberMoveModifierType, PokemonPpRestoreModifierType, PokemonPpUpModifierType, ModifierPoolType, getPlayerModifierTypeOptions } from "#app/modifier/modifier-type"; +import { + regenerateModifierPoolThresholds, + getPlayerShopModifierTypeOptionsForWave, + PokemonModifierType, + FusePokemonModifierType, + PokemonMoveModifierType, + TmModifierType, + RememberMoveModifierType, + PokemonPpRestoreModifierType, + PokemonPpUpModifierType, + ModifierPoolType, + getPlayerModifierTypeOptions, +} from "#app/modifier/modifier-type"; import type { Modifier } from "#app/modifier/modifier"; -import { ExtraModifierModifier, HealShopCostModifier, PokemonHeldItemModifier, TempExtraModifierModifier } from "#app/modifier/modifier"; +import { + ExtraModifierModifier, + HealShopCostModifier, + PokemonHeldItemModifier, + TempExtraModifierModifier, +} from "#app/modifier/modifier"; 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"; @@ -23,7 +40,12 @@ export class SelectModifierPhase extends BattlePhase { private typeOptions: ModifierTypeOption[]; - constructor(rerollCount: number = 0, modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings, isCopy: boolean = false) { + constructor( + rerollCount = 0, + modifierTiers?: ModifierTier[], + customModifierSettings?: CustomModifierSettings, + isCopy = false, + ) { super(); this.rerollCount = rerollCount; @@ -52,8 +74,9 @@ export class SelectModifierPhase extends BattlePhase { } // If custom modifiers are specified, overrides default item count - if (!!this.customModifierSettings) { - const newItemCount = (this.customModifierSettings.guaranteedModifierTiers?.length || 0) + + if (this.customModifierSettings) { + const newItemCount = + (this.customModifierSettings.guaranteedModifierTiers?.length || 0) + (this.customModifierSettings.guaranteedModifierTypeOptions?.length || 0) + (this.customModifierSettings.guaranteedModifierTypeFuncs?.length || 0); if (this.customModifierSettings.fillRemaining) { @@ -69,11 +92,22 @@ export class SelectModifierPhase extends BattlePhase { const modifierSelectCallback = (rowCursor: number, cursor: number) => { if (rowCursor < 0 || cursor < 0) { globalScene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => { - globalScene.ui.setOverlayMode(Mode.CONFIRM, () => { - globalScene.ui.revertMode(); - globalScene.ui.setMode(Mode.MESSAGE); - super.end(); - }, () => globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers))); + globalScene.ui.setOverlayMode( + Mode.CONFIRM, + () => { + globalScene.ui.revertMode(); + globalScene.ui.setMode(Mode.MESSAGE); + super.end(); + }, + () => + globalScene.ui.setMode( + Mode.MODIFIER_SELECT, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ), + ); }); return false; } @@ -87,34 +121,74 @@ export class SelectModifierPhase extends BattlePhase { if (rerollCost < 0 || globalScene.money < rerollCost) { globalScene.ui.playError(); return false; - } else { - globalScene.reroll = true; - globalScene.unshiftPhase(new SelectModifierPhase(this.rerollCount + 1, this.typeOptions.map(o => o.type?.tier).filter(t => t !== undefined) as ModifierTier[])); - globalScene.ui.clearText(); - globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); - if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) { - globalScene.money -= rerollCost; - globalScene.updateMoneyText(); - globalScene.animateMoneyChanged(false); - } - globalScene.playSound("se/buy"); } + globalScene.reroll = true; + globalScene.unshiftPhase( + new SelectModifierPhase( + this.rerollCount + 1, + this.typeOptions.map(o => o.type?.tier).filter(t => t !== undefined) as ModifierTier[], + ), + ); + globalScene.ui.clearText(); + globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end()); + if (!Overrides.WAIVE_ROLL_FEE_OVERRIDE) { + globalScene.money -= rerollCost; + globalScene.updateMoneyText(); + globalScene.animateMoneyChanged(false); + } + globalScene.playSound("se/buy"); break; case 1: - globalScene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: number, itemIndex: number, itemQuantity: number, toSlotIndex: number) => { - if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) { - const itemModifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[]; - const itemModifier = itemModifiers[itemIndex]; - globalScene.tryTransferHeldItemModifier(itemModifier, party[toSlotIndex], true, itemQuantity, undefined, undefined, false); - } else { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers)); - } - }, PartyUiHandler.FilterItemMaxStacks); + globalScene.ui.setModeWithoutClear( + Mode.PARTY, + PartyUiMode.MODIFIER_TRANSFER, + -1, + (fromSlotIndex: number, itemIndex: number, itemQuantity: number, toSlotIndex: number) => { + if ( + toSlotIndex !== undefined && + fromSlotIndex < 6 && + toSlotIndex < 6 && + fromSlotIndex !== toSlotIndex && + itemIndex > -1 + ) { + const itemModifiers = globalScene.findModifiers( + m => + m instanceof PokemonHeldItemModifier && + m.isTransferable && + m.pokemonId === party[fromSlotIndex].id, + ) as PokemonHeldItemModifier[]; + const itemModifier = itemModifiers[itemIndex]; + globalScene.tryTransferHeldItemModifier( + itemModifier, + party[toSlotIndex], + true, + itemQuantity, + undefined, + undefined, + false, + ); + } else { + globalScene.ui.setMode( + Mode.MODIFIER_SELECT, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ); + } + }, + PartyUiHandler.FilterItemMaxStacks, + ); break; case 2: globalScene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.CHECK, -1, () => { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers)); + globalScene.ui.setMode( + Mode.MODIFIER_SELECT, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ); }); break; case 3: @@ -143,8 +217,14 @@ export class SelectModifierPhase extends BattlePhase { } break; default: - const shopOptions = getPlayerShopModifierTypeOptionsForWave(globalScene.currentBattle.waveIndex, globalScene.getWaveMoneyAmount(1)); - const shopOption = shopOptions[rowCursor > 2 || shopOptions.length <= SHOP_OPTIONS_ROW_LIMIT ? cursor : cursor + SHOP_OPTIONS_ROW_LIMIT]; + const shopOptions = getPlayerShopModifierTypeOptionsForWave( + globalScene.currentBattle.waveIndex, + globalScene.getWaveMoneyAmount(1), + ); + const shopOption = + shopOptions[ + rowCursor > 2 || shopOptions.length <= SHOP_OPTIONS_ROW_LIMIT ? cursor : cursor + SHOP_OPTIONS_ROW_LIMIT + ]; if (shopOption.type) { modifierType = shopOption.type; } @@ -155,18 +235,18 @@ export class SelectModifierPhase extends BattlePhase { break; } - if (cost! && (globalScene.money < cost) && !Overrides.WAIVE_ROLL_FEE_OVERRIDE) { // TODO: is the bang on cost correct? + if (cost! && globalScene.money < cost && !Overrides.WAIVE_ROLL_FEE_OVERRIDE) { + // TODO: is the bang on cost correct? globalScene.ui.playError(); return false; } - const applyModifier = (modifier: Modifier, playSound: boolean = false) => { + const applyModifier = (modifier: Modifier, playSound = false) => { const result = globalScene.addModifier(modifier, false, playSound, undefined, undefined, cost); // Queue a copy of this phase when applying a TM or Memory Mushroom. // If the player selects either of these, then escapes out of consuming them, // they are returned to a shop in the same state. - if (modifier.type instanceof RememberMoveModifierType || - modifier.type instanceof TmModifierType) { + if (modifier.type instanceof RememberMoveModifierType || modifier.type instanceof TmModifierType) { globalScene.unshiftPhase(this.copy()); } @@ -189,53 +269,96 @@ export class SelectModifierPhase extends BattlePhase { } }; - if (modifierType! instanceof PokemonModifierType) { //TODO: is the bang correct? + if (modifierType! instanceof PokemonModifierType) { + //TODO: is the bang correct? if (modifierType instanceof FusePokemonModifierType) { - globalScene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: number, spliceSlotIndex: number) => { - if (spliceSlotIndex !== undefined && fromSlotIndex < 6 && spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex) { - globalScene.ui.setMode(Mode.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, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers)); - } - }, modifierType.selectFilter); + globalScene.ui.setModeWithoutClear( + Mode.PARTY, + PartyUiMode.SPLICE, + -1, + (fromSlotIndex: number, spliceSlotIndex: number) => { + if ( + spliceSlotIndex !== undefined && + fromSlotIndex < 6 && + spliceSlotIndex < 6 && + fromSlotIndex !== spliceSlotIndex + ) { + globalScene.ui.setMode(Mode.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, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ); + } + }, + modifierType.selectFilter, + ); } else { const pokemonModifierType = modifierType as PokemonModifierType; const isMoveModifier = modifierType instanceof PokemonMoveModifierType; const isTmModifier = modifierType instanceof TmModifierType; const isRememberMoveModifier = modifierType instanceof RememberMoveModifierType; - const isPpRestoreModifier = (modifierType instanceof PokemonPpRestoreModifierType || modifierType instanceof PokemonPpUpModifierType); - const partyUiMode = isMoveModifier ? PartyUiMode.MOVE_MODIFIER - : isTmModifier ? PartyUiMode.TM_MODIFIER - : isRememberMoveModifier ? PartyUiMode.REMEMBER_MOVE_MODIFIER + const isPpRestoreModifier = + modifierType instanceof PokemonPpRestoreModifierType || modifierType instanceof PokemonPpUpModifierType; + const partyUiMode = isMoveModifier + ? PartyUiMode.MOVE_MODIFIER + : isTmModifier + ? PartyUiMode.TM_MODIFIER + : isRememberMoveModifier + ? PartyUiMode.REMEMBER_MOVE_MODIFIER : PartyUiMode.MODIFIER; - const tmMoveId = isTmModifier - ? (modifierType as TmModifierType).moveId - : undefined; - globalScene.ui.setModeWithoutClear(Mode.PARTY, partyUiMode, -1, (slotIndex: number, option: PartyOption) => { - if (slotIndex < 6) { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { - const modifier = !isMoveModifier - ? !isRememberMoveModifier - ? modifierType.newModifier(party[slotIndex]) - : modifierType.newModifier(party[slotIndex], option as number) - : modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1); - applyModifier(modifier!, true); // TODO: is the bang correct? - }); - } else { - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers)); - } - }, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined, tmMoveId, isPpRestoreModifier); + const tmMoveId = isTmModifier ? (modifierType as TmModifierType).moveId : undefined; + globalScene.ui.setModeWithoutClear( + Mode.PARTY, + partyUiMode, + -1, + (slotIndex: number, option: PartyOption) => { + if (slotIndex < 6) { + globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { + const modifier = !isMoveModifier + ? !isRememberMoveModifier + ? modifierType.newModifier(party[slotIndex]) + : modifierType.newModifier(party[slotIndex], option as number) + : modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1); + applyModifier(modifier!, true); // TODO: is the bang correct? + }); + } else { + globalScene.ui.setMode( + Mode.MODIFIER_SELECT, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ); + } + }, + pokemonModifierType.selectFilter, + modifierType instanceof PokemonMoveModifierType + ? (modifierType as PokemonMoveModifierType).moveSelectFilter + : undefined, + tmMoveId, + isPpRestoreModifier, + ); } } else { applyModifier(modifierType!.newModifier()!); // TODO: is the bang correct? } - return !cost!;// TODO: is the bang correct? + return !cost!; // TODO: is the bang correct? }; - globalScene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), this.typeOptions, modifierSelectCallback, this.getRerollCost(globalScene.lockModifierTiers)); + globalScene.ui.setMode( + Mode.MODIFIER_SELECT, + this.isPlayer(), + this.typeOptions, + modifierSelectCallback, + this.getRerollCost(globalScene.lockModifierTiers), + ); } updateSeed(): void { @@ -250,8 +373,9 @@ export class SelectModifierPhase extends BattlePhase { let baseValue = 0; if (Overrides.WAIVE_ROLL_FEE_OVERRIDE) { return baseValue; - } else if (lockRarities) { - const tierValues = [ 50, 125, 300, 750, 2000 ]; + } + if (lockRarities) { + const tierValues = [50, 125, 300, 750, 2000]; for (const opt of this.typeOptions) { baseValue += tierValues[opt.type.tier ?? 0]; } @@ -270,7 +394,10 @@ export class SelectModifierPhase extends BattlePhase { multiplier = this.customModifierSettings.rerollMultiplier; } - const baseMultiplier = Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 10) * baseValue * (2 ** this.rerollCount) * multiplier, Number.MAX_SAFE_INTEGER); + const baseMultiplier = Math.min( + Math.ceil(globalScene.currentBattle.waveIndex / 10) * baseValue * 2 ** this.rerollCount * multiplier, + Number.MAX_SAFE_INTEGER, + ); // Apply Black Sludge to reroll cost const modifiedRerollCost = new NumberHolder(baseMultiplier); @@ -283,15 +410,24 @@ export class SelectModifierPhase extends BattlePhase { } getModifierTypeOptions(modifierCount: number): ModifierTypeOption[] { - return getPlayerModifierTypeOptions(modifierCount, globalScene.getPlayerParty(), globalScene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings); + return getPlayerModifierTypeOptions( + modifierCount, + globalScene.getPlayerParty(), + globalScene.lockModifierTiers ? this.modifierTiers : undefined, + this.customModifierSettings, + ); } copy(): SelectModifierPhase { return new SelectModifierPhase( this.rerollCount, this.modifierTiers, - { guaranteedModifierTypeOptions: this.typeOptions, rerollMultiplier: this.customModifierSettings?.rerollMultiplier, allowLuckUpgrades: false }, - true + { + guaranteedModifierTypeOptions: this.typeOptions, + rerollMultiplier: this.customModifierSettings?.rerollMultiplier, + allowLuckUpgrades: false, + }, + true, ); } diff --git a/src/phases/select-starter-phase.ts b/src/phases/select-starter-phase.ts index b7ad15533a6..103174a4c83 100644 --- a/src/phases/select-starter-phase.ts +++ b/src/phases/select-starter-phase.ts @@ -15,7 +15,6 @@ import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; import * as Utils from "../utils"; export class SelectStarterPhase extends Phase { - constructor() { super(); } @@ -59,19 +58,30 @@ export class SelectStarterPhase extends Phase { starterFormIndex = Overrides.STARTER_FORM_OVERRIDES[starter.species.speciesId]!; } - let starterGender = starter.species.malePercent !== null - ? !starterProps.female ? Gender.MALE : Gender.FEMALE - : Gender.GENDERLESS; + let starterGender = + starter.species.malePercent !== null ? (!starterProps.female ? Gender.MALE : Gender.FEMALE) : Gender.GENDERLESS; if (Overrides.GENDER_OVERRIDE !== null) { starterGender = Overrides.GENDER_OVERRIDE; } const starterIvs = globalScene.gameData.dexData[starter.species.speciesId].ivs.slice(0); - const starterPokemon = globalScene.addPlayerPokemon(starter.species, globalScene.gameMode.getStartingLevel(), starter.abilityIndex, starterFormIndex, starterGender, starterProps.shiny, starterProps.variant, starterIvs, starter.nature); + const starterPokemon = globalScene.addPlayerPokemon( + starter.species, + globalScene.gameMode.getStartingLevel(), + starter.abilityIndex, + starterFormIndex, + starterGender, + starterProps.shiny, + starterProps.variant, + starterIvs, + starter.nature, + ); starter.moveset && starterPokemon.tryPopulateMoveset(starter.moveset); if (starter.passive) { starterPokemon.passive = true; } - starterPokemon.luck = globalScene.gameData.getDexAttrLuck(globalScene.gameData.dexData[starter.species.speciesId].caughtAttr); + starterPokemon.luck = globalScene.gameData.getDexAttrLuck( + globalScene.gameData.dexData[starter.species.speciesId].caughtAttr, + ); if (starter.pokerus) { starterPokemon.pokerus = true; } @@ -109,7 +119,7 @@ export class SelectStarterPhase extends Phase { globalScene.sessionPlayTime = 0; globalScene.lastSavePlayTime = 0; // Ensures Keldeo (or any future Pokemon that have this type of form change) starts in the correct form - globalScene.getPlayerParty().forEach((p) => { + globalScene.getPlayerParty().forEach(p => { globalScene.triggerPokemonFormChange(p, SpeciesFormChangeMoveLearnedTrigger); }); this.end(); diff --git a/src/phases/select-target-phase.ts b/src/phases/select-target-phase.ts index a1e38e3f9d2..2042d0a3fcf 100644 --- a/src/phases/select-target-phase.ts +++ b/src/phases/select-target-phase.ts @@ -23,7 +23,9 @@ export class SelectTargetPhase extends PokemonPhase { const user = fieldSide[this.fieldIndex]; const moveObject = allMoves[move!]; if (moveObject && user.isMoveTargetRestricted(moveObject.id, user, fieldSide[targets[0]])) { - const errorMessage = user.getRestrictingTag(move!, user, fieldSide[targets[0]])!.selectionDeniedText(user, moveObject.id); + const errorMessage = user + .getRestrictingTag(move!, user, fieldSide[targets[0]])! + .selectionDeniedText(user, moveObject.id); globalScene.queueMessage(i18next.t(errorMessage, { moveName: moveObject.name }), 0, true); targets = []; } @@ -31,10 +33,10 @@ export class SelectTargetPhase extends PokemonPhase { globalScene.currentBattle.turnCommands[this.fieldIndex] = null; globalScene.unshiftPhase(new CommandPhase(this.fieldIndex)); } else { - turnCommand!.targets = targets; //TODO: is the bang correct here? + turnCommand!.targets = targets; //TODO: is the bang correct here? } if (turnCommand?.command === Command.BALL && this.fieldIndex) { - globalScene.currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; //TODO: is the bang correct here? + globalScene.currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true; //TODO: is the bang correct here? } this.end(); }); diff --git a/src/phases/show-ability-phase.ts b/src/phases/show-ability-phase.ts index d759ad833a1..326b3a55ce3 100644 --- a/src/phases/show-ability-phase.ts +++ b/src/phases/show-ability-phase.ts @@ -5,7 +5,7 @@ import { PokemonPhase } from "./pokemon-phase"; export class ShowAbilityPhase extends PokemonPhase { private passive: boolean; - constructor(battlerIndex: BattlerIndex, passive: boolean = false) { + constructor(battlerIndex: BattlerIndex, passive = false) { super(battlerIndex); this.passive = passive; @@ -17,7 +17,6 @@ export class ShowAbilityPhase extends PokemonPhase { const pokemon = this.getPokemon(); if (pokemon) { - if (!pokemon.isPlayer()) { /** If its an enemy pokemon, list it as last enemy to use ability or move */ globalScene.currentBattle.lastEnemyInvolved = pokemon.getBattlerIndex() % 2; diff --git a/src/phases/show-party-exp-bar-phase.ts b/src/phases/show-party-exp-bar-phase.ts index 004592bc335..568b8b615c8 100644 --- a/src/phases/show-party-exp-bar-phase.ts +++ b/src/phases/show-party-exp-bar-phase.ts @@ -36,12 +36,15 @@ export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase { if (globalScene.expParty === ExpNotification.SKIP) { this.end(); } else if (globalScene.expParty === ExpNotification.ONLY_LEVEL_UP) { - if (newLevel > lastLevel) { // this means if we level up + if (newLevel > lastLevel) { + // this means if we level up // instead of displaying the exp gain in the small frame, we display the new level // we use the same method for mode 0 & 1, by giving a parameter saying to display the exp or the level - globalScene.partyExpBar.showPokemonExp(pokemon, exp.value, globalScene.expParty === ExpNotification.ONLY_LEVEL_UP, newLevel).then(() => { - setTimeout(() => this.end(), 800 / Math.pow(2, globalScene.expGainsSpeed)); - }); + globalScene.partyExpBar + .showPokemonExp(pokemon, exp.value, globalScene.expParty === ExpNotification.ONLY_LEVEL_UP, newLevel) + .then(() => { + setTimeout(() => this.end(), 800 / Math.pow(2, globalScene.expGainsSpeed)); + }); } else { this.end(); } @@ -52,6 +55,5 @@ export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase { } else { this.end(); } - } } diff --git a/src/phases/show-trainer-phase.ts b/src/phases/show-trainer-phase.ts index 17106b54048..740c11f5c5d 100644 --- a/src/phases/show-trainer-phase.ts +++ b/src/phases/show-trainer-phase.ts @@ -18,7 +18,7 @@ export class ShowTrainerPhase extends BattlePhase { targets: globalScene.trainer, x: 106, duration: 1000, - onComplete: () => this.end() + onComplete: () => this.end(), }); } } diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index 753d1f7cede..71b50fa9dce 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -1,6 +1,15 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; -import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, PostStatStageChangeAbAttr, ProtectStatAbAttr, ReflectStatStageChangeAbAttr, StatStageChangeCopyAbAttr, StatStageChangeMultiplierAbAttr } from "#app/data/ability"; +import { + applyAbAttrs, + applyPostStatStageChangeAbAttrs, + applyPreStatStageChangeAbAttrs, + PostStatStageChangeAbAttr, + ProtectStatAbAttr, + ReflectStatStageChangeAbAttr, + StatStageChangeCopyAbAttr, + StatStageChangeMultiplierAbAttr, +} from "#app/data/ability"; import { ArenaTagSide, MistTag } from "#app/data/arena-tag"; import type { ArenaTag } from "#app/data/arena-tag"; import type Pokemon from "#app/field/pokemon"; @@ -14,7 +23,11 @@ import { Stat, type BattleStat, getStatKey, getStatStageChangeDescriptionKey } f import { OctolockTag } from "#app/data/battler-tags"; import { ArenaTagType } from "#app/enums/arena-tag-type"; -export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleStat[], relativeChanges: number[]) => void; +export type StatStageChangeCallback = ( + target: Pokemon | null, + changed: BattleStat[], + relativeChanges: number[], +) => void; export class StatStageChangePhase extends PokemonPhase { private stats: BattleStat[]; @@ -27,8 +40,18 @@ export class StatStageChangePhase extends PokemonPhase { private comingFromMirrorArmorUser: boolean; private comingFromStickyWeb: boolean; - - constructor(battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: number, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null, comingFromMirrorArmorUser: boolean = false, comingFromStickyWeb: boolean = false) { + constructor( + battlerIndex: BattlerIndex, + selfTarget: boolean, + stats: BattleStat[], + stages: number, + showMessage = true, + ignoreAbilities = false, + canBeCopied = true, + onChange: StatStageChangeCallback | null = null, + comingFromMirrorArmorUser = false, + comingFromStickyWeb = false, + ) { super(battlerIndex); this.selfTarget = selfTarget; @@ -43,12 +66,23 @@ export class StatStageChangePhase extends PokemonPhase { } start() { - // Check if multiple stats are being changed at the same time, then run SSCPhase for each of them if (this.stats.length > 1) { for (let i = 0; i < this.stats.length; i++) { - const stat = [ this.stats[i] ]; - globalScene.unshiftPhase(new StatStageChangePhase(this.battlerIndex, this.selfTarget, stat, this.stages, this.showMessage, this.ignoreAbilities, this.canBeCopied, this.onChange, this.comingFromMirrorArmorUser)); + const stat = [this.stats[i]]; + globalScene.unshiftPhase( + new StatStageChangePhase( + this.battlerIndex, + this.selfTarget, + stat, + this.stages, + this.showMessage, + this.ignoreAbilities, + this.canBeCopied, + this.onChange, + this.comingFromMirrorArmorUser, + ), + ); } return this.end(); } @@ -65,8 +99,9 @@ export class StatStageChangePhase extends PokemonPhase { /** If this SSCP is from sticky web, then check if pokemon that last sucessfully used sticky web is on field */ const stickyTagID = globalScene.arena.findTagsOnSide( (t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB, - ArenaTagSide.PLAYER)[0].sourceId; - globalScene.getEnemyField().forEach((e) => { + ArenaTagSide.PLAYER, + )[0].sourceId; + globalScene.getEnemyField().forEach(e => { if (e.id === stickyTagID) { opponentPokemon = e; } @@ -78,8 +113,9 @@ export class StatStageChangePhase extends PokemonPhase { } else { const stickyTagID = globalScene.arena.findTagsOnSide( (t: ArenaTag) => t.tagType === ArenaTagType.STICKY_WEB, - ArenaTagSide.ENEMY)[0].sourceId; - globalScene.getPlayerField().forEach((e) => { + ArenaTagSide.ENEMY, + )[0].sourceId; + globalScene.getPlayerField().forEach(e => { if (e.id === stickyTagID) { opponentPokemon = e; } @@ -104,15 +140,33 @@ export class StatStageChangePhase extends PokemonPhase { if (!this.selfTarget && stages.value < 0) { // TODO: add a reference to the source of the stat change to fix Infiltrator interaction - globalScene.arena.applyTagsForSide(MistTag, pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY, false, null, cancelled); + globalScene.arena.applyTagsForSide( + MistTag, + pokemon.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY, + false, + null, + cancelled, + ); } if (!cancelled.value && !this.selfTarget && stages.value < 0) { applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled, simulate); /** Potential stat reflection due to Mirror Armor, does not apply to Octolock end of turn effect */ - if (opponentPokemon !== undefined && !pokemon.findTag(t => t instanceof OctolockTag) && !this.comingFromMirrorArmorUser) { - applyPreStatStageChangeAbAttrs(ReflectStatStageChangeAbAttr, pokemon, stat, cancelled, simulate, opponentPokemon, this.stages); + if ( + opponentPokemon !== undefined && + !pokemon.findTag(t => t instanceof OctolockTag) && + !this.comingFromMirrorArmorUser + ) { + applyPreStatStageChangeAbAttrs( + ReflectStatStageChangeAbAttr, + pokemon, + stat, + cancelled, + simulate, + opponentPokemon, + this.stages, + ); } } @@ -124,9 +178,14 @@ export class StatStageChangePhase extends PokemonPhase { return !cancelled.value; }); - const relLevels = filteredStats.map(s => (stages.value >= 1 ? Math.min(pokemon.getStatStage(s) + stages.value, 6) : Math.max(pokemon.getStatStage(s) + stages.value, -6)) - pokemon.getStatStage(s)); + const relLevels = filteredStats.map( + s => + (stages.value >= 1 + ? Math.min(pokemon.getStatStage(s) + stages.value, 6) + : Math.max(pokemon.getStatStage(s) + stages.value, -6)) - pokemon.getStatStage(s), + ); - this.onChange && this.onChange(this.getPokemon(), filteredStats, relLevels); + this.onChange?.(this.getPokemon(), filteredStats, relLevels); const end = () => { if (this.showMessage) { @@ -163,10 +222,16 @@ export class StatStageChangePhase extends PokemonPhase { applyPostStatStageChangeAbAttrs(PostStatStageChangeAbAttr, pokemon, filteredStats, this.stages, this.selfTarget); // Look for any other stat change phases; if this is the last one, do White Herb check - const existingPhase = globalScene.findPhase(p => p instanceof StatStageChangePhase && p.battlerIndex === this.battlerIndex); + const existingPhase = globalScene.findPhase( + p => p instanceof StatStageChangePhase && p.battlerIndex === this.battlerIndex, + ); if (!(existingPhase instanceof StatStageChangePhase)) { // Apply White Herb if needed - const whiteHerb = globalScene.applyModifier(ResetNegativeStatStageModifier, this.player, pokemon) as ResetNegativeStatStageModifier; + const whiteHerb = globalScene.applyModifier( + ResetNegativeStatStageModifier, + this.player, + pokemon, + ) as ResetNegativeStatStageModifier; // If the White Herb was applied, consume it if (whiteHerb) { pokemon.loseHeldItem(whiteHerb); @@ -184,7 +249,8 @@ export class StatStageChangePhase extends PokemonPhase { const pokemonMaskSprite = pokemon.maskSprite; const tileX = (this.player ? 106 : 236) * pokemon.getSpriteScale() * globalScene.field.scale; - const tileY = ((this.player ? 148 : 84) + (stages.value >= 1 ? 160 : 0)) * pokemon.getSpriteScale() * globalScene.field.scale; + const tileY = + ((this.player ? 148 : 84) + (stages.value >= 1 ? 160 : 0)) * pokemon.getSpriteScale() * globalScene.field.scale; const tileWidth = 156 * globalScene.field.scale * pokemon.getSpriteScale(); const tileHeight = 316 * globalScene.field.scale * pokemon.getSpriteScale(); @@ -210,15 +276,15 @@ export class StatStageChangePhase extends PokemonPhase { targets: statSprite, delay: 1000, duration: 250, - alpha: 0 + alpha: 0, }); - } + }, }); globalScene.tweens.add({ targets: statSprite, duration: 1500, - y: `${stages.value >= 1 ? "-" : "+"}=${160 * 6}` + y: `${stages.value >= 1 ? "-" : "+"}=${160 * 6}`, }); globalScene.time.delayedCall(1750, () => { @@ -231,13 +297,22 @@ export class StatStageChangePhase extends PokemonPhase { } aggregateStatStageChanges(): void { - const accEva: BattleStat[] = [ Stat.ACC, Stat.EVA ]; + const accEva: BattleStat[] = [Stat.ACC, Stat.EVA]; const isAccEva = accEva.some(s => this.stats.includes(s)); let existingPhase: StatStageChangePhase; if (this.stats.length === 1) { - while ((existingPhase = (globalScene.findPhase(p => p instanceof StatStageChangePhase && p.battlerIndex === this.battlerIndex && p.stats.length === 1 - && (p.stats[0] === this.stats[0]) - && p.selfTarget === this.selfTarget && p.showMessage === this.showMessage && p.ignoreAbilities === this.ignoreAbilities) as StatStageChangePhase))) { + while ( + (existingPhase = globalScene.findPhase( + p => + p instanceof StatStageChangePhase && + p.battlerIndex === this.battlerIndex && + p.stats.length === 1 && + p.stats[0] === this.stats[0] && + p.selfTarget === this.selfTarget && + p.showMessage === this.showMessage && + p.ignoreAbilities === this.ignoreAbilities, + ) as StatStageChangePhase) + ) { this.stages += existingPhase.stages; if (!globalScene.tryRemovePhase(p => p === existingPhase)) { @@ -245,9 +320,18 @@ export class StatStageChangePhase extends PokemonPhase { } } } - while ((existingPhase = (globalScene.findPhase(p => p instanceof StatStageChangePhase && p.battlerIndex === this.battlerIndex && p.selfTarget === this.selfTarget - && (accEva.some(s => p.stats.includes(s)) === isAccEva) - && p.stages === this.stages && p.showMessage === this.showMessage && p.ignoreAbilities === this.ignoreAbilities) as StatStageChangePhase))) { + while ( + (existingPhase = globalScene.findPhase( + p => + p instanceof StatStageChangePhase && + p.battlerIndex === this.battlerIndex && + p.selfTarget === this.selfTarget && + accEva.some(s => p.stats.includes(s)) === isAccEva && + p.stages === this.stages && + p.showMessage === this.showMessage && + p.ignoreAbilities === this.ignoreAbilities, + ) as StatStageChangePhase) + ) { this.stats.push(...existingPhase.stats); if (!globalScene.tryRemovePhase(p => p === existingPhase)) { break; @@ -272,21 +356,31 @@ export class StatStageChangePhase extends PokemonPhase { let statsFragment = ""; if (relStageStats.length > 1) { - statsFragment = relStageStats.length >= 5 - ? i18next.t("battle:stats") - : `${relStageStats.slice(0, -1).map(s => i18next.t(getStatKey(s))).join(", ")}${relStageStats.length > 2 ? "," : ""} ${i18next.t("battle:statsAnd")} ${i18next.t(getStatKey(relStageStats[relStageStats.length - 1]))}`; - messages.push(i18next.t(getStatStageChangeDescriptionKey(Math.abs(parseInt(rl)), stages >= 1), { - pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), - stats: statsFragment, - count: relStageStats.length - })); + statsFragment = + relStageStats.length >= 5 + ? i18next.t("battle:stats") + : `${relStageStats + .slice(0, -1) + .map(s => i18next.t(getStatKey(s))) + .join( + ", ", + )}${relStageStats.length > 2 ? "," : ""} ${i18next.t("battle:statsAnd")} ${i18next.t(getStatKey(relStageStats[relStageStats.length - 1]))}`; + messages.push( + i18next.t(getStatStageChangeDescriptionKey(Math.abs(Number.parseInt(rl)), stages >= 1), { + pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), + stats: statsFragment, + count: relStageStats.length, + }), + ); } else { statsFragment = i18next.t(getStatKey(relStageStats[0])); - messages.push(i18next.t(getStatStageChangeDescriptionKey(Math.abs(parseInt(rl)), stages >= 1), { - pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), - stats: statsFragment, - count: relStageStats.length - })); + messages.push( + i18next.t(getStatStageChangeDescriptionKey(Math.abs(Number.parseInt(rl)), stages >= 1), { + pokemonNameWithAffix: getPokemonNameWithAffix(this.getPokemon()), + stats: statsFragment, + count: relStageStats.length, + }), + ); } }); diff --git a/src/phases/summon-missing-phase.ts b/src/phases/summon-missing-phase.ts index 459a0399964..32bc7495dce 100644 --- a/src/phases/summon-missing-phase.ts +++ b/src/phases/summon-missing-phase.ts @@ -9,7 +9,11 @@ export class SummonMissingPhase extends SummonPhase { } preSummon(): void { - globalScene.ui.showText(i18next.t("battle:sendOutPokemon", { pokemonName: getPokemonNameWithAffix(this.getPokemon()) })); + globalScene.ui.showText( + i18next.t("battle:sendOutPokemon", { + pokemonName: getPokemonNameWithAffix(this.getPokemon()), + }), + ); globalScene.time.delayedCall(250, () => this.summon()); } } diff --git a/src/phases/summon-phase.ts b/src/phases/summon-phase.ts index 09eded9e52f..31cd2645e68 100644 --- a/src/phases/summon-phase.ts +++ b/src/phases/summon-phase.ts @@ -18,7 +18,7 @@ import { globalScene } from "#app/global-scene"; export class SummonPhase extends PartyMemberPokemonPhase { private loaded: boolean; - constructor(fieldIndex: number, player: boolean = true, loaded: boolean = false) { + constructor(fieldIndex: number, player = true, loaded = false) { super(fieldIndex, player); this.loaded = loaded; @@ -31,13 +31,15 @@ export class SummonPhase extends PartyMemberPokemonPhase { } /** - * Sends out a Pokemon before the battle begins and shows the appropriate messages - */ + * Sends out a Pokemon before the battle begins and shows the appropriate messages + */ preSummon(): void { const partyMember = this.getPokemon(); // If the Pokemon about to be sent out is fainted, illegal under a challenge, or no longer in the party for some reason, switch to the first non-fainted legal Pokemon if (!partyMember.isAllowedInBattle() || (this.player && !this.getParty().some(p => p.id === partyMember.id))) { - console.warn("The Pokemon about to be sent out is fainted or illegal under a challenge. Attempting to resolve..."); + console.warn( + "The Pokemon about to be sent out is fainted or illegal under a challenge. Attempting to resolve...", + ); // First check if they're somehow still in play, if so remove them. if (partyMember.isOnField()) { @@ -58,16 +60,28 @@ export class SummonPhase extends PartyMemberPokemonPhase { } // Swaps the fainted Pokemon and the first non-fainted legal Pokemon in the party - [ party[this.partyMemberIndex], party[legalIndex] ] = [ party[legalIndex], party[this.partyMemberIndex] ]; - console.warn("Swapped %s %O with %s %O", getPokemonNameWithAffix(partyMember), partyMember, getPokemonNameWithAffix(party[0]), party[0]); + [party[this.partyMemberIndex], party[legalIndex]] = [party[legalIndex], party[this.partyMemberIndex]]; + console.warn( + "Swapped %s %O with %s %O", + getPokemonNameWithAffix(partyMember), + partyMember, + getPokemonNameWithAffix(party[0]), + party[0], + ); } if (this.player) { - globalScene.ui.showText(i18next.t("battle:playerGo", { pokemonName: getPokemonNameWithAffix(this.getPokemon()) })); + globalScene.ui.showText( + i18next.t("battle:playerGo", { + pokemonName: getPokemonNameWithAffix(this.getPokemon()), + }), + ); if (this.player) { globalScene.pbTray.hide(); } - globalScene.trainer.setTexture(`trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`); + globalScene.trainer.setTexture( + `trainer_${globalScene.gameData.gender === PlayerGender.FEMALE ? "f" : "m"}_back_pb`, + ); globalScene.time.delayedCall(562, () => { globalScene.trainer.setFrame("2"); globalScene.time.delayedCall(64, () => { @@ -78,13 +92,21 @@ export class SummonPhase extends PartyMemberPokemonPhase { targets: globalScene.trainer, x: -36, duration: 1000, - onComplete: () => globalScene.trainer.setVisible(false) + onComplete: () => globalScene.trainer.setVisible(false), }); globalScene.time.delayedCall(750, () => this.summon()); - } else if (globalScene.currentBattle.battleType === BattleType.TRAINER || globalScene.currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) { - const trainerName = globalScene.currentBattle.trainer?.getName(!(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER); + } else if ( + globalScene.currentBattle.battleType === BattleType.TRAINER || + globalScene.currentBattle.mysteryEncounter?.encounterMode === MysteryEncounterMode.TRAINER_BATTLE + ) { + const trainerName = globalScene.currentBattle.trainer?.getName( + !(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ); const pokemonName = this.getPokemon().getNameToRender(); - const message = i18next.t("battle:trainerSendOut", { trainerName, pokemonName }); + const message = i18next.t("battle:trainerSendOut", { + trainerName, + pokemonName, + }); globalScene.pbTrayEnemy.hide(); globalScene.ui.showText(message, null, () => this.summon()); @@ -100,7 +122,12 @@ export class SummonPhase extends PartyMemberPokemonPhase { summon(): void { const pokemon = this.getPokemon(); - const pokeball = globalScene.addFieldSprite(this.player ? 36 : 248, this.player ? 80 : 44, "pb", getPokeballAtlasKey(pokemon.pokeball)); + const pokeball = globalScene.addFieldSprite( + this.player ? 36 : 248, + this.player ? 80 : 44, + "pb", + getPokeballAtlasKey(pokemon.pokeball), + ); pokeball.setVisible(false); pokeball.setOrigin(0.5, 0.625); globalScene.field.add(pokeball); @@ -109,7 +136,9 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.setFieldPosition(FieldPosition.RIGHT, 0); } else { const availablePartyMembers = this.getParty().filter(p => p.isAllowedInBattle()).length; - pokemon.setFieldPosition(!globalScene.currentBattle.double || availablePartyMembers === 1 ? FieldPosition.CENTER : FieldPosition.LEFT); + pokemon.setFieldPosition( + !globalScene.currentBattle.double || availablePartyMembers === 1 ? FieldPosition.CENTER : FieldPosition.LEFT, + ); } const fpOffset = pokemon.getFieldPositionOffset(); @@ -119,7 +148,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { globalScene.tweens.add({ targets: pokeball, duration: 650, - x: (this.player ? 100 : 236) + fpOffset[0] + x: (this.player ? 100 : 236) + fpOffset[0], }); globalScene.tweens.add({ @@ -167,11 +196,11 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.getSprite().clearTint(); pokemon.resetSummonData(); globalScene.time.delayedCall(1000, () => this.end()); - } + }, }); - } + }, }); - } + }, }); } @@ -187,7 +216,9 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.setFieldPosition(FieldPosition.RIGHT, 0); } else { const availablePartyMembers = this.getParty().filter(p => !p.isFainted()).length; - pokemon.setFieldPosition(!globalScene.currentBattle.double || availablePartyMembers === 1 ? FieldPosition.CENTER : FieldPosition.LEFT); + pokemon.setFieldPosition( + !globalScene.currentBattle.double || availablePartyMembers === 1 ? FieldPosition.CENTER : FieldPosition.LEFT, + ); } globalScene.add.existing(pokemon); @@ -228,7 +259,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.resetSummonData(); globalScene.updateFieldScale(); globalScene.time.delayedCall(1000, () => this.end()); - } + }, }); } @@ -241,7 +272,11 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.resetTurnData(); - if (!this.loaded || [ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(globalScene.currentBattle.battleType) || (globalScene.currentBattle.waveIndex % 10) === 1) { + if ( + !this.loaded || + [BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER].includes(globalScene.currentBattle.battleType) || + globalScene.currentBattle.waveIndex % 10 === 1 + ) { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true); this.queuePostSummon(); } diff --git a/src/phases/switch-biome-phase.ts b/src/phases/switch-biome-phase.ts index 88addb4ef47..2dd2a642f43 100644 --- a/src/phases/switch-biome-phase.ts +++ b/src/phases/switch-biome-phase.ts @@ -20,7 +20,7 @@ export class SwitchBiomePhase extends BattlePhase { } globalScene.tweens.add({ - targets: [ globalScene.arenaEnemy, globalScene.lastEnemyTrainer ], + targets: [globalScene.arenaEnemy, globalScene.lastEnemyTrainer], x: "+=300", duration: 2000, onComplete: () => { @@ -38,11 +38,11 @@ export class SwitchBiomePhase extends BattlePhase { globalScene.arenaPlayerTransition.setVisible(true); globalScene.tweens.add({ - targets: [ globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition ], + targets: [globalScene.arenaPlayer, globalScene.arenaBgTransition, globalScene.arenaPlayerTransition], duration: 1000, delay: 1000, ease: "Sine.easeInOut", - alpha: (target: any) => target === globalScene.arenaPlayer ? 0 : 1, + alpha: (target: any) => (target === globalScene.arenaPlayer ? 0 : 1), onComplete: () => { globalScene.arenaBg.setTexture(bgTexture); globalScene.arenaPlayer.setBiome(this.nextBiome); @@ -57,9 +57,9 @@ export class SwitchBiomePhase extends BattlePhase { } this.end(); - } + }, }); - } + }, }); } } diff --git a/src/phases/switch-phase.ts b/src/phases/switch-phase.ts index 34b70aeaf63..8562309ede5 100644 --- a/src/phases/switch-phase.ts +++ b/src/phases/switch-phase.ts @@ -17,14 +17,14 @@ export class SwitchPhase extends BattlePhase { private readonly doReturn: boolean; /** - * Creates a new SwitchPhase - * @param switchType {@linkcode SwitchType} The type of switch logic this phase implements - * @param fieldIndex Field index to switch out - * @param isModal Indicates if the switch should be forced (true) or is - * optional (false). - * @param doReturn Indicates if the party member on the field should be - * recalled to ball or has already left the field. Passed to {@linkcode SwitchSummonPhase}. - */ + * Creates a new SwitchPhase + * @param switchType {@linkcode SwitchType} The type of switch logic this phase implements + * @param fieldIndex Field index to switch out + * @param isModal Indicates if the switch should be forced (true) or is + * optional (false). + * @param doReturn Indicates if the party member on the field should be + * recalled to ball or has already left the field. Passed to {@linkcode SwitchSummonPhase}. + */ constructor(switchType: SwitchType, fieldIndex: number, isModal: boolean, doReturn: boolean) { super(); @@ -54,22 +54,35 @@ export class SwitchPhase extends BattlePhase { } // Check if there is any space still in field - if (this.isModal && globalScene.getPlayerField().filter(p => p.isAllowedInBattle() && p.isActive(true)).length >= globalScene.currentBattle.getBattlerCount()) { + if ( + this.isModal && + globalScene.getPlayerField().filter(p => p.isAllowedInBattle() && p.isActive(true)).length >= + globalScene.currentBattle.getBattlerCount() + ) { return super.end(); } // Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once - const fieldIndex = globalScene.currentBattle.getBattlerCount() === 1 || globalScene.getPokemonAllowedInBattle().length > 1 ? this.fieldIndex : 0; + const fieldIndex = + globalScene.currentBattle.getBattlerCount() === 1 || globalScene.getPokemonAllowedInBattle().length > 1 + ? this.fieldIndex + : 0; - globalScene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: number, option: PartyOption) => { - if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) { - // Remove any pre-existing PostSummonPhase under the same field index. - // Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave. - globalScene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex); - 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()); - }, PartyUiHandler.FilterNonFainted); + globalScene.ui.setMode( + Mode.PARTY, + this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, + fieldIndex, + (slotIndex: number, option: PartyOption) => { + if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) { + // Remove any pre-existing PostSummonPhase under the same field index. + // Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave. + globalScene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex); + 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()); + }, + PartyUiHandler.FilterNonFainted, + ); } } diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index f8350fb7d4c..48bcd0c4ebd 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -22,13 +22,13 @@ export class SwitchSummonPhase extends SummonPhase { private lastPokemon: Pokemon; /** - * Constructor for creating a new SwitchSummonPhase - * @param switchType the type of switch behavior - * @param fieldIndex integer representing position on the battle field - * @param slotIndex integer for the index of pokemon (in party of 6) to switch into - * @param doReturn boolean whether to render "comeback" dialogue - * @param player boolean if the switch is from the player - */ + * Constructor for creating a new SwitchSummonPhase + * @param switchType the type of switch behavior + * @param fieldIndex integer representing position on the battle field + * @param slotIndex integer for the index of pokemon (in party of 6) to switch into + * @param doReturn boolean whether to render "comeback" dialogue + * @param player boolean if the switch is from the player + */ constructor(switchType: SwitchType, fieldIndex: number, slotIndex: number, doReturn: boolean, player?: boolean) { super(fieldIndex, player !== undefined ? player : true); @@ -45,7 +45,9 @@ export class SwitchSummonPhase extends SummonPhase { if (!this.player) { if (this.slotIndex === -1) { //@ts-ignore - this.slotIndex = globalScene.currentBattle.trainer?.getNextSummonIndex(!this.fieldIndex ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER); // TODO: what would be the default trainer-slot fallback? + this.slotIndex = globalScene.currentBattle.trainer?.getNextSummonIndex( + !this.fieldIndex ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ); // TODO: what would be the default trainer-slot fallback? } if (this.slotIndex > -1) { this.showEnemyTrainer(!(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER); @@ -53,17 +55,22 @@ export class SwitchSummonPhase extends SummonPhase { } } - if (!this.doReturn || (this.slotIndex !== -1 && !(this.player ? globalScene.getPlayerParty() : globalScene.getEnemyParty())[this.slotIndex])) { + if ( + !this.doReturn || + (this.slotIndex !== -1 && + !(this.player ? globalScene.getPlayerParty() : globalScene.getEnemyParty())[this.slotIndex]) + ) { if (this.player) { return this.switchAndSummon(); - } else { - globalScene.time.delayedCall(750, () => this.switchAndSummon()); - return; } + globalScene.time.delayedCall(750, () => this.switchAndSummon()); + return; } const pokemon = this.getPokemon(); - (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.removeTagsBySourceId(pokemon.id)); + (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => + enemyPokemon.removeTagsBySourceId(pokemon.id), + ); if (this.switchType === SwitchType.SWITCH || this.switchType === SwitchType.INITIAL_SWITCH) { const substitute = pokemon.getTag(SubstituteTag); @@ -73,17 +80,22 @@ export class SwitchSummonPhase extends SummonPhase { duration: 250, scale: substitute.sprite.scale * 0.5, ease: "Sine.easeIn", - onComplete: () => substitute.sprite.destroy() + onComplete: () => substitute.sprite.destroy(), }); } } - globalScene.ui.showText(this.player ? - i18next.t("battle:playerComeBack", { pokemonName: getPokemonNameWithAffix(pokemon) }) : - i18next.t("battle:trainerComeBack", { - trainerName: globalScene.currentBattle.trainer?.getName(!(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER), - pokemonName: pokemon.getNameToRender() - }) + globalScene.ui.showText( + this.player + ? i18next.t("battle:playerComeBack", { + pokemonName: getPokemonNameWithAffix(pokemon), + }) + : i18next.t("battle:trainerComeBack", { + trainerName: globalScene.currentBattle.trainer?.getName( + !(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ), + pokemonName: pokemon.getNameToRender(), + }), ); globalScene.playSound("se/pb_rel"); pokemon.hideInfo(); @@ -96,7 +108,7 @@ export class SwitchSummonPhase extends SummonPhase { onComplete: () => { globalScene.time.delayedCall(750, () => this.switchAndSummon()); pokemon.leaveField(this.switchType === SwitchType.SWITCH, false); - } + }, }); } @@ -106,12 +118,38 @@ export class SwitchSummonPhase extends SummonPhase { this.lastPokemon = this.getPokemon(); applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon); if (this.switchType === SwitchType.BATON_PASS && switchedInPokemon) { - (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedInPokemon.id)); - if (!globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) { - const batonPassModifier = globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier - && (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id) as SwitchEffectTransferModifier; - if (batonPassModifier && !globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier && (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id)) { - globalScene.tryTransferHeldItemModifier(batonPassModifier, switchedInPokemon, false, undefined, undefined, undefined, false); + (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach(enemyPokemon => + enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedInPokemon.id), + ); + if ( + !globalScene.findModifier( + m => + m instanceof SwitchEffectTransferModifier && + (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id, + ) + ) { + const batonPassModifier = globalScene.findModifier( + m => + m instanceof SwitchEffectTransferModifier && + (m as SwitchEffectTransferModifier).pokemonId === this.lastPokemon.id, + ) as SwitchEffectTransferModifier; + if ( + batonPassModifier && + !globalScene.findModifier( + m => + m instanceof SwitchEffectTransferModifier && + (m as SwitchEffectTransferModifier).pokemonId === switchedInPokemon.id, + ) + ) { + globalScene.tryTransferHeldItemModifier( + batonPassModifier, + switchedInPokemon, + false, + undefined, + undefined, + undefined, + false, + ); } } } @@ -119,12 +157,17 @@ export class SwitchSummonPhase extends SummonPhase { party[this.slotIndex] = this.lastPokemon; party[this.fieldIndex] = switchedInPokemon; const showTextAndSummon = () => { - globalScene.ui.showText(this.player ? - i18next.t("battle:playerGo", { pokemonName: getPokemonNameWithAffix(switchedInPokemon) }) : - i18next.t("battle:trainerGo", { - trainerName: globalScene.currentBattle.trainer?.getName(!(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER), - pokemonName: this.getPokemon().getNameToRender() - }) + globalScene.ui.showText( + this.player + ? i18next.t("battle:playerGo", { + pokemonName: getPokemonNameWithAffix(switchedInPokemon), + }) + : i18next.t("battle:trainerGo", { + trainerName: globalScene.currentBattle.trainer?.getName( + !(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ), + pokemonName: this.getPokemon().getNameToRender(), + }), ); /** * If this switch is passing a Substitute, make the switched Pokemon match the returned Pokemon's state as it left. @@ -165,12 +208,18 @@ export class SwitchSummonPhase extends SummonPhase { const lastUsedMove = moveId ? allMoves[moveId] : undefined; const currentCommand = globalScene.currentBattle.turnCommands[this.fieldIndex]?.command; - const lastPokemonIsForceSwitchedAndNotFainted = lastUsedMove?.hasAttr(ForceSwitchOutAttr) && !this.lastPokemon.isFainted(); - const lastPokemonHasForceSwitchAbAttr = this.lastPokemon.hasAbilityWithAttr(PostDamageForceSwitchAbAttr) && !this.lastPokemon.isFainted(); + const lastPokemonIsForceSwitchedAndNotFainted = + lastUsedMove?.hasAttr(ForceSwitchOutAttr) && !this.lastPokemon.isFainted(); + const lastPokemonHasForceSwitchAbAttr = + this.lastPokemon.hasAbilityWithAttr(PostDamageForceSwitchAbAttr) && !this.lastPokemon.isFainted(); // Compensate for turn spent summoning // Or compensate for force switch move if switched out pokemon is not fainted - if (currentCommand === Command.POKEMON || lastPokemonIsForceSwitchedAndNotFainted || lastPokemonHasForceSwitchAbAttr) { + if ( + currentCommand === Command.POKEMON || + lastPokemonIsForceSwitchedAndNotFainted || + lastPokemonHasForceSwitchAbAttr + ) { pokemon.battleSummonData.turnCount--; pokemon.battleSummonData.waveTurnCount--; } diff --git a/src/phases/tera-phase.ts b/src/phases/tera-phase.ts index 5411861011e..c9320daf12f 100644 --- a/src/phases/tera-phase.ts +++ b/src/phases/tera-phase.ts @@ -20,13 +20,17 @@ export class TeraPhase extends BattlePhase { start() { super.start(); - globalScene.queueMessage(i18next.t("battle:pokemonTerastallized", { pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), type: i18next.t(`pokemonInfo:Type.${PokemonType[this.pokemon.getTeraType()]}`) })); + globalScene.queueMessage( + i18next.t("battle:pokemonTerastallized", { + pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), + type: i18next.t(`pokemonInfo:Type.${PokemonType[this.pokemon.getTeraType()]}`), + }), + ); new CommonBattleAnim(CommonAnim.TERASTALLIZE, this.pokemon).play(false, () => { this.end(); }); } - end() { this.pokemon.isTerastallized = true; this.pokemon.updateSpritePipelineData(); diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index a560897037e..5b69f8db45c 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -5,7 +5,12 @@ import { Gender } from "#app/data/gender"; import { getBiomeKey } from "#app/field/arena"; import { GameMode, GameModes, getGameMode } from "#app/game-mode"; import type { Modifier } from "#app/modifier/modifier"; -import { getDailyRunStarterModifiers, ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { + getDailyRunStarterModifiers, + ModifierPoolType, + modifierTypes, + regenerateModifierPoolThresholds, +} from "#app/modifier/modifier-type"; import { Phase } from "#app/phase"; import type { SessionSaveData } from "#app/system/game-data"; import { Unlockables } from "#app/system/unlockables"; @@ -23,7 +28,6 @@ import { SummonPhase } from "./summon-phase"; import { globalScene } from "#app/global-scene"; import Overrides from "#app/overrides"; - export class TitlePhase extends Phase { private loaded: boolean; private lastSessionData: SessionSaveData; @@ -43,18 +47,21 @@ export class TitlePhase extends Phase { globalScene.playBgm("title", true); - globalScene.gameData.getSession(loggedInUser?.lastSessionSlot ?? -1).then(sessionData => { - if (sessionData) { - this.lastSessionData = sessionData; - const biomeKey = getBiomeKey(sessionData.arena.biome); - const bgTexture = `${biomeKey}_bg`; - globalScene.arenaBg.setTexture(bgTexture); - } - this.showOptions(); - }).catch(err => { - console.error(err); - this.showOptions(); - }); + globalScene.gameData + .getSession(loggedInUser?.lastSessionSlot ?? -1) + .then(sessionData => { + if (sessionData) { + this.lastSessionData = sessionData; + const biomeKey = getBiomeKey(sessionData.arena.biome); + const bgTexture = `${biomeKey}_bg`; + globalScene.arenaBg.setTexture(bgTexture); + } + this.showOptions(); + }) + .catch(err => { + console.error(err); + this.showOptions(); + }); } showOptions(): void { @@ -65,105 +72,110 @@ export class TitlePhase extends Phase { handler: () => { this.loadSaveSlot(this.lastSessionData || !loggedInUser ? -1 : loggedInUser.lastSessionSlot); return true; - } + }, }); } - options.push({ - label: i18next.t("menu:newGame"), - handler: () => { - const setModeAndEnd = (gameMode: GameModes) => { - this.gameMode = gameMode; - globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.clearText(); - this.end(); - }; - const { gameData } = globalScene; - const options: OptionSelectItem[] = []; - options.push({ - label: GameMode.getModeName(GameModes.CLASSIC), - handler: () => { - setModeAndEnd(GameModes.CLASSIC); - return true; - } - }); - options.push({ - label: i18next.t("menu:dailyRun"), - handler: () => { - this.initDailyRun(); - return true; - } - }); - if (gameData.isUnlocked(Unlockables.ENDLESS_MODE)) { + options.push( + { + label: i18next.t("menu:newGame"), + handler: () => { + const setModeAndEnd = (gameMode: GameModes) => { + this.gameMode = gameMode; + globalScene.ui.setMode(Mode.MESSAGE); + globalScene.ui.clearText(); + this.end(); + }; + const { gameData } = globalScene; + const options: OptionSelectItem[] = []; options.push({ - label: GameMode.getModeName(GameModes.CHALLENGE), + label: GameMode.getModeName(GameModes.CLASSIC), handler: () => { - setModeAndEnd(GameModes.CHALLENGE); + setModeAndEnd(GameModes.CLASSIC); return true; - } + }, }); options.push({ - label: GameMode.getModeName(GameModes.ENDLESS), + label: i18next.t("menu:dailyRun"), handler: () => { - setModeAndEnd(GameModes.ENDLESS); + this.initDailyRun(); return true; - } + }, }); - if (gameData.isUnlocked(Unlockables.SPLICED_ENDLESS_MODE)) { + if (gameData.isUnlocked(Unlockables.ENDLESS_MODE)) { options.push({ - label: GameMode.getModeName(GameModes.SPLICED_ENDLESS), + label: GameMode.getModeName(GameModes.CHALLENGE), handler: () => { - setModeAndEnd(GameModes.SPLICED_ENDLESS); + setModeAndEnd(GameModes.CHALLENGE); return true; - } + }, }); + options.push({ + label: GameMode.getModeName(GameModes.ENDLESS), + handler: () => { + setModeAndEnd(GameModes.ENDLESS); + return true; + }, + }); + if (gameData.isUnlocked(Unlockables.SPLICED_ENDLESS_MODE)) { + options.push({ + label: GameMode.getModeName(GameModes.SPLICED_ENDLESS), + handler: () => { + setModeAndEnd(GameModes.SPLICED_ENDLESS); + return true; + }, + }); + } } - } - options.push({ - label: i18next.t("menu:cancel"), - handler: () => { - globalScene.clearPhaseQueue(); - globalScene.pushPhase(new TitlePhase()); - super.end(); - return true; - } - }); - globalScene.ui.showText(i18next.t("menu:selectGameMode"), null, () => globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { options: options })); - return true; - } - }, - { - label: i18next.t("menu:loadGame"), - handler: () => { - globalScene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD, - (slotId: number) => { + options.push({ + label: i18next.t("menu:cancel"), + handler: () => { + globalScene.clearPhaseQueue(); + globalScene.pushPhase(new TitlePhase()); + super.end(); + return true; + }, + }); + globalScene.ui.showText(i18next.t("menu:selectGameMode"), null, () => + globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { + options: options, + }), + ); + return true; + }, + }, + { + label: i18next.t("menu:loadGame"), + handler: () => { + globalScene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD, (slotId: number) => { if (slotId === -1) { return this.showOptions(); } this.loadSaveSlot(slotId); }); - return true; - } - }, - { - label: i18next.t("menu:runHistory"), - handler: () => { - globalScene.ui.setOverlayMode(Mode.RUN_HISTORY); - return true; + return true; + }, }, - keepOpen: true - }, - { - label: i18next.t("menu:settings"), - handler: () => { - globalScene.ui.setOverlayMode(Mode.SETTINGS); - return true; + { + label: i18next.t("menu:runHistory"), + handler: () => { + globalScene.ui.setOverlayMode(Mode.RUN_HISTORY); + return true; + }, + keepOpen: true, }, - keepOpen: true - }); + { + label: i18next.t("menu:settings"), + handler: () => { + globalScene.ui.setOverlayMode(Mode.SETTINGS); + return true; + }, + keepOpen: true, + }, + ); const config: OptionSelectConfig = { options: options, noCancel: true, - yOffset: 47 + yOffset: 47, }; globalScene.ui.setMode(Mode.TITLE, config); } @@ -172,17 +184,20 @@ export class TitlePhase extends Phase { globalScene.sessionSlotId = slotId > -1 || !loggedInUser ? slotId : loggedInUser.lastSessionSlot; globalScene.ui.setMode(Mode.MESSAGE); globalScene.ui.resetModeChain(); - globalScene.gameData.loadSession(slotId, slotId === -1 ? this.lastSessionData : undefined).then((success: boolean) => { - if (success) { - this.loaded = true; - globalScene.ui.showText(i18next.t("menu:sessionSuccess"), null, () => this.end()); - } else { - this.end(); - } - }).catch(err => { - console.error(err); - globalScene.ui.showText(i18next.t("menu:failedToLoadSession"), null); - }); + globalScene.gameData + .loadSession(slotId, slotId === -1 ? this.lastSessionData : undefined) + .then((success: boolean) => { + if (success) { + this.loaded = true; + globalScene.ui.showText(i18next.t("menu:sessionSuccess"), null, () => this.end()); + } else { + this.end(); + } + }) + .catch(err => { + console.error(err); + globalScene.ui.showText(i18next.t("menu:failedToLoadSession"), null); + }); } initDailyRun(): void { @@ -211,10 +226,23 @@ export class TitlePhase extends Phase { for (const starter of starters) { const starterProps = globalScene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr); const starterFormIndex = Math.min(starterProps.formIndex, Math.max(starter.species.forms.length - 1, 0)); - const starterGender = starter.species.malePercent !== null - ? !starterProps.female ? Gender.MALE : Gender.FEMALE - : Gender.GENDERLESS; - const starterPokemon = globalScene.addPlayerPokemon(starter.species, startingLevel, starter.abilityIndex, starterFormIndex, starterGender, starterProps.shiny, starterProps.variant, undefined, starter.nature); + const starterGender = + starter.species.malePercent !== null + ? !starterProps.female + ? Gender.MALE + : Gender.FEMALE + : Gender.GENDERLESS; + const starterPokemon = globalScene.addPlayerPokemon( + starter.species, + startingLevel, + starter.abilityIndex, + starterFormIndex, + starterGender, + starterProps.shiny, + starterProps.variant, + undefined, + starter.nature, + ); starterPokemon.setVisible(false); party.push(starterPokemon); loadPokemonAssets.push(starterPokemon.loadAssets()); @@ -222,11 +250,17 @@ export class TitlePhase extends Phase { regenerateModifierPoolThresholds(party, ModifierPoolType.DAILY_STARTER); - const modifiers: Modifier[] = Array(3).fill(null).map(() => modifierTypes.EXP_SHARE().withIdFromFunc(modifierTypes.EXP_SHARE).newModifier()) - .concat(Array(3).fill(null).map(() => modifierTypes.GOLDEN_EXP_CHARM().withIdFromFunc(modifierTypes.GOLDEN_EXP_CHARM).newModifier())) - .concat([ modifierTypes.MAP().withIdFromFunc(modifierTypes.MAP).newModifier() ]) + const modifiers: Modifier[] = Array(3) + .fill(null) + .map(() => modifierTypes.EXP_SHARE().withIdFromFunc(modifierTypes.EXP_SHARE).newModifier()) + .concat( + Array(3) + .fill(null) + .map(() => modifierTypes.GOLDEN_EXP_CHARM().withIdFromFunc(modifierTypes.GOLDEN_EXP_CHARM).newModifier()), + ) + .concat([modifierTypes.MAP().withIdFromFunc(modifierTypes.MAP).newModifier()]) .concat(getDailyRunStarterModifiers(party)) - .filter((m) => m !== null); + .filter(m => m !== null); for (const m of modifiers) { globalScene.addModifier(m, true, false, false, true); @@ -247,15 +281,17 @@ export class TitlePhase extends Phase { // If Online, calls seed fetch from db to generate daily run. If Offline, generates a daily run based on current date. if (!Utils.isLocal || Utils.isLocalServerConnected) { - fetchDailyRunSeed().then(seed => { - if (seed) { - generateDaily(seed); - } else { - throw new Error("Daily run seed is null!"); - } - }).catch(err => { - console.error("Failed to load daily run:\n", err); - }); + fetchDailyRunSeed() + .then(seed => { + if (seed) { + generateDaily(seed); + } else { + throw new Error("Daily run seed is null!"); + } + }) + .catch(err => { + console.error("Failed to load daily run:\n", err); + }); } else { let seed: string = btoa(new Date().toISOString().substring(0, 10)); if (!Utils.isNullOrUndefined(Overrides.DAILY_RUN_SEED_OVERRIDE)) { @@ -290,7 +326,10 @@ export class TitlePhase extends Phase { globalScene.pushPhase(new SummonPhase(1, true, true)); } - if (globalScene.currentBattle.battleType !== BattleType.TRAINER && (globalScene.currentBattle.waveIndex > 1 || !globalScene.gameMode.isDaily)) { + if ( + globalScene.currentBattle.battleType !== BattleType.TRAINER && + (globalScene.currentBattle.waveIndex > 1 || !globalScene.gameMode.isDaily) + ) { const minPartySize = globalScene.currentBattle.double ? 2 : 1; if (availablePartyMembers > minPartySize) { globalScene.pushPhase(new CheckSwitchPhase(0, globalScene.currentBattle.double)); diff --git a/src/phases/toggle-double-position-phase.ts b/src/phases/toggle-double-position-phase.ts index f61577444d2..37f47d5cf95 100644 --- a/src/phases/toggle-double-position-phase.ts +++ b/src/phases/toggle-double-position-phase.ts @@ -16,14 +16,19 @@ export class ToggleDoublePositionPhase extends BattlePhase { const playerPokemon = globalScene.getPlayerField().find(p => p.isActive(true)); if (playerPokemon) { - playerPokemon.setFieldPosition(this.double && globalScene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, 500).then(() => { - if (playerPokemon.getFieldIndex() === 1) { - const party = globalScene.getPlayerParty(); - party[1] = party[0]; - party[0] = playerPokemon; - } - this.end(); - }); + playerPokemon + .setFieldPosition( + this.double && globalScene.getPokemonAllowedInBattle().length > 1 ? FieldPosition.LEFT : FieldPosition.CENTER, + 500, + ) + .then(() => { + if (playerPokemon.getFieldIndex() === 1) { + const party = globalScene.getPlayerParty(); + party[1] = party[0]; + party[0] = playerPokemon; + } + this.end(); + }); } else { this.end(); } diff --git a/src/phases/trainer-message-test-phase.ts b/src/phases/trainer-message-test-phase.ts index 34ce2e8b53e..fa3f553cdd6 100644 --- a/src/phases/trainer-message-test-phase.ts +++ b/src/phases/trainer-message-test-phase.ts @@ -19,17 +19,23 @@ export class TrainerMessageTestPhase extends BattlePhase { const testMessages: string[] = []; for (const t of Object.keys(trainerConfigs)) { - const type = parseInt(t); - if (this.trainerTypes.length && !this.trainerTypes.find(tt => tt === type as TrainerType)) { + const type = Number.parseInt(t); + if (this.trainerTypes.length && !this.trainerTypes.find(tt => tt === (type as TrainerType))) { continue; } const config = trainerConfigs[type]; - [ config.encounterMessages, config.femaleEncounterMessages, config.victoryMessages, config.femaleVictoryMessages, config.defeatMessages, config.femaleDefeatMessages ] - .map(messages => { - if (messages?.length) { - testMessages.push(...messages); - } - }); + [ + config.encounterMessages, + config.femaleEncounterMessages, + config.victoryMessages, + config.femaleVictoryMessages, + config.defeatMessages, + config.femaleDefeatMessages, + ].map(messages => { + if (messages?.length) { + testMessages.push(...messages); + } + }); } for (const message of testMessages) { diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index e2617f598da..024c1e3f837 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -38,47 +38,92 @@ export class TrainerVictoryPhase extends BattlePhase { const trainerType = globalScene.currentBattle.trainer?.config.trainerType!; // TODO: is this bang correct? // Validate Voucher for boss trainers if (vouchers.hasOwnProperty(TrainerType[trainerType])) { - if (!globalScene.validateVoucher(vouchers[TrainerType[trainerType]]) && globalScene.currentBattle.trainer?.config.isBoss) { + if ( + !globalScene.validateVoucher(vouchers[TrainerType[trainerType]]) && + globalScene.currentBattle.trainer?.config.isBoss + ) { if (globalScene.eventManager.getUpgradeUnlockedVouchers()) { - globalScene.unshiftPhase(new ModifierRewardPhase([ modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM ][vouchers[TrainerType[trainerType]].voucherType])); + globalScene.unshiftPhase( + new ModifierRewardPhase( + [ + modifierTypes.VOUCHER_PLUS, + modifierTypes.VOUCHER_PLUS, + modifierTypes.VOUCHER_PLUS, + modifierTypes.VOUCHER_PREMIUM, + ][vouchers[TrainerType[trainerType]].voucherType], + ), + ); } else { - globalScene.unshiftPhase(new ModifierRewardPhase([ modifierTypes.VOUCHER, modifierTypes.VOUCHER, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM ][vouchers[TrainerType[trainerType]].voucherType])); + globalScene.unshiftPhase( + new ModifierRewardPhase( + [modifierTypes.VOUCHER, modifierTypes.VOUCHER, modifierTypes.VOUCHER_PLUS, modifierTypes.VOUCHER_PREMIUM][ + vouchers[TrainerType[trainerType]].voucherType + ], + ), + ); } } } // Breeders in Space achievement if ( - globalScene.arena.biomeType === Biome.SPACE - && (trainerType === TrainerType.BREEDER || trainerType === TrainerType.EXPERT_POKEMON_BREEDER) + globalScene.arena.biomeType === Biome.SPACE && + (trainerType === TrainerType.BREEDER || trainerType === TrainerType.EXPERT_POKEMON_BREEDER) ) { globalScene.validateAchv(achvs.BREEDERS_IN_SPACE); } - globalScene.ui.showText(i18next.t("battle:trainerDefeated", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }), null, () => { - const victoryMessages = globalScene.currentBattle.trainer?.getVictoryMessages()!; // TODO: is this bang correct? - let message: string; - globalScene.executeWithSeedOffset(() => message = Utils.randSeedItem(victoryMessages), globalScene.currentBattle.waveIndex); - message = message!; // tell TS compiler it's defined now + globalScene.ui.showText( + i18next.t("battle:trainerDefeated", { + trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true), + }), + null, + () => { + const victoryMessages = globalScene.currentBattle.trainer?.getVictoryMessages()!; // TODO: is this bang correct? + let message: string; + globalScene.executeWithSeedOffset( + () => (message = Utils.randSeedItem(victoryMessages)), + globalScene.currentBattle.waveIndex, + ); + message = message!; // tell TS compiler it's defined now - const showMessage = () => { - const originalFunc = showMessageOrEnd; - showMessageOrEnd = () => globalScene.ui.showDialogue(message, globalScene.currentBattle.trainer?.getName(TrainerSlot.TRAINER, true), null, originalFunc); - - showMessageOrEnd(); - }; - let showMessageOrEnd = () => this.end(); - if (victoryMessages?.length) { - if (globalScene.currentBattle.trainer?.config.hasCharSprite && !globalScene.ui.shouldSkipDialogue(message)) { + const showMessage = () => { const originalFunc = showMessageOrEnd; - showMessageOrEnd = () => globalScene.charSprite.hide().then(() => globalScene.hideFieldOverlay(250).then(() => originalFunc())); - globalScene.showFieldOverlay(500).then(() => globalScene.charSprite.showCharacter(globalScene.currentBattle.trainer?.getKey()!, getCharVariantFromDialogue(victoryMessages[0])).then(() => showMessage())); // TODO: is this bang correct? + showMessageOrEnd = () => + globalScene.ui.showDialogue( + message, + globalScene.currentBattle.trainer?.getName(TrainerSlot.TRAINER, true), + null, + originalFunc, + ); + + showMessageOrEnd(); + }; + let showMessageOrEnd = () => this.end(); + if (victoryMessages?.length) { + if (globalScene.currentBattle.trainer?.config.hasCharSprite && !globalScene.ui.shouldSkipDialogue(message)) { + const originalFunc = showMessageOrEnd; + showMessageOrEnd = () => + globalScene.charSprite.hide().then(() => globalScene.hideFieldOverlay(250).then(() => originalFunc())); + globalScene + .showFieldOverlay(500) + .then(() => + globalScene.charSprite + .showCharacter( + globalScene.currentBattle.trainer?.getKey()!, + getCharVariantFromDialogue(victoryMessages[0]), + ) + .then(() => showMessage()), + ); // TODO: is this bang correct? + } else { + showMessage(); + } } else { - showMessage(); + showMessageOrEnd(); } - } else { - showMessageOrEnd(); - } - }, null, true); + }, + null, + true, + ); this.showEnemyTrainer(); } diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index fc4190ef2eb..c55f6d69a58 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -5,7 +5,13 @@ import { WeatherType } from "#app/enums/weather-type"; import { TurnEndEvent } from "#app/events/battle-scene"; import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; -import { TurnHealModifier, EnemyTurnHealModifier, EnemyStatusEffectHealChanceModifier, TurnStatusEffectModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier"; +import { + TurnHealModifier, + EnemyTurnHealModifier, + EnemyStatusEffectHealChanceModifier, + TurnStatusEffectModifier, + TurnHeldItemTransferModifier, +} from "#app/modifier/modifier"; import i18next from "i18next"; import { FieldPhase } from "./field-phase"; import { PokemonHealPhase } from "./pokemon-heal-phase"; @@ -29,8 +35,16 @@ export class TurnEndPhase extends FieldPhase { globalScene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon); if (globalScene.arena.terrain?.terrainType === TerrainType.GRASSY && pokemon.isGrounded()) { - globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), - Math.max(pokemon.getMaxHp() >> 4, 1), i18next.t("battle:turnEndHpRestore", { pokemonName: getPokemonNameWithAffix(pokemon) }), true)); + globalScene.unshiftPhase( + new PokemonHealPhase( + pokemon.getBattlerIndex(), + Math.max(pokemon.getMaxHp() >> 4, 1), + i18next.t("battle:turnEndHpRestore", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + true, + ), + ); } if (!pokemon.isPlayer()) { diff --git a/src/phases/turn-init-phase.ts b/src/phases/turn-init-phase.ts index 946c9626718..3104b65eb3f 100644 --- a/src/phases/turn-init-phase.ts +++ b/src/phases/turn-init-phase.ts @@ -1,5 +1,8 @@ import { BattlerIndex } from "#app/battle"; -import { handleMysteryEncounterBattleStartEffects, handleMysteryEncounterTurnStartEffects } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; +import { + handleMysteryEncounterBattleStartEffects, + handleMysteryEncounterTurnStartEffects, +} from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { TurnInitEvent } from "#app/events/battle-scene"; import type { PlayerPokemon } from "#app/field/pokemon"; import i18next from "i18next"; @@ -22,7 +25,7 @@ export class TurnInitPhase extends FieldPhase { globalScene.getPlayerField().forEach(p => { // If this pokemon is in play and evolved into something illegal under the current challenge, force a switch if (p.isOnField() && !p.isAllowedInBattle()) { - globalScene.queueMessage(i18next.t("challenges:illegalEvolution", { "pokemon": p.name }), null, true); + globalScene.queueMessage(i18next.t("challenges:illegalEvolution", { pokemon: p.name }), null, true); const allowedPokemon = globalScene.getPokemonAllowedInBattle(); @@ -30,7 +33,10 @@ export class TurnInitPhase extends FieldPhase { // If there are no longer any legal pokemon in the party, game over. globalScene.clearPhaseQueue(); globalScene.unshiftPhase(new GameOverPhase()); - } else if (allowedPokemon.length >= globalScene.currentBattle.getBattlerCount() || (globalScene.currentBattle.double && !allowedPokemon[0].isActive(true))) { + } else if ( + allowedPokemon.length >= globalScene.currentBattle.getBattlerCount() || + (globalScene.currentBattle.double && !allowedPokemon[0].isActive(true)) + ) { // If there is at least one pokemon in the back that is legal to switch in, force a switch. p.switchOut(); } else { diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index 0d924e9f48b..6065a0caf6e 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -41,9 +41,13 @@ export class TurnStartPhase extends FieldPhase { let orderedTargets: Pokemon[] = playerField.concat(enemyField); // We seed it with the current turn to prevent an inconsistency where it // was varying based on how long since you last reloaded - globalScene.executeWithSeedOffset(() => { - orderedTargets = Utils.randSeedShuffle(orderedTargets); - }, globalScene.currentBattle.turn, globalScene.waveSeed); + globalScene.executeWithSeedOffset( + () => { + orderedTargets = Utils.randSeedShuffle(orderedTargets); + }, + globalScene.currentBattle.turn, + globalScene.waveSeed, + ); // Next, a check for Trick Room is applied to determine sort order. const speedReversed = new Utils.BooleanHolder(false); @@ -72,16 +76,19 @@ export class TurnStartPhase extends FieldPhase { // This occurs before the main loop because of battles with more than two Pokemon const battlerBypassSpeed = {}; - globalScene.getField(true).filter(p => p.summonData).map(p => { - const bypassSpeed = new Utils.BooleanHolder(false); - const canCheckHeldItems = new Utils.BooleanHolder(true); - applyAbAttrs(BypassSpeedChanceAbAttr, p, null, false, bypassSpeed); - applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, false, bypassSpeed, canCheckHeldItems); - if (canCheckHeldItems.value) { - globalScene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed); - } - battlerBypassSpeed[p.getBattlerIndex()] = bypassSpeed; - }); + globalScene + .getField(true) + .filter(p => p.summonData) + .map(p => { + const bypassSpeed = new Utils.BooleanHolder(false); + const canCheckHeldItems = new Utils.BooleanHolder(true); + applyAbAttrs(BypassSpeedChanceAbAttr, p, null, false, bypassSpeed); + applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, false, bypassSpeed, canCheckHeldItems); + if (canCheckHeldItems.value) { + globalScene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed); + } + battlerBypassSpeed[p.getBattlerIndex()] = bypassSpeed; + }); // The function begins sorting orderedTargets based on command priority, move priority, and possible speed bypasses. // Non-FIGHT commands (SWITCH, BALL, RUN) have a higher command priority and will always occur before any FIGHT commands. @@ -93,7 +100,8 @@ export class TurnStartPhase extends FieldPhase { if (aCommand?.command !== bCommand?.command) { if (aCommand?.command === Command.FIGHT) { return 1; - } else if (bCommand?.command === Command.FIGHT) { + } + if (bCommand?.command === Command.FIGHT) { return -1; } } else if (aCommand?.command === Command.FIGHT) { @@ -115,7 +123,7 @@ export class TurnStartPhase extends FieldPhase { if (isSameBracket && battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) { return battlerBypassSpeed[a].value ? -1 : 1; } - return (aPriority < bPriority) ? 1 : -1; + return aPriority < bPriority ? 1 : -1; } } @@ -155,7 +163,6 @@ export class TurnStartPhase extends FieldPhase { } for (const o of moveOrder) { - const pokemon = field[o]; const turnCommand = globalScene.currentBattle.turnCommands[o]; @@ -170,42 +177,62 @@ export class TurnStartPhase extends FieldPhase { if (!queuedMove) { continue; } - const move = pokemon.getMoveset().find(m => m?.moveId === queuedMove.move && m?.ppUsed < m?.getMovePp()) || new PokemonMove(queuedMove.move); + const move = + pokemon.getMoveset().find(m => m?.moveId === queuedMove.move && m?.ppUsed < m?.getMovePp()) || + new PokemonMove(queuedMove.move); if (move.getMove().hasAttr(MoveHeaderAttr)) { globalScene.unshiftPhase(new MoveHeaderPhase(pokemon, move)); } if (pokemon.isPlayer()) { if (turnCommand.cursor === -1) { - globalScene.pushPhase(new MovePhase(pokemon, turnCommand.targets || turnCommand.move!.targets, move));//TODO: is the bang correct here? + globalScene.pushPhase(new MovePhase(pokemon, turnCommand.targets || turnCommand.move!.targets, move)); //TODO: is the bang correct here? } else { - const playerPhase = new MovePhase(pokemon, turnCommand.targets || turnCommand.move!.targets, move, false, queuedMove.ignorePP);//TODO: is the bang correct here? + const playerPhase = new MovePhase( + pokemon, + turnCommand.targets || turnCommand.move!.targets, + move, + false, + queuedMove.ignorePP, + ); //TODO: is the bang correct here? globalScene.pushPhase(playerPhase); } } else { - globalScene.pushPhase(new MovePhase(pokemon, turnCommand.targets || turnCommand.move!.targets, move, false, queuedMove.ignorePP));//TODO: is the bang correct here? + globalScene.pushPhase( + new MovePhase( + pokemon, + turnCommand.targets || turnCommand.move!.targets, + move, + false, + queuedMove.ignorePP, + ), + ); //TODO: is the bang correct here? } break; case Command.BALL: - globalScene.unshiftPhase(new AttemptCapturePhase(turnCommand.targets![0] % 2, turnCommand.cursor!));//TODO: is the bang correct here? + globalScene.unshiftPhase(new AttemptCapturePhase(turnCommand.targets![0] % 2, turnCommand.cursor!)); //TODO: is the bang correct here? break; case Command.POKEMON: const switchType = turnCommand.args?.[0] ? SwitchType.BATON_PASS : SwitchType.SWITCH; - globalScene.unshiftPhase(new SwitchSummonPhase(switchType, pokemon.getFieldIndex(), turnCommand.cursor!, true, pokemon.isPlayer())); + globalScene.unshiftPhase( + new SwitchSummonPhase(switchType, pokemon.getFieldIndex(), turnCommand.cursor!, true, pokemon.isPlayer()), + ); break; case Command.RUN: let runningPokemon = pokemon; if (globalScene.currentBattle.double) { const playerActivePokemon = field.filter(pokemon => { - if (!!pokemon) { + if (pokemon) { return pokemon.isPlayer() && pokemon.isActive(); - } else { - return; } + return; }); // if only one pokemon is alive, use that one if (playerActivePokemon.length > 1) { - // find which active pokemon has faster speed - const fasterPokemon = playerActivePokemon[0].getStat(Stat.SPD) > playerActivePokemon[1].getStat(Stat.SPD) ? playerActivePokemon[0] : playerActivePokemon[1]; + // find which active pokemon has faster speed + const fasterPokemon = + playerActivePokemon[0].getStat(Stat.SPD) > playerActivePokemon[1].getStat(Stat.SPD) + ? playerActivePokemon[0] + : playerActivePokemon[1]; // check if either active pokemon has the ability "Run Away" const hasRunAway = playerActivePokemon.find(p => p.hasAbility(Abilities.RUN_AWAY)); runningPokemon = hasRunAway !== undefined ? hasRunAway : fasterPokemon; @@ -225,10 +252,10 @@ export class TurnStartPhase extends FieldPhase { globalScene.pushPhase(new TurnEndPhase()); /** - * this.end() will call shiftPhase(), which dumps everything from PrependQueue (aka everything that is unshifted()) to the front - * of the queue and dequeues to start the next phase - * this is important since stuff like SwitchSummon, AttemptRun, AttemptCapture Phases break the "flow" and should take precedence - */ + * this.end() will call shiftPhase(), which dumps everything from PrependQueue (aka everything that is unshifted()) to the front + * of the queue and dequeues to start the next phase + * this is important since stuff like SwitchSummon, AttemptRun, AttemptCapture Phases break the "flow" and should take precedence + */ this.end(); } } diff --git a/src/phases/unlock-phase.ts b/src/phases/unlock-phase.ts index 2d24ee92baf..b420a4b3a61 100644 --- a/src/phases/unlock-phase.ts +++ b/src/phases/unlock-phase.ts @@ -20,10 +20,19 @@ export class UnlockPhase extends Phase { // Sound loaded into game as is globalScene.playSound("level_up_fanfare"); globalScene.ui.setMode(Mode.MESSAGE); - globalScene.ui.showText(i18next.t("battle:unlockedSomething", { unlockedThing: getUnlockableName(this.unlockable) }), null, () => { - globalScene.time.delayedCall(1500, () => globalScene.arenaBg.setVisible(true)); - this.end(); - }, null, true, 1500); + globalScene.ui.showText( + i18next.t("battle:unlockedSomething", { + unlockedThing: getUnlockableName(this.unlockable), + }), + null, + () => { + globalScene.time.delayedCall(1500, () => globalScene.arenaBg.setVisible(true)); + this.end(); + }, + null, + true, + 1500, + ); }); } } diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index 13e04569ef3..78bf72195e8 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -18,7 +18,7 @@ export class VictoryPhase extends PokemonPhase { /** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */ isExpOnly: boolean; - constructor(battlerIndex: BattlerIndex | number, isExpOnly: boolean = false) { + constructor(battlerIndex: BattlerIndex | number, isExpOnly = false) { super(battlerIndex); this.isExpOnly = isExpOnly; @@ -42,14 +42,21 @@ export class VictoryPhase extends PokemonPhase { return this.end(); } - if (!globalScene.getEnemyParty().find(p => globalScene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) { + if ( + !globalScene + .getEnemyParty() + .find(p => (globalScene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true))) + ) { globalScene.pushPhase(new BattleEndPhase(true)); if (globalScene.currentBattle.battleType === BattleType.TRAINER) { globalScene.pushPhase(new TrainerVictoryPhase()); } if (globalScene.gameMode.isEndless || !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) { globalScene.pushPhase(new EggLapsePhase()); - if (globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex === ClassicFixedBossWaves.EVIL_BOSS_2) { + if ( + globalScene.gameMode.isClassic && + globalScene.currentBattle.waveIndex === ClassicFixedBossWaves.EVIL_BOSS_2 + ) { // Should get Lock Capsule on 165 before shop phase so it can be used in the rewards shop globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.LOCK_CAPSULE)); } @@ -57,7 +64,10 @@ export class VictoryPhase extends PokemonPhase { globalScene.pushPhase(new SelectModifierPhase(undefined, undefined, this.getFixedBattleCustomModifiers())); } else if (globalScene.gameMode.isDaily) { globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.EXP_CHARM)); - if (globalScene.currentBattle.waveIndex > 10 && !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) { + if ( + globalScene.currentBattle.waveIndex > 10 && + !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex) + ) { globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.GOLDEN_POKEBALL)); } } else { @@ -65,14 +75,29 @@ export class VictoryPhase extends PokemonPhase { if (globalScene.gameMode.isEndless && globalScene.currentBattle.waveIndex === 10) { globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.EXP_SHARE)); } - if (globalScene.currentBattle.waveIndex <= 750 && (globalScene.currentBattle.waveIndex <= 500 || (globalScene.currentBattle.waveIndex % 30) === superExpWave)) { - globalScene.pushPhase(new ModifierRewardPhase((globalScene.currentBattle.waveIndex % 30) !== superExpWave || globalScene.currentBattle.waveIndex > 250 ? modifierTypes.EXP_CHARM : modifierTypes.SUPER_EXP_CHARM)); + if ( + globalScene.currentBattle.waveIndex <= 750 && + (globalScene.currentBattle.waveIndex <= 500 || globalScene.currentBattle.waveIndex % 30 === superExpWave) + ) { + globalScene.pushPhase( + new ModifierRewardPhase( + globalScene.currentBattle.waveIndex % 30 !== superExpWave || globalScene.currentBattle.waveIndex > 250 + ? modifierTypes.EXP_CHARM + : modifierTypes.SUPER_EXP_CHARM, + ), + ); } if (globalScene.currentBattle.waveIndex <= 150 && !(globalScene.currentBattle.waveIndex % 50)) { globalScene.pushPhase(new ModifierRewardPhase(modifierTypes.GOLDEN_POKEBALL)); } if (globalScene.gameMode.isEndless && !(globalScene.currentBattle.waveIndex % 50)) { - globalScene.pushPhase(new ModifierRewardPhase(!(globalScene.currentBattle.waveIndex % 250) ? modifierTypes.VOUCHER_PREMIUM : modifierTypes.VOUCHER_PLUS)); + globalScene.pushPhase( + new ModifierRewardPhase( + !(globalScene.currentBattle.waveIndex % 250) + ? modifierTypes.VOUCHER_PREMIUM + : modifierTypes.VOUCHER_PLUS, + ), + ); globalScene.pushPhase(new AddEnemyBuffModifierPhase()); } } diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index aa09f8a850d..9199b7996bc 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -1,5 +1,13 @@ import { globalScene } from "#app/global-scene"; -import { applyPreWeatherEffectAbAttrs, SuppressWeatherEffectAbAttr, PreWeatherDamageAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPostWeatherLapseAbAttrs, PostWeatherLapseAbAttr } from "#app/data/ability"; +import { + applyPreWeatherEffectAbAttrs, + SuppressWeatherEffectAbAttr, + PreWeatherDamageAbAttr, + applyAbAttrs, + BlockNonDirectDamageAbAttr, + applyPostWeatherLapseAbAttrs, + PostWeatherLapseAbAttr, +} from "#app/data/ability"; import { CommonAnim } from "#app/data/battle-anims"; import type { Weather } from "#app/data/weather"; import { getWeatherDamageMessage, getWeatherLapseMessage } from "#app/data/weather"; @@ -14,7 +22,11 @@ export class WeatherEffectPhase extends CommonAnimPhase { public weather: Weather | null; constructor() { - super(undefined, undefined, CommonAnim.SUNNY + ((globalScene?.arena?.weather?.weatherType || WeatherType.NONE) - 1)); + super( + undefined, + undefined, + CommonAnim.SUNNY + ((globalScene?.arena?.weather?.weatherType || WeatherType.NONE) - 1), + ); this.weather = globalScene?.arena?.weather; } @@ -30,10 +42,11 @@ export class WeatherEffectPhase extends CommonAnimPhase { this.setAnimation(CommonAnim.SUNNY + (this.weather.weatherType - 1)); if (this.weather.isDamaging()) { - const cancelled = new Utils.BooleanHolder(false); - this.executeForAll((pokemon: Pokemon) => applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, pokemon, this.weather, cancelled)); + this.executeForAll((pokemon: Pokemon) => + applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, pokemon, this.weather, cancelled), + ); if (!cancelled.value) { const inflictDamage = (pokemon: Pokemon) => { @@ -42,7 +55,11 @@ export class WeatherEffectPhase extends CommonAnimPhase { applyPreWeatherEffectAbAttrs(PreWeatherDamageAbAttr, pokemon, this.weather, cancelled); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); - if (cancelled.value || pokemon.getTag(BattlerTagType.UNDERGROUND) || pokemon.getTag(BattlerTagType.UNDERWATER)) { + if ( + cancelled.value || + pokemon.getTag(BattlerTagType.UNDERGROUND) || + pokemon.getTag(BattlerTagType.UNDERWATER) + ) { return; } @@ -53,7 +70,10 @@ export class WeatherEffectPhase extends CommonAnimPhase { }; this.executeForAll((pokemon: Pokemon) => { - const immune = !pokemon || !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length || pokemon.switchOutStatus; + const immune = + !pokemon || + !!pokemon.getTypes(true, true).filter(t => this.weather?.isTypeDamageImmune(t)).length || + pokemon.switchOutStatus; if (!immune) { inflictDamage(pokemon); } diff --git a/src/pipelines/field-sprite.ts b/src/pipelines/field-sprite.ts index f81845073c1..547281d7dee 100644 --- a/src/pipelines/field-sprite.ts +++ b/src/pipelines/field-sprite.ts @@ -208,19 +208,21 @@ void main() { export default class FieldSpritePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { constructor(game: Phaser.Game, config?: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig) { - super(config || { - game: game, - name: "field-sprite", - fragShader: spriteFragShader, - vertShader: spriteVertShader - }); + super( + config || { + game: game, + name: "field-sprite", + fragShader: spriteFragShader, + vertShader: spriteVertShader, + }, + ); } onPreRender(): void { this.set1f("time", 0); this.set1i("ignoreTimeTint", 0); this.set1f("terrainColorRatio", 0); - this.set3fv("terrainColor", [ 0, 0, 0 ]); + this.set3fv("terrainColor", [0, 0, 0]); } onBind(gameObject: Phaser.GameObjects.GameObject): void { @@ -230,7 +232,7 @@ export default class FieldSpritePipeline extends Phaser.Renderer.WebGL.Pipelines const data = sprite.pipelineData; const ignoreTimeTint = data["ignoreTimeTint"] as boolean; - const terrainColorRatio = data["terrainColorRatio"] as number || 0; + const terrainColorRatio = (data["terrainColorRatio"] as number) || 0; const time = globalScene.currentBattle?.waveIndex ? ((globalScene.currentBattle.waveIndex + globalScene.waveCycleOffset) % 40) / 40 // ((new Date().getSeconds() * 1000 + new Date().getMilliseconds()) % 10000) / 10000 @@ -238,10 +240,22 @@ export default class FieldSpritePipeline extends Phaser.Renderer.WebGL.Pipelines this.set1f("time", time); this.set1i("ignoreTimeTint", ignoreTimeTint ? 1 : 0); this.set1i("isOutside", globalScene.arena.isOutside() ? 1 : 0); - this.set3fv("dayTint", globalScene.arena.getDayTint().map(c => c / 255)); - this.set3fv("duskTint", globalScene.arena.getDuskTint().map(c => c / 255)); - this.set3fv("nightTint", globalScene.arena.getNightTint().map(c => c / 255)); - this.set3fv("terrainColor", getTerrainColor(globalScene.arena.terrain?.terrainType || TerrainType.NONE).map(c => c / 255)); + this.set3fv( + "dayTint", + globalScene.arena.getDayTint().map(c => c / 255), + ); + this.set3fv( + "duskTint", + globalScene.arena.getDuskTint().map(c => c / 255), + ); + this.set3fv( + "nightTint", + globalScene.arena.getNightTint().map(c => c / 255), + ); + this.set3fv( + "terrainColor", + getTerrainColor(globalScene.arena.terrain?.terrainType || TerrainType.NONE).map(c => c / 255), + ); this.set1f("terrainColorRatio", terrainColorRatio); } diff --git a/src/pipelines/invert.ts b/src/pipelines/invert.ts index 9c30f2b5cee..a945d0c95aa 100644 --- a/src/pipelines/invert.ts +++ b/src/pipelines/invert.ts @@ -14,14 +14,12 @@ void main() `; export default class InvertPostFX extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline { - constructor (game: Game) { + constructor(game: Game) { super({ game, name: "InvertPostFX", fragShader, - uniforms: [ - "uMainSampler" - ] + uniforms: ["uMainSampler"], } as Phaser.Types.Renderer.WebGL.WebGLPipelineConfig); } } diff --git a/src/pipelines/sprite.ts b/src/pipelines/sprite.ts index 90c0e65d25c..439e35f711f 100644 --- a/src/pipelines/sprite.ts +++ b/src/pipelines/sprite.ts @@ -322,17 +322,17 @@ export default class SpritePipeline extends FieldSpritePipeline { game: game, name: "sprite", fragShader: spriteFragShader, - vertShader: spriteVertShader + vertShader: spriteVertShader, }); - this._tone = [ 0, 0, 0, 0 ]; + this._tone = [0, 0, 0, 0]; } onPreRender(): void { super.onPreRender(); this.set1f("teraTime", 0); - this.set3fv("teraColor", [ 0, 0, 0 ]); + this.set3fv("teraColor", [0, 0, 0]); this.set1i("hasShadow", 0); this.set1i("yCenter", 0); this.set2f("relPosition", 0, 0); @@ -347,31 +347,38 @@ export default class SpritePipeline extends FieldSpritePipeline { onBind(gameObject: Phaser.GameObjects.GameObject): void { super.onBind(gameObject); - const sprite = (gameObject as Phaser.GameObjects.Sprite); + const sprite = gameObject as Phaser.GameObjects.Sprite; const data = sprite.pipelineData; const tone = data["tone"] as number[]; - const teraColor = (data["isTerastallized"] as boolean) ? (data["teraColor"] as number[] ?? [ 0, 0, 0 ]) : [ 0, 0, 0 ]; + const teraColor = (data["isTerastallized"] as boolean) ? ((data["teraColor"] as number[]) ?? [0, 0, 0]) : [0, 0, 0]; const hasShadow = data["hasShadow"] as boolean; const yShadowOffset = data["yShadowOffset"] as number; const ignoreFieldPos = data["ignoreFieldPos"] as boolean; const ignoreOverride = data["ignoreOverride"] as boolean; - const isEntityObj = sprite.parentContainer instanceof Pokemon || sprite.parentContainer instanceof Trainer || sprite.parentContainer instanceof MysteryEncounterIntroVisuals; + const isEntityObj = + sprite.parentContainer instanceof Pokemon || + sprite.parentContainer instanceof Trainer || + sprite.parentContainer instanceof MysteryEncounterIntroVisuals; const field = isEntityObj ? sprite.parentContainer.parentContainer : sprite.parentContainer; - const position = isEntityObj - ? [ sprite.parentContainer.x, sprite.parentContainer.y ] - : [ sprite.x, sprite.y ]; + const position = isEntityObj ? [sprite.parentContainer.x, sprite.parentContainer.y] : [sprite.x, sprite.y]; if (field) { position[0] += field.x / field.scale; position[1] += field.y / field.scale; } - position[0] += -(sprite.width - (sprite.frame.width)) / 2 + sprite.frame.x + (!ignoreFieldPos ? (sprite.x - field.x) : 0); + position[0] += + -(sprite.width - sprite.frame.width) / 2 + sprite.frame.x + (!ignoreFieldPos ? sprite.x - field.x : 0); if (sprite.originY === 0.5) { - position[1] += (sprite.height / 2) * ((isEntityObj ? sprite.parentContainer : sprite).scale - 1) + (!ignoreFieldPos ? (sprite.y - field.y) : 0); + position[1] += + (sprite.height / 2) * ((isEntityObj ? sprite.parentContainer : sprite).scale - 1) + + (!ignoreFieldPos ? sprite.y - field.y : 0); } this.set1f("teraTime", (this.game.getTime() % 500000) / 500000); - this.set3fv("teraColor", teraColor.map(c => c / 255)); + this.set3fv( + "teraColor", + teraColor.map(c => c / 255), + ); this.set1i("hasShadow", hasShadow ? 1 : 0); this.set1i("yCenter", sprite.originY === 0.5 ? 1 : 0); this.set1f("fieldScale", field?.scale || 1); @@ -379,21 +386,34 @@ export default class SpritePipeline extends FieldSpritePipeline { this.set2f("texFrameUv", sprite.frame.u0, sprite.frame.v0); this.set2f("size", sprite.frame.width, sprite.height); this.set2f("texSize", sprite.texture.source[0].width, sprite.texture.source[0].height); - this.set1f("yOffset", sprite.height - sprite.frame.height * (isEntityObj ? sprite.parentContainer.scale : sprite.scale)); + this.set1f( + "yOffset", + sprite.height - sprite.frame.height * (isEntityObj ? sprite.parentContainer.scale : sprite.scale), + ); this.set1f("yShadowOffset", yShadowOffset ?? 0); this.set4fv("tone", tone); this.bindTexture(this.game.textures.get("tera").source[0].glTexture!, 1); // TODO: is this bang correct? if (globalScene.fusionPaletteSwaps) { const spriteColors = ((ignoreOverride && data["spriteColorsBase"]) || data["spriteColors"] || []) as number[][]; - const fusionSpriteColors = ((ignoreOverride && data["fusionSpriteColorsBase"]) || data["fusionSpriteColors"] || []) as number[][]; + const fusionSpriteColors = ((ignoreOverride && data["fusionSpriteColorsBase"]) || + data["fusionSpriteColors"] || + []) as number[][]; - const emptyColors = [ 0, 0, 0, 0 ]; + const emptyColors = [0, 0, 0, 0]; const flatSpriteColors: number[] = []; const flatFusionSpriteColors: number[] = []; for (let c = 0; c < 32; c++) { - flatSpriteColors.splice(flatSpriteColors.length, 0, ...(c < spriteColors.length ? spriteColors[c] : emptyColors)); - flatFusionSpriteColors.splice(flatFusionSpriteColors.length, 0, ...(c < fusionSpriteColors.length ? fusionSpriteColors[c] : emptyColors)); + flatSpriteColors.splice( + flatSpriteColors.length, + 0, + ...(c < spriteColors.length ? spriteColors[c] : emptyColors), + ); + flatFusionSpriteColors.splice( + flatFusionSpriteColors.length, + 0, + ...(c < fusionSpriteColors.length ? fusionSpriteColors[c] : emptyColors), + ); } this.set4iv("spriteColors", flatSpriteColors.flat()); @@ -403,21 +423,30 @@ export default class SpritePipeline extends FieldSpritePipeline { onBatch(gameObject: Phaser.GameObjects.GameObject): void { if (gameObject) { - const sprite = (gameObject as Phaser.GameObjects.Sprite); + const sprite = gameObject as Phaser.GameObjects.Sprite; const data = sprite.pipelineData; const variant: number = data.hasOwnProperty("variant") ? data["variant"] - : sprite.parentContainer instanceof Pokemon ? sprite.parentContainer.variant + : sprite.parentContainer instanceof Pokemon + ? sprite.parentContainer.variant : 0; - let variantColors; + let variantColors: { [x: string]: string }[]; - const emptyColors = [ 0, 0, 0, 0 ]; + const emptyColors = [0, 0, 0, 0]; const flatBaseColors: number[] = []; const flatVariantColors: number[] = []; - if ((sprite.parentContainer instanceof Pokemon ? sprite.parentContainer.shiny : !!data["shiny"]) - && (variantColors = variantColorCache[sprite.parentContainer instanceof Pokemon ? sprite.parentContainer.getSprite().texture.key : data["spriteKey"]]) && variantColors.hasOwnProperty(variant)) { + if ( + (sprite.parentContainer instanceof Pokemon ? sprite.parentContainer.shiny : !!data["shiny"]) && + (variantColors = + variantColorCache[ + sprite.parentContainer instanceof Pokemon + ? sprite.parentContainer.getSprite().texture.key + : data["spriteKey"] + ]) && + variantColors.hasOwnProperty(variant) + ) { const baseColors = Object.keys(variantColors[variant]); for (let c = 0; c < 32; c++) { if (c < baseColors.length) { @@ -444,30 +473,72 @@ export default class SpritePipeline extends FieldSpritePipeline { super.onBatch(gameObject); } - batchQuad(gameObject: Phaser.GameObjects.GameObject, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, - u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, - texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, unit?: number): boolean { + batchQuad( + gameObject: Phaser.GameObjects.GameObject, + x0: number, + y0: number, + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number, + u0: number, + v0: number, + u1: number, + v1: number, + tintTL: number, + tintTR: number, + tintBL: number, + tintBR: number, + tintEffect: number | boolean, + texture?: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper, + unit?: number, + ): boolean { const sprite = gameObject as Phaser.GameObjects.Sprite; this.set1f("vCutoff", v1); const hasShadow = sprite.pipelineData["hasShadow"] as boolean; - const yShadowOffset = sprite.pipelineData["yShadowOffset"] as number ?? 0; + const yShadowOffset = (sprite.pipelineData["yShadowOffset"] as number) ?? 0; if (hasShadow) { - const isEntityObj = sprite.parentContainer instanceof Pokemon || sprite.parentContainer instanceof Trainer || sprite.parentContainer instanceof MysteryEncounterIntroVisuals; + const isEntityObj = + sprite.parentContainer instanceof Pokemon || + sprite.parentContainer instanceof Trainer || + sprite.parentContainer instanceof MysteryEncounterIntroVisuals; const field = isEntityObj ? sprite.parentContainer.parentContainer : sprite.parentContainer; const fieldScaleRatio = field.scale / 6; - const baseY = (isEntityObj - ? sprite.parentContainer.y - : sprite.y + sprite.height) * 6 / fieldScaleRatio; - const bottomPadding = Math.ceil(sprite.height * 0.05 + Math.max(yShadowOffset, 0)) * 6 / fieldScaleRatio; + const baseY = ((isEntityObj ? sprite.parentContainer.y : sprite.y + sprite.height) * 6) / fieldScaleRatio; + const bottomPadding = (Math.ceil(sprite.height * 0.05 + Math.max(yShadowOffset, 0)) * 6) / fieldScaleRatio; const yDelta = (baseY - y1) / field.scale; y2 = y1 = baseY + bottomPadding; - const pixelHeight = (v1 - v0) / (sprite.frame.height * (isEntityObj ? sprite.parentContainer.scale : sprite.scale)); + const pixelHeight = + (v1 - v0) / (sprite.frame.height * (isEntityObj ? sprite.parentContainer.scale : sprite.scale)); v1 += (yDelta + bottomPadding / field.scale) * pixelHeight; } - return super.batchQuad(gameObject, x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, unit); + return super.batchQuad( + gameObject, + x0, + y0, + x1, + y1, + x2, + y2, + x3, + y3, + u0, + v0, + u1, + v1, + tintTL, + tintTR, + tintBL, + tintBR, + tintEffect, + texture, + unit, + ); } get tone(): number[] { diff --git a/src/plugins/api/api-base.ts b/src/plugins/api/api-base.ts index 5c1a30ff3ab..6a0eca56eaa 100644 --- a/src/plugins/api/api-base.ts +++ b/src/plugins/api/api-base.ts @@ -85,8 +85,8 @@ export abstract class ApiBase { */ protected toUrlSearchParams>(data: D) { const arr = Object.entries(data) - .map(([ key, value ]) => (value !== undefined ? [ key, String(value) ] : [ key, "" ])) - .filter(([ , value ]) => value !== ""); + .map(([key, value]) => (value !== undefined ? [key, String(value)] : [key, ""])) + .filter(([, value]) => value !== ""); return new URLSearchParams(arr); } diff --git a/src/plugins/api/pokerogue-account-api.ts b/src/plugins/api/pokerogue-account-api.ts index 66ab8d67520..bab74799677 100644 --- a/src/plugins/api/pokerogue-account-api.ts +++ b/src/plugins/api/pokerogue-account-api.ts @@ -24,14 +24,13 @@ export class PokerogueAccountApi extends ApiBase { if (response.ok) { const resData = (await response.json()) as AccountInfoResponse; - return [ resData, response.status ]; - } else { - console.warn("Could not get account info!", response.status, response.statusText); - return [ null, response.status ]; + return [resData, response.status]; } + console.warn("Could not get account info!", response.status, response.statusText); + return [null, response.status]; } catch (err) { console.warn("Could not get account info!", err); - return [ null, 500 ]; + return [null, 500]; } } @@ -46,9 +45,8 @@ export class PokerogueAccountApi extends ApiBase { if (response.ok) { return null; - } else { - return response.text(); } + return response.text(); } catch (err) { console.warn("Register failed!", err); } @@ -70,10 +68,9 @@ export class PokerogueAccountApi extends ApiBase { const loginResponse = (await response.json()) as AccountLoginResponse; setCookie(SESSION_ID_COOKIE_NAME, loginResponse.token); return null; - } else { - console.warn("Login failed!", response.status, response.statusText); - return response.text(); } + console.warn("Login failed!", response.status, response.statusText); + return response.text(); } catch (err) { console.warn("Login failed!", err); } diff --git a/src/plugins/api/pokerogue-admin-api.ts b/src/plugins/api/pokerogue-admin-api.ts index eeba5319adc..5923f286430 100644 --- a/src/plugins/api/pokerogue-admin-api.ts +++ b/src/plugins/api/pokerogue-admin-api.ts @@ -22,12 +22,11 @@ export class PokerogueAdminApi extends ApiBase { if (response.ok) { return null; - } else { - console.warn("Could not link account with discord!", response.status, response.statusText); + } + console.warn("Could not link account with discord!", response.status, response.statusText); - if (response.status === 404) { - return this.ERR_USERNAME_NOT_FOUND; - } + if (response.status === 404) { + return this.ERR_USERNAME_NOT_FOUND; } } catch (err) { console.warn("Could not link account with discord!", err); @@ -47,12 +46,11 @@ export class PokerogueAdminApi extends ApiBase { if (response.ok) { return null; - } else { - console.warn("Could not unlink account from discord!", response.status, response.statusText); + } + console.warn("Could not unlink account from discord!", response.status, response.statusText); - if (response.status === 404) { - return this.ERR_USERNAME_NOT_FOUND; - } + if (response.status === 404) { + return this.ERR_USERNAME_NOT_FOUND; } } catch (err) { console.warn("Could not unlink account from discord!", err); @@ -72,12 +70,11 @@ export class PokerogueAdminApi extends ApiBase { if (response.ok) { return null; - } else { - console.warn("Could not link account with google!", response.status, response.statusText); + } + console.warn("Could not link account with google!", response.status, response.statusText); - if (response.status === 404) { - return this.ERR_USERNAME_NOT_FOUND; - } + if (response.status === 404) { + return this.ERR_USERNAME_NOT_FOUND; } } catch (err) { console.warn("Could not link account with google!", err); @@ -97,12 +94,11 @@ export class PokerogueAdminApi extends ApiBase { if (response.ok) { return null; - } else { - console.warn("Could not unlink account from google!", response.status, response.statusText); + } + console.warn("Could not unlink account from google!", response.status, response.statusText); - if (response.status === 404) { - return this.ERR_USERNAME_NOT_FOUND; - } + if (response.status === 404) { + return this.ERR_USERNAME_NOT_FOUND; } } catch (err) { console.warn("Could not unlink account from google!", err); @@ -123,18 +119,17 @@ export class PokerogueAdminApi extends ApiBase { if (response.ok) { const resData: SearchAccountResponse = await response.json(); - return [ resData, undefined ]; - } else { - console.warn("Could not find account!", response.status, response.statusText); + return [resData, undefined]; + } + console.warn("Could not find account!", response.status, response.statusText); - if (response.status === 404) { - return [ undefined, this.ERR_USERNAME_NOT_FOUND ]; - } + if (response.status === 404) { + return [undefined, this.ERR_USERNAME_NOT_FOUND]; } } catch (err) { console.warn("Could not find account!", err); } - return [ undefined, this.ERR_GENERIC ]; + return [undefined, this.ERR_GENERIC]; } } diff --git a/src/plugins/api/pokerogue-api.ts b/src/plugins/api/pokerogue-api.ts index 92d0ff1bbbb..c6dfae019a5 100644 --- a/src/plugins/api/pokerogue-api.ts +++ b/src/plugins/api/pokerogue-api.ts @@ -48,9 +48,8 @@ export class PokerogueApi extends ApiBase { const response = await this.doPost("/auth/discord/logout"); if (response.ok) { return true; - } else { - console.warn(`Discord unlink failed (${response.status}: ${response.statusText})`); } + console.warn(`Discord unlink failed (${response.status}: ${response.statusText})`); } catch (err) { console.warn("Could not unlink Discord!", err); } @@ -67,9 +66,8 @@ export class PokerogueApi extends ApiBase { const response = await this.doPost("/auth/google/logout"); if (response.ok) { return true; - } else { - console.warn(`Google unlink failed (${response.status}: ${response.statusText})`); } + console.warn(`Google unlink failed (${response.status}: ${response.statusText})`); } catch (err) { console.warn("Could not unlink Google!", err); } diff --git a/src/plugins/api/pokerogue-savedata-api.ts b/src/plugins/api/pokerogue-savedata-api.ts index 184bfbb4bdb..b8531e82d4f 100644 --- a/src/plugins/api/pokerogue-savedata-api.ts +++ b/src/plugins/api/pokerogue-savedata-api.ts @@ -29,7 +29,7 @@ export class PokerogueSavedataApi extends ApiBase { public async updateAll(bodyData: UpdateAllSavedataRequest) { try { const rawBodyData = JSON.stringify(bodyData, (_k: any, v: any) => - typeof v === "bigint" ? (v <= MAX_INT_ATTR_VALUE ? Number(v) : v.toString()) : v + typeof v === "bigint" ? (v <= MAX_INT_ATTR_VALUE ? Number(v) : v.toString()) : v, ); const response = await this.doPost("/savedata/updateall", rawBodyData); return await response.text(); diff --git a/src/plugins/api/pokerogue-session-savedata-api.ts b/src/plugins/api/pokerogue-session-savedata-api.ts index 44a7b463849..e703d55a242 100644 --- a/src/plugins/api/pokerogue-session-savedata-api.ts +++ b/src/plugins/api/pokerogue-session-savedata-api.ts @@ -82,9 +82,8 @@ export class PokerogueSessionSavedataApi extends ApiBase { if (response.ok) { return null; - } else { - return await response.text(); } + return await response.text(); } catch (err) { console.warn("Could not delete session savedata!", err); return "Unknown error"; diff --git a/src/plugins/cache-busted-loader-plugin.ts b/src/plugins/cache-busted-loader-plugin.ts index 344da3eaa66..e5b1abb5903 100644 --- a/src/plugins/cache-busted-loader-plugin.ts +++ b/src/plugins/cache-busted-loader-plugin.ts @@ -15,7 +15,7 @@ export default class CacheBustedLoaderPlugin extends Phaser.Loader.LoaderPlugin addFile(file): void { if (!Array.isArray(file)) { - file = [ file ]; + file = [file]; } file.forEach(item => { diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 904b51c6dc7..92b0e15dbb9 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"; import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import HttpBackend from "i18next-http-backend"; @@ -8,9 +8,9 @@ import pkg from "../../package.json"; //#region Interfaces/Types interface LoadingFontFaceProperty { - face: FontFace, - extraOptions?: { [key:string]: any }, - only?: Array + face: FontFace; + extraOptions?: { [key: string]: any }; + only?: Array; } //#region Constants @@ -23,52 +23,70 @@ const unicodeRanges = { kana: "U+3040-30FF", CJKCommon: "U+2E80-2EFF,U+3000-303F,U+31C0-31EF,U+3200-32FF,U+3400-4DBF,U+F900-FAFF,U+FE30-FE4F", CJKIdeograph: "U+4E00-9FFF", - specialCharacters: "U+266A,U+2605,U+2665,U+2663" //♪.★,♥,♣ + specialCharacters: "U+266A,U+2605,U+2665,U+2663", //♪.★,♥,♣ }; const rangesByLanguage = { - korean: [ unicodeRanges.CJKCommon, unicodeRanges.hangul ].join(","), - chinese: [ unicodeRanges.CJKCommon, unicodeRanges.fullwidth, unicodeRanges.CJKIdeograph ].join(","), - japanese: [ unicodeRanges.CJKCommon, unicodeRanges.fullwidth, unicodeRanges.kana, unicodeRanges.CJKIdeograph ].join(",") + korean: [unicodeRanges.CJKCommon, unicodeRanges.hangul].join(","), + chinese: [unicodeRanges.CJKCommon, unicodeRanges.fullwidth, unicodeRanges.CJKIdeograph].join(","), + japanese: [unicodeRanges.CJKCommon, unicodeRanges.fullwidth, unicodeRanges.kana, unicodeRanges.CJKIdeograph].join( + ",", + ), }; const fonts: Array = [ // unicode (special character from PokePT) { - face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: unicodeRanges.specialCharacters }), + face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { + unicodeRange: unicodeRanges.specialCharacters, + }), }, { - face: new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: unicodeRanges.specialCharacters }), + face: new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.woff2)", { + unicodeRange: unicodeRanges.specialCharacters, + }), extraOptions: { sizeAdjust: "133%" }, }, // unicode (korean) { - face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: rangesByLanguage.korean }), + face: new FontFace("emerald", "url(./fonts/PokePT_Wansung.woff2)", { + unicodeRange: rangesByLanguage.korean, + }), }, { - face: new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.woff2)", { unicodeRange: rangesByLanguage.korean }), + face: new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.woff2)", { + unicodeRange: rangesByLanguage.korean, + }), extraOptions: { sizeAdjust: "133%" }, }, // unicode (chinese) { - face: new FontFace("emerald", "url(./fonts/unifont-15.1.05.subset.woff2)", { unicodeRange: rangesByLanguage.chinese }), + face: new FontFace("emerald", "url(./fonts/unifont-15.1.05.subset.woff2)", { + unicodeRange: rangesByLanguage.chinese, + }), extraOptions: { sizeAdjust: "70%", format: "woff2" }, - only: [ "en", "es", "fr", "it", "de", "zh", "pt", "ko", "ca" ], + only: ["en", "es", "fr", "it", "de", "zh", "pt", "ko", "ca"], }, { - face: new FontFace("pkmnems", "url(./fonts/unifont-15.1.05.subset.woff2)", { unicodeRange: rangesByLanguage.chinese }), + face: new FontFace("pkmnems", "url(./fonts/unifont-15.1.05.subset.woff2)", { + unicodeRange: rangesByLanguage.chinese, + }), extraOptions: { format: "woff2" }, - only: [ "en", "es", "fr", "it", "de", "zh", "pt", "ko", "ca" ], + only: ["en", "es", "fr", "it", "de", "zh", "pt", "ko", "ca"], }, // japanese { - face: new FontFace("emerald", "url(./fonts/Galmuri11.subset.woff2)", { unicodeRange: rangesByLanguage.japanese }), + face: new FontFace("emerald", "url(./fonts/Galmuri11.subset.woff2)", { + unicodeRange: rangesByLanguage.japanese, + }), extraOptions: { sizeAdjust: "66%" }, - only: [ "ja" ], + only: ["ja"], }, { - face: new FontFace("pkmnems", "url(./fonts/Galmuri9.subset.woff2)", { unicodeRange: rangesByLanguage.japanese }), - only: [ "ja" ], + face: new FontFace("pkmnems", "url(./fonts/Galmuri9.subset.woff2)", { + unicodeRange: rangesByLanguage.japanese, + }), + only: ["ja"], }, ]; @@ -91,7 +109,7 @@ async function initFonts(language: string | undefined) { const results = await Promise.allSettled( fonts .filter(font => !font.only || font.only.some(exclude => language?.indexOf(exclude) === 0)) - .map(font => Object.assign(font.face, font.extraOptions ?? {}).load()) + .map(font => Object.assign(font.face, font.extraOptions ?? {}).load()), ); for (const result of results) { if (result.status === "fulfilled") { @@ -111,7 +129,7 @@ async function initFonts(language: string | undefined) { * @returns a money formatted string */ function i18nMoneyFormatter(amount: any): string { - if (isNaN(Number(amount))) { + if (Number.isNaN(Number(amount))) { console.warn(`i18nMoneyFormatter: value "${amount}" is not a number!`); } @@ -153,9 +171,9 @@ export async function initI18n(): Promise { i18next.use(new KoreanPostpositionProcessor()); await i18next.init({ fallbackLng: "en", - supportedLngs: [ "en", "es-ES", "fr", "it", "de", "zh-CN", "zh-TW", "pt-BR", "ko", "ja", "ca-ES" ], + supportedLngs: ["en", "es-ES", "fr", "it", "de", "zh-CN", "zh-TW", "pt-BR", "ko", "ja", "ca-ES"], backend: { - loadPath(lng: string, [ ns ]: string[]) { + loadPath(lng: string, [ns]: string[]) { let fileName: string; if (namespaceMap[ns]) { fileName = namespaceMap[ns]; @@ -261,16 +279,15 @@ export async function initI18n(): Promise { "mysteryEncounterMessages", ], detection: { - lookupLocalStorage: "prLang" + lookupLocalStorage: "prLang", }, debug: Number(import.meta.env.VITE_I18N_DEBUG) === 1, interpolation: { escapeValue: false, }, - postProcess: [ "korean-postposition" ], + postProcess: ["korean-postposition"], }); - if (i18next.services.formatter) { i18next.services.formatter.add("money", i18nMoneyFormatter); } diff --git a/src/plugins/vite/vite-minify-json-plugin.ts b/src/plugins/vite/vite-minify-json-plugin.ts index a638271562f..f14fdf7042d 100644 --- a/src/plugins/vite/vite-minify-json-plugin.ts +++ b/src/plugins/vite/vite-minify-json-plugin.ts @@ -1,6 +1,6 @@ import path from "path"; import fs from "fs"; -import { type Plugin as VitePlugin } from "vite"; +import type { Plugin as VitePlugin } from "vite"; /** * Crawl a directory (recursively if wanted) for json files and minifies found ones. @@ -8,7 +8,7 @@ import { type Plugin as VitePlugin } from "vite"; * @param recursive if true, will crawl subdirectories */ function applyToDir(dir: string, recursive?: boolean) { - const files = fs.readdirSync(dir).filter((file) => !/^\..*/.test(file)); + const files = fs.readdirSync(dir).filter(file => !/^\..*/.test(file)); for (const file of files) { const filePath = path.join(dir, file); @@ -41,9 +41,9 @@ export function minifyJsonPlugin(basePath: string | string[], recursive?: boolea }, async closeBundle() { console.log("Minifying JSON files..."); - const basePathes = Array.isArray(basePath) ? basePath : [ basePath ]; + const basePathes = Array.isArray(basePath) ? basePath : [basePath]; - basePathes.forEach((basePath) => { + basePathes.forEach(basePath => { const baseDir = path.resolve(buildDir, basePath); if (fs.existsSync(baseDir)) { applyToDir(baseDir, recursive); diff --git a/src/scene-base.ts b/src/scene-base.ts index c6ca9bb8ba2..430a9bc8aac 100644 --- a/src/scene-base.ts +++ b/src/scene-base.ts @@ -12,11 +12,8 @@ export class SceneBase extends Phaser.Scene { */ public readonly scaledCanvas = { width: 1920 / 6, - height: 1080 / 6 + height: 1080 / 6, }; - constructor(config?: string | Phaser.Types.Scenes.SettingsConfig) { - super(config); - } getCachedUrl(url: string): string { const manifest = this.game["manifest"]; @@ -45,11 +42,17 @@ export class SceneBase extends Phaser.Scene { if (!filename) { filename = `${key}.png`; } - this.load.spritesheet(key, this.getCachedUrl(`images/${folder}/${filename}`), { frameWidth: size, frameHeight: size }); + this.load.spritesheet(key, this.getCachedUrl(`images/${folder}/${filename}`), { + frameWidth: size, + frameHeight: size, + }); if (folder.startsWith("ui")) { legacyCompatibleImages.push(key); folder = folder.replace("ui", "ui/legacy"); - this.load.spritesheet(`${key}_legacy`, this.getCachedUrl(`images/${folder}/${filename}`), { frameWidth: size, frameHeight: size }); + this.load.spritesheet(`${key}_legacy`, this.getCachedUrl(`images/${folder}/${filename}`), { + frameWidth: size, + frameHeight: size, + }); } } @@ -60,11 +63,19 @@ export class SceneBase extends Phaser.Scene { if (folder) { folder += "/"; } - this.load.atlas(key, this.getCachedUrl(`images/${folder}${filenameRoot}.png`), this.getCachedUrl(`images/${folder}${filenameRoot}.json`)); + this.load.atlas( + key, + this.getCachedUrl(`images/${folder}${filenameRoot}.png`), + this.getCachedUrl(`images/${folder}${filenameRoot}.json`), + ); if (folder.startsWith("ui")) { legacyCompatibleImages.push(key); folder = folder.replace("ui", "ui/legacy"); - this.load.atlas(`${key}_legacy`, this.getCachedUrl(`images/${folder}${filenameRoot}.png`), this.getCachedUrl(`images/${folder}${filenameRoot}.json`)); + this.load.atlas( + `${key}_legacy`, + this.getCachedUrl(`images/${folder}${filenameRoot}.png`), + this.getCachedUrl(`images/${folder}${filenameRoot}.json`), + ); } } @@ -78,7 +89,7 @@ export class SceneBase extends Phaser.Scene { folder += "/"; } if (!Array.isArray(filenames)) { - filenames = [ filenames ]; + filenames = [filenames]; } for (const f of filenames as string[]) { this.load.audio(folder + key, this.getCachedUrl(`audio/${folder}${f}`)); diff --git a/src/system/achv.ts b/src/system/achv.ts index bd9348a52bf..bd8595b2f94 100644 --- a/src/system/achv.ts +++ b/src/system/achv.ts @@ -5,7 +5,13 @@ import i18next from "i18next"; import * as Utils from "../utils"; import { PlayerGender } from "#enums/player-gender"; import type { Challenge } from "#app/data/challenge"; -import { FlipStatChallenge, FreshStartChallenge, SingleGenerationChallenge, SingleTypeChallenge, InverseBattleChallenge } from "#app/data/challenge"; +import { + FlipStatChallenge, + FreshStartChallenge, + SingleGenerationChallenge, + SingleTypeChallenge, + InverseBattleChallenge, +} from "#app/data/challenge"; import type { ConditionFn } from "#app/@types/common"; import { Stat, getShortenedStatKey } from "#app/enums/stat"; import { Challenges } from "#app/enums/challenges"; @@ -16,7 +22,7 @@ export enum AchvTier { GREAT, ULTRA, ROGUE, - MASTER + MASTER, } export class Achv { @@ -33,7 +39,14 @@ export class Achv { private conditionFunc: ConditionFn | undefined; - constructor(localizationKey:string, name: string, description: string, iconImage: string, score: number, conditionFunc?: ConditionFn) { + constructor( + localizationKey: string, + name: string, + description: string, + iconImage: string, + score: number, + conditionFunc?: ConditionFn, + ) { this.name = name; this.description = description; this.iconImage = iconImage; @@ -50,7 +63,9 @@ export class Achv { getName(playerGender: PlayerGender = PlayerGender.UNSET): string { const genderStr = PlayerGender[playerGender].toLowerCase(); // Localization key is used to get the name of the achievement - return i18next.t(`achv:${this.localizationKey}.name`, { context: genderStr }); + return i18next.t(`achv:${this.localizationKey}.name`, { + context: genderStr, + }); } getDescription(): string { @@ -101,7 +116,14 @@ export class RibbonAchv extends Achv { ribbonAmount: number; constructor(localizationKey: string, name: string, ribbonAmount: number, iconImage: string, score: number) { - super(localizationKey, name, "", iconImage, score, (_args: any[]) => globalScene.gameData.gameStats.ribbonsOwned >= this.ribbonAmount); + super( + localizationKey, + name, + "", + iconImage, + score, + (_args: any[]) => globalScene.gameData.gameStats.ribbonsOwned >= this.ribbonAmount, + ); this.ribbonAmount = ribbonAmount; } } @@ -110,7 +132,14 @@ export class DamageAchv extends Achv { damageAmount: number; constructor(localizationKey: string, name: string, damageAmount: number, iconImage: string, score: number) { - super(localizationKey, name, "", iconImage, score, (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.damageAmount); + super( + localizationKey, + name, + "", + iconImage, + score, + (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.damageAmount, + ); this.damageAmount = damageAmount; } } @@ -119,7 +148,14 @@ export class HealAchv extends Achv { healAmount: number; constructor(localizationKey: string, name: string, healAmount: number, iconImage: string, score: number) { - super(localizationKey, name, "", iconImage, score, (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.healAmount); + super( + localizationKey, + name, + "", + iconImage, + score, + (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.healAmount, + ); this.healAmount = healAmount; } } @@ -128,24 +164,44 @@ export class LevelAchv extends Achv { level: number; constructor(localizationKey: string, name: string, level: number, iconImage: string, score: number) { - super(localizationKey, name, "", iconImage, score, (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.level); + super( + localizationKey, + name, + "", + iconImage, + score, + (args: any[]) => (args[0] instanceof Utils.NumberHolder ? args[0].value : args[0]) >= this.level, + ); this.level = level; } } export class ModifierAchv extends Achv { - constructor(localizationKey: string, name: string, description: string, iconImage: string, score: number, modifierFunc: (modifier: Modifier) => boolean) { - super(localizationKey, name, description, iconImage, score, (args: any[]) => modifierFunc((args[0] as Modifier))); + constructor( + localizationKey: string, + name: string, + description: string, + iconImage: string, + score: number, + modifierFunc: (modifier: Modifier) => boolean, + ) { + super(localizationKey, name, description, iconImage, score, (args: any[]) => modifierFunc(args[0] as Modifier)); } } export class ChallengeAchv extends Achv { - constructor(localizationKey: string, name: string, description: string, iconImage: string, score: number, challengeFunc: (challenge: Challenge) => boolean) { + constructor( + localizationKey: string, + name: string, + description: string, + iconImage: string, + score: number, + challengeFunc: (challenge: Challenge) => boolean, + ) { super(localizationKey, name, description, iconImage, score, (args: any[]) => challengeFunc(args[0] as Challenge)); } } - /** * Get the description of an achievement from the localization file with all the necessary variables filled in * @param localizationKey The localization key of the achievement @@ -158,49 +214,117 @@ export function getAchievementDescription(localizationKey: string): string { switch (localizationKey) { case "10K_MONEY": - return i18next.t("achv:MoneyAchv.description", { context: genderStr, "moneyAmount": achvs._10K_MONEY.moneyAmount.toLocaleString("en-US") }); + return i18next.t("achv:MoneyAchv.description", { + context: genderStr, + moneyAmount: achvs._10K_MONEY.moneyAmount.toLocaleString("en-US"), + }); case "100K_MONEY": - return i18next.t("achv:MoneyAchv.description", { context: genderStr, "moneyAmount": achvs._100K_MONEY.moneyAmount.toLocaleString("en-US") }); + return i18next.t("achv:MoneyAchv.description", { + context: genderStr, + moneyAmount: achvs._100K_MONEY.moneyAmount.toLocaleString("en-US"), + }); case "1M_MONEY": - return i18next.t("achv:MoneyAchv.description", { context: genderStr, "moneyAmount": achvs._1M_MONEY.moneyAmount.toLocaleString("en-US") }); + return i18next.t("achv:MoneyAchv.description", { + context: genderStr, + moneyAmount: achvs._1M_MONEY.moneyAmount.toLocaleString("en-US"), + }); case "10M_MONEY": - return i18next.t("achv:MoneyAchv.description", { context: genderStr, "moneyAmount": achvs._10M_MONEY.moneyAmount.toLocaleString("en-US") }); + return i18next.t("achv:MoneyAchv.description", { + context: genderStr, + moneyAmount: achvs._10M_MONEY.moneyAmount.toLocaleString("en-US"), + }); case "250_DMG": - return i18next.t("achv:DamageAchv.description", { context: genderStr, "damageAmount": achvs._250_DMG.damageAmount.toLocaleString("en-US") }); + return i18next.t("achv:DamageAchv.description", { + context: genderStr, + damageAmount: achvs._250_DMG.damageAmount.toLocaleString("en-US"), + }); case "1000_DMG": - return i18next.t("achv:DamageAchv.description", { context: genderStr, "damageAmount": achvs._1000_DMG.damageAmount.toLocaleString("en-US") }); + return i18next.t("achv:DamageAchv.description", { + context: genderStr, + damageAmount: achvs._1000_DMG.damageAmount.toLocaleString("en-US"), + }); case "2500_DMG": - return i18next.t("achv:DamageAchv.description", { context: genderStr, "damageAmount": achvs._2500_DMG.damageAmount.toLocaleString("en-US") }); + return i18next.t("achv:DamageAchv.description", { + context: genderStr, + damageAmount: achvs._2500_DMG.damageAmount.toLocaleString("en-US"), + }); case "10000_DMG": - return i18next.t("achv:DamageAchv.description", { context: genderStr, "damageAmount": achvs._10000_DMG.damageAmount.toLocaleString("en-US") }); + return i18next.t("achv:DamageAchv.description", { + context: genderStr, + damageAmount: achvs._10000_DMG.damageAmount.toLocaleString("en-US"), + }); case "250_HEAL": - return i18next.t("achv:HealAchv.description", { context: genderStr, "healAmount": achvs._250_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); + return i18next.t("achv:HealAchv.description", { + context: genderStr, + healAmount: achvs._250_HEAL.healAmount.toLocaleString("en-US"), + HP: i18next.t(getShortenedStatKey(Stat.HP)), + }); case "1000_HEAL": - return i18next.t("achv:HealAchv.description", { context: genderStr, "healAmount": achvs._1000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); + return i18next.t("achv:HealAchv.description", { + context: genderStr, + healAmount: achvs._1000_HEAL.healAmount.toLocaleString("en-US"), + HP: i18next.t(getShortenedStatKey(Stat.HP)), + }); case "2500_HEAL": - return i18next.t("achv:HealAchv.description", { context: genderStr, "healAmount": achvs._2500_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); + return i18next.t("achv:HealAchv.description", { + context: genderStr, + healAmount: achvs._2500_HEAL.healAmount.toLocaleString("en-US"), + HP: i18next.t(getShortenedStatKey(Stat.HP)), + }); case "10000_HEAL": - return i18next.t("achv:HealAchv.description", { context: genderStr, "healAmount": achvs._10000_HEAL.healAmount.toLocaleString("en-US"), "HP": i18next.t(getShortenedStatKey(Stat.HP)) }); + return i18next.t("achv:HealAchv.description", { + context: genderStr, + healAmount: achvs._10000_HEAL.healAmount.toLocaleString("en-US"), + HP: i18next.t(getShortenedStatKey(Stat.HP)), + }); case "LV_100": - return i18next.t("achv:LevelAchv.description", { context: genderStr, "level": achvs.LV_100.level }); + return i18next.t("achv:LevelAchv.description", { + context: genderStr, + level: achvs.LV_100.level, + }); case "LV_250": - return i18next.t("achv:LevelAchv.description", { context: genderStr, "level": achvs.LV_250.level }); + return i18next.t("achv:LevelAchv.description", { + context: genderStr, + level: achvs.LV_250.level, + }); case "LV_1000": - return i18next.t("achv:LevelAchv.description", { context: genderStr, "level": achvs.LV_1000.level }); + return i18next.t("achv:LevelAchv.description", { + context: genderStr, + level: achvs.LV_1000.level, + }); case "10_RIBBONS": - return i18next.t("achv:RibbonAchv.description", { context: genderStr, "ribbonAmount": achvs._10_RIBBONS.ribbonAmount.toLocaleString("en-US") }); + return i18next.t("achv:RibbonAchv.description", { + context: genderStr, + ribbonAmount: achvs._10_RIBBONS.ribbonAmount.toLocaleString("en-US"), + }); case "25_RIBBONS": - return i18next.t("achv:RibbonAchv.description", { context: genderStr, "ribbonAmount": achvs._25_RIBBONS.ribbonAmount.toLocaleString("en-US") }); + return i18next.t("achv:RibbonAchv.description", { + context: genderStr, + ribbonAmount: achvs._25_RIBBONS.ribbonAmount.toLocaleString("en-US"), + }); case "50_RIBBONS": - return i18next.t("achv:RibbonAchv.description", { context: genderStr, "ribbonAmount": achvs._50_RIBBONS.ribbonAmount.toLocaleString("en-US") }); + return i18next.t("achv:RibbonAchv.description", { + context: genderStr, + ribbonAmount: achvs._50_RIBBONS.ribbonAmount.toLocaleString("en-US"), + }); case "75_RIBBONS": - return i18next.t("achv:RibbonAchv.description", { context: genderStr, "ribbonAmount": achvs._75_RIBBONS.ribbonAmount.toLocaleString("en-US") }); + return i18next.t("achv:RibbonAchv.description", { + context: genderStr, + ribbonAmount: achvs._75_RIBBONS.ribbonAmount.toLocaleString("en-US"), + }); case "100_RIBBONS": - return i18next.t("achv:RibbonAchv.description", { context: genderStr, "ribbonAmount": achvs._100_RIBBONS.ribbonAmount.toLocaleString("en-US") }); + return i18next.t("achv:RibbonAchv.description", { + context: genderStr, + ribbonAmount: achvs._100_RIBBONS.ribbonAmount.toLocaleString("en-US"), + }); case "TRANSFER_MAX_STAT_STAGE": - return i18next.t("achv:TRANSFER_MAX_STAT_STAGE.description", { context: genderStr }); + return i18next.t("achv:TRANSFER_MAX_STAT_STAGE.description", { + context: genderStr, + }); case "MAX_FRIENDSHIP": - return i18next.t("achv:MAX_FRIENDSHIP.description", { context: genderStr }); + return i18next.t("achv:MAX_FRIENDSHIP.description", { + context: genderStr, + }); case "MEGA_EVOLVE": return i18next.t("achv:MEGA_EVOLVE.description", { context: genderStr }); case "GIGANTAMAX": @@ -208,55 +332,89 @@ export function getAchievementDescription(localizationKey: string): string { case "TERASTALLIZE": return i18next.t("achv:TERASTALLIZE.description", { context: genderStr }); case "STELLAR_TERASTALLIZE": - return i18next.t("achv:STELLAR_TERASTALLIZE.description", { context: genderStr }); + return i18next.t("achv:STELLAR_TERASTALLIZE.description", { + context: genderStr, + }); case "SPLICE": return i18next.t("achv:SPLICE.description", { context: genderStr }); case "MINI_BLACK_HOLE": - return i18next.t("achv:MINI_BLACK_HOLE.description", { context: genderStr }); + return i18next.t("achv:MINI_BLACK_HOLE.description", { + context: genderStr, + }); case "CATCH_MYTHICAL": - return i18next.t("achv:CATCH_MYTHICAL.description", { context: genderStr }); + return i18next.t("achv:CATCH_MYTHICAL.description", { + context: genderStr, + }); case "CATCH_SUB_LEGENDARY": - return i18next.t("achv:CATCH_SUB_LEGENDARY.description", { context: genderStr }); + return i18next.t("achv:CATCH_SUB_LEGENDARY.description", { + context: genderStr, + }); case "CATCH_LEGENDARY": - return i18next.t("achv:CATCH_LEGENDARY.description", { context: genderStr }); + return i18next.t("achv:CATCH_LEGENDARY.description", { + context: genderStr, + }); case "SEE_SHINY": return i18next.t("achv:SEE_SHINY.description", { context: genderStr }); case "SHINY_PARTY": return i18next.t("achv:SHINY_PARTY.description", { context: genderStr }); case "HATCH_MYTHICAL": - return i18next.t("achv:HATCH_MYTHICAL.description", { context: genderStr }); + return i18next.t("achv:HATCH_MYTHICAL.description", { + context: genderStr, + }); case "HATCH_SUB_LEGENDARY": - return i18next.t("achv:HATCH_SUB_LEGENDARY.description", { context: genderStr }); + return i18next.t("achv:HATCH_SUB_LEGENDARY.description", { + context: genderStr, + }); case "HATCH_LEGENDARY": - return i18next.t("achv:HATCH_LEGENDARY.description", { context: genderStr }); + return i18next.t("achv:HATCH_LEGENDARY.description", { + context: genderStr, + }); case "HATCH_SHINY": return i18next.t("achv:HATCH_SHINY.description", { context: genderStr }); case "HIDDEN_ABILITY": - return i18next.t("achv:HIDDEN_ABILITY.description", { context: genderStr }); + return i18next.t("achv:HIDDEN_ABILITY.description", { + context: genderStr, + }); case "PERFECT_IVS": return i18next.t("achv:PERFECT_IVS.description", { context: genderStr }); case "CLASSIC_VICTORY": - return i18next.t("achv:CLASSIC_VICTORY.description", { context: genderStr }); + return i18next.t("achv:CLASSIC_VICTORY.description", { + context: genderStr, + }); case "UNEVOLVED_CLASSIC_VICTORY": - return i18next.t("achv:UNEVOLVED_CLASSIC_VICTORY.description", { context: genderStr }); + return i18next.t("achv:UNEVOLVED_CLASSIC_VICTORY.description", { + context: genderStr, + }); case "MONO_GEN_ONE": return i18next.t("achv:MONO_GEN_ONE.description", { context: genderStr }); case "MONO_GEN_TWO": return i18next.t("achv:MONO_GEN_TWO.description", { context: genderStr }); case "MONO_GEN_THREE": - return i18next.t("achv:MONO_GEN_THREE.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_THREE.description", { + context: genderStr, + }); case "MONO_GEN_FOUR": - return i18next.t("achv:MONO_GEN_FOUR.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_FOUR.description", { + context: genderStr, + }); case "MONO_GEN_FIVE": - return i18next.t("achv:MONO_GEN_FIVE.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_FIVE.description", { + context: genderStr, + }); case "MONO_GEN_SIX": return i18next.t("achv:MONO_GEN_SIX.description", { context: genderStr }); case "MONO_GEN_SEVEN": - return i18next.t("achv:MONO_GEN_SEVEN.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_SEVEN.description", { + context: genderStr, + }); case "MONO_GEN_EIGHT": - return i18next.t("achv:MONO_GEN_EIGHT.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_EIGHT.description", { + context: genderStr, + }); case "MONO_GEN_NINE": - return i18next.t("achv:MONO_GEN_NINE.description", { context: genderStr }); + return i18next.t("achv:MONO_GEN_NINE.description", { + context: genderStr, + }); case "MONO_NORMAL": case "MONO_FIGHTING": case "MONO_FLYING": @@ -275,21 +433,27 @@ export function getAchievementDescription(localizationKey: string): string { case "MONO_DRAGON": case "MONO_DARK": case "MONO_FAIRY": - return i18next.t("achv:MonoType.description", { context: genderStr, "type": i18next.t(`pokemonInfo:Type.${localizationKey.slice(5)}`) }); + return i18next.t("achv:MonoType.description", { + context: genderStr, + type: i18next.t(`pokemonInfo:Type.${localizationKey.slice(5)}`), + }); case "FRESH_START": return i18next.t("achv:FRESH_START.description", { context: genderStr }); case "INVERSE_BATTLE": - return i18next.t("achv:INVERSE_BATTLE.description", { context: genderStr }); + return i18next.t("achv:INVERSE_BATTLE.description", { + context: genderStr, + }); case "FLIP_STATS": return i18next.t("achv:FLIP_STATS.description", { context: genderStr }); case "FLIP_INVERSE": return i18next.t("achv:FLIP_INVERSE.description", { context: genderStr }); case "BREEDERS_IN_SPACE": - return i18next.t("achv:BREEDERS_IN_SPACE.description", { context: genderStr }); + return i18next.t("achv:BREEDERS_IN_SPACE.description", { + context: genderStr, + }); default: return ""; } - } export const achvs = { @@ -313,58 +477,451 @@ export const achvs = { _50_RIBBONS: new RibbonAchv("50_RIBBONS", "", 50, "ultra_ribbon", 50).setSecret(true), _75_RIBBONS: new RibbonAchv("75_RIBBONS", "", 75, "rogue_ribbon", 75).setSecret(true), _100_RIBBONS: new RibbonAchv("100_RIBBONS", "", 100, "master_ribbon", 100).setSecret(true), - TRANSFER_MAX_STAT_STAGE: new Achv("TRANSFER_MAX_STAT_STAGE", "", "TRANSFER_MAX_STAT_STAGE.description", "baton", 20), + TRANSFER_MAX_STAT_STAGE: new Achv("TRANSFER_MAX_STAT_STAGE", "", "TRANSFER_MAX_STAT_STAGE.description", "baton", 20), MAX_FRIENDSHIP: new Achv("MAX_FRIENDSHIP", "", "MAX_FRIENDSHIP.description", "soothe_bell", 25), MEGA_EVOLVE: new Achv("MEGA_EVOLVE", "", "MEGA_EVOLVE.description", "mega_bracelet", 50), GIGANTAMAX: new Achv("GIGANTAMAX", "", "GIGANTAMAX.description", "dynamax_band", 50), - TERASTALLIZE: new Achv("TERASTALLIZE", "", "TERASTALLIZE.description", "tera_orb", 25), - STELLAR_TERASTALLIZE: new Achv("STELLAR_TERASTALLIZE", "", "STELLAR_TERASTALLIZE.description", "stellar_tera_shard", 25).setSecret(true), - SPLICE: new Achv("SPLICE", "", "SPLICE.description", "dna_splicers", 10), - MINI_BLACK_HOLE: new ModifierAchv("MINI_BLACK_HOLE", "", "MINI_BLACK_HOLE.description", "mini_black_hole", 25, modifier => modifier instanceof TurnHeldItemTransferModifier).setSecret(), - CATCH_MYTHICAL: new Achv("CATCH_MYTHICAL", "", "CATCH_MYTHICAL.description", "strange_ball", 50).setSecret(), - CATCH_SUB_LEGENDARY: new Achv("CATCH_SUB_LEGENDARY", "", "CATCH_SUB_LEGENDARY.description", "rb", 75).setSecret(), + TERASTALLIZE: new Achv("TERASTALLIZE", "", "TERASTALLIZE.description", "tera_orb", 25), + STELLAR_TERASTALLIZE: new Achv( + "STELLAR_TERASTALLIZE", + "", + "STELLAR_TERASTALLIZE.description", + "stellar_tera_shard", + 25, + ).setSecret(true), + SPLICE: new Achv("SPLICE", "", "SPLICE.description", "dna_splicers", 10), + MINI_BLACK_HOLE: new ModifierAchv( + "MINI_BLACK_HOLE", + "", + "MINI_BLACK_HOLE.description", + "mini_black_hole", + 25, + modifier => modifier instanceof TurnHeldItemTransferModifier, + ).setSecret(), + CATCH_MYTHICAL: new Achv("CATCH_MYTHICAL", "", "CATCH_MYTHICAL.description", "strange_ball", 50).setSecret(), + CATCH_SUB_LEGENDARY: new Achv("CATCH_SUB_LEGENDARY", "", "CATCH_SUB_LEGENDARY.description", "rb", 75).setSecret(), CATCH_LEGENDARY: new Achv("CATCH_LEGENDARY", "", "CATCH_LEGENDARY.description", "mb", 100).setSecret(), SEE_SHINY: new Achv("SEE_SHINY", "", "SEE_SHINY.description", "pb_gold", 75), SHINY_PARTY: new Achv("SHINY_PARTY", "", "SHINY_PARTY.description", "shiny_charm", 100).setSecret(true), HATCH_MYTHICAL: new Achv("HATCH_MYTHICAL", "", "HATCH_MYTHICAL.description", "mystery_egg", 75).setSecret(), - HATCH_SUB_LEGENDARY: new Achv("HATCH_SUB_LEGENDARY", "", "HATCH_SUB_LEGENDARY.description", "oval_stone", 100).setSecret(), - HATCH_LEGENDARY: new Achv("HATCH_LEGENDARY", "", "HATCH_LEGENDARY.description", "lucky_egg", 125).setSecret(), - HATCH_SHINY: new Achv("HATCH_SHINY", "", "HATCH_SHINY.description", "golden_egg", 100).setSecret(), - HIDDEN_ABILITY: new Achv("HIDDEN_ABILITY", "", "HIDDEN_ABILITY.description", "ability_charm", 75), - PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100), - CLASSIC_VICTORY: new Achv("CLASSIC_VICTORY", "", "CLASSIC_VICTORY.description", "relic_crown", 150, (_) => globalScene.gameData.gameStats.sessionsWon === 0), - UNEVOLVED_CLASSIC_VICTORY: new Achv("UNEVOLVED_CLASSIC_VICTORY", "", "UNEVOLVED_CLASSIC_VICTORY.description", "eviolite", 175, (_) => globalScene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions)), - MONO_GEN_ONE_VICTORY: new ChallengeAchv("MONO_GEN_ONE", "", "MONO_GEN_ONE.description", "ribbon_gen1", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_TWO_VICTORY: new ChallengeAchv("MONO_GEN_TWO", "", "MONO_GEN_TWO.description", "ribbon_gen2", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_THREE_VICTORY: new ChallengeAchv("MONO_GEN_THREE", "", "MONO_GEN_THREE.description", "ribbon_gen3", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_FOUR_VICTORY: new ChallengeAchv("MONO_GEN_FOUR", "", "MONO_GEN_FOUR.description", "ribbon_gen4", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_FIVE_VICTORY: new ChallengeAchv("MONO_GEN_FIVE", "", "MONO_GEN_FIVE.description", "ribbon_gen5", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_SIX_VICTORY: new ChallengeAchv("MONO_GEN_SIX", "", "MONO_GEN_SIX.description", "ribbon_gen6", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_SEVEN_VICTORY: new ChallengeAchv("MONO_GEN_SEVEN", "", "MONO_GEN_SEVEN.description", "ribbon_gen7", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_EIGHT_VICTORY: new ChallengeAchv("MONO_GEN_EIGHT", "", "MONO_GEN_EIGHT.description", "ribbon_gen8", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GEN_NINE_VICTORY: new ChallengeAchv("MONO_GEN_NINE", "", "MONO_GEN_NINE.description", "ribbon_gen9", 100, (c) => c instanceof SingleGenerationChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_NORMAL: new ChallengeAchv("MONO_NORMAL", "", "MONO_NORMAL.description", "silk_scarf", 100, (c) => c instanceof SingleTypeChallenge && c.value === 1 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_FIGHTING: new ChallengeAchv("MONO_FIGHTING", "", "MONO_FIGHTING.description", "black_belt", 100, (c) => c instanceof SingleTypeChallenge && c.value === 2 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_FLYING: new ChallengeAchv("MONO_FLYING", "", "MONO_FLYING.description", "sharp_beak", 100, (c) => c instanceof SingleTypeChallenge && c.value === 3 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_POISON: new ChallengeAchv("MONO_POISON", "", "MONO_POISON.description", "poison_barb", 100, (c) => c instanceof SingleTypeChallenge && c.value === 4 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GROUND: new ChallengeAchv("MONO_GROUND", "", "MONO_GROUND.description", "soft_sand", 100, (c) => c instanceof SingleTypeChallenge && c.value === 5 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_ROCK: new ChallengeAchv("MONO_ROCK", "", "MONO_ROCK.description", "hard_stone", 100, (c) => c instanceof SingleTypeChallenge && c.value === 6 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_BUG: new ChallengeAchv("MONO_BUG", "", "MONO_BUG.description", "silver_powder", 100, (c) => c instanceof SingleTypeChallenge && c.value === 7 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GHOST: new ChallengeAchv("MONO_GHOST", "", "MONO_GHOST.description", "spell_tag", 100, (c) => c instanceof SingleTypeChallenge && c.value === 8 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_STEEL: new ChallengeAchv("MONO_STEEL", "", "MONO_STEEL.description", "metal_coat", 100, (c) => c instanceof SingleTypeChallenge && c.value === 9 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_FIRE: new ChallengeAchv("MONO_FIRE", "", "MONO_FIRE.description", "charcoal", 100, (c) => c instanceof SingleTypeChallenge && c.value === 10 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_WATER: new ChallengeAchv("MONO_WATER", "", "MONO_WATER.description", "mystic_water", 100, (c) => c instanceof SingleTypeChallenge && c.value === 11 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_GRASS: new ChallengeAchv("MONO_GRASS", "", "MONO_GRASS.description", "miracle_seed", 100, (c) => c instanceof SingleTypeChallenge && c.value === 12 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_ELECTRIC: new ChallengeAchv("MONO_ELECTRIC", "", "MONO_ELECTRIC.description", "magnet", 100, (c) => c instanceof SingleTypeChallenge && c.value === 13 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_PSYCHIC: new ChallengeAchv("MONO_PSYCHIC", "", "MONO_PSYCHIC.description", "twisted_spoon", 100, (c) => c instanceof SingleTypeChallenge && c.value === 14 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_ICE: new ChallengeAchv("MONO_ICE", "", "MONO_ICE.description", "never_melt_ice", 100, (c) => c instanceof SingleTypeChallenge && c.value === 15 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_DRAGON: new ChallengeAchv("MONO_DRAGON", "", "MONO_DRAGON.description", "dragon_fang", 100, (c) => c instanceof SingleTypeChallenge && c.value === 16 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_DARK: new ChallengeAchv("MONO_DARK", "", "MONO_DARK.description", "black_glasses", 100, (c) => c instanceof SingleTypeChallenge && c.value === 17 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - MONO_FAIRY: new ChallengeAchv("MONO_FAIRY", "", "MONO_FAIRY.description", "fairy_feather", 100, (c) => c instanceof SingleTypeChallenge && c.value === 18 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - FRESH_START: new ChallengeAchv("FRESH_START", "", "FRESH_START.description", "reviver_seed", 100, (c) => c instanceof FreshStartChallenge && c.value > 0 && !globalScene.gameMode.challenges.some(c => [ Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT ].includes(c.id) && c.value > 0)), - INVERSE_BATTLE: new ChallengeAchv("INVERSE_BATTLE", "", "INVERSE_BATTLE.description", "inverse", 100, (c) => c instanceof InverseBattleChallenge && c.value > 0), - FLIP_STATS: new ChallengeAchv("FLIP_STATS", "", "FLIP_STATS.description", "dubious_disc", 100, (c) => c instanceof FlipStatChallenge && c.value > 0), - FLIP_INVERSE: new ChallengeAchv("FLIP_INVERSE", "", "FLIP_INVERSE.description", "cracked_pot", 100, (c) => c instanceof FlipStatChallenge && c.value > 0 && globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0)).setSecret(), + HATCH_SUB_LEGENDARY: new Achv( + "HATCH_SUB_LEGENDARY", + "", + "HATCH_SUB_LEGENDARY.description", + "oval_stone", + 100, + ).setSecret(), + HATCH_LEGENDARY: new Achv("HATCH_LEGENDARY", "", "HATCH_LEGENDARY.description", "lucky_egg", 125).setSecret(), + HATCH_SHINY: new Achv("HATCH_SHINY", "", "HATCH_SHINY.description", "golden_egg", 100).setSecret(), + HIDDEN_ABILITY: new Achv("HIDDEN_ABILITY", "", "HIDDEN_ABILITY.description", "ability_charm", 75), + PERFECT_IVS: new Achv("PERFECT_IVS", "", "PERFECT_IVS.description", "blunder_policy", 100), + CLASSIC_VICTORY: new Achv( + "CLASSIC_VICTORY", + "", + "CLASSIC_VICTORY.description", + "relic_crown", + 150, + _ => globalScene.gameData.gameStats.sessionsWon === 0, + ), + UNEVOLVED_CLASSIC_VICTORY: new Achv( + "UNEVOLVED_CLASSIC_VICTORY", + "", + "UNEVOLVED_CLASSIC_VICTORY.description", + "eviolite", + 175, + _ => globalScene.getPlayerParty().some(p => p.getSpeciesForm(true).speciesId in pokemonEvolutions), + ), + MONO_GEN_ONE_VICTORY: new ChallengeAchv( + "MONO_GEN_ONE", + "", + "MONO_GEN_ONE.description", + "ribbon_gen1", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 1 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_TWO_VICTORY: new ChallengeAchv( + "MONO_GEN_TWO", + "", + "MONO_GEN_TWO.description", + "ribbon_gen2", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 2 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_THREE_VICTORY: new ChallengeAchv( + "MONO_GEN_THREE", + "", + "MONO_GEN_THREE.description", + "ribbon_gen3", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 3 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_FOUR_VICTORY: new ChallengeAchv( + "MONO_GEN_FOUR", + "", + "MONO_GEN_FOUR.description", + "ribbon_gen4", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 4 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_FIVE_VICTORY: new ChallengeAchv( + "MONO_GEN_FIVE", + "", + "MONO_GEN_FIVE.description", + "ribbon_gen5", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 5 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_SIX_VICTORY: new ChallengeAchv( + "MONO_GEN_SIX", + "", + "MONO_GEN_SIX.description", + "ribbon_gen6", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 6 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_SEVEN_VICTORY: new ChallengeAchv( + "MONO_GEN_SEVEN", + "", + "MONO_GEN_SEVEN.description", + "ribbon_gen7", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 7 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_EIGHT_VICTORY: new ChallengeAchv( + "MONO_GEN_EIGHT", + "", + "MONO_GEN_EIGHT.description", + "ribbon_gen8", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 8 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GEN_NINE_VICTORY: new ChallengeAchv( + "MONO_GEN_NINE", + "", + "MONO_GEN_NINE.description", + "ribbon_gen9", + 100, + c => + c instanceof SingleGenerationChallenge && + c.value === 9 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_NORMAL: new ChallengeAchv( + "MONO_NORMAL", + "", + "MONO_NORMAL.description", + "silk_scarf", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 1 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_FIGHTING: new ChallengeAchv( + "MONO_FIGHTING", + "", + "MONO_FIGHTING.description", + "black_belt", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 2 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_FLYING: new ChallengeAchv( + "MONO_FLYING", + "", + "MONO_FLYING.description", + "sharp_beak", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 3 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_POISON: new ChallengeAchv( + "MONO_POISON", + "", + "MONO_POISON.description", + "poison_barb", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 4 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GROUND: new ChallengeAchv( + "MONO_GROUND", + "", + "MONO_GROUND.description", + "soft_sand", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 5 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_ROCK: new ChallengeAchv( + "MONO_ROCK", + "", + "MONO_ROCK.description", + "hard_stone", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 6 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_BUG: new ChallengeAchv( + "MONO_BUG", + "", + "MONO_BUG.description", + "silver_powder", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 7 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GHOST: new ChallengeAchv( + "MONO_GHOST", + "", + "MONO_GHOST.description", + "spell_tag", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 8 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_STEEL: new ChallengeAchv( + "MONO_STEEL", + "", + "MONO_STEEL.description", + "metal_coat", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 9 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_FIRE: new ChallengeAchv( + "MONO_FIRE", + "", + "MONO_FIRE.description", + "charcoal", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 10 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_WATER: new ChallengeAchv( + "MONO_WATER", + "", + "MONO_WATER.description", + "mystic_water", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 11 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_GRASS: new ChallengeAchv( + "MONO_GRASS", + "", + "MONO_GRASS.description", + "miracle_seed", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 12 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_ELECTRIC: new ChallengeAchv( + "MONO_ELECTRIC", + "", + "MONO_ELECTRIC.description", + "magnet", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 13 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_PSYCHIC: new ChallengeAchv( + "MONO_PSYCHIC", + "", + "MONO_PSYCHIC.description", + "twisted_spoon", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 14 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_ICE: new ChallengeAchv( + "MONO_ICE", + "", + "MONO_ICE.description", + "never_melt_ice", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 15 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_DRAGON: new ChallengeAchv( + "MONO_DRAGON", + "", + "MONO_DRAGON.description", + "dragon_fang", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 16 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_DARK: new ChallengeAchv( + "MONO_DARK", + "", + "MONO_DARK.description", + "black_glasses", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 17 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + MONO_FAIRY: new ChallengeAchv( + "MONO_FAIRY", + "", + "MONO_FAIRY.description", + "fairy_feather", + 100, + c => + c instanceof SingleTypeChallenge && + c.value === 18 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + FRESH_START: new ChallengeAchv( + "FRESH_START", + "", + "FRESH_START.description", + "reviver_seed", + 100, + c => + c instanceof FreshStartChallenge && + c.value > 0 && + !globalScene.gameMode.challenges.some( + c => [Challenges.INVERSE_BATTLE, Challenges.FLIP_STAT].includes(c.id) && c.value > 0, + ), + ), + INVERSE_BATTLE: new ChallengeAchv( + "INVERSE_BATTLE", + "", + "INVERSE_BATTLE.description", + "inverse", + 100, + c => c instanceof InverseBattleChallenge && c.value > 0, + ), + FLIP_STATS: new ChallengeAchv( + "FLIP_STATS", + "", + "FLIP_STATS.description", + "dubious_disc", + 100, + c => c instanceof FlipStatChallenge && c.value > 0, + ), + FLIP_INVERSE: new ChallengeAchv( + "FLIP_INVERSE", + "", + "FLIP_INVERSE.description", + "cracked_pot", + 100, + c => + c instanceof FlipStatChallenge && + c.value > 0 && + globalScene.gameMode.challenges.some(c => c.id === Challenges.INVERSE_BATTLE && c.value > 0), + ).setSecret(), BREEDERS_IN_SPACE: new Achv("BREEDERS_IN_SPACE", "", "BREEDERS_IN_SPACE.description", "moon_stone", 50).setSecret(), }; diff --git a/src/system/arena-data.ts b/src/system/arena-data.ts index 518acb55c89..07396b31d1b 100644 --- a/src/system/arena-data.ts +++ b/src/system/arena-data.ts @@ -13,10 +13,18 @@ export default class ArenaData { public playerTerasUsed: number; constructor(source: Arena | any) { - const sourceArena = source instanceof Arena ? source as Arena : null; + const sourceArena = source instanceof Arena ? (source as Arena) : null; this.biome = sourceArena ? sourceArena.biomeType : source.biome; - this.weather = sourceArena ? sourceArena.weather : source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : null; - this.terrain = sourceArena ? sourceArena.terrain : source.terrain ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) : null; + this.weather = sourceArena + ? sourceArena.weather + : source.weather + ? new Weather(source.weather.weatherType, source.weather.turnsLeft) + : null; + this.terrain = sourceArena + ? sourceArena.terrain + : source.terrain + ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) + : null; this.playerTerasUsed = (sourceArena ? sourceArena.playerTerasUsed : source.playerTerasUsed) ?? 0; this.tags = []; diff --git a/src/system/egg-data.ts b/src/system/egg-data.ts index 8296c2da98e..8fb8335bcf7 100644 --- a/src/system/egg-data.ts +++ b/src/system/egg-data.ts @@ -17,9 +17,9 @@ export default class EggData { public overrideHiddenAbility: boolean; constructor(source: Egg | any) { - const sourceEgg = source instanceof Egg ? source as Egg : null; + const sourceEgg = source instanceof Egg ? (source as Egg) : null; this.id = sourceEgg ? sourceEgg.id : source.id; - this.tier = sourceEgg ? sourceEgg.tier : (source.tier ?? Math.floor(this.id / EGG_SEED)); + this.tier = sourceEgg ? sourceEgg.tier : (source.tier ?? Math.floor(this.id / EGG_SEED)); // legacy egg if (source.species === 0) { // check if it has a gachaType (deprecated) @@ -39,11 +39,25 @@ export default class EggData { toEgg(): Egg { // Species will be 0 if an old legacy is loaded from DB if (!this.species) { - return new Egg({ id: this.id, hatchWaves: this.hatchWaves, sourceType: this.sourceType, timestamp: this.timestamp, tier: Math.floor(this.id / EGG_SEED) }); - } else { - return new Egg({ id: this.id, tier: this.tier, sourceType: this.sourceType, hatchWaves: this.hatchWaves, - timestamp: this.timestamp, variantTier: this.variantTier, isShiny: this.isShiny, species: this.species, - eggMoveIndex: this.eggMoveIndex, overrideHiddenAbility: this.overrideHiddenAbility }); + return new Egg({ + id: this.id, + hatchWaves: this.hatchWaves, + sourceType: this.sourceType, + timestamp: this.timestamp, + tier: Math.floor(this.id / EGG_SEED), + }); } + return new Egg({ + id: this.id, + tier: this.tier, + sourceType: this.sourceType, + hatchWaves: this.hatchWaves, + timestamp: this.timestamp, + variantTier: this.variantTier, + isShiny: this.isShiny, + species: this.species, + eggMoveIndex: this.eggMoveIndex, + overrideHiddenAbility: this.overrideHiddenAbility, + }); } } diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 4f6cb0aed93..82ad2276fef 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -50,7 +50,11 @@ import { WeatherType } from "#enums/weather-type"; import { TerrainType } from "#app/data/terrain"; import { ReloadSessionPhase } from "#app/phases/reload-session-phase"; import { RUN_HISTORY_LIMIT } from "#app/ui/run-history-ui-handler"; -import { applySessionVersionMigration, applySystemVersionMigration, applySettingsVersionMigration } from "./version_migration/version_converter"; +import { + applySessionVersionMigration, + applySystemVersionMigration, + applySettingsVersionMigration, +} from "./version_migration/version_converter"; import { MysteryEncounterSaveData } from "#app/data/mystery-encounters/mystery-encounter-save-data"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; @@ -59,20 +63,38 @@ import { pokemonFormChanges } from "#app/data/pokemon-forms"; import type { PokemonType } from "#enums/pokemon-type"; export const defaultStarterSpecies: Species[] = [ - Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, - Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, - Species.TREECKO, Species.TORCHIC, Species.MUDKIP, - Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, - Species.SNIVY, Species.TEPIG, Species.OSHAWOTT, - Species.CHESPIN, Species.FENNEKIN, Species.FROAKIE, - Species.ROWLET, Species.LITTEN, Species.POPPLIO, - Species.GROOKEY, Species.SCORBUNNY, Species.SOBBLE, - Species.SPRIGATITO, Species.FUECOCO, Species.QUAXLY + Species.BULBASAUR, + Species.CHARMANDER, + Species.SQUIRTLE, + Species.CHIKORITA, + Species.CYNDAQUIL, + Species.TOTODILE, + Species.TREECKO, + Species.TORCHIC, + Species.MUDKIP, + Species.TURTWIG, + Species.CHIMCHAR, + Species.PIPLUP, + Species.SNIVY, + Species.TEPIG, + Species.OSHAWOTT, + Species.CHESPIN, + Species.FENNEKIN, + Species.FROAKIE, + Species.ROWLET, + Species.LITTEN, + Species.POPPLIO, + Species.GROOKEY, + Species.SCORBUNNY, + Species.SOBBLE, + Species.SPRIGATITO, + Species.FUECOCO, + Species.QUAXLY, ]; const saveKey = "x0i2O7WRiANTqPmZ"; // Temporary; secure encryption is not yet necessary -export function getDataTypeKey(dataType: GameDataType, slotId: number = 0): string { +export function getDataTypeKey(dataType: GameDataType, slotId = 0): string { switch (dataType) { case GameDataType.SYSTEM: return "data"; @@ -94,15 +116,15 @@ export function getDataTypeKey(dataType: GameDataType, slotId: number = 0): stri } export function encrypt(data: string, bypassLogin: boolean): string { - return (bypassLogin - ? (data: string) => btoa(data) - : (data: string) => AES.encrypt(data, saveKey))(data) as unknown as string; // TODO: is this correct? + return (bypassLogin ? (data: string) => btoa(data) : (data: string) => AES.encrypt(data, saveKey))( + data, + ) as unknown as string; // TODO: is this correct? } export function decrypt(data: string, bypassLogin: boolean): string { - return (bypassLogin - ? (data: string) => atob(data) - : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))(data); + return (bypassLogin ? (data: string) => atob(data) : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))( + data, + ); } export interface SystemSaveData { @@ -154,25 +176,25 @@ interface Unlocks { } interface AchvUnlocks { - [key: string]: number + [key: string]: number; } interface VoucherUnlocks { - [key: string]: number + [key: string]: number; } export interface VoucherCounts { - [type: string]: number; + [type: string]: number; } export interface DexData { - [key: number]: DexEntry + [key: number]: DexEntry; } export interface DexEntry { seenAttr: bigint; caughtAttr: bigint; - natureAttr: number, + natureAttr: number; seenCount: number; caughtCount: number; hatchedCount: number; @@ -187,7 +209,7 @@ export const DexAttr = { DEFAULT_VARIANT: 16n, VARIANT_2: 32n, VARIANT_3: 64n, - DEFAULT_FORM: 128n + DEFAULT_FORM: 128n, }; export interface DexAttrProps { @@ -200,7 +222,7 @@ export interface DexAttrProps { export const AbilityAttr = { ABILITY_1: 1, ABILITY_2: 2, - ABILITY_HIDDEN: 4 + ABILITY_HIDDEN: 4, }; export type RunHistoryData = Record; @@ -212,14 +234,14 @@ export interface RunEntry { isFavorite: boolean; } -export type StarterMoveset = [ Moves ] | [ Moves, Moves ] | [ Moves, Moves, Moves ] | [ Moves, Moves, Moves, Moves ]; +export type StarterMoveset = [Moves] | [Moves, Moves] | [Moves, Moves, Moves] | [Moves, Moves, Moves, Moves]; export interface StarterFormMoveData { - [key: number]: StarterMoveset + [key: number]: StarterMoveset; } export interface StarterMoveData { - [key: number]: StarterMoveset | StarterFormMoveData + [key: number]: StarterMoveset | StarterFormMoveData; } export interface StarterAttributes { @@ -240,33 +262,33 @@ export interface StarterPreferences { // the latest data saved/loaded for the Starter Preferences. Required to reduce read/writes. Initialize as "{}", since this is the default value and no data needs to be stored if present. // if they ever add private static variables, move this into StarterPrefs -const StarterPrefers_DEFAULT : string = "{}"; -let StarterPrefers_private_latest : string = StarterPrefers_DEFAULT; +const StarterPrefers_DEFAULT: string = "{}"; +let StarterPrefers_private_latest: string = StarterPrefers_DEFAULT; +// called on starter selection show once +export function loadStarterPreferences(): StarterPreferences { + return JSON.parse( + (StarterPrefers_private_latest = + localStorage.getItem(`starterPrefs_${loggedInUser?.username}`) || StarterPrefers_DEFAULT), + ); +} + +// called on starter selection clear, always +export function saveStarterPreferences(prefs: StarterPreferences): void { + const pStr: string = JSON.stringify(prefs); + if (pStr !== StarterPrefers_private_latest) { + // something changed, store the update + localStorage.setItem(`starterPrefs_${loggedInUser?.username}`, pStr); + // update the latest prefs + StarterPrefers_private_latest = pStr; + } +} // This is its own class as StarterPreferences... // - don't need to be loaded on startup // - isn't stored with other data // - don't require to be encrypted // - shouldn't require calls outside of the starter selection -export class StarterPrefs { - // called on starter selection show once - static load(): StarterPreferences { - return JSON.parse( - StarterPrefers_private_latest = (localStorage.getItem(`starterPrefs_${loggedInUser?.username}`) || StarterPrefers_DEFAULT) - ); - } - - // called on starter selection clear, always - static save(prefs: StarterPreferences): void { - const pStr : string = JSON.stringify(prefs); - if (pStr !== StarterPrefers_private_latest) { - // something changed, store the update - localStorage.setItem(`starterPrefs_${loggedInUser?.username}`, pStr); - // update the latest prefs - StarterPrefers_private_latest = pStr; - } - } -} +export class StarterPrefs {} export interface StarterDataEntry { moveset: StarterMoveset | StarterFormMoveData | null; @@ -280,11 +302,11 @@ export interface StarterDataEntry { } export interface StarterData { - [key: number]: StarterDataEntry + [key: number]: StarterDataEntry; } export interface TutorialFlags { - [key: string]: boolean + [key: string]: boolean; } export interface SeenDialogues { @@ -306,7 +328,7 @@ const systemShortKeys = { abilityAttr: "$a", passiveAttr: "$pa", valueReduction: "$vr", - classicWinCount: "$wc" + classicWinCount: "$wc", }; export class GameData { @@ -346,7 +368,7 @@ export class GameData { [Unlockables.ENDLESS_MODE]: false, [Unlockables.MINI_BLACK_HOLE]: false, [Unlockables.SPLICED_ENDLESS_MODE]: false, - [Unlockables.EVIOLITE]: false + [Unlockables.EVIOLITE]: false, }; this.achvUnlocks = {}; this.voucherUnlocks = {}; @@ -354,11 +376,11 @@ export class GameData { [VoucherType.REGULAR]: 0, [VoucherType.PLUS]: 0, [VoucherType.PREMIUM]: 0, - [VoucherType.GOLDEN]: 0 + [VoucherType.GOLDEN]: 0, }; this.eggs = []; - this.eggPity = [ 0, 0, 0, 0 ]; - this.unlockPity = [ 0, 0, 0, 0 ]; + this.eggPity = [0, 0, 0, 0]; + this.unlockPity = [0, 0, 0, 0]; this.initDexData(); this.initStarterData(); } @@ -379,7 +401,7 @@ export class GameData { gameVersion: globalScene.game.config.gameVersion, timestamp: new Date().getTime(), eggPity: this.eggPity.slice(0), - unlockPity: this.unlockPity.slice(0) + unlockPity: this.unlockPity.slice(0), }; } @@ -401,24 +423,25 @@ export class GameData { const data = this.getSystemSaveData(); const maxIntAttrValue = 0x80000000; - const systemData = JSON.stringify(data, (k: any, v: any) => typeof v === "bigint" ? v <= maxIntAttrValue ? Number(v) : v.toString() : v); + const systemData = JSON.stringify(data, (_k: any, v: any) => + typeof v === "bigint" ? (v <= maxIntAttrValue ? Number(v) : v.toString()) : v, + ); localStorage.setItem(`data_${loggedInUser?.username}`, encrypt(systemData, bypassLogin)); if (!bypassLogin) { - pokerogueApi.savedata.system.update({ clientSessionId }, systemData) - .then(error => { - globalScene.ui.savingIcon.hide(); - if (error) { - if (error.startsWith("session out of date")) { - globalScene.clearPhaseQueue(); - globalScene.unshiftPhase(new ReloadSessionPhase()); - } - console.error(error); - return resolve(false); + pokerogueApi.savedata.system.update({ clientSessionId }, systemData).then(error => { + globalScene.ui.savingIcon.hide(); + if (error) { + if (error.startsWith("session out of date")) { + globalScene.clearPhaseQueue(); + globalScene.unshiftPhase(new ReloadSessionPhase()); } - resolve(true); - }); + console.error(error); + return resolve(false); + } + resolve(true); + }); } else { globalScene.ui.savingIcon.hide(); @@ -436,23 +459,34 @@ export class GameData { } if (!bypassLogin) { - pokerogueApi.savedata.system.get({ clientSessionId }) - .then(saveDataOrErr => { - if (!saveDataOrErr || saveDataOrErr.length === 0 || saveDataOrErr[0] !== "{") { - if (saveDataOrErr?.startsWith("sql: no rows in result set")) { - globalScene.queueMessage("Save data could not be found. If this is a new account, you can safely ignore this message.", null, true); - return resolve(true); - } else if (saveDataOrErr?.includes("Too many connections")) { - globalScene.queueMessage("Too many people are trying to connect and the server is overloaded. Please try again later.", null, true); - return resolve(false); - } - console.error(saveDataOrErr); + pokerogueApi.savedata.system.get({ clientSessionId }).then(saveDataOrErr => { + if (!saveDataOrErr || saveDataOrErr.length === 0 || saveDataOrErr[0] !== "{") { + if (saveDataOrErr?.startsWith("sql: no rows in result set")) { + globalScene.queueMessage( + "Save data could not be found. If this is a new account, you can safely ignore this message.", + null, + true, + ); + return resolve(true); + } + if (saveDataOrErr?.includes("Too many connections")) { + globalScene.queueMessage( + "Too many people are trying to connect and the server is overloaded. Please try again later.", + null, + true, + ); return resolve(false); } + console.error(saveDataOrErr); + return resolve(false); + } - const cachedSystem = localStorage.getItem(`data_${loggedInUser?.username}`); - this.initSystem(saveDataOrErr, cachedSystem ? AES.decrypt(cachedSystem, saveKey).toString(enc.Utf8) : undefined).then(resolve); - }); + const cachedSystem = localStorage.getItem(`data_${loggedInUser?.username}`); + this.initSystem( + saveDataOrErr, + cachedSystem ? AES.decrypt(cachedSystem, saveKey).toString(enc.Utf8) : undefined, + ).then(resolve); + }); } else { this.initSystem(decrypt(localStorage.getItem(`data_${loggedInUser?.username}`)!, bypassLogin)).then(resolve); // TODO: is this bang correct? } @@ -513,7 +547,7 @@ export class GameData { this.migrateStarterAbilities(systemData, this.starterData); - const starterIds = Object.keys(this.starterData).map(s => parseInt(s) as Species); + const starterIds = Object.keys(this.starterData).map(s => Number.parseInt(s) as Species); for (const s of starterIds) { this.starterData[s].candyCount += systemData.dexData[s].caughtCount; this.starterData[s].candyCount += systemData.dexData[s].hatchedCount * 2; @@ -560,12 +594,10 @@ export class GameData { }); } - this.eggs = systemData.eggs - ? systemData.eggs.map(e => e.toEgg()) - : []; + this.eggs = systemData.eggs ? systemData.eggs.map(e => e.toEgg()) : []; - this.eggPity = systemData.eggPity ? systemData.eggPity.slice(0) : [ 0, 0, 0, 0 ]; - this.unlockPity = systemData.unlockPity ? systemData.unlockPity.slice(0) : [ 0, 0, 0, 0 ]; + this.eggPity = systemData.eggPity ? systemData.eggPity.slice(0) : [0, 0, 0, 0]; + this.unlockPity = systemData.unlockPity ? systemData.unlockPity.slice(0) : [0, 0, 0, 0]; this.dexData = Object.assign(this.dexData, systemData.dexData); this.consolidateDexData(this.dexData); @@ -595,7 +627,7 @@ export class GameData { const lsItemKey = `runHistoryData_${loggedInUser?.username}`; const lsItem = localStorage.getItem(lsItemKey); if (lsItem) { - const cachedResponse = lsItem; + const cachedResponse = lsItem; if (cachedResponse) { const runHistory = JSON.parse(decrypt(cachedResponse, bypassLogin)); return runHistory; @@ -609,25 +641,22 @@ export class GameData { return cachedRHData; } */ - } else { - localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, ""); - return {}; - } - } else { - const lsItemKey = `runHistoryData_${loggedInUser?.username}`; - const lsItem = localStorage.getItem(lsItemKey); - if (lsItem) { - const cachedResponse = lsItem; - if (cachedResponse) { - const runHistory : RunHistoryData = JSON.parse(decrypt(cachedResponse, bypassLogin)); - return runHistory; - } - return {}; - } else { - localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, ""); - return {}; } + localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, ""); + return {}; } + const lsItemKey = `runHistoryData_${loggedInUser?.username}`; + const lsItem = localStorage.getItem(lsItemKey); + if (lsItem) { + const cachedResponse = lsItem; + if (cachedResponse) { + const runHistory: RunHistoryData = JSON.parse(decrypt(cachedResponse, bypassLogin)); + return runHistory; + } + return {}; + } + localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, ""); + return {}; } /** @@ -636,25 +665,28 @@ export class GameData { * @param isVictory: result of the run * Arbitrary limit of 25 runs per player - Will delete runs, starting with the oldest one, if needed */ - async saveRunHistory(runEntry : SessionSaveData, isVictory: boolean): Promise { + async saveRunHistory(runEntry: SessionSaveData, isVictory: boolean): Promise { const runHistoryData = await this.getRunHistoryData(); // runHistoryData should always return run history or {} empty object let timestamps = Object.keys(runHistoryData).map(Number); // Arbitrary limit of 25 entries per user --> Can increase or decrease - while (timestamps.length >= RUN_HISTORY_LIMIT ) { - const oldestTimestamp = (Math.min.apply(Math, timestamps)).toString(); + while (timestamps.length >= RUN_HISTORY_LIMIT) { + const oldestTimestamp = Math.min.apply(Math, timestamps).toString(); delete runHistoryData[oldestTimestamp]; timestamps = Object.keys(runHistoryData).map(Number); } - const timestamp = (runEntry.timestamp).toString(); + const timestamp = runEntry.timestamp.toString(); runHistoryData[timestamp] = { entry: runEntry, isVictory: isVictory, isFavorite: false, }; - localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, encrypt(JSON.stringify(runHistoryData), bypassLogin)); + localStorage.setItem( + `runHistoryData_${loggedInUser?.username}`, + encrypt(JSON.stringify(runHistoryData), bypassLogin), + ); /** * Networking Code DO NOT DELETE * @@ -676,7 +708,8 @@ export class GameData { return JSON.parse(dataStr, (k: string, v: any) => { if (k === "gameStats") { return new GameStats(v); - } else if (k === "eggs") { + } + if (k === "eggs") { const ret: EggData[] = []; if (v === null) { v = []; @@ -687,11 +720,11 @@ export class GameData { return ret; } - return k.endsWith("Attr") && ![ "natureAttr", "abilityAttr", "passiveAttr" ].includes(k) ? BigInt(v ?? 0) : v; + return k.endsWith("Attr") && !["natureAttr", "abilityAttr", "passiveAttr"].includes(k) ? BigInt(v ?? 0) : v; }) as SystemSaveData; } - convertSystemDataStr(dataStr: string, shorten: boolean = false): string { + convertSystemDataStr(dataStr: string, shorten = false): string { if (!shorten) { // Account for past key oversight dataStr = dataStr.replace(/\$pAttr/g, "$pa"); @@ -712,7 +745,9 @@ export class GameData { return true; } - const systemData = await pokerogueApi.savedata.system.verify({ clientSessionId }); + const systemData = await pokerogueApi.savedata.system.verify({ + clientSessionId, + }); if (systemData) { globalScene.clearPhaseQueue(); @@ -764,17 +799,18 @@ export class GameData { * @returns `true` if the configurations are successfully saved. */ public saveMappingConfigs(deviceName: string, config): boolean { - const key = deviceName.toLowerCase(); // Convert the gamepad name to lowercase to use as a key - let mappingConfigs: object = {}; // Initialize an empty object to hold the mapping configurations - if (localStorage.hasOwnProperty("mappingConfigs")) {// Check if 'mappingConfigs' exists in localStorage + const key = deviceName.toLowerCase(); // Convert the gamepad name to lowercase to use as a key + let mappingConfigs: object = {}; // Initialize an empty object to hold the mapping configurations + if (localStorage.hasOwnProperty("mappingConfigs")) { + // Check if 'mappingConfigs' exists in localStorage mappingConfigs = JSON.parse(localStorage.getItem("mappingConfigs")!); // TODO: is this bang correct? - } // Parse the existing 'mappingConfigs' from localStorage + } // Parse the existing 'mappingConfigs' from localStorage if (!mappingConfigs[key]) { mappingConfigs[key] = {}; - } // If there is no configuration for the given key, create an empty object for it - mappingConfigs[key].custom = config.custom; // Assign the custom configuration to the mapping configuration for the given key - localStorage.setItem("mappingConfigs", JSON.stringify(mappingConfigs)); // Save the updated mapping configurations back to localStorage - return true; // Return true to indicate the operation was successful + } // If there is no configuration for the given key, create an empty object for it + mappingConfigs[key].custom = config.custom; // Assign the custom configuration to the mapping configuration for the given key + localStorage.setItem("mappingConfigs", JSON.stringify(mappingConfigs)); // Save the updated mapping configurations back to localStorage + return true; // Return true to indicate the operation was successful } /** @@ -788,23 +824,26 @@ export class GameData { * for the corresponding gamepad or device key. The method then returns `true` to indicate success. */ public loadMappingConfigs(): boolean { - if (!localStorage.hasOwnProperty("mappingConfigs")) {// Check if 'mappingConfigs' exists in localStorage + if (!localStorage.hasOwnProperty("mappingConfigs")) { + // Check if 'mappingConfigs' exists in localStorage return false; - } // If 'mappingConfigs' does not exist, return false + } // If 'mappingConfigs' does not exist, return false - const mappingConfigs = JSON.parse(localStorage.getItem("mappingConfigs")!); // Parse the existing 'mappingConfigs' from localStorage // TODO: is this bang correct? + const mappingConfigs = JSON.parse(localStorage.getItem("mappingConfigs")!); // Parse the existing 'mappingConfigs' from localStorage // TODO: is this bang correct? - for (const key of Object.keys(mappingConfigs)) {// Iterate over the keys of the mapping configurations + for (const key of Object.keys(mappingConfigs)) { + // Iterate over the keys of the mapping configurations globalScene.inputController.injectConfig(key, mappingConfigs[key]); - } // Inject each configuration into the input controller for the corresponding key + } // Inject each configuration into the input controller for the corresponding key - return true; // Return true to indicate the operation was successful + return true; // Return true to indicate the operation was successful } public resetMappingToFactory(): boolean { - if (!localStorage.hasOwnProperty("mappingConfigs")) {// Check if 'mappingConfigs' exists in localStorage + if (!localStorage.hasOwnProperty("mappingConfigs")) { + // Check if 'mappingConfigs' exists in localStorage return false; - } // If 'mappingConfigs' does not exist, return false + } // If 'mappingConfigs' does not exist, return false localStorage.removeItem("mappingConfigs"); globalScene.inputController.resetConfigs(); return true; // TODO: is `true` the correct return value? @@ -823,11 +862,18 @@ export class GameData { * to update the specified setting with the new value. Finally, it saves the updated settings back * to localStorage and returns `true` to indicate success. */ - public saveControlSetting(device: Device, localStoragePropertyName: string, setting: SettingGamepad|SettingKeyboard, settingDefaults, valueIndex: number): boolean { - let settingsControls: object = {}; // Initialize an empty object to hold the gamepad settings + public saveControlSetting( + device: Device, + localStoragePropertyName: string, + setting: SettingGamepad | SettingKeyboard, + settingDefaults, + valueIndex: number, + ): boolean { + let settingsControls: object = {}; // Initialize an empty object to hold the gamepad settings - if (localStorage.hasOwnProperty(localStoragePropertyName)) { // Check if 'settingsControls' exists in localStorage - settingsControls = JSON.parse(localStorage.getItem(localStoragePropertyName)!); // Parse the existing 'settingsControls' from localStorage // TODO: is this bang correct? + if (localStorage.hasOwnProperty(localStoragePropertyName)) { + // Check if 'settingsControls' exists in localStorage + settingsControls = JSON.parse(localStorage.getItem(localStoragePropertyName)!); // Parse the existing 'settingsControls' from localStorage // TODO: is this bang correct? } if (device === Device.GAMEPAD) { @@ -836,15 +882,17 @@ export class GameData { setSettingKeyboard(setting as SettingKeyboard, valueIndex); } - Object.keys(settingDefaults).forEach(s => { // Iterate over the default gamepad settings - if (s === setting) {// If the current setting matches, update its value + Object.keys(settingDefaults).forEach(s => { + // Iterate over the default gamepad settings + if (s === setting) { + // If the current setting matches, update its value settingsControls[s] = valueIndex; } }); - localStorage.setItem(localStoragePropertyName, JSON.stringify(settingsControls)); // Save the updated gamepad settings back to localStorage + localStorage.setItem(localStoragePropertyName, JSON.stringify(settingsControls)); // Save the updated gamepad settings back to localStorage - return true; // Return true to indicate the operation was successful + return true; // Return true to indicate the operation was successful } /** @@ -870,7 +918,9 @@ export class GameData { } private loadGamepadSettings(): boolean { - Object.values(SettingGamepad).map(setting => setting as SettingGamepad).forEach(setting => setSettingGamepad(setting, settingGamepadDefaults[setting])); + Object.values(SettingGamepad) + .map(setting => setting as SettingGamepad) + .forEach(setting => setSettingGamepad(setting, settingGamepadDefaults[setting])); if (!localStorage.hasOwnProperty("settingsGamepad")) { return false; @@ -891,14 +941,16 @@ export class GameData { tutorials = JSON.parse(localStorage.getItem(key)!); // TODO: is this bang correct? } - Object.keys(Tutorial).map(t => t as Tutorial).forEach(t => { - const key = Tutorial[t]; - if (key === tutorial) { - tutorials[key] = flag; - } else { - tutorials[key] ??= false; - } - }); + Object.keys(Tutorial) + .map(t => t as Tutorial) + .forEach(t => { + const key = Tutorial[t]; + if (key === tutorial) { + tutorials[key] = flag; + } else { + tutorials[key] ??= false; + } + }); localStorage.setItem(key, JSON.stringify(tutorials)); @@ -908,7 +960,9 @@ export class GameData { public getTutorialFlags(): TutorialFlags { const key = getDataTypeKey(GameDataType.TUTORIALS); const ret: TutorialFlags = {}; - Object.values(Tutorial).map(tutorial => tutorial as Tutorial).forEach(tutorial => ret[Tutorial[tutorial]] = false); + Object.values(Tutorial) + .map(tutorial => tutorial as Tutorial) + .forEach(tutorial => (ret[Tutorial[tutorial]] = false)); if (!localStorage.hasOwnProperty(key)) { return ret; @@ -966,13 +1020,16 @@ export class GameData { score: globalScene.score, waveIndex: globalScene.currentBattle.waveIndex, battleType: globalScene.currentBattle.battleType, - trainer: globalScene.currentBattle.battleType === BattleType.TRAINER ? new TrainerData(globalScene.currentBattle.trainer) : null, + trainer: + globalScene.currentBattle.battleType === BattleType.TRAINER + ? new TrainerData(globalScene.currentBattle.trainer) + : null, gameVersion: globalScene.game.config.gameVersion, timestamp: new Date().getTime(), challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)), mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData, - playerFaints: globalScene.arena.playerFaints + playerFaints: globalScene.arena.playerFaints, } as SessionSaveData; } @@ -992,17 +1049,19 @@ export class GameData { }; if (!bypassLogin && !localStorage.getItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`)) { - pokerogueApi.savedata.session.get({ slot: slotId, clientSessionId }) - .then(async response => { - if (!response || response?.length === 0 || response?.[0] !== "{") { - console.error(response); - return resolve(null); - } + pokerogueApi.savedata.session.get({ slot: slotId, clientSessionId }).then(async response => { + if (!response || response?.length === 0 || response?.[0] !== "{") { + console.error(response); + return resolve(null); + } - localStorage.setItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`, encrypt(response, bypassLogin)); + localStorage.setItem( + `sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`, + encrypt(response, bypassLogin), + ); - await handleSessionData(response); - }); + await handleSessionData(response); + }); } else { const sessionData = localStorage.getItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`); if (sessionData) { @@ -1068,14 +1127,27 @@ export class GameData { const battleType = sessionData.battleType || 0; const trainerConfig = sessionData.trainer ? trainerConfigs[sessionData.trainer.trainerType] : null; - const mysteryEncounterType = sessionData.mysteryEncounterType !== -1 ? sessionData.mysteryEncounterType : undefined; - const battle = globalScene.newBattle(sessionData.waveIndex, battleType, sessionData.trainer, battleType === BattleType.TRAINER ? trainerConfig?.doubleOnly || sessionData.trainer?.variant === TrainerVariant.DOUBLE : sessionData.enemyParty.length > 1, mysteryEncounterType)!; // TODO: is this bang correct? + const mysteryEncounterType = + sessionData.mysteryEncounterType !== -1 ? sessionData.mysteryEncounterType : undefined; + const battle = globalScene.newBattle( + sessionData.waveIndex, + battleType, + sessionData.trainer, + battleType === BattleType.TRAINER + ? trainerConfig?.doubleOnly || sessionData.trainer?.variant === TrainerVariant.DOUBLE + : sessionData.enemyParty.length > 1, + mysteryEncounterType, + )!; // TODO: is this bang correct? battle.enemyLevels = sessionData.enemyParty.map(p => p.level); globalScene.arena.init(); sessionData.enemyParty.forEach((enemyData, e) => { - const enemyPokemon = enemyData.toPokemon(battleType, e, sessionData.trainer?.variant === TrainerVariant.DOUBLE) as EnemyPokemon; + const enemyPokemon = enemyData.toPokemon( + battleType, + e, + sessionData.trainer?.variant === TrainerVariant.DOUBLE, + ) as EnemyPokemon; battle.enemyParty[e] = enemyPokemon; if (battleType === BattleType.WILD) { battle.seenEnemyPartyMemberIds.add(enemyPokemon.id); @@ -1085,10 +1157,22 @@ export class GameData { }); globalScene.arena.weather = sessionData.arena.weather; - globalScene.arena.eventTarget.dispatchEvent(new WeatherChangedEvent(WeatherType.NONE, globalScene.arena.weather?.weatherType!, globalScene.arena.weather?.turnsLeft!)); // TODO: is this bang correct? + globalScene.arena.eventTarget.dispatchEvent( + new WeatherChangedEvent( + WeatherType.NONE, + globalScene.arena.weather?.weatherType!, + globalScene.arena.weather?.turnsLeft!, + ), + ); // TODO: is this bang correct? globalScene.arena.terrain = sessionData.arena.terrain; - globalScene.arena.eventTarget.dispatchEvent(new TerrainChangedEvent(TerrainType.NONE, globalScene.arena.terrain?.terrainType!, globalScene.arena.terrain?.turnsLeft!)); // TODO: is this bang correct? + globalScene.arena.eventTarget.dispatchEvent( + new TerrainChangedEvent( + TerrainType.NONE, + globalScene.arena.terrain?.terrainType!, + globalScene.arena.terrain?.turnsLeft!, + ), + ); // TODO: is this bang correct? globalScene.arena.playerTerasUsed = sessionData.arena.playerTerasUsed; @@ -1097,7 +1181,9 @@ export class GameData { for (const tag of globalScene.arena.tags) { if (tag instanceof ArenaTrapTag) { const { tagType, side, turnCount, layers, maxLayers } = tag as ArenaTrapTag; - globalScene.arena.eventTarget.dispatchEvent(new TagAddedEvent(tagType, side, turnCount, layers, maxLayers)); + globalScene.arena.eventTarget.dispatchEvent( + new TagAddedEvent(tagType, side, turnCount, layers, maxLayers), + ); } else { globalScene.arena.eventTarget.dispatchEvent(new TagAddedEvent(tag.tagType, tag.side, tag.turnCount)); } @@ -1173,7 +1259,6 @@ export class GameData { localStorage.removeItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`); resolve(true); - } }); }); @@ -1194,53 +1279,52 @@ export class GameData { daily = JSON.parse(atob(localStorage.getItem("daily")!)); // TODO: is this bang correct? if (daily.includes(seed)) { return resolve(false); - } else { - daily.push(seed); - localStorage.setItem("daily", btoa(JSON.stringify(daily))); - return resolve(true); } - } else { daily.push(seed); localStorage.setItem("daily", btoa(JSON.stringify(daily))); return resolve(true); } - } else { + daily.push(seed); + localStorage.setItem("daily", btoa(JSON.stringify(daily))); return resolve(true); } + return resolve(true); }); } - /** * Attempt to clear session data after the end of a run * After session data is removed, attempt to update user info so the menu updates * To delete an unfinished run instead, use {@linkcode deleteSession} */ async tryClearSession(slotId: number): Promise<[success: boolean, newClear: boolean]> { - let result: [boolean, boolean] = [ false, false ]; + let result: [boolean, boolean] = [false, false]; if (bypassLogin) { localStorage.removeItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`); - result = [ true, true ]; + result = [true, true]; } else { const sessionData = this.getSessionSaveData(); const { trainerId } = this; - const jsonResponse = await pokerogueApi.savedata.session.clear({ slot: slotId, trainerId, clientSessionId }, sessionData); + const jsonResponse = await pokerogueApi.savedata.session.clear( + { slot: slotId, trainerId, clientSessionId }, + sessionData, + ); if (!jsonResponse?.error) { - result = [ true, jsonResponse?.success ?? false ]; + result = [true, jsonResponse?.success ?? false]; if (loggedInUser) { loggedInUser!.lastSessionSlot = -1; } localStorage.removeItem(`sessionData${slotId ? slotId : ""}_${loggedInUser?.username}`); } else { - if (jsonResponse && jsonResponse.error?.startsWith("session out of date")) { + if (jsonResponse?.error?.startsWith("session out of date")) { globalScene.clearPhaseQueue(); globalScene.unshiftPhase(new ReloadSessionPhase()); } console.error(jsonResponse); - result = [ false, false ]; + result = [false, false]; } } @@ -1273,10 +1357,14 @@ export class GameData { v = []; } for (const md of v) { - if (md?.className === "ExpBalanceModifier") { // Temporarily limit EXP Balance until it gets reworked + if (md?.className === "ExpBalanceModifier") { + // Temporarily limit EXP Balance until it gets reworked md.stackCount = Math.min(md.stackCount, 4); } - if (md instanceof Modifier.EnemyAttackStatusEffectChanceModifier && md.effect === StatusEffect.FREEZE || md.effect === StatusEffect.SLEEP) { + if ( + (md instanceof Modifier.EnemyAttackStatusEffectChanceModifier && md.effect === StatusEffect.FREEZE) || + md.effect === StatusEffect.SLEEP + ) { continue; } ret.push(new PersistentModifierData(md, player)); @@ -1315,7 +1403,7 @@ export class GameData { return sessionData; } - saveAll(skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false, useCachedSystem: boolean = false): Promise { + saveAll(skipVerification = false, sync = false, useCachedSession = false, useCachedSystem = false): Promise { return new Promise(resolve => { Utils.executeIf(!skipVerification, updateUserInfo).then(success => { if (success !== null && !success) { @@ -1324,43 +1412,62 @@ export class GameData { if (sync) { globalScene.ui.savingIcon.show(); } - const sessionData = useCachedSession ? - this.parseSessionData(decrypt(localStorage.getItem(`sessionData${globalScene.sessionSlotId ? globalScene.sessionSlotId : ""}_${loggedInUser?.username}`)!, bypassLogin)) // TODO: is this bang correct? + const sessionData = useCachedSession + ? this.parseSessionData( + decrypt( + localStorage.getItem( + `sessionData${globalScene.sessionSlotId ? globalScene.sessionSlotId : ""}_${loggedInUser?.username}`, + )!, + bypassLogin, + ), + ) // TODO: is this bang correct? : this.getSessionSaveData(); const maxIntAttrValue = 0x80000000; - const systemData = useCachedSystem ? this.parseSystemData(decrypt(localStorage.getItem(`data_${loggedInUser?.username}`)!, bypassLogin)) : this.getSystemSaveData(); // TODO: is this bang correct? + 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, sessionSlotId: globalScene.sessionSlotId, - clientSessionId: clientSessionId + clientSessionId: clientSessionId, }; - localStorage.setItem(`data_${loggedInUser?.username}`, encrypt(JSON.stringify(systemData, (k: any, v: any) => typeof v === "bigint" ? v <= maxIntAttrValue ? Number(v) : v.toString() : v), bypassLogin)); + localStorage.setItem( + `data_${loggedInUser?.username}`, + encrypt( + JSON.stringify(systemData, (_k: any, v: any) => + typeof v === "bigint" ? (v <= maxIntAttrValue ? Number(v) : v.toString()) : v, + ), + bypassLogin, + ), + ); - localStorage.setItem(`sessionData${globalScene.sessionSlotId ? globalScene.sessionSlotId : ""}_${loggedInUser?.username}`, encrypt(JSON.stringify(sessionData), bypassLogin)); + localStorage.setItem( + `sessionData${globalScene.sessionSlotId ? globalScene.sessionSlotId : ""}_${loggedInUser?.username}`, + encrypt(JSON.stringify(sessionData), bypassLogin), + ); console.debug("Session data saved"); if (!bypassLogin && sync) { - pokerogueApi.savedata.updateAll(request) - .then(error => { - if (sync) { - globalScene.lastSavePlayTime = 0; - globalScene.ui.savingIcon.hide(); + pokerogueApi.savedata.updateAll(request).then(error => { + if (sync) { + globalScene.lastSavePlayTime = 0; + globalScene.ui.savingIcon.hide(); + } + if (error) { + if (error.startsWith("session out of date")) { + globalScene.clearPhaseQueue(); + globalScene.unshiftPhase(new ReloadSessionPhase()); } - if (error) { - if (error.startsWith("session out of date")) { - globalScene.clearPhaseQueue(); - globalScene.unshiftPhase(new ReloadSessionPhase()); - } - console.error(error); - return resolve(false); - } - resolve(true); - }); + console.error(error); + return resolve(false); + } + resolve(true); + }); } else { this.verify().then(success => { globalScene.ui.savingIcon.hide(); @@ -1371,7 +1478,7 @@ export class GameData { }); } - public tryExportData(dataType: GameDataType, slotId: number = 0): Promise { + public tryExportData(dataType: GameDataType, slotId = 0): Promise { return new Promise(resolve => { const dataKey: string = `${getDataTypeKey(dataType, slotId)}_${loggedInUser?.username}`; const handleData = (dataStr: string) => { @@ -1381,7 +1488,9 @@ export class GameData { break; } const encryptedData = AES.encrypt(dataStr, saveKey); - const blob = new Blob([ encryptedData.toString() ], { type: "text/json" }); + const blob = new Blob([encryptedData.toString()], { + type: "text/json", + }); const link = document.createElement("a"); link.href = window.URL.createObjectURL(blob); link.download = `${dataKey}.prsv`; @@ -1394,7 +1503,10 @@ export class GameData { if (dataType === GameDataType.SYSTEM) { promise = pokerogueApi.savedata.system.get({ clientSessionId }); } else if (dataType === GameDataType.SESSION) { - promise = pokerogueApi.savedata.session.get({ slot: slotId, clientSessionId }); + promise = pokerogueApi.savedata.session.get({ + slot: slotId, + clientSessionId, + }); } promise.then(response => { @@ -1417,7 +1529,7 @@ export class GameData { }); } - public importData(dataType: GameDataType, slotId: number = 0): void { + public importData(dataType: GameDataType, slotId = 0): void { const dataKey = `${getDataTypeKey(dataType, slotId)}_${loggedInUser?.username}`; let saveFile: any = document.getElementById("saveFile"); @@ -1430,91 +1542,120 @@ export class GameData { saveFile.type = "file"; saveFile.accept = ".prsv"; saveFile.style.display = "none"; - saveFile.addEventListener("change", - e => { - const reader = new FileReader(); + saveFile.addEventListener("change", e => { + const reader = new FileReader(); - reader.onload = (_ => { - return e => { - let dataName: string; - let dataStr = AES.decrypt(e.target?.result?.toString()!, saveKey).toString(enc.Utf8); // TODO: is this bang correct? - let valid = false; - try { - dataName = GameDataType[dataType].toLowerCase(); - switch (dataType) { - case GameDataType.SYSTEM: - dataStr = this.convertSystemDataStr(dataStr); - const systemData = this.parseSystemData(dataStr); - valid = !!systemData.dexData && !!systemData.timestamp; - break; - case GameDataType.SESSION: - const sessionData = this.parseSessionData(dataStr); - valid = !!sessionData.party && !!sessionData.enemyParty && !!sessionData.timestamp; - break; - case GameDataType.RUN_HISTORY: - const data = JSON.parse(dataStr); - const keys = Object.keys(data); - dataName = i18next.t("menuUiHandler:RUN_HISTORY").toLowerCase(); - keys.forEach((key) => { - const entryKeys = Object.keys(data[key]); - valid = [ "isFavorite", "isVictory", "entry" ].every(v => entryKeys.includes(v)) && entryKeys.length === 3; - }); - break; - case GameDataType.SETTINGS: - case GameDataType.TUTORIALS: - valid = true; - break; - } - } catch (ex) { - console.error(ex); + reader.onload = (_ => { + return e => { + let dataName: string; + let dataStr = AES.decrypt(e.target?.result?.toString()!, saveKey).toString(enc.Utf8); // TODO: is this bang correct? + let valid = false; + try { + dataName = GameDataType[dataType].toLowerCase(); + switch (dataType) { + case GameDataType.SYSTEM: + dataStr = this.convertSystemDataStr(dataStr); + const systemData = this.parseSystemData(dataStr); + valid = !!systemData.dexData && !!systemData.timestamp; + break; + case GameDataType.SESSION: + const sessionData = this.parseSessionData(dataStr); + valid = !!sessionData.party && !!sessionData.enemyParty && !!sessionData.timestamp; + break; + case GameDataType.RUN_HISTORY: + const data = JSON.parse(dataStr); + const keys = Object.keys(data); + dataName = i18next.t("menuUiHandler:RUN_HISTORY").toLowerCase(); + keys.forEach(key => { + const entryKeys = Object.keys(data[key]); + valid = + ["isFavorite", "isVictory", "entry"].every(v => entryKeys.includes(v)) && entryKeys.length === 3; + }); + break; + case GameDataType.SETTINGS: + case GameDataType.TUTORIALS: + valid = true; + break; } + } catch (ex) { + console.error(ex); + } - const displayError = (error: string) => globalScene.ui.showText(error, null, () => globalScene.ui.showText("", 0), Utils.fixedInt(1500)); - dataName = dataName!; // tell TS compiler that dataName is defined! + const displayError = (error: string) => + globalScene.ui.showText(error, null, () => globalScene.ui.showText("", 0), Utils.fixedInt(1500)); + dataName = dataName!; // tell TS compiler that dataName is defined! - if (!valid) { - return globalScene.ui.showText(`Your ${dataName} data could not be loaded. It may be corrupted.`, null, () => globalScene.ui.showText("", 0), Utils.fixedInt(1500)); - } + if (!valid) { + return globalScene.ui.showText( + `Your ${dataName} data could not be loaded. It may be corrupted.`, + null, + () => globalScene.ui.showText("", 0), + Utils.fixedInt(1500), + ); + } - globalScene.ui.showText(`Your ${dataName} data will be overridden and the page will reload. Proceed?`, null, () => { - globalScene.ui.setOverlayMode(Mode.CONFIRM, () => { - localStorage.setItem(dataKey, encrypt(dataStr, bypassLogin)); + globalScene.ui.showText( + `Your ${dataName} data will be overridden and the page will reload. Proceed?`, + null, + () => { + globalScene.ui.setOverlayMode( + Mode.CONFIRM, + () => { + localStorage.setItem(dataKey, encrypt(dataStr, bypassLogin)); - if (!bypassLogin && dataType < GameDataType.SETTINGS) { - updateUserInfo().then(success => { - if (!success[0]) { - return displayError(`Could not contact the server. Your ${dataName} data could not be imported.`); - } - const { trainerId, secretId } = this; - let updatePromise: Promise; - if (dataType === GameDataType.SESSION) { - updatePromise = pokerogueApi.savedata.session.update({ slot: slotId, trainerId, secretId, clientSessionId }, dataStr); - } else { - updatePromise = pokerogueApi.savedata.system.update({ trainerId, secretId, clientSessionId }, dataStr); - } - updatePromise - .then(error => { + if (!bypassLogin && dataType < GameDataType.SETTINGS) { + updateUserInfo().then(success => { + if (!success[0]) { + return displayError( + `Could not contact the server. Your ${dataName} data could not be imported.`, + ); + } + const { trainerId, secretId } = this; + let updatePromise: Promise; + if (dataType === GameDataType.SESSION) { + updatePromise = pokerogueApi.savedata.session.update( + { + slot: slotId, + trainerId, + secretId, + clientSessionId, + }, + dataStr, + ); + } else { + updatePromise = pokerogueApi.savedata.system.update( + { trainerId, secretId, clientSessionId }, + dataStr, + ); + } + updatePromise.then(error => { if (error) { console.error(error); - return displayError(`An error occurred while updating ${dataName} data. Please contact the administrator.`); + return displayError( + `An error occurred while updating ${dataName} data. Please contact the administrator.`, + ); } - window.location = window.location; + window.location.reload(); }); - }); - } else { - window.location = window.location; - } - }, () => { - globalScene.ui.revertMode(); - globalScene.ui.showText("", 0); - }, false, -98); - }); - }; - })((e.target as any).files[0]); + }); + } else { + window.location.reload(); + } + }, + () => { + globalScene.ui.revertMode(); + globalScene.ui.showText("", 0); + }, + false, + -98, + ); + }, + ); + }; + })((e.target as any).files[0]); - reader.readAsText((e.target as any).files[0]); - } - ); + reader.readAsText((e.target as any).files[0]); + }); saveFile.click(); } @@ -1523,20 +1664,31 @@ export class GameData { for (const species of allSpecies) { data[species.speciesId] = { - seenAttr: 0n, caughtAttr: 0n, natureAttr: 0, seenCount: 0, caughtCount: 0, hatchedCount: 0, ivs: [ 0, 0, 0, 0, 0, 0 ] + seenAttr: 0n, + caughtAttr: 0n, + natureAttr: 0, + seenCount: 0, + caughtCount: 0, + hatchedCount: 0, + ivs: [0, 0, 0, 0, 0, 0], }; } - const defaultStarterAttr = DexAttr.NON_SHINY | DexAttr.MALE | DexAttr.FEMALE | DexAttr.DEFAULT_VARIANT | DexAttr.DEFAULT_FORM; + const defaultStarterAttr = + DexAttr.NON_SHINY | DexAttr.MALE | DexAttr.FEMALE | DexAttr.DEFAULT_VARIANT | DexAttr.DEFAULT_FORM; const defaultStarterNatures: Nature[] = []; - globalScene.executeWithSeedOffset(() => { - const neutralNatures = [ Nature.HARDY, Nature.DOCILE, Nature.SERIOUS, Nature.BASHFUL, Nature.QUIRKY ]; - for (let s = 0; s < defaultStarterSpecies.length; s++) { - defaultStarterNatures.push(Utils.randSeedItem(neutralNatures)); - } - }, 0, "default"); + globalScene.executeWithSeedOffset( + () => { + const neutralNatures = [Nature.HARDY, Nature.DOCILE, Nature.SERIOUS, Nature.BASHFUL, Nature.QUIRKY]; + for (let s = 0; s < defaultStarterSpecies.length; s++) { + defaultStarterNatures.push(Utils.randSeedItem(neutralNatures)); + } + }, + 0, + "default", + ); for (let ds = 0; ds < defaultStarterSpecies.length; ds++) { const entry = data[defaultStarterSpecies[ds]] as DexEntry; @@ -1555,7 +1707,7 @@ export class GameData { private initStarterData(): void { const starterData: StarterData = {}; - const starterSpeciesIds = Object.keys(speciesStarterCosts).map(k => parseInt(k) as Species); + const starterSpeciesIds = Object.keys(speciesStarterCosts).map(k => Number.parseInt(k) as Species); for (const speciesId of starterSpeciesIds) { starterData[speciesId] = { @@ -1566,16 +1718,19 @@ export class GameData { abilityAttr: defaultStarterSpecies.includes(speciesId) ? AbilityAttr.ABILITY_1 : 0, passiveAttr: 0, valueReduction: 0, - classicWinCount: 0 + classicWinCount: 0, }; } this.starterData = starterData; } - setPokemonSeen(pokemon: Pokemon, incrementCount: boolean = true, trainer: boolean = false): void { + setPokemonSeen(pokemon: Pokemon, incrementCount = true, trainer = false): void { // Some Mystery Encounters block updates to these stats - if (globalScene.currentBattle?.isBattleMysteryEncounter() && globalScene.currentBattle.mysteryEncounter?.preventGameStatsUpdates) { + if ( + globalScene.currentBattle?.isBattleMysteryEncounter() && + globalScene.currentBattle.mysteryEncounter?.preventGameStatsUpdates + ) { return; } const dexEntry = this.dexData[pokemon.species.speciesId]; @@ -1604,15 +1759,14 @@ export class GameData { * @param showMessage * @returns `true` if Pokemon catch unlocked a new starter, `false` if Pokemon catch did not unlock a starter */ - setPokemonCaught(pokemon: Pokemon, incrementCount: boolean = true, fromEgg: boolean = false, showMessage: boolean = true): Promise { + setPokemonCaught(pokemon: Pokemon, incrementCount = true, fromEgg = false, showMessage = true): Promise { // If incrementCount === false (not a catch scenario), only update the pokemon's dex data if the Pokemon has already been marked as caught in dex // Prevents form changes, nature changes, etc. from unintentionally updating the dex data of a "rental" pokemon const speciesRootForm = pokemon.species.getRootSpeciesId(); if (!incrementCount && !globalScene.gameData.dexData[speciesRootForm].caughtAttr) { return Promise.resolve(false); - } else { - return this.setPokemonSpeciesCaught(pokemon, pokemon.species, incrementCount, fromEgg, showMessage); } + return this.setPokemonSpeciesCaught(pokemon, pokemon.species, incrementCount, fromEgg, showMessage); } /** @@ -1624,7 +1778,13 @@ export class GameData { * @param showMessage * @returns `true` if Pokemon catch unlocked a new starter, `false` if Pokemon catch did not unlock a starter */ - setPokemonSpeciesCaught(pokemon: Pokemon, species: PokemonSpecies, incrementCount: boolean = true, fromEgg: boolean = false, showMessage: boolean = true): Promise { + setPokemonSpeciesCaught( + pokemon: Pokemon, + species: PokemonSpecies, + incrementCount = true, + fromEgg = false, + showMessage = true, + ): Promise { return new Promise(resolve => { const dexEntry = this.dexData[species.speciesId]; const caughtAttr = dexEntry.caughtAttr; @@ -1652,8 +1812,10 @@ export class GameData { dexEntry.caughtAttr |= globalScene.gameData.getFormAttr(3); } } else { - const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) ? pokemonFormChanges[species.speciesId] : []; - const toCurrentFormChanges = allFormChanges.filter(f => (f.formKey === formKey)); + const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) + ? pokemonFormChanges[species.speciesId] + : []; + const toCurrentFormChanges = allFormChanges.filter(f => f.formKey === formKey); if (toCurrentFormChanges.length > 0) { // Needs to do this or Castform can unlock the wrong form, etc. dexEntry.caughtAttr |= globalScene.gameData.getFormAttr(0); @@ -1663,9 +1825,10 @@ export class GameData { // Unlock ability if (speciesStarterCosts.hasOwnProperty(species.speciesId)) { - this.starterData[species.speciesId].abilityAttr |= pokemon.abilityIndex !== 1 || pokemon.species.ability2 - ? 1 << pokemon.abilityIndex - : AbilityAttr.ABILITY_HIDDEN; + this.starterData[species.speciesId].abilityAttr |= + pokemon.abilityIndex !== 1 || pokemon.species.ability2 + ? 1 << pokemon.abilityIndex + : AbilityAttr.ABILITY_HIDDEN; } // Unlock nature @@ -1705,14 +1868,23 @@ export class GameData { } if (!hasPrevolution && (!globalScene.gameMode.isDaily || hasNewAttr || fromEgg)) { - this.addStarterCandy(species, (1 * (pokemon.isShiny() ? 5 * (1 << (pokemon.variant ?? 0)) : 1)) * (fromEgg || pokemon.isBoss() ? 2 : 1)); + this.addStarterCandy( + species, + 1 * (pokemon.isShiny() ? 5 * (1 << (pokemon.variant ?? 0)) : 1) * (fromEgg || pokemon.isBoss() ? 2 : 1), + ); } } const checkPrevolution = (newStarter: boolean) => { if (hasPrevolution) { const prevolutionSpecies = pokemonPrevolutions[species.speciesId]; - this.setPokemonSpeciesCaught(pokemon, getPokemonSpecies(prevolutionSpecies), incrementCount, fromEgg, showMessage).then(result => resolve(result)); + this.setPokemonSpeciesCaught( + pokemon, + getPokemonSpecies(prevolutionSpecies), + incrementCount, + fromEgg, + showMessage, + ).then(result => resolve(result)); } else { resolve(newStarter); } @@ -1724,14 +1896,20 @@ export class GameData { return; } globalScene.playSound("level_up_fanfare"); - globalScene.ui.showText(i18next.t("battle:addedAsAStarter", { pokemonName: species.name }), null, () => checkPrevolution(true), null, true); + globalScene.ui.showText( + i18next.t("battle:addedAsAStarter", { pokemonName: species.name }), + null, + () => checkPrevolution(true), + null, + true, + ); } else { checkPrevolution(false); } }); } - incrementRibbonCount(species: PokemonSpecies, forStarter: boolean = false): number { + incrementRibbonCount(species: PokemonSpecies, forStarter = false): number { const speciesIdToIncrement: Species = species.getRootSpeciesId(forStarter); if (!this.starterData[speciesIdToIncrement].classicWinCount) { @@ -1785,7 +1963,12 @@ export class GameData { * @param showMessage Default true. If true, will display message for unlocked egg move * @param prependSpeciesToMessage Default false. If true, will change message from "X Egg Move Unlocked!" to "Bulbasaur X Egg Move Unlocked!" */ - setEggMoveUnlocked(species: PokemonSpecies, eggMoveIndex: number, showMessage: boolean = true, prependSpeciesToMessage: boolean = false): Promise { + setEggMoveUnlocked( + species: PokemonSpecies, + eggMoveIndex: number, + showMessage = true, + prependSpeciesToMessage = false, + ): Promise { return new Promise(resolve => { const speciesId = species.speciesId; if (!speciesEggMoves.hasOwnProperty(speciesId) || !speciesEggMoves[speciesId][eggMoveIndex]) { @@ -1812,7 +1995,10 @@ export class GameData { globalScene.playSound("level_up_fanfare"); const moveName = allMoves[speciesEggMoves[speciesId][eggMoveIndex]].name; let message = prependSpeciesToMessage ? species.getName() + " " : ""; - message += eggMoveIndex === 3 ? i18next.t("egg:rareEggMoveUnlock", { moveName: moveName }) : i18next.t("egg:eggMoveUnlock", { moveName: moveName }); + message += + eggMoveIndex === 3 + ? i18next.t("egg:rareEggMoveUnlock", { moveName: moveName }) + : i18next.t("egg:eggMoveUnlock", { moveName: moveName }); globalScene.ui.showText(message, null, () => resolve(true), null, true); }); @@ -1883,7 +2069,7 @@ export class GameData { return starterCount; } - getSpeciesDefaultDexAttr(species: PokemonSpecies, _forSeen: boolean = false, optimistic: boolean = false): bigint { + getSpeciesDefaultDexAttr(species: PokemonSpecies, _forSeen = false, optimistic = false): bigint { let ret = 0n; const dexEntry = this.dexData[species.speciesId]; const attr = dexEntry.caughtAttr; @@ -1904,7 +2090,7 @@ export class GameData { } } else { // Default to non shiny. Fallback to shiny if it's the only thing that's unlocked - ret |= (attr & DexAttr.NON_SHINY || !(attr & DexAttr.SHINY)) ? DexAttr.NON_SHINY : DexAttr.SHINY; + ret |= attr & DexAttr.NON_SHINY || !(attr & DexAttr.SHINY) ? DexAttr.NON_SHINY : DexAttr.SHINY; if (attr & DexAttr.DEFAULT_VARIANT) { ret |= DexAttr.DEFAULT_VARIANT; @@ -1921,7 +2107,7 @@ export class GameData { return ret; } - getSpeciesDexAttrProps(species: PokemonSpecies, dexAttr: bigint): DexAttrProps { + getSpeciesDexAttrProps(_species: PokemonSpecies, dexAttr: bigint): DexAttrProps { const shiny = !(dexAttr & DexAttr.NON_SHINY); const female = !(dexAttr & DexAttr.MALE); let variant: Variant = 0; @@ -1938,7 +2124,7 @@ export class GameData { shiny, female, variant, - formIndex + formIndex, }; } @@ -1958,14 +2144,14 @@ export class GameData { } getSpeciesDefaultNatureAttr(species: PokemonSpecies): number { - return 1 << (this.getSpeciesDefaultNature(species)); + return 1 << this.getSpeciesDefaultNature(species); } getDexAttrLuck(dexAttr: bigint): number { - return dexAttr & DexAttr.SHINY ? dexAttr & DexAttr.VARIANT_3 ? 3 : dexAttr & DexAttr.VARIANT_2 ? 2 : 1 : 0; + return dexAttr & DexAttr.SHINY ? (dexAttr & DexAttr.VARIANT_3 ? 3 : dexAttr & DexAttr.VARIANT_2 ? 2 : 1) : 0; } - getNaturesForAttr(natureAttr: number = 0): Nature[] { + getNaturesForAttr(natureAttr = 0): Nature[] { const ret: Nature[] = []; for (let n = 0; n < 25; n++) { if (natureAttr & (1 << (n + 1))) { @@ -2020,20 +2206,21 @@ export class GameData { entry.hatchedCount = 0; } if (!entry.hasOwnProperty("natureAttr") || (entry.caughtAttr && !entry.natureAttr)) { - entry.natureAttr = this.defaultDexData?.[k].natureAttr || (1 << Utils.randInt(25, 1)); + entry.natureAttr = this.defaultDexData?.[k].natureAttr || 1 << Utils.randInt(25, 1); } } } migrateStarterAbilities(systemData: SystemSaveData, initialStarterData?: StarterData): void { - const starterIds = Object.keys(this.starterData).map(s => parseInt(s) as Species); + const starterIds = Object.keys(this.starterData).map(s => Number.parseInt(s) as Species); const starterData = initialStarterData || systemData.starterData; const dexData = systemData.dexData; for (const s of starterIds) { const dexAttr = dexData[s].caughtAttr; - starterData[s].abilityAttr = (dexAttr & DexAttr.DEFAULT_VARIANT ? AbilityAttr.ABILITY_1 : 0) - | (dexAttr & DexAttr.VARIANT_2 ? AbilityAttr.ABILITY_2 : 0) - | (dexAttr & DexAttr.VARIANT_3 ? AbilityAttr.ABILITY_HIDDEN : 0); + starterData[s].abilityAttr = + (dexAttr & DexAttr.DEFAULT_VARIANT ? AbilityAttr.ABILITY_1 : 0) | + (dexAttr & DexAttr.VARIANT_2 ? AbilityAttr.ABILITY_2 : 0) | + (dexAttr & DexAttr.VARIANT_3 ? AbilityAttr.ABILITY_HIDDEN : 0); if (dexAttr) { if (!(dexAttr & DexAttr.DEFAULT_VARIANT)) { dexData[s].caughtAttr ^= DexAttr.DEFAULT_VARIANT; diff --git a/src/system/game-speed.ts b/src/system/game-speed.ts index 4b34a04b5f8..e2156c03728 100644 --- a/src/system/game-speed.ts +++ b/src/system/game-speed.ts @@ -15,7 +15,7 @@ export function initGameSpeed() { if (value instanceof Utils.FixedInt) { return (value as Utils.FixedInt).value; } - return thisArg.gameSpeed === 1 ? value : Math.ceil(value /= thisArg.gameSpeed); + return thisArg.gameSpeed === 1 ? value : Math.ceil((value /= thisArg.gameSpeed)); }; const originalAddEvent = this.time.addEvent; @@ -23,15 +23,21 @@ export function initGameSpeed() { if (!(config instanceof Phaser.Time.TimerEvent) && config.delay) { config.delay = transformValue(config.delay); } - return originalAddEvent.apply(this, [ config ]); + return originalAddEvent.apply(this, [config]); }; const originalTweensAdd = this.tweens.add; - this.tweens.add = function (config: Phaser.Types.Tweens.TweenBuilderConfig | Phaser.Types.Tweens.TweenChainBuilderConfig | Phaser.Tweens.Tween | Phaser.Tweens.TweenChain) { + this.tweens.add = function ( + config: + | Phaser.Types.Tweens.TweenBuilderConfig + | Phaser.Types.Tweens.TweenChainBuilderConfig + | Phaser.Tweens.Tween + | Phaser.Tweens.TweenChain, + ) { if (config.loopDelay) { config.loopDelay = transformValue(config.loopDelay as number); } - if (!(config instanceof Phaser.Tweens.TweenChain) ) { + if (!(config instanceof Phaser.Tweens.TweenChain)) { if (config.duration) { config.duration = transformValue(config.duration); } @@ -48,12 +54,12 @@ export function initGameSpeed() { } } } - return originalTweensAdd.apply(this, [ config ]); + return originalTweensAdd.apply(this, [config]); }; const originalTweensChain = this.tweens.chain; this.tweens.chain = function (config: Phaser.Types.Tweens.TweenChainBuilderConfig): Phaser.Tweens.TweenChain { if (config.tweens) { - config.tweens.forEach(t => { + for (const t of config.tweens) { if (t.duration) { t.duration = transformValue(t.duration); } @@ -69,9 +75,9 @@ export function initGameSpeed() { if (t.hold) { t.hold = transformValue(t.hold); } - }); + } } - return originalTweensChain.apply(this, [ config ]); + return originalTweensChain.apply(this, [config]); }; const originalAddCounter = this.tweens.addCounter; this.tweens.addCounter = function (config: Phaser.Types.Tweens.NumberTweenBuilderConfig) { @@ -90,23 +96,19 @@ export function initGameSpeed() { if (config.hold) { config.hold = transformValue(config.hold); } - return originalAddCounter.apply(this, [ config ]); + return originalAddCounter.apply(this, [config]); }; const originalFadeOut = SoundFade.fadeOut; - SoundFade.fadeOut = (( - scene: Phaser.Scene, - sound: Phaser.Sound.BaseSound, - duration: number, - destroy?: boolean - ) => originalFadeOut(globalScene, sound, transformValue(duration), destroy)) as FadeOut; + SoundFade.fadeOut = ((_scene: Phaser.Scene, sound: Phaser.Sound.BaseSound, duration: number, destroy?: boolean) => + originalFadeOut(globalScene, sound, transformValue(duration), destroy)) as FadeOut; const originalFadeIn = SoundFade.fadeIn; SoundFade.fadeIn = (( - scene: Phaser.Scene, + _scene: Phaser.Scene, sound: string | Phaser.Sound.BaseSound, duration: number, endVolume?: number, - startVolume?: number + startVolume?: number, ) => originalFadeIn(globalScene, sound, transformValue(duration), endVolume, startVolume)) as FadeIn; } diff --git a/src/system/modifier-data.ts b/src/system/modifier-data.ts index 4816115f586..cbda45572ac 100644 --- a/src/system/modifier-data.ts +++ b/src/system/modifier-data.ts @@ -13,7 +13,7 @@ export default class ModifierData { public className: string; constructor(source: PersistentModifier | any, player: boolean) { - const sourceModifier = source instanceof PersistentModifier ? source as PersistentModifier : null; + const sourceModifier = source instanceof PersistentModifier ? (source as PersistentModifier) : null; this.player = player; this.typeId = sourceModifier ? sourceModifier.type.id : source.typeId; if (sourceModifier) { @@ -28,7 +28,7 @@ export default class ModifierData { this.className = sourceModifier ? sourceModifier.constructor.name : source.className; } - toModifier(constructor: any): PersistentModifier | null { + toModifier(_constructor: any): PersistentModifier | null { const typeFunc = getModifierTypeFuncById(this.typeId); if (!typeFunc) { return null; @@ -39,10 +39,16 @@ export default class ModifierData { type.id = this.typeId; if (type instanceof ModifierTypeGenerator) { - type = (type as ModifierTypeGenerator).generateType(this.player ? globalScene.getPlayerParty() : globalScene.getEnemyField(), this.typePregenArgs); + type = (type as ModifierTypeGenerator).generateType( + this.player ? globalScene.getPlayerParty() : globalScene.getEnemyField(), + this.typePregenArgs, + ); } - const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier; + const ret = Reflect.construct( + _constructor, + ([type] as any[]).concat(this.args).concat(this.stackCount), + ) as PersistentModifier; if (ret.stackCount > ret.getMaxStackCount()) { ret.stackCount = ret.getMaxStackCount(); diff --git a/src/system/pokemon-data.ts b/src/system/pokemon-data.ts index 7531d74e404..4e694bc1189 100644 --- a/src/system/pokemon-data.ts +++ b/src/system/pokemon-data.ts @@ -38,9 +38,9 @@ export default class PokemonData { public status: Status | null; public friendship: number; public metLevel: number; - public metBiome: Biome | -1; // -1 for starters + public metBiome: Biome | -1; // -1 for starters public metSpecies: Species; - public metWave: number; // 0 for unknown (previous saves), -1 for starters + public metWave: number; // 0 for unknown (previous saves), -1 for starters public luck: number; public pauseEvolutions: boolean; public pokerus: boolean; @@ -73,7 +73,7 @@ export default class PokemonData { public mysteryEncounterPokemonData: CustomPokemonData | null; public fusionMysteryEncounterPokemonData: CustomPokemonData | null; - constructor(source: Pokemon | any, forHistory: boolean = false) { + constructor(source: Pokemon | any, forHistory = false) { const sourcePokemon = source instanceof Pokemon ? source : null; this.id = source.id; this.player = sourcePokemon ? sourcePokemon.isPlayer() : source.player; @@ -96,13 +96,14 @@ export default class PokemonData { } this.stats = source.stats; this.ivs = source.ivs; - this.nature = source.nature !== undefined ? source.nature : 0 as Nature; - this.friendship = source.friendship !== undefined ? source.friendship : getPokemonSpecies(this.species).baseFriendship; + this.nature = source.nature !== undefined ? source.nature : (0 as Nature); + this.friendship = + source.friendship !== undefined ? source.friendship : getPokemonSpecies(this.species).baseFriendship; this.metLevel = source.metLevel || 5; this.metBiome = source.metBiome !== undefined ? source.metBiome : -1; this.metSpecies = source.metSpecies; this.metWave = source.metWave ?? (this.metBiome === -1 ? -1 : 0); - this.luck = source.luck !== undefined ? source.luck : (source.shiny ? (source.variant + 1) : 0); + this.luck = source.luck !== undefined ? source.luck : source.shiny ? source.variant + 1 : 0; if (!forHistory) { this.pauseEvolutions = !!source.pauseEvolutions; this.evoCounter = source.evoCounter ?? 0; @@ -118,7 +119,8 @@ export default class PokemonData { this.fusionShiny = source.fusionShiny; this.fusionVariant = source.fusionVariant; this.fusionGender = source.fusionGender; - this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0); + this.fusionLuck = + source.fusionLuck !== undefined ? source.fusionLuck : source.fusionShiny ? source.fusionVariant + 1 : 0; this.fusionCustomPokemonData = new CustomPokemonData(source.fusionCustomPokemonData); this.fusionTeraType = (source.fusionTeraType ?? 0) as PokemonType; this.usedTMs = source.usedTMs ?? []; @@ -127,8 +129,12 @@ export default class PokemonData { // Deprecated, but needed for session data migration this.natureOverride = source.natureOverride; - this.mysteryEncounterPokemonData = source.mysteryEncounterPokemonData ? new CustomPokemonData(source.mysteryEncounterPokemonData) : null; - this.fusionMysteryEncounterPokemonData = source.fusionMysteryEncounterPokemonData ? new CustomPokemonData(source.fusionMysteryEncounterPokemonData) : null; + this.mysteryEncounterPokemonData = source.mysteryEncounterPokemonData + ? new CustomPokemonData(source.mysteryEncounterPokemonData) + : null; + this.fusionMysteryEncounterPokemonData = source.fusionMysteryEncounterPokemonData + ? new CustomPokemonData(source.fusionMysteryEncounterPokemonData) + : null; if (!forHistory) { this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss); @@ -144,7 +150,9 @@ export default class PokemonData { } } } else { - this.moveset = (source.moveset || [ new PokemonMove(Moves.TACKLE), new PokemonMove(Moves.GROWL) ]).filter(m => m).map((m: any) => new PokemonMove(m.moveId, m.ppUsed, m.ppUp, m.virtual, m.maxPpOverride)); + this.moveset = (source.moveset || [new PokemonMove(Moves.TACKLE), new PokemonMove(Moves.GROWL)]) + .filter(m => m) + .map((m: any) => new PokemonMove(m.moveId, m.ppUsed, m.ppUp, m.virtual, m.maxPpOverride)); if (!forHistory) { this.status = source.status ? new Status(source.status.effect, source.status.toxicTurnCount, source.status.sleepTurnsRemaining) @@ -172,15 +180,38 @@ export default class PokemonData { } } - toPokemon(battleType?: BattleType, partyMemberIndex: number = 0, double: boolean = false): Pokemon { + toPokemon(battleType?: BattleType, partyMemberIndex = 0, double = false): Pokemon { const species = getPokemonSpecies(this.species); const ret: Pokemon = this.player - ? globalScene.addPlayerPokemon(species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this, (playerPokemon) => { - if (this.nickname) { - playerPokemon.nickname = this.nickname; - } - }) - : globalScene.addEnemyPokemon(species, this.level, battleType === BattleType.TRAINER ? !double || !(partyMemberIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER : TrainerSlot.NONE, this.boss, false, this); + ? globalScene.addPlayerPokemon( + species, + this.level, + this.abilityIndex, + this.formIndex, + this.gender, + this.shiny, + this.variant, + this.ivs, + this.nature, + this, + playerPokemon => { + if (this.nickname) { + playerPokemon.nickname = this.nickname; + } + }, + ) + : globalScene.addEnemyPokemon( + species, + this.level, + battleType === BattleType.TRAINER + ? !double || !(partyMemberIndex % 2) + ? TrainerSlot.TRAINER + : TrainerSlot.TRAINER_PARTNER + : TrainerSlot.NONE, + this.boss, + false, + this, + ); if (this.summonData) { ret.primeSummonData(this.summonData); } diff --git a/src/system/session-history.ts b/src/system/session-history.ts index d9dd2022d8f..8eb81cb6efe 100644 --- a/src/system/session-history.ts +++ b/src/system/session-history.ts @@ -5,13 +5,13 @@ import type PersistentModifierData from "./modifier-data"; export enum SessionHistoryResult { ACTIVE, WIN, - LOSS + LOSS, } export interface SessionHistory { seed: string; playTime: number; - result: SessionHistoryResult, + result: SessionHistoryResult; gameMode: GameModes; party: PokemonData[]; modifiers: PersistentModifierData[]; diff --git a/src/system/settings/settings-gamepad.ts b/src/system/settings/settings-gamepad.ts index 840304ab1ba..f4a6bd465af 100644 --- a/src/system/settings/settings-gamepad.ts +++ b/src/system/settings/settings-gamepad.ts @@ -6,49 +6,49 @@ import { SettingKeyboard } from "#app/system/settings/settings-keyboard"; import { globalScene } from "#app/global-scene"; export enum SettingGamepad { - Controller = "CONTROLLER", - Gamepad_Support = "GAMEPAD_SUPPORT", - Button_Up = "BUTTON_UP", - Button_Down = "BUTTON_DOWN", - Button_Left = "BUTTON_LEFT", - Button_Right = "BUTTON_RIGHT", - Button_Action = "BUTTON_ACTION", - Button_Cancel = "BUTTON_CANCEL", - Button_Menu = "BUTTON_MENU", - Button_Stats = "BUTTON_STATS", - Button_Cycle_Form = "BUTTON_CYCLE_FORM", - Button_Cycle_Shiny = "BUTTON_CYCLE_SHINY", - Button_Cycle_Gender = "BUTTON_CYCLE_GENDER", - Button_Cycle_Ability = "BUTTON_CYCLE_ABILITY", - Button_Cycle_Nature = "BUTTON_CYCLE_NATURE", - Button_Cycle_Tera = "BUTTON_CYCLE_TERA", - Button_Speed_Up = "BUTTON_SPEED_UP", - Button_Slow_Down = "BUTTON_SLOW_DOWN", - Button_Submit = "BUTTON_SUBMIT", + Controller = "CONTROLLER", + Gamepad_Support = "GAMEPAD_SUPPORT", + Button_Up = "BUTTON_UP", + Button_Down = "BUTTON_DOWN", + Button_Left = "BUTTON_LEFT", + Button_Right = "BUTTON_RIGHT", + Button_Action = "BUTTON_ACTION", + Button_Cancel = "BUTTON_CANCEL", + Button_Menu = "BUTTON_MENU", + Button_Stats = "BUTTON_STATS", + Button_Cycle_Form = "BUTTON_CYCLE_FORM", + Button_Cycle_Shiny = "BUTTON_CYCLE_SHINY", + Button_Cycle_Gender = "BUTTON_CYCLE_GENDER", + Button_Cycle_Ability = "BUTTON_CYCLE_ABILITY", + Button_Cycle_Nature = "BUTTON_CYCLE_NATURE", + Button_Cycle_Tera = "BUTTON_CYCLE_TERA", + Button_Speed_Up = "BUTTON_SPEED_UP", + Button_Slow_Down = "BUTTON_SLOW_DOWN", + Button_Submit = "BUTTON_SUBMIT", } const pressAction = "Press action to assign"; export const settingGamepadOptions = { - [SettingGamepad.Controller]: [ "Default", "Change" ], - [SettingGamepad.Gamepad_Support]: [ "Auto", "Disabled" ], - [SettingGamepad.Button_Up]: [ `KEY ${Button.UP.toString()}`, pressAction ], - [SettingGamepad.Button_Down]: [ `KEY ${Button.DOWN.toString()}`, pressAction ], - [SettingGamepad.Button_Left]: [ `KEY ${Button.LEFT.toString()}`, pressAction ], - [SettingGamepad.Button_Right]: [ `KEY ${Button.RIGHT.toString()}`, pressAction ], - [SettingGamepad.Button_Action]: [ `KEY ${Button.ACTION.toString()}`, pressAction ], - [SettingGamepad.Button_Cancel]: [ `KEY ${Button.CANCEL.toString()}`, pressAction ], - [SettingGamepad.Button_Menu]: [ `KEY ${Button.MENU.toString()}`, pressAction ], - [SettingGamepad.Button_Stats]: [ `KEY ${Button.STATS.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Form]: [ `KEY ${Button.CYCLE_FORM.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Shiny]: [ `KEY ${Button.CYCLE_SHINY.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Gender]: [ `KEY ${Button.CYCLE_GENDER.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Ability]: [ `KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Nature]: [ `KEY ${Button.CYCLE_NATURE.toString()}`, pressAction ], - [SettingGamepad.Button_Cycle_Tera]: [ `KEY ${Button.CYCLE_TERA.toString()}`, pressAction ], - [SettingGamepad.Button_Speed_Up]: [ `KEY ${Button.SPEED_UP.toString()}`, pressAction ], - [SettingGamepad.Button_Slow_Down]: [ `KEY ${Button.SLOW_DOWN.toString()}`, pressAction ], - [SettingGamepad.Button_Submit]: [ `KEY ${Button.SUBMIT.toString()}`, pressAction ], + [SettingGamepad.Controller]: ["Default", "Change"], + [SettingGamepad.Gamepad_Support]: ["Auto", "Disabled"], + [SettingGamepad.Button_Up]: [`KEY ${Button.UP.toString()}`, pressAction], + [SettingGamepad.Button_Down]: [`KEY ${Button.DOWN.toString()}`, pressAction], + [SettingGamepad.Button_Left]: [`KEY ${Button.LEFT.toString()}`, pressAction], + [SettingGamepad.Button_Right]: [`KEY ${Button.RIGHT.toString()}`, pressAction], + [SettingGamepad.Button_Action]: [`KEY ${Button.ACTION.toString()}`, pressAction], + [SettingGamepad.Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, pressAction], + [SettingGamepad.Button_Menu]: [`KEY ${Button.MENU.toString()}`, pressAction], + [SettingGamepad.Button_Stats]: [`KEY ${Button.STATS.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Form]: [`KEY ${Button.CYCLE_FORM.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Shiny]: [`KEY ${Button.CYCLE_SHINY.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Gender]: [`KEY ${Button.CYCLE_GENDER.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Ability]: [`KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Nature]: [`KEY ${Button.CYCLE_NATURE.toString()}`, pressAction], + [SettingGamepad.Button_Cycle_Tera]: [`KEY ${Button.CYCLE_TERA.toString()}`, pressAction], + [SettingGamepad.Button_Speed_Up]: [`KEY ${Button.SPEED_UP.toString()}`, pressAction], + [SettingGamepad.Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, pressAction], + [SettingGamepad.Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, pressAction], }; export const settingGamepadDefaults = { @@ -83,8 +83,8 @@ export const settingGamepadBlackList = [ export function setSettingGamepad(setting: SettingGamepad, value: number): boolean { switch (setting) { case SettingGamepad.Gamepad_Support: - // if we change the value of the gamepad support, we call a method in the inputController to - // activate or deactivate the controller listener + // if we change the value of the gamepad support, we call a method in the inputController to + // activate or deactivate the controller listener globalScene.inputController.setGamepadSupport(settingGamepadOptions[setting][value] !== "Disabled"); break; case SettingGamepad.Button_Action: @@ -102,7 +102,7 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole case SettingGamepad.Button_Submit: if (value) { if (globalScene.ui) { - const cancelHandler = (success: boolean = false) : boolean => { + const cancelHandler = (success = false): boolean => { globalScene.ui.revertMode(); (globalScene.ui.getHandler() as SettingsGamepadUiHandler).updateBindings(); return success; @@ -120,7 +120,11 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole if (globalScene.ui && gp) { const cancelHandler = () => { globalScene.ui.revertMode(); - (globalScene.ui.getHandler() as SettingsGamepadUiHandler).setOptionCursor(Object.values(SettingGamepad).indexOf(SettingGamepad.Controller), 0, true); + (globalScene.ui.getHandler() as SettingsGamepadUiHandler).setOptionCursor( + Object.values(SettingGamepad).indexOf(SettingGamepad.Controller), + 0, + true, + ); (globalScene.ui.getHandler() as SettingsGamepadUiHandler).updateBindings(); return false; }; @@ -130,13 +134,16 @@ export function setSettingGamepad(setting: SettingGamepad, value: number): boole return true; }; globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { - options: [ ...gp.map((g: string) => ({ - label: truncateString(g, 30), // Truncate the gamepad name for display - handler: () => changeGamepadHandler(g) - })), { - label: "Cancel", - handler: cancelHandler, - }] + options: [ + ...gp.map((g: string) => ({ + label: truncateString(g, 30), // Truncate the gamepad name for display + handler: () => changeGamepadHandler(g), + })), + { + label: "Cancel", + handler: cancelHandler, + }, + ], }); return false; } diff --git a/src/system/settings/settings-keyboard.ts b/src/system/settings/settings-keyboard.ts index 1a7db1b10c2..ffe8811e5d9 100644 --- a/src/system/settings/settings-keyboard.ts +++ b/src/system/settings/settings-keyboard.ts @@ -5,81 +5,81 @@ import i18next from "i18next"; import { globalScene } from "#app/global-scene"; export enum SettingKeyboard { - // Default_Layout = "DEFAULT_LAYOUT", - Button_Up = "BUTTON_UP", - Alt_Button_Up = "ALT_BUTTON_UP", - Button_Down = "BUTTON_DOWN", - Alt_Button_Down = "ALT_BUTTON_DOWN", - Button_Left = "BUTTON_LEFT", - Alt_Button_Left = "ALT_BUTTON_LEFT", - Button_Right = "BUTTON_RIGHT", - Alt_Button_Right = "ALT_BUTTON_RIGHT", - Button_Action = "BUTTON_ACTION", - Alt_Button_Action = "ALT_BUTTON_ACTION", - Button_Cancel = "BUTTON_CANCEL", - Alt_Button_Cancel = "ALT_BUTTON_CANCEL", - Button_Menu = "BUTTON_MENU", - Alt_Button_Menu = "ALT_BUTTON_MENU", - Button_Stats = "BUTTON_STATS", - Alt_Button_Stats = "ALT_BUTTON_STATS", - Button_Cycle_Form = "BUTTON_CYCLE_FORM", - Alt_Button_Cycle_Form = "ALT_BUTTON_CYCLE_FORM", - Button_Cycle_Shiny = "BUTTON_CYCLE_SHINY", - Alt_Button_Cycle_Shiny = "ALT_BUTTON_CYCLE_SHINY", - Button_Cycle_Gender = "BUTTON_CYCLE_GENDER", - Alt_Button_Cycle_Gender = "ALT_BUTTON_CYCLE_GENDER", - Button_Cycle_Ability = "BUTTON_CYCLE_ABILITY", - Alt_Button_Cycle_Ability = "ALT_BUTTON_CYCLE_ABILITY", - Button_Cycle_Nature = "BUTTON_CYCLE_NATURE", - Alt_Button_Cycle_Nature = "ALT_BUTTON_CYCLE_NATURE", - Button_Cycle_Tera = "BUTTON_CYCLE_TERA", - Alt_Button_Cycle_Tera = "ALT_BUTTON_CYCLE_TERA", - Button_Speed_Up = "BUTTON_SPEED_UP", - Alt_Button_Speed_Up = "ALT_BUTTON_SPEED_UP", - Button_Slow_Down = "BUTTON_SLOW_DOWN", - Alt_Button_Slow_Down = "ALT_BUTTON_SLOW_DOWN", - Button_Submit = "BUTTON_SUBMIT", - Alt_Button_Submit = "ALT_BUTTON_SUBMIT", + // Default_Layout = "DEFAULT_LAYOUT", + Button_Up = "BUTTON_UP", + Alt_Button_Up = "ALT_BUTTON_UP", + Button_Down = "BUTTON_DOWN", + Alt_Button_Down = "ALT_BUTTON_DOWN", + Button_Left = "BUTTON_LEFT", + Alt_Button_Left = "ALT_BUTTON_LEFT", + Button_Right = "BUTTON_RIGHT", + Alt_Button_Right = "ALT_BUTTON_RIGHT", + Button_Action = "BUTTON_ACTION", + Alt_Button_Action = "ALT_BUTTON_ACTION", + Button_Cancel = "BUTTON_CANCEL", + Alt_Button_Cancel = "ALT_BUTTON_CANCEL", + Button_Menu = "BUTTON_MENU", + Alt_Button_Menu = "ALT_BUTTON_MENU", + Button_Stats = "BUTTON_STATS", + Alt_Button_Stats = "ALT_BUTTON_STATS", + Button_Cycle_Form = "BUTTON_CYCLE_FORM", + Alt_Button_Cycle_Form = "ALT_BUTTON_CYCLE_FORM", + Button_Cycle_Shiny = "BUTTON_CYCLE_SHINY", + Alt_Button_Cycle_Shiny = "ALT_BUTTON_CYCLE_SHINY", + Button_Cycle_Gender = "BUTTON_CYCLE_GENDER", + Alt_Button_Cycle_Gender = "ALT_BUTTON_CYCLE_GENDER", + Button_Cycle_Ability = "BUTTON_CYCLE_ABILITY", + Alt_Button_Cycle_Ability = "ALT_BUTTON_CYCLE_ABILITY", + Button_Cycle_Nature = "BUTTON_CYCLE_NATURE", + Alt_Button_Cycle_Nature = "ALT_BUTTON_CYCLE_NATURE", + Button_Cycle_Tera = "BUTTON_CYCLE_TERA", + Alt_Button_Cycle_Tera = "ALT_BUTTON_CYCLE_TERA", + Button_Speed_Up = "BUTTON_SPEED_UP", + Alt_Button_Speed_Up = "ALT_BUTTON_SPEED_UP", + Button_Slow_Down = "BUTTON_SLOW_DOWN", + Alt_Button_Slow_Down = "ALT_BUTTON_SLOW_DOWN", + Button_Submit = "BUTTON_SUBMIT", + Alt_Button_Submit = "ALT_BUTTON_SUBMIT", } const pressAction = i18next.t("settings:pressToBind"); export const settingKeyboardOptions = { // [SettingKeyboard.Default_Layout]: ['Default'], - [SettingKeyboard.Button_Up]: [ `KEY ${Button.UP.toString()}`, pressAction ], - [SettingKeyboard.Button_Down]: [ `KEY ${Button.DOWN.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Up]: [ `KEY ${Button.UP.toString()}`, pressAction ], - [SettingKeyboard.Button_Left]: [ `KEY ${Button.LEFT.toString()}`, pressAction ], - [SettingKeyboard.Button_Right]: [ `KEY ${Button.RIGHT.toString()}`, pressAction ], - [SettingKeyboard.Button_Action]: [ `KEY ${Button.ACTION.toString()}`, pressAction ], - [SettingKeyboard.Button_Menu]: [ `KEY ${Button.MENU.toString()}`, pressAction ], - [SettingKeyboard.Button_Submit]: [ `KEY ${Button.SUBMIT.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Down]: [ `KEY ${Button.DOWN.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Left]: [ `KEY ${Button.LEFT.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Right]: [ `KEY ${Button.RIGHT.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Action]: [ `KEY ${Button.ACTION.toString()}`, pressAction ], - [SettingKeyboard.Button_Cancel]: [ `KEY ${Button.CANCEL.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cancel]: [ `KEY ${Button.CANCEL.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Menu]: [ `KEY ${Button.MENU.toString()}`, pressAction ], - [SettingKeyboard.Button_Stats]: [ `KEY ${Button.STATS.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Stats]: [ `KEY ${Button.STATS.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Form]: [ `KEY ${Button.CYCLE_FORM.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Form]: [ `KEY ${Button.CYCLE_FORM.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Shiny]: [ `KEY ${Button.CYCLE_SHINY.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Shiny]: [ `KEY ${Button.CYCLE_SHINY.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Gender]: [ `KEY ${Button.CYCLE_GENDER.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Gender]: [ `KEY ${Button.CYCLE_GENDER.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Ability]: [ `KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Ability]: [ `KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Nature]: [ `KEY ${Button.CYCLE_NATURE.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Nature]: [ `KEY ${Button.CYCLE_NATURE.toString()}`, pressAction ], - [SettingKeyboard.Button_Cycle_Tera]: [ `KEY ${Button.CYCLE_TERA.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Cycle_Tera]: [ `KEY ${Button.CYCLE_TERA.toString()}`, pressAction ], - [SettingKeyboard.Button_Speed_Up]: [ `KEY ${Button.SPEED_UP.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Speed_Up]: [ `KEY ${Button.SPEED_UP.toString()}`, pressAction ], - [SettingKeyboard.Button_Slow_Down]: [ `KEY ${Button.SLOW_DOWN.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Slow_Down]: [ `KEY ${Button.SLOW_DOWN.toString()}`, pressAction ], - [SettingKeyboard.Alt_Button_Submit]: [ `KEY ${Button.SUBMIT.toString()}`, pressAction ], + [SettingKeyboard.Button_Up]: [`KEY ${Button.UP.toString()}`, pressAction], + [SettingKeyboard.Button_Down]: [`KEY ${Button.DOWN.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Up]: [`KEY ${Button.UP.toString()}`, pressAction], + [SettingKeyboard.Button_Left]: [`KEY ${Button.LEFT.toString()}`, pressAction], + [SettingKeyboard.Button_Right]: [`KEY ${Button.RIGHT.toString()}`, pressAction], + [SettingKeyboard.Button_Action]: [`KEY ${Button.ACTION.toString()}`, pressAction], + [SettingKeyboard.Button_Menu]: [`KEY ${Button.MENU.toString()}`, pressAction], + [SettingKeyboard.Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Down]: [`KEY ${Button.DOWN.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Left]: [`KEY ${Button.LEFT.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Right]: [`KEY ${Button.RIGHT.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Action]: [`KEY ${Button.ACTION.toString()}`, pressAction], + [SettingKeyboard.Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cancel]: [`KEY ${Button.CANCEL.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Menu]: [`KEY ${Button.MENU.toString()}`, pressAction], + [SettingKeyboard.Button_Stats]: [`KEY ${Button.STATS.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Stats]: [`KEY ${Button.STATS.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Form]: [`KEY ${Button.CYCLE_FORM.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Form]: [`KEY ${Button.CYCLE_FORM.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Shiny]: [`KEY ${Button.CYCLE_SHINY.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Shiny]: [`KEY ${Button.CYCLE_SHINY.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Gender]: [`KEY ${Button.CYCLE_GENDER.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Gender]: [`KEY ${Button.CYCLE_GENDER.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Ability]: [`KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Ability]: [`KEY ${Button.CYCLE_ABILITY.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Nature]: [`KEY ${Button.CYCLE_NATURE.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Nature]: [`KEY ${Button.CYCLE_NATURE.toString()}`, pressAction], + [SettingKeyboard.Button_Cycle_Tera]: [`KEY ${Button.CYCLE_TERA.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Cycle_Tera]: [`KEY ${Button.CYCLE_TERA.toString()}`, pressAction], + [SettingKeyboard.Button_Speed_Up]: [`KEY ${Button.SPEED_UP.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Speed_Up]: [`KEY ${Button.SPEED_UP.toString()}`, pressAction], + [SettingKeyboard.Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Slow_Down]: [`KEY ${Button.SLOW_DOWN.toString()}`, pressAction], + [SettingKeyboard.Alt_Button_Submit]: [`KEY ${Button.SUBMIT.toString()}`, pressAction], }; export const settingKeyboardDefaults = { @@ -132,7 +132,6 @@ export const settingKeyboardBlackList = [ SettingKeyboard.Button_Right, ]; - export function setSettingKeyboard(setting: SettingKeyboard, value: number): boolean { switch (setting) { case SettingKeyboard.Button_Up: @@ -170,7 +169,7 @@ export function setSettingKeyboard(setting: SettingKeyboard, value: number): boo case SettingKeyboard.Alt_Button_Submit: if (value) { if (globalScene.ui) { - const cancelHandler = (success: boolean = false) : boolean => { + const cancelHandler = (success = false): boolean => { globalScene.ui.revertMode(); (globalScene.ui.getHandler() as SettingsKeyboardUiHandler).updateBindings(); return success; @@ -184,5 +183,4 @@ export function setSettingKeyboard(setting: SettingKeyboard, value: number): boo break; } return true; - } diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index b750400d6f5..1a7279d371c 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -11,13 +11,17 @@ import { PlayerGender } from "#enums/player-gender"; import { ShopCursorTarget } from "#enums/shop-cursor-target"; import { isLocal } from "#app/utils"; -const VOLUME_OPTIONS: SettingOption[] = new Array(11).fill(null).map((_, i) => i ? { - value: (i * 10).toString(), - label: (i * 10).toString(), -} : { - value: "Mute", - label: i18next.t("settings:mute") -}); +const VOLUME_OPTIONS: SettingOption[] = new Array(11).fill(null).map((_, i) => + i + ? { + value: (i * 10).toString(), + label: (i * 10).toString(), + } + : { + value: "Mute", + label: i18next.t("settings:mute"), + }, +); const SHOP_OVERLAY_OPACITY_OPTIONS: SettingOption[] = new Array(9).fill(null).map((_, i) => { const value = ((i + 1) * 10).toString(); @@ -30,55 +34,55 @@ const SHOP_OVERLAY_OPACITY_OPTIONS: SettingOption[] = new Array(9).fill(null).ma const OFF_ON: SettingOption[] = [ { value: "Off", - label: i18next.t("settings:off") + label: i18next.t("settings:off"), }, { value: "On", - label: i18next.t("settings:on") - } + label: i18next.t("settings:on"), + }, ]; const AUTO_DISABLED: SettingOption[] = [ { value: "Auto", - label: i18next.t("settings:auto") + label: i18next.t("settings:auto"), }, { value: "Disabled", - label: i18next.t("settings:disabled") - } + label: i18next.t("settings:disabled"), + }, ]; const TOUCH_CONTROLS_OPTIONS: SettingOption[] = [ { value: "Auto", - label: i18next.t("settings:auto") + label: i18next.t("settings:auto"), }, { value: "Disabled", label: i18next.t("settings:disabled"), needConfirmation: true, - confirmationMessage: i18next.t("settings:confirmDisableTouch") - } + confirmationMessage: i18next.t("settings:confirmDisableTouch"), + }, ]; const SHOP_CURSOR_TARGET_OPTIONS: SettingOption[] = [ { value: "Rewards", - label: i18next.t("settings:rewards") + label: i18next.t("settings:rewards"), }, { value: "Shop", - label: i18next.t("settings:shop") + label: i18next.t("settings:shop"), }, { value: "Reroll", - label: i18next.t("settings:reroll") + label: i18next.t("settings:reroll"), }, { value: "Check Team", - label: i18next.t("settings:checkTeam") - } + label: i18next.t("settings:checkTeam"), + }, ]; const shopCursorTargetIndexMap = SHOP_CURSOR_TARGET_OPTIONS.map(option => { @@ -102,27 +106,27 @@ const shopCursorTargetIndexMap = SHOP_CURSOR_TARGET_OPTIONS.map(option => { export enum SettingType { GENERAL, DISPLAY, - AUDIO + AUDIO, } type SettingOption = { - value: string, - label: string, - needConfirmation?: boolean, - confirmationMessage?: string + value: string; + label: string; + needConfirmation?: boolean; + confirmationMessage?: string; }; export interface Setting { - key: string - label: string - options: SettingOption[] - default: number - type: SettingType - requireReload?: boolean + key: string; + label: string; + options: SettingOption[]; + default: number; + type: SettingType; + requireReload?: boolean; /** Whether the setting can be activated or not */ - activatable?: boolean + activatable?: boolean; /** Determines whether the setting should be hidden from the UI */ - isHidden?: () => boolean + isHidden?: () => boolean; } /** @@ -171,12 +175,12 @@ export const SettingKeys = { Battle_Music: "BATTLE_MUSIC", Show_BGM_Bar: "SHOW_BGM_BAR", Move_Touch_Controls: "MOVE_TOUCH_CONTROLS", - Shop_Overlay_Opacity: "SHOP_OVERLAY_OPACITY" + Shop_Overlay_Opacity: "SHOP_OVERLAY_OPACITY", }; export enum MusicPreference { GENFIVE, - ALLGENS + ALLGENS, } /** @@ -189,39 +193,39 @@ export const Setting: Array = [ options: [ { value: "1", - label: "1x" + label: "1x", }, { value: "1.25", - label: "1.25x" + label: "1.25x", }, { value: "1.5", - label: "1.5x" + label: "1.5x", }, { value: "2", - label: "2x" + label: "2x", }, { value: "2.5", - label: "2.5x" + label: "2.5x", }, { value: "3", - label: "3x" + label: "3x", }, { value: "4", - label: "4x" + label: "4x", }, { value: "5", - label: "5x" - } + label: "5x", + }, ], default: 3, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.HP_Bar_Speed, @@ -229,23 +233,23 @@ export const Setting: Array = [ options: [ { value: "Normal", - label: i18next.t("settings:normal") + label: i18next.t("settings:normal"), }, { value: "Fast", - label: i18next.t("settings:fast") + label: i18next.t("settings:fast"), }, { value: "Faster", - label: i18next.t("settings:faster") + label: i18next.t("settings:faster"), }, { value: "Skip", - label: i18next.t("settings:skip") - } + label: i18next.t("settings:skip"), + }, ], default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.EXP_Gains_Speed, @@ -253,23 +257,23 @@ export const Setting: Array = [ options: [ { value: "Normal", - label: i18next.t("settings:normal") + label: i18next.t("settings:normal"), }, { value: "Fast", - label: i18next.t("settings:fast") + label: i18next.t("settings:fast"), }, { value: "Faster", - label: i18next.t("settings:faster") + label: i18next.t("settings:faster"), }, { value: "Skip", - label: i18next.t("settings:skip") - } + label: i18next.t("settings:skip"), + }, ], default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.EXP_Party_Display, @@ -277,26 +281,26 @@ export const Setting: Array = [ options: [ { value: "Normal", - label: i18next.t("settings:normal") + label: i18next.t("settings:normal"), }, { value: "Level Up Notification", - label: i18next.t("settings:levelUpNotifications") + label: i18next.t("settings:levelUpNotifications"), }, { value: "Skip", - label: i18next.t("settings:skip") - } + label: i18next.t("settings:skip"), + }, ], default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Skip_Seen_Dialogues, label: i18next.t("settings:skipSeenDialogues"), options: OFF_ON, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Egg_Skip, @@ -304,19 +308,19 @@ export const Setting: Array = [ options: [ { value: "Never", - label: i18next.t("settings:never") + label: i18next.t("settings:never"), }, { value: "Ask", - label: i18next.t("settings:ask") + label: i18next.t("settings:ask"), }, { value: "Always", - label: i18next.t("settings:always") - } + label: i18next.t("settings:always"), + }, ], default: 1, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Battle_Style, @@ -324,50 +328,50 @@ export const Setting: Array = [ options: [ { value: "Switch", - label: i18next.t("settings:switch") + label: i18next.t("settings:switch"), }, { value: "Set", - label: i18next.t("settings:set") - } + label: i18next.t("settings:set"), + }, ], default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Command_Cursor_Memory, label: i18next.t("settings:commandCursorMemory"), options: OFF_ON, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Enable_Retries, label: i18next.t("settings:enableRetries"), options: OFF_ON, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Hide_IVs, label: i18next.t("settings:hideIvs"), options: OFF_ON, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Tutorials, label: i18next.t("settings:tutorials"), options: OFF_ON, default: 1, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Vibration, label: i18next.t("settings:vibrations"), options: AUTO_DISABLED, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }, { key: SettingKeys.Touch_Controls, @@ -375,7 +379,7 @@ export const Setting: Array = [ options: TOUCH_CONTROLS_OPTIONS, default: 0, type: SettingType.GENERAL, - isHidden: () => !hasTouchscreen() + isHidden: () => !hasTouchscreen(), }, { key: SettingKeys.Move_Touch_Controls, @@ -383,13 +387,13 @@ export const Setting: Array = [ options: [ { value: "Configure", - label: i18next.t("settings:change") - } + label: i18next.t("settings:change"), + }, ], default: 0, type: SettingType.GENERAL, activatable: true, - isHidden: () => !hasTouchscreen() + isHidden: () => !hasTouchscreen(), }, { key: SettingKeys.Language, @@ -397,16 +401,16 @@ export const Setting: Array = [ options: [ { value: "English", - label: "English" + label: "English", }, { value: "Change", - label: i18next.t("settings:change") - } + label: i18next.t("settings:change"), + }, ], default: 0, type: SettingType.DISPLAY, - requireReload: true + requireReload: true, }, { key: SettingKeys.UI_Theme, @@ -414,16 +418,16 @@ export const Setting: Array = [ options: [ { value: "Default", - label: i18next.t("settings:default") + label: i18next.t("settings:default"), }, { value: "Legacy", - label: i18next.t("settings:legacy") - } + label: i18next.t("settings:legacy"), + }, ], default: 0, type: SettingType.DISPLAY, - requireReload: true + requireReload: true, }, { key: SettingKeys.Window_Type, @@ -432,11 +436,11 @@ export const Setting: Array = [ const windowType = (i + 1).toString(); return { value: windowType, - label: windowType + label: windowType, }; }), default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Money_Format, @@ -444,15 +448,15 @@ export const Setting: Array = [ options: [ { value: "Normal", - label: i18next.t("settings:normal") + label: i18next.t("settings:normal"), }, { value: "Abbreviated", - label: i18next.t("settings:abbreviated") - } + label: i18next.t("settings:abbreviated"), + }, ], default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Damage_Numbers, @@ -460,33 +464,33 @@ export const Setting: Array = [ options: [ { value: "Off", - label: i18next.t("settings:off") + label: i18next.t("settings:off"), }, { value: "Simple", - label: i18next.t("settings:simple") + label: i18next.t("settings:simple"), }, { value: "Fancy", - label: i18next.t("settings:fancy") - } + label: i18next.t("settings:fancy"), + }, ], default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Move_Animations, label: i18next.t("settings:moveAnimations"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Show_Stats_on_Level_Up, label: i18next.t("settings:showStatsOnLevelUp"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Candy_Upgrade_Notification, @@ -494,19 +498,19 @@ export const Setting: Array = [ options: [ { value: "Off", - label: i18next.t("settings:off") + label: i18next.t("settings:off"), }, { value: "Passives Only", - label: i18next.t("settings:passivesOnly") + label: i18next.t("settings:passivesOnly"), }, { value: "On", - label: i18next.t("settings:on") - } + label: i18next.t("settings:on"), + }, ], default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Candy_Upgrade_Display, @@ -514,37 +518,37 @@ export const Setting: Array = [ options: [ { value: "Icon", - label: i18next.t("settings:icon") + label: i18next.t("settings:icon"), }, { value: "Animation", - label: i18next.t("settings:animation") - } + label: i18next.t("settings:animation"), + }, ], default: 0, type: SettingType.DISPLAY, - requireReload: true + requireReload: true, }, { key: SettingKeys.Move_Info, label: i18next.t("settings:moveInfo"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Show_Moveset_Flyout, label: i18next.t("settings:showMovesetFlyout"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Show_Arena_Flyout, label: i18next.t("settings:showArenaFlyout"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Show_Time_Of_Day_Widget, @@ -560,15 +564,15 @@ export const Setting: Array = [ options: [ { value: "Bounce", - label: i18next.t("settings:bounce") + label: i18next.t("settings:bounce"), }, { value: "Back", - label: i18next.t("settings:timeOfDay_back") - } + label: i18next.t("settings:timeOfDay_back"), + }, ], default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Sprite_Set, @@ -576,23 +580,23 @@ export const Setting: Array = [ options: [ { value: "Consistent", - label: i18next.t("settings:consistent") + label: i18next.t("settings:consistent"), }, { value: "Experimental", - label: i18next.t("settings:experimental") - } + label: i18next.t("settings:experimental"), + }, ], default: 0, type: SettingType.DISPLAY, - requireReload: true + requireReload: true, }, { key: SettingKeys.Fusion_Palette_Swaps, label: i18next.t("settings:fusionPaletteSwaps"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Player_Gender, @@ -600,64 +604,64 @@ export const Setting: Array = [ options: [ { value: "Boy", - label: i18next.t("settings:boy") + label: i18next.t("settings:boy"), }, { value: "Girl", - label: i18next.t("settings:girl") - } + label: i18next.t("settings:girl"), + }, ], default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Type_Hints, label: i18next.t("settings:typeHints"), options: OFF_ON, default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Show_BGM_Bar, label: i18next.t("settings:showBgmBar"), options: OFF_ON, default: 1, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Master_Volume, label: i18next.t("settings:masterVolume"), options: VOLUME_OPTIONS, default: 5, - type: SettingType.AUDIO + type: SettingType.AUDIO, }, { key: SettingKeys.BGM_Volume, label: i18next.t("settings:bgmVolume"), options: VOLUME_OPTIONS, default: 10, - type: SettingType.AUDIO + type: SettingType.AUDIO, }, { key: SettingKeys.Field_Volume, label: i18next.t("settings:fieldVolume"), options: VOLUME_OPTIONS, default: 10, - type: SettingType.AUDIO + type: SettingType.AUDIO, }, { key: SettingKeys.SE_Volume, label: i18next.t("settings:seVolume"), options: VOLUME_OPTIONS, default: 10, - type: SettingType.AUDIO + type: SettingType.AUDIO, }, { key: SettingKeys.UI_Volume, label: i18next.t("settings:uiVolume"), options: VOLUME_OPTIONS, default: 10, - type: SettingType.AUDIO + type: SettingType.AUDIO, }, { key: SettingKeys.Battle_Music, @@ -665,23 +669,23 @@ export const Setting: Array = [ options: [ { value: "Gen V", - label: i18next.t("settings:musicGenFive") + label: i18next.t("settings:musicGenFive"), }, { value: "All Gens", - label: i18next.t("settings:musicAllGens") - } + label: i18next.t("settings:musicAllGens"), + }, ], default: MusicPreference.ALLGENS, type: SettingType.AUDIO, - requireReload: true + requireReload: true, }, { key: SettingKeys.Shop_Cursor_Target, label: i18next.t("settings:shopCursorTarget"), options: SHOP_CURSOR_TARGET_OPTIONS, default: 0, - type: SettingType.DISPLAY + type: SettingType.DISPLAY, }, { key: SettingKeys.Shop_Overlay_Opacity, @@ -689,8 +693,8 @@ export const Setting: Array = [ options: SHOP_OVERLAY_OPACITY_OPTIONS, default: 7, type: SettingType.DISPLAY, - requireReload: false - } + requireReload: false, + }, ]; if (isLocal) { @@ -699,7 +703,7 @@ if (isLocal) { label: i18next.t("settings:dexForDevs"), options: OFF_ON, default: 0, - type: SettingType.GENERAL + type: SettingType.GENERAL, }); } @@ -716,7 +720,9 @@ export function settingIndex(key: string) { * Resets all settings to their defaults */ export function resetSettings() { - Setting.forEach(s => setSetting(s.key, s.default)); + for (const s of Setting) { + setSetting(s.key, s.default); + } } /** @@ -732,26 +738,26 @@ export function setSetting(setting: string, value: number): boolean { } switch (Setting[index].key) { case SettingKeys.Game_Speed: - globalScene.gameSpeed = parseFloat(Setting[index].options[value].value.replace("x", "")); + globalScene.gameSpeed = Number.parseFloat(Setting[index].options[value].value.replace("x", "")); break; case SettingKeys.Master_Volume: - globalScene.masterVolume = value ? parseInt(Setting[index].options[value].value) * 0.01 : 0; + globalScene.masterVolume = value ? Number.parseInt(Setting[index].options[value].value) * 0.01 : 0; globalScene.updateSoundVolume(); break; case SettingKeys.BGM_Volume: - globalScene.bgmVolume = value ? parseInt(Setting[index].options[value].value) * 0.01 : 0; + globalScene.bgmVolume = value ? Number.parseInt(Setting[index].options[value].value) * 0.01 : 0; globalScene.updateSoundVolume(); break; case SettingKeys.Field_Volume: - globalScene.fieldVolume = value ? parseInt(Setting[index].options[value].value) * 0.01 : 0; + globalScene.fieldVolume = value ? Number.parseInt(Setting[index].options[value].value) * 0.01 : 0; globalScene.updateSoundVolume(); break; case SettingKeys.SE_Volume: - globalScene.seVolume = value ? parseInt(Setting[index].options[value].value) * 0.01 : 0; + globalScene.seVolume = value ? Number.parseInt(Setting[index].options[value].value) * 0.01 : 0; globalScene.updateSoundVolume(); break; case SettingKeys.UI_Volume: - globalScene.uiVolume = value ? parseInt(Setting[index].options[value].value) * 0.01 : 0; + globalScene.uiVolume = value ? Number.parseInt(Setting[index].options[value].value) * 0.01 : 0; break; case SettingKeys.Battle_Music: globalScene.musicPreference = value; @@ -763,7 +769,7 @@ export function setSetting(setting: string, value: number): boolean { globalScene.uiTheme = value; break; case SettingKeys.Window_Type: - updateWindowType(parseInt(Setting[index].options[value].value)); + updateWindowType(Number.parseInt(Setting[index].options[value].value)); break; case SettingKeys.Tutorials: globalScene.enableTutorials = Setting[index].options[value].value === "On"; @@ -828,15 +834,17 @@ export function setSetting(setting: string, value: number): boolean { globalScene.showTimeOfDayWidget = Setting[index].options[value].value === "On"; break; case SettingKeys.Time_Of_Day_Animation: - globalScene.timeOfDayAnimation = Setting[index].options[value].value === "Bounce" ? EaseType.BOUNCE : EaseType.BACK; + globalScene.timeOfDayAnimation = + Setting[index].options[value].value === "Bounce" ? EaseType.BOUNCE : EaseType.BACK; break; case SettingKeys.Show_Stats_on_Level_Up: globalScene.showLevelUpStats = Setting[index].options[value].value === "On"; break; - case SettingKeys.Shop_Cursor_Target: + case SettingKeys.Shop_Cursor_Target: { const selectedValue = shopCursorTargetIndexMap[value]; globalScene.shopCursorTarget = selectedValue; break; + } case SettingKeys.Command_Cursor_Memory: globalScene.commandCursorMemory = Setting[index].options[value].value === "On"; break; @@ -864,13 +872,14 @@ export function setSetting(setting: string, value: number): boolean { return false; } break; - case SettingKeys.Touch_Controls: + case SettingKeys.Touch_Controls: { globalScene.enableTouchControls = Setting[index].options[value].value !== "Disabled" && hasTouchscreen(); const touchControls = document.getElementById("touchControls"); if (touchControls) { touchControls.classList.toggle("visible", globalScene.enableTouchControls); } break; + } case SettingKeys.Vibration: globalScene.enableVibration = Setting[index].options[value].value !== "Disabled" && hasTouchscreen(); break; @@ -901,43 +910,43 @@ export function setSetting(setting: string, value: number): boolean { options: [ { label: "English", - handler: () => changeLocaleHandler("en") + handler: () => changeLocaleHandler("en"), }, { label: "Español (ES)", - handler: () => changeLocaleHandler("es-ES") + handler: () => changeLocaleHandler("es-ES"), }, { label: "Italiano", - handler: () => changeLocaleHandler("it") + handler: () => changeLocaleHandler("it"), }, { label: "Français", - handler: () => changeLocaleHandler("fr") + handler: () => changeLocaleHandler("fr"), }, { label: "Deutsch", - handler: () => changeLocaleHandler("de") + handler: () => changeLocaleHandler("de"), }, { label: "Português (BR)", - handler: () => changeLocaleHandler("pt-BR") + handler: () => changeLocaleHandler("pt-BR"), }, { label: "简体中文", - handler: () => changeLocaleHandler("zh-CN") + handler: () => changeLocaleHandler("zh-CN"), }, { label: "繁體中文", - handler: () => changeLocaleHandler("zh-TW") + handler: () => changeLocaleHandler("zh-TW"), }, { label: "한국어", - handler: () => changeLocaleHandler("ko") + handler: () => changeLocaleHandler("ko"), }, { label: "日本語", - handler: () => changeLocaleHandler("ja") + handler: () => changeLocaleHandler("ja"), }, // { // label: "Català", @@ -945,17 +954,17 @@ export function setSetting(setting: string, value: number): boolean { // }, { label: i18next.t("settings:back"), - handler: () => cancelHandler() - } + handler: () => cancelHandler(), + }, ], - maxOptions: 7 + maxOptions: 7, }); return false; } } break; case SettingKeys.Shop_Overlay_Opacity: - globalScene.updateShopOverlayOpacity(parseInt(Setting[index].options[value].value) * .01); + globalScene.updateShopOverlayOpacity(Number.parseInt(Setting[index].options[value].value) * 0.01); break; } diff --git a/src/system/trainer-data.ts b/src/system/trainer-data.ts index 134d16e25ef..48ab8d8d42a 100644 --- a/src/system/trainer-data.ts +++ b/src/system/trainer-data.ts @@ -9,9 +9,13 @@ export default class TrainerData { public partnerName: string; constructor(source: Trainer | any) { - const sourceTrainer = source instanceof Trainer ? source as Trainer : null; + const sourceTrainer = source instanceof Trainer ? (source as Trainer) : null; this.trainerType = sourceTrainer ? sourceTrainer.config.trainerType : source.trainerType; - this.variant = source.hasOwnProperty("variant") ? source.variant : source.female ? TrainerVariant.FEMALE : TrainerVariant.DEFAULT; + this.variant = source.hasOwnProperty("variant") + ? source.variant + : source.female + ? TrainerVariant.FEMALE + : TrainerVariant.DEFAULT; this.partyTemplateIndex = source.partyMemberTemplateIndex; this.name = source.name; this.partnerName = source.partnerName; diff --git a/src/system/unlockables.ts b/src/system/unlockables.ts index 0a666e2c755..2c396aad1f9 100644 --- a/src/system/unlockables.ts +++ b/src/system/unlockables.ts @@ -5,7 +5,7 @@ export enum Unlockables { ENDLESS_MODE, MINI_BLACK_HOLE, SPLICED_ENDLESS_MODE, - EVIOLITE + EVIOLITE, } export function getUnlockableName(unlockable: Unlockables) { diff --git a/src/system/version_migration/version_converter.ts b/src/system/version_migration/version_converter.ts index 98d340d03aa..3c5abc2cc18 100644 --- a/src/system/version_migration/version_converter.ts +++ b/src/system/version_migration/version_converter.ts @@ -10,7 +10,7 @@ import * as v1_1_0 from "./versions/v1_1_0"; // --- v1.7.0 PATCHES --- // import * as v1_7_0 from "./versions/v1_7_0"; -const LATEST_VERSION = version.split(".").map(value => parseInt(value)); +const LATEST_VERSION = version.split(".").map(value => Number.parseInt(value)); /** * Converts incoming {@linkcode SystemSaveData} that has a version below the @@ -23,7 +23,7 @@ const LATEST_VERSION = version.split(".").map(value => parseInt(value)); * @see {@link SystemVersionConverter} */ export function applySystemVersionMigration(data: SystemSaveData) { - const curVersion = data.gameVersion.split(".").map(value => parseInt(value)); + const curVersion = data.gameVersion.split(".").map(value => Number.parseInt(value)); if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) { const converter = new SystemVersionConverter(); @@ -43,7 +43,7 @@ export function applySystemVersionMigration(data: SystemSaveData) { * @see {@link SessionVersionConverter} */ export function applySessionVersionMigration(data: SessionSaveData) { - const curVersion = data.gameVersion.split(".").map(value => parseInt(value)); + const curVersion = data.gameVersion.split(".").map(value => Number.parseInt(value)); if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) { const converter = new SessionVersionConverter(); @@ -64,7 +64,7 @@ export function applySessionVersionMigration(data: SessionSaveData) { */ export function applySettingsVersionMigration(data: Object) { const gameVersion: string = data.hasOwnProperty("gameVersion") ? data["gameVersion"] : "1.0.0"; - const curVersion = gameVersion.split(".").map(value => parseInt(value)); + const curVersion = gameVersion.split(".").map(value => Number.parseInt(value)); if (!curVersion.every((value, index) => value === LATEST_VERSION[index])) { const converter = new SettingsVersionConverter(); @@ -101,8 +101,7 @@ abstract class VersionConverter { * body. * @param data The data to be operated on */ - applyStaticPreprocessors(_data: any): void { - } + applyStaticPreprocessors(_data: any): void {} /** * Uses the current version the incoming data to determine the starting point @@ -128,7 +127,7 @@ class SessionVersionConverter extends VersionConverter { } override applyMigration(data: SessionSaveData, curVersion: number[]): void { - const [ curMajor, curMinor, curPatch ] = curVersion; + const [curMajor, curMinor, curPatch] = curVersion; if (curMajor === 1) { if (curMinor === 0) { @@ -158,7 +157,7 @@ class SessionVersionConverter extends VersionConverter { */ class SystemVersionConverter extends VersionConverter { override applyMigration(data: SystemSaveData, curVersion: number[]): void { - const [ curMajor, curMinor, curPatch ] = curVersion; + const [curMajor, curMinor, curPatch] = curVersion; if (curMajor === 1) { if (curMinor === 0) { @@ -188,7 +187,7 @@ class SystemVersionConverter extends VersionConverter { */ class SettingsVersionConverter extends VersionConverter { override applyMigration(data: Object, curVersion: number[]): void { - const [ curMajor, curMinor, curPatch ] = curVersion; + const [curMajor, curMinor, curPatch] = curVersion; if (curMajor === 1) { if (curMinor === 0) { diff --git a/src/system/version_migration/versions/v1_0_4.ts b/src/system/version_migration/versions/v1_0_4.ts index 2795e940866..16bd9db9915 100644 --- a/src/system/version_migration/versions/v1_0_4.ts +++ b/src/system/version_migration/versions/v1_0_4.ts @@ -1,6 +1,6 @@ import { SettingKeys } from "#app/system/settings/settings"; -import type { SystemSaveData, SessionSaveData } from "#app/system/game-data"; -import { AbilityAttr, defaultStarterSpecies, DexAttr } from "#app/system/game-data"; +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"; @@ -12,8 +12,9 @@ export const systemMigrators = [ */ function migrateAbilityData(data: SystemSaveData) { if (data.starterData && data.dexData) { + // biome-ignore lint/complexity/noForEach: Object.keys(data.starterData).forEach(sd => { - if (data.dexData[sd]?.caughtAttr && (data.starterData[sd] && !data.starterData[sd].abilityAttr)) { + if (data.dexData[sd]?.caughtAttr && data.starterData[sd] && !data.starterData[sd].abilityAttr) { data.starterData[sd].abilityAttr = 1; } }); @@ -25,22 +26,44 @@ export const systemMigrators = [ * @param data {@linkcode SystemSaveData} */ function fixLegendaryStats(data: SystemSaveData) { - if (data.gameStats && (data.gameStats.legendaryPokemonCaught !== undefined && data.gameStats.subLegendaryPokemonCaught === undefined)) { + if ( + data.gameStats && + data.gameStats.legendaryPokemonCaught !== undefined && + data.gameStats.subLegendaryPokemonCaught === undefined + ) { data.gameStats.subLegendaryPokemonSeen = 0; data.gameStats.subLegendaryPokemonCaught = 0; data.gameStats.subLegendaryPokemonHatched = 0; - allSpecies.filter(s => s.subLegendary).forEach(s => { - const dexEntry = data.dexData[s.speciesId]; - data.gameStats.subLegendaryPokemonSeen += dexEntry.seenCount; - data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen - dexEntry.seenCount, 0); - data.gameStats.subLegendaryPokemonCaught += dexEntry.caughtCount; - data.gameStats.legendaryPokemonCaught = Math.max(data.gameStats.legendaryPokemonCaught - dexEntry.caughtCount, 0); - data.gameStats.subLegendaryPokemonHatched += dexEntry.hatchedCount; - data.gameStats.legendaryPokemonHatched = Math.max(data.gameStats.legendaryPokemonHatched - dexEntry.hatchedCount, 0); - }); - data.gameStats.subLegendaryPokemonSeen = Math.max(data.gameStats.subLegendaryPokemonSeen, data.gameStats.subLegendaryPokemonCaught); - data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen, data.gameStats.legendaryPokemonCaught); - data.gameStats.mythicalPokemonSeen = Math.max(data.gameStats.mythicalPokemonSeen, data.gameStats.mythicalPokemonCaught); + // biome-ignore lint/complexity/noForEach: + allSpecies + .filter(s => s.subLegendary) + .forEach(s => { + const dexEntry = data.dexData[s.speciesId]; + data.gameStats.subLegendaryPokemonSeen += dexEntry.seenCount; + data.gameStats.legendaryPokemonSeen = Math.max(data.gameStats.legendaryPokemonSeen - dexEntry.seenCount, 0); + data.gameStats.subLegendaryPokemonCaught += dexEntry.caughtCount; + data.gameStats.legendaryPokemonCaught = Math.max( + data.gameStats.legendaryPokemonCaught - dexEntry.caughtCount, + 0, + ); + data.gameStats.subLegendaryPokemonHatched += dexEntry.hatchedCount; + data.gameStats.legendaryPokemonHatched = Math.max( + data.gameStats.legendaryPokemonHatched - dexEntry.hatchedCount, + 0, + ); + }); + data.gameStats.subLegendaryPokemonSeen = Math.max( + data.gameStats.subLegendaryPokemonSeen, + data.gameStats.subLegendaryPokemonCaught, + ); + data.gameStats.legendaryPokemonSeen = Math.max( + data.gameStats.legendaryPokemonSeen, + data.gameStats.legendaryPokemonCaught, + ); + data.gameStats.mythicalPokemonSeen = Math.max( + data.gameStats.mythicalPokemonSeen, + data.gameStats.mythicalPokemonCaught, + ); } }, @@ -59,7 +82,7 @@ export const systemMigrators = [ } } } - } + }, ] as const; export const settingsMigrators = [ @@ -68,13 +91,16 @@ export const settingsMigrators = [ * SettingKeys.Shop_Cursor_Target}. * @param data the `settings` object */ + + // biome-ignore lint/complexity/noBannedTypes: TODO: fix the type to not be object... function fixRerollTarget(data: Object) { if (data.hasOwnProperty("REROLL_TARGET") && !data.hasOwnProperty(SettingKeys.Shop_Cursor_Target)) { data[SettingKeys.Shop_Cursor_Target] = data["REROLL_TARGET"]; + // biome-ignore lint/performance/noDelete: intentional delete data["REROLL_TARGET"]; localStorage.setItem("settings", JSON.stringify(data)); } - } + }, ] as const; export const sessionMigrators = [ @@ -85,7 +111,7 @@ export const sessionMigrators = [ * @param data {@linkcode SessionSaveData} */ function migrateModifiers(data: SessionSaveData) { - data.modifiers.forEach((m) => { + for (const m of data.modifiers) { if (m.className === "PokemonBaseStatModifier") { m.className = "BaseStatModifier"; } else if (m.className === "PokemonResetNegativeStatStageModifier") { @@ -102,13 +128,13 @@ export const sessionMigrators = [ m.typePregenArgs[0] = newStat; // From [ stat, battlesLeft ] to [ stat, maxBattles, battleCount ] - m.args = [ newStat, maxBattles, Math.min(m.args[1], maxBattles) ]; + m.args = [newStat, maxBattles, Math.min(m.args[1], maxBattles)]; } else { m.className = "TempCritBoosterModifier"; m.typePregenArgs = []; // From [ stat, battlesLeft ] to [ maxBattles, battleCount ] - m.args = [ maxBattles, Math.min(m.args[1], maxBattles) ]; + m.args = [maxBattles, Math.min(m.args[1], maxBattles)]; } } else if (m.className === "DoubleBattleChanceBoosterModifier" && m.args.length === 1) { let maxBattles: number; @@ -125,17 +151,17 @@ export const sessionMigrators = [ } // From [ battlesLeft ] to [ maxBattles, battleCount ] - m.args = [ maxBattles, Math.min(m.args[0], maxBattles) ]; + m.args = [maxBattles, Math.min(m.args[0], maxBattles)]; } - }); + } - data.enemyModifiers.forEach((m) => { + for (const m of data.enemyModifiers) { if (m.className === "PokemonBaseStatModifier") { m.className = "BaseStatModifier"; } else if (m.className === "PokemonResetNegativeStatStageModifier") { m.className = "ResetNegativeStatStageModifier"; } - }); + } }, /** * Converts old Pokemon natureOverride and mysteryEncounterData @@ -144,7 +170,7 @@ export const sessionMigrators = [ */ function migrateCustomPokemonDataAndNatureOverrides(data: SessionSaveData) { // Fix Pokemon nature overrides and custom data migration - data.party.forEach(pokemon => { + for (const pokemon of data.party) { if (pokemon["mysteryEncounterPokemonData"]) { pokemon.customPokemonData = new CustomPokemonData(pokemon["mysteryEncounterPokemonData"]); pokemon["mysteryEncounterPokemonData"] = null; @@ -158,6 +184,6 @@ export const sessionMigrators = [ pokemon.customPokemonData.nature = pokemon["natureOverride"]; pokemon["natureOverride"] = -1; } - }); - } + } + }, ] as const; diff --git a/src/system/version_migration/versions/v1_7_0.ts b/src/system/version_migration/versions/v1_7_0.ts index 3dcff3af241..167cd974e56 100644 --- a/src/system/version_migration/versions/v1_7_0.ts +++ b/src/system/version_migration/versions/v1_7_0.ts @@ -14,12 +14,15 @@ export const systemMigrators = [ Object.keys(data.starterData).forEach(sd => { const caughtAttr = data.dexData[sd]?.caughtAttr; const speciesNumber = Number(sd); - if (!speciesNumber) { // An unknown bug at some point in time caused some accounts to have starter data for pokedex number 0 which crashes + if (!speciesNumber) { + // An unknown bug at some point in time caused some accounts to have starter data for pokedex number 0 which crashes return; } const species = getPokemonSpecies(speciesNumber); if (caughtAttr && species.forms?.length > 1) { - const selectableForms = species.forms.filter((form, formIndex) => form.isStarterSelectable && (caughtAttr & globalScene.gameData.getFormAttr(formIndex))); + const selectableForms = species.forms.filter( + (form, formIndex) => form.isStarterSelectable && caughtAttr & globalScene.gameData.getFormAttr(formIndex), + ); if (selectableForms.length === 0) { data.dexData[sd].caughtAttr += DexAttr.DEFAULT_FORM; } @@ -33,9 +36,9 @@ export const settingsMigrators = [] as const; export const sessionMigrators = [ function migrateTera(data: SessionSaveData) { - for (let i = 0; i < data.modifiers.length;) { + for (let i = 0; i < data.modifiers.length; ) { if (data.modifiers[i].className === "TerastallizeModifier") { - data.party.forEach((p) => { + data.party.forEach(p => { if (p.id === data.modifiers[i].args[0]) { p.teraType = data.modifiers[i].args[1]; } @@ -46,9 +49,9 @@ export const sessionMigrators = [ } } - for (let i = 0; i < data.enemyModifiers.length;) { + for (let i = 0; i < data.enemyModifiers.length; ) { if (data.enemyModifiers[i].className === "TerastallizeModifier") { - data.enemyParty.forEach((p) => { + data.enemyParty.forEach(p => { if (p.id === data.enemyModifiers[i].args[0]) { p.teraType = data.enemyModifiers[i].args[1]; } @@ -70,5 +73,5 @@ export const sessionMigrators = [ p.teraType = getPokemonSpeciesForm(p.species, p.formIndex).type1; } }); - } + }, ] as const; diff --git a/src/system/voucher.ts b/src/system/voucher.ts index e6bee131797..39294bccf13 100644 --- a/src/system/voucher.ts +++ b/src/system/voucher.ts @@ -9,7 +9,7 @@ export enum VoucherType { REGULAR, PLUS, PREMIUM, - GOLDEN + GOLDEN, } export class Voucher { @@ -31,10 +31,10 @@ export class Voucher { /** * Get the name of the voucher - * @param playerGender - this is ignored here. It's only there to match the signature of the function in the Achv class + * @param _playerGender - this is ignored here. It's only there to match the signature of the function in the Achv class * @returns the name of the voucher */ - getName(playerGender: PlayerGender): string { + getName(_playerGender: PlayerGender): string { return getVoucherTypeName(this.voucherType); } @@ -89,32 +89,32 @@ export interface Vouchers { export const vouchers: Vouchers = {}; export function initVouchers() { - for (const achv of [ achvs.CLASSIC_VICTORY ]) { - const voucherType = achv.score >= 150 - ? VoucherType.GOLDEN - : achv.score >= 100 - ? VoucherType.PREMIUM - : achv.score >= 75 - ? VoucherType.PLUS - : VoucherType.REGULAR; + for (const achv of [achvs.CLASSIC_VICTORY]) { + const voucherType = + achv.score >= 150 + ? VoucherType.GOLDEN + : achv.score >= 100 + ? VoucherType.PREMIUM + : achv.score >= 75 + ? VoucherType.PLUS + : VoucherType.REGULAR; vouchers[achv.id] = new Voucher(voucherType, getAchievementDescription(achv.localizationKey)); } - const bossTrainerTypes = Object.keys(trainerConfigs) - .filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL && trainerConfigs[tt].hasVoucher); + const bossTrainerTypes = Object.keys(trainerConfigs).filter( + tt => + trainerConfigs[tt].isBoss && + trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL && + trainerConfigs[tt].hasVoucher, + ); for (const trainerType of bossTrainerTypes) { - const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10 - ? VoucherType.PLUS - : VoucherType.PREMIUM; + const voucherType = trainerConfigs[trainerType].moneyMultiplier < 10 ? VoucherType.PLUS : VoucherType.PREMIUM; const key = TrainerType[trainerType]; const trainerName = trainerConfigs[trainerType].name; const trainer = trainerConfigs[trainerType]; const title = trainer.title ? ` (${trainer.title})` : ""; - vouchers[key] = new Voucher( - voucherType, - `${i18next.t("voucher:defeatTrainer", { trainerName })} ${title}`, - ); + vouchers[key] = new Voucher(voucherType, `${i18next.t("voucher:defeatTrainer", { trainerName })} ${title}`); } const voucherKeys = Object.keys(vouchers); for (const k of voucherKeys) { diff --git a/src/timed-event-manager.ts b/src/timed-event-manager.ts index c12f9d569c0..80667b033ad 100644 --- a/src/timed-event-manager.ts +++ b/src/timed-event-manager.ts @@ -13,7 +13,7 @@ import { MysteryEncounterTier } from "./enums/mystery-encounter-tier"; export enum EventType { SHINY, NO_TIMER_DISPLAY, - LUCK + LUCK, } interface EventBanner { @@ -63,7 +63,7 @@ const timedEvents: TimedEvent[] = [ endDate: new Date(Date.UTC(2025, 0, 4, 0)), bannerKey: "winter_holidays2024-event-", scale: 0.21, - availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ], + availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN"], eventEncounters: [ { species: Species.GIMMIGHOUL, blockEvolution: true }, { species: Species.DELIBIRD }, @@ -84,17 +84,26 @@ const timedEvents: TimedEvent[] = [ { species: Species.SMOLIV }, { species: Species.ALOLA_VULPIX }, { species: Species.GALAR_DARUMAKA }, - { species: Species.IRON_BUNDLE } + { species: Species.IRON_BUNDLE }, ], - delibirdyBuff: [ "CATCHING_CHARM", "SHINY_CHARM", "ABILITY_CHARM", "EXP_CHARM", "SUPER_EXP_CHARM", "HEALING_CHARM" ], + delibirdyBuff: ["CATCHING_CHARM", "SHINY_CHARM", "ABILITY_CHARM", "EXP_CHARM", "SUPER_EXP_CHARM", "HEALING_CHARM"], weather: [{ weatherType: WeatherType.SNOW, weight: 1 }], mysteryEncounterTierChanges: [ - { mysteryEncounter: MysteryEncounterType.DELIBIRDY, tier: MysteryEncounterTier.COMMON }, + { + mysteryEncounter: MysteryEncounterType.DELIBIRDY, + tier: MysteryEncounterTier.COMMON, + }, { mysteryEncounter: MysteryEncounterType.PART_TIMER, disable: true }, - { mysteryEncounter: MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, disable: true }, + { + mysteryEncounter: MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, + disable: true, + }, { mysteryEncounter: MysteryEncounterType.FIELD_TRIP, disable: true }, - { mysteryEncounter: MysteryEncounterType.DEPARTMENT_STORE_SALE, disable: true } - ] + { + mysteryEncounter: MysteryEncounterType.DEPARTMENT_STORE_SALE, + disable: true, + }, + ], }, { name: "Year of the Snake", @@ -104,7 +113,7 @@ const timedEvents: TimedEvent[] = [ endDate: new Date(Date.UTC(2025, 1, 3, 0)), bannerKey: "yearofthesnakeevent-", scale: 0.21, - availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ], + availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN"], eventEncounters: [ { species: Species.EKANS }, { species: Species.ONIX }, @@ -120,32 +129,46 @@ const timedEvents: TimedEvent[] = [ { species: Species.DARUMAKA }, { species: Species.DRAMPA }, { species: Species.SILICOBRA }, - { species: Species.BLOODMOON_URSALUNA } + { species: Species.BLOODMOON_URSALUNA }, ], luckBoostedSpecies: [ - Species.EKANS, Species.ARBOK, - Species.ONIX, Species.STEELIX, - Species.DRATINI, Species.DRAGONAIR, Species.DRAGONITE, - Species.CLEFFA, Species.CLEFAIRY, Species.CLEFABLE, + Species.EKANS, + Species.ARBOK, + Species.ONIX, + Species.STEELIX, + Species.DRATINI, + Species.DRAGONAIR, + Species.DRAGONITE, + Species.CLEFFA, + Species.CLEFAIRY, + Species.CLEFABLE, Species.UMBREON, - Species.DUNSPARCE, Species.DUDUNSPARCE, - Species.TEDDIURSA, Species.URSARING, Species.URSALUNA, + Species.DUNSPARCE, + Species.DUDUNSPARCE, + Species.TEDDIURSA, + Species.URSARING, + Species.URSALUNA, Species.SEVIPER, Species.LUNATONE, Species.RAYQUAZA, - Species.CHINGLING, Species.CHIMECHO, + Species.CHINGLING, + Species.CHIMECHO, Species.CRESSELIA, Species.DARKRAI, - Species.SNIVY, Species.SERVINE, Species.SERPERIOR, - Species.DARUMAKA, Species.DARMANITAN, + Species.SNIVY, + Species.SERVINE, + Species.SERPERIOR, + Species.DARUMAKA, + Species.DARMANITAN, Species.ZYGARDE, Species.DRAMPA, Species.LUNALA, Species.BLACEPHALON, - Species.SILICOBRA, Species.SANDACONDA, + Species.SILICOBRA, + Species.SANDACONDA, Species.ROARING_MOON, - Species.BLOODMOON_URSALUNA - ] + Species.BLOODMOON_URSALUNA, + ], }, { name: "Valentine", @@ -156,7 +179,7 @@ const timedEvents: TimedEvent[] = [ shinyMultiplier: 2, bannerKey: "valentines2025event-", scale: 0.21, - availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ], + availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN"], eventEncounters: [ { species: Species.NIDORAN_F }, { species: Species.NIDORAN_M }, @@ -177,9 +200,9 @@ const timedEvents: TimedEvent[] = [ { species: Species.MILCERY }, { species: Species.INDEEDEE }, { species: Species.TANDEMAUS }, - { species: Species.ENAMORUS } + { species: Species.ENAMORUS }, ], - luckBoostedSpecies: [ Species.LUVDISC ] + luckBoostedSpecies: [Species.LUVDISC], }, { name: "PKMNDAY2025", @@ -189,35 +212,48 @@ const timedEvents: TimedEvent[] = [ classicFriendshipMultiplier: 4, bannerKey: "pkmnday2025event-", scale: 0.21, - availableLangs: [ "en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN" ], + availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es-ES", "pt-BR", "zh-CN"], eventEncounters: [ { species: Species.PIKACHU, formIndex: 1, blockEvolution: true }, // Partner Form { species: Species.EEVEE, formIndex: 1, blockEvolution: true }, // Partner Form { species: Species.CHIKORITA }, { species: Species.TOTODILE }, - { species: Species.TEPIG } + { species: Species.TEPIG }, ], luckBoostedSpecies: [ - Species.PICHU, Species.PIKACHU, Species.RAICHU, Species.ALOLA_RAICHU, - Species.PSYDUCK, Species.GOLDUCK, - Species.EEVEE, Species.FLAREON, Species.JOLTEON, Species.VAPOREON, Species.ESPEON, Species.UMBREON, Species.LEAFEON, Species.GLACEON, Species.SYLVEON, - Species.CHIKORITA, Species.BAYLEEF, Species.MEGANIUM, - Species.TOTODILE, Species.CROCONAW, Species.FERALIGATR, - Species.TEPIG, Species.PIGNITE, Species.EMBOAR, + Species.PICHU, + Species.PIKACHU, + Species.RAICHU, + Species.ALOLA_RAICHU, + Species.PSYDUCK, + Species.GOLDUCK, + Species.EEVEE, + Species.FLAREON, + Species.JOLTEON, + Species.VAPOREON, + Species.ESPEON, + Species.UMBREON, + Species.LEAFEON, + Species.GLACEON, + Species.SYLVEON, + Species.CHIKORITA, + Species.BAYLEEF, + Species.MEGANIUM, + Species.TOTODILE, + Species.CROCONAW, + Species.FERALIGATR, + Species.TEPIG, + Species.PIGNITE, + Species.EMBOAR, Species.ZYGARDE, - Species.ETERNAL_FLOETTE - ] - } + Species.ETERNAL_FLOETTE, + ], + }, ]; export class TimedEventManager { - constructor() {} - isActive(event: TimedEvent) { - return ( - event.startDate < new Date() && - new Date() < event.endDate - ); + return event.startDate < new Date() && new Date() < event.endDate; } activeEvent(): TimedEvent | undefined { @@ -229,16 +265,16 @@ export class TimedEventManager { } activeEventHasBanner(): boolean { - const activeEvents = timedEvents.filter((te) => this.isActive(te) && te.hasOwnProperty("bannerFilename")); + const activeEvents = timedEvents.filter(te => this.isActive(te) && te.hasOwnProperty("bannerFilename")); return activeEvents.length > 0; } getShinyMultiplier(): number { let multiplier = 1; - const shinyEvents = timedEvents.filter((te) => te.eventType === EventType.SHINY && this.isActive(te)); - shinyEvents.forEach((se) => { + const shinyEvents = timedEvents.filter(te => te.eventType === EventType.SHINY && this.isActive(te)); + for (const se of shinyEvents) { multiplier *= se.shinyMultiplier ?? 1; - }); + } return multiplier; } @@ -249,11 +285,13 @@ export class TimedEventManager { getEventEncounters(): EventEncounter[] { const ret: EventEncounter[] = []; - timedEvents.filter((te) => this.isActive(te)).map((te) => { - if (!isNullOrUndefined(te.eventEncounters)) { - ret.push(...te.eventEncounters); - } - }); + timedEvents + .filter(te => this.isActive(te)) + .map(te => { + if (!isNullOrUndefined(te.eventEncounters)) { + ret.push(...te.eventEncounters); + } + }); return ret; } @@ -263,12 +301,12 @@ export class TimedEventManager { */ getClassicFriendshipMultiplier(): number { let multiplier = CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER; - const classicFriendshipEvents = timedEvents.filter((te) => this.isActive(te)); - classicFriendshipEvents.forEach((fe) => { + const classicFriendshipEvents = timedEvents.filter(te => this.isActive(te)); + for (const fe of classicFriendshipEvents) { if (!isNullOrUndefined(fe.classicFriendshipMultiplier) && fe.classicFriendshipMultiplier > multiplier) { multiplier = fe.classicFriendshipMultiplier; } - }); + } return multiplier; } @@ -277,7 +315,7 @@ export class TimedEventManager { * @returns Whether vouchers should be upgraded */ getUpgradeUnlockedVouchers(): boolean { - return timedEvents.some((te) => this.isActive(te) && (te.upgradeUnlockedVouchers ?? false)); + return timedEvents.some(te => this.isActive(te) && (te.upgradeUnlockedVouchers ?? false)); } /** @@ -286,11 +324,13 @@ export class TimedEventManager { */ getDelibirdyBuff(): string[] { const ret: string[] = []; - timedEvents.filter((te) => this.isActive(te)).map((te) => { - if (!isNullOrUndefined(te.delibirdyBuff)) { - ret.push(...te.delibirdyBuff); - } - }); + timedEvents + .filter(te => this.isActive(te)) + .map(te => { + if (!isNullOrUndefined(te.delibirdyBuff)) { + ret.push(...te.delibirdyBuff); + } + }); return ret; } @@ -300,69 +340,82 @@ export class TimedEventManager { */ getWeather(): WeatherPoolEntry[] { const ret: WeatherPoolEntry[] = []; - timedEvents.filter((te) => this.isActive(te)).map((te) => { - if (!isNullOrUndefined(te.weather)) { - ret.push(...te.weather); - } - }); + timedEvents + .filter(te => this.isActive(te)) + .map(te => { + if (!isNullOrUndefined(te.weather)) { + ret.push(...te.weather); + } + }); return ret; } getAllMysteryEncounterChanges(): EventMysteryEncounterTier[] { const ret: EventMysteryEncounterTier[] = []; - timedEvents.filter((te) => this.isActive(te)).map((te) => { - if (!isNullOrUndefined(te.mysteryEncounterTierChanges)) { - ret.push(...te.mysteryEncounterTierChanges); - } - }); + timedEvents + .filter(te => this.isActive(te)) + .map(te => { + if (!isNullOrUndefined(te.mysteryEncounterTierChanges)) { + ret.push(...te.mysteryEncounterTierChanges); + } + }); return ret; } getEventMysteryEncountersDisabled(): MysteryEncounterType[] { const ret: MysteryEncounterType[] = []; - timedEvents.filter((te) => this.isActive(te) && !isNullOrUndefined(te.mysteryEncounterTierChanges)).map((te) => { - te.mysteryEncounterTierChanges?.map((metc) => { - if (metc.disable) { - ret.push(metc.mysteryEncounter); - } + timedEvents + .filter(te => this.isActive(te) && !isNullOrUndefined(te.mysteryEncounterTierChanges)) + .map(te => { + te.mysteryEncounterTierChanges?.map(metc => { + if (metc.disable) { + ret.push(metc.mysteryEncounter); + } + }); }); - }); return ret; } - getMysteryEncounterTierForEvent(encounterType: MysteryEncounterType, normal: MysteryEncounterTier): MysteryEncounterTier { + getMysteryEncounterTierForEvent( + encounterType: MysteryEncounterType, + normal: MysteryEncounterTier, + ): MysteryEncounterTier { let ret = normal; - timedEvents.filter((te) => this.isActive(te) && !isNullOrUndefined(te.mysteryEncounterTierChanges)).map((te) => { - te.mysteryEncounterTierChanges?.map((metc) => { - if (metc.mysteryEncounter === encounterType) { - ret = metc.tier ?? normal; - } + timedEvents + .filter(te => this.isActive(te) && !isNullOrUndefined(te.mysteryEncounterTierChanges)) + .map(te => { + te.mysteryEncounterTierChanges?.map(metc => { + if (metc.mysteryEncounter === encounterType) { + ret = metc.tier ?? normal; + } + }); }); - }); return ret; } getEventLuckBoost(): number { let ret = 0; - const luckEvents = timedEvents.filter((te) => this.isActive(te) && !isNullOrUndefined(te.luckBoost)); - luckEvents.forEach((le) => { + const luckEvents = timedEvents.filter(te => this.isActive(te) && !isNullOrUndefined(te.luckBoost)); + for (const le of luckEvents) { ret += le.luckBoost!; - }); + } return ret; } getEventLuckBoostedSpecies(): Species[] { const ret: Species[] = []; - timedEvents.filter((te) => this.isActive(te)).map((te) => { - if (!isNullOrUndefined(te.luckBoostedSpecies)) { - ret.push(...te.luckBoostedSpecies.filter(s => !ret.includes(s))); - } - }); + timedEvents + .filter(te => this.isActive(te)) + .map(te => { + if (!isNullOrUndefined(te.luckBoostedSpecies)) { + ret.push(...te.luckBoostedSpecies.filter(s => !ret.includes(s))); + } + }); return ret; } areFusionsBoosted(): boolean { - return timedEvents.some((te) => this.isActive(te) && te.boostFusions); + return timedEvents.some(te => this.isActive(te) && te.boostFusions); } } @@ -399,7 +452,7 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container { setup() { const lang = i18next.resolvedLanguage; - if (this.event && this.event.bannerKey) { + if (this.event?.bannerKey) { let key = this.event.bannerKey; if (lang && this.event.availableLangs && this.event.availableLangs.length > 0) { if (this.event.availableLangs.includes(lang)) { @@ -421,7 +474,7 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container { this.banner.x, this.banner.y + 2, this.timeToGo(this.event.endDate), - TextStyle.WINDOW + TextStyle.WINDOW, ); this.eventTimerText.setName("text-event-timer"); this.eventTimerText.setScale(0.15); @@ -449,7 +502,6 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container { } private timeToGo(date: Date) { - // Utility to add leading zero function z(n) { return (n < 10 ? "0" : "") + n; @@ -461,13 +513,18 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container { diff = Math.abs(diff); // Get time components - const days = diff / 8.64e7 | 0; - const hours = diff % 8.64e7 / 3.6e6 | 0; - const mins = diff % 3.6e6 / 6e4 | 0; - const secs = Math.round(diff % 6e4 / 1e3); + const days = (diff / 8.64e7) | 0; + const hours = ((diff % 8.64e7) / 3.6e6) | 0; + const mins = ((diff % 3.6e6) / 6e4) | 0; + const secs = Math.round((diff % 6e4) / 1e3); // Return formatted string - return i18next.t("menu:eventTimer", { days: z(days), hours: z(hours), mins: z(mins), secs: z(secs) }); + return i18next.t("menu:eventTimer", { + days: z(days), + hours: z(hours), + mins: z(mins), + secs: z(secs), + }); } updateCountdown() { diff --git a/src/touch-controls.ts b/src/touch-controls.ts index db2ae223d3f..e2b5ad05baa 100644 --- a/src/touch-controls.ts +++ b/src/touch-controls.ts @@ -9,9 +9,9 @@ export default class TouchControl { private buttonLock: string[] = new Array(); private inputInterval: NodeJS.Timeout[] = new Array(); /** Whether touch controls are disabled */ - private disabled: boolean = false; + private disabled = false; /** Whether the last touch event has finished before disabling */ - private finishedLastTouch: boolean = false; + private finishedLastTouch = false; constructor() { this.events = globalScene.game.events; @@ -23,12 +23,12 @@ export default class TouchControl { */ disable() { this.disabled = true; - this.finishedLastTouch = false; + this.finishedLastTouch = false; } /** * Enable touch controls - */ + */ enable() { this.disabled = false; this.finishedLastTouch = false; @@ -39,7 +39,7 @@ export default class TouchControl { */ init() { this.preventElementZoom(document.querySelector("#dpad")); - document.querySelectorAll(".apad-button").forEach((element) => this.preventElementZoom(element as HTMLElement)); + document.querySelectorAll(".apad-button").forEach(element => this.preventElementZoom(element as HTMLElement)); // Select all elements with the 'data-key' attribute and bind keys to them for (const button of document.querySelectorAll("[data-key]")) { // @ts-ignore - Bind the key to the button using the dataset key @@ -87,11 +87,10 @@ export default class TouchControl { }, repeatInputDelayMillis); this.buttonLock.push(key); node.classList.add("active"); - } touchButtonUp(node: HTMLElement, key: string, id: string) { - if (!this.buttonLock.includes(key) || this.disabled && this.finishedLastTouch) { + if (!this.buttonLock.includes(key) || (this.disabled && this.finishedLastTouch)) { return; } this.finishedLastTouch = true; @@ -126,14 +125,14 @@ export default class TouchControl { this.events.emit("input_down", { controller_type: "keyboard", button: button, - isTouch: true + isTouch: true, }); break; case "keyup": this.events.emit("input_up", { controller_type: "keyboard", button: button, - isTouch: true + isTouch: true, }); break; } @@ -151,7 +150,6 @@ export default class TouchControl { return; } element.addEventListener("touchstart", (event: TouchEvent) => { - if (!(event.currentTarget instanceof HTMLElement)) { return; } @@ -175,8 +173,8 @@ export default class TouchControl { } /** - * Deactivates all currently pressed keys. - */ + * Deactivates all currently pressed keys. + */ deactivatePressedKey(): void { for (const key of Object.keys(this.inputInterval)) { clearInterval(this.inputInterval[key]); @@ -204,9 +202,16 @@ export function hasTouchscreen(): boolean { */ export function isMobile(): boolean { let ret = false; - (function (a) { + (a => { // Check the user agent string against a regex for mobile devices - if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) { + if ( + /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test( + a, + ) || + /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( + a.substr(0, 4), + ) + ) { ret = true; } })(navigator.userAgent || navigator.vendor || window["opera"]); diff --git a/src/tutorial.ts b/src/tutorial.ts index 6890075a642..82912f73979 100644 --- a/src/tutorial.ts +++ b/src/tutorial.ts @@ -14,7 +14,7 @@ export enum Tutorial { Pokerus = "POKERUS", Stat_Change = "STAT_CHANGE", Select_Item = "SELECT_ITEM", - Egg_Gacha = "EGG_GACHA" + Egg_Gacha = "EGG_GACHA", } const tutorialHandlers = { @@ -28,40 +28,93 @@ const tutorialHandlers = { if (globalScene.enableTouchControls) { return resolve(); } - globalScene.showFieldOverlay(1000).then(() => globalScene.ui.showText(i18next.t("tutorial:accessMenu"), null, () => globalScene.hideFieldOverlay(1000).then(() => resolve()), null, true)); + globalScene + .showFieldOverlay(1000) + .then(() => + globalScene.ui.showText( + i18next.t("tutorial:accessMenu"), + null, + () => globalScene.hideFieldOverlay(1000).then(() => resolve()), + null, + true, + ), + ); }); }, [Tutorial.Menu]: () => { return new Promise(resolve => { globalScene.gameData.saveTutorialFlag(Tutorial.Access_Menu, true); - globalScene.ui.showText(i18next.t("tutorial:menu"), null, () => globalScene.ui.showText("", null, () => resolve()), null, true); + globalScene.ui.showText( + i18next.t("tutorial:menu"), + null, + () => globalScene.ui.showText("", null, () => resolve()), + null, + true, + ); }); }, [Tutorial.Starter_Select]: () => { return new Promise(resolve => { - globalScene.ui.showText(i18next.t("tutorial:starterSelect"), null, () => globalScene.ui.showText("", null, () => resolve()), null, true); + globalScene.ui.showText( + i18next.t("tutorial:starterSelect"), + null, + () => globalScene.ui.showText("", null, () => resolve()), + null, + true, + ); }); }, [Tutorial.Pokerus]: () => { return new Promise(resolve => { - globalScene.ui.showText(i18next.t("tutorial:pokerus"), null, () => globalScene.ui.showText("", null, () => resolve()), null, true); + globalScene.ui.showText( + i18next.t("tutorial:pokerus"), + null, + () => globalScene.ui.showText("", null, () => resolve()), + null, + true, + ); }); }, [Tutorial.Stat_Change]: () => { return new Promise(resolve => { - globalScene.showFieldOverlay(1000).then(() => globalScene.ui.showText(i18next.t("tutorial:statChange"), null, () => globalScene.ui.showText("", null, () => globalScene.hideFieldOverlay(1000).then(() => resolve())), null, true)); + globalScene + .showFieldOverlay(1000) + .then(() => + globalScene.ui.showText( + i18next.t("tutorial:statChange"), + null, + () => globalScene.ui.showText("", null, () => globalScene.hideFieldOverlay(1000).then(() => resolve())), + null, + true, + ), + ); }); }, [Tutorial.Select_Item]: () => { return new Promise(resolve => { globalScene.ui.setModeWithoutClear(Mode.MESSAGE).then(() => { - globalScene.ui.showText(i18next.t("tutorial:selectItem"), null, () => globalScene.ui.showText("", null, () => globalScene.ui.setModeWithoutClear(Mode.MODIFIER_SELECT).then(() => resolve())), null, true); + globalScene.ui.showText( + i18next.t("tutorial:selectItem"), + null, + () => + globalScene.ui.showText("", null, () => + globalScene.ui.setModeWithoutClear(Mode.MODIFIER_SELECT).then(() => resolve()), + ), + null, + true, + ); }); }); }, [Tutorial.Egg_Gacha]: () => { return new Promise(resolve => { - globalScene.ui.showText(i18next.t("tutorial:eggGacha"), null, () => globalScene.ui.showText("", null, () => resolve()), null, true); + globalScene.ui.showText( + i18next.t("tutorial:eggGacha"), + null, + () => globalScene.ui.showText("", null, () => resolve()), + null, + true, + ); }); }, }; @@ -119,7 +172,7 @@ async function showTutorialOverlay(handler: UiHandler) { ease: "Sine.easeOut", onComplete: () => { return true; - } + }, }); } else { return true; @@ -140,10 +193,9 @@ async function hideTutorialOverlay(handler: UiHandler) { ease: "Sine.easeOut", onComplete: () => { return true; - } + }, }); } else { return true; } } - diff --git a/src/ui-inputs.ts b/src/ui-inputs.ts index d5c4529470b..c9898f9b71e 100644 --- a/src/ui-inputs.ts +++ b/src/ui-inputs.ts @@ -45,23 +45,31 @@ export class UiInputs { } listenInputs(): void { - this.events.on("input_down", (event) => { - this.detectInputMethod(event); + this.events.on( + "input_down", + event => { + this.detectInputMethod(event); - const actions = this.getActionsKeyDown(); - if (!actions.hasOwnProperty(event.button)) { - return; - } - actions[event.button](); - }, this); + const actions = this.getActionsKeyDown(); + if (!actions.hasOwnProperty(event.button)) { + return; + } + actions[event.button](); + }, + this, + ); - this.events.on("input_up", (event) => { - const actions = this.getActionsKeyUp(); - if (!actions.hasOwnProperty(event.button)) { - return; - } - actions[event.button](); - }, this); + this.events.on( + "input_up", + event => { + const actions = this.getActionsKeyUp(); + if (!actions.hasOwnProperty(event.button)) { + return; + } + actions[event.button](); + }, + this, + ); } doVibration(inputSuccess: boolean, vibrationLength: number): void { @@ -72,46 +80,46 @@ export class UiInputs { getActionsKeyDown(): ActionKeys { const actions: ActionKeys = { - [Button.UP]: () => this.buttonDirection(Button.UP), - [Button.DOWN]: () => this.buttonDirection(Button.DOWN), - [Button.LEFT]: () => this.buttonDirection(Button.LEFT), - [Button.RIGHT]: () => this.buttonDirection(Button.RIGHT), - [Button.SUBMIT]: () => this.buttonTouch(), - [Button.ACTION]: () => this.buttonAb(Button.ACTION), - [Button.CANCEL]: () => this.buttonAb(Button.CANCEL), - [Button.MENU]: () => this.buttonMenu(), - [Button.STATS]: () => this.buttonGoToFilter(Button.STATS), - [Button.CYCLE_SHINY]: () => this.buttonCycleOption(Button.CYCLE_SHINY), - [Button.CYCLE_FORM]: () => this.buttonCycleOption(Button.CYCLE_FORM), - [Button.CYCLE_GENDER]: () => this.buttonCycleOption(Button.CYCLE_GENDER), - [Button.CYCLE_ABILITY]: () => this.buttonCycleOption(Button.CYCLE_ABILITY), - [Button.CYCLE_NATURE]: () => this.buttonCycleOption(Button.CYCLE_NATURE), - [Button.CYCLE_TERA]: () => this.buttonCycleOption(Button.CYCLE_TERA), - [Button.SPEED_UP]: () => this.buttonSpeedChange(), - [Button.SLOW_DOWN]: () => this.buttonSpeedChange(false), + [Button.UP]: () => this.buttonDirection(Button.UP), + [Button.DOWN]: () => this.buttonDirection(Button.DOWN), + [Button.LEFT]: () => this.buttonDirection(Button.LEFT), + [Button.RIGHT]: () => this.buttonDirection(Button.RIGHT), + [Button.SUBMIT]: () => this.buttonTouch(), + [Button.ACTION]: () => this.buttonAb(Button.ACTION), + [Button.CANCEL]: () => this.buttonAb(Button.CANCEL), + [Button.MENU]: () => this.buttonMenu(), + [Button.STATS]: () => this.buttonGoToFilter(Button.STATS), + [Button.CYCLE_SHINY]: () => this.buttonCycleOption(Button.CYCLE_SHINY), + [Button.CYCLE_FORM]: () => this.buttonCycleOption(Button.CYCLE_FORM), + [Button.CYCLE_GENDER]: () => this.buttonCycleOption(Button.CYCLE_GENDER), + [Button.CYCLE_ABILITY]: () => this.buttonCycleOption(Button.CYCLE_ABILITY), + [Button.CYCLE_NATURE]: () => this.buttonCycleOption(Button.CYCLE_NATURE), + [Button.CYCLE_TERA]: () => this.buttonCycleOption(Button.CYCLE_TERA), + [Button.SPEED_UP]: () => this.buttonSpeedChange(), + [Button.SLOW_DOWN]: () => this.buttonSpeedChange(false), }; return actions; } getActionsKeyUp(): ActionKeys { const actions: ActionKeys = { - [Button.UP]: () => undefined, - [Button.DOWN]: () => undefined, - [Button.LEFT]: () => undefined, - [Button.RIGHT]: () => undefined, - [Button.SUBMIT]: () => undefined, - [Button.ACTION]: () => undefined, - [Button.CANCEL]: () => undefined, - [Button.MENU]: () => undefined, - [Button.STATS]: () => this.buttonStats(false), - [Button.CYCLE_SHINY]: () => undefined, - [Button.CYCLE_FORM]: () => undefined, - [Button.CYCLE_GENDER]: () => undefined, - [Button.CYCLE_ABILITY]: () => undefined, - [Button.CYCLE_NATURE]: () => undefined, - [Button.CYCLE_TERA]: () => this.buttonInfo(false), - [Button.SPEED_UP]: () => undefined, - [Button.SLOW_DOWN]: () => undefined, + [Button.UP]: () => undefined, + [Button.DOWN]: () => undefined, + [Button.LEFT]: () => undefined, + [Button.RIGHT]: () => undefined, + [Button.SUBMIT]: () => undefined, + [Button.ACTION]: () => undefined, + [Button.CANCEL]: () => undefined, + [Button.MENU]: () => undefined, + [Button.STATS]: () => this.buttonStats(false), + [Button.CYCLE_SHINY]: () => undefined, + [Button.CYCLE_FORM]: () => undefined, + [Button.CYCLE_GENDER]: () => undefined, + [Button.CYCLE_ABILITY]: () => undefined, + [Button.CYCLE_NATURE]: () => undefined, + [Button.CYCLE_TERA]: () => this.buttonInfo(false), + [Button.SPEED_UP]: () => undefined, + [Button.SLOW_DOWN]: () => undefined, }; return actions; } @@ -130,7 +138,7 @@ export class UiInputs { globalScene.ui.processInput(Button.SUBMIT) || globalScene.ui.processInput(Button.ACTION); } - buttonStats(pressed: boolean = true): void { + buttonStats(pressed = true): void { // allow access to Button.STATS as a toggle for other elements for (const t of globalScene.getInfoToggles(true)) { t.toggleInfo(pressed); @@ -142,7 +150,7 @@ export class UiInputs { } buttonGoToFilter(button: Button): void { - const whitelist = [ StarterSelectUiHandler, PokedexUiHandler, PokedexPageUiHandler ]; + const whitelist = [StarterSelectUiHandler, PokedexUiHandler, PokedexPageUiHandler]; const uiHandler = globalScene.ui?.getHandler(); if (whitelist.some(handler => uiHandler instanceof handler)) { globalScene.ui.processInput(button); @@ -151,8 +159,8 @@ export class UiInputs { } } - buttonInfo(pressed: boolean = true): void { - if (globalScene.showMovesetFlyout ) { + buttonInfo(pressed = true): void { + if (globalScene.showMovesetFlyout) { for (const p of globalScene.getField().filter(p => p?.isActive(true))) { p.toggleFlyout(pressed); } @@ -193,7 +201,17 @@ export class UiInputs { } buttonCycleOption(button: Button): void { - const whitelist = [ StarterSelectUiHandler, PokedexUiHandler, PokedexPageUiHandler, SettingsUiHandler, RunInfoUiHandler, SettingsDisplayUiHandler, SettingsAudioUiHandler, SettingsGamepadUiHandler, SettingsKeyboardUiHandler ]; + const whitelist = [ + StarterSelectUiHandler, + PokedexUiHandler, + PokedexPageUiHandler, + SettingsUiHandler, + RunInfoUiHandler, + SettingsDisplayUiHandler, + SettingsAudioUiHandler, + SettingsGamepadUiHandler, + SettingsKeyboardUiHandler, + ]; const uiHandler = globalScene.ui?.getHandler(); if (whitelist.some(handler => uiHandler instanceof handler)) { globalScene.ui.processInput(button); @@ -205,16 +223,24 @@ export class UiInputs { buttonSpeedChange(up = true): void { const settingGameSpeed = settingIndex(SettingKeys.Game_Speed); if (up && globalScene.gameSpeed < 5) { - globalScene.gameData.saveSetting(SettingKeys.Game_Speed, Setting[settingGameSpeed].options.findIndex((item) => item.label === `${globalScene.gameSpeed}x`) + 1); + globalScene.gameData.saveSetting( + SettingKeys.Game_Speed, + Setting[settingGameSpeed].options.findIndex(item => item.label === `${globalScene.gameSpeed}x`) + 1, + ); if (globalScene.ui?.getMode() === Mode.SETTINGS) { (globalScene.ui.getHandler() as SettingsUiHandler).show([]); } } else if (!up && globalScene.gameSpeed > 1) { - globalScene.gameData.saveSetting(SettingKeys.Game_Speed, Math.max(Setting[settingGameSpeed].options.findIndex((item) => item.label === `${globalScene.gameSpeed}x`) - 1, 0)); + globalScene.gameData.saveSetting( + SettingKeys.Game_Speed, + Math.max( + Setting[settingGameSpeed].options.findIndex(item => item.label === `${globalScene.gameSpeed}x`) - 1, + 0, + ), + ); if (globalScene.ui?.getMode() === Mode.SETTINGS) { (globalScene.ui.getHandler() as SettingsUiHandler).show([]); } } } - } diff --git a/src/ui/ability-bar.ts b/src/ui/ability-bar.ts index 8335f7b517c..7fe9c0d8052 100644 --- a/src/ui/ability-bar.ts +++ b/src/ui/ability-bar.ts @@ -27,7 +27,9 @@ export default class AbilityBar extends Phaser.GameObjects.Container { this.add(this.bg); - this.abilityBarText = addTextObject(15, 3, "", TextStyle.MESSAGE, { fontSize: "72px" }); + this.abilityBarText = addTextObject(15, 3, "", TextStyle.MESSAGE, { + fontSize: "72px", + }); this.abilityBarText.setOrigin(0, 0); this.abilityBarText.setWordWrapWidth(600, true); this.add(this.abilityBarText); @@ -36,8 +38,10 @@ export default class AbilityBar extends Phaser.GameObjects.Container { this.shown = false; } - showAbility(pokemon: Pokemon, passive: boolean = false): void { - this.abilityBarText.setText(`${i18next.t("fightUiHandler:abilityFlyInText", { pokemonName: getPokemonNameWithAffix(pokemon), passive: passive ? i18next.t("fightUiHandler:passive") : "", abilityName: !passive ? pokemon.getAbility().name : pokemon.getPassiveAbility().name })}`); + showAbility(pokemon: Pokemon, passive = false): void { + this.abilityBarText.setText( + `${i18next.t("fightUiHandler:abilityFlyInText", { pokemonName: getPokemonNameWithAffix(pokemon), passive: passive ? i18next.t("fightUiHandler:passive") : "", abilityName: !passive ? pokemon.getAbility().name : pokemon.getPassiveAbility().name })}`, + ); if (this.shown) { return; @@ -45,7 +49,6 @@ export default class AbilityBar extends Phaser.GameObjects.Container { globalScene.fieldUI.bringToTop(this); - this.y = baseY + (globalScene.currentBattle.double ? 14 : 0); this.tween = globalScene.tweens.add({ targets: this, @@ -55,7 +58,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container { onComplete: () => { this.tween = null; this.resetAutoHideTimer(); - } + }, }); this.setVisible(true); @@ -83,7 +86,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container { onComplete: () => { this.tween = null; this.setVisible(false); - } + }, }); this.shown = false; diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index a462ed158cb..f605f73e171 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -44,10 +44,10 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { protected blockInput: boolean; - protected scrollCursor: number = 0; - protected fullCursor: number = 0; + protected scrollCursor = 0; + protected fullCursor = 0; - protected scale: number = 0.1666666667; + protected scale = 0.1666666667; private cursorObj: Phaser.GameObjects.Image | null; @@ -56,7 +56,6 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { protected defaultTextStyle: TextStyle = TextStyle.WINDOW; protected textContent: string; - constructor(mode: Mode | null) { super(mode); } @@ -70,7 +69,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { setup() { const ui = this.getUi(); - this.optionSelectContainer = globalScene.add.container((globalScene.game.canvas.width / 6) - 1, -48); + 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.setVisible(false); ui.add(this.optionSelectContainer); @@ -114,31 +113,49 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { this.optionSelectIcons.splice(0, this.optionSelectIcons.length); } - const optionsWithScroll = (this.config?.options && this.config?.options.length > (this.config?.maxOptions!)) ? this.getOptionsWithScroll() : options; + const optionsWithScroll = + this.config?.options && this.config?.options.length > this.config?.maxOptions! + ? this.getOptionsWithScroll() + : options; // 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; this.optionSelectText = addBBCodeTextObject( - 0, 0, optionsForWidth.map(o => o.item - ? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}] ${o.label}[/color][/shadow]` - : `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}]${o.label}[/color][/shadow]` - ).join("\n"), - TextStyle.WINDOW, { maxLines: options.length, lineSpacing: 12 } + 0, + 0, + optionsForWidth + .map(o => + o.item + ? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}] ${o.label}[/color][/shadow]` + : `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}]${o.label}[/color][/shadow]`, + ) + .join("\n"), + TextStyle.WINDOW, + { maxLines: options.length, lineSpacing: 12 }, ); this.optionSelectText.setOrigin(0, 0); this.optionSelectText.setName("text-option-select"); this.optionSelectTextContainer.add(this.optionSelectText); - this.optionSelectContainer.setPosition((globalScene.game.canvas.width / 6) - 1 - (this.config?.xOffset || 0), -48 + (this.config?.yOffset || 0)); + this.optionSelectContainer.setPosition( + globalScene.game.canvas.width / 6 - 1 - (this.config?.xOffset || 0), + -48 + (this.config?.yOffset || 0), + ); this.optionSelectBg.width = Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth()); this.optionSelectBg.height = this.getWindowHeight(); - this.optionSelectTextContainer.setPosition(this.optionSelectBg.x - this.optionSelectBg.width + 12 + 24 * this.scale, this.optionSelectBg.y - this.optionSelectBg.height + 2 + 42 * this.scale); + this.optionSelectTextContainer.setPosition( + this.optionSelectBg.x - this.optionSelectBg.width + 12 + 24 * this.scale, + this.optionSelectBg.y - this.optionSelectBg.height + 2 + 42 * this.scale, + ); // Now that the container and background widths are established, we can set up the proper text restricted to visible options - this.textContent = optionsWithScroll.map(o => o.item - ? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}] ${o.label}[/color][/shadow]` - : `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}]${o.label}[/color][/shadow]` - ).join("\n"); + this.textContent = optionsWithScroll + .map(o => + o.item + ? `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}] ${o.label}[/color][/shadow]` + : `[shadow=${getTextColor(o.style ?? this.defaultTextStyle, true, globalScene.uiTheme)}][color=${getTextColor(o.style ?? TextStyle.WINDOW, false, globalScene.uiTheme)}]${o.label}[/color][/shadow]`, + ) + .join("\n"); this.optionSelectText.setText(this.textContent); options.forEach((option: OptionSelectItem, i: number) => { @@ -299,8 +316,12 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { const optionsScrollTotal = options.length; const optionStartIndex = this.scrollCursor; - const optionEndIndex = Math.min(optionsScrollTotal, optionStartIndex + - (!optionStartIndex || this.scrollCursor + (this.config.maxOptions - 1) >= optionsScrollTotal ? this.config.maxOptions - 1 : this.config.maxOptions - 2) + const optionEndIndex = Math.min( + optionsScrollTotal, + optionStartIndex + + (!optionStartIndex || this.scrollCursor + (this.config.maxOptions - 1) >= optionsScrollTotal + ? this.config.maxOptions - 1 + : this.config.maxOptions - 2), ); if (this.config?.maxOptions && options.length > this.config.maxOptions) { @@ -310,14 +331,14 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { options.unshift({ label: scrollUpLabel, handler: () => true, - style: this.defaultTextStyle + style: this.defaultTextStyle, }); } if (optionEndIndex < optionsScrollTotal) { options.push({ label: scrollDownLabel, handler: () => true, - style: this.defaultTextStyle + style: this.defaultTextStyle, }); } } @@ -336,13 +357,12 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { const changed = this.fullCursor !== fullCursor; if (changed && this.config?.maxOptions && this.config.options.length > this.config.maxOptions) { - // If the fullCursor is the last possible value, we go to the bottom if (fullCursor === this.unskippedIndices.length - 1) { this.fullCursor = fullCursor; this.cursor = this.config.maxOptions - (this.config.options.length - this.unskippedIndices[fullCursor]); this.scrollCursor = this.config.options.length - this.config.maxOptions + 1; - // If the fullCursor is the first possible value, we go to the top + // If the fullCursor is the first possible value, we go to the top } else if (fullCursor === 0) { this.fullCursor = fullCursor; this.cursor = this.unskippedIndices[fullCursor]; @@ -389,7 +409,11 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { } this.cursorObj.setScale(this.scale * 6); - this.cursorObj.setPositionRelative(this.optionSelectBg, 12, 102 * this.scale + this.cursor * (114 * this.scale - 3)); + this.cursorObj.setPositionRelative( + this.optionSelectBg, + 12, + 102 * this.scale + this.cursor * (114 * this.scale - 3), + ); return changed; } diff --git a/src/ui/achv-bar.ts b/src/ui/achv-bar.ts index 9196399f40f..1e068157afa 100644 --- a/src/ui/achv-bar.ts +++ b/src/ui/achv-bar.ts @@ -28,7 +28,18 @@ export default class AchvBar extends Phaser.GameObjects.Container { this.defaultWidth = 200; this.defaultHeight = 40; - this.bg = globalScene.add.nineslice(0, 0, "achv_bar", undefined, this.defaultWidth, this.defaultHeight, 41, 6, 16, 4); + this.bg = globalScene.add.nineslice( + 0, + 0, + "achv_bar", + undefined, + this.defaultWidth, + this.defaultHeight, + 41, + 6, + 16, + 4, + ); this.bg.setOrigin(0, 0); this.add(this.bg); @@ -37,15 +48,21 @@ export default class AchvBar extends Phaser.GameObjects.Container { this.icon.setOrigin(0, 0); this.add(this.icon); - this.titleText = addTextObject(40, 3, "", TextStyle.MESSAGE, { fontSize: "72px" }); + this.titleText = addTextObject(40, 3, "", TextStyle.MESSAGE, { + fontSize: "72px", + }); this.titleText.setOrigin(0, 0); this.add(this.titleText); - this.scoreText = addTextObject(150, 3, "", TextStyle.MESSAGE, { fontSize: "72px" }); + this.scoreText = addTextObject(150, 3, "", TextStyle.MESSAGE, { + fontSize: "72px", + }); this.scoreText.setOrigin(1, 0); this.add(this.scoreText); - this.descriptionText = addTextObject(43, 16, "", TextStyle.WINDOW_ALT, { fontSize: "72px" }); + this.descriptionText = addTextObject(43, 16, "", TextStyle.WINDOW_ALT, { + fontSize: "72px", + }); this.descriptionText.setOrigin(0, 0); this.add(this.descriptionText); @@ -80,23 +97,29 @@ export default class AchvBar extends Phaser.GameObjects.Container { } // Take the width of the default interface or the title if longest - this.bg.width = Math.max(this.defaultWidth, this.icon.displayWidth + this.titleText.displayWidth + this.scoreText.displayWidth + 16); + this.bg.width = Math.max( + this.defaultWidth, + this.icon.displayWidth + this.titleText.displayWidth + this.scoreText.displayWidth + 16, + ); this.scoreText.x = this.bg.width - 2; this.descriptionText.width = this.bg.width - this.icon.displayWidth - 16; this.descriptionText.setWordWrapWidth(this.descriptionText.width * 6); // Take the height of the default interface or the description if longest - this.bg.height = Math.max(this.defaultHeight, this.titleText.displayHeight + this.descriptionText.displayHeight + 8); - this.icon.y = (this.bg.height / 2) - (this.icon.height / 2); + this.bg.height = Math.max( + this.defaultHeight, + this.titleText.displayHeight + this.descriptionText.displayHeight + 8, + ); + this.icon.y = this.bg.height / 2 - this.icon.height / 2; globalScene.playSound("se/achv"); globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6) - (this.bg.width / 2), + x: globalScene.game.canvas.width / 6 - this.bg.width / 2, duration: 500, - ease: "Sine.easeOut" + ease: "Sine.easeOut", }); globalScene.time.delayedCall(10000, () => this.hide(this.playerGender)); @@ -105,14 +128,14 @@ export default class AchvBar extends Phaser.GameObjects.Container { this.shown = true; } - protected hide(playerGender: PlayerGender): void { + protected hide(_playerGender: PlayerGender): void { if (!this.shown) { return; } globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6), + x: globalScene.game.canvas.width / 6, duration: 500, ease: "Sine.easeIn", onComplete: () => { @@ -122,7 +145,7 @@ export default class AchvBar extends Phaser.GameObjects.Container { const shifted = this.queue.shift(); shifted && this.showAchv(shifted); } - } + }, }); } } diff --git a/src/ui/achvs-ui-handler.ts b/src/ui/achvs-ui-handler.ts index 74a121c231b..8b5a4dbd395 100644 --- a/src/ui/achvs-ui-handler.ts +++ b/src/ui/achvs-ui-handler.ts @@ -14,17 +14,17 @@ import { globalScene } from "#app/global-scene"; enum Page { ACHIEVEMENTS, - VOUCHERS + VOUCHERS, } interface LanguageSetting { - TextSize: string, + TextSize: string; } const languageSettings: { [key: string]: LanguageSetting } = { - "de":{ - TextSize: "80px" - } + de: { + TextSize: "80px", + }, }; export default class AchvsUiHandler extends MessageUiHandler { @@ -72,9 +72,12 @@ export default class AchvsUiHandler extends MessageUiHandler { this.mainContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); - this.mainContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.mainContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); - this.headerBg = addWindow(0, 0, (globalScene.game.canvas.width / 6) - 2, 24); + this.headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); this.headerBg.setOrigin(0, 0); this.headerText = addTextObject(0, 0, "", TextStyle.SETTINGS_LABEL); @@ -83,7 +86,9 @@ export default class AchvsUiHandler extends MessageUiHandler { this.headerActionButton = new Phaser.GameObjects.Sprite(globalScene, 0, 0, "keyboard", "ACTION.png"); this.headerActionButton.setOrigin(0, 0); this.headerActionButton.setPositionRelative(this.headerBg, 236, 6); - this.headerActionText = addTextObject(0, 0, "", TextStyle.WINDOW, { fontSize:"60px" }); + this.headerActionText = addTextObject(0, 0, "", TextStyle.WINDOW, { + fontSize: "60px", + }); this.headerActionText.setOrigin(0, 0); this.headerActionText.setPositionRelative(this.headerBg, 264, 8); @@ -91,14 +96,27 @@ export default class AchvsUiHandler extends MessageUiHandler { const genderIndex = globalScene.gameData.gender ?? PlayerGender.MALE; const genderStr = PlayerGender[genderIndex].toLowerCase(); - this.achvsName = i18next.t("achv:Achievements.name", { context: genderStr }); + this.achvsName = i18next.t("achv:Achievements.name", { + context: genderStr, + }); this.vouchersName = i18next.t("voucher:vouchers"); - this.iconsBg = addWindow(0, this.headerBg.height, (globalScene.game.canvas.width / 6) - 2, (globalScene.game.canvas.height / 6) - this.headerBg.height - 68); + this.iconsBg = addWindow( + 0, + this.headerBg.height, + globalScene.game.canvas.width / 6 - 2, + globalScene.game.canvas.height / 6 - this.headerBg.height - 68, + ); this.iconsBg.setOrigin(0, 0); const yOffset = 6; - this.scrollBar = new ScrollBar(this.iconsBg.width - 9, this.iconsBg.y + yOffset, 4, this.iconsBg.height - yOffset * 2, this.ROWS); + this.scrollBar = new ScrollBar( + this.iconsBg.width - 9, + this.iconsBg.y + yOffset, + 4, + this.iconsBg.height - yOffset * 2, + this.ROWS, + ); this.iconsContainer = globalScene.add.container(5, this.headerBg.height + 8); @@ -144,10 +162,12 @@ export default class AchvsUiHandler extends MessageUiHandler { this.unlockText.setOrigin(0.5, 0.5); this.unlockText.setPositionRelative(unlockBg, unlockBg.width / 2, unlockBg.height / 2); - const descriptionBg = addWindow(0, titleBg.y + titleBg.height, (globalScene.game.canvas.width / 6) - 2, 42); + const descriptionBg = addWindow(0, titleBg.y + titleBg.height, globalScene.game.canvas.width / 6 - 2, 42); descriptionBg.setOrigin(0, 0); - const descriptionText = addTextObject(0, 0, "", TextStyle.WINDOW, { maxLines: 2 }); + const descriptionText = addTextObject(0, 0, "", TextStyle.WINDOW, { + maxLines: 2, + }); descriptionText.setWordWrapWidth(1870); descriptionText.setOrigin(0, 0); descriptionText.setPositionRelative(descriptionBg, 8, 4); @@ -200,7 +220,9 @@ export default class AchvsUiHandler extends MessageUiHandler { const genderIndex = globalScene.gameData.gender ?? PlayerGender.MALE; const genderStr = PlayerGender[genderIndex].toLowerCase(); - achv.name = i18next.t(`achv:${achv.localizationKey}.name`, { context: genderStr }); + achv.name = i18next.t(`achv:${achv.localizationKey}.name`, { + context: genderStr, + }); achv.description = getAchievementDescription(achv.localizationKey); const achvUnlocks = globalScene.gameData.achvUnlocks; const unlocked = achvUnlocks.hasOwnProperty(achv.id); @@ -208,7 +230,9 @@ export default class AchvsUiHandler extends MessageUiHandler { this.titleText.setText(unlocked ? achv.name : "???"); this.showText(!hidden ? achv.description : ""); this.scoreText.setText(`${achv.score}pt`); - this.unlockText.setText(unlocked ? new Date(achvUnlocks[achv.id]).toLocaleDateString() : i18next.t("achv:Locked.name")); + this.unlockText.setText( + unlocked ? new Date(achvUnlocks[achv.id]).toLocaleDateString() : i18next.t("achv:Locked.name"), + ); } protected showVoucher(voucher: Voucher) { @@ -217,7 +241,9 @@ export default class AchvsUiHandler extends MessageUiHandler { this.titleText.setText(getVoucherTypeName(voucher.voucherType)); this.showText(voucher.description); - this.unlockText.setText(unlocked ? new Date(voucherUnlocks[voucher.id]).toLocaleDateString() : i18next.t("voucher:locked")); + this.unlockText.setText( + unlocked ? new Date(voucherUnlocks[voucher.id]).toLocaleDateString() : i18next.t("voucher:locked"), + ); } processInput(button: Button): boolean { @@ -245,14 +271,14 @@ export default class AchvsUiHandler extends MessageUiHandler { globalScene.ui.revertMode(); } else { const rowIndex = Math.floor(this.cursor / this.COLS); - const itemOffset = (this.scrollCursor * this.COLS); + const itemOffset = this.scrollCursor * this.COLS; switch (button) { case Button.UP: if (this.cursor < this.COLS) { if (this.scrollCursor) { success = this.setScrollCursor(this.scrollCursor - 1); } else { - // Wrap around to the last row + // Wrap around to the last row success = this.setScrollCursor(Math.ceil(this.currentTotal / this.COLS) - this.ROWS); let newCursorIndex = this.cursor + (this.ROWS - 1) * this.COLS; if (newCursorIndex > this.currentTotal - this.scrollCursor * this.COLS - 1) { @@ -268,10 +294,10 @@ export default class AchvsUiHandler extends MessageUiHandler { const canMoveDown = itemOffset + 1 < this.currentTotal; if (rowIndex >= this.ROWS - 1) { if (this.scrollCursor < Math.ceil(this.currentTotal / this.COLS) - this.ROWS && canMoveDown) { - // scroll down one row + // scroll down one row success = this.setScrollCursor(this.scrollCursor + 1); } else { - // wrap back to the first row + // wrap back to the first row success = this.setScrollCursor(0) && this.setCursor(this.cursor % this.COLS); } } else if (canMoveDown) { @@ -286,8 +312,8 @@ export default class AchvsUiHandler extends MessageUiHandler { } break; case Button.RIGHT: - if ((this.cursor + 1) % this.COLS === 0 || (this.cursor + itemOffset) === (this.currentTotal - 1)) { - success = this.setCursor(this.cursor - this.cursor % this.COLS); + if ((this.cursor + 1) % this.COLS === 0 || this.cursor + itemOffset === this.currentTotal - 1) { + success = this.setCursor(this.cursor - (this.cursor % this.COLS)); } else { success = this.setCursor(this.cursor + 1); } @@ -372,7 +398,6 @@ export default class AchvsUiHandler extends MessageUiHandler { return true; } - /** * updateAchvIcons(): void * Determines what data is to be displayed on the UI and updates it accordingly based on the current value of this.scrollCursor diff --git a/src/ui/admin-ui-handler.ts b/src/ui/admin-ui-handler.ts index e31acda6fa2..34b6e59145f 100644 --- a/src/ui/admin-ui-handler.ts +++ b/src/ui/admin-ui-handler.ts @@ -12,7 +12,6 @@ type AdminUiHandlerService = "discord" | "google"; type AdminUiHandlerServiceMode = "Link" | "Unlink"; export default class AdminUiHandler extends FormModalUiHandler { - private adminMode: AdminMode; private adminResult: AdminSearchInfo; private config: ModalConfig; @@ -23,9 +22,8 @@ export default class AdminUiHandler extends FormModalUiHandler { private readonly ERR_REQUIRED_FIELD = (field: string) => { if (field === "username") { return `${formatText(field)} is required`; - } else { - return `${formatText(field)} Id is required`; } + return `${formatText(field)} Id is required`; }; // returns a string saying whether a username has been successfully linked/unlinked to discord/google private readonly SUCCESS_SERVICE_MODE = (service: string, mode: string) => { @@ -45,19 +43,19 @@ export default class AdminUiHandler extends FormModalUiHandler { } override getMargin(): [number, number, number, number] { - return [ 0, 0, 0, 0 ]; + return [0, 0, 0, 0]; } override getButtonLabels(): string[] { switch (this.adminMode) { case AdminMode.LINK: - return [ "Link Account", "Cancel" ]; + return ["Link Account", "Cancel"]; case AdminMode.SEARCH: - return [ "Find account", "Cancel" ]; + return ["Find account", "Cancel"]; case AdminMode.ADMIN: - return [ "Back to search", "Cancel" ]; + return ["Back to search", "Cancel"]; default: - return [ "Activate ADMIN", "Cancel" ]; + return ["Activate ADMIN", "Cancel"]; } } @@ -65,20 +63,32 @@ export default class AdminUiHandler extends FormModalUiHandler { const inputFieldConfigs: InputFieldConfig[] = []; switch (this.adminMode) { case AdminMode.LINK: - inputFieldConfigs.push( { label: "Username" }); - inputFieldConfigs.push( { label: "Discord ID" }); + inputFieldConfigs.push({ label: "Username" }); + inputFieldConfigs.push({ label: "Discord ID" }); break; case AdminMode.SEARCH: - inputFieldConfigs.push( { label: "Username" }); + inputFieldConfigs.push({ label: "Username" }); break; case AdminMode.ADMIN: - const adminResult = this.adminResult ?? { username: "", discordId: "", googleId: "", lastLoggedIn: "", registered: "" }; + const adminResult = this.adminResult ?? { + username: "", + discordId: "", + googleId: "", + lastLoggedIn: "", + registered: "", + }; // Discord and Google ID fields that are not empty get locked, other fields are all locked - inputFieldConfigs.push( { label: "Username", isReadOnly: true }); - inputFieldConfigs.push( { label: "Discord ID", isReadOnly: adminResult.discordId !== "" }); - inputFieldConfigs.push( { label: "Google ID", isReadOnly: adminResult.googleId !== "" }); - inputFieldConfigs.push( { label: "Last played", isReadOnly: true }); - inputFieldConfigs.push( { label: "Registered", isReadOnly: true }); + inputFieldConfigs.push({ label: "Username", isReadOnly: true }); + inputFieldConfigs.push({ + label: "Discord ID", + isReadOnly: adminResult.discordId !== "", + }); + inputFieldConfigs.push({ + label: "Google ID", + isReadOnly: adminResult.googleId !== "", + }); + inputFieldConfigs.push({ label: "Last played", isReadOnly: true }); + inputFieldConfigs.push({ label: "Registered", isReadOnly: true }); break; } return inputFieldConfigs; @@ -96,7 +106,13 @@ export default class AdminUiHandler extends FormModalUiHandler { show(args: any[]): boolean { this.config = args[0] as ModalConfig; // config this.adminMode = args[1] as AdminMode; // admin mode - this.adminResult = args[2] ?? { username: "", discordId: "", googleId: "", lastLoggedIn: "", registered: "" }; // admin result, if any + this.adminResult = args[2] ?? { + username: "", + discordId: "", + googleId: "", + lastLoggedIn: "", + registered: "", + }; // admin result, if any const isMessageError = args[3]; // is the message shown a success or error const fields = this.getInputFieldConfigs(); @@ -122,23 +138,22 @@ export default class AdminUiHandler extends FormModalUiHandler { if (super.show(args)) { this.populateFields(this.adminMode, this.adminResult); const originalSubmitAction = this.submitAction; - this.submitAction = (_) => { + this.submitAction = _ => { this.submitAction = originalSubmitAction; 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(Mode.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(Mode.LOADING, { buttonActions: [] }); if (this.adminMode === AdminMode.LINK) { this.adminLinkUnlink(adminSearchResult, "discord", "Link") // calls server to link discord .then(response => { if (response.error) { return this.showMessage(response.errorType, adminSearchResult, true); // error or some kind - } else { - return this.showMessage(this.SUCCESS_SERVICE_MODE("discord", "link"), adminSearchResult, false); // success } + return this.showMessage(this.SUCCESS_SERVICE_MODE("discord", "link"), adminSearchResult, false); // success }); } else if (this.adminMode === AdminMode.SEARCH) { this.adminSearch(adminSearchResult) // admin search for username @@ -158,7 +173,13 @@ export default class AdminUiHandler extends FormModalUiHandler { } showMessage(message: string, adminResult: AdminSearchInfo, isError: boolean) { - globalScene.ui.setMode(Mode.ADMIN, Object.assign(this.config, { errorMessage: message?.trim() }), this.adminMode, adminResult, isError); + globalScene.ui.setMode( + Mode.ADMIN, + Object.assign(this.config, { errorMessage: message?.trim() }), + this.adminMode, + adminResult, + isError, + ); if (isError) { globalScene.ui.playError(); } else { @@ -184,9 +205,14 @@ export default class AdminUiHandler extends FormModalUiHandler { case AdminMode.ADMIN: Object.keys(adminResult).forEach((aR, i) => { this.inputs[i].setText(adminResult[aR]); - if (aR === "discordId" || aR === "googleId") { // this is here to add the icons for linking/unlinking of google/discord IDs + if (aR === "discordId" || aR === "googleId") { + // this is here to add the icons for linking/unlinking of google/discord IDs const nineSlice = this.inputContainers[i].list.find(iC => iC.type === "NineSlice"); - const img = globalScene.add.image(this.inputContainers[i].x + nineSlice!.width + this.buttonGap, this.inputContainers[i].y + (Math.floor(nineSlice!.height / 2)), adminResult[aR] === "" ? "link_icon" : "unlink_icon"); + const img = globalScene.add.image( + this.inputContainers[i].x + nineSlice!.width + this.buttonGap, + this.inputContainers[i].y + Math.floor(nineSlice!.height / 2), + adminResult[aR] === "" ? "link_icon" : "unlink_icon", + ); img.setName(`adminBtn_${aR}`); img.setOrigin(0.5, 0.5); img.setInteractive(); @@ -195,24 +221,30 @@ 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(Mode.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: []}); - return this.showMessage(response.errorType, adminResult, true); // fail - } else { // success, reload panel with new results - globalScene.ui.setMode(Mode.LOADING, { buttonActions: []}); - this.adminSearch(adminResult) - .then(response => { - if (response.error) { - return this.showMessage(response.errorType, adminResult, true); - } - return this.showMessage(this.SUCCESS_SERVICE_MODE(service, mode), response.adminSearchResult ?? adminResult, false); - }); - } - }); + 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: [] }); + return this.showMessage(response.errorType, adminResult, true); // fail + } + // success, reload panel with new results + globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); + this.adminSearch(adminResult).then(response => { + if (response.error) { + return this.showMessage(response.errorType, adminResult, true); + } + return this.showMessage( + this.SUCCESS_SERVICE_MODE(service, mode), + response.adminSearchResult ?? adminResult, + false, + ); + }); + }, + ); }); this.addInteractionHoverEffect(img); this.modalContainer.add(img); @@ -222,47 +254,52 @@ export default class AdminUiHandler extends FormModalUiHandler { } } - private areFieldsValid(adminMode: AdminMode, service?: string): { error: boolean; errorMessage?: string; } { + private areFieldsValid(adminMode: AdminMode, service?: string): { error: boolean; errorMessage?: string } { switch (adminMode) { case AdminMode.LINK: - if (!this.inputs[0].text) { // username missing from link panel + if (!this.inputs[0].text) { + // username missing from link panel return { error: true, - errorMessage: this.ERR_REQUIRED_FIELD("username") + errorMessage: this.ERR_REQUIRED_FIELD("username"), }; } - if (!this.inputs[1].text) { // discordId missing from linking panel + if (!this.inputs[1].text) { + // discordId missing from linking panel return { error: true, - errorMessage: this.ERR_REQUIRED_FIELD("discord") + errorMessage: this.ERR_REQUIRED_FIELD("discord"), }; } break; case AdminMode.SEARCH: - if (!this.inputs[0].text) { // username missing from search panel + if (!this.inputs[0].text) { + // username missing from search panel return { error: true, - errorMessage: this.ERR_REQUIRED_FIELD("username") + errorMessage: this.ERR_REQUIRED_FIELD("username"), }; } break; case AdminMode.ADMIN: - if (!this.inputs[1].text && service === "discord") { // discordId missing from admin panel + if (!this.inputs[1].text && service === "discord") { + // discordId missing from admin panel return { error: true, - errorMessage: this.ERR_REQUIRED_FIELD(service) + errorMessage: this.ERR_REQUIRED_FIELD(service), }; } - if (!this.inputs[2].text && service === "google") { // googleId missing from admin panel + if (!this.inputs[2].text && service === "google") { + // googleId missing from admin panel return { error: true, - errorMessage: this.ERR_REQUIRED_FIELD(service) + errorMessage: this.ERR_REQUIRED_FIELD(service), }; } break; } return { - error: false + error: false, }; } @@ -272,25 +309,32 @@ export default class AdminUiHandler extends FormModalUiHandler { discordId: this.inputs[1]?.node ? this.inputs[1]?.text : "", googleId: this.inputs[2]?.node ? this.inputs[2]?.text : "", lastLoggedIn: this.inputs[3]?.node ? this.inputs[3]?.text : "", - registered: this.inputs[4]?.node ? this.inputs[4]?.text : "" + registered: this.inputs[4]?.node ? this.inputs[4]?.text : "", }; } private async adminSearch(adminSearchResult: AdminSearchInfo) { try { - const [ adminInfo, errorType ] = await pokerogueApi.admin.searchAccount({ username: adminSearchResult.username }); - if (errorType || !adminInfo) { // error - if adminInfo.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db + const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({ + username: adminSearchResult.username, + }); + if (errorType || !adminInfo) { + // error - if adminInfo.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db return { adminSearchResult: adminSearchResult, error: true, errorType }; - } else { // success - return { adminSearchResult: adminInfo, error: false }; } + // success + return { adminSearchResult: adminInfo, error: false }; } catch (err) { console.error(err); return { error: true, errorType: err }; } } - private async adminLinkUnlink(adminSearchResult: AdminSearchInfo, service: AdminUiHandlerService, mode: AdminUiHandlerServiceMode) { + private async adminLinkUnlink( + adminSearchResult: AdminSearchInfo, + service: AdminUiHandlerService, + mode: AdminUiHandlerServiceMode, + ) { try { let errorType: string | null = null; @@ -329,10 +373,9 @@ export default class AdminUiHandler extends FormModalUiHandler { if (errorType) { // error - if response.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db return { adminSearchResult: adminSearchResult, error: true, errorType }; - } else { - // success! - return { adminSearchResult: adminSearchResult, error: false }; } + // success! + return { adminSearchResult: adminSearchResult, error: false }; } catch (err) { console.error(err); return { error: true, errorType: err }; @@ -341,19 +384,24 @@ export default class AdminUiHandler extends FormModalUiHandler { private updateAdminPanelInfo(adminSearchResult: AdminSearchInfo, mode?: AdminMode) { mode = mode ?? AdminMode.ADMIN; - globalScene.ui.setMode(Mode.ADMIN, { - buttonActions: [ - // we double revert here and below to go back 2 layers of menus - () => { - globalScene.ui.revertMode(); - globalScene.ui.revertMode(); - }, - () => { - globalScene.ui.revertMode(); - globalScene.ui.revertMode(); - } - ] - }, mode, adminSearchResult); + globalScene.ui.setMode( + Mode.ADMIN, + { + buttonActions: [ + // we double revert here and below to go back 2 layers of menus + () => { + globalScene.ui.revertMode(); + globalScene.ui.revertMode(); + }, + () => { + globalScene.ui.revertMode(); + globalScene.ui.revertMode(); + }, + ], + }, + mode, + adminSearchResult, + ); } clear(): void { @@ -361,7 +409,7 @@ export default class AdminUiHandler extends FormModalUiHandler { // this is used to remove the existing fields on the admin panel so they can be updated - const itemsToRemove: string[] = [ "formLabel", "adminBtn" ]; // this is the start of the names for each element we want to remove + const itemsToRemove: string[] = ["formLabel", "adminBtn"]; // this is the start of the names for each element we want to remove const removeArray: any[] = []; const mC = this.modalContainer.list; for (let i = mC.length - 1; i >= 0; i--) { @@ -370,7 +418,11 @@ export default class AdminUiHandler extends FormModalUiHandler { * It then also checks for any containers that are within this.modalContainer, and checks if any of its child elements are of type rexInputText * and if either of these conditions are met, the element is destroyed. */ - if (itemsToRemove.some(iTR => mC[i].name.includes(iTR)) || (mC[i].type === "Container" && (mC[i] as Phaser.GameObjects.Container).list.find(m => m.type === "rexInputText"))) { + if ( + itemsToRemove.some(iTR => mC[i].name.includes(iTR)) || + (mC[i].type === "Container" && + (mC[i] as Phaser.GameObjects.Container).list.find(m => m.type === "rexInputText")) + ) { removeArray.push(mC[i]); } } @@ -384,7 +436,7 @@ export default class AdminUiHandler extends FormModalUiHandler { export enum AdminMode { LINK, SEARCH, - ADMIN + ADMIN, } export function getAdminModeName(adminMode: AdminMode): string { diff --git a/src/ui/arena-flyout.ts b/src/ui/arena-flyout.ts index 7e9b24d1d97..36a44eb5aa0 100644 --- a/src/ui/arena-flyout.ts +++ b/src/ui/arena-flyout.ts @@ -5,7 +5,13 @@ import { WeatherType } from "#enums/weather-type"; import { TerrainType } from "#app/data/terrain"; import { addWindow, WindowVariant } from "./ui-theme"; import type { ArenaEvent } from "#app/events/arena"; -import { ArenaEventType, TagAddedEvent, TagRemovedEvent, TerrainChangedEvent, WeatherChangedEvent } from "#app/events/arena"; +import { + ArenaEventType, + TagAddedEvent, + TagRemovedEvent, + TerrainChangedEvent, + WeatherChangedEvent, +} from "#app/events/arena"; import type { TurnEndEvent } from "../events/battle-scene"; import { BattleSceneEventType } from "../events/battle-scene"; import { ArenaTagType } from "#enums/arena-tag-type"; @@ -27,7 +33,7 @@ interface ArenaEffectInfo { /** The enum string representation of the effect */ name: string; /** {@linkcode ArenaEffectType} type of effect */ - effecType: ArenaEffectType, + effecType: ArenaEffectType; /** The maximum duration set by the effect */ maxDuration: number; @@ -44,7 +50,7 @@ export function getFieldEffectText(arenaTagType: string): string { const effectName = Utils.toCamelCaseString(arenaTagType); const i18nKey = `arenaFlyout:${effectName}` as ParseKeys; const resultName = i18next.t(i18nKey); - return (!resultName || resultName === i18nKey) ? Utils.formatText(arenaTagType) : resultName; + return !resultName || resultName === i18nKey ? Utils.formatText(arenaTagType) : resultName; } export class ArenaFlyout extends Phaser.GameObjects.Container { @@ -93,8 +99,8 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { private readonly fieldEffectInfo: ArenaEffectInfo[] = []; // Stores callbacks in a variable so they can be unsubscribed from when destroyed - private readonly onNewArenaEvent = (event: Event) => this.onNewArena(event); - private readonly onTurnEndEvent = (event: Event) => this.onTurnEnd(event); + private readonly onNewArenaEvent = (event: Event) => this.onNewArena(event); + private readonly onTurnEndEvent = (event: Event) => this.onTurnEnd(event); private readonly onFieldEffectChangedEvent = (event: Event) => this.onFieldEffectChanged(event); @@ -116,19 +122,34 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { this.flyoutWindow = addWindow(0, 0, this.flyoutWidth, this.flyoutHeight, false, false, 0, 0, WindowVariant.THIN); this.flyoutContainer.add(this.flyoutWindow); - this.flyoutWindowHeader = addWindow(this.flyoutWidth / 2, 0, this.flyoutWidth / 2, 14, false, false, 0, 0, WindowVariant.XTHIN); + this.flyoutWindowHeader = addWindow( + this.flyoutWidth / 2, + 0, + this.flyoutWidth / 2, + 14, + false, + false, + 0, + 0, + WindowVariant.XTHIN, + ); this.flyoutWindowHeader.setOrigin(); this.flyoutContainer.add(this.flyoutWindowHeader); - this.flyoutTextHeader = addTextObject(this.flyoutWidth / 2, 0, i18next.t("arenaFlyout:activeBattleEffects"), TextStyle.BATTLE_INFO); + this.flyoutTextHeader = addTextObject( + this.flyoutWidth / 2, + 0, + i18next.t("arenaFlyout:activeBattleEffects"), + TextStyle.BATTLE_INFO, + ); this.flyoutTextHeader.setFontSize(54); this.flyoutTextHeader.setAlign("center"); this.flyoutTextHeader.setOrigin(); this.flyoutContainer.add(this.flyoutTextHeader); - this.timeOfDayWidget = new TimeOfDayWidget((this.flyoutWidth / 2) + (this.flyoutWindowHeader.displayWidth / 2)); + this.timeOfDayWidget = new TimeOfDayWidget(this.flyoutWidth / 2 + this.flyoutWindowHeader.displayWidth / 2); this.flyoutContainer.add(this.timeOfDayWidget); this.flyoutTextHeaderPlayer = addTextObject(6, 5, i18next.t("arenaFlyout:player"), TextStyle.SUMMARY_BLUE); @@ -138,14 +159,24 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { this.flyoutContainer.add(this.flyoutTextHeaderPlayer); - this.flyoutTextHeaderField = addTextObject(this.flyoutWidth / 2, 5, i18next.t("arenaFlyout:neutral"), TextStyle.SUMMARY_GREEN); + this.flyoutTextHeaderField = addTextObject( + this.flyoutWidth / 2, + 5, + i18next.t("arenaFlyout:neutral"), + TextStyle.SUMMARY_GREEN, + ); this.flyoutTextHeaderField.setFontSize(54); this.flyoutTextHeaderField.setAlign("center"); this.flyoutTextHeaderField.setOrigin(0.5, 0); this.flyoutContainer.add(this.flyoutTextHeaderField); - this.flyoutTextHeaderEnemy = addTextObject(this.flyoutWidth - 6, 5, i18next.t("arenaFlyout:enemy"), TextStyle.SUMMARY_RED); + this.flyoutTextHeaderEnemy = addTextObject( + this.flyoutWidth - 6, + 5, + i18next.t("arenaFlyout:enemy"), + TextStyle.SUMMARY_RED, + ); this.flyoutTextHeaderEnemy.setFontSize(54); this.flyoutTextHeaderEnemy.setAlign("right"); this.flyoutTextHeaderEnemy.setOrigin(1, 0); @@ -181,20 +212,19 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { // Subscribes to required events available on game start globalScene.eventTarget.addEventListener(BattleSceneEventType.NEW_ARENA, this.onNewArenaEvent); - globalScene.eventTarget.addEventListener(BattleSceneEventType.TURN_END, this.onTurnEndEvent); + globalScene.eventTarget.addEventListener(BattleSceneEventType.TURN_END, this.onTurnEndEvent); } - private onNewArena(event: Event) { + private onNewArena(_event: Event) { this.fieldEffectInfo.length = 0; // Subscribes to required events available on battle start globalScene.arena.eventTarget.addEventListener(ArenaEventType.WEATHER_CHANGED, this.onFieldEffectChangedEvent); globalScene.arena.eventTarget.addEventListener(ArenaEventType.TERRAIN_CHANGED, this.onFieldEffectChangedEvent); - globalScene.arena.eventTarget.addEventListener(ArenaEventType.TAG_ADDED, this.onFieldEffectChangedEvent); - globalScene.arena.eventTarget.addEventListener(ArenaEventType.TAG_REMOVED, this.onFieldEffectChangedEvent); + globalScene.arena.eventTarget.addEventListener(ArenaEventType.TAG_ADDED, this.onFieldEffectChangedEvent); + globalScene.arena.eventTarget.addEventListener(ArenaEventType.TAG_REMOVED, this.onFieldEffectChangedEvent); } - /** Clears out the current string stored in all arena effect texts */ private clearText() { this.flyoutTextPlayer.text = ""; @@ -252,7 +282,7 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { let foundIndex: number; switch (arenaEffectChangedEvent.constructor) { - case TagAddedEvent: + case TagAddedEvent: { const tagAddedEvent = arenaEffectChangedEvent as TagAddedEvent; const isArenaTrapTag = globalScene.arena.getTag(tagAddedEvent.arenaTagType) instanceof ArenaTrapTag; let arenaEffectType: ArenaEffectType; @@ -265,15 +295,20 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { arenaEffectType = ArenaEffectType.ENEMY; } - const existingTrapTagIndex = isArenaTrapTag ? this.fieldEffectInfo.findIndex(e => tagAddedEvent.arenaTagType === e.tagType && arenaEffectType === e.effecType) : -1; - let name: string = getFieldEffectText(ArenaTagType[tagAddedEvent.arenaTagType]); + const existingTrapTagIndex = isArenaTrapTag + ? this.fieldEffectInfo.findIndex( + e => tagAddedEvent.arenaTagType === e.tagType && arenaEffectType === e.effecType, + ) + : -1; + let name: string = getFieldEffectText(ArenaTagType[tagAddedEvent.arenaTagType]); if (isArenaTrapTag) { if (existingTrapTagIndex !== -1) { const layers = tagAddedEvent.arenaTagMaxLayers > 1 ? ` (${tagAddedEvent.arenaTagLayers})` : ""; this.fieldEffectInfo[existingTrapTagIndex].name = `${name}${layers}`; break; - } else if (tagAddedEvent.arenaTagMaxLayers > 1) { + } + if (tagAddedEvent.arenaTagMaxLayers > 1) { name = `${name} (${tagAddedEvent.arenaTagLayers})`; } } @@ -283,40 +318,45 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { effecType: arenaEffectType, maxDuration: tagAddedEvent.duration, duration: tagAddedEvent.duration, - tagType: tagAddedEvent.arenaTagType + tagType: tagAddedEvent.arenaTagType, }); break; - case TagRemovedEvent: + } + case TagRemovedEvent: { const tagRemovedEvent = arenaEffectChangedEvent as TagRemovedEvent; foundIndex = this.fieldEffectInfo.findIndex(info => info.tagType === tagRemovedEvent.arenaTagType); - if (foundIndex !== -1) { // If the tag was being tracked, remove it + if (foundIndex !== -1) { + // If the tag was being tracked, remove it this.fieldEffectInfo.splice(foundIndex, 1); } break; + } case WeatherChangedEvent: - case TerrainChangedEvent: + case TerrainChangedEvent: { const fieldEffectChangedEvent = arenaEffectChangedEvent as WeatherChangedEvent | TerrainChangedEvent; // Stores the old Weather/Terrain name in case it's in the array already - const oldName = - getFieldEffectText(fieldEffectChangedEvent instanceof WeatherChangedEvent - ? WeatherType[fieldEffectChangedEvent.oldWeatherType] - : TerrainType[fieldEffectChangedEvent.oldTerrainType]); + const oldName = getFieldEffectText( + fieldEffectChangedEvent instanceof WeatherChangedEvent + ? WeatherType[fieldEffectChangedEvent.oldWeatherType] + : TerrainType[fieldEffectChangedEvent.oldTerrainType], + ); // Stores the new Weather/Terrain info const newInfo = { - name: - getFieldEffectText(fieldEffectChangedEvent instanceof WeatherChangedEvent - ? WeatherType[fieldEffectChangedEvent.newWeatherType] - : TerrainType[fieldEffectChangedEvent.newTerrainType]), - effecType: fieldEffectChangedEvent instanceof WeatherChangedEvent - ? ArenaEffectType.WEATHER - : ArenaEffectType.TERRAIN, + name: getFieldEffectText( + fieldEffectChangedEvent instanceof WeatherChangedEvent + ? WeatherType[fieldEffectChangedEvent.newWeatherType] + : TerrainType[fieldEffectChangedEvent.newTerrainType], + ), + effecType: + fieldEffectChangedEvent instanceof WeatherChangedEvent ? ArenaEffectType.WEATHER : ArenaEffectType.TERRAIN, maxDuration: fieldEffectChangedEvent.duration, - duration: fieldEffectChangedEvent.duration }; + duration: fieldEffectChangedEvent.duration, + }; - foundIndex = this.fieldEffectInfo.findIndex(info => [ newInfo.name, oldName ].includes(info.name)); + foundIndex = this.fieldEffectInfo.findIndex(info => [newInfo.name, oldName].includes(info.name)); if (foundIndex === -1) { if (newInfo.name !== undefined) { this.fieldEffectInfo.push(newInfo); // Adds the info to the array if it doesn't already exist and is defined @@ -327,6 +367,7 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { this.fieldEffectInfo[foundIndex] = newInfo; // Otherwise, replace the old info } break; + } } this.updateFieldText(); @@ -353,7 +394,8 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { } --info.duration; - if (info.duration <= 0) { // Removes the item if the duration has expired + if (info.duration <= 0) { + // Removes the item if the duration has expired this.fieldEffectInfo.splice(this.fieldEffectInfo.indexOf(info), 1); } } @@ -372,18 +414,18 @@ export class ArenaFlyout extends Phaser.GameObjects.Container { duration: Utils.fixedInt(125), ease: "Sine.easeInOut", alpha: visible ? 1 : 0, - onComplete: () => this.timeOfDayWidget.parentVisible = visible, + onComplete: () => (this.timeOfDayWidget.parentVisible = visible), }); } public destroy(fromScene?: boolean): void { globalScene.eventTarget.removeEventListener(BattleSceneEventType.NEW_ARENA, this.onNewArenaEvent); - globalScene.eventTarget.removeEventListener(BattleSceneEventType.TURN_END, this.onTurnEndEvent); + globalScene.eventTarget.removeEventListener(BattleSceneEventType.TURN_END, this.onTurnEndEvent); globalScene.arena.eventTarget.removeEventListener(ArenaEventType.WEATHER_CHANGED, this.onFieldEffectChangedEvent); globalScene.arena.eventTarget.removeEventListener(ArenaEventType.TERRAIN_CHANGED, this.onFieldEffectChangedEvent); - globalScene.arena.eventTarget.removeEventListener(ArenaEventType.TAG_ADDED, this.onFieldEffectChangedEvent); - globalScene.arena.eventTarget.removeEventListener(ArenaEventType.TAG_REMOVED, this.onFieldEffectChangedEvent); + globalScene.arena.eventTarget.removeEventListener(ArenaEventType.TAG_ADDED, this.onFieldEffectChangedEvent); + globalScene.arena.eventTarget.removeEventListener(ArenaEventType.TAG_REMOVED, this.onFieldEffectChangedEvent); super.destroy(fromScene); } diff --git a/src/ui/autocomplete-ui-handler.ts b/src/ui/autocomplete-ui-handler.ts index 23abdb85772..a170ae43f23 100644 --- a/src/ui/autocomplete-ui-handler.ts +++ b/src/ui/autocomplete-ui-handler.ts @@ -27,8 +27,15 @@ export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler protected setupOptions() { super.setupOptions(); if (this.modalContainer) { - this.optionSelectContainer.setSize(this.optionSelectContainer.height, Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth())); - this.optionSelectContainer.setPositionRelative(this.modalContainer, this.optionSelectBg.width, this.optionSelectBg.height + 50); + this.optionSelectContainer.setSize( + this.optionSelectContainer.height, + Math.max(this.optionSelectText.displayWidth + 24, this.getWindowWidth()), + ); + this.optionSelectContainer.setPositionRelative( + this.modalContainer, + this.optionSelectBg.width, + this.optionSelectBg.height + 50, + ); } } diff --git a/src/ui/awaitable-ui-handler.ts b/src/ui/awaitable-ui-handler.ts index cc970358cb2..890e2884fd5 100644 --- a/src/ui/awaitable-ui-handler.ts +++ b/src/ui/awaitable-ui-handler.ts @@ -6,7 +6,7 @@ import { globalScene } from "#app/global-scene"; export default abstract class AwaitableUiHandler extends UiHandler { protected awaitingActionInput: boolean; protected onActionInput: Function | null; - public tutorialActive: boolean = false; + public tutorialActive = false; public tutorialOverlay: Phaser.GameObjects.Rectangle; constructor(mode: Mode | null = null) { @@ -32,7 +32,14 @@ export default abstract class AwaitableUiHandler extends UiHandler { */ initTutorialOverlay(container: Phaser.GameObjects.Container) { if (!this.tutorialOverlay) { - this.tutorialOverlay = new Phaser.GameObjects.Rectangle(globalScene, -1, -1, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0x070707); + this.tutorialOverlay = new Phaser.GameObjects.Rectangle( + globalScene, + -1, + -1, + globalScene.scaledCanvas.width, + globalScene.scaledCanvas.height, + 0x070707, + ); this.tutorialOverlay.setName("tutorial-overlay"); this.tutorialOverlay.setOrigin(0, 0); this.tutorialOverlay.setAlpha(0); diff --git a/src/ui/ball-ui-handler.ts b/src/ui/ball-ui-handler.ts index a402d11ef1d..cfa44832824 100644 --- a/src/ui/ball-ui-handler.ts +++ b/src/ui/ball-ui-handler.ts @@ -15,7 +15,7 @@ export default class BallUiHandler extends UiHandler { private cursorObj: Phaser.GameObjects.Image | null; - private scale: number = 0.1666666667; + private scale = 0.1666666667; constructor() { super(Mode.BALL); @@ -34,7 +34,10 @@ export default class BallUiHandler extends UiHandler { optionsTextContent += "Cancel"; const optionsText = addTextObject(0, 0, optionsTextContent, TextStyle.WINDOW, { align: "right", maxLines: 6 }); const optionsTextWidth = optionsText.displayWidth; - this.pokeballSelectContainer = globalScene.add.container((globalScene.game.canvas.width / 6) - 51 - Math.max(64, optionsTextWidth), -49); + this.pokeballSelectContainer = globalScene.add.container( + globalScene.game.canvas.width / 6 - 51 - Math.max(64, optionsTextWidth), + -49, + ); this.pokeballSelectContainer.setVisible(false); ui.add(this.pokeballSelectContainer); @@ -46,7 +49,9 @@ export default class BallUiHandler extends UiHandler { optionsText.setPositionRelative(this.pokeballSelectBg, 42, 9); optionsText.setLineSpacing(this.scale * 72); - this.countsText = addTextObject(0, 0, "", TextStyle.WINDOW, { maxLines: 5 }); + this.countsText = addTextObject(0, 0, "", TextStyle.WINDOW, { + maxLines: 5, + }); this.countsText.setPositionRelative(this.pokeballSelectBg, 18, 9); this.countsText.setLineSpacing(this.scale * 72); this.pokeballSelectContainer.add(this.countsText); @@ -107,7 +112,11 @@ export default class BallUiHandler extends UiHandler { } updateCounts() { - this.countsText.setText(Object.values(globalScene.pokeballCounts).map(c => `x${c}`).join("\n")); + this.countsText.setText( + Object.values(globalScene.pokeballCounts) + .map(c => `x${c}`) + .join("\n"), + ); } setCursor(cursor: number): boolean { diff --git a/src/ui/base-stats-overlay.ts b/src/ui/base-stats-overlay.ts index f2e94fa24a4..5a6c67cae7b 100644 --- a/src/ui/base-stats-overlay.ts +++ b/src/ui/base-stats-overlay.ts @@ -6,21 +6,20 @@ import i18next from "i18next"; import { globalScene } from "#app/global-scene"; interface BaseStatsOverlaySettings { - scale?:number; // scale the box? A scale of 0.5 is recommended - x?: number; - y?: number; - /** Default is always half the screen, regardless of scale */ - width?: number; + scale?: number; // scale the box? A scale of 0.5 is recommended + x?: number; + y?: number; + /** Default is always half the screen, regardless of scale */ + width?: number; } const HEIGHT = 120; const BORDER = 8; const GLOBAL_SCALE = 6; -const shortStats = [ "HP", "ATK", "DEF", "SPATK", "SPDEF", "SPD" ]; +const shortStats = ["HP", "ATK", "DEF", "SPATK", "SPDEF", "SPD"]; export class BaseStatsOverlay extends Phaser.GameObjects.Container implements InfoToggle { - - public active: boolean = false; + public active = false; private statsLabels: Phaser.GameObjects.Text[] = []; private statsRectangles: Phaser.GameObjects.Rectangle[] = []; @@ -67,8 +66,7 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In } // show this component with infos for the specific move - show(values: number[], total: number):boolean { - + show(values: number[], total: number): boolean { for (let i = 0; i < 6; i++) { this.statsLabels[i].setText(i18next.t(`pokemonInfo:Stat.${shortStats[i]}shortened`) + ": " + `${values[i]}`); // This accounts for base stats up to 200, might not be enough. @@ -79,7 +77,6 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In this.statsTotalLabel.setText(i18next.t("pokedexUiHandler:baseTotal") + ": " + `${total}`); - this.setVisible(true); this.active = true; return true; @@ -98,7 +95,7 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In targets: this.statsLabels, duration: Utils.fixedInt(125), ease: "Sine.easeInOut", - alpha: visible ? 1 : 0 + alpha: visible ? 1 : 0, }); if (!visible) { this.setVisible(false); @@ -110,12 +107,12 @@ export class BaseStatsOverlay extends Phaser.GameObjects.Container implements In } // width of this element - static getWidth(scale:number):number { + static getWidth(_scale: number): number { return globalScene.game.canvas.width / GLOBAL_SCALE / 2; } // height of this element - static getHeight(scale:number, onSide?: boolean):number { + static getHeight(scale: number, _onSide?: boolean): number { return HEIGHT * scale; } } diff --git a/src/ui/battle-flyout.ts b/src/ui/battle-flyout.ts index c26f853382e..206546ad9cb 100644 --- a/src/ui/battle-flyout.ts +++ b/src/ui/battle-flyout.ts @@ -13,12 +13,12 @@ import { getPokemonNameWithAffix } from "#app/messages"; /** Container for info about a {@linkcode Move} */ interface MoveInfo { /** The {@linkcode Move} itself */ - move: Move, + move: Move; /** The maximum PP of the {@linkcode Move} */ - maxPp: number, + maxPp: number; /** The amount of PP used by the {@linkcode Move} */ - ppUsed: number, + ppUsed: number; } /** A Flyout Menu attached to each {@linkcode BattleInfo} object on the field UI */ @@ -55,7 +55,7 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { private moveInfo: MoveInfo[] = new Array(); /** Current state of the flyout's visibility */ - public flyoutVisible: boolean = false; + public flyoutVisible = false; // Stores callbacks in a variable so they can be unsubscribed from when destroyed private readonly onMoveUsedEvent = (event: Event) => this.onMoveUsed(event); @@ -68,7 +68,7 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { this.player = player; this.translationX = this.player ? -this.flyoutWidth : this.flyoutWidth; - this.anchorX = (this.player ? -130 : -40); + this.anchorX = this.player ? -130 : -40; this.anchorY = -2.5 + (this.player ? -18.5 : -13); this.flyoutParent = globalScene.add.container(this.anchorX - this.translationX, this.anchorY); @@ -87,8 +87,11 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { // Loops through and sets the position of each text object according to the width and height of the flyout for (let i = 0; i < 4; i++) { this.flyoutText[i] = addTextObject( - (this.flyoutWidth / 4) + (this.flyoutWidth / 2) * (i % 2), - (this.flyoutHeight / 4) + (this.flyoutHeight / 2) * (i < 2 ? 0 : 1), "???", TextStyle.BATTLE_INFO); + this.flyoutWidth / 4 + (this.flyoutWidth / 2) * (i % 2), + this.flyoutHeight / 4 + (this.flyoutHeight / 2) * (i < 2 ? 0 : 1), + "???", + TextStyle.BATTLE_INFO, + ); this.flyoutText[i].setFontSize(45); this.flyoutText[i].setLineSpacing(-10); this.flyoutText[i].setAlign("center"); @@ -98,9 +101,25 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { this.flyoutContainer.add(this.flyoutText); this.flyoutContainer.add( - new Phaser.GameObjects.Rectangle(globalScene, this.flyoutWidth / 2, 0, 1, this.flyoutHeight + (globalScene.uiTheme === UiTheme.LEGACY ? 1 : 0), 0x212121).setOrigin(0.5, 0)); + new Phaser.GameObjects.Rectangle( + globalScene, + this.flyoutWidth / 2, + 0, + 1, + this.flyoutHeight + (globalScene.uiTheme === UiTheme.LEGACY ? 1 : 0), + 0x212121, + ).setOrigin(0.5, 0), + ); this.flyoutContainer.add( - new Phaser.GameObjects.Rectangle(globalScene, 0, this.flyoutHeight / 2, this.flyoutWidth + 6, 1, 0x212121).setOrigin(0, 0.5)); + new Phaser.GameObjects.Rectangle( + globalScene, + 0, + this.flyoutHeight / 2, + this.flyoutWidth + 6, + 1, + 0x212121, + ).setOrigin(0, 0.5), + ); } /** @@ -135,9 +154,8 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { /** Updates all of the {@linkcode MoveInfo} objects in the moveInfo array */ private onMoveUsed(event: Event) { const moveUsedEvent = event as MoveUsedEvent; - if (!moveUsedEvent - || moveUsedEvent.pokemonId !== this.pokemon?.id - || moveUsedEvent.move.id === Moves.STRUGGLE) { // Ignore Struggle + if (!moveUsedEvent || moveUsedEvent.pokemonId !== this.pokemon?.id || moveUsedEvent.move.id === Moves.STRUGGLE) { + // Ignore Struggle return; } @@ -145,7 +163,11 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { if (foundInfo) { foundInfo.ppUsed = moveUsedEvent.ppUsed; } else { - this.moveInfo.push({ move: moveUsedEvent.move, maxPp: moveUsedEvent.move.pp, ppUsed: moveUsedEvent.ppUsed }); + this.moveInfo.push({ + move: moveUsedEvent.move, + maxPp: moveUsedEvent.move.pp, + ppUsed: moveUsedEvent.ppUsed, + }); } this.setText(); @@ -153,14 +175,18 @@ export default class BattleFlyout extends Phaser.GameObjects.Container { private onBerryUsed(event: Event) { const berryUsedEvent = event as BerryUsedEvent; - if (!berryUsedEvent - || berryUsedEvent.berryModifier.pokemonId !== this.pokemon?.id - || berryUsedEvent.berryModifier.berryType !== BerryType.LEPPA) { // We only care about Leppa berries + if ( + !berryUsedEvent || + berryUsedEvent.berryModifier.pokemonId !== this.pokemon?.id || + berryUsedEvent.berryModifier.berryType !== BerryType.LEPPA + ) { + // We only care about Leppa berries return; } const foundInfo = this.moveInfo.find(info => info.ppUsed === info.maxPp); - if (!foundInfo) { // This will only happen on a de-sync of PP tracking + if (!foundInfo) { + // This will only happen on a de-sync of PP tracking return; } foundInfo.ppUsed = Math.max(foundInfo.ppUsed - 10, 0); diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index b866ec229d1..355ab9167a1 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -73,8 +73,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container { public flyoutMenu?: BattleFlyout; private statOrder: Stat[]; - private readonly statOrderPlayer = [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD ]; - private readonly statOrderEnemy = [ Stat.HP, Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD ]; + private readonly statOrderPlayer = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD]; + private readonly statOrderEnemy = [Stat.HP, Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD]; constructor(x: number, y: number, player: boolean) { super(globalScene, x, y); @@ -200,7 +200,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const expMaskRect = globalScene.make.graphics({}); expMaskRect.setScale(6); - expMaskRect.fillStyle(0xFFFFFF); + expMaskRect.fillStyle(0xffffff); expMaskRect.beginPath(); expMaskRect.fillRect(127, 126, 85, 2); @@ -239,7 +239,10 @@ export default class BattleInfo extends Phaser.GameObjects.Container { // we do a check for i > statOverflow to see when the stat labels go onto the next column // For enemies, we have HP (i=0) by itself then a new column, so we check for i > 0 // For players, we don't have HP, so we start with i = 0 and i = 1 for our first column, and so need to check for i > 1 - const statX = i > statOverflow ? this.statNumbers[Math.max(i - 2, 0)].x + this.statNumbers[Math.max(i - 2, 0)].width + paddingX : startingX; // we have the Math.max(i - 2, 0) in there so for i===1 to not return a negative number; since this is now based on anything >0 instead of >1, we need to allow for i-2 < 0 + const statX = + i > statOverflow + ? this.statNumbers[Math.max(i - 2, 0)].x + this.statNumbers[Math.max(i - 2, 0)].width + paddingX + : startingX; // we have the Math.max(i - 2, 0) in there so for i===1 to not return a negative number; since this is now based on anything >0 instead of >1, we need to allow for i-2 < 0 const baseY = -this.statsBox.height / 2 + 4; // this is the baseline for the y-axis let statY: number; // this will be the y-axis placement for the labels @@ -255,7 +258,12 @@ export default class BattleInfo extends Phaser.GameObjects.Container { statLabels.push(statLabel); this.statValuesContainer.add(statLabel); - const statNumber = globalScene.add.sprite(statX + statLabel.width, statY, "pbinfo_stat_numbers", this.statOrder[i] !== Stat.HP ? "3" : "empty"); + const statNumber = globalScene.add.sprite( + statX + statLabel.width, + statY, + "pbinfo_stat_numbers", + this.statOrder[i] !== Stat.HP ? "3" : "empty", + ); statNumber.setName("icon_stat_number_" + i.toString()); statNumber.setOrigin(0, 0); this.statNumbers.push(statNumber); @@ -265,7 +273,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container { statLabel.setVisible(false); statNumber.setVisible(false); } - }); if (!this.player) { @@ -275,17 +282,29 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.moveBelow(this.flyoutMenu, this.box); } - this.type1Icon = globalScene.add.sprite(player ? -139 : -15, player ? -17 : -15.5, `pbinfo_${player ? "player" : "enemy"}_type1`); + this.type1Icon = globalScene.add.sprite( + player ? -139 : -15, + player ? -17 : -15.5, + `pbinfo_${player ? "player" : "enemy"}_type1`, + ); this.type1Icon.setName("icon_type_1"); this.type1Icon.setOrigin(0, 0); this.add(this.type1Icon); - this.type2Icon = globalScene.add.sprite(player ? -139 : -15, player ? -1 : -2.5, `pbinfo_${player ? "player" : "enemy"}_type2`); + this.type2Icon = globalScene.add.sprite( + player ? -139 : -15, + player ? -1 : -2.5, + `pbinfo_${player ? "player" : "enemy"}_type2`, + ); this.type2Icon.setName("icon_type_2"); this.type2Icon.setOrigin(0, 0); this.add(this.type2Icon); - this.type3Icon = globalScene.add.sprite(player ? -154 : 0, player ? -17 : -15.5, `pbinfo_${player ? "player" : "enemy"}_type`); + this.type3Icon = globalScene.add.sprite( + player ? -154 : 0, + player ? -17 : -15.5, + `pbinfo_${player ? "player" : "enemy"}_type`, + ); this.type3Icon.setName("icon_type_3"); this.type3Icon.setOrigin(0, 0); this.add(this.type3Icon); @@ -327,32 +346,60 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.teraIcon.setVisible(pokemon.isTerastallized); this.teraIcon.on("pointerover", () => { if (pokemon.isTerastallized) { - globalScene.ui.showTooltip("", i18next.t("fightUiHandler:teraHover", { type: i18next.t(`pokemonInfo:Type.${PokemonType[this.lastTeraType]}`) })); + globalScene.ui.showTooltip( + "", + i18next.t("fightUiHandler:teraHover", { + type: i18next.t(`pokemonInfo:Type.${PokemonType[this.lastTeraType]}`), + }), + ); } }); this.teraIcon.on("pointerout", () => globalScene.ui.hideTooltip()); const isFusion = pokemon.isFusion(); - this.splicedIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 2.5); + this.splicedIcon.setPositionRelative( + this.nameText, + nameTextWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), + 2.5, + ); this.splicedIcon.setVisible(isFusion); if (this.splicedIcon.visible) { - this.splicedIcon.on("pointerover", () => globalScene.ui.showTooltip("", `${pokemon.species.getName(pokemon.formIndex)}/${pokemon.fusionSpecies?.getName(pokemon.fusionFormIndex)}`)); + this.splicedIcon.on("pointerover", () => + globalScene.ui.showTooltip( + "", + `${pokemon.species.getName(pokemon.formIndex)}/${pokemon.fusionSpecies?.getName(pokemon.fusionFormIndex)}`, + ), + ); this.splicedIcon.on("pointerout", () => globalScene.ui.hideTooltip()); } const doubleShiny = isFusion && pokemon.shiny && pokemon.fusionShiny; const baseVariant = !doubleShiny ? pokemon.getVariant() : pokemon.variant; - this.shinyIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0) + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0), 2.5); + this.shinyIcon.setPositionRelative( + this.nameText, + nameTextWidth + + this.genderText.displayWidth + + 1 + + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0) + + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0), + 2.5, + ); this.shinyIcon.setTexture(`shiny_star${doubleShiny ? "_1" : ""}`); this.shinyIcon.setVisible(pokemon.isShiny()); this.shinyIcon.setTint(getVariantTint(baseVariant)); if (this.shinyIcon.visible) { - const shinyDescriptor = doubleShiny || baseVariant ? - `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` - : ""; - this.shinyIcon.on("pointerover", () => globalScene.ui.showTooltip("", `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`)); + const shinyDescriptor = + doubleShiny || baseVariant + ? `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` + : ""; + this.shinyIcon.on("pointerover", () => + globalScene.ui.showTooltip( + "", + `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`, + ), + ); this.shinyIcon.on("pointerout", () => globalScene.ui.hideTooltip()); } @@ -364,7 +411,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!this.player) { if (this.nameText.visible) { - this.nameText.on("pointerover", () => globalScene.ui.showTooltip("", i18next.t("battleInfo:generation", { generation: i18next.t(`starterSelectUiHandler:gen${pokemon.species.generation}`) }))); + this.nameText.on("pointerover", () => + globalScene.ui.showTooltip( + "", + i18next.t("battleInfo:generation", { + generation: i18next.t(`starterSelectUiHandler:gen${pokemon.species.generation}`), + }), + ), + ); this.nameText.on("pointerout", () => globalScene.ui.hideTooltip()); } @@ -372,13 +426,16 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.ownedIcon.setVisible(!!dexEntry.caughtAttr); const opponentPokemonDexAttr = pokemon.getDexAttr(); if (globalScene.gameMode.isClassic) { - if (globalScene.gameData.starterData[pokemon.species.getRootSpeciesId()].classicWinCount > 0 && globalScene.gameData.starterData[pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) { + if ( + globalScene.gameData.starterData[pokemon.species.getRootSpeciesId()].classicWinCount > 0 && + globalScene.gameData.starterData[pokemon.species.getRootSpeciesId(true)].classicWinCount > 0 + ) { this.championRibbon.setVisible(true); } } // Check if Player owns all genders and forms of the Pokemon - const missingDexAttrs = ((dexEntry.caughtAttr & opponentPokemonDexAttr) < opponentPokemonDexAttr); + const missingDexAttrs = (dexEntry.caughtAttr & opponentPokemonDexAttr) < opponentPokemonDexAttr; const ownedAbilityAttrs = globalScene.gameData.starterData[pokemon.species.getRootSpeciesId()].abilityAttr; @@ -453,10 +510,18 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.baseY = this.y; } - const offsetElements = [ this.nameText, this.genderText, this.teraIcon, this.splicedIcon, this.shinyIcon, this.statusIndicator, this.levelContainer ]; - offsetElements.forEach(el => el.y += 1.5 * (mini ? -1 : 1)); + const offsetElements = [ + this.nameText, + this.genderText, + this.teraIcon, + this.splicedIcon, + this.shinyIcon, + this.statusIndicator, + this.levelContainer, + ]; + offsetElements.forEach(el => (el.y += 1.5 * (mini ? -1 : 1))); - [ this.type1Icon, this.type2Icon, this.type3Icon ].forEach(el => { + [this.type1Icon, this.type2Icon, this.type3Icon].forEach(el => { el.x += 4 * (mini ? 1 : -1); el.y += -8 * (mini ? 1 : -1); }); @@ -464,7 +529,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.statValuesContainer.x += 2 * (mini ? 1 : -1); this.statValuesContainer.y += -7 * (mini ? 1 : -1); - const toggledElements = [ this.hpNumbersContainer, this.expBar ]; + const toggledElements = [this.hpNumbersContainer, this.expBar]; toggledElements.forEach(el => el.setVisible(!mini)); } @@ -473,7 +538,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { targets: this.statsContainer, duration: Utils.fixedInt(125), ease: "Sine.easeInOut", - alpha: visible ? 1 : 0 + alpha: visible ? 1 : 0, }); } @@ -483,7 +548,18 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (boss !== this.boss) { this.boss = boss; - [ this.nameText, this.genderText, this.teraIcon, this.splicedIcon, this.shinyIcon, this.ownedIcon, this.championRibbon, this.statusIndicator, this.levelContainer, this.statValuesContainer ].map(e => e.x += 48 * (boss ? -1 : 1)); + [ + this.nameText, + this.genderText, + this.teraIcon, + this.splicedIcon, + this.shinyIcon, + this.ownedIcon, + this.championRibbon, + this.statusIndicator, + this.levelContainer, + this.statValuesContainer, + ].map(e => (e.x += 48 * (boss ? -1 : 1))); this.hpBar.x += 38 * (boss ? -1 : 1); this.hpBar.y += 2 * (this.boss ? -1 : 1); this.hpBar.setTexture(`overlay_hp${boss ? "_boss" : ""}`); @@ -504,8 +580,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const uiTheme = globalScene.uiTheme; const maxHp = pokemon.getMaxHp(); for (let s = 1; s < this.bossSegments; s++) { - const dividerX = (Math.round((maxHp / this.bossSegments) * s) / maxHp) * this.hpBar.width; - const divider = globalScene.add.rectangle(0, 0, 1, this.hpBar.height - (uiTheme ? 0 : 1), pokemon.bossSegmentIndex >= s ? 0xFFFFFF : 0x404040); + const dividerX = (Math.round((maxHp / this.bossSegments) * s) / maxHp) * this.hpBar.width; + const divider = globalScene.add.rectangle( + 0, + 0, + 1, + this.hpBar.height - (uiTheme ? 0 : 1), + pokemon.bossSegmentIndex >= s ? 0xffffff : 0x404040, + ); divider.setOrigin(0.5, 0); divider.setName("hpBar_divider_" + s.toString()); this.add(divider); @@ -547,7 +629,11 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (teraTypeUpdated) { this.teraIcon.setVisible(teraType !== PokemonType.UNKNOWN); - this.teraIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1, 2); + this.teraIcon.setPositionRelative( + this.nameText, + this.nameText.displayWidth + this.genderText.displayWidth + 1, + 2, + ); this.teraIcon.setTintFill(Phaser.Display.Color.GetColor(...getTypeRgb(teraType))); this.lastTeraType = teraType; } @@ -555,9 +641,28 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (nameUpdated || teraTypeUpdated) { this.splicedIcon.setVisible(!!pokemon.fusionSpecies); - this.teraIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1, 2); - this.splicedIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 1.5); - this.shinyIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0) + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0), 2.5); + this.teraIcon.setPositionRelative( + this.nameText, + this.nameText.displayWidth + this.genderText.displayWidth + 1, + 2, + ); + this.splicedIcon.setPositionRelative( + this.nameText, + this.nameText.displayWidth + + this.genderText.displayWidth + + 1 + + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), + 1.5, + ); + this.shinyIcon.setPositionRelative( + this.nameText, + this.nameText.displayWidth + + this.genderText.displayWidth + + 1 + + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0) + + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0), + 2.5, + ); } if (this.lastStatus !== (pokemon.status?.effect || StatusEffect.NONE)) { @@ -594,7 +699,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { }; const updatePokemonHp = () => { - let duration = !instant ? Phaser.Math.Clamp(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000) : 0; + let duration = !instant ? Phaser.Math.Clamp(Math.abs(this.lastHp - pokemon.hp) * 5, 250, 5000) : 0; const speed = globalScene.hpBarSpeed; if (speed) { duration = speed >= 3 ? 0 : duration / Math.pow(2, speed); @@ -616,7 +721,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { onComplete: () => { updateHpFrame(); resolve(); - } + }, }); if (!this.player) { this.lastHp = pokemon.hp; @@ -627,9 +732,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (this.player) { const isLevelCapped = pokemon.level >= globalScene.getMaxExpLevel(); - if ((this.lastExp !== pokemon.exp || this.lastLevel !== pokemon.level)) { + if (this.lastExp !== pokemon.exp || this.lastLevel !== pokemon.level) { const originalResolve = resolve; - const durationMultipler = Math.max(Phaser.Tweens.Builders.GetEaseFunction("Cubic.easeIn")(1 - (Math.min(pokemon.level - this.lastLevel, 10) / 10)), 0.1); + const durationMultipler = Math.max( + Phaser.Tweens.Builders.GetEaseFunction("Cubic.easeIn")( + 1 - Math.min(pokemon.level - this.lastLevel, 10) / 10, + ), + 0.1, + ); resolve = () => this.updatePokemonExp(pokemon, false, durationMultipler).then(() => originalResolve()); } else if (isLevelCapped !== this.lastLevelCapped) { this.setLevel(pokemon.level); @@ -640,7 +750,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (this.lastHp !== pokemon.hp || this.lastMaxHp !== pokemon.getMaxHp()) { return updatePokemonHp(); - } else if (!this.player && this.lastLevel !== pokemon.level) { + } + if (!this.player && this.lastLevel !== pokemon.level) { this.setLevel(pokemon.level); this.lastLevel = pokemon.level; } @@ -666,7 +777,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const nameSizeTest = addTextObject(0, 0, displayName, TextStyle.BATTLE_INFO); nameTextWidth = nameSizeTest.displayWidth; - while (nameTextWidth > (this.player || !this.boss ? 60 : 98) - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 8 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8)) { + while ( + nameTextWidth > + (this.player || !this.boss ? 60 : 98) - + ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + + (pokemon.fusionSpecies ? 8 : 0) + + (pokemon.isShiny() ? 8 : 0) + + (Math.min(pokemon.level.toString().length, 3) - 3) * 8) + ) { displayName = `${displayName.slice(0, displayName.endsWith(".") ? -2 : -1).trimEnd()}.`; nameSizeTest.setText(displayName); nameTextWidth = nameSizeTest.displayWidth; @@ -678,11 +796,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.lastName = pokemon.getNameToRender(); if (this.nameText.visible) { - this.nameText.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.nameText.width, this.nameText.height), Phaser.Geom.Rectangle.Contains); + this.nameText.setInteractive( + new Phaser.Geom.Rectangle(0, 0, this.nameText.width, this.nameText.height), + Phaser.Geom.Rectangle.Contains, + ); } } - updatePokemonExp(pokemon: Pokemon, instant?: boolean, levelDurationMultiplier: number = 1): Promise { + updatePokemonExp(pokemon: Pokemon, instant?: boolean, levelDurationMultiplier = 1): Promise { return new Promise(resolve => { const levelUp = this.lastLevel < pokemon.level; const relLevelExp = getLevelRelExp(this.lastLevel + 1, pokemon.species.growthRate); @@ -696,8 +817,16 @@ export default class BattleInfo extends Phaser.GameObjects.Container { } instant = true; } - const durationMultiplier = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn")(1 - (Math.max(this.lastLevel - 100, 0) / 150)); - let duration = this.visible && !instant ? (((levelExp - this.lastLevelExp) / relLevelExp) * BattleInfo.EXP_GAINS_DURATION_BASE) * durationMultiplier * levelDurationMultiplier : 0; + const durationMultiplier = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn")( + 1 - Math.max(this.lastLevel - 100, 0) / 150, + ); + let duration = + this.visible && !instant + ? ((levelExp - this.lastLevelExp) / relLevelExp) * + BattleInfo.EXP_GAINS_DURATION_BASE * + durationMultiplier * + levelDurationMultiplier + : 0; const speed = globalScene.expGainsSpeed; if (speed && speed >= ExpGainsSpeed.DEFAULT) { duration = speed >= ExpGainsSpeed.SKIP ? ExpGainsSpeed.DEFAULT : duration / Math.pow(2, speed); @@ -734,7 +863,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { return; } resolve(); - } + }, }); }); } @@ -744,7 +873,9 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.levelNumbersContainer.removeAll(true); const levelStr = level.toString(); for (let i = 0; i < levelStr.length; i++) { - this.levelNumbersContainer.add(globalScene.add.image(i * 8, 0, `numbers${isCapped && this.player ? "_red" : ""}`, levelStr[i])); + this.levelNumbersContainer.add( + globalScene.add.image(i * 8, 0, `numbers${isCapped && this.player ? "_red" : ""}`, levelStr[i]), + ); } this.levelContainer.setX((this.player ? -41 : -50) - 8 * Math.max(levelStr.length - 3, 0)); } @@ -827,5 +958,5 @@ export class EnemyBattleInfo extends BattleInfo { super(140, -141, false); } - setMini(mini: boolean): void { } // Always mini + setMini(_mini: boolean): void {} // Always mini } diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index c87ac18c65d..ccb9378c688 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -55,7 +55,7 @@ export default class BattleMessageUiHandler extends MessageUiHandler { moveDetailsWindow.setName("move-details-window"); moveDetailsWindow.setOrigin(0, 1); - this.movesWindowContainer.add([ movesWindow, moveDetailsWindow ]); + this.movesWindowContainer.add([movesWindow, moveDetailsWindow]); ui.add(this.movesWindowContainer); const messageContainer = globalScene.add.container(12, -39); @@ -64,8 +64,8 @@ export default class BattleMessageUiHandler extends MessageUiHandler { const message = addTextObject(0, 0, "", TextStyle.MESSAGE, { maxLines: 2, wordWrap: { - width: this.wordWrapWidth - } + width: this.wordWrapWidth, + }, }); messageContainer.add(message); @@ -77,7 +77,9 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.nameBox = globalScene.add.nineslice(0, 0, "namebox", globalScene.windowType, 72, 16, 8, 8, 5, 5); this.nameBox.setOrigin(0, 0); - this.nameText = addTextObject(8, 0, "Rival", TextStyle.MESSAGE, { maxLines: 1 }); + this.nameText = addTextObject(8, 0, "Rival", TextStyle.MESSAGE, { + maxLines: 1, + }); this.nameBoxContainer.add(this.nameBox); this.nameBoxContainer.add(this.nameText); @@ -91,7 +93,9 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.levelUpStatsContainer = levelUpStatsContainer; - const levelUpStatsLabelsContent = addTextObject((globalScene.game.canvas.width / 6) - 73, -94, "", TextStyle.WINDOW, { maxLines: 6 }); + const levelUpStatsLabelsContent = addTextObject(globalScene.game.canvas.width / 6 - 73, -94, "", TextStyle.WINDOW, { + maxLines: 6, + }); levelUpStatsLabelsContent.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); let levelUpStatsLabelText = ""; @@ -101,19 +105,36 @@ export default class BattleMessageUiHandler extends MessageUiHandler { levelUpStatsLabelsContent.text = levelUpStatsLabelText; levelUpStatsLabelsContent.x -= levelUpStatsLabelsContent.displayWidth; - const levelUpStatsBg = addWindow((globalScene.game.canvas.width / 6), -100, 80 + levelUpStatsLabelsContent.displayWidth, 100); + const levelUpStatsBg = addWindow( + globalScene.game.canvas.width / 6, + -100, + 80 + levelUpStatsLabelsContent.displayWidth, + 100, + ); levelUpStatsBg.setOrigin(1, 0); levelUpStatsContainer.add(levelUpStatsBg); levelUpStatsContainer.add(levelUpStatsLabelsContent); - const levelUpStatsIncrContent = addTextObject((globalScene.game.canvas.width / 6) - 50, -94, "+\n+\n+\n+\n+\n+", TextStyle.WINDOW, { maxLines: 6 }); + const levelUpStatsIncrContent = addTextObject( + globalScene.game.canvas.width / 6 - 50, + -94, + "+\n+\n+\n+\n+\n+", + TextStyle.WINDOW, + { maxLines: 6 }, + ); levelUpStatsIncrContent.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); levelUpStatsContainer.add(levelUpStatsIncrContent); this.levelUpStatsIncrContent = levelUpStatsIncrContent; - const levelUpStatsValuesContent = addBBCodeTextObject((globalScene.game.canvas.width / 6) - 7, -94, "", TextStyle.WINDOW, { maxLines: 6, lineSpacing: 5 }); + const levelUpStatsValuesContent = addBBCodeTextObject( + globalScene.game.canvas.width / 6 - 7, + -94, + "", + TextStyle.WINDOW, + { maxLines: 6, lineSpacing: 5 }, + ); levelUpStatsValuesContent.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); levelUpStatsValuesContent.setOrigin(1, 0); levelUpStatsValuesContent.setAlign("right"); @@ -153,12 +174,27 @@ export default class BattleMessageUiHandler extends MessageUiHandler { super.clear(); } - showText(text: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null) { + showText( + text: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ) { this.hideNameText(); super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); } - showDialogue(text: string, name?: string, delay?: number | null, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number) { + showDialogue( + text: string, + name?: string, + delay?: number | null, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + ) { if (name) { this.showNameText(name); } @@ -182,10 +218,9 @@ export default class BattleMessageUiHandler extends MessageUiHandler { this.onActionInput = () => { if (!showTotals) { return this.promptLevelUpStats(partyMemberIndex, [], true).then(() => resolve()); - } else { - this.levelUpStatsContainer.setVisible(false); - resolve(); } + this.levelUpStatsContainer.setVisible(false); + resolve(); }; }); } diff --git a/src/ui/bgm-bar.ts b/src/ui/bgm-bar.ts index 0cd3da71248..45ed766c7fa 100644 --- a/src/ui/bgm-bar.ts +++ b/src/ui/bgm-bar.ts @@ -24,7 +24,18 @@ export default class BgmBar extends Phaser.GameObjects.Container { this.defaultWidth = 230; this.defaultHeight = 100; - this.bg = globalScene.add.nineslice(-5, -5, "bgm_bar", undefined, this.defaultWidth, this.defaultHeight, 0, 0, 10, 10); + this.bg = globalScene.add.nineslice( + -5, + -5, + "bgm_bar", + undefined, + this.defaultWidth, + this.defaultHeight, + 0, + 0, + 10, + 10, + ); this.bg.setOrigin(0, 0); this.add(this.bg); @@ -40,8 +51,8 @@ export default class BgmBar extends Phaser.GameObjects.Container { } /* - * Set the BGM Name to the BGM bar. - * @param {string} bgmName The name of the BGM to set. + * Set the BGM Name to the BGM bar. + * @param {string} bgmName The name of the BGM to set. */ setBgmToBgmBar(bgmName: string): void { this.musicText.setText(`${i18next.t("bgmName:music")}${this.getRealBgmName(bgmName)}`); @@ -83,11 +94,13 @@ export default class BgmBar extends Phaser.GameObjects.Container { ease: "Sine.easeInOut", onComplete: () => { this.setVisible(true); - } + }, }); } getRealBgmName(bgmName: string): string { - return i18next.t([ `bgmName:${bgmName}`, "bgmName:missing_entries" ], { name: Utils.formatText(bgmName) }); + return i18next.t([`bgmName:${bgmName}`, "bgmName:missing_entries"], { + name: Utils.formatText(bgmName), + }); } } diff --git a/src/ui/candy-bar.ts b/src/ui/candy-bar.ts index d58fd040a7c..ba85ed7fef3 100644 --- a/src/ui/candy-bar.ts +++ b/src/ui/candy-bar.ts @@ -18,7 +18,7 @@ export default class CandyBar extends Phaser.GameObjects.Container { public shown: boolean; constructor() { - super(globalScene, (globalScene.game.canvas.width / 6), -((globalScene.game.canvas.height) / 6) + 15); + super(globalScene, globalScene.game.canvas.width / 6, -(globalScene.game.canvas.height / 6) + 15); } setup(): void { @@ -52,9 +52,10 @@ export default class CandyBar extends Phaser.GameObjects.Container { if (this.shown) { if (this.speciesId === starterSpeciesId) { return resolve(); - } else { - return this.hide().then(() => this.showStarterSpeciesCandy(starterSpeciesId, count)).then(() => resolve()); } + return this.hide() + .then(() => this.showStarterSpeciesCandy(starterSpeciesId, count)) + .then(() => resolve()); } const colorScheme = starterColors[starterSpeciesId]; @@ -62,7 +63,9 @@ export default class CandyBar extends Phaser.GameObjects.Container { this.candyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0]))); this.candyOverlayIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1]))); - this.countText.setText(`${globalScene.gameData.starterData[starterSpeciesId].candyCount + count} (+${count.toString()})`); + this.countText.setText( + `${globalScene.gameData.starterData[starterSpeciesId].candyCount + count} (+${count.toString()})`, + ); this.bg.width = this.countText.displayWidth + 28; @@ -76,14 +79,14 @@ export default class CandyBar extends Phaser.GameObjects.Container { this.tween = globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6) - (this.bg.width - 5), + x: globalScene.game.canvas.width / 6 - (this.bg.width - 5), duration: 500, ease: "Sine.easeOut", onComplete: () => { this.tween = null; this.resetAutoHideTimer(); resolve(); - } + }, }); this.setVisible(true); @@ -107,7 +110,7 @@ export default class CandyBar extends Phaser.GameObjects.Container { this.tween = globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6), + x: globalScene.game.canvas.width / 6, duration: 500, ease: "Sine.easeIn", onComplete: () => { @@ -115,7 +118,7 @@ export default class CandyBar extends Phaser.GameObjects.Container { this.shown = false; this.setVisible(false); resolve(); - } + }, }); }); } diff --git a/src/ui/challenges-select-ui-handler.ts b/src/ui/challenges-select-ui-handler.ts index 31ee91388fc..61989cd594e 100644 --- a/src/ui/challenges-select-ui-handler.ts +++ b/src/ui/challenges-select-ui-handler.ts @@ -28,7 +28,12 @@ export default class GameChallengesUiHandler extends UiHandler { private descriptionText: BBCodeText; - private challengeLabels: Array<{ label: Phaser.GameObjects.Text, value: Phaser.GameObjects.Text, leftArrow: Phaser.GameObjects.Image, rightArrow: Phaser.GameObjects.Image }>; + private challengeLabels: Array<{ + label: Phaser.GameObjects.Text; + value: Phaser.GameObjects.Text; + leftArrow: Phaser.GameObjects.Image; + rightArrow: Phaser.GameObjects.Image; + }>; private monoTypeValue: Phaser.GameObjects.Sprite; private cursorObj: Phaser.GameObjects.NineSlice | null; @@ -57,15 +62,25 @@ export default class GameChallengesUiHandler extends UiHandler { this.challengesContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.challengesContainer.setName("challenges"); - this.challengesContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.challengesContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); - const bgOverlay = globalScene.add.rectangle(-1, -1, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0x424242, 0.8); + const bgOverlay = globalScene.add.rectangle( + -1, + -1, + globalScene.scaledCanvas.width, + globalScene.scaledCanvas.height, + 0x424242, + 0.8, + ); bgOverlay.setName("rect-challenge-overlay"); bgOverlay.setOrigin(0, 0); this.challengesContainer.add(bgOverlay); // TODO: Change this back to /9 when adding in difficulty - const headerBg = addWindow(0, 0, (globalScene.game.canvas.width / 6), 24); + const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6, 24); headerBg.setName("window-header-bg"); headerBg.setOrigin(0, 0); @@ -75,11 +90,21 @@ export default class GameChallengesUiHandler extends UiHandler { headerText.setPositionRelative(headerBg, 8, 4); this.optionsWidth = globalScene.scaledCanvas.width * 0.6; - this.optionsBg = addWindow(0, headerBg.height, this.optionsWidth, globalScene.scaledCanvas.height - headerBg.height - 2); + this.optionsBg = addWindow( + 0, + headerBg.height, + this.optionsWidth, + globalScene.scaledCanvas.height - headerBg.height - 2, + ); this.optionsBg.setName("window-options-bg"); this.optionsBg.setOrigin(0, 0); - const descriptionBg = addWindow(0, headerBg.height, globalScene.scaledCanvas.width - this.optionsWidth, globalScene.scaledCanvas.height - headerBg.height - 26); + const descriptionBg = addWindow( + 0, + headerBg.height, + globalScene.scaledCanvas.width - this.optionsWidth, + globalScene.scaledCanvas.height - headerBg.height - 26, + ); descriptionBg.setName("window-desc-bg"); descriptionBg.setOrigin(0, 0); descriptionBg.setPositionRelative(this.optionsBg, this.optionsBg.width, 0); @@ -89,12 +114,12 @@ export default class GameChallengesUiHandler extends UiHandler { fontSize: 84, color: Color.ORANGE, padding: { - bottom: 6 + bottom: 6, }, wrap: { mode: "word", width: (descriptionBg.width - 12) * 6, - } + }, }); this.descriptionText.setName("text-desc"); globalScene.add.existing(this.descriptionText); @@ -112,7 +137,18 @@ export default class GameChallengesUiHandler extends UiHandler { this.startText.setOrigin(0, 0); this.startText.setPositionRelative(this.startBg, (this.startBg.width - this.startText.displayWidth) / 2, 4); - this.startCursor = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, descriptionBg.width - 8, 16, 1, 1, 1, 1); + this.startCursor = globalScene.add.nineslice( + 0, + 0, + "summary_moves_cursor", + undefined, + descriptionBg.width - 8, + 16, + 1, + 1, + 1, + 1, + ); this.startCursor.setName("9s-start-cursor"); this.startCursor.setOrigin(0, 0); this.startCursor.setPositionRelative(this.startBg, 4, 3); @@ -153,7 +189,7 @@ export default class GameChallengesUiHandler extends UiHandler { label: label, value: value, leftArrow: leftArrow, - rightArrow: rightArrow + rightArrow: rightArrow, }; } @@ -208,7 +244,8 @@ export default class GameChallengesUiHandler extends UiHandler { const tempText = addTextObject(0, 0, "", TextStyle.SETTINGS_LABEL); // this is added here to get the widest text object for this language, which will be used for the arrow placement - for (let j = 0; j <= globalScene.gameMode.challenges[i].maxValue; j++) { // this goes through each challenge's value to find out what the max width will be + for (let j = 0; j <= globalScene.gameMode.challenges[i].maxValue; j++) { + // this goes through each challenge's value to find out what the max width will be if (globalScene.gameMode.challenges[i].id !== Challenges.SINGLE_TYPE) { tempText.setText(globalScene.gameMode.challenges[i].getValue(j)); if (tempText.displayWidth > this.widestTextBox) { @@ -234,17 +271,28 @@ export default class GameChallengesUiHandler extends UiHandler { challengeLabel.label.setText(challenge.getName()); challengeLabel.leftArrow.setPositionRelative(challengeLabel.label, this.leftArrowGap, 4.5); challengeLabel.leftArrow.setVisible(challenge.value !== 0); - challengeLabel.rightArrow.setPositionRelative(challengeLabel.leftArrow, Math.max(this.monoTypeValue.width, this.widestTextBox) + challengeLabel.leftArrow.displayWidth + 2 * this.arrowSpacing, 0); + challengeLabel.rightArrow.setPositionRelative( + challengeLabel.leftArrow, + Math.max(this.monoTypeValue.width, this.widestTextBox) + + challengeLabel.leftArrow.displayWidth + + 2 * this.arrowSpacing, + 0, + ); challengeLabel.rightArrow.setVisible(challenge.value !== challenge.maxValue); // this check looks to make sure that the arrows and value textbox don't take up too much space that they'll clip the right edge of the options background - if (challengeLabel.rightArrow.x + challengeLabel.rightArrow.width + this.optionsBg.rightWidth + this.arrowSpacing > this.optionsWidth) { + if ( + challengeLabel.rightArrow.x + challengeLabel.rightArrow.width + this.optionsBg.rightWidth + this.arrowSpacing > + this.optionsWidth + ) { // if we go out of bounds of the box, set the x position as far right as we can without going past the box, with this.arrowSpacing to allow a small gap between the arrow and border challengeLabel.rightArrow.setX(this.optionsWidth - this.arrowSpacing - this.optionsBg.rightWidth); } // this line of code gets the center point between the left and right arrows from their left side (Arrow.x gives middle point), taking into account the width of the arrows - const xLocation = Math.round((challengeLabel.leftArrow.x + challengeLabel.rightArrow.x + challengeLabel.leftArrow.displayWidth) / 2); + const xLocation = Math.round( + (challengeLabel.leftArrow.x + challengeLabel.rightArrow.x + challengeLabel.leftArrow.displayWidth) / 2, + ); if (challenge.id === Challenges.SINGLE_TYPE) { this.monoTypeValue.setX(xLocation); this.monoTypeValue.setY(challengeLabel.label.y + 8); @@ -266,12 +314,10 @@ export default class GameChallengesUiHandler extends UiHandler { // This checks if a challenge has been selected by the user and updates the text/its opacity accordingly. this.hasSelectedChallenge = globalScene.gameMode.challenges.some(c => c.value !== 0); if (this.hasSelectedChallenge) { - this.startText.setText(i18next.t("common:start")); this.startText.setAlpha(1); this.startText.setPositionRelative(this.startBg, (this.startBg.width - this.startText.displayWidth) / 2, 4); } else { - this.startText.setText(i18next.t("challenges:noneSelected")); this.startText.setAlpha(0.5); this.startText.setPositionRelative(this.startBg, (this.startBg.width - this.startText.displayWidth) / 2, 4); @@ -362,14 +408,16 @@ export default class GameChallengesUiHandler extends UiHandler { case Button.UP: if (this.cursor === 0) { if (this.scrollCursor === 0) { - // When at the top of the menu and pressing UP, move to the bottommost item. - if (globalScene.gameMode.challenges.length > rowsToDisplay) { // If there are more than 9 challenges, scroll to the bottom - // First, set the cursor to the last visible element, preparing for the scroll to the end. + // When at the top of the menu and pressing UP, move to the bottommost item. + if (globalScene.gameMode.challenges.length > rowsToDisplay) { + // If there are more than 9 challenges, scroll to the bottom + // First, set the cursor to the last visible element, preparing for the scroll to the end. const successA = this.setCursor(rowsToDisplay - 1); // Then, adjust the scroll to display the bottommost elements of the menu. const successB = this.setScrollCursor(globalScene.gameMode.challenges.length - rowsToDisplay); success = successA && successB; // success is just there to play the little validation sound effect - } else { // If there are 9 or less challenges, just move to the bottom one + } else { + // If there are 9 or less challenges, just move to the bottom one success = this.setCursor(globalScene.gameMode.challenges.length - 1); } } else { @@ -385,18 +433,21 @@ export default class GameChallengesUiHandler extends UiHandler { case Button.DOWN: if (this.cursor === rowsToDisplay - 1) { if (this.scrollCursor < globalScene.gameMode.challenges.length - rowsToDisplay) { - // When at the bottom and pressing DOWN, scroll if possible. + // When at the bottom and pressing DOWN, scroll if possible. success = this.setScrollCursor(this.scrollCursor + 1); } else { - // When at the bottom of a scrolling menu and pressing DOWN, move to the topmost item. - // First, set the cursor to the first visible element, preparing for the scroll to the top. + // When at the bottom of a scrolling menu and pressing DOWN, move to the topmost item. + // First, set the cursor to the first visible element, preparing for the scroll to the top. const successA = this.setCursor(0); // Then, adjust the scroll to display the topmost elements of the menu. const successB = this.setScrollCursor(0); success = successA && successB; // success is just there to play the little validation sound effect } - } else if (globalScene.gameMode.challenges.length < rowsToDisplay && this.cursor === globalScene.gameMode.challenges.length - 1) { - // When at the bottom of a non-scrolling menu and pressing DOWN, move to the topmost item. + } else if ( + globalScene.gameMode.challenges.length < rowsToDisplay && + this.cursor === globalScene.gameMode.challenges.length - 1 + ) { + // When at the bottom of a non-scrolling menu and pressing DOWN, move to the topmost item. success = this.setCursor(0); } else { success = this.setCursor(this.cursor + 1); @@ -406,14 +457,14 @@ export default class GameChallengesUiHandler extends UiHandler { } break; case Button.LEFT: - // Moves the option cursor left, if possible. + // Moves the option cursor left, if possible. success = this.getActiveChallenge().decreaseValue(); if (success) { this.updateText(); } break; case Button.RIGHT: - // Moves the option cursor right, if possible. + // Moves the option cursor right, if possible. success = this.getActiveChallenge().increaseValue(); if (success) { this.updateText(); @@ -434,7 +485,18 @@ export default class GameChallengesUiHandler extends UiHandler { let ret = super.setCursor(cursor); if (!this.cursorObj) { - this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, this.optionsWidth - 8, 16, 1, 1, 1, 1); + this.cursorObj = globalScene.add.nineslice( + 0, + 0, + "summary_moves_cursor", + undefined, + this.optionsWidth - 8, + 16, + 1, + 1, + 1, + 1, + ); this.cursorObj.setOrigin(0, 0); this.valuesContainer.add(this.cursorObj); } diff --git a/src/ui/char-sprite.ts b/src/ui/char-sprite.ts index ccd97e2c8e4..74c021a65b8 100644 --- a/src/ui/char-sprite.ts +++ b/src/ui/char-sprite.ts @@ -10,11 +10,11 @@ export default class CharSprite extends Phaser.GameObjects.Container { public shown: boolean; constructor() { - super(globalScene, (globalScene.game.canvas.width / 6) + 32, -42); + super(globalScene, globalScene.game.canvas.width / 6 + 32, -42); } setup(): void { - [ this.sprite, this.transitionSprite ] = new Array(2).fill(null).map(() => { + [this.sprite, this.transitionSprite] = new Array(2).fill(null).map(() => { const ret = globalScene.add.sprite(0, 0, "", ""); ret.setOrigin(0.5, 1); this.add(ret); @@ -49,12 +49,12 @@ export default class CharSprite extends Phaser.GameObjects.Container { globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6) - 102, + x: globalScene.game.canvas.width / 6 - 102, duration: 750, ease: "Cubic.easeOut", onComplete: () => { resolve(); - } + }, }); this.setVisible(globalScene.textures.get(key).key !== Utils.MissingTextureKey); @@ -81,7 +81,7 @@ export default class CharSprite extends Phaser.GameObjects.Container { this.sprite.setTexture(this.key, variant); this.transitionSprite.setVisible(false); resolve(); - } + }, }); this.variant = variant; }); @@ -95,7 +95,7 @@ export default class CharSprite extends Phaser.GameObjects.Container { globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6) + 32, + x: globalScene.game.canvas.width / 6 + 32, duration: 750, ease: "Cubic.easeIn", onComplete: () => { @@ -103,7 +103,7 @@ export default class CharSprite extends Phaser.GameObjects.Container { this.setVisible(false); } resolve(); - } + }, }); this.shown = false; diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index 0dd3602d205..55937bb8b00 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -17,7 +17,7 @@ export enum Command { BALL, POKEMON, RUN, - TERA + TERA, } export default class CommandUiHandler extends UiHandler { @@ -26,8 +26,8 @@ export default class CommandUiHandler extends UiHandler { private teraButton: Phaser.GameObjects.Sprite; - protected fieldIndex: number = 0; - protected cursor2: number = 0; + protected fieldIndex = 0; + protected cursor2 = 0; constructor() { super(Mode.COMMAND); @@ -39,7 +39,7 @@ export default class CommandUiHandler extends UiHandler { i18next.t("commandUiHandler:fight"), i18next.t("commandUiHandler:ball"), i18next.t("commandUiHandler:pokemon"), - i18next.t("commandUiHandler:run") + i18next.t("commandUiHandler:run"), ]; this.commandsContainer = globalScene.add.container(217, -38.7); @@ -51,7 +51,12 @@ export default class CommandUiHandler extends UiHandler { this.teraButton.setName("terrastallize-button"); this.teraButton.setScale(1.3); this.teraButton.setFrame("fire"); - this.teraButton.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true, teraColor: getTypeRgb(PokemonType.FIRE), isTerastallized: false }); + this.teraButton.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + teraColor: getTypeRgb(PokemonType.FIRE), + isTerastallized: false, + }); this.commandsContainer.add(this.teraButton); for (let c = 0; c < commands.length; c++) { @@ -64,7 +69,7 @@ export default class CommandUiHandler extends UiHandler { show(args: any[]): boolean { super.show(args); - this.fieldIndex = args.length ? args[0] as number : 0; + this.fieldIndex = args.length ? (args[0] as number) : 0; this.commandsContainer.setVisible(true); @@ -92,7 +97,12 @@ export default class CommandUiHandler extends UiHandler { messageHandler.commandWindow.setVisible(true); messageHandler.movesWindowContainer.setVisible(false); messageHandler.message.setWordWrapWidth(this.canTera() ? 910 : 1110); - messageHandler.showText(i18next.t("commandUiHandler:actionMessage", { pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon()) }), 0); + messageHandler.showText( + i18next.t("commandUiHandler:actionMessage", { + pokemonName: getPokemonNameWithAffix(commandPhase.getPokemon()), + }), + 0, + ); if (this.getCursor() === Command.POKEMON) { this.setCursor(Command.FIGHT); } else { @@ -110,10 +120,9 @@ export default class CommandUiHandler extends UiHandler { const cursor = this.getCursor(); if (button === Button.CANCEL || button === Button.ACTION) { - if (button === Button.ACTION) { switch (cursor) { - // Fight + // Fight case Command.FIGHT: ui.setMode(Mode.FIGHT, (globalScene.getCurrentPhase() as CommandPhase).getFieldIndex()); success = true; @@ -125,7 +134,13 @@ export default class CommandUiHandler extends UiHandler { break; // Pokemon case Command.POKEMON: - ui.setMode(Mode.PARTY, PartyUiMode.SWITCH, (globalScene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex(), null, PartyUiHandler.FilterNonFainted); + ui.setMode( + Mode.PARTY, + PartyUiMode.SWITCH, + (globalScene.getCurrentPhase() as CommandPhase).getPokemon().getFieldIndex(), + null, + PartyUiHandler.FilterNonFainted, + ); success = true; break; // Run @@ -182,14 +197,21 @@ export default class CommandUiHandler extends UiHandler { canTera(): boolean { const hasTeraMod = !!globalScene.getModifiers(TerastallizeAccessModifier).length; const activePokemon = globalScene.getField()[this.fieldIndex]; - const isBlockedForm = activePokemon.isMega() || activePokemon.isMax() || activePokemon.hasSpecies(Species.NECROZMA, "ultra"); + const isBlockedForm = + activePokemon.isMega() || activePokemon.isMax() || activePokemon.hasSpecies(Species.NECROZMA, "ultra"); const currentTeras = globalScene.arena.playerTerasUsed; - const plannedTera = globalScene.currentBattle.preTurnCommands[0]?.command === Command.TERA && this.fieldIndex > 0 ? 1 : 0; - return hasTeraMod && !isBlockedForm && (currentTeras + plannedTera) < 1; + const plannedTera = + globalScene.currentBattle.preTurnCommands[0]?.command === Command.TERA && this.fieldIndex > 0 ? 1 : 0; + return hasTeraMod && !isBlockedForm && currentTeras + plannedTera < 1; } toggleTeraButton() { - this.teraButton.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true, teraColor: getTypeRgb(globalScene.getField()[this.fieldIndex].getTeraType()), isTerastallized: this.getCursor() === Command.TERA }); + this.teraButton.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + teraColor: getTypeRgb(globalScene.getField()[this.fieldIndex].getTeraType()), + isTerastallized: this.getCursor() === Command.TERA, + }); } getCursor(): number { diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index 3a3a5dfbfe7..a8710b0ab01 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -5,9 +5,7 @@ import i18next from "i18next"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; - export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { - public static readonly windowWidth: number = 48; private switchCheck: boolean; @@ -22,7 +20,13 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { } show(args: any[]): boolean { - if (args.length === 4 && args[0] instanceof Function && args[1] instanceof Function && args[2] instanceof Function && args[3] === "fullParty") { + if ( + args.length === 4 && + args[0] instanceof Function && + args[1] instanceof Function && + args[2] instanceof Function && + args[3] === "fullParty" + ) { const config: OptionSelectConfig = { options: [ { @@ -31,35 +35,38 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { args[0](); return true; }, - }, { + }, + { label: i18next.t("menu:yes"), handler: () => { args[1](); return true; - } - }, { + }, + }, + { label: i18next.t("menu:no"), handler: () => { args[2](); return true; - } - } + }, + }, ], - delay: args.length >= 8 && args[7] !== null ? args[7] as number : 0 + delay: args.length >= 8 && args[7] !== null ? (args[7] as number) : 0, }; - super.show([ config ]); + super.show([config]); - this.switchCheck = args.length >= 5 && args[4] !== null && args[4] as boolean; + this.switchCheck = args.length >= 5 && args[4] !== null && (args[4] as boolean); - const xOffset = (args.length >= 6 && args[5] !== null ? args[5] as number : 0); - const yOffset = (args.length >= 7 && args[6] !== null ? args[6] as number : 0); + const xOffset = args.length >= 6 && args[5] !== null ? (args[5] as number) : 0; + const yOffset = args.length >= 7 && args[6] !== null ? (args[6] as number) : 0; - this.optionSelectContainer.setPosition((globalScene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset); + this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); return true; - } else if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { + } + if (args.length >= 2 && args[0] instanceof Function && args[1] instanceof Function) { const config: OptionSelectConfig = { options: [ { @@ -67,28 +74,28 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { handler: () => { args[0](); return true; - } + }, }, { label: i18next.t("menu:no"), handler: () => { args[1](); return true; - } - } + }, + }, ], - delay: args.length >= 6 && args[5] !== null ? args[5] as number : 0, - noCancel: args.length >= 7 && args[6] !== null ? args[6] as boolean : false, + delay: args.length >= 6 && args[5] !== null ? (args[5] as number) : 0, + noCancel: args.length >= 7 && args[6] !== null ? (args[6] as boolean) : false, }; - super.show([ config ]); + super.show([config]); - this.switchCheck = args.length >= 3 && args[2] !== null && args[2] as boolean; + this.switchCheck = args.length >= 3 && args[2] !== null && (args[2] as boolean); - const xOffset = (args.length >= 4 && args[3] !== null ? args[3] as number : 0); - const yOffset = (args.length >= 5 && args[4] !== null ? args[4] as number : 0); + const xOffset = args.length >= 4 && args[3] !== null ? (args[3] as number) : 0; + const yOffset = args.length >= 5 && args[4] !== null ? (args[4] as number) : 0; - this.optionSelectContainer.setPosition((globalScene.game.canvas.width / 6) - 1 + xOffset, -48 + yOffset); + this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); diff --git a/src/ui/daily-run-scoreboard.ts b/src/ui/daily-run-scoreboard.ts index d9131150262..53c737898e7 100644 --- a/src/ui/daily-run-scoreboard.ts +++ b/src/ui/daily-run-scoreboard.ts @@ -6,16 +6,16 @@ import { WindowVariant, addWindow } from "./ui-theme"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; export interface RankingEntry { - rank: number, - username: string, - score: number, - wave: number + rank: number; + username: string; + score: number; + wave: number; } // Don't forget to update translations when adding a new category export enum ScoreboardCategory { DAILY, - WEEKLY + WEEKLY, } export class DailyRunScoreboard extends Phaser.GameObjects.Container { @@ -63,7 +63,13 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { const titleWindow = addWindow(0, 0, 114, 18, false, false, undefined, undefined, WindowVariant.THIN); this.add(titleWindow); - this.titleLabel = addTextObject(titleWindow.displayWidth / 2, titleWindow.displayHeight / 2, i18next.t("menu:loading"), TextStyle.WINDOW, { fontSize: "64px" }); + this.titleLabel = addTextObject( + titleWindow.displayWidth / 2, + titleWindow.displayHeight / 2, + i18next.t("menu:loading"), + TextStyle.WINDOW, + { fontSize: "64px" }, + ); this.titleLabel.setOrigin(0.5, 0.5); this.add(this.titleLabel); @@ -95,7 +101,11 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { this.update(this.category < Utils.getEnumKeys(ScoreboardCategory).length - 1 ? this.category + 1 : 0); }); - this.prevPageButton = globalScene.add.sprite(window.displayWidth / 2 - 16, titleWindow.displayHeight + window.displayHeight - 15, "cursor_reverse"); + this.prevPageButton = globalScene.add.sprite( + window.displayWidth / 2 - 16, + titleWindow.displayHeight + window.displayHeight - 15, + "cursor_reverse", + ); this.prevPageButton.setOrigin(0, 0); this.prevPageButton.setAlpha(0.5); this.add(this.prevPageButton); @@ -107,11 +117,21 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { } }); - this.pageNumberLabel = addTextObject(window.displayWidth / 2, titleWindow.displayHeight + window.displayHeight - 16, "1", TextStyle.WINDOW, { fontSize: "64px" }); + this.pageNumberLabel = addTextObject( + window.displayWidth / 2, + titleWindow.displayHeight + window.displayHeight - 16, + "1", + TextStyle.WINDOW, + { fontSize: "64px" }, + ); this.pageNumberLabel.setOrigin(0.5, 0); this.add(this.pageNumberLabel); - this.nextPageButton = globalScene.add.sprite(window.displayWidth / 2 + 16, titleWindow.displayHeight + window.displayHeight - 15, "cursor"); + this.nextPageButton = globalScene.add.sprite( + window.displayWidth / 2 + 16, + titleWindow.displayHeight + window.displayHeight - 15, + "cursor", + ); this.nextPageButton.setOrigin(1, 0); this.nextPageButton.setAlpha(0.5); this.add(this.nextPageButton); @@ -133,18 +153,26 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { const getEntry = (rank: string, username: string, score: string, wave: string) => { const entryContainer = globalScene.add.container(0, 0); - const rankLabel = addTextObject(0, 0, rank, TextStyle.WINDOW, { fontSize: "54px" }); + const rankLabel = addTextObject(0, 0, rank, TextStyle.WINDOW, { + fontSize: "54px", + }); entryContainer.add(rankLabel); - const usernameLabel = addTextObject(12, 0, username, TextStyle.WINDOW, { fontSize: "54px" }); + const usernameLabel = addTextObject(12, 0, username, TextStyle.WINDOW, { + fontSize: "54px", + }); entryContainer.add(usernameLabel); - const scoreLabel = addTextObject(84, 0, score, TextStyle.WINDOW, { fontSize: "54px" }); + const scoreLabel = addTextObject(84, 0, score, TextStyle.WINDOW, { + fontSize: "54px", + }); entryContainer.add(scoreLabel); switch (this.category) { case ScoreboardCategory.DAILY: - const waveLabel = addTextObject(68, 0, wave, TextStyle.WINDOW, { fontSize: "54px" }); + const waveLabel = addTextObject(68, 0, wave, TextStyle.WINDOW, { + fontSize: "54px", + }); entryContainer.add(waveLabel); break; case ScoreboardCategory.WEEKLY: @@ -155,7 +183,14 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { return entryContainer; }; - this.rankingsContainer.add(getEntry(i18next.t("menu:positionIcon"), i18next.t("menu:usernameScoreboard"), i18next.t("menu:score"), i18next.t("menu:wave"))); + this.rankingsContainer.add( + getEntry( + i18next.t("menu:positionIcon"), + i18next.t("menu:usernameScoreboard"), + i18next.t("menu:score"), + i18next.t("menu:wave"), + ), + ); rankings.forEach((r: RankingEntry, i: number) => { const entryContainer = getEntry(r.rank.toString(), r.username, r.score.toString(), r.wave.toString()); @@ -175,7 +210,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { * * @param {ScoreboardCategory} [category=this.category] - The category to fetch rankings for. Defaults to the current category. * @param {number} [page=this.page] - The page number to fetch. Defaults to the current page. - */ + */ update(category: ScoreboardCategory = this.category, page: number = this.page) { if (this.isUpdating) { return; @@ -191,39 +226,49 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { this.page = page = 1; } - Utils.executeIf(category !== this.category || this.pageCount === undefined, - () => pokerogueApi.daily.getRankingsPageCount({ category }).then(count => this.pageCount = count) - ).then(() => { - pokerogueApi.daily.getRankings({ category, page }) - .then(rankings => { - this.page = page; - this.category = category; - this.titleLabel.setText(`${i18next.t(`menu:${ScoreboardCategory[category].toLowerCase()}Rankings`)}`); - this.pageNumberLabel.setText(page.toString()); - if (rankings) { - this.loadingLabel.setVisible(false); - this.updateRankings(rankings); - } else { - this.loadingLabel.setText(i18next.t("menu:noRankings")); - } - }).finally(() => { - this.isUpdating = false; - }); - }).catch(err => { - console.error("Failed to load daily rankings:\n", err); - }); + Utils.executeIf(category !== this.category || this.pageCount === undefined, () => + pokerogueApi.daily.getRankingsPageCount({ category }).then(count => (this.pageCount = count)), + ) + .then(() => { + pokerogueApi.daily + .getRankings({ category, page }) + .then(rankings => { + this.page = page; + this.category = category; + this.titleLabel.setText(`${i18next.t(`menu:${ScoreboardCategory[category].toLowerCase()}Rankings`)}`); + this.pageNumberLabel.setText(page.toString()); + if (rankings) { + this.loadingLabel.setVisible(false); + this.updateRankings(rankings); + } else { + this.loadingLabel.setText(i18next.t("menu:noRankings")); + } + }) + .finally(() => { + this.isUpdating = false; + }); + }) + .catch(err => { + console.error("Failed to load daily rankings:\n", err); + }); } /** * Sets the state of the navigation buttons. * @param {boolean} [enabled=true] - Whether the buttons should be enabled or disabled. */ - setButtonsState(enabled: boolean = true) { + setButtonsState(enabled = true) { const buttons = [ - { button: this.prevPageButton, alphaValue: enabled ? (this.page > 1 ? 1 : 0.5) : 0.5 }, - { button: this.nextPageButton, alphaValue: enabled ? (this.page < this.pageCount ? 1 : 0.5) : 0.5 }, + { + button: this.prevPageButton, + alphaValue: enabled ? (this.page > 1 ? 1 : 0.5) : 0.5, + }, + { + button: this.nextPageButton, + alphaValue: enabled ? (this.page < this.pageCount ? 1 : 0.5) : 0.5, + }, { button: this.nextCategoryButton, alphaValue: enabled ? 1 : 0.5 }, - { button: this.prevCategoryButton, alphaValue: enabled ? 1 : 0.5 } + { button: this.prevCategoryButton, alphaValue: enabled ? 1 : 0.5 }, ]; buttons.forEach(({ button, alphaValue }) => { diff --git a/src/ui/dropdown.ts b/src/ui/dropdown.ts index ec433a35733..2cbd1f0dfa9 100644 --- a/src/ui/dropdown.ts +++ b/src/ui/dropdown.ts @@ -5,24 +5,24 @@ import { ScrollBar } from "#app/ui/scroll-bar"; import i18next from "i18next"; export enum DropDownState { - ON = 0, - OFF = 1, - EXCLUDE = 2, - UNLOCKABLE = 3, - ONE = 4, - TWO = 5 + ON = 0, + OFF = 1, + EXCLUDE = 2, + UNLOCKABLE = 3, + ONE = 4, + TWO = 5, } export enum DropDownType { - SINGLE = 0, - MULTI = 1, - HYBRID = 2, - RADIAL = 3 + SINGLE = 0, + MULTI = 1, + HYBRID = 2, + RADIAL = 3, } export enum SortDirection { ASC = -1, - DESC = 1 + DESC = 1, } export enum SortCriteria { @@ -32,7 +32,7 @@ export enum SortCriteria { IV = 3, NAME = 4, CAUGHT = 5, - HATCHED = 6 + HATCHED = 6, } export class DropDownLabel { @@ -47,7 +47,6 @@ export class DropDownLabel { } } - export class DropDownOption extends Phaser.GameObjects.Container { public state: DropDownState = DropDownState.ON; public toggle: Phaser.GameObjects.Sprite; @@ -70,7 +69,7 @@ export class DropDownOption extends Phaser.GameObjects.Container { if (Array.isArray(labels)) { this.labels = labels; } else { - this.labels = labels ? [ labels ] : [ new DropDownLabel("") ]; + this.labels = labels ? [labels] : [new DropDownLabel("")]; } this.currentLabelIndex = 0; const currentLabel = this.labels[this.currentLabelIndex]; @@ -105,7 +104,7 @@ export class DropDownOption extends Phaser.GameObjects.Container { this.toggle = globalScene.add.sprite(0, 0, "cursor"); this.toggle.setScale(0.5); this.toggle.setOrigin(0, 0.5); - this.toggle.setRotation(Math.PI / 180 * -90); + this.toggle.setRotation((Math.PI / 180) * -90); } else { this.toggle = globalScene.add.sprite(0, 0, "candy"); this.toggle.setScale(0.3); @@ -279,35 +278,40 @@ export class DropDownOption extends Phaser.GameObjects.Container { this.text.setText(currentText); return w; } - } - export class DropDown extends Phaser.GameObjects.Container { public options: DropDownOption[]; private window: Phaser.GameObjects.NineSlice; private cursorObj: Phaser.GameObjects.Image; public dropDownType: DropDownType = DropDownType.MULTI; - public cursor: number = 0; - private lastCursor: number = -1; - public defaultCursor: number = 0; + public cursor = 0; + private lastCursor = -1; + public defaultCursor = 0; private onChange: () => void; private lastDir: SortDirection = SortDirection.ASC; private defaultSettings: any[]; private dropDownScrollBar: ScrollBar; - private totalOptions: number = 0; - private maxOptions: number = 0; - private shownOptions: number = 0; - private tooManyOptions: Boolean = false; - private firstShown: number = 0; - private optionHeight: number = 0; - private optionSpacing: number = 0; - private optionPaddingX: number = 4; - private optionPaddingY: number = 6; - private optionWidth: number = 100; - private cursorOffset: number = 0; + private totalOptions = 0; + private maxOptions = 0; + private shownOptions = 0; + private tooManyOptions = false; + private firstShown = 0; + private optionHeight = 0; + private optionSpacing = 0; + private optionPaddingX = 4; + private optionPaddingY = 6; + private optionWidth = 100; + private cursorOffset = 0; - constructor(x: number, y: number, options: DropDownOption[], onChange: () => void, type: DropDownType = DropDownType.MULTI, optionSpacing: number = 2) { + constructor( + x: number, + y: number, + options: DropDownOption[], + onChange: () => void, + type: DropDownType = DropDownType.MULTI, + optionSpacing = 2, + ) { const windowPadding = 5; const cursorOffset = 7; @@ -331,7 +335,16 @@ export class DropDown extends Phaser.GameObjects.Container { // For MULTI and HYBRID filter, add an ALL option at the top if (this.dropDownType === DropDownType.MULTI || this.dropDownType === DropDownType.HYBRID) { - this.options.unshift(new DropDownOption("ALL", new DropDownLabel(i18next.t("filterBar:all"), undefined, this.checkForAllOn() ? DropDownState.ON : DropDownState.OFF))); + this.options.unshift( + new DropDownOption( + "ALL", + new DropDownLabel( + i18next.t("filterBar:all"), + undefined, + this.checkForAllOn() ? DropDownState.ON : DropDownState.OFF, + ), + ), + ); } this.maxOptions = 19; @@ -343,7 +356,6 @@ export class DropDown extends Phaser.GameObjects.Container { // Place ui elements in the correct spot options.forEach((option, index) => { - const toggleVisibility = type !== DropDownType.SINGLE || option.state === DropDownState.ON; option.setupToggleIcon(type, toggleVisibility); @@ -366,7 +378,17 @@ export class DropDown extends Phaser.GameObjects.Container { this.firstShown = 0; }); - this.window = addWindow(0, 0, this.optionWidth, options[this.shownOptions - 1].y + this.optionHeight + this.optionPaddingY, false, false, undefined, undefined, WindowVariant.XTHIN); + this.window = addWindow( + 0, + 0, + this.optionWidth, + options[this.shownOptions - 1].y + this.optionHeight + this.optionPaddingY, + false, + false, + undefined, + undefined, + WindowVariant.XTHIN, + ); this.add(this.window); this.add(options); this.add(this.cursorObj); @@ -408,7 +430,6 @@ export class DropDown extends Phaser.GameObjects.Container { } setCursor(cursor: number): boolean { - if (this.tooManyOptions) { this.setLabels(cursor); } @@ -418,37 +439,35 @@ export class DropDown extends Phaser.GameObjects.Container { cursor = 0; this.cursorObj.setVisible(false); return false; - } else if (cursor >= this.options.length) { + } + if (cursor >= this.options.length) { cursor = this.options.length - 1; this.cursorObj.y = this.options[cursor].y + 3.5; this.cursorObj.setVisible(true); return false; - } else { - this.cursorObj.y = this.options[cursor].y + 3.5; - this.cursorObj.setVisible(true); - // If hydrid type, we need to update the filters when going up/down in the list - if (this.dropDownType === DropDownType.HYBRID) { - this.lastCursor = cursor; - this.onChange(); - } + } + this.cursorObj.y = this.options[cursor].y + 3.5; + this.cursorObj.setVisible(true); + // If hydrid type, we need to update the filters when going up/down in the list + if (this.dropDownType === DropDownType.HYBRID) { + this.lastCursor = cursor; + this.onChange(); } return true; } setLabels(cursor: number) { - - if ((cursor === 0) && (this.lastCursor === this.totalOptions - 1)) { + if (cursor === 0 && this.lastCursor === this.totalOptions - 1) { this.firstShown = 0; - } else if ((cursor === this.totalOptions - 1) && (this.lastCursor === 0)) { + } else if (cursor === this.totalOptions - 1 && this.lastCursor === 0) { this.firstShown = this.totalOptions - this.shownOptions; - } else if ((cursor - this.firstShown >= this.shownOptions) && (cursor > this.lastCursor)) { + } else if (cursor - this.firstShown >= this.shownOptions && cursor > this.lastCursor) { this.firstShown += 1; - } else if ((cursor < this.firstShown) && (cursor < this.lastCursor)) { + } else if (cursor < this.firstShown && cursor < this.lastCursor) { this.firstShown -= 1; } this.options.forEach((option, index) => { - option.y = (index - this.firstShown) * (this.optionHeight + this.optionSpacing) + this.optionPaddingY; const baseX = this.cursorOffset + this.optionPaddingX + 3; @@ -460,7 +479,7 @@ export class DropDown extends Phaser.GameObjects.Container { option.setTogglePosition(baseX, baseY); } - if ((index < this.firstShown) || ( index >= this.firstShown + this.shownOptions)) { + if (index < this.firstShown || index >= this.firstShown + this.shownOptions) { option.visible = false; } else { option.visible = true; @@ -494,7 +513,7 @@ export class DropDown extends Phaser.GameObjects.Container { } } else if (this.dropDownType === DropDownType.SINGLE) { if (option.state === DropDownState.OFF) { - this.options.forEach((option) => { + this.options.forEach(option => { option.setOptionState(DropDownState.OFF); option.setDirection(SortDirection.ASC); option.toggle.setVisible(false); @@ -537,9 +556,12 @@ export class DropDown extends Phaser.GameObjects.Container { */ getVals(): any[] { if (this.dropDownType === DropDownType.MULTI) { - return this.options.filter((option, i) => i > 0 && option.state === DropDownState.ON).map((option) => option.val); - } else if (this.dropDownType === DropDownType.HYBRID) { - const selected = this.options.filter((option, i) => i > 0 && option.state === DropDownState.ON).map((option) => option.val); + return this.options.filter((option, i) => i > 0 && option.state === DropDownState.ON).map(option => option.val); + } + if (this.dropDownType === DropDownType.HYBRID) { + const selected = this.options + .filter((option, i) => i > 0 && option.state === DropDownState.ON) + .map(option => option.val); if (selected.length > 0) { return selected; } @@ -548,16 +570,18 @@ export class DropDown extends Phaser.GameObjects.Container { return this.options.filter((_, i) => i > 0).map(option => option.val); } // if nothing is selected and a single option is hovered, return that one - return [ this.options[this.cursor].val ]; - } else if (this.dropDownType === DropDownType.RADIAL) { - return this.options.map((option) => { + return [this.options[this.cursor].val]; + } + if (this.dropDownType === DropDownType.RADIAL) { + return this.options.map(option => { return { val: option.val, state: option.state }; }); - } else { - return this.options.filter(option => option.state === DropDownState.ON).map((option) => { + } + return this.options + .filter(option => option.state === DropDownState.ON) + .map(option => { return { val: option.val, dir: option.dir }; }); - } } /** @@ -566,9 +590,14 @@ export class DropDown extends Phaser.GameObjects.Container { * - the settings dictionary is like this { val: any, state: DropDownState, cursor: boolean, dir: SortDirection } */ private getSettings(): any[] { - const settings : any[] = []; + const settings: any[] = []; for (let i = 0; i < this.options.length; i++) { - settings.push({ val: this.options[i].val, state: this.options[i].state, cursor: (this.cursor === i), dir: this.options[i].dir }); + settings.push({ + val: this.options[i].val, + state: this.options[i].state, + cursor: this.cursor === i, + dir: this.options[i].dir, + }); } return settings; } @@ -581,22 +610,22 @@ export class DropDown extends Phaser.GameObjects.Container { const currentValues = this.getSettings(); const compareValues = (keys: string[]): boolean => { - return currentValues.length === this.defaultSettings.length && - currentValues.every((value, index) => - keys.every(key => value[key] === this.defaultSettings[index][key]) - ); + return ( + currentValues.length === this.defaultSettings.length && + currentValues.every((value, index) => keys.every(key => value[key] === this.defaultSettings[index][key])) + ); }; switch (this.dropDownType) { case DropDownType.MULTI: case DropDownType.RADIAL: - return compareValues([ "val", "state" ]); + return compareValues(["val", "state"]); case DropDownType.HYBRID: - return compareValues([ "val", "state", "cursor" ]); + return compareValues(["val", "state", "cursor"]); case DropDownType.SINGLE: - return compareValues([ "val", "state", "dir" ]); + return compareValues(["val", "state", "dir"]); default: return false; @@ -638,7 +667,7 @@ export class DropDown extends Phaser.GameObjects.Container { * Set all options to a specific state * @param state the DropDownState to assign to each option */ - private setAllOptions(state: DropDownState) : void { + private setAllOptions(state: DropDownState): void { // For single type dropdown, setting all options is not relevant if (this.dropDownType === DropDownType.SINGLE) { return; @@ -687,5 +716,4 @@ export class DropDown extends Phaser.GameObjects.Container { this.x = this.parentContainer.width - this.window.width; } } - } diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index 3cd8a7e8dc9..cb6a474f01d 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -38,7 +38,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { private summaryFinished: boolean; private defaultText: string; - private scale: number = 0.1666666667; + private scale = 0.1666666667; constructor() { super(Mode.EGG_GACHA); @@ -68,18 +68,18 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaContainer.add(bg); const hatchFrameNames = globalScene.anims.generateFrameNames("gacha_hatch", { suffix: ".png", start: 1, end: 4 }); - if (!(globalScene.anims.exists("open"))) { + if (!globalScene.anims.exists("open")) { globalScene.anims.create({ key: "open", frames: hatchFrameNames, - frameRate: 12 + frameRate: 12, }); } - if (!(globalScene.anims.exists("close"))) { + if (!globalScene.anims.exists("close")) { globalScene.anims.create({ key: "close", frames: hatchFrameNames.reverse(), - frameRate: 12 + frameRate: 12, }); } @@ -108,7 +108,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { let pokemonIconX = -20; let pokemonIconY = 6; - if ([ "de", "es-ES", "fr", "ko", "pt-BR" ].includes(currentLanguage)) { + if (["de", "es-ES", "fr", "ko", "pt-BR"].includes(currentLanguage)) { gachaTextStyle = TextStyle.SMALLER_WINDOW_ALT; gachaX = 2; gachaY = 2; @@ -116,7 +116,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { let legendaryLabelX = gachaX; let legendaryLabelY = gachaY; - if ([ "de", "es-ES" ].includes(currentLanguage)) { + if (["de", "es-ES"].includes(currentLanguage)) { pokemonIconX = -25; pokemonIconY = 10; legendaryLabelX = -6; @@ -129,11 +129,11 @@ export default class EggGachaUiHandler extends MessageUiHandler { switch (gachaType as GachaType) { case GachaType.LEGENDARY: - if ([ "de", "es-ES" ].includes(currentLanguage)) { + if (["de", "es-ES"].includes(currentLanguage)) { gachaUpLabel.setAlign("center"); gachaUpLabel.setY(0); } - if ([ "pt-BR" ].includes(currentLanguage)) { + if (["pt-BR"].includes(currentLanguage)) { gachaUpLabel.setX(legendaryLabelX - 2); } else { gachaUpLabel.setX(legendaryLabelX); @@ -141,7 +141,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { gachaUpLabel.setY(legendaryLabelY); const pokemonIcon = globalScene.add.sprite(pokemonIconX, pokemonIconY, "pokemon_icons_0"); - if ([ "pt-BR" ].includes(currentLanguage)) { + if (["pt-BR"].includes(currentLanguage)) { pokemonIcon.setX(pokemonIconX - 2); } pokemonIcon.setScale(0.5); @@ -150,7 +150,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { gachaInfoContainer.add(pokemonIcon); break; case GachaType.MOVE: - if ([ "de", "es-ES", "fr", "pt-BR" ].includes(currentLanguage)) { + if (["de", "es-ES", "fr", "pt-BR"].includes(currentLanguage)) { gachaUpLabel.setAlign("center"); gachaUpLabel.setY(0); } @@ -160,7 +160,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { gachaUpLabel.setOrigin(0.5, 0); break; case GachaType.SHINY: - if ([ "de", "fr", "ko" ].includes(currentLanguage)) { + if (["de", "fr", "ko"].includes(currentLanguage)) { gachaUpLabel.setAlign("center"); gachaUpLabel.setY(0); } @@ -187,7 +187,9 @@ export default class EggGachaUiHandler extends MessageUiHandler { gachaGlass.setAlpha(0.5); gachaHatch.setAlpha(0.9); - gachaHatch.on("animationupdate", (_anim, frame) => gachaUnderlay.setFrame(frame.textureFrame === "4.png" ? "open_hatch" : "default")); + gachaHatch.on("animationupdate", (_anim, frame) => + gachaUnderlay.setFrame(frame.textureFrame === "4.png" ? "open_hatch" : "default"), + ); this.gachaContainers.push(gachaContainer); this.gachaKnobs.push(gachaKnob); @@ -201,10 +203,9 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaOptionsContainer = globalScene.add.container(); - this.eggGachaOptionsContainer = globalScene.add.container((globalScene.game.canvas.width / 6), 148); + this.eggGachaOptionsContainer = globalScene.add.container(globalScene.game.canvas.width / 6, 148); this.eggGachaContainer.add(this.eggGachaOptionsContainer); - this.eggGachaOptionSelectBg = addWindow(0, 0, 96, 16 + 576 * this.scale); this.eggGachaOptionSelectBg.setOrigin(1, 1); this.eggGachaOptionsContainer.add(this.eggGachaOptionSelectBg); @@ -212,31 +213,48 @@ export default class EggGachaUiHandler extends MessageUiHandler { const multiplierOne = "x1"; const multiplierTen = "x10"; const pullOptions = [ - { multiplier: multiplierOne, description: `1 ${i18next.t("egg:pull")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) }, - { multiplier: multiplierTen, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) }, - { multiplier: multiplierOne, description: `5 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PLUS) }, - { multiplier: multiplierOne, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PREMIUM) }, - { multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) } + { + multiplier: multiplierOne, + description: `1 ${i18next.t("egg:pull")}`, + icon: getVoucherTypeIcon(VoucherType.REGULAR), + }, + { + multiplier: multiplierTen, + description: `10 ${i18next.t("egg:pulls")}`, + icon: getVoucherTypeIcon(VoucherType.REGULAR), + }, + { + multiplier: multiplierOne, + description: `5 ${i18next.t("egg:pulls")}`, + icon: getVoucherTypeIcon(VoucherType.PLUS), + }, + { + multiplier: multiplierOne, + description: `10 ${i18next.t("egg:pulls")}`, + icon: getVoucherTypeIcon(VoucherType.PREMIUM), + }, + { + multiplier: multiplierOne, + description: `25 ${i18next.t("egg:pulls")}`, + icon: getVoucherTypeIcon(VoucherType.GOLDEN), + }, ]; const resolvedLanguage = i18next.resolvedLanguage ?? "en"; - const pullOptionsText = pullOptions.map(option =>{ - const desc = option.description.split(" "); - if (desc[0].length < 2) { - desc[0] += [ "zh", "ko" ].includes(resolvedLanguage.substring(0, 2)) ? " " : " "; - } - if (option.multiplier === multiplierOne) { - desc[0] = " " + desc[0]; - } - return ` ${option.multiplier.padEnd(5)}${desc.join(" ")}`; - }).join("\n"); + const pullOptionsText = pullOptions + .map(option => { + const desc = option.description.split(" "); + if (desc[0].length < 2) { + desc[0] += ["zh", "ko"].includes(resolvedLanguage.substring(0, 2)) ? " " : " "; + } + if (option.multiplier === multiplierOne) { + desc[0] = " " + desc[0]; + } + return ` ${option.multiplier.padEnd(5)}${desc.join(" ")}`; + }) + .join("\n"); - const optionText = addTextObject( - 0, - 0, - `${pullOptionsText}\n${i18next.t("menu:cancel")}`, - TextStyle.WINDOW, - ); + const optionText = addTextObject(0, 0, `${pullOptionsText}\n${i18next.t("menu:cancel")}`, TextStyle.WINDOW); optionText.setLineSpacing(28); optionText.setFontSize("80px"); @@ -255,7 +273,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaContainer.add(this.eggGachaOptionsContainer); new Array(Utils.getEnumKeys(VoucherType).length).fill(null).map((_, i) => { - const container = globalScene.add.container((globalScene.game.canvas.width / 6) - 56 * i, 0); + const container = globalScene.add.container(globalScene.game.canvas.width / 6 - 56 * i, 0); const bg = addWindow(0, 0, 56, 22); bg.setOrigin(1, 0); @@ -295,7 +313,9 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.eggGachaMessageBox = gachaMessageBox; - const gachaMessageText = addTextObject(8, 8, "", TextStyle.WINDOW, { maxLines: 2 }); + const gachaMessageText = addTextObject(8, 8, "", TextStyle.WINDOW, { + maxLines: 2, + }); gachaMessageText.setOrigin(0, 0); gachaMessageBoxContainer.add(gachaMessageText); @@ -338,7 +358,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { return Utils.fixedInt(delay); } - pull(pullCount: number = 0, count: number = 0, eggs?: Egg[]): void { + pull(pullCount = 0, count = 0, eggs?: Egg[]): void { if (Overrides.EGG_GACHA_PULL_COUNT_OVERRIDE && !count) { pullCount = Overrides.EGG_GACHA_PULL_COUNT_OVERRIDE; } @@ -376,7 +396,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { targets: egg, duration: this.getDelayValue(350), scale: 0.75, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); globalScene.tweens.add({ targets: egg, @@ -396,12 +416,12 @@ export default class EggGachaUiHandler extends MessageUiHandler { } else { this.showSummary(eggs!); } - } + }, }); - } + }, }); }); - } + }, }); }); }); @@ -419,10 +439,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { targets: this.gachaKnobs[this.gachaCursor], duration: this.getDelayValue(350), angle: 0, - ease: "Sine.easeInOut" + ease: "Sine.easeInOut", }); globalScene.time.delayedCall(this.getDelayValue(350), doPullAnim); - } + }, }); } else { doPullAnim(); @@ -438,7 +458,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { if (!eggs) { eggs = []; for (let i = 1; i <= pullCount; i++) { - const eggOptions: IEggOptions = { pulled: true, sourceType: this.gachaCursor }; + const eggOptions: IEggOptions = { + pulled: true, + sourceType: this.gachaCursor, + }; // Before creating the last egg, check if the guaranteed egg tier was already generated // if not, override the egg tier @@ -455,8 +478,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { // Shuffle the eggs in case the guaranteed one got added as last egg eggs = Utils.randSeedShuffle(eggs); - - (globalScene.currentBattle ? globalScene.gameData.saveAll(true, true, true) : globalScene.gameData.saveSystem()).then(success => { + (globalScene.currentBattle + ? globalScene.gameData.saveAll(true, true, true) + : globalScene.gameData.saveSystem() + ).then(success => { if (!success) { return globalScene.reset(true); } @@ -507,8 +532,11 @@ export default class EggGachaUiHandler extends MessageUiHandler { const row = Math.floor(t / rowItems); const sliceWidth = this.eggGachaOverlay.displayWidth / (cols + 2); const sliceHeight = height / (rows + 2); - const yOffset = (sliceHeight / 2 * (row / Math.max(rows - 1, 1))) + sliceHeight / 4; - const ret = globalScene.add.container(sliceWidth * (col + 1) + (sliceWidth * 0.5), sliceHeight * (row + 1) + yOffset); + const yOffset = (sliceHeight / 2) * (row / Math.max(rows - 1, 1)) + sliceHeight / 4; + const ret = globalScene.add.container( + sliceWidth * (col + 1) + sliceWidth * 0.5, + sliceHeight * (row + 1) + yOffset, + ); ret.setScale(0.0001); const eggSprite = globalScene.add.sprite(0, 0, "egg", `egg_${egg.getKey()}`); @@ -538,18 +566,18 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.setTransitioning(false); this.summaryFinished = true; } - } - })); - + }, + }), + ); }); - } + }, }); } hideSummary() { this.setTransitioning(true); globalScene.tweens.add({ - targets: [ this.eggGachaOverlay, this.eggGachaSummaryContainer ], + targets: [this.eggGachaOverlay, this.eggGachaSummaryContainer], alpha: 0, duration: this.getDelayValue(250), ease: "Cubic.easeIn", @@ -560,7 +588,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { this.setTransitioning(false); this.summaryFinished = false; this.eggGachaOptionsContainer.setVisible(true); - } + }, }); } @@ -576,7 +604,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { } consumeVouchers(voucherType: VoucherType, count: number): void { - globalScene.gameData.voucherCounts[voucherType] = Math.max(globalScene.gameData.voucherCounts[voucherType] - count, 0); + globalScene.gameData.voucherCounts[voucherType] = Math.max( + globalScene.gameData.voucherCounts[voucherType] - count, + 0, + ); this.updateVoucherCounts(); } @@ -586,7 +617,14 @@ export default class EggGachaUiHandler extends MessageUiHandler { }); } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number): void { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + ): void { if (!text) { text = this.defaultText; } @@ -630,7 +668,6 @@ export default class EggGachaUiHandler extends MessageUiHandler { return false; } } else { - if (this.eggGachaSummaryContainer.visible) { if (this.summaryFinished && (button === Button.ACTION || button === Button.CANCEL)) { this.hideSummary(); @@ -641,7 +678,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { case Button.ACTION: switch (this.cursor) { case 0: - if (!globalScene.gameData.voucherCounts[VoucherType.REGULAR] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { + if ( + !globalScene.gameData.voucherCounts[VoucherType.REGULAR] && + !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE + ) { error = true; this.showError(i18next.t("egg:notEnoughVouchers")); } else if (globalScene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { @@ -672,8 +712,14 @@ export default class EggGachaUiHandler extends MessageUiHandler { break; case 1: case 3: - if ((this.cursor === 1 && globalScene.gameData.voucherCounts[VoucherType.REGULAR] < 10 && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) - || (this.cursor === 3 && !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE)) { + if ( + (this.cursor === 1 && + globalScene.gameData.voucherCounts[VoucherType.REGULAR] < 10 && + !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) || + (this.cursor === 3 && + !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] && + !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) + ) { error = true; this.showError(i18next.t("egg:notEnoughVouchers")); } else if (globalScene.gameData.eggs.length < 90 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { @@ -694,7 +740,10 @@ export default class EggGachaUiHandler extends MessageUiHandler { } break; case 4: - if (!globalScene.gameData.voucherCounts[VoucherType.GOLDEN] && !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) { + if ( + !globalScene.gameData.voucherCounts[VoucherType.GOLDEN] && + !Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE + ) { error = true; this.showError(i18next.t("egg:notEnoughVouchers")); } else if (globalScene.gameData.eggs.length < 75 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { @@ -780,7 +829,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { duration: this.eggGachaContainer.visible ? 500 : 0, x: (_target, _key, _value, index) => 180 * (index - cursor), ease: "Cubic.easeInOut", - onComplete: () => this.setTransitioning(false) + onComplete: () => this.setTransitioning(false), }); } diff --git a/src/ui/egg-hatch-scene-handler.ts b/src/ui/egg-hatch-scene-handler.ts index 791c488c91a..6ede68b7ae6 100644 --- a/src/ui/egg-hatch-scene-handler.ts +++ b/src/ui/egg-hatch-scene-handler.ts @@ -24,11 +24,11 @@ export default class EggHatchSceneHandler extends UiHandler { globalScene.fieldUI.add(this.eggHatchContainer); const eggLightraysAnimFrames = globalScene.anims.generateFrameNames("egg_lightrays", { start: 0, end: 3 }); - if (!(globalScene.anims.exists("egg_lightrays"))) { + if (!globalScene.anims.exists("egg_lightrays")) { globalScene.anims.create({ key: "egg_lightrays", frames: eggLightraysAnimFrames, - frameRate: 32 + frameRate: 32, }); } } diff --git a/src/ui/egg-list-ui-handler.ts b/src/ui/egg-list-ui-handler.ts index 1b25d55d96d..cf3326bec13 100644 --- a/src/ui/egg-list-ui-handler.ts +++ b/src/ui/egg-list-ui-handler.ts @@ -24,7 +24,7 @@ export default class EggListUiHandler extends MessageUiHandler { private eggListMessageBoxContainer: Phaser.GameObjects.Container; private cursorObj: Phaser.GameObjects.Image; - private scrollGridHandler : ScrollableGridUiHandler; + private scrollGridHandler: ScrollableGridUiHandler; private iconAnimHandler: PokemonIconAnimHandler; @@ -39,7 +39,13 @@ export default class EggListUiHandler extends MessageUiHandler { this.eggListContainer.setVisible(false); ui.add(this.eggListContainer); - const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860); + const bgColor = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0x006860, + ); bgColor.setOrigin(0, 0); this.eggListContainer.add(bgColor); @@ -86,7 +92,7 @@ export default class EggListUiHandler extends MessageUiHandler { this.scrollGridHandler = new ScrollableGridUiHandler(this, this.ROWS, this.COLUMNS) .withScrollBar(scrollBar) .withUpdateGridCallBack(() => this.updateEggIcons()) - .withUpdateSingleElementCallback((i:number) => this.setEggDetails(i)); + .withUpdateSingleElementCallback((i: number) => this.setEggDetails(i)); this.eggListMessageBoxContainer = globalScene.add.container(0, globalScene.game.canvas.height / 6); this.eggListMessageBoxContainer.setVisible(false); @@ -170,8 +176,8 @@ export default class EggListUiHandler extends MessageUiHandler { weekday: "short", year: "numeric", month: "2-digit", - day: "numeric" - }) + day: "numeric", + }), ); this.eggHatchWavesText.setText(egg.getEggHatchWavesMessage()); this.eggGachaInfoText.setText(egg.getEggTypeDescriptor()); diff --git a/src/ui/egg-summary-ui-handler.ts b/src/ui/egg-summary-ui-handler.ts index 04b31ab9ca8..f335f83d8bf 100644 --- a/src/ui/egg-summary-ui-handler.ts +++ b/src/ui/egg-summary-ui-handler.ts @@ -39,7 +39,7 @@ export default class EggSummaryUiHandler extends MessageUiHandler { private eggHatchBg: Phaser.GameObjects.Image; private eggHatchData: EggHatchData[]; - private scrollGridHandler : ScrollableGridUiHandler; + private scrollGridHandler: ScrollableGridUiHandler; private cursorObj: Phaser.GameObjects.Image; /** used to add a delay before which it is not possible to exit the summary */ @@ -89,7 +89,13 @@ export default class EggSummaryUiHandler extends MessageUiHandler { this.infoContainer.setVisible(true); this.summaryContainer.add(this.infoContainer); - const scrollBar = new ScrollBar(iconContainerX + numCols * iconSize, iconContainerY + 3, 4, globalScene.game.canvas.height / 6 - 20, numRows); + const scrollBar = new ScrollBar( + iconContainerX + numCols * iconSize, + iconContainerY + 3, + 4, + globalScene.game.canvas.height / 6 - 20, + numRows, + ); this.summaryContainer.add(scrollBar); this.scrollGridHandler = new ScrollableGridUiHandler(this, numRows, numCols) @@ -146,17 +152,17 @@ export default class EggSummaryUiHandler extends MessageUiHandler { const speciesB = b.pokemon.species; if (getEggTierForSpecies(speciesA) < getEggTierForSpecies(speciesB)) { return -1; - } else if (getEggTierForSpecies(speciesA) > getEggTierForSpecies(speciesB)) { - return 1; - } else { - if (speciesA.speciesId < speciesB.speciesId) { - return -1; - } else if (speciesA.speciesId > speciesB.speciesId) { - return 1; - } else { - return 0; - } } + if (getEggTierForSpecies(speciesA) > getEggTierForSpecies(speciesB)) { + return 1; + } + if (speciesA.speciesId < speciesB.speciesId) { + return -1; + } + if (speciesA.speciesId > speciesB.speciesId) { + return 1; + } + return 0; }); } @@ -174,9 +180,9 @@ export default class EggSummaryUiHandler extends MessageUiHandler { // Prevent exiting the egg summary for 2 seconds if the egg hatching // was skipped automatically and for 1 second otherwise - const exitBlockingDuration = (globalScene.eggSkipPreference === 2) ? 2000 : 1000; + const exitBlockingDuration = globalScene.eggSkipPreference === 2 ? 2000 : 1000; this.blockExit = true; - globalScene.time.delayedCall(exitBlockingDuration, () => this.blockExit = false); + globalScene.time.delayedCall(exitBlockingDuration, () => (this.blockExit = false)); return true; } @@ -245,7 +251,10 @@ export default class EggSummaryUiHandler extends MessageUiHandler { changed = super.setCursor(cursor); if (changed) { - this.cursorObj.setPosition(iconContainerX - 1 + iconSize * (cursor % numCols), iconContainerY + 1 + iconSize * Math.floor(cursor / numCols)); + this.cursorObj.setPosition( + iconContainerX - 1 + iconSize * (cursor % numCols), + iconContainerY + 1 + iconSize * Math.floor(cursor / numCols), + ); if (lastCursor > -1) { this.iconAnimHandler.addOrUpdate(this.pokemonContainers[lastCursor].icon, PokemonIconAnimMode.NONE); @@ -257,5 +266,4 @@ export default class EggSummaryUiHandler extends MessageUiHandler { return changed; } - } diff --git a/src/ui/evolution-scene-handler.ts b/src/ui/evolution-scene-handler.ts index b35aa8f6cc0..91f3360a3d4 100644 --- a/src/ui/evolution-scene-handler.ts +++ b/src/ui/evolution-scene-handler.ts @@ -38,8 +38,8 @@ export default class EvolutionSceneHandler extends MessageUiHandler { const message = addTextObject(0, 0, "", TextStyle.MESSAGE, { maxLines: 2, wordWrap: { - width: 1780 - } + width: 1780, + }, }); this.messageContainer.add(message); diff --git a/src/ui/fight-ui-handler.ts b/src/ui/fight-ui-handler.ts index 2b1eaa8221e..a4f02e13303 100644 --- a/src/ui/fight-ui-handler.ts +++ b/src/ui/fight-ui-handler.ts @@ -30,11 +30,11 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { private accuracyText: Phaser.GameObjects.Text; private cursorObj: Phaser.GameObjects.Image | null; private moveCategoryIcon: Phaser.GameObjects.Sprite; - private moveInfoOverlay : MoveInfoOverlay; + private moveInfoOverlay: MoveInfoOverlay; - protected fieldIndex: number = 0; + protected fieldIndex = 0; protected fromCommand: Command = Command.FIGHT; - protected cursor2: number = 0; + protected cursor2 = 0; constructor() { super(Mode.FIGHT); @@ -51,7 +51,12 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { this.moveInfoContainer.setName("move-info"); ui.add(this.moveInfoContainer); - this.typeIcon = globalScene.add.sprite(globalScene.scaledCanvas.width - 57, -36, Utils.getLocalizedSpriteKey("types"), "unknown"); + this.typeIcon = globalScene.add.sprite( + globalScene.scaledCanvas.width - 57, + -36, + Utils.getLocalizedSpriteKey("types"), + "unknown", + ); this.typeIcon.setVisible(false); this.moveInfoContainer.add(this.typeIcon); @@ -101,9 +106,9 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { right: true, x: 0, y: -MoveInfoOverlay.getHeight(overlayScale, true), - width: (globalScene.game.canvas.width / 6) + 4, + width: globalScene.game.canvas.width / 6 + 4, hideEffectBox: true, - hideBg: true + hideBg: true, }); ui.add(this.moveInfoOverlay); // register the overlay to receive toggle events @@ -114,8 +119,8 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { show(args: any[]): boolean { super.show(args); - this.fieldIndex = args.length ? args[0] as number : 0; - this.fromCommand = args.length > 1 ? args[1] as Command : Command.FIGHT; + this.fieldIndex = args.length ? (args[0] as number) : 0; + this.fromCommand = args.length > 1 ? (args[1] as Command) : Command.FIGHT; const messageHandler = this.getUi().getMessageHandler(); messageHandler.bg.setVisible(false); @@ -193,10 +198,10 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { this.cursorObj?.setVisible(false); } globalScene.tweens.add({ - targets: [ this.movesContainer, this.cursorObj ], + targets: [this.movesContainer, this.cursorObj], duration: Utils.fixedInt(125), ease: "Sine.easeInOut", - alpha: visible ? 0 : 1 + alpha: visible ? 0 : 1, }); if (!visible) { this.movesContainer.setVisible(true); @@ -273,7 +278,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { this.ppText.setShadowColor(this.getTextColor(ppColorStyle, true)); this.moveInfoOverlay.show(pokemonMove.getMove()); - pokemon.getOpponents().forEach((opponent) => { + pokemon.getOpponents().forEach(opponent => { opponent.updateEffectiveness(this.getEffectivenessText(pokemon, opponent, pokemonMove)); }); } @@ -297,7 +302,11 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { * Returns undefined if it's a status move */ private getEffectivenessText(pokemon: Pokemon, opponent: Pokemon, pokemonMove: PokemonMove): string | undefined { - const effectiveness = opponent.getMoveEffectiveness(pokemon, pokemonMove.getMove(), !opponent.battleData?.abilityRevealed); + const effectiveness = opponent.getMoveEffectiveness( + pokemon, + pokemonMove.getMove(), + !opponent.battleData?.abilityRevealed, + ); if (effectiveness === undefined) { return undefined; } @@ -340,9 +349,11 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { } const moveColors = opponents - .map((opponent) => opponent.getMoveEffectiveness(pokemon, pokemonMove.getMove(), !opponent.battleData.abilityRevealed)) + .map(opponent => + opponent.getMoveEffectiveness(pokemon, pokemonMove.getMove(), !opponent.battleData.abilityRevealed), + ) .sort((a, b) => b - a) - .map((effectiveness) => getTypeDamageMultiplierColor(effectiveness ?? 0, "offense")); + .map(effectiveness => getTypeDamageMultiplierColor(effectiveness ?? 0, "offense")); return moveColors[0]; } @@ -369,7 +380,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle { this.movesContainer.removeAll(true); const opponents = (globalScene.getCurrentPhase() as CommandPhase).getPokemon().getOpponents(); - opponents.forEach((opponent) => { + opponents.forEach(opponent => { opponent.updateEffectiveness(undefined); }); } diff --git a/src/ui/filter-bar.ts b/src/ui/filter-bar.ts index 8ef910f954a..2aade130ed1 100644 --- a/src/ui/filter-bar.ts +++ b/src/ui/filter-bar.ts @@ -13,24 +13,32 @@ export enum DropDownColumn { CAUGHT, UNLOCKS, MISC, - SORT + SORT, } export class FilterBar extends Phaser.GameObjects.Container { private window: Phaser.GameObjects.NineSlice; - private labels: Phaser.GameObjects.Text[] = []; + private labels: Phaser.GameObjects.Text[] = []; private dropDowns: DropDown[] = []; private columns: DropDownColumn[] = []; public cursorObj: Phaser.GameObjects.Image; - public numFilters: number = 0; - public openDropDown: boolean = false; - private lastCursor: number = -1; + public numFilters = 0; + public openDropDown = false; + private lastCursor = -1; private uiTheme: UiTheme; private leftPaddingX: number; private rightPaddingX: number; private cursorOffset: number; - constructor(x: number, y: number, width: number, height: number, leftPaddingX: number = 6, rightPaddingX: number = 6, cursorOffset: number = 8) { + constructor( + x: number, + y: number, + width: number, + height: number, + leftPaddingX = 6, + rightPaddingX = 6, + cursorOffset = 8, + ) { super(globalScene, x, y); this.width = width; @@ -82,7 +90,7 @@ export class FilterBar extends Phaser.GameObjects.Container { * @param col the DropDownColumn used to register the filter to retrieve * @returns the associated DropDown if it exists, undefined otherwise */ - getFilter(col: DropDownColumn) : DropDown { + getFilter(col: DropDownColumn): DropDown { return this.dropDowns[this.columns.indexOf(col)]; } @@ -112,7 +120,6 @@ export class FilterBar extends Phaser.GameObjects.Container { * Position the filter dropdowns evenly across the width of the container */ private calcFilterPositions(): void { - let totalWidth = this.leftPaddingX + this.rightPaddingX + this.cursorOffset; this.labels.forEach(label => { totalWidth += label.displayWidth + this.cursorOffset; @@ -138,7 +145,7 @@ export class FilterBar extends Phaser.GameObjects.Container { for (let i = 0; i < this.dropDowns.length; i++) { if (this.dropDowns[i].dropDownType === DropDownType.HYBRID) { this.dropDowns[i].autoSize(); - this.dropDowns[i].x = - this.dropDowns[i].getWidth(); + this.dropDowns[i].x = -this.dropDowns[i].getWidth(); this.dropDowns[i].y = 0; } } @@ -171,19 +178,19 @@ export class FilterBar extends Phaser.GameObjects.Container { } incDropDownCursor(): boolean { - if (this.dropDowns[this.lastCursor].cursor === this.dropDowns[this.lastCursor].options.length - 1) {// if at the bottom of the list, wrap around + if (this.dropDowns[this.lastCursor].cursor === this.dropDowns[this.lastCursor].options.length - 1) { + // if at the bottom of the list, wrap around return this.dropDowns[this.lastCursor].setCursor(0); - } else { - return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor + 1); } + return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor + 1); } decDropDownCursor(): boolean { - if (this.dropDowns[this.lastCursor].cursor === 0) {// if at the top of the list, wrap around + if (this.dropDowns[this.lastCursor].cursor === 0) { + // if at the top of the list, wrap around return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].options.length - 1); - } else { - return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor - 1); } + return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor - 1); } toggleOptionState(): void { @@ -211,7 +218,6 @@ export class FilterBar extends Phaser.GameObjects.Container { * @returns the index of the closest filter */ getNearestFilter(container: StarterContainer): number { - const midx = container.x + container.icon.displayWidth / 2; let nearest = 0; let nearestDist = 1000; @@ -225,5 +231,4 @@ export class FilterBar extends Phaser.GameObjects.Container { return nearest; } - } diff --git a/src/ui/filter-text.ts b/src/ui/filter-text.ts index f69cf113f05..a6b01ba39e6 100644 --- a/src/ui/filter-text.ts +++ b/src/ui/filter-text.ts @@ -8,7 +8,7 @@ import type UI from "./ui"; import { Mode } from "./ui"; import { globalScene } from "#app/global-scene"; -export enum FilterTextRow{ +export enum FilterTextRow { NAME, MOVE_1, MOVE_2, @@ -18,13 +18,13 @@ export enum FilterTextRow{ export class FilterText extends Phaser.GameObjects.Container { private window: Phaser.GameObjects.NineSlice; - private labels: Phaser.GameObjects.Text[] = []; - private selections: Phaser.GameObjects.Text[] = []; + private labels: Phaser.GameObjects.Text[] = []; + private selections: Phaser.GameObjects.Text[] = []; private selectionStrings: string[] = []; private rows: FilterTextRow[] = []; public cursorObj: Phaser.GameObjects.Image; - public numFilters: number = 0; - private lastCursor: number = -1; + public numFilters = 0; + private lastCursor = -1; private uiTheme: UiTheme; private menuMessageBoxContainer: Phaser.GameObjects.Container; @@ -35,9 +35,9 @@ export class FilterText extends Phaser.GameObjects.Container { private onChange: () => void; - public defaultText: string = "---"; + public defaultText = "---"; - constructor(x: number, y: number, width: number, height: number, onChange: () => void,) { + constructor(x: number, y: number, width: number, height: number, onChange: () => void) { super(globalScene, x, y); this.onChange = onChange; @@ -59,7 +59,17 @@ export class FilterText extends Phaser.GameObjects.Container { this.menuMessageBoxContainer.setVisible(false); // Full-width window used for testing dialog messages in debug mode - this.dialogueMessageBox = addWindow(-this.textPadding, 0, globalScene.game.canvas.width / 6 + this.textPadding * 2, 49, false, false, 0, 0, WindowVariant.THIN); + this.dialogueMessageBox = addWindow( + -this.textPadding, + 0, + globalScene.game.canvas.width / 6 + this.textPadding * 2, + 49, + false, + false, + 0, + 0, + WindowVariant.THIN, + ); this.dialogueMessageBox.setOrigin(0, 0); this.menuMessageBoxContainer.add(this.dialogueMessageBox); @@ -69,7 +79,6 @@ export class FilterText extends Phaser.GameObjects.Container { this.menuMessageBoxContainer.add(menuMessageText); this.message = menuMessageText; - } /** @@ -80,7 +89,6 @@ export class FilterText extends Phaser.GameObjects.Container { * @returns true if successful, false if the provided column was already in use for another filter */ addFilter(row: FilterTextRow, title: string): boolean { - const paddingX = 6; const cursorOffset = 8; const extraSpaceX = 40; @@ -95,7 +103,12 @@ export class FilterText extends Phaser.GameObjects.Container { this.labels.push(filterTypesLabel); this.add(filterTypesLabel); - const filterTypesSelection = addTextObject(paddingX + cursorOffset + extraSpaceX, 3, this.defaultText, TextStyle.TOOLTIP_CONTENT); + const filterTypesSelection = addTextObject( + paddingX + cursorOffset + extraSpaceX, + 3, + this.defaultText, + TextStyle.TOOLTIP_CONTENT, + ); this.selections.push(filterTypesSelection); this.add(filterTypesSelection); @@ -120,7 +133,6 @@ export class FilterText extends Phaser.GameObjects.Container { } startSearch(index: number, ui: UI): void { - ui.playSelect(); const prefilledText = ""; const buttonAction: any = {}; @@ -133,19 +145,18 @@ export class FilterText extends Phaser.GameObjects.Container { const handler = ui.getHandler() as AwaitableUiHandler; handler.tutorialActive = true; // Switch to the dialog test window - this.selections[index].setText( dialogueName === "" ? this.defaultText : String(i18next.t(dialogueName))); + this.selections[index].setText(dialogueName === "" ? this.defaultText : String(i18next.t(dialogueName))); ui.revertMode(); this.onChange(); }, () => { ui.revertMode(); this.onChange; - } + }, ]; ui.setOverlayMode(Mode.POKEDEX_SCAN, buttonAction, prefilledText, index); } - setCursor(cursor: number): void { const cursorOffset = 8; @@ -199,7 +210,6 @@ export class FilterText extends Phaser.GameObjects.Container { * @returns the index of the closest filter */ getNearestFilter(container: StarterContainer): number { - const midy = container.y + container.icon.displayHeight / 2; let nearest = 0; let nearestDist = 1000; @@ -213,6 +223,4 @@ export class FilterText extends Phaser.GameObjects.Container { return nearest; } - - } diff --git a/src/ui/form-modal-ui-handler.ts b/src/ui/form-modal-ui-handler.ts index 86a1cc2238b..8784145acd6 100644 --- a/src/ui/form-modal-ui-handler.ts +++ b/src/ui/form-modal-ui-handler.ts @@ -38,7 +38,13 @@ export abstract class FormModalUiHandler extends ModalUiHandler { abstract getInputFieldConfigs(): InputFieldConfig[]; getHeight(config?: ModalConfig): number { - return 20 * this.getInputFieldConfigs().length + (this.getModalTitle() ? 26 : 0) + ((config as FormModalConfig)?.errorMessage ? 12 : 0) + this.getButtonTopMargin() + 28; + return ( + 20 * this.getInputFieldConfigs().length + + (this.getModalTitle() ? 26 : 0) + + ((config as FormModalConfig)?.errorMessage ? 12 : 0) + + this.getButtonTopMargin() + + 28 + ); } getReadableErrorMessage(error: string): string { @@ -60,7 +66,12 @@ export abstract class FormModalUiHandler extends ModalUiHandler { this.updateFields(config, hasTitle); } - this.errorMessage = addTextObject(10, (hasTitle ? 31 : 5) + 20 * (config.length - 1) + 16 + this.getButtonTopMargin(), "", TextStyle.TOOLTIP_CONTENT); + this.errorMessage = addTextObject( + 10, + (hasTitle ? 31 : 5) + 20 * (config.length - 1) + 16 + this.getButtonTopMargin(), + "", + TextStyle.TOOLTIP_CONTENT, + ); this.errorMessage.setColor(this.getTextColor(TextStyle.SUMMARY_PINK)); this.errorMessage.setShadowColor(this.getTextColor(TextStyle.SUMMARY_PINK, true)); this.errorMessage.setVisible(false); @@ -85,7 +96,11 @@ export abstract class FormModalUiHandler extends ModalUiHandler { const isPassword = config?.isPassword; const isReadOnly = config?.isReadOnly; - const input = addTextInputObject(4, -2, 440, 116, TextStyle.TOOLTIP_CONTENT, { type: isPassword ? "password" : "text", maxLength: isPassword ? 64 : 20, readOnly: isReadOnly }); + const input = addTextInputObject(4, -2, 440, 116, TextStyle.TOOLTIP_CONTENT, { + type: isPassword ? "password" : "text", + maxLength: isPassword ? 64 : 20, + readOnly: isReadOnly, + }); input.setOrigin(0, 0); inputContainer.add(inputBg); @@ -104,9 +119,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler { const config = args[0] as FormModalConfig; - this.submitAction = config.buttonActions.length - ? config.buttonActions[0] - : null; + this.submitAction = config.buttonActions.length ? config.buttonActions[0] : null; if (this.buttonBgs.length) { this.buttonBgs[0].off("pointerdown"); @@ -125,7 +138,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler { duration: Utils.fixedInt(1000), ease: "Sine.easeInOut", y: "-=24", - alpha: 1 + alpha: 1, }); return true; @@ -171,7 +184,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler { } export interface InputFieldConfig { - label: string, - isPassword?: boolean, - isReadOnly?: boolean + label: string; + isPassword?: boolean; + isReadOnly?: boolean; } diff --git a/src/ui/game-stats-ui-handler.ts b/src/ui/game-stats-ui-handler.ts index 09fd178e101..7d3decf0c4c 100644 --- a/src/ui/game-stats-ui-handler.ts +++ b/src/ui/game-stats-ui-handler.ts @@ -19,13 +19,13 @@ interface DisplayStat { } interface DisplayStats { - [key: string]: DisplayStat | string + [key: string]: DisplayStat | string; } const displayStats: DisplayStats = { playTime: { label_key: "playTime", - sourceFunc: gameData => Utils.getPlayTimeString(gameData.gameStats.playTime) + sourceFunc: gameData => Utils.getPlayTimeString(gameData.gameStats.playTime), }, battles: { label_key: "totalBattles", @@ -36,34 +36,34 @@ const displayStats: DisplayStats = { sourceFunc: gameData => { const starterCount = gameData.getStarterCount(d => !!d.caughtAttr); return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarterCosts).length) * 1000) / 10}%)`; - } + }, }, shinyStartersUnlocked: { label_key: "shinyStarters", sourceFunc: gameData => { const starterCount = gameData.getStarterCount(d => !!(d.caughtAttr & DexAttr.SHINY)); return `${starterCount} (${Math.floor((starterCount / Object.keys(speciesStarterCosts).length) * 1000) / 10}%)`; - } + }, }, dexSeen: { label_key: "speciesSeen", sourceFunc: gameData => { const seenCount = gameData.getSpeciesCount(d => !!d.seenAttr); return `${seenCount} (${Math.floor((seenCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`; - } + }, }, dexCaught: { label_key: "speciesCaught", sourceFunc: gameData => { const caughtCount = gameData.getSpeciesCount(d => !!d.caughtAttr); return `${caughtCount} (${Math.floor((caughtCount / Object.keys(gameData.dexData).length) * 1000) / 10}%)`; - } + }, }, ribbonsOwned: { label_key: "ribbonsOwned", sourceFunc: gameData => gameData.gameStats.ribbonsOwned.toString(), }, - classicSessionsPlayed:{ + classicSessionsPlayed: { label_key: "classicRuns", sourceFunc: gameData => gameData.gameStats.classicSessionsPlayed.toString(), }, @@ -82,12 +82,12 @@ const displayStats: DisplayStats = { endlessSessionsPlayed: { label_key: "endlessRuns", sourceFunc: gameData => gameData.gameStats.endlessSessionsPlayed.toString(), - hidden: true + hidden: true, }, highestEndlessWave: { label_key: "highestWaveEndless", sourceFunc: gameData => gameData.gameStats.highestEndlessWave.toString(), - hidden: true + hidden: true, }, highestMoney: { label_key: "highestMoney", @@ -120,67 +120,67 @@ const displayStats: DisplayStats = { subLegendaryPokemonSeen: { label_key: "subLegendsSeen", sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonSeen.toString(), - hidden: true + hidden: true, }, subLegendaryPokemonCaught: { label_key: "subLegendsCaught", sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonCaught.toString(), - hidden: true + hidden: true, }, subLegendaryPokemonHatched: { label_key: "subLegendsHatched", sourceFunc: gameData => gameData.gameStats.subLegendaryPokemonHatched.toString(), - hidden: true + hidden: true, }, legendaryPokemonSeen: { label_key: "legendsSeen", sourceFunc: gameData => gameData.gameStats.legendaryPokemonSeen.toString(), - hidden: true + hidden: true, }, legendaryPokemonCaught: { label_key: "legendsCaught", sourceFunc: gameData => gameData.gameStats.legendaryPokemonCaught.toString(), - hidden: true + hidden: true, }, legendaryPokemonHatched: { label_key: "legendsHatched", sourceFunc: gameData => gameData.gameStats.legendaryPokemonHatched.toString(), - hidden: true + hidden: true, }, mythicalPokemonSeen: { label_key: "mythicalsSeen", sourceFunc: gameData => gameData.gameStats.mythicalPokemonSeen.toString(), - hidden: true + hidden: true, }, mythicalPokemonCaught: { label_key: "mythicalsCaught", sourceFunc: gameData => gameData.gameStats.mythicalPokemonCaught.toString(), - hidden: true + hidden: true, }, mythicalPokemonHatched: { label_key: "mythicalsHatched", sourceFunc: gameData => gameData.gameStats.mythicalPokemonHatched.toString(), - hidden: true + hidden: true, }, shinyPokemonSeen: { label_key: "shiniesSeen", sourceFunc: gameData => gameData.gameStats.shinyPokemonSeen.toString(), - hidden: true + hidden: true, }, shinyPokemonCaught: { label_key: "shiniesCaught", sourceFunc: gameData => gameData.gameStats.shinyPokemonCaught.toString(), - hidden: true + hidden: true, }, shinyPokemonHatched: { label_key: "shiniesHatched", sourceFunc: gameData => gameData.gameStats.shinyPokemonHatched.toString(), - hidden: true + hidden: true, }, pokemonFused: { label_key: "pokemonFused", sourceFunc: gameData => gameData.gameStats.pokemonFused.toString(), - hidden: true + hidden: true, }, trainersDefeated: { label_key: "trainersDefeated", @@ -189,27 +189,27 @@ const displayStats: DisplayStats = { eggsPulled: { label_key: "eggsPulled", sourceFunc: gameData => gameData.gameStats.eggsPulled.toString(), - hidden: true + hidden: true, }, rareEggsPulled: { label_key: "rareEggsPulled", sourceFunc: gameData => gameData.gameStats.rareEggsPulled.toString(), - hidden: true + hidden: true, }, epicEggsPulled: { label_key: "epicEggsPulled", sourceFunc: gameData => gameData.gameStats.epicEggsPulled.toString(), - hidden: true + hidden: true, }, legendaryEggsPulled: { label_key: "legendaryEggsPulled", sourceFunc: gameData => gameData.gameStats.legendaryEggsPulled.toString(), - hidden: true + hidden: true, }, manaphyEggsPulled: { label_key: "manaphyEggsPulled", sourceFunc: gameData => gameData.gameStats.manaphyEggsPulled.toString(), - hidden: true + hidden: true, }, }; @@ -235,35 +235,50 @@ export default class GameStatsUiHandler extends UiHandler { this.gameStatsContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); - this.gameStatsContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.gameStatsContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); - const headerBg = addWindow(0, 0, (globalScene.game.canvas.width / 6) - 2, 24); + const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); headerBg.setOrigin(0, 0); const headerText = addTextObject(0, 0, i18next.t("gameStatsUiHandler:stats"), TextStyle.SETTINGS_LABEL); headerText.setOrigin(0, 0); headerText.setPositionRelative(headerBg, 8, 4); - const statsBgWidth = ((globalScene.game.canvas.width / 6) - 2) / 2; - const [ statsBgLeft, statsBgRight ] = new Array(2).fill(null).map((_, i) => { + const statsBgWidth = (globalScene.game.canvas.width / 6 - 2) / 2; + const [statsBgLeft, statsBgRight] = new Array(2).fill(null).map((_, i) => { const width = statsBgWidth + 2; - const height = Math.floor((globalScene.game.canvas.height / 6) - headerBg.height - 2); - const statsBg = addWindow((statsBgWidth - 2) * i, headerBg.height, width, height, false, false, i > 0 ? -3 : 0, 1); + const height = Math.floor(globalScene.game.canvas.height / 6 - headerBg.height - 2); + const statsBg = addWindow( + (statsBgWidth - 2) * i, + headerBg.height, + width, + height, + false, + false, + i > 0 ? -3 : 0, + 1, + ); statsBg.setOrigin(0, 0); return statsBg; }); this.statsContainer = globalScene.add.container(0, 0); - new Array(18).fill(null).map((_, s) => { - - const statLabel = addTextObject(8 + (s % 2 === 1 ? statsBgWidth : 0), 28 + Math.floor(s / 2) * 16, "", TextStyle.STATS_LABEL); + const statLabel = addTextObject( + 8 + (s % 2 === 1 ? statsBgWidth : 0), + 28 + Math.floor(s / 2) * 16, + "", + TextStyle.STATS_LABEL, + ); statLabel.setOrigin(0, 0); this.statsContainer.add(statLabel); this.statLabels.push(statLabel); - const statValue = addTextObject((statsBgWidth * ((s % 2) + 1)) - 8, statLabel.y, "", TextStyle.STATS_VALUE); + const statValue = addTextObject(statsBgWidth * ((s % 2) + 1) - 8, statLabel.y, "", TextStyle.STATS_VALUE); statValue.setOrigin(1, 0); this.statsContainer.add(statValue); this.statValues.push(statValue); @@ -277,7 +292,11 @@ export default class GameStatsUiHandler extends UiHandler { // arrows to show that we can scroll through the stats const isLegacyTheme = globalScene.uiTheme === UiTheme.LEGACY; - this.arrowDown = globalScene.add.sprite(statsBgWidth, globalScene.game.canvas.height / 6 - (isLegacyTheme ? 9 : 5), "prompt"); + this.arrowDown = globalScene.add.sprite( + statsBgWidth, + globalScene.game.canvas.height / 6 - (isLegacyTheme ? 9 : 5), + "prompt", + ); this.gameStatsContainer.add(this.arrowDown); this.arrowUp = globalScene.add.sprite(statsBgWidth, headerBg.height + (isLegacyTheme ? 7 : 3), "prompt"); this.arrowUp.flipY = true; @@ -320,7 +339,11 @@ export default class GameStatsUiHandler extends UiHandler { statKeys.forEach((key, s) => { const stat = displayStats[key] as DisplayStat; const value = stat.sourceFunc!(globalScene.gameData); // TODO: is this bang correct? - this.statLabels[s].setText(!stat.hidden || isNaN(parseInt(value)) || parseInt(value) ? i18next.t(`gameStatsUiHandler:${stat.label_key}`) : "???"); + this.statLabels[s].setText( + !stat.hidden || Number.isNaN(Number.parseInt(value)) || Number.parseInt(value) + ? i18next.t(`gameStatsUiHandler:${stat.label_key}`) + : "???", + ); this.statValues[s].setText(value); }); if (statKeys.length < 18) { @@ -403,16 +426,18 @@ export function initStatsKeys() { displayStats[key] = { label_key: label, sourceFunc: gameData => gameData.gameStats[key].toString(), - hidden: hidden + hidden: hidden, }; } else if (displayStats[key] === null) { displayStats[key] = { - sourceFunc: gameData => gameData.gameStats[key].toString() + sourceFunc: gameData => gameData.gameStats[key].toString(), }; } if (!(displayStats[key] as DisplayStat).label_key) { const splittableKey = key.replace(/([a-z]{2,})([A-Z]{1}(?:[^A-Z]|$))/g, "$1_$2"); - (displayStats[key] as DisplayStat).label_key = Utils.toReadableString(`${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`); + (displayStats[key] as DisplayStat).label_key = Utils.toReadableString( + `${splittableKey[0].toUpperCase()}${splittableKey.slice(1)}`, + ); } } } diff --git a/src/ui/hatched-pokemon-container.ts b/src/ui/hatched-pokemon-container.ts index f006002617a..0b283c2e063 100644 --- a/src/ui/hatched-pokemon-container.ts +++ b/src/ui/hatched-pokemon-container.ts @@ -91,8 +91,8 @@ export class HatchedPokemonContainer extends Phaser.GameObjects.Container { const caughtAttr = dexEntry.caughtAttr; const newShiny = BigInt(1 << (displayPokemon.shiny ? 1 : 0)); const newVariant = BigInt(1 << (displayPokemon.variant + 4)); - const newShinyOrVariant = ((newShiny & caughtAttr) === BigInt(0)) || ((newVariant & caughtAttr) === BigInt(0)); - const newForm = (BigInt(1 << displayPokemon.formIndex) * DexAttr.DEFAULT_FORM & caughtAttr) === BigInt(0); + const newShinyOrVariant = (newShiny & caughtAttr) === BigInt(0) || (newVariant & caughtAttr) === BigInt(0); + const newForm = ((BigInt(1 << displayPokemon.formIndex) * DexAttr.DEFAULT_FORM) & caughtAttr) === BigInt(0); const female = displayPokemon.gender === Gender.FEMALE; const formIndex = displayPokemon.formIndex; diff --git a/src/ui/loading-modal-ui-handler.ts b/src/ui/loading-modal-ui-handler.ts index 7ee0949c71e..9626276245d 100644 --- a/src/ui/loading-modal-ui-handler.ts +++ b/src/ui/loading-modal-ui-handler.ts @@ -21,11 +21,11 @@ export default class LoadingModalUiHandler extends ModalUiHandler { } getMargin(): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + return [0, 0, 48, 0]; } getButtonLabels(): string[] { - return [ ]; + return []; } setup(): void { diff --git a/src/ui/login-form-ui-handler.ts b/src/ui/login-form-ui-handler.ts index 55909b63e58..1087ffa3fd1 100644 --- a/src/ui/login-form-ui-handler.ts +++ b/src/ui/login-form-ui-handler.ts @@ -46,12 +46,12 @@ export default class LoginFormUiHandler extends FormModalUiHandler { this.usernameInfoImage = this.buildInteractableImage("settings_icon", "username-info-icon", { x: 20, - scale: 0.5 + scale: 0.5, }); this.saveDownloadImage = this.buildInteractableImage("saving_icon", "save-download-icon", { x: 0, - scale: 0.75 + scale: 0.75, }); this.infoContainer.add(this.usernameInfoImage); @@ -63,7 +63,10 @@ export default class LoginFormUiHandler extends FormModalUiHandler { private buildExternalPartyContainer() { this.externalPartyContainer = globalScene.add.container(0, 0); - this.externalPartyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 12, globalScene.game.canvas.height / 12), Phaser.Geom.Rectangle.Contains); + this.externalPartyContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 12, globalScene.game.canvas.height / 12), + Phaser.Geom.Rectangle.Contains, + ); this.externalPartyTitle = addTextObject(0, 4, "", TextStyle.SETTINGS_LABEL); this.externalPartyTitle.setOrigin(0.5, 0); this.externalPartyBg = addWindow(0, 0, 0, 0); @@ -94,11 +97,11 @@ export default class LoginFormUiHandler extends FormModalUiHandler { } override getMargin(_config?: ModalConfig): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + return [0, 0, 48, 0]; } override getButtonLabels(_config?: ModalConfig): string[] { - return [ i18next.t("menu:login"), i18next.t("menu:register") ]; + return [i18next.t("menu:login"), i18next.t("menu:register")]; } override getReadableErrorMessage(error: string): string { @@ -127,21 +130,23 @@ export default class LoginFormUiHandler extends FormModalUiHandler { override getInputFieldConfigs(): InputFieldConfig[] { const inputFieldConfigs: InputFieldConfig[] = []; inputFieldConfigs.push({ label: i18next.t("menu:username") }); - inputFieldConfigs.push({ label: i18next.t("menu:password"), isPassword: true }); + inputFieldConfigs.push({ + label: i18next.t("menu:password"), + isPassword: true, + }); return inputFieldConfigs; } override show(args: any[]): boolean { if (super.show(args)) { - const config = args[0] as ModalConfig; this.processExternalProvider(config); const originalLoginAction = this.submitAction; - this.submitAction = (_) => { + this.submitAction = _ => { // Prevent overlapping overrides on action modification this.submitAction = originalLoginAction; this.sanitizeInputs(); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: []}); + globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); const onFail = error => { globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); @@ -150,11 +155,11 @@ export default class LoginFormUiHandler extends FormModalUiHandler { return onFail(i18next.t("menu:emptyUsername")); } - const [ usernameInput, passwordInput ] = this.inputs; + const [usernameInput, passwordInput] = this.inputs; pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }).then(error => { - if (!error) { - originalLoginAction && originalLoginAction(); + if (!error && originalLoginAction) { + originalLoginAction(); } else { onFail(error); } @@ -173,7 +178,9 @@ export default class LoginFormUiHandler extends FormModalUiHandler { this.infoContainer.setVisible(false); this.setMouseCursorStyle("default"); //reset cursor - [ this.discordImage, this.googleImage, this.usernameInfoImage, this.saveDownloadImage ].forEach((img) => img.off("pointerdown")); + [this.discordImage, this.googleImage, this.usernameInfoImage, this.saveDownloadImage].forEach(img => + img.off("pointerdown"), + ); } private processExternalProvider(config: ModalConfig): void { @@ -208,7 +215,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { }); const onFail = error => { - globalScene.ui.setMode(Mode.LOADING, { buttonActions: []}); + globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); globalScene.ui.setModeForceTransition(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); }; @@ -226,20 +233,22 @@ export default class LoginFormUiHandler extends FormModalUiHandler { globalScene.ui.revertMode(); this.infoContainer.disableInteractive(); return true; - } + }, }); } globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { options: options, - delay: 1000 + delay: 1000, }); - this.infoContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width, globalScene.game.canvas.height), Phaser.Geom.Rectangle.Contains); + this.infoContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width, globalScene.game.canvas.height), + Phaser.Geom.Rectangle.Contains, + ); } else { if (dataKeys.length > 2) { return onFail(this.ERR_TOO_MANY_SAVES); - } else { - return onFail(this.ERR_NO_SAVES); } + return onFail(this.ERR_NO_SAVES); } }); @@ -277,7 +286,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { duration: Utils.fixedInt(1000), ease: "Sine.easeInOut", y: "-=24", - alpha: 1 + alpha: 1, }); this.infoContainer.setAlpha(0); @@ -286,17 +295,12 @@ export default class LoginFormUiHandler extends FormModalUiHandler { duration: Utils.fixedInt(1000), ease: "Sine.easeInOut", y: "-=24", - alpha: 1 + alpha: 1, }); } private buildInteractableImage(texture: string, name: string, opts: BuildInteractableImageOpts = {}) { - const { - scale = 0.07, - x = 0, - y = 0, - origin = { x: 0, y: 0 } - } = opts; + const { scale = 0.07, x = 0, y = 0, origin = { x: 0, y: 0 } } = opts; const img = globalScene.add.image(x, y, texture); img.setName(name); img.setOrigin(origin.x, origin.y); diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 3965eb38cc4..b83ae24c9e0 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -60,7 +60,7 @@ export default class MenuUiHandler extends MessageUiHandler { private menuMessageBox: Phaser.GameObjects.NineSlice; private dialogueMessageBox: Phaser.GameObjects.NineSlice; - protected scale: number = 0.1666666667; + protected scale = 0.1666666667; public bgmBar: BgmBar; @@ -68,12 +68,15 @@ export default class MenuUiHandler extends MessageUiHandler { super(mode); this.excludedMenus = () => [ - { condition: [ Mode.COMMAND, Mode.TITLE ].includes(mode ?? Mode.TITLE), options: [ MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST ]}, - { condition: bypassLogin, options: [ MenuOptions.LOG_OUT ]} + { + condition: [Mode.COMMAND, Mode.TITLE].includes(mode ?? Mode.TITLE), + options: [MenuOptions.EGG_GACHA, MenuOptions.EGG_LIST], + }, + { condition: bypassLogin, options: [MenuOptions.LOG_OUT] }, ]; this.menuOptions = Utils.getEnumKeys(MenuOptions) - .map(m => parseInt(MenuOptions[m]) as MenuOptions) + .map(m => Number.parseInt(MenuOptions[m]) as MenuOptions) .filter(m => { return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m)); }); @@ -83,7 +86,7 @@ export default class MenuUiHandler extends MessageUiHandler { const ui = this.getUi(); // wiki url directs based on languges available on wiki const lang = i18next.resolvedLanguage?.substring(0, 2)!; // TODO: is this bang correct? - if ([ "de", "fr", "ko", "zh" ].includes(lang)) { + if (["de", "fr", "ko", "zh"].includes(lang)) { wikiUrl = `https://wiki.pokerogue.net/${lang}:start`; } @@ -94,9 +97,20 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.menuContainer.setName("menu"); - this.menuContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.menuContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); - this.menuOverlay = new Phaser.GameObjects.Rectangle(globalScene, -1, -1, globalScene.scaledCanvas.width, globalScene.scaledCanvas.height, 0xffffff, 0.3); + this.menuOverlay = new Phaser.GameObjects.Rectangle( + globalScene, + -1, + -1, + globalScene.scaledCanvas.width, + globalScene.scaledCanvas.height, + 0xffffff, + 0.3, + ); this.menuOverlay.setName("menu-overlay"); this.menuOverlay.setOrigin(0, 0); this.menuContainer.add(this.menuOverlay); @@ -104,32 +118,39 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuContainer.add(this.bgmBar); this.menuContainer.setVisible(false); - } - render() { const ui = this.getUi(); this.excludedMenus = () => [ - { condition: globalScene.getCurrentPhase() instanceof SelectModifierPhase, options: [ MenuOptions.EGG_GACHA ]}, - { condition: bypassLogin, options: [ MenuOptions.LOG_OUT ]} + { + condition: globalScene.getCurrentPhase() instanceof SelectModifierPhase, + options: [MenuOptions.EGG_GACHA], + }, + { condition: bypassLogin, options: [MenuOptions.LOG_OUT] }, ]; this.menuOptions = Utils.getEnumKeys(MenuOptions) - .map(m => parseInt(MenuOptions[m]) as MenuOptions) + .map(m => Number.parseInt(MenuOptions[m]) as MenuOptions) .filter(m => { return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m)); }); - this.optionSelectText = addTextObject(0, 0, this.menuOptions.map(o => `${i18next.t(`menuUiHandler:${MenuOptions[o]}`)}`).join("\n"), TextStyle.WINDOW, { maxLines: this.menuOptions.length }); + this.optionSelectText = addTextObject( + 0, + 0, + this.menuOptions.map(o => `${i18next.t(`menuUiHandler:${MenuOptions[o]}`)}`).join("\n"), + TextStyle.WINDOW, + { maxLines: this.menuOptions.length }, + ); this.optionSelectText.setLineSpacing(12); this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale; this.menuBg = addWindow( - (globalScene.game.canvas.width / 6) - (this.optionSelectText.displayWidth + 25), + globalScene.game.canvas.width / 6 - (this.optionSelectText.displayWidth + 25), 0, this.optionSelectText.displayWidth + 19 + 24 * this.scale, - (globalScene.game.canvas.height / 6) - 2 + globalScene.game.canvas.height / 6 - 2, ); this.menuBg.setOrigin(0, 0); @@ -151,7 +172,17 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuMessageBoxContainer.add(this.menuMessageBox); // Full-width window used for testing dialog messages in debug mode - this.dialogueMessageBox = addWindow(-this.textPadding, 0, globalScene.game.canvas.width / 6 + this.textPadding * 2, 49, false, false, 0, 0, WindowVariant.THIN); + this.dialogueMessageBox = addWindow( + -this.textPadding, + 0, + globalScene.game.canvas.width / 6 + this.textPadding * 2, + 49, + false, + false, + 0, + 0, + WindowVariant.THIN, + ); this.dialogueMessageBox.setOrigin(0, 0); this.menuMessageBoxContainer.add(this.dialogueMessageBox); @@ -176,25 +207,32 @@ export default class MenuUiHandler extends MessageUiHandler { ui.revertMode(); ui.showText(message, null, () => { const config: OptionSelectConfig = { - options: new Array(5).fill(null).map((_, i) => i).filter(slotFilter).map(i => { - return { - label: i18next.t("menuUiHandler:slot", { slotNumber: i + 1 }), - handler: () => { - callback(i); - ui.revertMode(); - ui.showText("", 0); - return true; - } - }; - }).concat([{ - label: i18next.t("menuUiHandler:cancel"), - handler: () => { - ui.revertMode(); - ui.showText("", 0); - return true; - } - }]), - xOffset: 98 + options: new Array(5) + .fill(null) + .map((_, i) => i) + .filter(slotFilter) + .map(i => { + return { + label: i18next.t("menuUiHandler:slot", { slotNumber: i + 1 }), + handler: () => { + callback(i); + ui.revertMode(); + ui.showText("", 0); + return true; + }, + }; + }) + .concat([ + { + label: i18next.t("menuUiHandler:cancel"), + handler: () => { + ui.revertMode(); + ui.showText("", 0); + return true; + }, + }, + ]), + xOffset: 98, }; ui.setOverlayMode(Mode.MENU_OPTION_SELECT, config); }); @@ -204,10 +242,14 @@ export default class MenuUiHandler extends MessageUiHandler { manageDataOptions.push({ label: i18next.t("menuUiHandler:importSession"), handler: () => { - confirmSlot(i18next.t("menuUiHandler:importSlotSelect"), () => true, slotId => globalScene.gameData.importData(GameDataType.SESSION, slotId)); + confirmSlot( + i18next.t("menuUiHandler:importSlotSelect"), + () => true, + slotId => globalScene.gameData.importData(GameDataType.SESSION, slotId), + ); return true; }, - keepOpen: true + keepOpen: true, }); } manageDataOptions.push({ @@ -222,14 +264,17 @@ export default class MenuUiHandler extends MessageUiHandler { dataSlots.push(slotId); } }); - })).then(() => { - confirmSlot(i18next.t("menuUiHandler:exportSlotSelect"), + }), + ).then(() => { + confirmSlot( + i18next.t("menuUiHandler:exportSlotSelect"), i => dataSlots.indexOf(i) > -1, - slotId => globalScene.gameData.tryExportData(GameDataType.SESSION, slotId)); + slotId => globalScene.gameData.tryExportData(GameDataType.SESSION, slotId), + ); }); return true; }, - keepOpen: true + keepOpen: true, }); manageDataOptions.push({ label: i18next.t("menuUiHandler:importRunHistory"), @@ -237,7 +282,7 @@ export default class MenuUiHandler extends MessageUiHandler { globalScene.gameData.importData(GameDataType.RUN_HISTORY); return true; }, - keepOpen: true + keepOpen: true, }); manageDataOptions.push({ label: i18next.t("menuUiHandler:exportRunHistory"), @@ -245,7 +290,7 @@ export default class MenuUiHandler extends MessageUiHandler { globalScene.gameData.tryExportData(GameDataType.RUN_HISTORY); return true; }, - keepOpen: true + keepOpen: true, }); if (Utils.isLocal || Utils.isBeta) { manageDataOptions.push({ @@ -255,33 +300,36 @@ export default class MenuUiHandler extends MessageUiHandler { globalScene.gameData.importData(GameDataType.SYSTEM); return true; }, - keepOpen: true + keepOpen: true, }); } - manageDataOptions.push({ - label: i18next.t("menuUiHandler:exportData"), - handler: () => { - globalScene.gameData.tryExportData(GameDataType.SYSTEM); - return true; + manageDataOptions.push( + { + label: i18next.t("menuUiHandler:exportData"), + handler: () => { + globalScene.gameData.tryExportData(GameDataType.SYSTEM); + return true; + }, + keepOpen: true, }, - keepOpen: true - }, - { - label: i18next.t("menuUiHandler:consentPreferences"), - handler: () => { - const consentLink = document.querySelector(".termly-display-preferences") as HTMLInputElement; - const clickEvent = new MouseEvent("click", { - view: window, - bubbles: true, - cancelable: true - }); - consentLink.dispatchEvent(clickEvent); - consentLink.focus(); - return true; + { + label: i18next.t("menuUiHandler:consentPreferences"), + handler: () => { + const consentLink = document.querySelector(".termly-display-preferences") as HTMLInputElement; + const clickEvent = new MouseEvent("click", { + view: window, + bubbles: true, + cancelable: true, + }); + consentLink.dispatchEvent(clickEvent); + consentLink.focus(); + return true; + }, + keepOpen: true, }, - keepOpen: true - }); - if (Utils.isLocal || Utils.isBeta) { // this should make sure we don't have this option in live + ); + if (Utils.isLocal || Utils.isBeta) { + // this should make sure we don't have this option in live manageDataOptions.push({ label: "Test Dialogue", handler: () => { @@ -299,7 +347,7 @@ export default class MenuUiHandler extends MessageUiHandler { const interpolatorOptions: any = {}; const splitArr = dialogueName.split(" "); // this splits our inputted text into words to cycle through later const translatedString = splitArr[0]; // this is our outputted i18 string - const regex = RegExp("\\{\\{(\\w*)\\}\\}", "g"); // this is a regex expression to find all the text between {{ }} in the i18 output + const regex = /\{\{(\w*)\}\}/g; // this is a regex expression to find all the text between {{ }} in the i18 output const matches = i18next.t(translatedString).match(regex) ?? []; if (matches.length > 0) { for (let match = 0; match < matches.length; match++) { @@ -312,20 +360,27 @@ export default class MenuUiHandler extends MessageUiHandler { } // Switch to the dialog test window this.setDialogTestMode(true); - ui.showText(String(i18next.t(translatedString, interpolatorOptions)), null, () => globalScene.ui.showText("", 0, () => { - handler.tutorialActive = false; - // Go back to the default message window - this.setDialogTestMode(false); - }), null, true); + ui.showText( + String(i18next.t(translatedString, interpolatorOptions)), + null, + () => + globalScene.ui.showText("", 0, () => { + handler.tutorialActive = false; + // Go back to the default message window + this.setDialogTestMode(false); + }), + null, + true, + ); }, () => { ui.revertMode(); - } + }, ]; ui.setMode(Mode.TEST_DIALOGUE, buttonAction, prefilledText); return true; }, - keepOpen: true + keepOpen: true, }); } manageDataOptions.push({ @@ -334,14 +389,14 @@ export default class MenuUiHandler extends MessageUiHandler { globalScene.ui.revertMode(); return true; }, - keepOpen: true + keepOpen: true, }); //Thank you Vassiat this.manageDataConfig = { xOffset: 98, options: manageDataOptions, - maxOptions: 7 + maxOptions: 7, }; const communityOptions: OptionSelectItem[] = [ @@ -351,7 +406,7 @@ export default class MenuUiHandler extends MessageUiHandler { window.open(wikiUrl, "_blank")?.focus(); return true; }, - keepOpen: true + keepOpen: true, }, { label: "Discord", @@ -359,7 +414,7 @@ export default class MenuUiHandler extends MessageUiHandler { window.open(discordUrl, "_blank")?.focus(); return true; }, - keepOpen: true + keepOpen: true, }, { label: "GitHub", @@ -367,7 +422,7 @@ export default class MenuUiHandler extends MessageUiHandler { window.open(githubUrl, "_blank")?.focus(); return true; }, - keepOpen: true + keepOpen: true, }, { label: "Reddit", @@ -375,7 +430,7 @@ export default class MenuUiHandler extends MessageUiHandler { window.open(redditUrl, "_blank")?.focus(); return true; }, - keepOpen: true + keepOpen: true, }, { label: i18next.t("menuUiHandler:donate"), @@ -383,52 +438,58 @@ export default class MenuUiHandler extends MessageUiHandler { window.open(donateUrl, "_blank")?.focus(); return true; }, - keepOpen: true - } + keepOpen: true, + }, ]; if (!bypassLogin && loggedInUser?.hasAdminRole) { communityOptions.push({ label: "Admin", handler: () => { - - const skippedAdminModes: AdminMode[] = [ AdminMode.ADMIN ]; // this is here so that we can skip the menu populating enums that aren't meant for the menu, such as the AdminMode.ADMIN + const skippedAdminModes: AdminMode[] = [AdminMode.ADMIN]; // this is here so that we can skip the menu populating enums that aren't meant for the menu, such as the AdminMode.ADMIN const options: OptionSelectItem[] = []; - Object.values(AdminMode).filter((v) => !isNaN(Number(v)) && !skippedAdminModes.includes(v as AdminMode)).forEach((mode) => { // this gets all the enums in a way we can use - options.push({ - label: getAdminModeName(mode as AdminMode), - handler: () => { - ui.playSelect(); - ui.setOverlayMode(Mode.ADMIN, { - buttonActions: [ - // we double revert here and below to go back 2 layers of menus - () => { - ui.revertMode(); - ui.revertMode(); + Object.values(AdminMode) + .filter(v => !Number.isNaN(Number(v)) && !skippedAdminModes.includes(v as AdminMode)) + .forEach(mode => { + // this gets all the enums in a way we can use + options.push({ + label: getAdminModeName(mode as AdminMode), + handler: () => { + ui.playSelect(); + ui.setOverlayMode( + Mode.ADMIN, + { + buttonActions: [ + // we double revert here and below to go back 2 layers of menus + () => { + ui.revertMode(); + ui.revertMode(); + }, + () => { + ui.revertMode(); + ui.revertMode(); + }, + ], }, - () => { - ui.revertMode(); - ui.revertMode(); - } - ] - }, mode); // mode is our AdminMode enum - return true; - } + mode, + ); // mode is our AdminMode enum + return true; + }, + }); }); - }); options.push({ label: "Cancel", handler: () => { ui.revertMode(); return true; - } + }, }); globalScene.ui.setOverlayMode(Mode.OPTION_SELECT, { options: options, - delay: 0 + delay: 0, }); return true; }, - keepOpen: true + keepOpen: true, }); } communityOptions.push({ @@ -436,11 +497,11 @@ export default class MenuUiHandler extends MessageUiHandler { handler: () => { globalScene.ui.revertMode(); return true; - } + }, }); this.communityConfig = { xOffset: 98, - options: communityOptions + options: communityOptions, }; this.setCursor(0); } @@ -450,7 +511,7 @@ export default class MenuUiHandler extends MessageUiHandler { super.show(args); this.menuOptions = Utils.getEnumKeys(MenuOptions) - .map(m => parseInt(MenuOptions[m]) as MenuOptions) + .map(m => Number.parseInt(MenuOptions[m]) as MenuOptions) .filter(m => { return !this.excludedMenus().some(exclusion => exclusion.condition && exclusion.options.includes(m)); }); @@ -471,7 +532,6 @@ export default class MenuUiHandler extends MessageUiHandler { this.bgmBar.toggleBgmBar(true); - return true; } @@ -529,10 +589,22 @@ export default class MenuUiHandler extends MessageUiHandler { success = true; break; case MenuOptions.MANAGE_DATA: - if (!bypassLogin && !this.manageDataConfig.options.some(o => o.label === i18next.t("menuUiHandler:linkDiscord") || o.label === i18next.t("menuUiHandler:unlinkDiscord"))) { - this.manageDataConfig.options.splice(this.manageDataConfig.options.length - 1, 0, + if ( + !bypassLogin && + !this.manageDataConfig.options.some( + o => + o.label === i18next.t("menuUiHandler:linkDiscord") || + o.label === i18next.t("menuUiHandler:unlinkDiscord"), + ) + ) { + this.manageDataConfig.options.splice( + this.manageDataConfig.options.length - 1, + 0, { - label: loggedInUser?.discordId === "" ? i18next.t("menuUiHandler:linkDiscord") : i18next.t("menuUiHandler:unlinkDiscord"), + label: + loggedInUser?.discordId === "" + ? i18next.t("menuUiHandler:linkDiscord") + : i18next.t("menuUiHandler:unlinkDiscord"), handler: () => { if (loggedInUser?.discordId === "") { const token = Utils.getCookie(Utils.sessionIdKey); @@ -541,16 +613,18 @@ export default class MenuUiHandler extends MessageUiHandler { const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify&state=${token}&prompt=none`; window.open(discordUrl, "_self"); return true; - } else { - pokerogueApi.unlinkDiscord().then(_isSuccess => { - updateUserInfo().then(() => globalScene.reset(true, true)); - }); - return true; } - } + pokerogueApi.unlinkDiscord().then(_isSuccess => { + updateUserInfo().then(() => globalScene.reset(true, true)); + }); + return true; + }, }, { - label: loggedInUser?.googleId === "" ? i18next.t("menuUiHandler:linkGoogle") : i18next.t("menuUiHandler:unlinkGoogle"), + label: + loggedInUser?.googleId === "" + ? i18next.t("menuUiHandler:linkGoogle") + : i18next.t("menuUiHandler:unlinkGoogle"), handler: () => { if (loggedInUser?.googleId === "") { const token = Utils.getCookie(Utils.sessionIdKey); @@ -559,14 +633,14 @@ export default class MenuUiHandler extends MessageUiHandler { const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&response_type=code&redirect_uri=${redirectUri}&scope=openid&state=${token}`; window.open(googleUrl, "_self"); return true; - } else { - pokerogueApi.unlinkGoogle().then(_isSuccess => { - updateUserInfo().then(() => globalScene.reset(true, true)); - }); - return true; } - } - }); + pokerogueApi.unlinkGoogle().then(_isSuccess => { + updateUserInfo().then(() => globalScene.reset(true, true)); + }); + return true; + }, + }, + ); } ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.manageDataConfig); success = true; @@ -580,11 +654,11 @@ export default class MenuUiHandler extends MessageUiHandler { success = true; const doSaveQuit = () => { ui.setMode(Mode.LOADING, { - buttonActions: [], fadeOut: () => + buttonActions: [], + fadeOut: () => globalScene.gameData.saveAll(true, true, true, true).then(() => { - globalScene.reset(true); - }) + }), }); }; if (globalScene.currentBattle.turn > 1) { @@ -593,10 +667,16 @@ export default class MenuUiHandler extends MessageUiHandler { this.showText("", 0); return; } - ui.setOverlayMode(Mode.CONFIRM, doSaveQuit, () => { - ui.revertMode(); - this.showText("", 0); - }, false, -98); + ui.setOverlayMode( + Mode.CONFIRM, + doSaveQuit, + () => { + ui.revertMode(); + this.showText("", 0); + }, + false, + -98, + ); }); } else { doSaveQuit(); @@ -609,9 +689,11 @@ export default class MenuUiHandler extends MessageUiHandler { success = true; const doLogout = () => { ui.setMode(Mode.LOADING, { - buttonActions: [], fadeOut: () => pokerogueApi.account.logout().then(() => { - updateUserInfo().then(() => globalScene.reset(true, true)); - }) + buttonActions: [], + fadeOut: () => + pokerogueApi.account.logout().then(() => { + updateUserInfo().then(() => globalScene.reset(true, true)); + }), }); }; if (globalScene.currentBattle) { @@ -620,10 +702,16 @@ export default class MenuUiHandler extends MessageUiHandler { this.showText("", 0); return; } - ui.setOverlayMode(Mode.CONFIRM, doLogout, () => { - ui.revertMode(); - this.showText("", 0); - }, false, -98); + ui.setOverlayMode( + Mode.CONFIRM, + doLogout, + () => { + ui.revertMode(); + this.showText("", 0); + }, + false, + -98, + ); }); } else { doLogout(); @@ -675,12 +763,21 @@ export default class MenuUiHandler extends MessageUiHandler { this.menuMessageBox.setVisible(!isDialogMode); this.dialogueMessageBox.setVisible(isDialogMode); // If we're testing dialog, we use the same word wrapping as the battle message handler - this.message.setWordWrapWidth(isDialogMode ? globalScene.ui.getMessageHandler().wordWrapWidth : this.defaultWordWrapWidth); + this.message.setWordWrapWidth( + isDialogMode ? globalScene.ui.getMessageHandler().wordWrapWidth : this.defaultWordWrapWidth, + ); this.message.setX(isDialogMode ? this.textPadding + 1 : this.textPadding); this.message.setY(isDialogMode ? this.textPadding + 0.4 : this.textPadding); } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number): void { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + ): void { this.menuMessageBoxContainer.setVisible(!!text); super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); diff --git a/src/ui/message-ui-handler.ts b/src/ui/message-ui-handler.ts index 18e1dfb1aff..50522152021 100644 --- a/src/ui/message-ui-handler.ts +++ b/src/ui/message-ui-handler.ts @@ -34,15 +34,37 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { } } - showText(text: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null) { + showText( + text: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ) { this.showTextInternal(text, delay, callback, callbackDelay, prompt, promptDelay); } - showDialogue(text: string, name?: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null) { + showDialogue( + text: string, + _name?: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ) { this.showTextInternal(text, delay, callback, callbackDelay, prompt, promptDelay); } - private showTextInternal(text: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null) { + private showTextInternal( + text: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ) { if (delay === null || delay === undefined) { delay = 20; } @@ -60,13 +82,13 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { charVarMap.set(actionMatch.index, actionMatch[2]); break; case "d": - delayMap.set(actionMatch.index, parseInt(actionMatch[2])); + delayMap.set(actionMatch.index, Number.parseInt(actionMatch[2])); break; case "s": soundMap.set(actionMatch.index, actionMatch[2]); break; case "f": - fadeMap.set(actionMatch.index, parseInt(actionMatch[2])); + fadeMap.set(actionMatch.index, Number.parseInt(actionMatch[2])); break; } text = text.slice(0, actionMatch.index) + text.slice(actionMatch.index + actionMatch[2].length + 4); @@ -122,7 +144,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { this.textTimer = globalScene.time.addEvent({ delay: delay, callback: () => { - const charIndex = text.length - (this.textTimer?.repeatCount!); // TODO: is this bang correct? + const charIndex = text.length - this.textTimer?.repeatCount!; // TODO: is this bang correct? const charVar = charVarMap.get(charIndex); const charSound = soundMap.get(charIndex); const charDelay = delayMap.get(charIndex); @@ -156,7 +178,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { onComplete: () => { this.textTimer!.paused = false; // TODO: is the bang correct? advance(); - } + }, }); } else if (charFade) { this.textTimer!.paused = true; @@ -175,7 +197,7 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { advance(); } }, - repeat: text.length + repeat: text.length, }); } else { this.message.setText(text); @@ -192,7 +214,9 @@ export default abstract class MessageUiHandler extends AwaitableUiHandler { const wrappedTextLines = this.message.runWordWrap(this.message.text).split(/\n/g); const textLinesCount = wrappedTextLines.length; const lastTextLine = wrappedTextLines[wrappedTextLines.length - 1]; - const lastLineTest = globalScene.add.text(0, 0, lastTextLine, { font: "96px emerald" }); + const lastLineTest = globalScene.add.text(0, 0, lastTextLine, { + font: "96px emerald", + }); lastLineTest.setScale(this.message.scale); const lastLineWidth = lastLineTest.displayWidth; lastLineTest.destroy(); diff --git a/src/ui/modal-ui-handler.ts b/src/ui/modal-ui-handler.ts index 909010e3566..b7dbbeb202d 100644 --- a/src/ui/modal-ui-handler.ts +++ b/src/ui/modal-ui-handler.ts @@ -44,7 +44,10 @@ export abstract class ModalUiHandler extends UiHandler { this.modalContainer = globalScene.add.container(0, 0); - this.modalContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.modalContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); this.modalBg = addWindow(0, 0, 0, 0); @@ -73,7 +76,10 @@ export abstract class ModalUiHandler extends UiHandler { const buttonBg = addWindow(0, 0, buttonLabel.getBounds().width + 8, 16, false, false, 0, 0, WindowVariant.THIN); buttonBg.setOrigin(0.5, 0); - buttonBg.setInteractive(new Phaser.Geom.Rectangle(0, 0, buttonBg.width, buttonBg.height), Phaser.Geom.Rectangle.Contains); + buttonBg.setInteractive( + new Phaser.Geom.Rectangle(0, 0, buttonBg.width, buttonBg.height), + Phaser.Geom.Rectangle.Contains, + ); const buttonContainer = globalScene.add.container(0, buttonTopMargin); @@ -93,9 +99,15 @@ export abstract class ModalUiHandler extends UiHandler { if (args.length >= 1 && "buttonActions" in args[0]) { super.show(args); if (args[0].hasOwnProperty("fadeOut") && typeof args[0].fadeOut === "function") { - const [ marginTop, marginRight, marginBottom, marginLeft ] = this.getMargin(); + const [marginTop, marginRight, marginBottom, marginLeft] = this.getMargin(); - const overlay = globalScene.add.rectangle(( this.getWidth() + marginLeft + marginRight) / 2, (this.getHeight() + marginTop + marginBottom) / 2, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0); + const overlay = globalScene.add.rectangle( + (this.getWidth() + marginLeft + marginRight) / 2, + (this.getHeight() + marginTop + marginBottom) / 2, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0, + ); overlay.setOrigin(0.5, 0.5); overlay.setName("rect-ui-overlay-modal"); overlay.setAlpha(0); @@ -108,7 +120,7 @@ export abstract class ModalUiHandler extends UiHandler { alpha: 1, duration: 250, ease: "Sine.easeOut", - onComplete: args[0].fadeOut + onComplete: args[0].fadeOut, }); } @@ -122,7 +134,7 @@ export abstract class ModalUiHandler extends UiHandler { for (let a = 0; a < this.buttonBgs.length; a++) { if (a < this.buttonBgs.length) { - this.buttonBgs[a].on("pointerdown", (_) => config.buttonActions[a]()); + this.buttonBgs[a].on("pointerdown", _ => config.buttonActions[a]()); } } @@ -133,10 +145,13 @@ export abstract class ModalUiHandler extends UiHandler { } updateContainer(config?: ModalConfig): void { - const [ marginTop, marginRight, marginBottom, marginLeft ] = this.getMargin(config); + const [marginTop, marginRight, marginBottom, marginLeft] = this.getMargin(config); - const [ width, height ] = [ this.getWidth(config), this.getHeight(config) ]; - this.modalContainer.setPosition((((globalScene.game.canvas.width / 6) - (width + (marginRight - marginLeft))) / 2), (((-globalScene.game.canvas.height / 6) - (height + (marginBottom - marginTop))) / 2)); + const [width, height] = [this.getWidth(config), this.getHeight(config)]; + this.modalContainer.setPosition( + (globalScene.game.canvas.width / 6 - (width + (marginRight - marginLeft))) / 2, + (-globalScene.game.canvas.height / 6 - (height + (marginBottom - marginTop))) / 2, + ); this.modalBg.setSize(width, height); @@ -153,7 +168,7 @@ export abstract class ModalUiHandler extends UiHandler { } } - processInput(button: Button): boolean { + processInput(_button: Button): boolean { return false; } @@ -168,7 +183,9 @@ export abstract class ModalUiHandler extends UiHandler { * Adds a hover effect to a game object which changes the cursor to a `pointer` and tints it slighly * @param gameObject the game object to add hover events/effects to */ - protected addInteractionHoverEffect(gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.NineSlice | Phaser.GameObjects.Sprite) { + protected addInteractionHoverEffect( + gameObject: Phaser.GameObjects.Image | Phaser.GameObjects.NineSlice | Phaser.GameObjects.Sprite, + ) { gameObject.on("pointerover", () => { this.setMouseCursorStyle("pointer"); gameObject.setTint(0xbbbbbb); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 7942a160a85..e5d8f858782 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -33,9 +33,9 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { private rerollCostText: Phaser.GameObjects.Text; private lockRarityButtonText: Phaser.GameObjects.Text; private moveInfoOverlay: MoveInfoOverlay; - private moveInfoOverlayActive: boolean = false; + private moveInfoOverlayActive = false; - private rowCursor: number = 0; + private rowCursor = 0; private player: boolean; /** * If reroll cost is negative, it is assumed there are 0 items in the shop. @@ -73,7 +73,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.checkButtonWidth = context.measureText(i18next.t("modifierSelectUiHandler:checkTeam")).width; } - this.transferButtonContainer = globalScene.add.container((globalScene.game.canvas.width - this.checkButtonWidth) / 6 - 21, OPTION_BUTTON_YPOSITION); + this.transferButtonContainer = globalScene.add.container( + (globalScene.game.canvas.width - this.checkButtonWidth) / 6 - 21, + OPTION_BUTTON_YPOSITION, + ); this.transferButtonContainer.setName("transfer-btn"); this.transferButtonContainer.setVisible(false); ui.add(this.transferButtonContainer); @@ -83,7 +86,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { transferButtonText.setOrigin(1, 0); this.transferButtonContainer.add(transferButtonText); - this.checkButtonContainer = globalScene.add.container((globalScene.game.canvas.width) / 6 - 1, OPTION_BUTTON_YPOSITION); + this.checkButtonContainer = globalScene.add.container( + globalScene.game.canvas.width / 6 - 1, + OPTION_BUTTON_YPOSITION, + ); this.checkButtonContainer.setName("use-btn"); this.checkButtonContainer.setVisible(false); ui.add(this.checkButtonContainer); @@ -113,16 +119,29 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.lockRarityButtonContainer.setVisible(false); ui.add(this.lockRarityButtonContainer); - this.lockRarityButtonText = addTextObject(-4, -2, i18next.t("modifierSelectUiHandler:lockRarities"), TextStyle.PARTY); + this.lockRarityButtonText = addTextObject( + -4, + -2, + i18next.t("modifierSelectUiHandler:lockRarities"), + TextStyle.PARTY, + ); this.lockRarityButtonText.setOrigin(0, 0); this.lockRarityButtonContainer.add(this.lockRarityButtonText); - this.continueButtonContainer = globalScene.add.container((globalScene.game.canvas.width / 12), -(globalScene.game.canvas.height / 12)); + this.continueButtonContainer = globalScene.add.container( + globalScene.game.canvas.width / 12, + -(globalScene.game.canvas.height / 12), + ); this.continueButtonContainer.setVisible(false); ui.add(this.continueButtonContainer); // Create continue button - const continueButtonText = addTextObject(-24, 5, i18next.t("modifierSelectUiHandler:continueNextWaveButton"), TextStyle.MESSAGE); + const continueButtonText = addTextObject( + -24, + 5, + i18next.t("modifierSelectUiHandler:continueNextWaveButton"), + TextStyle.MESSAGE, + ); continueButtonText.setName("text-continue-btn"); this.continueButtonContainer.add(continueButtonText); @@ -135,7 +154,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { right: true, x: 1, y: -MoveInfoOverlay.getHeight(overlayScale, true) - 1, - width: (globalScene.game.canvas.width / 6) - 2, + width: globalScene.game.canvas.width / 6 - 2, }); ui.add(this.moveInfoOverlay); // register the overlay to receive toggle events @@ -143,7 +162,6 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { } show(args: any[]): boolean { - globalScene.disableMenu = false; if (this.active) { @@ -155,7 +173,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { return false; } - if (args.length !== 4 || !(args[1] instanceof Array) || !(args[2] instanceof Function)) { + if (args.length !== 4 || !Array.isArray(args[1]) || !(args[2] instanceof Function)) { return false; } @@ -165,7 +183,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.player = args[0]; - const partyHasHeldItem = this.player && !!globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable).length; + const partyHasHeldItem = + this.player && !!globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable).length; const canLockRarities = !!globalScene.findModifier(m => m instanceof LockModifierTiersModifier); this.transferButtonContainer.setVisible(false); @@ -196,11 +215,16 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { const shopTypeOptions = !removeHealShop ? getPlayerShopModifierTypeOptionsForWave(globalScene.currentBattle.waveIndex, baseShopCost.value) : []; - const optionsYOffset = shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET; + const optionsYOffset = + shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET; for (let m = 0; m < typeOptions.length; m++) { - const sliceWidth = (globalScene.game.canvas.width / 6) / (typeOptions.length + 2); - const option = new ModifierOption(sliceWidth * (m + 1) + (sliceWidth * 0.5), -globalScene.game.canvas.height / 12 + optionsYOffset, typeOptions[m]); + const sliceWidth = globalScene.game.canvas.width / 6 / (typeOptions.length + 2); + const option = new ModifierOption( + sliceWidth * (m + 1) + sliceWidth * 0.5, + -globalScene.game.canvas.height / 12 + optionsYOffset, + typeOptions[m], + ); option.setScale(0.5); globalScene.add.existing(option); this.modifierContainer.add(option); @@ -215,9 +239,16 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { for (let m = 0; m < shopTypeOptions.length; m++) { const row = m < SHOP_OPTIONS_ROW_LIMIT ? 0 : 1; const col = m < SHOP_OPTIONS_ROW_LIMIT ? m : m - SHOP_OPTIONS_ROW_LIMIT; - const rowOptions = shopTypeOptions.slice(row ? SHOP_OPTIONS_ROW_LIMIT : 0, row ? undefined : SHOP_OPTIONS_ROW_LIMIT); - const sliceWidth = (globalScene.game.canvas.width / 6) / (rowOptions.length + 2); - const option = new ModifierOption(sliceWidth * (col + 1) + (sliceWidth * 0.5), ((-globalScene.game.canvas.height / 12) - (globalScene.game.canvas.height / 32) - (42 - (28 * row - 1))), shopTypeOptions[m]); + const rowOptions = shopTypeOptions.slice( + row ? SHOP_OPTIONS_ROW_LIMIT : 0, + row ? undefined : SHOP_OPTIONS_ROW_LIMIT, + ); + const sliceWidth = globalScene.game.canvas.width / 6 / (rowOptions.length + 2); + const option = new ModifierOption( + sliceWidth * (col + 1) + sliceWidth * 0.5, + -globalScene.game.canvas.height / 12 - globalScene.game.canvas.height / 32 - (42 - (28 * row - 1)), + shopTypeOptions[m], + ); option.setScale(0.375); globalScene.add.existing(option); this.modifierContainer.add(option); @@ -249,10 +280,13 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { const index = Math.floor(value * typeOptions.length); if (index > i && index <= typeOptions.length) { const option = this.options[i]; - option?.show(Math.floor((1 - value) * 1250) * 0.325 + 2000 * maxUpgradeCount, -(maxUpgradeCount - typeOptions[i].upgradeCount)); + option?.show( + Math.floor((1 - value) * 1250) * 0.325 + 2000 * maxUpgradeCount, + -(maxUpgradeCount - typeOptions[i].upgradeCount), + ); i++; } - } + }, }); globalScene.time.delayedCall(1000 + maxUpgradeCount * 2000, () => { @@ -268,7 +302,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { globalScene.tweens.add({ targets: this.transferButtonContainer, alpha: 1, - duration: 250 + duration: 250, }); } @@ -282,22 +316,22 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.lockRarityButtonContainer.setVisible(canLockRarities); globalScene.tweens.add({ - targets: [ this.checkButtonContainer, this.continueButtonContainer ], + targets: [this.checkButtonContainer, this.continueButtonContainer], alpha: 1, - duration: 250 + duration: 250, }); globalScene.tweens.add({ - targets: [ this.rerollButtonContainer, this.lockRarityButtonContainer ], + targets: [this.rerollButtonContainer, this.lockRarityButtonContainer], alpha: this.rerollCost < 0 ? 0.5 : 1, - duration: 250 + duration: 250, }); const updateCursorTarget = () => { if (globalScene.shopCursorTarget === ShopCursorTarget.CHECK_TEAM) { this.setRowCursor(0); this.setCursor(2); - } else if ((globalScene.shopCursorTarget === ShopCursorTarget.SHOP) && globalScene.gameMode.hasNoShop) { + } else if (globalScene.shopCursorTarget === ShopCursorTarget.SHOP && globalScene.gameMode.hasNoShop) { this.setRowCursor(ShopCursorTarget.REWARDS); this.setCursor(0); } else { @@ -308,7 +342,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { updateCursorTarget(); - handleTutorial(Tutorial.Select_Item).then((res) => { + handleTutorial(Tutorial.Select_Item).then(res => { if (res) { updateCursorTarget(); } @@ -469,7 +503,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.modifierContainer.add(this.cursorObj); } - const options = (this.rowCursor === 1 ? this.options : this.shopOptionsRows[this.shopOptionsRows.length - (this.rowCursor - 1)]); + const options = + this.rowCursor === 1 ? this.options : this.shopOptionsRows[this.shopOptionsRows.length - (this.rowCursor - 1)]; this.cursorObj.setScale(this.rowCursor === 1 ? 2 : this.rowCursor >= 2 ? 1.5 : 1); @@ -479,18 +514,31 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { if (this.rowCursor === 1 && options.length === 0) { // Continue button when no shop items this.cursorObj.setScale(1.25); - this.cursorObj.setPosition((globalScene.game.canvas.width / 18) + 23, (-globalScene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2)); + this.cursorObj.setPosition( + globalScene.game.canvas.width / 18 + 23, + -globalScene.game.canvas.height / 12 - + (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2), + ); ui.showText(i18next.t("modifierSelectUiHandler:continueNextWaveDescription")); return ret; } - const sliceWidth = (globalScene.game.canvas.width / 6) / (options.length + 2); + const sliceWidth = globalScene.game.canvas.width / 6 / (options.length + 2); if (this.rowCursor < 2) { // Cursor on free items - this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 20, (-globalScene.game.canvas.height / 12) - (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2)); + this.cursorObj.setPosition( + sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 20, + -globalScene.game.canvas.height / 12 - + (this.shopOptionsRows.length > 1 ? SINGLE_SHOP_ROW_YOFFSET - 2 : DOUBLE_SHOP_ROW_YOFFSET - 2), + ); } else { // Cursor on paying items - this.cursorObj.setPosition(sliceWidth * (cursor + 1) + (sliceWidth * 0.5) - 16, (-globalScene.game.canvas.height / 12 - globalScene.game.canvas.height / 32) - (-14 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1)))); + this.cursorObj.setPosition( + sliceWidth * (cursor + 1) + sliceWidth * 0.5 - 16, + -globalScene.game.canvas.height / 12 - + globalScene.game.canvas.height / 32 - + (-14 + 28 * (this.rowCursor - (this.shopOptionsRows.length - 1))), + ); } const type = options[this.cursor].modifierTypeOption.type; @@ -500,13 +548,22 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { this.moveInfoOverlay.show(allMoves[type.moveId]); } } else if (cursor === 0) { - this.cursorObj.setPosition(6, this.lockRarityButtonContainer.visible ? OPTION_BUTTON_YPOSITION - 8 : OPTION_BUTTON_YPOSITION + 4); + this.cursorObj.setPosition( + 6, + this.lockRarityButtonContainer.visible ? OPTION_BUTTON_YPOSITION - 8 : OPTION_BUTTON_YPOSITION + 4, + ); ui.showText(i18next.t("modifierSelectUiHandler:rerollDesc")); } else if (cursor === 1) { - this.cursorObj.setPosition((globalScene.game.canvas.width - this.transferButtonWidth - this.checkButtonWidth) / 6 - 30, OPTION_BUTTON_YPOSITION + 4); + this.cursorObj.setPosition( + (globalScene.game.canvas.width - this.transferButtonWidth - this.checkButtonWidth) / 6 - 30, + OPTION_BUTTON_YPOSITION + 4, + ); ui.showText(i18next.t("modifierSelectUiHandler:transferDesc")); } else if (cursor === 2) { - this.cursorObj.setPosition((globalScene.game.canvas.width - this.checkButtonWidth) / 6 - 10, OPTION_BUTTON_YPOSITION + 4); + this.cursorObj.setPosition( + (globalScene.game.canvas.width - this.checkButtonWidth) / 6 - 10, + OPTION_BUTTON_YPOSITION + 4, + ); ui.showText(i18next.t("modifierSelectUiHandler:checkTeamDesc")); } else { this.cursorObj.setPosition(6, OPTION_BUTTON_YPOSITION + 4); @@ -521,7 +578,9 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { if (rowCursor !== lastRowCursor) { this.rowCursor = rowCursor; - let newCursor = Math.round(this.cursor / Math.max(this.getRowItems(lastRowCursor) - 1, 1) * (this.getRowItems(rowCursor) - 1)); + let newCursor = Math.round( + (this.cursor / Math.max(this.getRowItems(lastRowCursor) - 1, 1)) * (this.getRowItems(rowCursor) - 1), + ); if (rowCursor === 1 && this.options.length === 0) { // Handle empty shop newCursor = 0; @@ -582,9 +641,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { if (rerollDisabled) { this.rerollCostText.setVisible(false); return; - } else { - this.rerollCostText.setVisible(true); } + this.rerollCostText.setVisible(true); const canReroll = globalScene.money >= this.rerollCost; const formattedMoney = Utils.formatMoney(globalScene.moneyFormat, this.rerollCost); @@ -630,10 +688,16 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { scale: 0.01, duration: 250, ease: "Cubic.easeIn", - onComplete: () => options.forEach(o => o.destroy()) + onComplete: () => options.forEach(o => o.destroy()), }); - [ this.rerollButtonContainer, this.checkButtonContainer, this.transferButtonContainer, this.lockRarityButtonContainer, this.continueButtonContainer ].forEach(container => { + [ + this.rerollButtonContainer, + this.checkButtonContainer, + this.transferButtonContainer, + this.lockRarityButtonContainer, + this.continueButtonContainer, + ].forEach(container => { if (container.visible) { globalScene.tweens.add({ targets: container, @@ -646,7 +710,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { } else { container.setAlpha(1); } - } + }, }); } }); @@ -716,11 +780,15 @@ class ModifierOption extends Phaser.GameObjects.Container { this.itemText = addTextObject(0, 35, this.modifierTypeOption.type?.name!, TextStyle.PARTY, { align: "center" }); // TODO: is this bang correct? this.itemText.setOrigin(0.5, 0); this.itemText.setAlpha(0); - this.itemText.setTint(this.modifierTypeOption.type?.tier ? getModifierTierTextTint(this.modifierTypeOption.type?.tier) : undefined); + this.itemText.setTint( + this.modifierTypeOption.type?.tier ? getModifierTierTextTint(this.modifierTypeOption.type?.tier) : undefined, + ); this.add(this.itemText); if (this.modifierTypeOption.cost) { - this.itemCostText = addTextObject(0, 45, "", TextStyle.MONEY, { align: "center" }); + this.itemCostText = addTextObject(0, 45, "", TextStyle.MONEY, { + align: "center", + }); this.itemCostText.setOrigin(0.5, 0); this.itemCostText.setAlpha(0); @@ -736,7 +804,7 @@ class ModifierOption extends Phaser.GameObjects.Container { targets: this.pb, y: 0, duration: 1250, - ease: "Bounce.Out" + ease: "Bounce.Out", }); let lastValue = 1; @@ -754,42 +822,52 @@ class ModifierOption extends Phaser.GameObjects.Container { } const value = t.getValue(); if (!bounce && value > lastValue) { - globalScene.playSound("se/pb_bounce_1", { volume: 1 / ++bounceCount }); + globalScene.playSound("se/pb_bounce_1", { + volume: 1 / ++bounceCount, + }); bounce = true; } else if (bounce && value < lastValue) { bounce = false; } lastValue = value; - } + }, }); for (let u = 0; u < this.modifierTypeOption.upgradeCount; u++) { const upgradeIndex = u; - globalScene.time.delayedCall(remainingDuration - 2000 * (this.modifierTypeOption.upgradeCount - (upgradeIndex + 1 + upgradeCountOffset)), () => { - globalScene.playSound("se/upgrade", { rate: 1 + 0.25 * upgradeIndex }); - this.pbTint.setPosition(this.pb.x, this.pb.y); - this.pbTint.setTintFill(0xFFFFFF); - this.pbTint.setAlpha(0); - this.pbTint.setVisible(true); - globalScene.tweens.add({ - targets: this.pbTint, - alpha: 1, - duration: 1000, - ease: "Sine.easeIn", - onComplete: () => { - this.pb.setTexture("pb", this.getPbAtlasKey(-this.modifierTypeOption.upgradeCount + (upgradeIndex + 1))); - globalScene.tweens.add({ - targets: this.pbTint, - alpha: 0, - duration: 750, - ease: "Sine.easeOut", - onComplete: () => { - this.pbTint.setVisible(false); - } - }); - } - }); - }); + globalScene.time.delayedCall( + remainingDuration - 2000 * (this.modifierTypeOption.upgradeCount - (upgradeIndex + 1 + upgradeCountOffset)), + () => { + globalScene.playSound("se/upgrade", { + rate: 1 + 0.25 * upgradeIndex, + }); + this.pbTint.setPosition(this.pb.x, this.pb.y); + this.pbTint.setTintFill(0xffffff); + this.pbTint.setAlpha(0); + this.pbTint.setVisible(true); + globalScene.tweens.add({ + targets: this.pbTint, + alpha: 1, + duration: 1000, + ease: "Sine.easeIn", + onComplete: () => { + this.pb.setTexture( + "pb", + this.getPbAtlasKey(-this.modifierTypeOption.upgradeCount + (upgradeIndex + 1)), + ); + globalScene.tweens.add({ + targets: this.pbTint, + alpha: 0, + duration: 750, + ease: "Sine.easeOut", + onComplete: () => { + this.pbTint.setVisible(false); + }, + }); + }, + }); + }, + ); } } @@ -808,7 +886,7 @@ class ModifierOption extends Phaser.GameObjects.Container { delay: 250, ease: "Sine.easeIn", alpha: 0, - onComplete: () => this.pb.destroy() + onComplete: () => this.pb.destroy(), }); } @@ -817,7 +895,7 @@ class ModifierOption extends Phaser.GameObjects.Container { duration: 500, ease: "Elastic.Out", scale: 2, - alpha: 1 + alpha: 1, }); if (!this.modifierTypeOption.cost) { globalScene.tweens.add({ @@ -825,7 +903,7 @@ class ModifierOption extends Phaser.GameObjects.Container { alpha: 0, duration: 500, ease: "Sine.easeIn", - onComplete: () => this.itemTint.destroy() + onComplete: () => this.itemTint.destroy(), }); } globalScene.tweens.add({ @@ -833,7 +911,7 @@ class ModifierOption extends Phaser.GameObjects.Container { duration: 500, alpha: 1, y: 25, - ease: "Cubic.easeInOut" + ease: "Cubic.easeInOut", }); if (this.itemCostText) { globalScene.tweens.add({ @@ -841,13 +919,13 @@ class ModifierOption extends Phaser.GameObjects.Container { duration: 500, alpha: 1, y: 35, - ease: "Cubic.easeInOut" + ease: "Cubic.easeInOut", }); } }); } - getPbAtlasKey(tierOffset: number = 0) { + getPbAtlasKey(tierOffset = 0) { return getPokeballAtlasKey((this.modifierTypeOption.type?.tier! + tierOffset) as number as PokeballType); // TODO: is this bang correct? } diff --git a/src/ui/move-info-overlay.ts b/src/ui/move-info-overlay.ts index 1b49c2dd3c3..6fc99beb0ae 100644 --- a/src/ui/move-info-overlay.ts +++ b/src/ui/move-info-overlay.ts @@ -9,19 +9,19 @@ import { PokemonType } from "#enums/pokemon-type"; import i18next from "i18next"; export interface MoveInfoOverlaySettings { - delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. - scale?:number; // scale the box? A scale of 0.5 is recommended - top?: boolean; // should the effect box be on top? - right?: boolean; // should the effect box be on the right? - onSide?: boolean; // should the effect be on the side? ignores top argument if true - //location and width of the component; unaffected by scaling - x?: number; - y?: number; - /** Default is always half the screen, regardless of scale */ - width?: number; - /** Determines whether to display the small secondary box */ - hideEffectBox?: boolean; - hideBg?: boolean; + delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. + scale?: number; // scale the box? A scale of 0.5 is recommended + top?: boolean; // should the effect box be on top? + right?: boolean; // should the effect box be on the right? + onSide?: boolean; // should the effect be on the side? ignores top argument if true + //location and width of the component; unaffected by scaling + x?: number; + y?: number; + /** Default is always half the screen, regardless of scale */ + width?: number; + /** Determines whether to display the small secondary box */ + hideEffectBox?: boolean; + hideBg?: boolean; } const EFF_HEIGHT = 48; @@ -31,22 +31,22 @@ const BORDER = 8; const GLOBAL_SCALE = 6; export default class MoveInfoOverlay extends Phaser.GameObjects.Container implements InfoToggle { - public active: boolean = false; + public active = false; private move: Move; private desc: Phaser.GameObjects.Text; - private descScroll : Phaser.Tweens.Tween | null = null; + private descScroll: Phaser.Tweens.Tween | null = null; private val: Phaser.GameObjects.Container; - private pp: Phaser.GameObjects.Text; + private pp: Phaser.GameObjects.Text; private pow: Phaser.GameObjects.Text; private acc: Phaser.GameObjects.Text; private typ: Phaser.GameObjects.Sprite; private cat: Phaser.GameObjects.Sprite; private descBg: Phaser.GameObjects.NineSlice; - private options : MoveInfoOverlaySettings; + private options: MoveInfoOverlaySettings; constructor(options?: MoveInfoOverlaySettings) { if (options?.onSide) { @@ -59,18 +59,33 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem // prepare the description box const width = (options?.width || MoveInfoOverlay.getWidth(scale)) / scale; // divide by scale as we always want this to be half a window wide - this.descBg = addWindow( (options?.onSide && !options?.right ? EFF_WIDTH : 0), options?.top ? EFF_HEIGHT : 0, width - (options?.onSide ? EFF_WIDTH : 0), DESC_HEIGHT); + this.descBg = addWindow( + options?.onSide && !options?.right ? EFF_WIDTH : 0, + options?.top ? EFF_HEIGHT : 0, + width - (options?.onSide ? EFF_WIDTH : 0), + DESC_HEIGHT, + ); this.descBg.setOrigin(0, 0); this.add(this.descBg); // set up the description; wordWrap uses true pixels, unaffected by any scaling, while other values are affected - this.desc = addTextObject((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER, (options?.top ? EFF_HEIGHT : 0) + BORDER - 2, "", TextStyle.BATTLE_INFO, { wordWrap: { width: (width - (BORDER - 2) * 2 - (options?.onSide ? EFF_WIDTH : 0)) * GLOBAL_SCALE }}); + this.desc = addTextObject( + (options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER, + (options?.top ? EFF_HEIGHT : 0) + BORDER - 2, + "", + TextStyle.BATTLE_INFO, + { + wordWrap: { + width: (width - (BORDER - 2) * 2 - (options?.onSide ? EFF_WIDTH : 0)) * GLOBAL_SCALE, + }, + }, + ); this.desc.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); // limit the text rendering, required for scrolling later on const maskPointOrigin = { - x: (options?.x || 0), - y: (options?.y || 0), + x: options?.x || 0, + y: options?.y || 0, }; if (maskPointOrigin.x < 0) { maskPointOrigin.x += globalScene.game.canvas.width / GLOBAL_SCALE; @@ -80,10 +95,13 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem } const moveDescriptionTextMaskRect = globalScene.make.graphics(); - moveDescriptionTextMaskRect.fillStyle(0xFF0000); + moveDescriptionTextMaskRect.fillStyle(0xff0000); moveDescriptionTextMaskRect.fillRect( - maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER) * scale, maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2) * scale, - width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2) * scale, (DESC_HEIGHT - (BORDER - 2) * 2) * scale); + maskPointOrigin.x + ((options?.onSide && !options?.right ? EFF_WIDTH : 0) + BORDER) * scale, + maskPointOrigin.y + ((options?.top ? EFF_HEIGHT : 0) + BORDER - 2) * scale, + width - ((options?.onSide ? EFF_WIDTH : 0) - BORDER * 2) * scale, + (DESC_HEIGHT - (BORDER - 2) * 2) * scale, + ); moveDescriptionTextMaskRect.setScale(6); const moveDescriptionTextMask = this.createGeometryMask(moveDescriptionTextMaskRect); @@ -91,7 +109,11 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem this.desc.setMask(moveDescriptionTextMask); // prepare the effect box - this.val = new Phaser.GameObjects.Container(globalScene, options?.right ? width - EFF_WIDTH : 0, options?.top || options?.onSide ? 0 : DESC_HEIGHT); + this.val = new Phaser.GameObjects.Container( + globalScene, + options?.right ? width - EFF_WIDTH : 0, + options?.top || options?.onSide ? 0 : DESC_HEIGHT, + ); this.add(this.val); const valuesBg = addWindow(0, 0, EFF_WIDTH, EFF_HEIGHT); @@ -145,7 +167,7 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem } // show this component with infos for the specific move - show(move : Move):boolean { + show(move: Move): boolean { if (!globalScene.enableMoveInfo) { return false; // move infos have been disabled // TODO:: is `false` correct? i used to be `undeefined` } @@ -166,7 +188,7 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem } // determine if we need to add new scrolling effects - const moveDescriptionLineCount = Math.floor(this.desc.displayHeight * (96 / 72) / 14.83); + const moveDescriptionLineCount = Math.floor((this.desc.displayHeight * (96 / 72)) / 14.83); if (moveDescriptionLineCount > 3) { // generate scrolling effects this.descScroll = globalScene.tweens.add({ @@ -175,7 +197,7 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem loop: -1, hold: Utils.fixedInt(2000), duration: Utils.fixedInt((moveDescriptionLineCount - 3) * 2000), - y: `-=${14.83 * (72 / 96) * (moveDescriptionLineCount - 3)}` + y: `-=${14.83 * (72 / 96) * (moveDescriptionLineCount - 3)}`, }); } @@ -199,7 +221,7 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem targets: this.desc, duration: Utils.fixedInt(125), ease: "Sine.easeInOut", - alpha: visible ? 1 : 0 + alpha: visible ? 1 : 0, }); if (!visible) { this.setVisible(false); @@ -211,12 +233,12 @@ export default class MoveInfoOverlay extends Phaser.GameObjects.Container implem } // width of this element - static getWidth(scale:number):number { + static getWidth(_scale: number): number { return globalScene.game.canvas.width / GLOBAL_SCALE / 2; } // height of this element - static getHeight(scale:number, onSide?: boolean):number { - return (onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : (EFF_HEIGHT + DESC_HEIGHT)) * scale; + static getHeight(scale: number, onSide?: boolean): number { + return (onSide ? Math.max(EFF_HEIGHT, DESC_HEIGHT) : EFF_HEIGHT + DESC_HEIGHT) * scale; } } diff --git a/src/ui/mystery-encounter-ui-handler.ts b/src/ui/mystery-encounter-ui-handler.ts index 383f4ab73d3..87d2e2ba28c 100644 --- a/src/ui/mystery-encounter-ui-handler.ts +++ b/src/ui/mystery-encounter-ui-handler.ts @@ -36,16 +36,16 @@ export default class MysteryEncounterUiHandler extends UiHandler { private dexProgressWindow: Phaser.GameObjects.NineSlice; private dexProgressContainer: Phaser.GameObjects.Container; - private showDexProgress: boolean = false; + private showDexProgress = false; private overrideSettings?: OptionSelectSettings; private encounterOptions: MysteryEncounterOption[] = []; private optionsMeetsReqs: boolean[]; - protected viewPartyIndex: number = 0; - protected viewPartyXPosition: number = 0; + protected viewPartyIndex = 0; + protected viewPartyXPosition = 0; - protected blockInput: boolean = true; + protected blockInput = true; constructor() { super(Mode.MYSTERY_ENCOUNTER); @@ -86,7 +86,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { this.descriptionContainer.add(this.rarityBall); const dexProgressIndicator = globalScene.add.sprite(12, 10, "encounter_radar"); - dexProgressIndicator.setScale(0.80); + dexProgressIndicator.setScale(0.8); this.dexProgressContainer.add(dexProgressIndicator); this.dexProgressContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, 24, 28), Phaser.Geom.Rectangle.Contains); } @@ -94,9 +94,13 @@ export default class MysteryEncounterUiHandler extends UiHandler { override show(args: any[]): boolean { super.show(args); - this.overrideSettings = args[0] as OptionSelectSettings ?? {}; - const showDescriptionContainer = isNullOrUndefined(this.overrideSettings?.hideDescription) ? true : !this.overrideSettings.hideDescription; - const slideInDescription = isNullOrUndefined(this.overrideSettings?.slideInDescription) ? true : this.overrideSettings.slideInDescription; + this.overrideSettings = (args[0] as OptionSelectSettings) ?? {}; + const showDescriptionContainer = isNullOrUndefined(this.overrideSettings?.hideDescription) + ? true + : !this.overrideSettings.hideDescription; + const slideInDescription = isNullOrUndefined(this.overrideSettings?.slideInDescription) + ? true + : this.overrideSettings.slideInDescription; const startingCursorIndex = this.overrideSettings?.startingCursorIndex ?? 0; this.cursorContainer.setVisible(true); @@ -136,7 +140,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { success = true; const overrideSettings: OptionSelectSettings = { ...this.overrideSettings, - slideInDescription: false + slideInDescription: false, }; globalScene.ui.setMode(Mode.PARTY, PartyUiMode.CHECK, -1, () => { globalScene.ui.setMode(Mode.MYSTERY_ENCOUNTER, overrideSettings); @@ -145,7 +149,12 @@ export default class MysteryEncounterUiHandler extends UiHandler { this.unblockInput(); }, 300); }); - } else if (this.blockInput || (!this.optionsMeetsReqs[cursor] && (selected.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || selected.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL))) { + } else if ( + this.blockInput || + (!this.optionsMeetsReqs[cursor] && + (selected.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || + selected.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL)) + ) { success = false; } else { if ((globalScene.getCurrentPhase() as MysteryEncounterPhase).handleOptionSelect(selected, cursor)) { @@ -159,6 +168,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { } } else { switch (this.optionsContainer.getAll()?.length) { + // biome-ignore lint/suspicious/useDefaultSwitchClauseLast: Default shares logic with case 3 and it makes more sense for the statements to be ordered by the case value default: case 3: success = this.handleTwoOptionMoveInput(button); @@ -293,7 +303,11 @@ export default class MysteryEncounterUiHandler extends UiHandler { this.blockInput = false; for (let i = 0; i < this.optionsContainer.length - 1; i++) { const optionMode = this.encounterOptions[i].optionMode; - if (!this.optionsMeetsReqs[i] && (optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL)) { + if ( + !this.optionsMeetsReqs[i] && + (optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || + optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + ) { continue; } (this.optionsContainer.getAt(i) as Phaser.GameObjects.Text).setAlpha(1); @@ -321,26 +335,38 @@ export default class MysteryEncounterUiHandler extends UiHandler { if (cursor === this.viewPartyIndex) { this.cursorObj.setPosition(this.viewPartyXPosition, -17); - } else if (this.optionsContainer.getAll()?.length === 3) { // 2 Options + } else if (this.optionsContainer.getAll()?.length === 3) { + // 2 Options this.cursorObj.setPosition(-10.5 + (cursor % 2 === 1 ? 100 : 0), 15); - } else if (this.optionsContainer.getAll()?.length === 4) { // 3 Options + } else if (this.optionsContainer.getAll()?.length === 4) { + // 3 Options this.cursorObj.setPosition(-10.5 + (cursor % 2 === 1 ? 100 : 0), 7 + (cursor > 1 ? 16 : 0)); - } else if (this.optionsContainer.getAll()?.length === 5) { // 4 Options + } else if (this.optionsContainer.getAll()?.length === 5) { + // 4 Options this.cursorObj.setPosition(-10.5 + (cursor % 2 === 1 ? 100 : 0), 7 + (cursor > 1 ? 16 : 0)); } return changed; } - displayEncounterOptions(slideInDescription: boolean = true): void { + displayEncounterOptions(slideInDescription = true): void { this.getUi().clearText(); const mysteryEncounter = globalScene.currentBattle.mysteryEncounter!; this.encounterOptions = this.overrideSettings?.overrideOptions ?? mysteryEncounter.options; this.optionsMeetsReqs = []; - const titleText: string | null = getEncounterText(mysteryEncounter.dialogue.encounterOptionsDialogue?.title, TextStyle.TOOLTIP_TITLE); - const descriptionText: string | null = getEncounterText(mysteryEncounter.dialogue.encounterOptionsDialogue?.description, TextStyle.TOOLTIP_CONTENT); - const queryText: string | null = getEncounterText(mysteryEncounter.dialogue.encounterOptionsDialogue?.query, TextStyle.TOOLTIP_CONTENT); + const titleText: string | null = getEncounterText( + mysteryEncounter.dialogue.encounterOptionsDialogue?.title, + TextStyle.TOOLTIP_TITLE, + ); + const descriptionText: string | null = getEncounterText( + mysteryEncounter.dialogue.encounterOptionsDialogue?.description, + TextStyle.TOOLTIP_CONTENT, + ); + const queryText: string | null = getEncounterText( + mysteryEncounter.dialogue.encounterOptionsDialogue?.query, + TextStyle.TOOLTIP_CONTENT, + ); // Clear options container (except cursor) this.optionsContainer.removeAll(true); @@ -351,23 +377,41 @@ export default class MysteryEncounterUiHandler extends UiHandler { let optionText: BBCodeText; switch (this.encounterOptions.length) { + // biome-ignore lint/suspicious/useDefaultSwitchClauseLast: default shares logic with case 2 and it makes more sense for the statements to be ordered by the case number default: case 2: - optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, 8, "-", TextStyle.WINDOW, { fontSize: "80px", lineSpacing: -8 }); + optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, 8, "-", TextStyle.WINDOW, { + fontSize: "80px", + lineSpacing: -8, + }); break; case 3: - optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, i < 2 ? 0 : 16, "-", TextStyle.WINDOW, { fontSize: "80px", lineSpacing: -8 }); + optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, i < 2 ? 0 : 16, "-", TextStyle.WINDOW, { + fontSize: "80px", + lineSpacing: -8, + }); break; case 4: - optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, i < 2 ? 0 : 16, "-", TextStyle.WINDOW, { fontSize: "80px", lineSpacing: -8 }); + optionText = addBBCodeTextObject(i % 2 === 0 ? 0 : 100, i < 2 ? 0 : 16, "-", TextStyle.WINDOW, { + fontSize: "80px", + lineSpacing: -8, + }); break; } this.optionsMeetsReqs.push(option.meetsRequirements()); const optionDialogue = option.dialogue!; - const label = !this.optionsMeetsReqs[i] && optionDialogue.disabledButtonLabel ? optionDialogue.disabledButtonLabel : optionDialogue.buttonLabel; + const label = + !this.optionsMeetsReqs[i] && optionDialogue.disabledButtonLabel + ? optionDialogue.disabledButtonLabel + : optionDialogue.buttonLabel; let text: string | null; - if (option.hasRequirements() && this.optionsMeetsReqs[i] && (option.optionMode === MysteryEncounterOptionMode.DEFAULT_OR_SPECIAL || option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL)) { + if ( + option.hasRequirements() && + this.optionsMeetsReqs[i] && + (option.optionMode === MysteryEncounterOptionMode.DEFAULT_OR_SPECIAL || + option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + ) { // Options with special requirements that are met are automatically colored green text = getEncounterText(label, TextStyle.ME_OPTION_SPECIAL); } else { @@ -378,7 +422,11 @@ export default class MysteryEncounterUiHandler extends UiHandler { optionText.setText(text); } - if (!this.optionsMeetsReqs[i] && (option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL)) { + if ( + !this.optionsMeetsReqs[i] && + (option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || + option.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) + ) { optionText.setAlpha(0.5); } if (this.blockInput) { @@ -389,7 +437,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { const nonScrollWidth = 90; const optionTextMaskRect = globalScene.make.graphics({}); optionTextMaskRect.setScale(6); - optionTextMaskRect.fillStyle(0xFFFFFF); + optionTextMaskRect.fillStyle(0xffffff); optionTextMaskRect.beginPath(); optionTextMaskRect.fillRect(optionText.x + 11, optionText.y + 140, nonScrollWidth, 18); @@ -411,8 +459,8 @@ export default class MysteryEncounterUiHandler extends UiHandler { delay: Utils.fixedInt(2000), loop: -1, hold: Utils.fixedInt(2000), - duration: Utils.fixedInt((optionTextWidth - nonScrollWidth) / 15 * 2000), - x: `-=${(optionTextWidth - nonScrollWidth)}` + duration: Utils.fixedInt(((optionTextWidth - nonScrollWidth) / 15) * 2000), + x: `-=${optionTextWidth - nonScrollWidth}`, }); } @@ -420,30 +468,47 @@ export default class MysteryEncounterUiHandler extends UiHandler { } // View Party Button - const viewPartyText = addBBCodeTextObject((globalScene.game.canvas.width) / 6, -24, getBBCodeFrag(i18next.t("mysteryEncounterMessages:view_party_button"), TextStyle.PARTY), TextStyle.PARTY); + const viewPartyText = addBBCodeTextObject( + globalScene.game.canvas.width / 6, + -24, + getBBCodeFrag(i18next.t("mysteryEncounterMessages:view_party_button"), TextStyle.PARTY), + TextStyle.PARTY, + ); this.optionsContainer.add(viewPartyText); - viewPartyText.x -= (viewPartyText.displayWidth + 16); + viewPartyText.x -= viewPartyText.displayWidth + 16; this.viewPartyXPosition = viewPartyText.x - 10; // Description Window - const titleTextObject = addBBCodeTextObject(0, 0, titleText ?? "", TextStyle.TOOLTIP_TITLE, { wordWrap: { width: 750 }, align: "center", lineSpacing: -8 }); + const titleTextObject = addBBCodeTextObject(0, 0, titleText ?? "", TextStyle.TOOLTIP_TITLE, { + wordWrap: { width: 750 }, + align: "center", + lineSpacing: -8, + }); this.descriptionContainer.add(titleTextObject); titleTextObject.setPosition(72 - titleTextObject.displayWidth / 2, 5.5); // Rarity of encounter - const index = mysteryEncounter.encounterTier === MysteryEncounterTier.COMMON ? 0 : - mysteryEncounter.encounterTier === MysteryEncounterTier.GREAT ? 1 : - mysteryEncounter.encounterTier === MysteryEncounterTier.ULTRA ? 2 : - mysteryEncounter.encounterTier === MysteryEncounterTier.ROGUE ? 3 : 4; + const index = + mysteryEncounter.encounterTier === MysteryEncounterTier.COMMON + ? 0 + : mysteryEncounter.encounterTier === MysteryEncounterTier.GREAT + ? 1 + : mysteryEncounter.encounterTier === MysteryEncounterTier.ULTRA + ? 2 + : mysteryEncounter.encounterTier === MysteryEncounterTier.ROGUE + ? 3 + : 4; const ballType = getPokeballAtlasKey(index); this.rarityBall.setTexture("pb", ballType); - const descriptionTextObject = addBBCodeTextObject(6, 25, descriptionText ?? "", TextStyle.TOOLTIP_CONTENT, { wordWrap: { width: 830 }}); + const descriptionTextObject = addBBCodeTextObject(6, 25, descriptionText ?? "", TextStyle.TOOLTIP_CONTENT, { + wordWrap: { width: 830 }, + }); // Sets up the mask that hides the description text to give an illusion of scrolling const descriptionTextMaskRect = globalScene.make.graphics({}); descriptionTextMaskRect.setScale(6); - descriptionTextMaskRect.fillStyle(0xFFFFFF); + descriptionTextMaskRect.fillStyle(0xffffff); descriptionTextMaskRect.beginPath(); descriptionTextMaskRect.fillRect(6, 53, 206, 57); @@ -466,13 +531,15 @@ export default class MysteryEncounterUiHandler extends UiHandler { loop: -1, hold: Utils.fixedInt(2000), duration: Utils.fixedInt((descriptionLineCount - 6) * 2000), - y: `-=${10 * (descriptionLineCount - 6)}` + y: `-=${10 * (descriptionLineCount - 6)}`, }); } this.descriptionContainer.add(descriptionTextObject); - const queryTextObject = addBBCodeTextObject(0, 0, queryText ?? "", TextStyle.TOOLTIP_CONTENT, { wordWrap: { width: 830 }}); + const queryTextObject = addBBCodeTextObject(0, 0, queryText ?? "", TextStyle.TOOLTIP_CONTENT, { + wordWrap: { width: 830 }, + }); this.descriptionContainer.add(queryTextObject); queryTextObject.setPosition(75 - queryTextObject.displayWidth / 2, 90); @@ -483,7 +550,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { targets: this.descriptionContainer, x: "+=150", ease: "Sine.easeInOut", - duration: 1000 + duration: 1000, }); } } @@ -510,7 +577,12 @@ export default class MysteryEncounterUiHandler extends UiHandler { let text: string | null; const cursorOption = this.encounterOptions[cursor]; const optionDialogue = cursorOption.dialogue!; - if (!this.optionsMeetsReqs[cursor] && (cursorOption.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || cursorOption.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) && optionDialogue.disabledButtonTooltip) { + if ( + !this.optionsMeetsReqs[cursor] && + (cursorOption.optionMode === MysteryEncounterOptionMode.DISABLED_OR_DEFAULT || + cursorOption.optionMode === MysteryEncounterOptionMode.DISABLED_OR_SPECIAL) && + optionDialogue.disabledButtonTooltip + ) { text = getEncounterText(optionDialogue.disabledButtonTooltip, TextStyle.TOOLTIP_CONTENT); } else { text = getEncounterText(optionDialogue.buttonTooltip, TextStyle.TOOLTIP_CONTENT); @@ -518,19 +590,36 @@ export default class MysteryEncounterUiHandler extends UiHandler { // Auto-color options green/blue for good/bad by looking for (+)/(-) if (text) { - const primaryStyleString = [ ...text.match(new RegExp(/\[color=[^\[]*\]\[shadow=[^\[]*\]/i))! ][0]; - text = text.replace(/(\(\+\)[^\(\[]*)/gi, substring => "[/color][/shadow]" + getBBCodeFrag(substring, TextStyle.SUMMARY_GREEN) + "[/color][/shadow]" + primaryStyleString); - text = text.replace(/(\(\-\)[^\(\[]*)/gi, substring => "[/color][/shadow]" + getBBCodeFrag(substring, TextStyle.SUMMARY_BLUE) + "[/color][/shadow]" + primaryStyleString); + const primaryStyleString = [...text.match(new RegExp(/\[color=[^\[]*\]\[shadow=[^\[]*\]/i))!][0]; + text = text.replace( + /(\(\+\)[^\(\[]*)/gi, + substring => + "[/color][/shadow]" + + getBBCodeFrag(substring, TextStyle.SUMMARY_GREEN) + + "[/color][/shadow]" + + primaryStyleString, + ); + text = text.replace( + /(\(\-\)[^\(\[]*)/gi, + substring => + "[/color][/shadow]" + + getBBCodeFrag(substring, TextStyle.SUMMARY_BLUE) + + "[/color][/shadow]" + + primaryStyleString, + ); } if (text) { - const tooltipTextObject = addBBCodeTextObject(6, 7, text, TextStyle.TOOLTIP_CONTENT, { wordWrap: { width: 600 }, fontSize: "72px" }); + const tooltipTextObject = addBBCodeTextObject(6, 7, text, TextStyle.TOOLTIP_CONTENT, { + wordWrap: { width: 600 }, + fontSize: "72px", + }); this.tooltipContainer.add(tooltipTextObject); // Sets up the mask that hides the description text to give an illusion of scrolling const tooltipTextMaskRect = globalScene.make.graphics({}); tooltipTextMaskRect.setScale(6); - tooltipTextMaskRect.fillStyle(0xFFFFFF); + tooltipTextMaskRect.fillStyle(0xffffff); tooltipTextMaskRect.beginPath(); tooltipTextMaskRect.fillRect(this.tooltipContainer.x, this.tooltipContainer.y + 188.5, 150, 32); @@ -552,7 +641,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { loop: -1, hold: Utils.fixedInt(1200), duration: Utils.fixedInt((tooltipLineCount - 3) * 1200), - y: `-=${11.2 * (tooltipLineCount - 3)}` + y: `-=${11.2 * (tooltipLineCount - 3)}`, }); } } @@ -606,7 +695,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { this.dexProgressContainer.on("pointerout", () => { globalScene.ui.hideTooltip(); }); - } + }, }); } else if (!show && this.showDexProgress) { this.showDexProgress = false; @@ -619,7 +708,7 @@ export default class MysteryEncounterUiHandler extends UiHandler { onComplete: () => { this.dexProgressContainer.off("pointerover"); this.dexProgressContainer.off("pointerout"); - } + }, }); } } diff --git a/src/ui/party-exp-bar.ts b/src/ui/party-exp-bar.ts index b9da9320fcb..7b7f5277ca1 100644 --- a/src/ui/party-exp-bar.ts +++ b/src/ui/party-exp-bar.ts @@ -13,7 +13,7 @@ export default class PartyExpBar extends Phaser.GameObjects.Container { public shown: boolean; constructor() { - super(globalScene, (globalScene.game.canvas.width / 6), -((globalScene.game.canvas.height) / 6) + 15); + super(globalScene, globalScene.game.canvas.width / 6, -(globalScene.game.canvas.height / 6) + 15); } setup(): void { @@ -43,9 +43,11 @@ export default class PartyExpBar extends Phaser.GameObjects.Container { // if we want to only display the level in the small frame if (showOnlyLevelUp) { - if (newLevel > 200) { // if the level is greater than 200, we only display Lv. UP + if (newLevel > 200) { + // if the level is greater than 200, we only display Lv. UP this.expText.setText(i18next.t("battleScene:levelUp")); - } else { // otherwise we display Lv. Up and the new level + } else { + // otherwise we display Lv. Up and the new level this.expText.setText(i18next.t("battleScene:levelUpWithLevel", { level: newLevel })); } } else { @@ -63,13 +65,13 @@ export default class PartyExpBar extends Phaser.GameObjects.Container { this.tween = globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6) - (this.bg.width - 5), + x: globalScene.game.canvas.width / 6 - (this.bg.width - 5), duration: 500 / Math.pow(2, globalScene.expGainsSpeed), ease: "Sine.easeOut", onComplete: () => { this.tween = null; resolve(); - } + }, }); this.setVisible(true); @@ -89,7 +91,7 @@ export default class PartyExpBar extends Phaser.GameObjects.Container { this.tween = globalScene.tweens.add({ targets: this, - x: (globalScene.game.canvas.width / 6), + x: globalScene.game.canvas.width / 6, duration: 500, ease: "Sine.easeIn", onComplete: () => { @@ -98,7 +100,7 @@ export default class PartyExpBar extends Phaser.GameObjects.Container { this.setVisible(false); this.pokemonIcon?.destroy(); resolve(); - } + }, }); }); } diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 19b2b78e22f..21e5f9077f4 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -6,7 +6,11 @@ import { Command } from "#app/ui/command-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler"; import { Mode } from "#app/ui/ui"; import * as Utils from "#app/utils"; -import { PokemonFormChangeItemModifier, PokemonHeldItemModifier, SwitchEffectTransferModifier } from "#app/modifier/modifier"; +import { + PokemonFormChangeItemModifier, + PokemonHeldItemModifier, + SwitchEffectTransferModifier, +} from "#app/modifier/modifier"; import { allMoves, ForceSwitchOutAttr } from "#app/data/moves/move"; import { Gender, getGenderColor, getGenderSymbol } from "#app/data/gender"; import { StatusEffect } from "#enums/status-effect"; @@ -97,7 +101,7 @@ export enum PartyUiMode { * Indicates that the party UI is open to select a party member for an arbitrary effect. * This is generally used in for Mystery Encounter or special effects that require the player to select a Pokemon */ - SELECT + SELECT, } export enum PartyOption { @@ -127,10 +131,18 @@ export enum PartyOption { } export type PartySelectCallback = (cursor: number, option: PartyOption) => void; -export type PartyModifierTransferSelectCallback = (fromCursor: number, index: number, itemQuantity?: number, toCursor?: number) => void; +export type PartyModifierTransferSelectCallback = ( + fromCursor: number, + index: number, + itemQuantity?: number, + toCursor?: number, +) => void; export type PartyModifierSpliceSelectCallback = (fromCursor: number, toCursor?: number) => void; export type PokemonSelectFilter = (pokemon: PlayerPokemon) => string | null; -export type PokemonModifierTransferSelectFilter = (pokemon: PlayerPokemon, modifier: PokemonHeldItemModifier) => string | null; +export type PokemonModifierTransferSelectFilter = ( + pokemon: PlayerPokemon, + modifier: PokemonHeldItemModifier, +) => string | null; export type PokemonMoveSelectFilter = (pokemonMove: PokemonMove) => string | null; export default class PartyUiHandler extends MessageUiHandler { @@ -147,9 +159,9 @@ export default class PartyUiHandler extends MessageUiHandler { private optionsMode: boolean; private optionsScroll: boolean; - private optionsCursor: number = 0; - private optionsScrollCursor: number = 0; - private optionsScrollTotal: number = 0; + private optionsCursor = 0; + private optionsScrollCursor = 0; + private optionsScrollTotal = 0; /** This is only public for test/ui/transfer-item.test.ts */ public optionsContainer: Phaser.GameObjects.Container; private optionsBg: Phaser.GameObjects.NineSlice; @@ -166,7 +178,7 @@ export default class PartyUiHandler extends MessageUiHandler { /** Whether to transfer all items */ private transferAll: boolean; - private lastCursor: number = 0; + private lastCursor = 0; private selectCallback: PartySelectCallback | PartyModifierTransferSelectCallback | null; private selectFilter: PokemonSelectFilter | PokemonModifierTransferSelectFilter; private moveSelectFilter: PokemonMoveSelectFilter; @@ -181,14 +193,18 @@ export default class PartyUiHandler extends MessageUiHandler { public static FilterNonFainted = (pokemon: PlayerPokemon) => { if (pokemon.isFainted()) { - return i18next.t("partyUiHandler:noEnergy", { pokemonName: getPokemonNameWithAffix(pokemon) }); + return i18next.t("partyUiHandler:noEnergy", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } return null; }; public static FilterFainted = (pokemon: PlayerPokemon) => { if (!pokemon.isFainted()) { - return i18next.t("partyUiHandler:hasEnergy", { pokemonName: getPokemonNameWithAffix(pokemon) }); + return i18next.t("partyUiHandler:hasEnergy", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } return null; }; @@ -202,7 +218,9 @@ export default class PartyUiHandler extends MessageUiHandler { const challengeAllowed = new Utils.BooleanHolder(true); applyChallenges(globalScene.gameMode, ChallengeType.POKEMON_IN_BATTLE, pokemon, challengeAllowed); if (!challengeAllowed.value) { - return i18next.t("partyUiHandler:cantBeUsed", { pokemonName: getPokemonNameWithAffix(pokemon) }); + return i18next.t("partyUiHandler:cantBeUsed", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } return null; }; @@ -210,16 +228,36 @@ export default class PartyUiHandler extends MessageUiHandler { private static FilterAllMoves = (_pokemonMove: PokemonMove) => null; public static FilterItemMaxStacks = (pokemon: PlayerPokemon, modifier: PokemonHeldItemModifier) => { - const matchingModifier = globalScene.findModifier(m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(modifier)) as PokemonHeldItemModifier; + const matchingModifier = globalScene.findModifier( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(modifier), + ) as PokemonHeldItemModifier; if (matchingModifier && matchingModifier.stackCount === matchingModifier.getMaxStackCount()) { - return i18next.t("partyUiHandler:tooManyItems", { pokemonName: getPokemonNameWithAffix(pokemon) }); + return i18next.t("partyUiHandler:tooManyItems", { + pokemonName: getPokemonNameWithAffix(pokemon), + }); } return null; }; public static NoEffectMessage = i18next.t("partyUiHandler:anyEffect"); - private localizedOptions = [ PartyOption.SEND_OUT, PartyOption.SUMMARY, PartyOption.POKEDEX, PartyOption.CANCEL, PartyOption.APPLY, PartyOption.RELEASE, PartyOption.TEACH, PartyOption.SPLICE, PartyOption.UNSPLICE, PartyOption.REVIVE, PartyOption.TRANSFER, PartyOption.UNPAUSE_EVOLUTION, PartyOption.PASS_BATON, PartyOption.RENAME, PartyOption.SELECT ]; + private localizedOptions = [ + PartyOption.SEND_OUT, + PartyOption.SUMMARY, + PartyOption.POKEDEX, + PartyOption.CANCEL, + PartyOption.APPLY, + PartyOption.RELEASE, + PartyOption.TEACH, + PartyOption.SPLICE, + PartyOption.UNSPLICE, + PartyOption.REVIVE, + PartyOption.TRANSFER, + PartyOption.UNPAUSE_EVOLUTION, + PartyOption.PASS_BATON, + PartyOption.RENAME, + PartyOption.SELECT, + ]; constructor() { super(Mode.PARTY); @@ -271,7 +309,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.partyCancelButton = partyCancelButton; - this.optionsContainer = globalScene.add.container((globalScene.game.canvas.width / 6) - 1, -1); + this.optionsContainer = globalScene.add.container(globalScene.game.canvas.width / 6 - 1, -1); partyContainer.add(this.optionsContainer); this.iconAnimHandler = new PokemonIconAnimHandler(); @@ -305,15 +343,15 @@ export default class PartyUiHandler extends MessageUiHandler { this.partyUiMode = args[0] as PartyUiMode; - this.fieldIndex = args.length > 1 ? args[1] as number : -1; + this.fieldIndex = args.length > 1 ? (args[1] as number) : -1; this.selectCallback = args.length > 2 && args[2] instanceof Function ? args[2] : undefined; - this.selectFilter = args.length > 3 && args[3] instanceof Function - ? args[3] as PokemonSelectFilter - : PartyUiHandler.FilterAll; - this.moveSelectFilter = args.length > 4 && args[4] instanceof Function - ? args[4] as PokemonMoveSelectFilter - : PartyUiHandler.FilterAllMoves; + this.selectFilter = + args.length > 3 && args[3] instanceof Function ? (args[3] as PokemonSelectFilter) : PartyUiHandler.FilterAll; + this.moveSelectFilter = + args.length > 4 && args[4] instanceof Function + ? (args[4] as PokemonMoveSelectFilter) + : PartyUiHandler.FilterAllMoves; this.tmMoveId = args.length > 5 && args[5] ? args[5] : Moves.NONE; this.showMovePp = args.length > 6 && args[6]; @@ -354,25 +392,42 @@ export default class PartyUiHandler extends MessageUiHandler { this.startTransfer(); let ableToTransfer: string; - for (let p = 0; p < globalScene.getPlayerParty().length; p++) { // this for look goes through each of the party pokemon + for (let p = 0; p < globalScene.getPlayerParty().length; p++) { + // this for look goes through each of the party pokemon const newPokemon = globalScene.getPlayerParty()[p]; // this next line gets all of the transferable items from pokemon [p]; it does this by getting all the held modifiers that are transferable and checking to see if they belong to pokemon [p] const getTransferrableItemsFromPokemon = (newPokemon: PlayerPokemon) => - globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).isTransferable && (m as PokemonHeldItemModifier).pokemonId === newPokemon.id) as PokemonHeldItemModifier[]; + globalScene.findModifiers( + m => + m instanceof PokemonHeldItemModifier && + (m as PokemonHeldItemModifier).isTransferable && + (m as PokemonHeldItemModifier).pokemonId === newPokemon.id, + ) as PokemonHeldItemModifier[]; // this next bit checks to see if the the selected item from the original transfer pokemon exists on the new pokemon [p]; this returns undefined if the new pokemon doesn't have the item at all, otherwise it returns the pokemonHeldItemModifier for that item - const matchingModifier = globalScene.findModifier(m => m instanceof PokemonHeldItemModifier && m.pokemonId === newPokemon.id && m.matchType(getTransferrableItemsFromPokemon(pokemon)[this.transferOptionCursor])) as PokemonHeldItemModifier; + const matchingModifier = globalScene.findModifier( + m => + m instanceof PokemonHeldItemModifier && + m.pokemonId === newPokemon.id && + m.matchType(getTransferrableItemsFromPokemon(pokemon)[this.transferOptionCursor]), + ) as PokemonHeldItemModifier; const partySlot = this.partySlots.filter(m => m.getPokemon() === newPokemon)[0]; // this gets pokemon [p] for us - if (p !== this.transferCursor) { // this skips adding the able/not able labels on the pokemon doing the transfer - if (matchingModifier) { // if matchingModifier exists then the item exists on the new pokemon - if (matchingModifier.getMaxStackCount() === matchingModifier.stackCount) { // checks to see if the stack of items is at max stack; if so, set the description label to "Not able" + if (p !== this.transferCursor) { + // this skips adding the able/not able labels on the pokemon doing the transfer + if (matchingModifier) { + // if matchingModifier exists then the item exists on the new pokemon + if (matchingModifier.getMaxStackCount() === matchingModifier.stackCount) { + // checks to see if the stack of items is at max stack; if so, set the description label to "Not able" ableToTransfer = i18next.t("partyUiHandler:notAble"); - } else { // if the pokemon isn't at max stack, make the label "Able" + } else { + // if the pokemon isn't at max stack, make the label "Able" ableToTransfer = i18next.t("partyUiHandler:able"); } - } else { // if matchingModifier doesn't exist, that means the pokemon doesn't have any of the item, and we need to show "Able" + } else { + // if matchingModifier doesn't exist, that means the pokemon doesn't have any of the item, and we need to show "Able" ableToTransfer = i18next.t("partyUiHandler:able"); } - } else { // this else relates to the transfer pokemon. We set the text to be blank so there's no "Able"/"Not able" text + } else { + // this else relates to the transfer pokemon. We set the text to be blank so there's no "Able"/"Not able" text ableToTransfer = ""; } partySlot.slotHpBar.setVisible(false); @@ -385,7 +440,8 @@ export default class PartyUiHandler extends MessageUiHandler { this.clearOptions(); ui.playSelect(); return true; - } else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER && option !== PartyOption.CANCEL) { + } + if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER && option !== PartyOption.CANCEL) { // clear overlay on cancel this.moveInfoOverlay.clear(); const filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon); @@ -398,11 +454,24 @@ export default class PartyUiHandler extends MessageUiHandler { } ui.playSelect(); return true; - } else if ((![ PartyOption.SUMMARY, PartyOption.POKEDEX, PartyOption.UNPAUSE_EVOLUTION, PartyOption.UNSPLICE, PartyOption.RELEASE, PartyOption.CANCEL, PartyOption.RENAME ].includes(option)) - || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) { + } + if ( + ![ + PartyOption.SUMMARY, + PartyOption.POKEDEX, + PartyOption.UNPAUSE_EVOLUTION, + PartyOption.UNSPLICE, + PartyOption.RELEASE, + PartyOption.CANCEL, + PartyOption.RENAME, + ].includes(option) || + (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE) + ) { let filterResult: string | null; const getTransferrableItemsFromPokemon = (pokemon: PlayerPokemon) => - globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id) as PokemonHeldItemModifier[]; + globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id, + ) as PokemonHeldItemModifier[]; if (option !== PartyOption.TRANSFER && option !== PartyOption.SPLICE) { filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon); if (filterResult === null && (option === PartyOption.SEND_OUT || option === PartyOption.PASS_BATON)) { @@ -412,7 +481,12 @@ export default class PartyUiHandler extends MessageUiHandler { filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]!); // TODO: is this bang correct? } } else { - filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)(pokemon, getTransferrableItemsFromPokemon(globalScene.getPlayerParty()[this.transferCursor])[this.transferOptionCursor]); + filterResult = (this.selectFilter as PokemonModifierTransferSelectFilter)( + pokemon, + getTransferrableItemsFromPokemon(globalScene.getPlayerParty()[this.transferCursor])[ + this.transferOptionCursor + ], + ); } if (filterResult === null) { if (this.partyUiMode !== PartyUiMode.SPLICE) { @@ -422,12 +496,24 @@ export default class PartyUiHandler extends MessageUiHandler { if (option === PartyOption.TRANSFER) { if (this.transferCursor !== this.cursor) { if (this.transferAll) { - getTransferrableItemsFromPokemon(globalScene.getPlayerParty()[this.transferCursor]).forEach((_, i, array) => { - const invertedIndex = array.length - 1 - i; - (this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, invertedIndex, this.transferQuantitiesMax[invertedIndex], this.cursor); - }); + getTransferrableItemsFromPokemon(globalScene.getPlayerParty()[this.transferCursor]).forEach( + (_, i, array) => { + const invertedIndex = array.length - 1 - i; + (this.selectCallback as PartyModifierTransferSelectCallback)( + this.transferCursor, + invertedIndex, + this.transferQuantitiesMax[invertedIndex], + this.cursor, + ); + }, + ); } else { - (this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, this.transferOptionCursor, this.transferQuantities[this.transferOptionCursor], this.cursor); + (this.selectCallback as PartyModifierTransferSelectCallback)( + this.transferCursor, + this.transferOptionCursor, + this.transferQuantities[this.transferOptionCursor], + this.cursor, + ); } } this.clearTransfer(); @@ -447,7 +533,10 @@ export default class PartyUiHandler extends MessageUiHandler { selectCallback(this.cursor, option); } } else { - if (option >= PartyOption.FORM_CHANGE_ITEM && globalScene.getCurrentPhase() instanceof SelectModifierPhase) { + if ( + option >= PartyOption.FORM_CHANGE_ITEM && + globalScene.getCurrentPhase() instanceof SelectModifierPhase + ) { if (this.partyUiMode === PartyUiMode.CHECK) { const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon); const modifier = formChangeItemModifiers[option - PartyOption.FORM_CHANGE_ITEM]; @@ -455,20 +544,27 @@ export default class PartyUiHandler extends MessageUiHandler { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeItemTrigger, false, true); } } else if (this.cursor) { - (globalScene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor, option === PartyOption.PASS_BATON); + (globalScene.getCurrentPhase() as CommandPhase).handleCommand( + Command.POKEMON, + this.cursor, + option === PartyOption.PASS_BATON, + ); } } - if (this.partyUiMode !== PartyUiMode.MODIFIER && this.partyUiMode !== PartyUiMode.TM_MODIFIER && this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) { + if ( + this.partyUiMode !== PartyUiMode.MODIFIER && + this.partyUiMode !== PartyUiMode.TM_MODIFIER && + this.partyUiMode !== PartyUiMode.MOVE_MODIFIER + ) { ui.playSelect(); } return true; - } else { - this.clearOptions(); - this.showText(filterResult as string, undefined, () => this.showText("", 0), undefined, true); } + this.clearOptions(); + 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(Mode.SUMMARY, pokemon).then(() => this.clearOptions()); return true; } else if (option === PartyOption.POKEDEX) { ui.playSelect(); @@ -476,50 +572,91 @@ export default class PartyUiHandler extends MessageUiHandler { shiny: pokemon.shiny, variant: pokemon.variant, form: pokemon.formIndex, - female: pokemon.gender === Gender.FEMALE ? true : false + female: pokemon.gender === Gender.FEMALE, }; - ui.setOverlayMode(Mode.POKEDEX_PAGE, pokemon.species, pokemon.formIndex, attributes).then(() => this.clearOptions()); + ui.setOverlayMode(Mode.POKEDEX_PAGE, pokemon.species, pokemon.formIndex, attributes).then(() => + this.clearOptions(), + ); return true; } else if (option === PartyOption.UNPAUSE_EVOLUTION) { this.clearOptions(); ui.playSelect(); pokemon.pauseEvolutions = !pokemon.pauseEvolutions; - this.showText(i18next.t(pokemon.pauseEvolutions ? "partyUiHandler:pausedEvolutions" : "partyUiHandler:unpausedEvolutions", { pokemonName: getPokemonNameWithAffix(pokemon) }), undefined, () => this.showText("", 0), null, true); + this.showText( + i18next.t( + pokemon.pauseEvolutions ? "partyUiHandler:pausedEvolutions" : "partyUiHandler:unpausedEvolutions", + { pokemonName: getPokemonNameWithAffix(pokemon) }, + ), + undefined, + () => this.showText("", 0), + null, + true, + ); } else if (option === PartyOption.UNSPLICE) { this.clearOptions(); ui.playSelect(); - this.showText(i18next.t("partyUiHandler:unspliceConfirmation", { fusionName: pokemon.fusionSpecies?.name, pokemonName: pokemon.name }), null, () => { - ui.setModeWithoutClear(Mode.CONFIRM, () => { - const fusionName = pokemon.name; - pokemon.unfuse().then(() => { - this.clearPartySlots(); - this.populatePartySlots(); - ui.setMode(Mode.PARTY); - this.showText(i18next.t("partyUiHandler:wasReverted", { fusionName: fusionName, pokemonName: pokemon.name }), undefined, () => { + this.showText( + i18next.t("partyUiHandler:unspliceConfirmation", { + fusionName: pokemon.fusionSpecies?.name, + pokemonName: pokemon.name, + }), + null, + () => { + ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + const fusionName = pokemon.name; + pokemon.unfuse().then(() => { + this.clearPartySlots(); + this.populatePartySlots(); + ui.setMode(Mode.PARTY); + this.showText( + i18next.t("partyUiHandler:wasReverted", { + fusionName: fusionName, + pokemonName: pokemon.name, + }), + undefined, + () => { + ui.setMode(Mode.PARTY); + this.showText("", 0); + }, + null, + true, + ); + }); + }, + () => { ui.setMode(Mode.PARTY); this.showText("", 0); - }, null, true); - }); - }, () => { - ui.setMode(Mode.PARTY); - this.showText("", 0); - }); - }); + }, + ); + }, + ); } else if (option === PartyOption.RELEASE) { this.clearOptions(); ui.playSelect(); if (this.cursor >= globalScene.currentBattle.getBattlerCount() || !pokemon.isAllowedInBattle()) { this.blockInput = true; - this.showText(i18next.t("partyUiHandler:releaseConfirmation", { pokemonName: getPokemonNameWithAffix(pokemon) }), null, () => { - this.blockInput = false; - ui.setModeWithoutClear(Mode.CONFIRM, () => { - ui.setMode(Mode.PARTY); - this.doRelease(this.cursor); - }, () => { - ui.setMode(Mode.PARTY); - this.showText("", 0); - }); - }); + this.showText( + i18next.t("partyUiHandler:releaseConfirmation", { + pokemonName: getPokemonNameWithAffix(pokemon), + }), + null, + () => { + this.blockInput = false; + ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + ui.setMode(Mode.PARTY); + this.doRelease(this.cursor); + }, + () => { + ui.setMode(Mode.PARTY); + this.showText("", 0); + }, + ); + }, + ); } else { this.showText(i18next.t("partyUiHandler:releaseInBattle"), null, () => this.showText("", 0), null, true); } @@ -527,21 +664,25 @@ export default class PartyUiHandler extends MessageUiHandler { } else if (option === PartyOption.RENAME) { this.clearOptions(); ui.playSelect(); - ui.setModeWithoutClear(Mode.RENAME_POKEMON, { - buttonActions: [ - (nickname: string) => { - ui.playSelect(); - pokemon.nickname = nickname; - pokemon.updateInfo(); - this.clearPartySlots(); - this.populatePartySlots(); - ui.setMode(Mode.PARTY); - }, - () => { - ui.setMode(Mode.PARTY); - } - ] - }, pokemon); + ui.setModeWithoutClear( + Mode.RENAME_POKEMON, + { + buttonActions: [ + (nickname: string) => { + ui.playSelect(); + pokemon.nickname = nickname; + pokemon.updateInfo(); + this.clearPartySlots(); + this.populatePartySlots(); + ui.setMode(Mode.PARTY); + }, + () => { + ui.setMode(Mode.PARTY); + }, + ], + }, + pokemon, + ); return true; } else if (option === PartyOption.CANCEL) { return this.processInput(Button.CANCEL); @@ -556,40 +697,54 @@ export default class PartyUiHandler extends MessageUiHandler { } else { switch (button) { case Button.LEFT: - /** Decrease quantity for the current item and update UI */ + /** Decrease quantity for the current item and update UI */ if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) { - this.transferQuantities[option] = this.transferQuantities[option] === 1 ? this.transferQuantitiesMax[option] : this.transferQuantities[option] - 1; + this.transferQuantities[option] = + this.transferQuantities[option] === 1 + ? this.transferQuantitiesMax[option] + : this.transferQuantities[option] - 1; this.updateOptions(); - success = this.setCursor(this.optionsCursor); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */ + success = this.setCursor( + this.optionsCursor, + ); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */ } break; case Button.RIGHT: - /** Increase quantity for the current item and update UI */ + /** Increase quantity for the current item and update UI */ if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) { - this.transferQuantities[option] = this.transferQuantities[option] === this.transferQuantitiesMax[option] ? 1 : this.transferQuantities[option] + 1; + this.transferQuantities[option] = + this.transferQuantities[option] === this.transferQuantitiesMax[option] + ? 1 + : this.transferQuantities[option] + 1; this.updateOptions(); - success = this.setCursor(this.optionsCursor); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */ + success = this.setCursor( + this.optionsCursor, + ); /** Place again the cursor at the same position. Necessary, otherwise the cursor disappears */ } break; case Button.UP: - /** If currently selecting items to transfer, reset quantity selection */ + /** If currently selecting items to transfer, reset quantity selection */ if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) { if (option !== PartyOption.ALL) { this.transferQuantities[option] = this.transferQuantitiesMax[option]; } this.updateOptions(); } - success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1); /** Move cursor */ + success = this.setCursor( + this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1, + ); /** Move cursor */ break; case Button.DOWN: - /** If currently selecting items to transfer, reset quantity selection */ + /** If currently selecting items to transfer, reset quantity selection */ if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) { if (option !== PartyOption.ALL) { this.transferQuantities[option] = this.transferQuantitiesMax[option]; } this.updateOptions(); } - success = this.setCursor(this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0); /** Move cursor */ + success = this.setCursor( + this.optionsCursor < this.options.length - 1 ? this.optionsCursor + 1 : 0, + ); /** Move cursor */ break; } @@ -611,8 +766,12 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.cursor < 6) { if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) { /** Initialize item quantities for the selected Pokemon */ - const itemModifiers = globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.isTransferable && m.pokemonId === globalScene.getPlayerParty()[this.cursor].id) as PokemonHeldItemModifier[]; + const itemModifiers = globalScene.findModifiers( + m => + m instanceof PokemonHeldItemModifier && + m.isTransferable && + m.pokemonId === globalScene.getPlayerParty()[this.cursor].id, + ) as PokemonHeldItemModifier[]; this.transferQuantities = itemModifiers.map(item => item.getStackCount()); this.transferQuantitiesMax = itemModifiers.map(item => item.getStackCount()); } @@ -624,8 +783,12 @@ export default class PartyUiHandler extends MessageUiHandler { return this.processInput(Button.CANCEL); } return true; - } else if (button === Button.CANCEL) { - if ((this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.SPLICE) && this.transferMode) { + } + if (button === Button.CANCEL) { + if ( + (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.SPLICE) && + this.transferMode + ) { this.clearTransfer(); ui.playSelect(); } else if (this.partyUiMode !== PartyUiMode.FAINT_SWITCH && this.partyUiMode !== PartyUiMode.REVIVAL_BLESSING) { @@ -648,10 +811,10 @@ export default class PartyUiHandler extends MessageUiHandler { switch (button) { case Button.UP: - success = this.setCursor(this.cursor ? this.cursor < 6 ? this.cursor - 1 : slotCount - 1 : 6); + success = this.setCursor(this.cursor ? (this.cursor < 6 ? this.cursor - 1 : slotCount - 1) : 6); break; case Button.DOWN: - success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); + success = this.setCursor(this.cursor < 6 ? (this.cursor < slotCount - 1 ? this.cursor + 1 : 6) : 0); break; case Button.LEFT: if (this.cursor >= battlerCount && this.cursor <= 6) { @@ -662,11 +825,13 @@ export default class PartyUiHandler extends MessageUiHandler { if (slotCount === battlerCount) { success = this.setCursor(6); break; - } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1) { + } + if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1) { success = this.setCursor(2); break; - } else if (slotCount > battlerCount && this.cursor < battlerCount) { - success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); + } + if (slotCount > battlerCount && this.cursor < battlerCount) { + success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); break; } } @@ -692,7 +857,7 @@ export default class PartyUiHandler extends MessageUiHandler { } for (const p in party) { - const slotIndex = parseInt(p); + const slotIndex = Number.parseInt(p); const partySlot = new PartySlot(slotIndex, party[p], this.iconAnimHandler, this.partyUiMode, this.tmMoveId); globalScene.add.existing(partySlot); this.partySlotsContainer.add(partySlot); @@ -714,7 +879,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.optionsScrollCursor = cursor ? this.optionsScrollTotal - 8 : 0; this.updateOptions(); } else { - const isDown = cursor && cursor > this.optionsCursor; + const isDown = cursor && cursor > this.optionsCursor; if (isDown) { if (this.options[cursor] === PartyOption.SCROLL_DOWN) { isScroll = true; @@ -741,7 +906,10 @@ export default class PartyUiHandler extends MessageUiHandler { this.optionsCursorObj.setOrigin(0, 0); this.optionsContainer.add(this.optionsCursorObj); } - this.optionsCursorObj.setPosition(8 - this.optionsBg.displayWidth, -19 - (16 * ((this.options.length - 1) - this.optionsCursor))); + this.optionsCursorObj.setPosition( + 8 - this.optionsBg.displayWidth, + -19 - 16 * (this.options.length - 1 - this.optionsCursor), + ); } else { changed = this.cursor !== cursor; if (changed) { @@ -763,7 +931,14 @@ export default class PartyUiHandler extends MessageUiHandler { return changed; } - showText(text: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null) { + showText( + text: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ) { if (text.length === 0) { text = defaultMessage; } @@ -821,19 +996,20 @@ export default class PartyUiHandler extends MessageUiHandler { updateOptions(): void { const pokemon = globalScene.getPlayerParty()[this.cursor]; - const learnableLevelMoves = this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER - ? pokemon.getLearnableLevelMoves() - : []; + const learnableLevelMoves = + this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER ? pokemon.getLearnableLevelMoves() : []; if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER && learnableLevelMoves?.length) { // show the move overlay with info for the first move this.moveInfoOverlay.show(allMoves[learnableLevelMoves[0]]); } - const itemModifiers = this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER - ? globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.isTransferable && m.pokemonId === pokemon.id) as PokemonHeldItemModifier[] - : []; + const itemModifiers = + this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER + ? (globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id, + ) as PokemonHeldItemModifier[]) + : []; if (this.options.length) { this.options.splice(0, this.options.length); @@ -843,27 +1019,40 @@ export default class PartyUiHandler extends MessageUiHandler { let formChangeItemModifiers: PokemonFormChangeItemModifier[] | undefined; - if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER)) { + if ( + this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && + this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && + (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER) + ) { switch (this.partyUiMode) { case PartyUiMode.SWITCH: case PartyUiMode.FAINT_SWITCH: case PartyUiMode.POST_BATTLE_SWITCH: if (this.cursor >= globalScene.currentBattle.getBattlerCount()) { const allowBatonModifierSwitch = - this.partyUiMode !== PartyUiMode.FAINT_SWITCH - && globalScene.findModifier(m => m instanceof SwitchEffectTransferModifier - && (m as SwitchEffectTransferModifier).pokemonId === globalScene.getPlayerField()[this.fieldIndex].id); + this.partyUiMode !== PartyUiMode.FAINT_SWITCH && + globalScene.findModifier( + m => + m instanceof SwitchEffectTransferModifier && + (m as SwitchEffectTransferModifier).pokemonId === globalScene.getPlayerField()[this.fieldIndex].id, + ); const moveHistory = globalScene.getPlayerField()[this.fieldIndex].getMoveHistory(); - const isBatonPassMove = this.partyUiMode === PartyUiMode.FAINT_SWITCH && moveHistory.length && allMoves[moveHistory[moveHistory.length - 1].move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass() && moveHistory[moveHistory.length - 1].result === MoveResult.SUCCESS; + const isBatonPassMove = + this.partyUiMode === PartyUiMode.FAINT_SWITCH && + moveHistory.length && + allMoves[moveHistory[moveHistory.length - 1].move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass() && + moveHistory[moveHistory.length - 1].result === MoveResult.SUCCESS; // isBatonPassMove and allowBatonModifierSwitch shouldn't ever be true // at the same time, because they both explicitly check for a mutually // exclusive partyUiMode. But better safe than sorry. - this.options.push(isBatonPassMove && !allowBatonModifierSwitch ? PartyOption.PASS_BATON : PartyOption.SEND_OUT); + this.options.push( + isBatonPassMove && !allowBatonModifierSwitch ? PartyOption.PASS_BATON : PartyOption.SEND_OUT, + ); if (allowBatonModifierSwitch && !isBatonPassMove) { - // the BATON modifier gives an extra switch option for - // pokemon-command switches, allowing buffs to be optionally passed + // the BATON modifier gives an extra switch option for + // pokemon-command switches, allowing buffs to be optionally passed this.options.push(PartyOption.PASS_BATON); } } @@ -909,7 +1098,12 @@ export default class PartyUiHandler extends MessageUiHandler { this.options.push(PartyOption.POKEDEX); this.options.push(PartyOption.RENAME); - if ((pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) || (pokemon.isFusion() && pokemon.fusionSpecies && pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId)))) { + if ( + pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) || + (pokemon.isFusion() && + pokemon.fusionSpecies && + pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId)) + ) { this.options.push(PartyOption.UNPAUSE_EVOLUTION); } @@ -941,7 +1135,10 @@ export default class PartyUiHandler extends MessageUiHandler { this.optionsScrollTotal = this.options.length; let optionStartIndex = this.optionsScrollCursor; - let optionEndIndex = Math.min(this.optionsScrollTotal, optionStartIndex + (!optionStartIndex || this.optionsScrollCursor + 8 >= this.optionsScrollTotal ? 8 : 7)); + let optionEndIndex = Math.min( + this.optionsScrollTotal, + optionStartIndex + (!optionStartIndex || this.optionsScrollCursor + 8 >= this.optionsScrollTotal ? 8 : 7), + ); this.optionsScroll = this.optionsScrollTotal > 9; @@ -977,7 +1174,11 @@ export default class PartyUiHandler extends MessageUiHandler { optionName = "↑"; } else if (option === PartyOption.SCROLL_DOWN) { optionName = "↓"; - } else if ((this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) || option === PartyOption.CANCEL) { + } else if ( + (this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && + (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) || + option === PartyOption.CANCEL + ) { switch (option) { case PartyOption.MOVE_1: case PartyOption.MOVE_2: @@ -1010,7 +1211,10 @@ export default class PartyUiHandler extends MessageUiHandler { } else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) { const move = learnableLevelMoves[option]; optionName = allMoves[move].name; - altText = !pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move); + altText = !pokemon + .getSpeciesForm() + .getLevelMoves() + .find(plm => plm[1] === move); } else if (option === PartyOption.ALL) { optionName = i18next.t("partyUiHandler:ALL"); } else { @@ -1028,7 +1232,13 @@ export default class PartyUiHandler extends MessageUiHandler { /** For every item that has stack bigger than 1, display the current quantity selection */ const itemModifier = itemModifiers[option]; - if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && this.transferQuantitiesMax[option] > 1 && !this.transferMode && itemModifier !== undefined && itemModifier.type.name === optionName) { + if ( + this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && + this.transferQuantitiesMax[option] > 1 && + !this.transferMode && + itemModifier !== undefined && + itemModifier.type.name === optionName + ) { let amountText = ` (${this.transferQuantities[option]})`; /** If the amount held is the maximum, display the count in red */ @@ -1076,68 +1286,103 @@ export default class PartyUiHandler extends MessageUiHandler { } doRelease(slotIndex: number): void { - this.showText(this.getReleaseMessage(getPokemonNameWithAffix(globalScene.getPlayerParty()[slotIndex])), null, () => { - this.clearPartySlots(); - globalScene.removePartyMemberModifiers(slotIndex); - const releasedPokemon = globalScene.getPlayerParty().splice(slotIndex, 1)[0]; - releasedPokemon.destroy(); - this.populatePartySlots(); - if (this.cursor >= globalScene.getPlayerParty().length) { - this.setCursor(this.cursor - 1); - } - if (this.partyUiMode === PartyUiMode.RELEASE) { - const selectCallback = this.selectCallback; - this.selectCallback = null; - selectCallback && selectCallback(this.cursor, PartyOption.RELEASE); - } - this.showText("", 0); - }, null, true); + this.showText( + this.getReleaseMessage(getPokemonNameWithAffix(globalScene.getPlayerParty()[slotIndex])), + null, + () => { + this.clearPartySlots(); + globalScene.removePartyMemberModifiers(slotIndex); + const releasedPokemon = globalScene.getPlayerParty().splice(slotIndex, 1)[0]; + releasedPokemon.destroy(); + this.populatePartySlots(); + if (this.cursor >= globalScene.getPlayerParty().length) { + this.setCursor(this.cursor - 1); + } + if (this.partyUiMode === PartyUiMode.RELEASE) { + const selectCallback = this.selectCallback; + this.selectCallback = null; + selectCallback?.(this.cursor, PartyOption.RELEASE); + } + this.showText("", 0); + }, + null, + true, + ); } getReleaseMessage(pokemonName: string): string { const rand = Utils.randInt(128); if (rand < 20) { return i18next.t("partyUiHandler:goodbye", { pokemonName: pokemonName }); - } else if (rand < 40) { - return i18next.t("partyUiHandler:byebye", { pokemonName: pokemonName }); - } else if (rand < 60) { - return i18next.t("partyUiHandler:farewell", { pokemonName: pokemonName }); - } else if (rand < 80) { - return i18next.t("partyUiHandler:soLong", { pokemonName: pokemonName }); - } else if (rand < 100) { - return i18next.t("partyUiHandler:thisIsWhereWePart", { pokemonName: pokemonName }); - } else if (rand < 108) { - return i18next.t("partyUiHandler:illMissYou", { pokemonName: pokemonName }); - } else if (rand < 116) { - return i18next.t("partyUiHandler:illNeverForgetYou", { pokemonName: pokemonName }); - } else if (rand < 124) { - return i18next.t("partyUiHandler:untilWeMeetAgain", { pokemonName: pokemonName }); - } else if (rand < 127) { - return i18next.t("partyUiHandler:sayonara", { pokemonName: pokemonName }); - } else { - return i18next.t("partyUiHandler:smellYaLater", { pokemonName: pokemonName }); } + if (rand < 40) { + return i18next.t("partyUiHandler:byebye", { pokemonName: pokemonName }); + } + if (rand < 60) { + return i18next.t("partyUiHandler:farewell", { pokemonName: pokemonName }); + } + if (rand < 80) { + return i18next.t("partyUiHandler:soLong", { pokemonName: pokemonName }); + } + if (rand < 100) { + return i18next.t("partyUiHandler:thisIsWhereWePart", { + pokemonName: pokemonName, + }); + } + if (rand < 108) { + return i18next.t("partyUiHandler:illMissYou", { + pokemonName: pokemonName, + }); + } + if (rand < 116) { + return i18next.t("partyUiHandler:illNeverForgetYou", { + pokemonName: pokemonName, + }); + } + if (rand < 124) { + return i18next.t("partyUiHandler:untilWeMeetAgain", { + pokemonName: pokemonName, + }); + } + if (rand < 127) { + return i18next.t("partyUiHandler:sayonara", { pokemonName: pokemonName }); + } + return i18next.t("partyUiHandler:smellYaLater", { + pokemonName: pokemonName, + }); } getFormChangeItemsModifiers(pokemon: Pokemon) { - let formChangeItemModifiers = globalScene.findModifiers(m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === pokemon.id) as PokemonFormChangeItemModifier[]; - const ultraNecrozmaModifiers = formChangeItemModifiers.filter(m => m.active && m.formChangeItem === FormChangeItem.ULTRANECROZIUM_Z); + let formChangeItemModifiers = globalScene.findModifiers( + m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === pokemon.id, + ) as PokemonFormChangeItemModifier[]; + const ultraNecrozmaModifiers = formChangeItemModifiers.filter( + m => m.active && m.formChangeItem === FormChangeItem.ULTRANECROZIUM_Z, + ); if (ultraNecrozmaModifiers.length > 0) { // ULTRANECROZIUM_Z is active and deactivating it should be the only option return ultraNecrozmaModifiers; } if (formChangeItemModifiers.find(m => m.active)) { // a form is currently active. the user has to disable the form or activate ULTRANECROZIUM_Z - formChangeItemModifiers = formChangeItemModifiers.filter(m => m.active || m.formChangeItem === FormChangeItem.ULTRANECROZIUM_Z); + formChangeItemModifiers = formChangeItemModifiers.filter( + m => m.active || m.formChangeItem === FormChangeItem.ULTRANECROZIUM_Z, + ); } else if (pokemon.species.speciesId === Species.NECROZMA) { // no form is currently active. the user has to activate some form, except ULTRANECROZIUM_Z - formChangeItemModifiers = formChangeItemModifiers.filter(m => m.formChangeItem !== FormChangeItem.ULTRANECROZIUM_Z); + formChangeItemModifiers = formChangeItemModifiers.filter( + m => m.formChangeItem !== FormChangeItem.ULTRANECROZIUM_Z, + ); } return formChangeItemModifiers; } getOptionsCursorWithScroll(): number { - return this.optionsCursor + this.optionsScrollCursor + (this.options && this.options[0] === PartyOption.SCROLL_UP ? -1 : 0); + return ( + this.optionsCursor + + this.optionsScrollCursor + + (this.options && this.options[0] === PartyOption.SCROLL_UP ? -1 : 0) + ); } clearOptions() { @@ -1193,10 +1438,22 @@ class PartySlot extends Phaser.GameObjects.Container { private pokemonIcon: Phaser.GameObjects.Container; private iconAnimHandler: PokemonIconAnimHandler; - constructor(slotIndex: number, pokemon: PlayerPokemon, iconAnimHandler: PokemonIconAnimHandler, partyUiMode: PartyUiMode, tmMoveId: Moves) { - super(globalScene, slotIndex >= globalScene.currentBattle.getBattlerCount() ? 230.5 : 64, - slotIndex >= globalScene.currentBattle.getBattlerCount() ? -184 + (globalScene.currentBattle.double ? -40 : 0) - + (28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex : -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64); + constructor( + slotIndex: number, + pokemon: PlayerPokemon, + iconAnimHandler: PokemonIconAnimHandler, + partyUiMode: PartyUiMode, + tmMoveId: Moves, + ) { + super( + globalScene, + slotIndex >= globalScene.currentBattle.getBattlerCount() ? 230.5 : 64, + slotIndex >= globalScene.currentBattle.getBattlerCount() + ? -184 + + (globalScene.currentBattle.double ? -40 : 0) + + (28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex + : -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64, + ); this.slotIndex = slotIndex; this.pokemon = pokemon; @@ -1210,7 +1467,6 @@ class PartySlot extends Phaser.GameObjects.Container { } setup(partyUiMode: PartyUiMode, tmMoveId: Moves) { - const currentLanguage = i18next.resolvedLanguage ?? "en"; const offsetJa = currentLanguage === "ja"; @@ -1223,7 +1479,11 @@ class PartySlot extends Phaser.GameObjects.Container { this.add(slotBg); - const slotPb = globalScene.add.sprite(this.slotIndex >= battlerCount ? -85.5 : -51, this.slotIndex >= battlerCount ? 0 : -20.5, "party_pb"); + const slotPb = globalScene.add.sprite( + this.slotIndex >= battlerCount ? -85.5 : -51, + this.slotIndex >= battlerCount ? 0 : -20.5, + "party_pb", + ); this.slotPb = slotPb; this.add(slotPb); @@ -1243,7 +1503,7 @@ class PartySlot extends Phaser.GameObjects.Container { const nameSizeTest = addTextObject(0, 0, displayName, TextStyle.PARTY); nameTextWidth = nameSizeTest.displayWidth; - while (nameTextWidth > (this.slotIndex >= battlerCount ? 52 : (76 - (this.pokemon.fusionSpecies ? 8 : 0)))) { + while (nameTextWidth > (this.slotIndex >= battlerCount ? 52 : 76 - (this.pokemon.fusionSpecies ? 8 : 0))) { displayName = `${displayName.slice(0, displayName.endsWith(".") ? -2 : -1).trimEnd()}.`; nameSizeTest.setText(displayName); nameTextWidth = nameSizeTest.displayWidth; @@ -1252,18 +1512,31 @@ class PartySlot extends Phaser.GameObjects.Container { nameSizeTest.destroy(); this.slotName = addTextObject(0, 0, displayName, TextStyle.PARTY); - this.slotName.setPositionRelative(slotBg, this.slotIndex >= battlerCount ? 21 : 24, (this.slotIndex >= battlerCount ? 2 : 10) + (offsetJa ? 2 : 0)); + this.slotName.setPositionRelative( + slotBg, + this.slotIndex >= battlerCount ? 21 : 24, + (this.slotIndex >= battlerCount ? 2 : 10) + (offsetJa ? 2 : 0), + ); this.slotName.setOrigin(0, 0); const slotLevelLabel = globalScene.add.image(0, 0, "party_slot_overlay_lv"); - slotLevelLabel.setPositionRelative(slotBg, (this.slotIndex >= battlerCount ? 21 : 24) + 8, (this.slotIndex >= battlerCount ? 2 : 10) + 12); + slotLevelLabel.setPositionRelative( + slotBg, + (this.slotIndex >= battlerCount ? 21 : 24) + 8, + (this.slotIndex >= battlerCount ? 2 : 10) + 12, + ); slotLevelLabel.setOrigin(0, 0); - const slotLevelText = addTextObject(0, 0, this.pokemon.level.toString(), this.pokemon.level < globalScene.getMaxExpLevel() ? TextStyle.PARTY : TextStyle.PARTY_RED); + const slotLevelText = addTextObject( + 0, + 0, + this.pokemon.level.toString(), + this.pokemon.level < globalScene.getMaxExpLevel() ? TextStyle.PARTY : TextStyle.PARTY_RED, + ); slotLevelText.setPositionRelative(slotLevelLabel, 9, offsetJa ? 1.5 : 0); slotLevelText.setOrigin(0, 0.25); - slotInfoContainer.add([ this.slotName, slotLevelLabel, slotLevelText ]); + slotInfoContainer.add([this.slotName, slotLevelLabel, slotLevelText]); const genderSymbol = getGenderSymbol(this.pokemon.getGender(true)); @@ -1324,29 +1597,46 @@ class PartySlot extends Phaser.GameObjects.Container { } this.slotHpBar = globalScene.add.image(0, 0, "party_slot_hp_bar"); - this.slotHpBar.setPositionRelative(slotBg, this.slotIndex >= battlerCount ? 72 : 8, this.slotIndex >= battlerCount ? 6 : 31); + this.slotHpBar.setPositionRelative( + slotBg, + this.slotIndex >= battlerCount ? 72 : 8, + this.slotIndex >= battlerCount ? 6 : 31, + ); this.slotHpBar.setOrigin(0, 0); this.slotHpBar.setVisible(false); const hpRatio = this.pokemon.getHpRatio(); - this.slotHpOverlay = globalScene.add.sprite(0, 0, "party_slot_hp_overlay", hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low"); + this.slotHpOverlay = globalScene.add.sprite( + 0, + 0, + "party_slot_hp_overlay", + hpRatio > 0.5 ? "high" : hpRatio > 0.25 ? "medium" : "low", + ); this.slotHpOverlay.setPositionRelative(this.slotHpBar, 16, 2); this.slotHpOverlay.setOrigin(0, 0); this.slotHpOverlay.setScale(hpRatio, 1); this.slotHpOverlay.setVisible(false); this.slotHpText = addTextObject(0, 0, `${this.pokemon.hp}/${this.pokemon.getMaxHp()}`, TextStyle.PARTY); - this.slotHpText.setPositionRelative(this.slotHpBar, this.slotHpBar.width - 3, this.slotHpBar.height - 2 + (offsetJa ? 2 : 0)); + this.slotHpText.setPositionRelative( + this.slotHpBar, + this.slotHpBar.width - 3, + this.slotHpBar.height - 2 + (offsetJa ? 2 : 0), + ); this.slotHpText.setOrigin(1, 0); this.slotHpText.setVisible(false); this.slotDescriptionLabel = addTextObject(0, 0, "", TextStyle.MESSAGE); - this.slotDescriptionLabel.setPositionRelative(slotBg, this.slotIndex >= battlerCount ? 94 : 32, this.slotIndex >= battlerCount ? 16 : 46); + this.slotDescriptionLabel.setPositionRelative( + slotBg, + this.slotIndex >= battlerCount ? 94 : 32, + this.slotIndex >= battlerCount ? 16 : 46, + ); this.slotDescriptionLabel.setOrigin(0, 1); this.slotDescriptionLabel.setVisible(false); - slotInfoContainer.add([ this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel ]); + slotInfoContainer.add([this.slotHpBar, this.slotHpOverlay, this.slotHpText, this.slotDescriptionLabel]); if (partyUiMode !== PartyUiMode.TM_MODIFIER) { this.slotDescriptionLabel.setVisible(false); @@ -1369,7 +1659,6 @@ class PartySlot extends Phaser.GameObjects.Container { this.slotDescriptionLabel.setText(slotTmText); this.slotDescriptionLabel.setVisible(true); - } } @@ -1408,8 +1697,10 @@ class PartySlot extends Phaser.GameObjects.Container { private updateSlotTexture(): void { const battlerCount = globalScene.currentBattle.getBattlerCount(); - this.slotBg.setTexture(`party_slot${this.slotIndex >= battlerCount ? "" : "_main"}`, - `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`); + this.slotBg.setTexture( + `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}`, + `party_slot${this.slotIndex >= battlerCount ? "" : "_main"}${this.transfer ? "_swap" : this.pokemon.hp ? "" : "_fnt"}${this.selected ? "_sel" : ""}`, + ); } } diff --git a/src/ui/pokeball-tray.ts b/src/ui/pokeball-tray.ts index 0c913d195a9..0bf47699cdb 100644 --- a/src/ui/pokeball-tray.ts +++ b/src/ui/pokeball-tray.ts @@ -10,17 +10,39 @@ export default class PokeballTray extends Phaser.GameObjects.Container { public shown: boolean; constructor(player: boolean) { - super(globalScene, player ? (globalScene.game.canvas.width / 6) : 0, player ? -72 : -144); + super(globalScene, player ? globalScene.game.canvas.width / 6 : 0, player ? -72 : -144); this.player = player; } setup(): void { - this.bg = globalScene.add.nineslice(0, 0, `pb_tray_overlay_${this.player ? "player" : "enemy"}`, undefined, 104, 4, 48, 8, 0, 0); + this.bg = globalScene.add.nineslice( + 0, + 0, + `pb_tray_overlay_${this.player ? "player" : "enemy"}`, + undefined, + 104, + 4, + 48, + 8, + 0, + 0, + ); this.bg.setOrigin(this.player ? 1 : 0, 0); this.add(this.bg); - this.balls = new Array(6).fill(null).map((_, i) => globalScene.add.sprite((this.player ? -83 : 76) + (globalScene.game.canvas.width / 6) * (this.player ? -1 : 1) + 10 * i * (this.player ? 1 : -1), -8, "pb_tray_ball", "empty")); + this.balls = new Array(6) + .fill(null) + .map((_, i) => + globalScene.add.sprite( + (this.player ? -83 : 76) + + (globalScene.game.canvas.width / 6) * (this.player ? -1 : 1) + + 10 * i * (this.player ? 1 : -1), + -8, + "pb_tray_ball", + "empty", + ), + ); for (const ball of this.balls) { ball.setOrigin(0, 0); @@ -71,10 +93,10 @@ export default class PokeballTray extends Phaser.GameObjects.Container { x: `${this.player ? "-" : "+"}=104`, duration: b * 100, ease: "Sine.easeIn", - onComplete: () => globalScene.playSound(`se/${(b < party.length ? "pb_tray_ball" : "pb_tray_empty")}`) + onComplete: () => globalScene.playSound(`se/${b < party.length ? "pb_tray_ball" : "pb_tray_empty"}`), }); }); - } + }, }); this.setVisible(true); @@ -96,7 +118,7 @@ export default class PokeballTray extends Phaser.GameObjects.Container { x: `${this.player ? "-" : "+"}=${globalScene.game.canvas.width / 6}`, duration: 250, delay: b * 100, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); }); @@ -105,7 +127,7 @@ export default class PokeballTray extends Phaser.GameObjects.Container { width: 144, alpha: 0, duration: 500, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); globalScene.time.delayedCall(850, () => { diff --git a/src/ui/pokedex-info-overlay.ts b/src/ui/pokedex-info-overlay.ts index fe0b47b57e0..7dfa3745cb7 100644 --- a/src/ui/pokedex-info-overlay.ts +++ b/src/ui/pokedex-info-overlay.ts @@ -6,16 +6,16 @@ import i18next from "i18next"; import { globalScene } from "#app/global-scene"; export interface PokedexInfoOverlaySettings { - delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. - scale?:number; // scale the box? A scale of 0.5 is recommended - //location and width of the component; unaffected by scaling - x?: number; - y?: number; - /** Default is always half the screen, regardless of scale */ - width?: number; - /** Determines whether to display the small secondary box */ - hideEffectBox?: boolean; - hideBg?: boolean; + delayVisibility?: boolean; // if true, showing the overlay will only set it to active and populate the fields and the handler using this field has to manually call setVisible later. + scale?: number; // scale the box? A scale of 0.5 is recommended + //location and width of the component; unaffected by scaling + x?: number; + y?: number; + /** Default is always half the screen, regardless of scale */ + width?: number; + /** Determines whether to display the small secondary box */ + hideEffectBox?: boolean; + hideBg?: boolean; } const DESC_HEIGHT = 48; @@ -23,10 +23,10 @@ const BORDER = 8; const GLOBAL_SCALE = 6; export default class PokedexInfoOverlay extends Phaser.GameObjects.Container implements InfoToggle { - public active: boolean = false; + public active = false; private desc: Phaser.GameObjects.Text; - private descScroll : Phaser.Tweens.Tween | null = null; + private descScroll: Phaser.Tweens.Tween | null = null; private descBg: Phaser.GameObjects.NineSlice; @@ -52,7 +52,9 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp this.add(this.descBg); // set up the description; wordWrap uses true pixels, unaffected by any scaling, while other values are affected - this.desc = addTextObject(BORDER, BORDER - 2, "", TextStyle.BATTLE_INFO, { wordWrap: { width: (this.width - (BORDER - 2) * 2) * GLOBAL_SCALE }}); + this.desc = addTextObject(BORDER, BORDER - 2, "", TextStyle.BATTLE_INFO, { + wordWrap: { width: (this.width - (BORDER - 2) * 2) * GLOBAL_SCALE }, + }); this.desc.setLineSpacing(i18next.resolvedLanguage === "ja" ? 25 : 5); // limit the text rendering, required for scrolling later on @@ -67,10 +69,13 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp } this.textMaskRect = globalScene.make.graphics(); - this.textMaskRect.fillStyle(0xFF0000); + this.textMaskRect.fillStyle(0xff0000); this.textMaskRect.fillRect( - this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginY + (BORDER - 2) * this.scale, - this.width - (BORDER * 2) * this.scale, (DESC_HEIGHT - (BORDER - 2) * 2) * this.scale); + this.maskPointOriginX + BORDER * this.scale, + this.maskPointOriginY + (BORDER - 2) * this.scale, + this.width - BORDER * 2 * this.scale, + (DESC_HEIGHT - (BORDER - 2) * 2) * this.scale, + ); this.textMaskRect.setScale(6); const textMask = this.createGeometryMask(this.textMaskRect); @@ -86,7 +91,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp } // show this component with infos for the specific move - show(text: string):boolean { + show(text: string): boolean { if (!globalScene.enableMoveInfo) { return false; // move infos have been disabled // TODO:: is `false` correct? i used to be `undeefined` } @@ -101,16 +106,16 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp } // determine if we need to add new scrolling effects - const lineCount = Math.floor(this.desc.displayHeight * (96 / 72) / 14.83); + const lineCount = Math.floor((this.desc.displayHeight * (96 / 72)) / 14.83); - const newHeight = lineCount >= 3 ? 48 : (lineCount === 2 ? 36 : 24); + const newHeight = lineCount >= 3 ? 48 : lineCount === 2 ? 36 : 24; this.textMaskRect.clear(); - this.textMaskRect.fillStyle(0xFF0000); + this.textMaskRect.fillStyle(0xff0000); this.textMaskRect.fillRect( this.maskPointOriginX + BORDER * this.scale, this.maskPointOriginY + (BORDER - 2) * this.scale + (48 - newHeight), - this.width - (BORDER * 2) * this.scale, - (newHeight - (BORDER - 2) * 2) * this.scale + this.width - BORDER * 2 * this.scale, + (newHeight - (BORDER - 2) * 2) * this.scale, ); const updatedMask = this.createGeometryMask(this.textMaskRect); this.desc.setMask(updatedMask); @@ -127,7 +132,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp loop: -1, hold: Utils.fixedInt(2000), duration: Utils.fixedInt((lineCount - 3) * 2000), - y: `-=${14.83 * (72 / 96) * (lineCount - 3)}` + y: `-=${14.83 * (72 / 96) * (lineCount - 3)}`, }); } @@ -151,7 +156,7 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp targets: this.desc, duration: Utils.fixedInt(125), ease: "Sine.easeInOut", - alpha: visible ? 1 : 0 + alpha: visible ? 1 : 0, }); if (!visible) { this.setVisible(false); @@ -163,12 +168,12 @@ export default class PokedexInfoOverlay extends Phaser.GameObjects.Container imp } // width of this element - static getWidth(scale:number):number { + static getWidth(_scale: number): number { return globalScene.game.canvas.width / GLOBAL_SCALE / 2; } // height of this element - static getHeight(scale:number, onSide?: boolean):number { + static getHeight(scale: number, _onSide?: boolean): number { return DESC_HEIGHT * scale; } } diff --git a/src/ui/pokedex-mon-container.ts b/src/ui/pokedex-mon-container.ts index 1bcfafc0766..e61da86e95e 100644 --- a/src/ui/pokedex-mon-container.ts +++ b/src/ui/pokedex-mon-container.ts @@ -4,12 +4,11 @@ import { isNullOrUndefined } from "#app/utils"; import type PokemonSpecies from "../data/pokemon-species"; import { addTextObject, TextStyle } from "./text"; - interface SpeciesDetails { - shiny?: boolean, - formIndex?: number - female?: boolean, - variant?: Variant + shiny?: boolean; + formIndex?: number; + female?: boolean; + variant?: Variant; } export class PokedexMonContainer extends Phaser.GameObjects.Container { @@ -31,7 +30,7 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container { public passive2Icon: Phaser.GameObjects.Image; public passive1OverlayIcon: Phaser.GameObjects.Image; public passive2OverlayIcon: Phaser.GameObjects.Image; - public cost: number = 0; + public cost = 0; constructor(species: PokemonSpecies, options: SpeciesDetails = {}) { super(globalScene, 0, 0); @@ -57,7 +56,9 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container { this.add(this.shinyIcons); // value label - const label = addTextObject(1, 2, "0", TextStyle.WINDOW, { fontSize: "32px" }); + const label = addTextObject(1, 2, "0", TextStyle.WINDOW, { + fontSize: "32px", + }); label.setShadowOffset(2, 2); label.setOrigin(0, 0); label.setVisible(false); @@ -136,7 +137,6 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container { this.add(tmMove2Icon); this.tmMove2Icon = tmMove2Icon; - // passive icons const passive1Icon = globalScene.add.image(3, 3, "candy"); passive1Icon.setOrigin(0, 0); @@ -169,7 +169,6 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container { } setSpecies(species: PokemonSpecies, options: SpeciesDetails = {}) { - this.species = species; const { shiny, formIndex, female, variant } = options; @@ -196,10 +195,16 @@ export class PokedexMonContainer extends Phaser.GameObjects.Container { } // icon - this.icon = globalScene.add.sprite(-2, 2, species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant)); + this.icon = globalScene.add.sprite( + -2, + 2, + species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant), + ); this.icon.setScale(0.5); this.icon.setOrigin(0, 0); - this.icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant)); + this.icon.setFrame( + species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant), + ); this.checkIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant); this.add(this.icon); } diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index 6b6c2c89933..74921f13683 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -21,8 +21,8 @@ import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/bal import { starterPassiveAbilities } from "#app/data/balance/passives"; import { PokemonType } from "#enums/pokemon-type"; import { GameModes } from "#app/game-mode"; -import type { DexEntry, StarterAttributes } from "#app/system/game-data"; -import { AbilityAttr, DexAttr } from "#app/system/game-data"; +import type { DexEntry, StarterAttributes } from "#app/system/game-data"; +import { AbilityAttr, DexAttr } from "#app/system/game-data"; 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"; @@ -42,8 +42,20 @@ import type { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { Button } from "#enums/buttons"; import { EggSourceType } from "#enums/egg-source-types"; -import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; -import { BooleanHolder, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, rgbHexToRgba, toReadableString } from "#app/utils"; +import { + getPassiveCandyCount, + getValueReductionCandyCounts, + getSameSpeciesEggCandyCounts, +} from "#app/data/balance/starters"; +import { + BooleanHolder, + getLocalizedSpriteKey, + isNullOrUndefined, + NumberHolder, + padInt, + rgbHexToRgba, + toReadableString, +} from "#app/utils"; import type { Nature } from "#enums/nature"; import * as Utils from "../utils"; import { speciesTmMoves } from "#app/data/balance/tms"; @@ -55,61 +67,60 @@ import type { Abilities } from "#app/enums/abilities"; import { BaseStatsOverlay } from "#app/ui/base-stats-overlay"; import { globalScene } from "#app/global-scene"; - interface LanguageSetting { - starterInfoTextSize: string, - instructionTextSize: string, - starterInfoXPos?: number, - starterInfoYOffset?: number + starterInfoTextSize: string; + instructionTextSize: string; + starterInfoXPos?: number; + starterInfoYOffset?: number; } const languageSettings: { [key: string]: LanguageSetting } = { - "en":{ + en: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "de":{ + de: { starterInfoTextSize: "48px", instructionTextSize: "35px", starterInfoXPos: 33, }, - "es-ES":{ + "es-ES": { starterInfoTextSize: "56px", instructionTextSize: "35px", }, - "fr":{ + fr: { starterInfoTextSize: "54px", instructionTextSize: "38px", }, - "it":{ + it: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "pt_BR":{ + pt_BR: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoXPos: 33, }, - "zh":{ + zh: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoYOffset: 1, starterInfoXPos: 24, }, - "pt":{ + pt: { starterInfoTextSize: "48px", instructionTextSize: "42px", starterInfoXPos: 33, }, - "ko":{ + ko: { starterInfoTextSize: "52px", instructionTextSize: "38px", }, - "ja":{ + ja: { starterInfoTextSize: "51px", instructionTextSize: "38px", }, - "ca-ES":{ + "ca-ES": { starterInfoTextSize: "56px", instructionTextSize: "38px", }, @@ -121,10 +132,10 @@ const valueReductionMax = 2; const speciesContainerX = 109; interface SpeciesDetails { - shiny?: boolean, - formIndex?: number - female?: boolean, - variant?: number, + shiny?: boolean; + formIndex?: number; + female?: boolean; + variant?: number; } enum MenuOptions { @@ -136,10 +147,9 @@ enum MenuOptions { BIOMES, NATURES, TOGGLE_IVS, - EVOLUTIONS + EVOLUTIONS, } - export default class PokedexPageUiHandler extends MessageUiHandler { private starterSelectContainer: Phaser.GameObjects.Container; private shinyOverlay: Phaser.GameObjects.Image; @@ -162,7 +172,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container; private pokemonCaughtCountText: Phaser.GameObjects.Text; private pokemonFormText: Phaser.GameObjects.Text; - private pokemonHatchedIcon : Phaser.GameObjects.Sprite; + private pokemonHatchedIcon: Phaser.GameObjects.Sprite; private pokemonHatchedCountText: Phaser.GameObjects.Text; private pokemonShinyIcons: Phaser.GameObjects.Sprite[]; @@ -232,17 +242,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler { private starterAttributes: StarterAttributes; private savedStarterAttributes: StarterAttributes; - protected blockInput: boolean = false; - protected blockInputOverlay: boolean = false; + protected blockInput = false; + protected blockInputOverlay = false; - private showBackSprite: boolean = false; + private showBackSprite = false; // Menu private menuContainer: Phaser.GameObjects.Container; private menuBg: Phaser.GameObjects.NineSlice; protected optionSelectText: Phaser.GameObjects.Text; private menuOptions: MenuOptions[]; - protected scale: number = 0.1666666667; + protected scale = 0.1666666667; private menuDescriptions: string[]; private isFormGender: boolean; private filteredIndices: Species[] | null = null; @@ -266,7 +276,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterSelectContainer.setVisible(false); ui.add(this.starterSelectContainer); - const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860); + const bgColor = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0x006860, + ); bgColor.setOrigin(0, 0); this.starterSelectContainer.add(bgColor); @@ -287,7 +303,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonNameText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNameText); - this.pokemonGrowthRateLabelText = addTextObject(8, 106, i18next.t("pokedexUiHandler:growthRate"), TextStyle.SUMMARY_ALT, { fontSize: "36px" }); + this.pokemonGrowthRateLabelText = addTextObject( + 8, + 106, + i18next.t("pokedexUiHandler:growthRate"), + TextStyle.SUMMARY_ALT, + { fontSize: "36px" }, + ); this.pokemonGrowthRateLabelText.setOrigin(0, 0); this.pokemonGrowthRateLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonGrowthRateLabelText); @@ -300,7 +322,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonGenderText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonGenderText); - this.pokemonUncaughtText = addTextObject(6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.WINDOW, { fontSize: "56px" }); + this.pokemonUncaughtText = addTextObject(6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.WINDOW, { + fontSize: "56px", + }); this.pokemonUncaughtText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonUncaughtText); @@ -318,7 +342,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterSelectContainer.add(starterBoxContainer); this.pokemonSprite = globalScene.add.sprite(53, 63, "pkmn__sub"); - this.pokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + this.pokemonSprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); this.starterSelectContainer.add(this.pokemonSprite); this.type1Icon = globalScene.add.sprite(8, 98, getLocalizedSpriteKey("types")); @@ -331,11 +358,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.type2Icon.setOrigin(0, 0); this.starterSelectContainer.add(this.type2Icon); - this.pokemonLuckLabelText = addTextObject(8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { fontSize: "56px" }); + this.pokemonLuckLabelText = addTextObject(8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { + fontSize: "56px", + }); this.pokemonLuckLabelText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonLuckLabelText); - this.pokemonLuckText = addTextObject(8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { fontSize: "56px" }); + this.pokemonLuckText = addTextObject(8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { + fontSize: "56px", + }); this.pokemonLuckText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonLuckText); @@ -356,7 +387,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonCandyDarknessOverlay.setScale(0.5); this.pokemonCandyDarknessOverlay.setOrigin(0, 0); this.pokemonCandyDarknessOverlay.setTint(0x000000); - this.pokemonCandyDarknessOverlay.setAlpha(0.50); + this.pokemonCandyDarknessOverlay.setAlpha(0.5); this.pokemonCandyContainer.add(this.pokemonCandyDarknessOverlay); this.pokemonCandyCountText = addTextObject(9.5, 0, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" }); @@ -366,7 +397,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonCandyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, 30, 20), Phaser.Geom.Rectangle.Contains); this.starterSelectContainer.add(this.pokemonCandyContainer); - this.pokemonFormText = addTextObject(6, 42, "Form", TextStyle.WINDOW_ALT, { fontSize: "42px" }); + this.pokemonFormText = addTextObject(6, 42, "Form", TextStyle.WINDOW_ALT, { + fontSize: "42px", + }); this.pokemonFormText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonFormText); @@ -410,48 +443,110 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.instructionsContainer.setVisible(true); this.starterSelectContainer.add(this.instructionsContainer); - this.candyUpgradeIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "C.png"); + this.candyUpgradeIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "C.png", + ); this.candyUpgradeIconElement.setName("sprite-candyUpgrade-icon-element"); this.candyUpgradeIconElement.setScale(0.675); this.candyUpgradeIconElement.setOrigin(0.0, 0.0); - this.candyUpgradeLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:candyUpgrade"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.candyUpgradeLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("pokedexUiHandler:candyUpgrade"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.candyUpgradeLabel.setName("text-candyUpgrade-label"); // instruction rows that will be pushed into the container dynamically based on need // creating new sprites since they will be added to the scene later - this.shinyIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "R.png"); + this.shinyIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "R.png", + ); this.shinyIconElement.setName("sprite-shiny-icon-element"); this.shinyIconElement.setScale(0.675); this.shinyIconElement.setOrigin(0.0, 0.0); - this.shinyLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleShiny"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.shinyLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("pokedexUiHandler:cycleShiny"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.shinyLabel.setName("text-shiny-label"); - this.formIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "F.png"); + this.formIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "F.png", + ); this.formIconElement.setName("sprite-form-icon-element"); this.formIconElement.setScale(0.675); this.formIconElement.setOrigin(0.0, 0.0); - this.formLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleForm"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.formLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("pokedexUiHandler:cycleForm"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.formLabel.setName("text-form-label"); - this.genderIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "G.png"); + this.genderIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "G.png", + ); this.genderIconElement.setName("sprite-gender-icon-element"); this.genderIconElement.setScale(0.675); this.genderIconElement.setOrigin(0.0, 0.0); - this.genderLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleGender"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.genderLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("pokedexUiHandler:cycleGender"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.genderLabel.setName("text-gender-label"); - this.variantIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "V.png"); + this.variantIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "V.png", + ); this.variantIconElement.setName("sprite-variant-icon-element"); this.variantIconElement.setScale(0.675); this.variantIconElement.setOrigin(0.0, 0.0); - this.variantLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("pokedexUiHandler:cycleVariant"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.variantLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("pokedexUiHandler:cycleVariant"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.variantLabel.setName("text-variant-label"); this.showBackSpriteIconElement = new Phaser.GameObjects.Sprite(globalScene, 50, 7, "keyboard", "E.png"); this.showBackSpriteIconElement.setName("show-backSprite-icon-element"); this.showBackSpriteIconElement.setScale(0.675); this.showBackSpriteIconElement.setOrigin(0.0, 0.0); - this.showBackSpriteLabel = addTextObject(60, 7, i18next.t("pokedexUiHandler:showBackSprite"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.showBackSpriteLabel = addTextObject(60, 7, i18next.t("pokedexUiHandler:showBackSprite"), TextStyle.PARTY, { + fontSize: instructionTextSize, + }); this.showBackSpriteLabel.setName("show-backSprite-label"); this.starterSelectContainer.add(this.showBackSpriteIconElement); this.starterSelectContainer.add(this.showBackSpriteLabel); @@ -485,17 +580,25 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterSelectContainer.add(this.statsContainer); - // Adding menu container this.menuContainer = globalScene.add.container(-130, 0); this.menuContainer.setName("menu"); - this.menuContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.menuContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); this.menuContainer.setVisible(false); - this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => parseInt(MenuOptions[m]) as MenuOptions); + this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => Number.parseInt(MenuOptions[m]) as MenuOptions); - this.optionSelectText = addTextObject(0, 0, this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`).join("\n"), TextStyle.WINDOW, { maxLines: this.menuOptions.length }); + this.optionSelectText = addTextObject( + 0, + 0, + this.menuOptions.map(o => `${i18next.t(`pokedexUiHandler:${MenuOptions[o]}`)}`).join("\n"), + TextStyle.WINDOW, + { maxLines: this.menuOptions.length }, + ); this.optionSelectText.setLineSpacing(12); this.menuDescriptions = [ @@ -507,15 +610,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { i18next.t("pokedexUiHandler:showBiomes"), i18next.t("pokedexUiHandler:showNatures"), i18next.t("pokedexUiHandler:toggleIVs"), - i18next.t("pokedexUiHandler:showEvolutions") + i18next.t("pokedexUiHandler:showEvolutions"), ]; this.scale = getTextStyleOptions(TextStyle.WINDOW, globalScene.uiTheme).scale; this.menuBg = addWindow( - (globalScene.game.canvas.width / 6 - 83), + globalScene.game.canvas.width / 6 - 83, 0, this.optionSelectText.displayWidth + 19 + 24 * this.scale, - (globalScene.game.canvas.height / 6) - 2 + globalScene.game.canvas.height / 6 - 2, ); this.menuBg.setOrigin(0, 0); @@ -529,9 +632,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterSelectContainer.add(this.menuContainer); - // adding base stats - this.baseStatsOverlay = new BaseStatsOverlay({ x: 317, y: 0, width:133 }); + this.baseStatsOverlay = new BaseStatsOverlay({ x: 317, y: 0, width: 133 }); this.menuContainer.add(this.baseStatsOverlay); this.menuContainer.bringToTop(this.baseStatsOverlay); @@ -557,19 +659,24 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } show(args: any[]): boolean { - // Allow the use of candies if we are in one of the whitelisted phases - this.canUseCandies = [ "TitlePhase", "SelectStarterPhase", "CommandPhase" ].includes(globalScene.getCurrentPhase()?.constructor.name ?? ""); + this.canUseCandies = ["TitlePhase", "SelectStarterPhase", "CommandPhase"].includes( + globalScene.getCurrentPhase()?.constructor.name ?? "", + ); if (args.length >= 1 && args[0] === "refresh") { return false; - } else { - this.species = args[0]; - this.formIndex = args[1] ?? 0; - this.savedStarterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 }; - this.filteredIndices = args[3] ?? null; - this.starterSetup(); } + this.species = args[0]; + this.formIndex = args[1] ?? 0; + this.savedStarterAttributes = args[2] ?? { + shiny: false, + female: true, + variant: 0, + form: 0, + }; + this.filteredIndices = args[3] ?? null; + this.starterSetup(); this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers this.infoOverlay.clear(); @@ -581,7 +688,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterAttributes = this.initStarterPrefs(); - this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => parseInt(MenuOptions[m]) as MenuOptions); + this.menuOptions = Utils.getEnumKeys(MenuOptions).map(m => Number.parseInt(MenuOptions[m]) as MenuOptions); this.menuContainer.setVisible(true); @@ -592,11 +699,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.setCursor(0); return true; - } starterSetup(): void { - this.evolutions = []; this.prevolutions = []; this.battleForms = []; @@ -605,7 +710,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { let formKey = this.species?.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""; this.isFormGender = formKey === "male" || formKey === "female"; - if (this.isFormGender && ((this.savedStarterAttributes.female === true && formKey === "male") || (this.savedStarterAttributes.female === false && formKey === "female"))) { + if ( + this.isFormGender && + ((this.savedStarterAttributes.female === true && formKey === "male") || + (this.savedStarterAttributes.female === false && formKey === "female")) + ) { this.formIndex = (this.formIndex + 1) % 2; formKey = this.species.forms[this.formIndex].formKey; } @@ -614,26 +723,32 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.starterId = this.getStarterSpeciesId(this.species.speciesId); - const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) ? pokemonEvolutions[species.speciesId] : []; + const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) + ? pokemonEvolutions[species.speciesId] + : []; if (species.forms.length > 0) { const form = species.forms[formIndex]; // If this form has a specific set of moves, we get them. - this.levelMoves = (formIndex > 0 && pokemonFormLevelMoves.hasOwnProperty(species.speciesId) && pokemonFormLevelMoves[species.speciesId].hasOwnProperty(formIndex)) ? pokemonFormLevelMoves[species.speciesId][formIndex] : pokemonSpeciesLevelMoves[species.speciesId]; + this.levelMoves = + formIndex > 0 && + pokemonFormLevelMoves.hasOwnProperty(species.speciesId) && + pokemonFormLevelMoves[species.speciesId].hasOwnProperty(formIndex) + ? pokemonFormLevelMoves[species.speciesId][formIndex] + : pokemonSpeciesLevelMoves[species.speciesId]; this.ability1 = form.ability1; - this.ability2 = (form.ability2 === form.ability1) ? undefined : form.ability2; - this.abilityHidden = (form.abilityHidden === form.ability1) ? undefined : form.abilityHidden; + this.ability2 = form.ability2 === form.ability1 ? undefined : form.ability2; + this.abilityHidden = form.abilityHidden === form.ability1 ? undefined : form.abilityHidden; - this.evolutions = allEvolutions.filter(e => (e.preFormKey === form.formKey || e.preFormKey === null)); + this.evolutions = allEvolutions.filter(e => e.preFormKey === form.formKey || e.preFormKey === null); this.baseStats = form.baseStats; this.baseTotal = form.baseTotal; - } else { this.levelMoves = pokemonSpeciesLevelMoves[species.speciesId]; this.ability1 = species.ability1; - this.ability2 = (species.ability2 === species.ability1) ? undefined : species.ability2; - this.abilityHidden = (species.abilityHidden === species.ability1) ? undefined : species.abilityHidden; + this.ability2 = species.ability2 === species.ability1 ? undefined : species.ability2; + this.abilityHidden = species.abilityHidden === species.ability1 ? undefined : species.abilityHidden; this.evolutions = allEvolutions; this.baseStats = species.baseStats; @@ -641,15 +756,24 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } this.eggMoves = speciesEggMoves[this.starterId] ?? []; - this.hasEggMoves = Array.from({ length: 4 }, (_, em) => (globalScene.gameData.starterData[this.starterId].eggMoves & (1 << em)) !== 0); + this.hasEggMoves = Array.from( + { length: 4 }, + (_, em) => (globalScene.gameData.starterData[this.starterId].eggMoves & (1 << em)) !== 0, + ); - this.tmMoves = speciesTmMoves[species.speciesId]?.filter(m => Array.isArray(m) ? (m[0] === formKey ? true : false ) : true) - .map(m => Array.isArray(m) ? m[1] : m).sort((a, b) => allMoves[a].name > allMoves[b].name ? 1 : -1) ?? []; + this.tmMoves = + speciesTmMoves[species.speciesId] + ?.filter(m => (Array.isArray(m) ? m[0] === formKey : true)) + .map(m => (Array.isArray(m) ? m[1] : m)) + .sort((a, b) => (allMoves[a].name > allMoves[b].name ? 1 : -1)) ?? []; - const passiveId = starterPassiveAbilities.hasOwnProperty(species.speciesId) ? species.speciesId : - starterPassiveAbilities.hasOwnProperty(this.starterId) ? this.starterId : pokemonPrevolutions[this.starterId]; + const passiveId = starterPassiveAbilities.hasOwnProperty(species.speciesId) + ? species.speciesId + : starterPassiveAbilities.hasOwnProperty(this.starterId) + ? this.starterId + : pokemonPrevolutions[this.starterId]; const passives = starterPassiveAbilities[passiveId]; - this.passive = (this.formIndex in passives) ? passives[formIndex] : passives[0]; + this.passive = this.formIndex in passives ? passives[formIndex] : passives[0]; const starterData = globalScene.gameData.starterData[this.starterId]; const abilityAttr = starterData.abilityAttr; @@ -659,41 +783,42 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const hasAbility2 = abilityAttr & AbilityAttr.ABILITY_2; const hasHiddenAbility = abilityAttr & AbilityAttr.ABILITY_HIDDEN; - this.hasAbilities = [ - hasAbility1, - hasAbility2, - hasHiddenAbility - ]; + this.hasAbilities = [hasAbility1, hasAbility2, hasHiddenAbility]; const allBiomes = catchableSpecies[species.speciesId] ?? []; this.preBiomes = this.sanitizeBiomes( - (catchableSpecies[this.starterId] ?? []) - .filter(b => !allBiomes.some(bm => (b.biome === bm.biome && b.tier === bm.tier)) && !(b.biome === Biome.TOWN)), - this.starterId); + (catchableSpecies[this.starterId] ?? []).filter( + b => !allBiomes.some(bm => b.biome === bm.biome && b.tier === bm.tier) && !(b.biome === Biome.TOWN), + ), + this.starterId, + ); this.biomes = this.sanitizeBiomes(allBiomes, species.speciesId); - const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) ? pokemonFormChanges[species.speciesId] : []; - this.battleForms = allFormChanges.filter(f => (f.preFormKey === this.species.forms[this.formIndex].formKey)); + const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) + ? pokemonFormChanges[species.speciesId] + : []; + this.battleForms = allFormChanges.filter(f => f.preFormKey === this.species.forms[this.formIndex].formKey); - const preSpecies = pokemonPrevolutions.hasOwnProperty(this.species.speciesId) ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.species.speciesId]) : null; + const preSpecies = pokemonPrevolutions.hasOwnProperty(this.species.speciesId) + ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.species.speciesId]) + : null; if (preSpecies) { - const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : []; + const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) + ? pokemonEvolutions[preSpecies.speciesId] + : []; this.prevolutions = preEvolutions.filter( - e => e.speciesId === species.speciesId && ( - ( - (e.evoFormKey === "" || e.evoFormKey === null) && - ( - // This takes care of Cosplay Pikachu (Pichu is not shown) - (preSpecies.forms.some(form => form.formKey === species.forms[formIndex]?.formKey)) || + e => + e.speciesId === species.speciesId && + (((e.evoFormKey === "" || e.evoFormKey === null) && + // This takes care of Cosplay Pikachu (Pichu is not shown) + (preSpecies.forms.some(form => form.formKey === species.forms[formIndex]?.formKey) || // This takes care of Gholdengo (preSpecies.forms.length > 0 && species.forms.length === 0) || // This takes care of everything else - (preSpecies.forms.length === 0 && (species.forms.length === 0 || species.forms[formIndex]?.formKey === "")) - ) - ) - // This takes care of Burmy, Shellos etc - || e.evoFormKey === species.forms[formIndex]?.formKey - ) + (preSpecies.forms.length === 0 && + (species.forms.length === 0 || species.forms[formIndex]?.formKey === "")))) || + // This takes care of Burmy, Shellos etc + e.evoFormKey === species.forms[formIndex]?.formKey), ); } @@ -702,7 +827,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // Function to ensure that forms appear in the appropriate biome and tod sanitizeBiomes(biomes: BiomeTierTod[], speciesId: number): BiomeTierTod[] { - if (speciesId === Species.BURMY || speciesId === Species.WORMADAM) { return biomes.filter(b => { const formIndex = (() => { @@ -717,8 +841,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { })(); return this.formIndex === formIndex; }); - - } else if (speciesId === Species.ROTOM) { + } + if (speciesId === Species.ROTOM) { return biomes.filter(b => { const formIndex = (() => { switch (b.biome) { @@ -738,8 +862,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { })(); return this.formIndex === formIndex; }); - - } else if (speciesId === Species.LYCANROC) { + } + if (speciesId === Species.LYCANROC) { return biomes.filter(b => { const formIndex = (() => { switch (b.tod[0]) { @@ -781,7 +905,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { * @returns StarterAttributes for the species */ isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: number | undefined): boolean { - if (globalScene.dexForDevs) { return true; } @@ -806,7 +929,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { * @returns StarterAttributes for the species */ initStarterPrefs(): StarterAttributes { - const starterAttributes : StarterAttributes | null = this.species ? { ...this.savedStarterAttributes } : null; + const starterAttributes: StarterAttributes | null = this.species ? { ...this.savedStarterAttributes } : null; const caughtAttr = this.isCaught(); // no preferences or Pokemon wasn't caught, return empty attribute @@ -828,9 +951,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.unlockedVariants = [ !!(hasShiny && caughtAttr & DexAttr.DEFAULT_VARIANT), !!(hasShiny && caughtAttr & DexAttr.VARIANT_2), - !!(hasShiny && caughtAttr & DexAttr.VARIANT_3) + !!(hasShiny && caughtAttr & DexAttr.VARIANT_3), ]; - if (starterAttributes.variant === undefined || isNaN(starterAttributes.variant) || starterAttributes.variant < 0) { + if ( + starterAttributes.variant === undefined || + Number.isNaN(starterAttributes.variant) || + starterAttributes.variant < 0 + ) { starterAttributes.variant = 0; } else if (!this.unlockedVariants[starterAttributes.variant]) { let highestValidIndex = -1; @@ -844,7 +971,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } if (starterAttributes.female !== undefined) { - if ((starterAttributes.female && !(caughtAttr & DexAttr.FEMALE)) || (!starterAttributes.female && !(caughtAttr & DexAttr.MALE))) { + if ( + (starterAttributes.female && !(caughtAttr & DexAttr.FEMALE)) || + (!starterAttributes.female && !(caughtAttr & DexAttr.MALE)) + ) { starterAttributes.female = !starterAttributes.female; } } else { @@ -858,7 +988,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return starterAttributes; } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number, moveToTop?: boolean) { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + moveToTop?: boolean, + ) { super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); const singleLine = text?.indexOf("\n") === -1; @@ -900,25 +1038,22 @@ export default class PokedexPageUiHandler extends MessageUiHandler { */ getStarterSpeciesId(speciesId): number { if (speciesId === Species.PIKACHU) { - if ([ 0, 1, 8 ].includes(this.formIndex)) { + if ([0, 1, 8].includes(this.formIndex)) { return Species.PICHU; - } else { - return Species.PIKACHU; } + return Species.PIKACHU; } if (speciesStarterCosts.hasOwnProperty(speciesId)) { return speciesId; - } else { - return pokemonStarters[speciesId]; } + return pokemonStarters[speciesId]; } getStarterSpecies(species): PokemonSpecies { if (speciesStarterCosts.hasOwnProperty(species.speciesId)) { return species; - } else { - return allSpecies.find(sp => sp.speciesId === pokemonStarters[species.speciesId]) ?? species; } + return allSpecies.find(sp => sp.speciesId === pokemonStarters[species.speciesId]) ?? species; } processInput(button: Button): boolean { @@ -940,7 +1075,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.baseStatsOverlay.clear(); ui.showText(""); return true; - } else if (button === Button.UP || button === Button.DOWN) { + } + if (button === Button.UP || button === Button.DOWN) { this.blockInputOverlay = false; this.baseStatsOverlay.clear(); ui.showText(""); @@ -960,26 +1096,20 @@ export default class PokedexPageUiHandler extends MessageUiHandler { success = true; } } else { - const starterData = globalScene.gameData.starterData[this.starterId]; // prepare persistent starter data to store changes const starterAttributes = this.starterAttributes; if (button === Button.ACTION) { - switch (this.cursor) { - case MenuOptions.BASE_STATS: - if (!isCaught || !isFormCaught) { error = true; } else { - this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showBaseStats"), null, () => { - this.baseStatsOverlay.show(this.baseStats, this.baseTotal); this.blockInput = false; @@ -993,55 +1123,54 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.LEVEL_MOVES: - if (!isCaught || !isFormCaught) { error = true; } else { - this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showLevelMoves"), null, () => { - this.moveInfoOverlay.show(allMoves[this.levelMoves[0][1]]); ui.setModeWithoutClear(Mode.OPTION_SELECT, { - options: this.levelMoves.map(m => { - const levelNumber = m[0] > 0 ? String(m[0]) : ""; - const option: OptionSelectItem = { - label: levelNumber.padEnd(4, " ") + allMoves[m[1]].name, + options: this.levelMoves + .map(m => { + const levelNumber = m[0] > 0 ? String(m[0]) : ""; + const option: OptionSelectItem = { + label: levelNumber.padEnd(4, " ") + allMoves[m[1]].name, + handler: () => { + return false; + }, + onHover: () => { + this.moveInfoOverlay.show(allMoves[m[1]]); + if (m[0] === 0) { + this.showText(i18next.t("pokedexUiHandler:onlyEvolutionMove")); + } else if (m[0] === -1) { + this.showText(i18next.t("pokedexUiHandler:onlyRecallMove")); + } else if (m[0] <= 5) { + this.showText(i18next.t("pokedexUiHandler:onStarterSelectMove")); + } else { + this.showText(i18next.t("pokedexUiHandler:byLevelUpMove")); + } + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), handler: () => { - return false; + this.moveInfoOverlay.clear(); + this.clearText(); + ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + return true; }, onHover: () => { - this.moveInfoOverlay.show(allMoves[m[1]]); - if (m[0] === 0) { - this.showText(i18next.t("pokedexUiHandler:onlyEvolutionMove")); - } else if (m[0] === -1) { - this.showText(i18next.t("pokedexUiHandler:onlyRecallMove")); - } else if (m[0] <= 5) { - this.showText(i18next.t("pokedexUiHandler:onStarterSelectMove")); - } else { - this.showText(i18next.t("pokedexUiHandler:byLevelUpMove")); - } + this.moveInfoOverlay.clear(); }, - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - this.moveInfoOverlay.clear(); - this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); - return true; - }, - onHover: () => { - this.moveInfoOverlay.clear(); - }, - }), + }), supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1052,16 +1181,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.EGG_MOVES: - - if (!isCaught || !isFormCaught) { error = true; } else { - this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { - if (this.eggMoves.length === 0) { ui.showText(i18next.t("pokedexUiHandler:noEggMoves")); this.blockInput = false; @@ -1069,7 +1194,6 @@ 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, { @@ -1079,26 +1203,26 @@ export default class PokedexPageUiHandler extends MessageUiHandler { skip: true, style: TextStyle.MONEY_WINDOW, handler: () => false, // Non-selectable, but handler is required - onHover: () => this.moveInfoOverlay.clear() // No hover behavior for titles + onHover: () => this.moveInfoOverlay.clear(), // No hover behavior for titles }, ...this.eggMoves.slice(0, 3).map((m, i) => ({ label: allMoves[m].name, style: this.hasEggMoves[i] ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.moveInfoOverlay.show(allMoves[m]) + onHover: () => this.moveInfoOverlay.show(allMoves[m]), })), { label: i18next.t("pokedexUiHandler:rare"), skip: true, style: TextStyle.MONEY_WINDOW, handler: () => false, - onHover: () => this.moveInfoOverlay.clear() + onHover: () => this.moveInfoOverlay.clear(), }, { label: allMoves[this.eggMoves[3]].name, style: this.hasEggMoves[3] ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.moveInfoOverlay.show(allMoves[this.eggMoves[3]]) + onHover: () => this.moveInfoOverlay.show(allMoves[this.eggMoves[3]]), }, { label: i18next.t("menu:cancel"), @@ -1108,12 +1232,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, "refresh"); return true; }, - onHover: () => this.moveInfoOverlay.clear() - } + onHover: () => this.moveInfoOverlay.clear(), + }, ], supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1124,7 +1248,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.TM_MOVES: - if (!isCaught || !isFormCaught) { error = true; } else if (this.tmMoves.length < 1) { @@ -1135,36 +1258,37 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { ui.showText(i18next.t("pokedexUiHandler:showTmMoves"), null, () => { - this.moveInfoOverlay.show(allMoves[this.tmMoves[0]]); ui.setModeWithoutClear(Mode.OPTION_SELECT, { - options: this.tmMoves.map(m => { - const option: OptionSelectItem = { - label: allMoves[m].name, + options: this.tmMoves + .map(m => { + const option: OptionSelectItem = { + label: allMoves[m].name, + handler: () => { + return false; + }, + onHover: () => { + this.moveInfoOverlay.show(allMoves[m]); + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), handler: () => { - return false; + this.moveInfoOverlay.clear(); + this.clearText(); + ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + return true; }, onHover: () => { - this.moveInfoOverlay.show(allMoves[m]); + this.moveInfoOverlay.clear(); }, - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - this.moveInfoOverlay.clear(); - this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); - return true; - }, - onHover: () => { - this.moveInfoOverlay.clear(); - }, - }), + }), supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1175,17 +1299,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.ABILITIES: - if (!isCaught || !isFormCaught) { error = true; } else { - this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { - ui.showText(i18next.t("pokedexUiHandler:showAbilities"), null, () => { - this.infoOverlay.show(allAbilities[this.ability1].description); const options: any[] = []; @@ -1193,18 +1313,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler { if (this.ability1) { options.push({ label: allAbilities[this.ability1].name, - style: this.hasAbilities[0] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, + style: this.hasAbilities[0] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.infoOverlay.show(allAbilities[this.ability1].description) + onHover: () => this.infoOverlay.show(allAbilities[this.ability1].description), }); } if (this.ability2) { const ability = allAbilities[this.ability2]; options.push({ label: ability?.name, - style: this.hasAbilities[1] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, + style: this.hasAbilities[1] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.infoOverlay.show(ability?.description) + onHover: () => this.infoOverlay.show(ability?.description), }); } @@ -1214,14 +1334,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler { skip: true, style: TextStyle.MONEY_WINDOW, handler: () => false, - onHover: () => this.infoOverlay.clear() + onHover: () => this.infoOverlay.clear(), }); const ability = allAbilities[this.abilityHidden]; options.push({ label: allAbilities[this.abilityHidden].name, - style: this.hasAbilities[2] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, + style: this.hasAbilities[2] > 0 ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.infoOverlay.show(ability?.description) + onHover: () => this.infoOverlay.show(ability?.description), }); } @@ -1231,13 +1351,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { skip: true, style: TextStyle.MONEY_WINDOW, handler: () => false, - onHover: () => this.infoOverlay.clear() + onHover: () => this.infoOverlay.clear(), }); options.push({ label: allAbilities[this.passive].name, - style: this.hasPassive ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, + style: this.hasPassive ? TextStyle.SETTINGS_VALUE : TextStyle.SHADOW_TEXT, handler: () => false, - onHover: () => this.infoOverlay.show(allAbilities[this.passive].description) + onHover: () => this.infoOverlay.show(allAbilities[this.passive].description), }); } @@ -1249,14 +1369,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, "refresh"); return true; }, - onHover: () => this.infoOverlay.clear() + onHover: () => this.infoOverlay.clear(), }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1267,16 +1387,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.BIOMES: - if (!(isCaught || this.speciesStarterDexEntry?.seenAttr)) { error = true; } else { this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { - - if ((!this.biomes || this.biomes?.length === 0) && - (!this.preBiomes || this.preBiomes?.length === 0)) { + if ((!this.biomes || this.biomes?.length === 0) && (!this.preBiomes || this.preBiomes?.length === 0)) { ui.showText(i18next.t("pokedexUiHandler:noBiomes")); ui.playError(); this.blockInput = false; @@ -1286,29 +1403,39 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const options: any[] = []; ui.showText(i18next.t("pokedexUiHandler:showBiomes"), null, () => { - this.biomes.map(b => { options.push({ - label: i18next.t(`biome:${Biome[b.biome].toUpperCase()}`) + " - " + + label: + i18next.t(`biome:${Biome[b.biome].toUpperCase()}`) + + " - " + i18next.t(`biome:${BiomePoolTier[b.tier].toUpperCase()}`) + - ( b.tod.length === 1 && b.tod[0] === -1 ? "" : " (" + b.tod.map(tod => i18next.t(`biome:${TimeOfDay[tod].toUpperCase()}`)).join(", ") + ")"), - handler: () => false + (b.tod.length === 1 && b.tod[0] === -1 + ? "" + : " (" + + b.tod.map(tod => i18next.t(`biome:${TimeOfDay[tod].toUpperCase()}`)).join(", ") + + ")"), + handler: () => false, }); }); - if (this.preBiomes.length > 0) { options.push({ label: i18next.t("pokedexUiHandler:preBiomes"), skip: true, - handler: () => false + handler: () => false, }); this.preBiomes.map(b => { options.push({ - label: i18next.t(`biome:${Biome[b.biome].toUpperCase()}`) + " - " + + label: + i18next.t(`biome:${Biome[b.biome].toUpperCase()}`) + + " - " + i18next.t(`biome:${BiomePoolTier[b.tier].toUpperCase()}`) + - ( b.tod.length === 1 && b.tod[0] === -1 ? "" : " (" + b.tod.map(tod => i18next.t(`biome:${TimeOfDay[tod].toUpperCase()}`)).join(", ") + ")"), - handler: () => false + (b.tod.length === 1 && b.tod[0] === -1 + ? "" + : " (" + + b.tod.map(tod => i18next.t(`biome:${TimeOfDay[tod].toUpperCase()}`)).join(", ") + + ")"), + handler: () => false, }); }); } @@ -1321,14 +1448,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, "refresh"); return true; }, - onHover: () => this.moveInfoOverlay.clear() + onHover: () => this.moveInfoOverlay.clear(), }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1339,20 +1466,19 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.EVOLUTIONS: - if (!isCaught || !isFormCaught) { error = true; } else { - this.blockInput = true; ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => { - const options: any[] = []; - if ((!this.prevolutions || this.prevolutions?.length === 0) && - (!this.evolutions || this.evolutions?.length === 0) && - (!this.battleForms || this.battleForms?.length === 0)) { + if ( + (!this.prevolutions || this.prevolutions?.length === 0) && + (!this.evolutions || this.evolutions?.length === 0) && + (!this.battleForms || this.battleForms?.length === 0) + ) { ui.showText(i18next.t("pokedexUiHandler:noEvolutions")); ui.playError(); this.blockInput = false; @@ -1360,28 +1486,36 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } ui.showText(i18next.t("pokedexUiHandler:showEvolutions"), null, () => { - if (this.prevolutions?.length > 0) { options.push({ label: i18next.t("pokedexUiHandler:prevolutions"), style: TextStyle.MONEY_WINDOW, skip: true, - handler: () => false + handler: () => false, }); this.prevolutions.map(pre => { - const preSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[this.species.speciesId]); - const preFormIndex: number = preSpecies?.forms.find(f => f.formKey === pre.preFormKey)?.formIndex ?? 0; + const preSpecies = allSpecies.find( + species => species.speciesId === pokemonPrevolutions[this.species.speciesId], + ); + const preFormIndex: number = + preSpecies?.forms.find(f => f.formKey === pre.preFormKey)?.formIndex ?? 0; const conditionText: string = pre.description; options.push({ - label: pre.preFormKey ? - (preSpecies ?? this.species).getFormNameToDisplay(preFormIndex, true) : - (preSpecies ?? this.species).getExpandedSpeciesName(), + label: pre.preFormKey + ? (preSpecies ?? this.species).getFormNameToDisplay(preFormIndex, true) + : (preSpecies ?? this.species).getExpandedSpeciesName(), handler: () => { - const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]); + const newSpecies = allSpecies.find( + species => species.speciesId === pokemonPrevolutions[pre.speciesId], + ); // Attempts to find the formIndex of the prevolved species - const newFormKey = pre.preFormKey ? pre.preFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""); + const newFormKey = pre.preFormKey + ? pre.preFormKey + : this.species.forms.length > 0 + ? this.species.forms[this.formIndex].formKey + : ""; const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; this.starterAttributes.form = newFormIndex; @@ -1391,7 +1525,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes); return true; }, - onHover: () => this.showText(conditionText) + onHover: () => this.showText(conditionText), }); }); } @@ -1401,13 +1535,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler { label: i18next.t("pokedexUiHandler:evolutions"), style: TextStyle.MONEY_WINDOW, skip: true, - handler: () => false + handler: () => false, }); this.evolutions.map(evo => { const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId); - const isCaughtEvo = this.isCaught(evoSpecies) ? true : false; + const isCaughtEvo = !!this.isCaught(evoSpecies); // Attempts to find the formIndex of the evolved species - const newFormKey = evo.evoFormKey ? evo.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""); + const newFormKey = evo.evoFormKey + ? evo.evoFormKey + : this.species.forms.length > 0 + ? this.species.forms[this.formIndex].formKey + : ""; const matchingForm = evoSpecies?.forms.find(form => form.formKey === newFormKey); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; const isFormCaughtEvo = this.isFormCaught(evoSpecies, newFormIndex); @@ -1415,9 +1553,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const conditionText: string = evo.description; options.push({ - label: evo.evoFormKey ? - (evoSpecies ?? this.species).getFormNameToDisplay(newFormIndex, true) : - (evoSpecies ?? this.species).getExpandedSpeciesName(), + label: evo.evoFormKey + ? (evoSpecies ?? this.species).getFormNameToDisplay(newFormIndex, true) + : (evoSpecies ?? this.species).getExpandedSpeciesName(), style: isCaughtEvo && isFormCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT, handler: () => { this.starterAttributes.form = newFormIndex; @@ -1427,7 +1565,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, evoSpecies, newFormIndex, this.savedStarterAttributes); return true; }, - onHover: () => this.showText(conditionText) + onHover: () => this.showText(conditionText), }); }); } @@ -1437,13 +1575,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { label: i18next.t("pokedexUiHandler:forms"), style: TextStyle.MONEY_WINDOW, skip: true, - handler: () => false + handler: () => false, }); this.battleForms.map(bf => { const matchingForm = this.species?.forms.find(form => form.formKey === bf.formKey); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; - let conditionText:string = ""; + let conditionText = ""; if (bf.trigger) { conditionText = bf.trigger.description; } else { @@ -1466,10 +1604,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices); + ui.setMode( + Mode.POKEDEX_PAGE, + newSpecies, + newFormIndex, + this.savedStarterAttributes, + this.filteredIndices, + ); return true; }, - onHover: () => this.showText(conditionText) + onHover: () => this.showText(conditionText), }); } }); @@ -1483,14 +1627,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.setMode(Mode.POKEDEX_PAGE, "refresh"); return true; }, - onHover: () => this.moveInfoOverlay.clear() + onHover: () => this.moveInfoOverlay.clear(), }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; @@ -1501,7 +1645,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.TOGGLE_IVS: - if (!isCaught || !isFormCaught) { error = true; } else { @@ -1512,7 +1655,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { break; case MenuOptions.NATURES: - if (!isCaught || !isFormCaught) { error = true; } else { @@ -1521,25 +1663,27 @@ export default class PokedexPageUiHandler extends MessageUiHandler { ui.showText(i18next.t("pokedexUiHandler:showNature"), null, () => { const natures = globalScene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr); ui.setModeWithoutClear(Mode.OPTION_SELECT, { - options: natures.map((n: Nature, i: number) => { - const option: OptionSelectItem = { - label: getNatureName(n, true, true, true, globalScene.uiTheme), + options: natures + .map((n: Nature, _i: number) => { + const option: OptionSelectItem = { + label: getNatureName(n, true, true, true, globalScene.uiTheme), + handler: () => { + return false; + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), handler: () => { - return false; - } - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - this.clearText(); - ui.setMode(Mode.POKEDEX_PAGE, "refresh"); - this.blockInput = false; - return true; - } - }), + this.clearText(); + ui.setMode(Mode.POKEDEX_PAGE, "refresh"); + this.blockInput = false; + return true; + }, + }), maxOptions: 8, - yOffset: 19 + yOffset: 19, }); }); }); @@ -1547,17 +1691,21 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } break; } - } else { - const props = globalScene.gameData.getSpeciesDexAttrProps(this.species, this.getCurrentDexProps(this.species.speciesId)); + const props = globalScene.gameData.getSpeciesDexAttrProps( + this.species, + this.getCurrentDexProps(this.species.speciesId), + ); switch (button) { case Button.CYCLE_SHINY: if (this.canCycleShiny) { - if (!starterAttributes.shiny) { // Change to shiny, we need to get the proper default variant - const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : 0; - this.setSpeciesDetails(this.species, { shiny: true, variant: newVariant }); + const newVariant = starterAttributes.variant ? (starterAttributes.variant as Variant) : 0; + this.setSpeciesDetails(this.species, { + shiny: true, + variant: newVariant, + }); globalScene.playSound("se/sparkle"); @@ -1584,13 +1732,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler { starterAttributes.variant = newVariant; // store the selected variant this.savedStarterAttributes.variant = starterAttributes.variant; - if ((this.isCaught() & DexAttr.NON_SHINY) && (newVariant <= props.variant)) { - this.setSpeciesDetails(this.species, { shiny: false, variant: 0 }); + if (this.isCaught() & DexAttr.NON_SHINY && newVariant <= props.variant) { + this.setSpeciesDetails(this.species, { + shiny: false, + variant: 0, + }); success = true; starterAttributes.shiny = false; this.savedStarterAttributes.shiny = starterAttributes.shiny; } else { - this.setSpeciesDetails(this.species, { variant: newVariant as Variant }); + this.setSpeciesDetails(this.species, { + variant: newVariant as Variant, + }); success = true; } } @@ -1602,7 +1755,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { let newFormIndex = this.formIndex; do { newFormIndex = (newFormIndex + 1) % formCount; - if (this.species.forms[newFormIndex].isStarterSelectable || globalScene.dexForDevs) { // TODO: are those bangs correct? + if (this.species.forms[newFormIndex].isStarterSelectable || globalScene.dexForDevs) { + // TODO: are those bangs correct? break; } } while (newFormIndex !== props.formIndex || this.species.forms[newFormIndex].isUnobtainable); @@ -1617,7 +1771,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { starterAttributes.female = newFemale; this.savedStarterAttributes.female = starterAttributes.female; this.starterSetup(); - this.setSpeciesDetails(this.species, { formIndex: newFormIndex, female: newFemale }); + this.setSpeciesDetails(this.species, { + formIndex: newFormIndex, + female: newFemale, + }); success = this.setCursor(this.cursor); } break; @@ -1634,7 +1791,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.savedStarterAttributes.form = starterAttributes.form; this.formIndex = newFormIndex; this.starterSetup(); - this.setSpeciesDetails(this.species, { female: !props.female, formIndex: newFormIndex }); + this.setSpeciesDetails(this.species, { + female: !props.female, + formIndex: newFormIndex, + }); success = true; } break; @@ -1675,7 +1835,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { }, style: this.isPassiveAvailable() ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT, item: "candy", - itemArgs: this.isPassiveAvailable() ? starterColors[this.starterId] : [ "808080", "808080" ] + itemArgs: this.isPassiveAvailable() ? starterColors[this.starterId] : ["808080", "808080"], }); } @@ -1706,7 +1866,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { }, style: this.isValueReductionAvailable() ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT, item: "candy", - itemArgs: this.isValueReductionAvailable() ? starterColors[this.starterId] : [ "808080", "808080" ] + itemArgs: this.isValueReductionAvailable() ? starterColors[this.starterId] : ["808080", "808080"], }); } @@ -1718,7 +1878,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler { if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost) { if (globalScene.gameData.eggs.length >= 99 && !Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { // Egg list full, show error message at the top of the screen and abort - this.showText(i18next.t("egg:tooManyEggs"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), 2000, false, undefined, true); + this.showText( + i18next.t("egg:tooManyEggs"), + undefined, + () => this.showText("", 0, () => (this.tutorialActive = false)), + 2000, + false, + undefined, + true, + ); return false; } if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) { @@ -1726,7 +1894,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); - const egg = new Egg({ scene: globalScene, species: this.starterId, sourceType: EggSourceType.SAME_SPECIES_EGG }); + const egg = new Egg({ + scene: globalScene, + species: this.starterId, + sourceType: EggSourceType.SAME_SPECIES_EGG, + }); egg.addEggToGameData(); globalScene.gameData.saveSystem().then(success => { @@ -1743,18 +1915,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler { }, style: this.isSameSpeciesEggAvailable() ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT, item: "candy", - itemArgs: this.isSameSpeciesEggAvailable() ? starterColors[this.starterId] : [ "808080", "808080" ] + itemArgs: this.isSameSpeciesEggAvailable() ? starterColors[this.starterId] : ["808080", "808080"], }); options.push({ label: i18next.t("menu:cancel"), handler: () => { ui.setMode(Mode.POKEDEX_PAGE, "refresh"); return true; - } + }, }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, - yOffset: 47 + yOffset: 47, }); success = true; } @@ -1796,13 +1968,21 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const newIndex = index <= 0 ? allSpecies.length - 1 : index - 1; newSpecies = allSpecies[newIndex]; } - const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey); + const matchingForm = newSpecies?.forms.find( + form => form.formKey === this.species?.forms[this.formIndex]?.formKey, + ); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; this.starterAttributes.form = newFormIndex; this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); - ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices); + ui.setModeForceTransition( + Mode.POKEDEX_PAGE, + newSpecies, + newFormIndex, + this.savedStarterAttributes, + this.filteredIndices, + ); }); this.blockInput = false; break; @@ -1818,13 +1998,21 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const newIndex = index >= allSpecies.length - 1 ? 0 : index + 1; newSpecies = allSpecies[newIndex]; } - const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey); + const matchingForm = newSpecies?.forms.find( + form => form.formKey === this.species?.forms[this.formIndex]?.formKey, + ); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; this.starterAttributes.form = newFormIndex; this.savedStarterAttributes.form = newFormIndex; this.moveInfoOverlay.clear(); this.clearText(); - ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes, this.filteredIndices); + ui.setModeForceTransition( + Mode.POKEDEX_PAGE, + newSpecies, + newFormIndex, + this.savedStarterAttributes, + this.filteredIndices, + ); }); break; } @@ -1841,6 +2029,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } updateButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void { + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let iconPath; // touch controls cannot be rebound as is, and are just emulating a keyboard event. // Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls @@ -1870,7 +2059,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { controlLabel.setPosition(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY); iconElement.setVisible(true); controlLabel.setVisible(true); - this.instructionsContainer.add([ iconElement, controlLabel ]); + this.instructionsContainer.add([iconElement, controlLabel]); this.instructionRowY += 8; if (this.instructionRowY >= 24) { this.instructionRowY = 8; @@ -1886,9 +2075,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.hideInstructions(); this.instructionsContainer.removeAll(); this.filterInstructionsContainer.removeAll(); + + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let gamepadType; if (globalScene.inputMethod === "gamepad") { - gamepadType = globalScene.inputController.getConfig(globalScene.inputController.selectedDevice[Device.GAMEPAD]).padType; + gamepadType = globalScene.inputController.getConfig( + globalScene.inputController.selectedDevice[Device.GAMEPAD], + ).padType; } else { gamepadType = globalScene.inputMethod; } @@ -1902,13 +2095,28 @@ export default class PokedexPageUiHandler extends MessageUiHandler { if (this.isCaught()) { if (isFormCaught) { if (this.canUseCandies) { - this.updateButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.candyUpgradeIconElement, this.candyUpgradeLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Stats, + gamepadType, + this.candyUpgradeIconElement, + this.candyUpgradeLabel, + ); } if (this.canCycleShiny) { - this.updateButtonIcon(SettingKeyboard.Button_Cycle_Shiny, gamepadType, this.shinyIconElement, this.shinyLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Cycle_Shiny, + gamepadType, + this.shinyIconElement, + this.shinyLabel, + ); } if (this.canCycleGender) { - this.updateButtonIcon(SettingKeyboard.Button_Cycle_Gender, gamepadType, this.genderIconElement, this.genderLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Cycle_Gender, + gamepadType, + this.genderIconElement, + this.genderLabel, + ); } } else { // Making space for "Uncaught" text @@ -1936,7 +2144,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return valueLimit.value; } - setCursor(cursor: number): boolean { const ret = super.setCursor(cursor); @@ -1962,7 +2169,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return ret; } - getFriendship(speciesId: number) { + getFriendship(_speciesId: number) { let currentFriendship = globalScene.gameData.starterData[this.starterId].friendship; if (!currentFriendship || currentFriendship === undefined) { currentFriendship = 0; @@ -1981,8 +2188,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[this.starterId]; - return starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.starterId]) - && !(starterData.passiveAttr & PassiveAttr.UNLOCKED); + return ( + starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.starterId]) && + !(starterData.passiveAttr & PassiveAttr.UNLOCKED) + ); } /** @@ -1993,8 +2202,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[this.starterId]; - return starterData.candyCount >= getValueReductionCandyCounts(speciesStarterCosts[this.starterId])[starterData.valueReduction] - && starterData.valueReduction < valueReductionMax; + return ( + starterData.candyCount >= + getValueReductionCandyCounts(speciesStarterCosts[this.starterId])[starterData.valueReduction] && + starterData.valueReduction < valueReductionMax + ); } /** @@ -2010,7 +2222,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { setSpecies() { const species = this.species; - const starterAttributes : StarterAttributes | null = species ? { ...this.starterAttributes } : null; + const starterAttributes: StarterAttributes | null = species ? { ...this.starterAttributes } : null; if (!species && globalScene.ui.getTooltip().visible) { globalScene.ui.hideTooltip(); @@ -2031,11 +2243,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonNumberText.setText(padInt(species.speciesId, 4)); if (this.isCaught()) { - const defaultDexAttr = this.getCurrentDexProps(species.speciesId); // Set default attributes if for some reason starterAttributes does not exist or attributes missing const props: StarterAttributes = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); - if (starterAttributes?.variant && !isNaN(starterAttributes.variant)) { + if (starterAttributes?.variant && !Number.isNaN(starterAttributes.variant)) { if (props.shiny) { props.variant = starterAttributes.variant as Variant; } @@ -2092,7 +2303,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonCandyContainer.setVisible(false); this.pokemonFormText.setVisible(false); - this.setSpeciesDetails(species!, { // TODO: is this bang correct? + this.setSpeciesDetails(species!, { + // TODO: is this bang correct? shiny: false, formIndex: 0, female: false, @@ -2108,8 +2320,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // We will only update the sprite if there is a change to form, shiny/variant // or gender for species with gender sprite differences - const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female)) - || !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant) || forceUpdate; + const shouldUpdateSprite = + (species?.genderDiffs && !isNullOrUndefined(female)) || + !isNullOrUndefined(formIndex) || + !isNullOrUndefined(shiny) || + !isNullOrUndefined(variant) || + forceUpdate; if (this.activeTooltip === "CANDY") { if (this.species && this.pokemonCandyContainer.visible) { @@ -2178,14 +2394,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default? this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false)); - this.pokemonNumberText.setShadowColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true)); + this.pokemonNumberText.setShadowColor( + this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true), + ); const assetLoadCancelled = new BooleanHolder(false); this.assetLoadCancelled = assetLoadCancelled; if (shouldUpdateSprite) { - const back = this.showBackSprite ? true : false; - species.loadAssets(female!, formIndex, shiny, variant as Variant, true, back).then(() => { // TODO: is this bang correct? + const back = !!this.showBackSprite; + species.loadAssets(female!, formIndex, shiny, variant as Variant, true, back).then(() => { + // TODO: is this bang correct? if (assetLoadCancelled.value) { return; } @@ -2194,7 +2413,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonSprite.play(species.getSpriteKey(female!, formIndex, shiny, variant, back)); // TODO: is this bang correct? this.pokemonSprite.setPipelineData("shiny", shiny); this.pokemonSprite.setPipelineData("variant", variant); - this.pokemonSprite.setPipelineData("spriteKey", species.getSpriteKey(female!, formIndex, shiny, variant, back)); // TODO: is this bang correct? + this.pokemonSprite.setPipelineData( + "spriteKey", + species.getSpriteKey(female!, formIndex, shiny, variant, back), + ); // TODO: is this bang correct? this.pokemonSprite.setVisible(!this.statsMode); }); } else { @@ -2204,7 +2426,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY); const isShinyCaught = !!(caughtAttr & DexAttr.SHINY); - const caughtVariants = [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => caughtAttr & v); + const caughtVariants = [DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3].filter( + v => caughtAttr & v, + ); this.canCycleShiny = (isNonShinyCaught && isShinyCaught) || (isShinyCaught && caughtVariants.length > 1); const isMaleCaught = !!(caughtAttr & DexAttr.MALE); @@ -2212,8 +2436,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.canCycleGender = isMaleCaught && isFemaleCaught; // If the dev option for the dex is selected, all forms can be cycled through - this.canCycleForm = globalScene.dexForDevs ? species.forms.length > 1 : - species.forms.filter(f => f.isStarterSelectable).filter(f => f).length > 1; + this.canCycleForm = globalScene.dexForDevs + ? species.forms.length > 1 + : species.forms.filter(f => f.isStarterSelectable).filter(f => f).length > 1; if (caughtAttr && species.malePercent !== null) { const gender = !female ? Gender.MALE : Gender.FEMALE; @@ -2234,7 +2459,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // Setting tint of the sprite if (isFormCaught) { this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => { - const crier = (this.species.forms && this.species.forms.length > 0) ? this.species.forms[formIndex ?? this.formIndex] : this.species; + const crier = + this.species.forms && this.species.forms.length > 0 + ? this.species.forms[formIndex ?? this.formIndex] + : this.species; crier.cry(); }); this.pokemonSprite.clearTint(); @@ -2261,7 +2489,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { let growthReadable = toReadableString(GrowthRate[species.growthRate]); const growthAux = growthReadable.replace(" ", "_"); if (i18next.exists("growth:" + growthAux)) { - growthReadable = i18next.t("growth:" + growthAux as any); + growthReadable = i18next.t(("growth:" + growthAux) as any); } this.pokemonGrowthRateText.setText(growthReadable); @@ -2311,7 +2539,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonCaughtHatchedContainer.setY(25); this.pokemonCandyIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[0]))); this.pokemonCandyOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(colorScheme[1]))); - this.pokemonCandyCountText.setText(`x${species.speciesId === Species.PIKACHU ? 0 : globalScene.gameData.starterData[this.starterId].candyCount}`); + this.pokemonCandyCountText.setText( + `x${species.speciesId === Species.PIKACHU ? 0 : globalScene.gameData.starterData[this.starterId].candyCount}`, + ); this.pokemonCandyContainer.setVisible(true); if (pokemonPrevolutions.hasOwnProperty(species.speciesId)) { @@ -2324,7 +2554,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { this.pokemonFormText.setY(42); const { currentFriendship, friendshipCap } = this.getFriendship(this.species.speciesId); - const candyCropY = 16 - (16 * (currentFriendship / friendshipCap)); + const candyCropY = 16 - 16 * (currentFriendship / friendshipCap); this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY); this.pokemonCandyContainer.on("pointerover", () => { @@ -2335,7 +2565,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { globalScene.ui.hideTooltip(); this.activeTooltip = undefined; }); - } } else { this.pokemonUncaughtText.setVisible(true); @@ -2391,7 +2620,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } } - /** * Creates a temporary dex attr props that will be used to display the correct shiny, variant, and form based on this.starterAttributes * @@ -2401,7 +2629,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { getCurrentDexProps(speciesId: number): bigint { let props = 0n; const species = allSpecies.find(sp => sp.speciesId === speciesId); - const caughtAttr = globalScene.gameData.dexData[speciesId].caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & (species?.getFullUnlocksData() ?? 0n); + const caughtAttr = + globalScene.gameData.dexData[speciesId].caughtAttr & + globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & + (species?.getFullUnlocksData() ?? 0n); /* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props * It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props @@ -2415,7 +2646,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler { /* This part is very similar to above, but instead of for gender, it checks for shiny within starter preferences. * If they're not there, it enables shiny state by default if any shiny was caught */ - if (this.starterAttributes?.shiny || ((caughtAttr & DexAttr.SHINY) > 0n && this.starterAttributes?.shiny !== false)) { + if ( + this.starterAttributes?.shiny || + ((caughtAttr & DexAttr.SHINY) > 0n && this.starterAttributes?.shiny !== false) + ) { props += DexAttr.SHINY; if (this.starterAttributes?.variant !== undefined) { props += BigInt(Math.pow(2, this.starterAttributes?.variant)) * DexAttr.DEFAULT_VARIANT; @@ -2435,7 +2669,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler { props += DexAttr.NON_SHINY; props += DexAttr.DEFAULT_VARIANT; // we add the default variant here because non shiny versions are listed as default variant } - if (this.starterAttributes?.form) { // this checks for the form of the pokemon + if (this.starterAttributes?.form) { + // this checks for the form of the pokemon props += BigInt(Math.pow(2, this.starterAttributes?.form)) * DexAttr.DEFAULT_FORM; } else { // Get the first unlocked form @@ -2509,9 +2744,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } } - checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female: boolean, formIndex: number, shiny: boolean, variant: number) { + checkIconId( + icon: Phaser.GameObjects.Sprite, + species: PokemonSpecies, + female: boolean, + formIndex: number, + shiny: boolean, + variant: number, + ) { if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) { - console.log(`${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`); + console.log( + `${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`, + ); icon.setTexture(species.getIconAtlasKey(formIndex, false, variant)); icon.setFrame(species.getIconId(female, formIndex, false, variant)); } diff --git a/src/ui/pokedex-scan-ui-handler.ts b/src/ui/pokedex-scan-ui-handler.ts index a0a430018ff..b34246b97d1 100644 --- a/src/ui/pokedex-scan-ui-handler.ts +++ b/src/ui/pokedex-scan-ui-handler.ts @@ -12,7 +12,6 @@ import { allSpecies } from "#app/data/pokemon-species"; import i18next from "i18next"; export default class PokedexScanUiHandler extends FormModalUiHandler { - keys: string[]; reducedKeys: string[]; parallelKeys: string[]; @@ -21,10 +20,6 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { abilityKeys: string[]; row: number; - constructor(mode) { - super(mode); - } - setup() { super.setup(); @@ -33,20 +28,20 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { this.abilityKeys = allAbilities.map(a => a.name); } - getModalTitle(config?: ModalConfig): string { + getModalTitle(_config?: ModalConfig): string { return i18next.t("pokedexUiHandler:scanChooseOption"); } - getWidth(config?: ModalConfig): number { + getWidth(_config?: ModalConfig): number { return 300; } - getMargin(config?: ModalConfig): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + getMargin(_config?: ModalConfig): [number, number, number, number] { + return [0, 0, 48, 0]; } - getButtonLabels(config?: ModalConfig): string[] { - return [ i18next.t("pokedexUiHandler:scanSelect"), i18next.t("pokedexUiHandler:scanCancel") ]; + getButtonLabels(_config?: ModalConfig): string[] { + return [i18next.t("pokedexUiHandler:scanSelect"), i18next.t("pokedexUiHandler:scanCancel")]; } getReadableErrorMessage(error: string): string { @@ -67,7 +62,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { case FilterTextRow.MOVE_2: { return [{ label: i18next.t("pokedexUiHandler:scanLabelMove") }]; } - case FilterTextRow.ABILITY_1:{ + case FilterTextRow.ABILITY_1: { return [{ label: i18next.t("pokedexUiHandler:scanLabelAbility") }]; } case FilterTextRow.ABILITY_2: { @@ -77,7 +72,6 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { return [{ label: "" }]; } } - } reduceKeys(): void { @@ -102,7 +96,6 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { } } - // args[2] is an index of FilterTextRow show(args: any[]): boolean { this.row = args[2]; @@ -120,7 +113,10 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { }, 50); input.on("keydown", (inputObject, evt: KeyboardEvent) => { - if ([ "escape", "space" ].some((v) => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && ui.getMode() === Mode.AUTO_COMPLETE) { + if ( + ["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && + ui.getMode() === Mode.AUTO_COMPLETE + ) { // Delete autocomplete list and recovery focus. inputObject.on("blur", () => inputObject.node.focus(), { once: true }); ui.revertMode(); @@ -134,9 +130,11 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { } let options: OptionSelectItem[] = []; - const filteredKeys = this.reducedKeys.filter((command) => command.toLowerCase().includes(inputObject.text.toLowerCase())); + const filteredKeys = this.reducedKeys.filter(command => + command.toLowerCase().includes(inputObject.text.toLowerCase()), + ); if (inputObject.text !== "" && filteredKeys.length > 0) { - options = filteredKeys.slice(0).map((value) => { + options = filteredKeys.slice(0).map(value => { return { label: value, handler: () => { @@ -145,7 +143,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { } ui.revertMode(); return true; - } + }, }; }); } @@ -154,11 +152,10 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { const modalOpts = { options: options, maxOptions: 5, - modalContainer: this.modalContainer + modalContainer: this.modalContainer, }; ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOpts); } - }); if (super.show(args)) { @@ -170,7 +167,7 @@ export default class PokedexScanUiHandler extends FormModalUiHandler { } else { this.inputs[0].text = args[1]; } - this.submitAction = (_) => { + this.submitAction = _ => { if (ui.getMode() === Mode.POKEDEX_SCAN) { this.sanitizeInputs(); const outputName = this.reducedKeys.includes(this.inputs[0].text) ? this.inputs[0].text : ""; diff --git a/src/ui/pokedex-ui-handler.ts b/src/ui/pokedex-ui-handler.ts index 85bc0ee40f6..f4cb9f51c16 100644 --- a/src/ui/pokedex-ui-handler.ts +++ b/src/ui/pokedex-ui-handler.ts @@ -12,7 +12,7 @@ import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUN import { catchableSpecies } from "#app/data/balance/biomes"; import { PokemonType } from "#enums/pokemon-type"; import type { DexAttrProps, DexEntry, StarterAttributes, StarterPreferences } from "#app/system/game-data"; -import { AbilityAttr, DexAttr, StarterPrefs } from "#app/system/game-data"; +import { AbilityAttr, DexAttr, loadStarterPreferences, saveStarterPreferences } from "#app/system/game-data"; 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"; @@ -26,7 +26,11 @@ import { PokedexMonContainer } from "#app/ui/pokedex-mon-container"; import { DropDownColumn, FilterBar } from "#app/ui/filter-bar"; import { ScrollBar } from "#app/ui/scroll-bar"; import { Abilities } from "#enums/abilities"; -import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; +import { + getPassiveCandyCount, + getValueReductionCandyCounts, + getSameSpeciesEggCandyCounts, +} from "#app/data/balance/starters"; import { BooleanHolder, fixedInt, getLocalizedSpriteKey, padInt, randIntRange, rgbHexToRgba } from "#app/utils"; import type { Nature } from "#enums/nature"; import { addWindow } from "./ui-theme"; @@ -42,66 +46,65 @@ import { Biome } from "#enums/biome"; import { globalScene } from "#app/global-scene"; interface LanguageSetting { - starterInfoTextSize: string, - instructionTextSize: string, - starterInfoXPos?: number, - starterInfoYOffset?: number + starterInfoTextSize: string; + instructionTextSize: string; + starterInfoXPos?: number; + starterInfoYOffset?: number; } const languageSettings: { [key: string]: LanguageSetting } = { - "en":{ + en: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "de":{ + de: { starterInfoTextSize: "48px", instructionTextSize: "35px", starterInfoXPos: 33, }, - "es-ES":{ + "es-ES": { starterInfoTextSize: "56px", instructionTextSize: "35px", }, - "fr":{ + fr: { starterInfoTextSize: "54px", instructionTextSize: "38px", }, - "it":{ + it: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "pt_BR":{ + pt_BR: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoXPos: 33, }, - "zh":{ + zh: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoYOffset: 1, starterInfoXPos: 24, }, - "pt":{ + pt: { starterInfoTextSize: "48px", instructionTextSize: "42px", starterInfoXPos: 33, }, - "ko":{ + ko: { starterInfoTextSize: "52px", instructionTextSize: "38px", }, - "ja":{ + ja: { starterInfoTextSize: "51px", instructionTextSize: "38px", }, - "ca-ES":{ + "ca-ES": { starterInfoTextSize: "56px", instructionTextSize: "38px", }, }; - -enum FilterTextOptions{ +enum FilterTextOptions { NAME, MOVE_1, MOVE_2, @@ -110,15 +113,15 @@ enum FilterTextOptions{ } interface ContainerData { - species: PokemonSpecies, - cost: number, - props: DexAttrProps, - eggMove1?: boolean, - eggMove2?: boolean, - tmMove1?: boolean, - tmMove2?: boolean, - passive1?: boolean, - passive2?: boolean, + species: PokemonSpecies; + cost: number; + props: DexAttrProps; + eggMove1?: boolean; + eggMove2?: boolean; + tmMove1?: boolean; + tmMove2?: boolean; + passive1?: boolean; + passive2?: boolean; } const valueReductionMax = 2; @@ -132,22 +135,22 @@ const speciesContainerX = 143; * @param index UI index to calculate the starter position of * @returns An interface with an x and y property */ -function calcStarterPosition(index: number): {x: number, y: number} { +function calcStarterPosition(index: number): { x: number; y: number } { const yOffset = 13; const height = 17; const x = (index % 9) * 18; - const y = yOffset + (Math.floor(index / 9)) * height; + const y = yOffset + Math.floor(index / 9) * height; return { x: x, y: y }; } interface SpeciesDetails { - shiny?: boolean, - formIndex?: number - female?: boolean, - variant?: Variant, - abilityIndex?: number, - natureIndex?: number, + shiny?: boolean; + formIndex?: number; + female?: boolean; + variant?: Variant; + abilityIndex?: number; + natureIndex?: number; } export default class PokedexUiHandler extends MessageUiHandler { @@ -168,9 +171,9 @@ export default class PokedexUiHandler extends MessageUiHandler { private starterSelectMessageBoxContainer: Phaser.GameObjects.Container; private filterMode: boolean; - private filterBarCursor: number = 0; + private filterBarCursor = 0; private scrollCursor: number; - private oldCursor: number = -1; + private oldCursor = -1; private allSpecies: PokemonSpecies[] = []; private lastSpecies: PokemonSpecies; @@ -186,7 +189,7 @@ export default class PokedexUiHandler extends MessageUiHandler { private starterPreferences: StarterPreferences; - protected blockInput: boolean = false; + protected blockInput = false; // for text filters private readonly textPadding = 8; @@ -198,15 +201,15 @@ export default class PokedexUiHandler extends MessageUiHandler { protected manageDataConfig: OptionSelectConfig; private filterTextOptions: FilterTextOptions[]; protected optionSelectText: Phaser.GameObjects.Text; - protected scale: number = 0.1666666667; + protected scale = 0.1666666667; private menuBg: Phaser.GameObjects.NineSlice; private filterTextContainer: Phaser.GameObjects.Container; private filterText: FilterText; private filterTextMode: boolean; - private filterTextCursor: number = 0; + private filterTextCursor = 0; - private showDecorations: boolean = false; + private showDecorations = false; private goFilterIconElement1: Phaser.GameObjects.Sprite; private goFilterIconElement2: Phaser.GameObjects.Sprite; private goFilterLabel: Phaser.GameObjects.Text; @@ -221,8 +224,8 @@ export default class PokedexUiHandler extends MessageUiHandler { private trayRows: number; private trayColumns: number; private trayCursorObj: Phaser.GameObjects.Image; - private trayCursor: number = 0; - private showingTray: boolean = false; + private trayCursor = 0; + private showingTray = false; private showFormTrayIconElement: Phaser.GameObjects.Sprite; private showFormTrayLabel: Phaser.GameObjects.Text; private canShowFormTray: boolean; @@ -242,17 +245,26 @@ export default class PokedexUiHandler extends MessageUiHandler { this.starterSelectContainer.setVisible(false); ui.add(this.starterSelectContainer); - const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860); + const bgColor = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0x006860, + ); bgColor.setOrigin(0, 0); this.starterSelectContainer.add(bgColor); const pokemonContainerWindow = addWindow(speciesContainerX, filterBarHeight + 1, 175, 161); - const pokemonContainerBg = globalScene.add.image(speciesContainerX + 1, filterBarHeight + 2, "starter_container_bg"); + const pokemonContainerBg = globalScene.add.image( + speciesContainerX + 1, + filterBarHeight + 2, + "starter_container_bg", + ); pokemonContainerBg.setOrigin(0, 0); this.starterSelectContainer.add(pokemonContainerBg); this.starterSelectContainer.add(pokemonContainerWindow); - // Create and initialise filter text fields this.filterTextContainer = globalScene.add.container(0, 0); this.filterText = new FilterText(1, filterBarHeight + 2, 140, 100, this.updateStarters); @@ -266,7 +278,6 @@ export default class PokedexUiHandler extends MessageUiHandler { this.filterTextContainer.add(this.filterText); this.starterSelectContainer.add(this.filterTextContainer); - // Create and initialise filter bar this.filterBarContainer = globalScene.add.container(0, 0); this.filterBar = new FilterBar(speciesContainerX, 1, 175, filterBarHeight, 2, 0, 6); @@ -287,7 +298,7 @@ export default class PokedexUiHandler extends MessageUiHandler { this.filterBar.addFilter(DropDownColumn.GEN, i18next.t("filterBar:genFilter"), genDropDown); // type filter - const typeKeys = Object.keys(PokemonType).filter(v => isNaN(Number(v))); + const typeKeys = Object.keys(PokemonType).filter(v => Number.isNaN(Number(v))); const typeOptions: DropDownOption[] = []; typeKeys.forEach((type, index) => { if (index === 0 || index === 19) { @@ -296,17 +307,22 @@ export default class PokedexUiHandler extends MessageUiHandler { const typeSprite = globalScene.add.sprite(0, 0, getLocalizedSpriteKey("types")); typeSprite.setScale(0.5); typeSprite.setFrame(type.toLowerCase()); - typeOptions.push(new DropDownOption( index, new DropDownLabel("", typeSprite))); + typeOptions.push(new DropDownOption(index, new DropDownLabel("", typeSprite))); }); - this.filterBar.addFilter(DropDownColumn.TYPES, i18next.t("filterBar:typeFilter"), new DropDown(0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5)); + this.filterBar.addFilter( + DropDownColumn.TYPES, + i18next.t("filterBar:typeFilter"), + new DropDown(0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5), + ); // biome filter, making an entry in the dropdown for each biome const biomeOptions = Object.values(Biome) - .filter((value) => typeof value === "number") // Filter numeric values from the enum - .map((biomeValue, index) => - new DropDownOption( index, new DropDownLabel(i18next.t(`biome:${Biome[biomeValue].toUpperCase()}`))) + .filter(value => typeof value === "number") // Filter numeric values from the enum + .map( + (biomeValue, index) => + new DropDownOption(index, new DropDownLabel(i18next.t(`biome:${Biome[biomeValue].toUpperCase()}`))), ); - biomeOptions.push(new DropDownOption( biomeOptions.length, new DropDownLabel(i18next.t("filterBar:uncatchable")))); + biomeOptions.push(new DropDownOption(biomeOptions.length, new DropDownLabel(i18next.t("filterBar:uncatchable")))); const biomeDropDown: DropDown = new DropDown(0, 0, biomeOptions, this.updateStarters, DropDownType.HYBRID); this.filterBar.addFilter(DropDownColumn.BIOME, i18next.t("filterBar:biomeFilter"), biomeDropDown); @@ -332,10 +348,14 @@ export default class PokedexUiHandler extends MessageUiHandler { new DropDownOption("SHINY2", new DropDownLabel("", shiny2Sprite)), new DropDownOption("SHINY", new DropDownLabel("", shiny1Sprite)), new DropDownOption("NORMAL", new DropDownLabel(i18next.t("filterBar:normal"))), - new DropDownOption("UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught"))) + new DropDownOption("UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught"))), ]; - this.filterBar.addFilter(DropDownColumn.CAUGHT, i18next.t("filterBar:caughtFilter"), new DropDown(0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID)); + this.filterBar.addFilter( + DropDownColumn.CAUGHT, + i18next.t("filterBar:caughtFilter"), + new DropDown(0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID), + ); // unlocks filter const passiveLabels = [ @@ -359,7 +379,11 @@ export default class PokedexUiHandler extends MessageUiHandler { new DropDownOption("COST_REDUCTION", costReductionLabels), ]; - this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL)); + this.filterBar.addFilter( + DropDownColumn.UNLOCKS, + i18next.t("filterBar:unlocksFilter"), + new DropDown(0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL), + ); // misc filter const starters = [ @@ -398,19 +422,30 @@ export default class PokedexUiHandler extends MessageUiHandler { new DropDownOption("EGG", eggLabels), new DropDownOption("POKERUS", pokerusLabels), ]; - this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL)); + this.filterBar.addFilter( + DropDownColumn.MISC, + i18next.t("filterBar:miscFilter"), + new DropDown(0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL), + ); // sort filter const sortOptions = [ - new DropDownOption(SortCriteria.NUMBER, new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON)), + new DropDownOption( + SortCriteria.NUMBER, + new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON), + ), new DropDownOption(SortCriteria.COST, new DropDownLabel(i18next.t("filterBar:sortByCost"))), new DropDownOption(SortCriteria.CANDY, new DropDownLabel(i18next.t("filterBar:sortByCandies"))), new DropDownOption(SortCriteria.IV, new DropDownLabel(i18next.t("filterBar:sortByIVs"))), new DropDownOption(SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName"))), new DropDownOption(SortCriteria.CAUGHT, new DropDownLabel(i18next.t("filterBar:sortByNumCaught"))), - new DropDownOption(SortCriteria.HATCHED, new DropDownLabel(i18next.t("filterBar:sortByNumHatched"))) + new DropDownOption(SortCriteria.HATCHED, new DropDownLabel(i18next.t("filterBar:sortByNumHatched"))), ]; - this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE)); + this.filterBar.addFilter( + DropDownColumn.SORT, + i18next.t("filterBar:sortFilter"), + new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE), + ); this.filterBarContainer.add(this.filterBar); this.starterSelectContainer.add(this.filterBarContainer); @@ -433,7 +468,9 @@ export default class PokedexUiHandler extends MessageUiHandler { this.pokemonNameText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNameText); - this.pokemonFormText = addTextObject(6, 121, "", TextStyle.PARTY, { fontSize: textSettings.instructionTextSize }); + this.pokemonFormText = addTextObject(6, 121, "", TextStyle.PARTY, { + fontSize: textSettings.instructionTextSize, + }); this.pokemonFormText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonFormText); @@ -487,7 +524,10 @@ export default class PokedexUiHandler extends MessageUiHandler { this.starterSelectContainer.add(starterBoxContainer); this.pokemonSprite = globalScene.add.sprite(96, 143, "pkmn__sub"); - this.pokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + this.pokemonSprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); this.starterSelectContainer.add(this.pokemonSprite); this.type1Icon = globalScene.add.sprite(10, 158, getLocalizedSpriteKey("types")); @@ -519,7 +559,9 @@ export default class PokedexUiHandler extends MessageUiHandler { this.goFilterIconElement2.setName("sprite-goFilter2-icon-element"); this.goFilterIconElement2.setScale(0.675); this.goFilterIconElement2.setOrigin(0.0, 0.0); - this.goFilterLabel = addTextObject(30, 2, i18next.t("pokedexUiHandler:goFilters"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.goFilterLabel = addTextObject(30, 2, i18next.t("pokedexUiHandler:goFilters"), TextStyle.PARTY, { + fontSize: instructionTextSize, + }); this.goFilterLabel.setName("text-goFilter-label"); this.starterSelectContainer.add(this.goFilterIconElement1); this.starterSelectContainer.add(this.goFilterIconElement2); @@ -529,7 +571,13 @@ export default class PokedexUiHandler extends MessageUiHandler { this.toggleDecorationsIconElement.setName("sprite-toggleDecorations-icon-element"); this.toggleDecorationsIconElement.setScale(0.675); this.toggleDecorationsIconElement.setOrigin(0.0, 0.0); - this.toggleDecorationsLabel = addTextObject(20, 10, i18next.t("pokedexUiHandler:toggleDecorations"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.toggleDecorationsLabel = addTextObject( + 20, + 10, + i18next.t("pokedexUiHandler:toggleDecorations"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.toggleDecorationsLabel.setName("text-toggleDecorations-label"); this.starterSelectContainer.add(this.toggleDecorationsIconElement); this.starterSelectContainer.add(this.toggleDecorationsLabel); @@ -538,7 +586,9 @@ export default class PokedexUiHandler extends MessageUiHandler { this.showFormTrayIconElement.setName("sprite-showFormTray-icon-element"); this.showFormTrayIconElement.setScale(0.675); this.showFormTrayIconElement.setOrigin(0.0, 0.0); - this.showFormTrayLabel = addTextObject(16, 168, i18next.t("pokedexUiHandler:showForms"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.showFormTrayLabel = addTextObject(16, 168, i18next.t("pokedexUiHandler:showForms"), TextStyle.PARTY, { + fontSize: instructionTextSize, + }); this.showFormTrayLabel.setName("text-showFormTray-label"); this.showFormTrayIconElement.setVisible(false); this.showFormTrayLabel.setVisible(false); @@ -561,9 +611,8 @@ export default class PokedexUiHandler extends MessageUiHandler { } show(args: any[]): boolean { - if (!this.starterPreferences) { - this.starterPreferences = StarterPrefs.load(); + this.starterPreferences = loadStarterPreferences(); } this.pokerusSpecies = getPokerusStarters(); @@ -626,29 +675,34 @@ export default class PokedexUiHandler extends MessageUiHandler { const hasNonShiny = caughtAttr & DexAttr.NON_SHINY; if (starterAttributes.shiny && !hasShiny) { // shiny form wasn't unlocked, purging shiny and variant setting - delete starterAttributes.shiny; - delete starterAttributes.variant; + + starterAttributes.shiny = undefined; + starterAttributes.variant = undefined; } else if (starterAttributes.shiny === false && !hasNonShiny) { // non shiny form wasn't unlocked, purging shiny setting - delete starterAttributes.shiny; + starterAttributes.shiny = undefined; } if (starterAttributes.variant !== undefined) { const unlockedVariants = [ hasShiny && caughtAttr & DexAttr.DEFAULT_VARIANT, hasShiny && caughtAttr & DexAttr.VARIANT_2, - hasShiny && caughtAttr & DexAttr.VARIANT_3 + hasShiny && caughtAttr & DexAttr.VARIANT_3, ]; - if (isNaN(starterAttributes.variant) || starterAttributes.variant < 0 || !unlockedVariants[starterAttributes.variant]) { + if ( + Number.isNaN(starterAttributes.variant) || + starterAttributes.variant < 0 || + !unlockedVariants[starterAttributes.variant] + ) { // variant value is invalid or requested variant wasn't unlocked, purging setting - delete starterAttributes.variant; + starterAttributes.variant = undefined; } } if (starterAttributes.female !== undefined) { if (!(starterAttributes.female ? caughtAttr & DexAttr.FEMALE : caughtAttr & DexAttr.MALE)) { // requested gender wasn't unlocked, purging setting - delete starterAttributes.female; + starterAttributes.female = undefined; } } @@ -663,25 +717,29 @@ export default class PokedexUiHandler extends MessageUiHandler { const unlockedAbilities = [ hasAbility1, speciesHasSingleAbility ? hasAbility2 && !hasAbility1 : hasAbility2, - hasHiddenAbility + hasHiddenAbility, ]; if (!unlockedAbilities[starterAttributes.ability]) { // requested ability wasn't unlocked, purging setting - delete starterAttributes.ability; + starterAttributes.ability = undefined; } } const selectedForm = starterAttributes.form; - if (selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) { + if ( + selectedForm !== undefined && + (!species.forms[selectedForm]?.isStarterSelectable || + !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm))) + ) { // requested form wasn't unlocked/isn't a starter form, purging setting - delete starterAttributes.form; + starterAttributes.form = undefined; } if (starterAttributes.nature !== undefined) { const unlockedNatures = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr); if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) { // requested nature wasn't unlocked, purging setting - delete starterAttributes.nature; + starterAttributes.nature = undefined; } } @@ -691,12 +749,20 @@ export default class PokedexUiHandler extends MessageUiHandler { /** * Set the selections for all filters to their default starting value */ - resetFilters() : void { + resetFilters(): void { this.filterBar.setValsToDefault(); this.filterText.setValsToDefault(); } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number, moveToTop?: boolean) { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + moveToTop?: boolean, + ) { super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); const singleLine = text?.indexOf("\n") === -1; @@ -734,9 +800,8 @@ export default class PokedexUiHandler extends MessageUiHandler { getStarterSpeciesId(speciesId): number { if (speciesStarterCosts.hasOwnProperty(speciesId)) { return speciesId; - } else { - return pokemonStarters[speciesId]; } + return pokemonStarters[speciesId]; } /** @@ -748,8 +813,10 @@ export default class PokedexUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; - return starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]) - && !(starterData.passiveAttr & PassiveAttr.UNLOCKED); + return ( + starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]) && + !(starterData.passiveAttr & PassiveAttr.UNLOCKED) + ); } /** @@ -761,8 +828,12 @@ export default class PokedexUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; - return starterData.candyCount >= getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])[starterData.valueReduction] - && starterData.valueReduction < valueReductionMax; + return ( + starterData.candyCount >= + getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)])[ + starterData.valueReduction + ] && starterData.valueReduction < valueReductionMax + ); } /** @@ -774,7 +845,9 @@ export default class PokedexUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)]; - return starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]); + return ( + starterData.candyCount >= getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(speciesId)]) + ); } /** @@ -783,7 +856,7 @@ export default class PokedexUiHandler extends MessageUiHandler { * @param species {@linkcode PokemonSpecies} of the icon used to check for upgrades * @param startPaused Should this animation be paused after it is added? */ - setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused: boolean = false): void { + setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused = false): void { globalScene.tweens.killTweensOf(icon); // Skip animations if they are disabled if (globalScene.candyUpgradeDisplay === 0 || species.speciesId !== species.getRootSpeciesId(false)) { @@ -804,16 +877,17 @@ export default class PokedexUiHandler extends MessageUiHandler { y: 2 - 5, duration: fixedInt(125), ease: "Cubic.easeOut", - yoyo: true + yoyo: true, }, { targets: icon, y: 2 - 3, duration: fixedInt(150), ease: "Cubic.easeOut", - yoyo: true - } - ], }; + yoyo: true, + }, + ], + }; const isPassiveAvailable = this.isPassiveAvailable(species.speciesId); const isValueReductionAvailable = this.isValueReductionAvailable(species.speciesId); @@ -824,7 +898,7 @@ export default class PokedexUiHandler extends MessageUiHandler { if (isPassiveAvailable) { globalScene.tweens.chain(tweenChain).paused = startPaused; } - // 'On' mode + // 'On' mode } else if (globalScene.candyUpgradeNotification === 2) { if (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable) { globalScene.tweens.chain(tweenChain).paused = startPaused; @@ -839,7 +913,11 @@ export default class PokedexUiHandler extends MessageUiHandler { const species = starter.species; const slotVisible = !!species?.speciesId; - if (!species || globalScene.candyUpgradeNotification === 0 || species.speciesId !== species.getRootSpeciesId(false)) { + if ( + !species || + globalScene.candyUpgradeNotification === 0 || + species.speciesId !== species.getRootSpeciesId(false) + ) { starter.candyUpgradeIcon.setVisible(false); starter.candyUpgradeOverlayIcon.setVisible(false); return; @@ -857,7 +935,8 @@ export default class PokedexUiHandler extends MessageUiHandler { // 'On' mode } else if (globalScene.candyUpgradeNotification === 2) { starter.candyUpgradeIcon.setVisible( - slotVisible && ( isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable )); + slotVisible && (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable), + ); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); } } @@ -867,7 +946,7 @@ export default class PokedexUiHandler extends MessageUiHandler { * @param pokemonContainer the container for the Pokemon to update */ updateCandyUpgradeDisplay(pokemonContainer: PokedexMonContainer) { - if (this.isUpgradeIconEnabled() ) { + if (this.isUpgradeIconEnabled()) { this.setUpgradeIcon(pokemonContainer); } if (this.isUpgradeAnimationEnabled()) { @@ -903,7 +982,10 @@ export default class PokedexUiHandler extends MessageUiHandler { this.filterBar.resetSelection(this.filterBarCursor); this.updateStarters(); success = true; - } else if (this.filterTextMode && !(this.filterText.getValue(this.filterTextCursor) === this.filterText.defaultText)) { + } else if ( + this.filterTextMode && + !(this.filterText.getValue(this.filterTextCursor) === this.filterText.defaultText) + ) { this.filterText.resetSelection(this.filterTextCursor); success = true; } else if (this.showingTray) { @@ -912,7 +994,7 @@ export default class PokedexUiHandler extends MessageUiHandler { this.tryExit(); success = true; } - } else if (button === Button.STATS) { + } else if (button === Button.STATS) { if (!this.filterMode && !this.showingTray) { this.cursorObj.setVisible(false); this.setSpecies(null); @@ -923,7 +1005,7 @@ export default class PokedexUiHandler extends MessageUiHandler { } else { error = true; } - } else if (button === Button.CYCLE_TERA) { + } else if (button === Button.CYCLE_TERA) { if (!this.filterTextMode && !this.showingTray) { this.cursorObj.setVisible(false); this.setSpecies(null); @@ -962,16 +1044,18 @@ export default class PokedexUiHandler extends MessageUiHandler { if (this.filterBar.openDropDown) { success = this.filterBar.decDropDownCursor(); } else if (numberOfStarters > 0) { - // UP from filter bar to bottom of Pokemon list + // UP from filter bar to bottom of Pokemon list this.setFilterMode(false); this.scrollCursor = Math.max(0, numOfRows - 9); this.updateScroll(); const proportion = this.filterBarCursor / Math.max(1, this.filterBar.numFilters - 1); const targetCol = Math.min(8, proportion < 0.5 ? Math.floor(proportion * 8) : Math.ceil(proportion * 8)); if (numberOfStarters % 9 > targetCol) { - this.setCursor(numberOfStarters - (numberOfStarters) % 9 + targetCol - this.scrollCursor * 9); + this.setCursor(numberOfStarters - (numberOfStarters % 9) + targetCol - this.scrollCursor * 9); } else { - this.setCursor(Math.max(numberOfStarters - (numberOfStarters) % 9 + targetCol - 9 - this.scrollCursor * 9, 0)); + this.setCursor( + Math.max(numberOfStarters - (numberOfStarters % 9) + targetCol - 9 - this.scrollCursor * 9, 0), + ); } success = true; } @@ -980,7 +1064,7 @@ export default class PokedexUiHandler extends MessageUiHandler { if (this.filterBar.openDropDown) { success = this.filterBar.incDropDownCursor(); } else if (numberOfStarters > 0) { - // DOWN from filter bar to top of Pokemon list + // DOWN from filter bar to top of Pokemon list this.setFilterMode(false); this.scrollCursor = 0; this.updateScroll(); @@ -1054,9 +1138,9 @@ export default class PokedexUiHandler extends MessageUiHandler { } else { const targetCol = this.trayCursor; if (numberOfForms % 9 > targetCol) { - success = this.setTrayCursor(numberOfForms - (numberOfForms) % 9 + targetCol); + success = this.setTrayCursor(numberOfForms - (numberOfForms % 9) + targetCol); } else { - success = this.setTrayCursor(Math.max(numberOfForms - (numberOfForms) % 9 + targetCol - 9, 0)); + success = this.setTrayCursor(Math.max(numberOfForms - (numberOfForms % 9) + targetCol - 9, 0)); } } break; @@ -1071,7 +1155,9 @@ export default class PokedexUiHandler extends MessageUiHandler { if (this.trayCursor % 9 !== 0) { success = this.setTrayCursor(this.trayCursor - 1); } else { - success = this.setTrayCursor(currentTrayRow < numOfRows - 1 ? (currentTrayRow + 1) * maxColumns - 1 : numberOfForms - 1); + success = this.setTrayCursor( + currentTrayRow < numOfRows - 1 ? (currentTrayRow + 1) * maxColumns - 1 : numberOfForms - 1, + ); } break; case Button.RIGHT: @@ -1108,8 +1194,10 @@ export default class PokedexUiHandler extends MessageUiHandler { } break; case Button.DOWN: - if ((currentRow < numOfRows - 1) && (this.cursor + 9 < this.filteredPokemonData.length)) { // not last row - if (currentRow - this.scrollCursor === 8) { // last row of visible pokemon + if (currentRow < numOfRows - 1 && this.cursor + 9 < this.filteredPokemonData.length) { + // not last row + if (currentRow - this.scrollCursor === 8) { + // last row of visible pokemon this.scrollCursor++; this.updateScroll(); success = this.setCursor(this.cursor); @@ -1117,12 +1205,12 @@ export default class PokedexUiHandler extends MessageUiHandler { success = this.setCursor(this.cursor + 9); } } else if (numOfRows > 1) { - // DOWN from last row of pokemon > Wrap around to first row + // DOWN from last row of pokemon > Wrap around to first row this.scrollCursor = 0; this.updateScroll(); success = this.setCursor(this.cursor % 9); } else { - // DOWN from single row of pokemon > Go to filters + // DOWN from single row of pokemon > Go to filters this.filterBarCursor = this.filterBar.getNearestFilter(this.pokemonContainers[this.cursor]); this.setFilterMode(true); success = true; @@ -1132,7 +1220,7 @@ export default class PokedexUiHandler extends MessageUiHandler { if (this.cursor % 9 !== 0) { success = this.setCursor(this.cursor - 1); } else { - // LEFT from filtered pokemon, on the left edge + // LEFT from filtered pokemon, on the left edge this.filterTextCursor = this.filterText.getNearestFilter(this.pokemonContainers[this.cursor]); this.setFilterTextMode(true); success = true; @@ -1143,18 +1231,19 @@ export default class PokedexUiHandler extends MessageUiHandler { if (this.cursor % 9 < (currentRow < numOfRows - 1 ? 8 : (numberOfStarters - 1) % 9)) { success = this.setCursor(this.cursor + 1); } else { - // RIGHT from filtered pokemon, on the right edge + // RIGHT from filtered pokemon, on the right edge this.filterTextCursor = this.filterText.getNearestFilter(this.pokemonContainers[this.cursor]); this.setFilterTextMode(true); success = true; } break; - case Button.CYCLE_FORM: + case Button.CYCLE_FORM: { const species = this.pokemonContainers[this.cursor].species; if (this.canShowFormTray) { success = this.openFormTray(species); } break; + } } } } @@ -1169,6 +1258,7 @@ export default class PokedexUiHandler extends MessageUiHandler { } updateButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void { + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let iconPath; // touch controls cannot be rebound as is, and are just emulating a keyboard event. // Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls @@ -1196,6 +1286,7 @@ export default class PokedexUiHandler extends MessageUiHandler { } updateFilterButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void { + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let iconPath; // touch controls cannot be rebound as is, and are just emulating a keyboard event. // Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls @@ -1222,12 +1313,14 @@ export default class PokedexUiHandler extends MessageUiHandler { // Returns true if one of the forms has the requested move hasFormLevelMove(form: PokemonForm, selectedMove: string): boolean { - if (!pokemonFormLevelMoves.hasOwnProperty(form.speciesId) || !pokemonFormLevelMoves[form.speciesId].hasOwnProperty(form.formIndex)) { + if ( + !pokemonFormLevelMoves.hasOwnProperty(form.speciesId) || + !pokemonFormLevelMoves[form.speciesId].hasOwnProperty(form.formIndex) + ) { return false; - } else { - const levelMoves = pokemonFormLevelMoves[form.speciesId][form.formIndex].map(m => allMoves[m[1]].name); - return levelMoves.includes(selectedMove); } + const levelMoves = pokemonFormLevelMoves[form.speciesId][form.formIndex].map(m => allMoves[m[1]].name); + return levelMoves.includes(selectedMove); } updateStarters = () => { @@ -1242,17 +1335,21 @@ export default class PokedexUiHandler extends MessageUiHandler { this.filteredPokemonData = []; this.allSpecies.forEach(species => { - const starterId = this.getStarterSpeciesId(species.speciesId); const currentDexAttr = this.getCurrentDexProps(species.speciesId); const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(species, currentDexAttr)); - const data: ContainerData = { species: species, cost: globalScene.gameData.getSpeciesStarterValue(starterId), props: props }; + const data: ContainerData = { + species: species, + cost: globalScene.gameData.getSpeciesStarterValue(starterId), + props: props, + }; // First, ensure you have the caught attributes for the species else default to bigint 0 // TODO: This might be removed depending on how accessible we want the pokedex function to be - const caughtAttr = (globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0)) & + const caughtAttr = + (globalScene.gameData.dexData[species.speciesId]?.caughtAttr || BigInt(0)) & (globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)]?.caughtAttr || BigInt(0)) & species.getFullUnlocksData(); const starterData = globalScene.gameData.starterData[starterId]; @@ -1306,22 +1403,29 @@ export default class PokedexUiHandler extends MessageUiHandler { } // Ability filter - const abilities = [ species.ability1, species.ability2, species.abilityHidden ].map(a => allAbilities[a].name); - const passives = starterPassiveAbilities[starterId] ?? {} as PassiveAbilities; + const abilities = [species.ability1, species.ability2, species.abilityHidden].map(a => allAbilities[a].name); + const passives = starterPassiveAbilities[starterId] ?? ({} as PassiveAbilities); const selectedAbility1 = this.filterText.getValue(FilterTextRow.ABILITY_1); - const fitsFormAbility1 = species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility1)); - const fitsAbility1 = abilities.includes(selectedAbility1) || fitsFormAbility1 || selectedAbility1 === this.filterText.defaultText; + const fitsFormAbility1 = species.forms.some(form => + [form.ability1, form.ability2, form.abilityHidden].map(a => allAbilities[a].name).includes(selectedAbility1), + ); + const fitsAbility1 = + abilities.includes(selectedAbility1) || fitsFormAbility1 || selectedAbility1 === this.filterText.defaultText; const fitsPassive1 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility1); const selectedAbility2 = this.filterText.getValue(FilterTextRow.ABILITY_2); - const fitsFormAbility2 = species.forms.some(form => [ form.ability1, form.ability2, form.abilityHidden ].map(a => allAbilities[a].name).includes(selectedAbility2)); - const fitsAbility2 = abilities.includes(selectedAbility2) || fitsFormAbility2 || selectedAbility2 === this.filterText.defaultText; + const fitsFormAbility2 = species.forms.some(form => + [form.ability1, form.ability2, form.abilityHidden].map(a => allAbilities[a].name).includes(selectedAbility2), + ); + const fitsAbility2 = + abilities.includes(selectedAbility2) || fitsFormAbility2 || selectedAbility2 === this.filterText.defaultText; const fitsPassive2 = Object.values(passives).some(p => allAbilities[p].name === selectedAbility2); // If both fields have been set to the same ability, show both ability and passive - const fitsAbilities = (fitsAbility1 && (fitsPassive2 || selectedAbility2 === this.filterText.defaultText)) || - (fitsAbility2 && (fitsPassive1 || selectedAbility1 === this.filterText.defaultText)); + const fitsAbilities = + (fitsAbility1 && (fitsPassive2 || selectedAbility2 === this.filterText.defaultText)) || + (fitsAbility2 && (fitsPassive1 || selectedAbility1 === this.filterText.defaultText)); if (fitsPassive1 || fitsPassive2) { if (fitsPassive1) { @@ -1343,13 +1447,15 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(species.generation); // Type filter - const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => species.isOfType((type as number) - 1)); + const fitsType = this.filterBar + .getVals(DropDownColumn.TYPES) + .some(type => species.isOfType((type as number) - 1)); // Biome filter const indexToBiome = new Map( Object.values(Biome) - .map((value, index) => (typeof value === "string" ? [ index, value ] : undefined)) - .filter((entry): entry is [number, string] => entry !== undefined) + .map((value, index) => (typeof value === "string" ? [index, value] : undefined)) + .filter((entry): entry is [number, string] => entry !== undefined), ); indexToBiome.set(35, "Uncatchable"); @@ -1359,9 +1465,10 @@ export default class PokedexUiHandler extends MessageUiHandler { if (biomes.length === 0) { biomes.push("Uncatchable"); } - const showNoBiome = (biomes.length === 0 && this.filterBar.getVals(DropDownColumn.BIOME).length === 36) ? true : false; - const fitsBiome = this.filterBar.getVals(DropDownColumn.BIOME).some(item => biomes.includes(indexToBiome.get(item) ?? "")) || showNoBiome; - + const showNoBiome = !!(biomes.length === 0 && this.filterBar.getVals(DropDownColumn.BIOME).length === 36); + const fitsBiome = + this.filterBar.getVals(DropDownColumn.BIOME).some(item => biomes.includes(indexToBiome.get(item) ?? "")) || + showNoBiome; // Caught / Shiny filter const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY); @@ -1373,13 +1480,17 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsCaught = this.filterBar.getVals(DropDownColumn.CAUGHT).some(caught => { if (caught === "SHINY3") { return isVariant3Caught; - } else if (caught === "SHINY2") { + } + if (caught === "SHINY2") { return isVariant2Caught && !isVariant3Caught; - } else if (caught === "SHINY") { + } + if (caught === "SHINY") { return isVariant1Caught && !isVariant2Caught && !isVariant3Caught; - } else if (caught === "NORMAL") { + } + if (caught === "NORMAL") { return isNonShinyCaught && !isVariant1Caught && !isVariant2Caught && !isVariant3Caught; - } else if (caught === "UNCAUGHT") { + } + if (caught === "UNCAUGHT") { return isUncaught; } }); @@ -1390,11 +1501,14 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsPassive = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => { if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.ON) { return isPassiveUnlocked; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.EXCLUDE) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.EXCLUDE) { return isStarterProgressable && !isPassiveUnlocked; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.UNLOCKABLE) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.UNLOCKABLE) { return isPassiveUnlockable; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.OFF) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.OFF) { return true; } }); @@ -1406,15 +1520,20 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => { if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) { return isCostReducedByOne || isCostReducedByTwo; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ONE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ONE) { return isCostReducedByOne; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.TWO) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.TWO) { return isCostReducedByTwo; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) { return isStarterProgressable && !(isCostReducedByOne || isCostReducedByTwo); - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.UNLOCKABLE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.UNLOCKABLE) { return isCostReductionUnlockable; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) { return true; } }); @@ -1454,22 +1573,27 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsWin = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "WIN" && misc.state === DropDownState.ON) { return hasWon; - } else if (misc.val === "WIN" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "WIN" && misc.state === DropDownState.EXCLUDE) { return hasNotWon || isUndefined; - } else if (misc.val === "WIN" && misc.state === DropDownState.OFF) { + } + if (misc.val === "WIN" && misc.state === DropDownState.OFF) { return true; } }); // HA Filter - const speciesHasHiddenAbility = species.abilityHidden !== species.ability1 && species.abilityHidden !== Abilities.NONE; + const speciesHasHiddenAbility = + species.abilityHidden !== species.ability1 && species.abilityHidden !== Abilities.NONE; const hasHA = starterData.abilityAttr & AbilityAttr.ABILITY_HIDDEN; const fitsHA = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.ON) { return hasHA; - } else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.EXCLUDE) { return speciesHasHiddenAbility && !hasHA; - } else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.OFF) { + } + if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.OFF) { return true; } }); @@ -1479,9 +1603,11 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsEgg = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "EGG" && misc.state === DropDownState.ON) { return isEggPurchasable; - } else if (misc.val === "EGG" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "EGG" && misc.state === DropDownState.EXCLUDE) { return isStarterProgressable && !isEggPurchasable; - } else if (misc.val === "EGG" && misc.state === DropDownState.OFF) { + } + if (misc.val === "EGG" && misc.state === DropDownState.OFF) { return true; } }); @@ -1490,14 +1616,32 @@ export default class PokedexUiHandler extends MessageUiHandler { const fitsPokerus = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "POKERUS" && misc.state === DropDownState.ON) { return this.pokerusSpecies.includes(species); - } else if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) { return !this.pokerusSpecies.includes(species); - } else if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) { + } + if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) { return true; } }); - if (fitsName && fitsAbilities && fitsMoves && fitsGen && fitsBiome && fitsType && fitsCaught && fitsPassive && fitsCostReduction && fitsStarter && fitsFavorite && fitsWin && fitsHA && fitsEgg && fitsPokerus) { + if ( + fitsName && + fitsAbilities && + fitsMoves && + fitsGen && + fitsBiome && + fitsType && + fitsCaught && + fitsPassive && + fitsCostReduction && + fitsStarter && + fitsFavorite && + fitsWin && + fitsHA && + fitsEgg && + fitsPokerus + ) { this.filteredPokemonData.push(data); } }); @@ -1509,26 +1653,42 @@ export default class PokedexUiHandler extends MessageUiHandler { const sort = this.filterBar.getVals(DropDownColumn.SORT)[0]; this.filteredPokemonData.sort((a, b) => { switch (sort.val) { - default: - break; case SortCriteria.NUMBER: return (a.species.speciesId - b.species.speciesId) * -sort.dir; case SortCriteria.COST: return (a.cost - b.cost) * -sort.dir; - case SortCriteria.CANDY: - const candyCountA = globalScene.gameData.starterData[this.getStarterSpeciesId(a.species.speciesId)].candyCount; - const candyCountB = globalScene.gameData.starterData[this.getStarterSpeciesId(b.species.speciesId)].candyCount; + case SortCriteria.CANDY: { + const candyCountA = + globalScene.gameData.starterData[this.getStarterSpeciesId(a.species.speciesId)].candyCount; + const candyCountB = + globalScene.gameData.starterData[this.getStarterSpeciesId(b.species.speciesId)].candyCount; return (candyCountA - candyCountB) * -sort.dir; - case SortCriteria.IV: - const avgIVsA = globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[a.species.speciesId].ivs.length; - const avgIVsB = globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[b.species.speciesId].ivs.length; + } + case SortCriteria.IV: { + const avgIVsA = + globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / + globalScene.gameData.dexData[a.species.speciesId].ivs.length; + const avgIVsB = + globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / + globalScene.gameData.dexData[b.species.speciesId].ivs.length; return (avgIVsA - avgIVsB) * -sort.dir; + } case SortCriteria.NAME: return a.species.name.localeCompare(b.species.name) * -sort.dir; case SortCriteria.CAUGHT: - return (globalScene.gameData.dexData[a.species.speciesId].caughtCount - globalScene.gameData.dexData[b.species.speciesId].caughtCount) * -sort.dir; + return ( + (globalScene.gameData.dexData[a.species.speciesId].caughtCount - + globalScene.gameData.dexData[b.species.speciesId].caughtCount) * + -sort.dir + ); case SortCriteria.HATCHED: - return (globalScene.gameData.dexData[this.getStarterSpeciesId(a.species.speciesId)].hatchedCount - globalScene.gameData.dexData[this.getStarterSpeciesId(b.species.speciesId)].hatchedCount) * -sort.dir; + return ( + (globalScene.gameData.dexData[this.getStarterSpeciesId(a.species.speciesId)].hatchedCount - + globalScene.gameData.dexData[this.getStarterSpeciesId(b.species.speciesId)].hatchedCount) * + -sort.dir + ); + default: + break; } return 0; }); @@ -1548,7 +1708,6 @@ export default class PokedexUiHandler extends MessageUiHandler { let pokerusCursorIndex = 0; this.pokemonContainers.forEach((container, i) => { - const i_data = i + onScreenFirstIndex; if (i_data >= this.filteredPokemonData.length) { @@ -1562,14 +1721,20 @@ export default class PokedexUiHandler extends MessageUiHandler { container.setSpecies(data.species, props); const starterSprite = container.icon as Phaser.GameObjects.Sprite; - starterSprite.setTexture(data.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), container.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant)); + starterSprite.setTexture( + data.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), + container.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant), + ); container.checkIconId(props.female, props.formIndex, props.shiny, props.variant); const speciesId = data.species.speciesId; const dexEntry = globalScene.gameData.dexData[speciesId]; - const caughtAttr = dexEntry.caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & data.species.getFullUnlocksData(); + const caughtAttr = + dexEntry.caughtAttr & + globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & + data.species.getFullUnlocksData(); - if ((caughtAttr & data.species.getFullUnlocksData()) || globalScene.dexForDevs) { + if (caughtAttr & data.species.getFullUnlocksData() || globalScene.dexForDevs) { container.icon.clearTint(); } else if (dexEntry.seenAttr) { container.icon.setTint(0x808080); @@ -1609,7 +1774,6 @@ export default class PokedexUiHandler extends MessageUiHandler { } if (this.showDecorations) { - if (this.pokerusSpecies.includes(data.species)) { this.pokerusCursorObjs[pokerusCursorIndex].setPosition(container.x - 1, container.y + 1); this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true); @@ -1619,34 +1783,47 @@ export default class PokedexUiHandler extends MessageUiHandler { this.updateStarterValueLabel(container); container.label.setVisible(true); - const speciesVariants = speciesId && caughtAttr & DexAttr.SHINY - ? [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => !!(caughtAttr & v)) - : []; + const speciesVariants = + speciesId && caughtAttr & DexAttr.SHINY + ? [DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3].filter(v => !!(caughtAttr & v)) + : []; for (let v = 0; v < 3; v++) { const hasVariant = speciesVariants.length > v; container.shinyIcons[v].setVisible(hasVariant); if (hasVariant) { - container.shinyIcons[v].setTint(getVariantTint(speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2)); + container.shinyIcons[v].setTint( + getVariantTint( + speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2, + ), + ); } } - container.starterPassiveBgs.setVisible(!!globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr); - container.hiddenAbilityIcon.setVisible(!!caughtAttr && !!(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4)); - container.classicWinIcon.setVisible(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0); + container.starterPassiveBgs.setVisible( + !!globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].passiveAttr, + ); + container.hiddenAbilityIcon.setVisible( + !!caughtAttr && !!(globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].abilityAttr & 4), + ); + container.classicWinIcon.setVisible( + globalScene.gameData.starterData[this.getStarterSpeciesId(speciesId)].classicWinCount > 0, + ); container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false); // 'Candy Icon' mode if (globalScene.candyUpgradeDisplay === 0) { - if (!starterColors[this.getStarterSpeciesId(speciesId)]) { // Default to white if no colors are found - starterColors[this.getStarterSpeciesId(speciesId)] = [ "ffffff", "ffffff" ]; + starterColors[this.getStarterSpeciesId(speciesId)] = ["ffffff", "ffffff"]; } // Set the candy colors - container.candyUpgradeIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][0]))); - container.candyUpgradeOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][1]))); - + container.candyUpgradeIcon.setTint( + argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][0])), + ); + container.candyUpgradeOverlayIcon.setTint( + argbFromRgba(rgbHexToRgba(starterColors[this.getStarterSpeciesId(speciesId)][1])), + ); } else if (globalScene.candyUpgradeDisplay === 1) { container.candyUpgradeIcon.setVisible(false); container.candyUpgradeOverlayIcon.setVisible(false); @@ -1735,7 +1912,6 @@ export default class PokedexUiHandler extends MessageUiHandler { } openFormTray(species: PokemonSpecies): boolean { - this.trayForms = species.forms.filter(f => !f.isUnobtainable); this.trayNumIcons = this.trayForms.length; @@ -1753,12 +1929,8 @@ export default class PokedexUiHandler extends MessageUiHandler { const goLeft = this.trayColumns <= spaceRight ? 0 : 1; this.trayBg.setSize(13 + this.trayColumns * 17, 8 + this.trayRows * 18); - this.formTrayContainer.setX( - (goLeft ? boxPos.x - 18 * (this.trayColumns - spaceRight) : boxPos.x) - 3 - ); - this.formTrayContainer.setY( - goUp ? boxPos.y - this.trayBg.height : boxPos.y + 17 - ); + this.formTrayContainer.setX((goLeft ? boxPos.x - 18 * (this.trayColumns - spaceRight) : boxPos.x) - 3); + this.formTrayContainer.setY(goUp ? boxPos.y - this.trayBg.height : boxPos.y + 17); const dexEntry = globalScene.gameData.dexData[species.speciesId]; const dexAttr = this.getCurrentDexProps(species.speciesId); @@ -1766,9 +1938,18 @@ export default class PokedexUiHandler extends MessageUiHandler { this.trayContainers = []; this.trayForms.map((f, index) => { - const isFormCaught = dexEntry ? (dexEntry.caughtAttr & species.getFullUnlocksData() & globalScene.gameData.getFormAttr(f.formIndex ?? 0)) > 0n : false; - const isFormSeen = dexEntry ? (dexEntry.seenAttr & globalScene.gameData.getFormAttr(f.formIndex ?? 0)) > 0n : false; - const formContainer = new PokedexMonContainer(species, { formIndex: f.formIndex, female: props.female, shiny: props.shiny, variant: props.variant }); + const isFormCaught = dexEntry + ? (dexEntry.caughtAttr & species.getFullUnlocksData() & globalScene.gameData.getFormAttr(f.formIndex ?? 0)) > 0n + : false; + const isFormSeen = dexEntry + ? (dexEntry.seenAttr & globalScene.gameData.getFormAttr(f.formIndex ?? 0)) > 0n + : false; + const formContainer = new PokedexMonContainer(species, { + formIndex: f.formIndex, + female: props.female, + shiny: props.shiny, + variant: props.variant, + }); this.iconAnimHandler.addOrUpdate(formContainer.icon, PokemonIconAnimMode.NONE); // Setting tint, for all saves some caught forms may only show up as seen if (isFormCaught || globalScene.dexForDevs) { @@ -1796,7 +1977,6 @@ export default class PokedexUiHandler extends MessageUiHandler { } closeFormTray(): boolean { - this.trayContainers.forEach(obj => { this.formTrayContainer.remove(obj, true); // Removes from container and destroys it }); @@ -1868,7 +2048,6 @@ export default class PokedexUiHandler extends MessageUiHandler { } setSpecies(species: PokemonSpecies | null) { - this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null; if (!species && globalScene.ui.getTooltip().visible) { @@ -1883,14 +2062,15 @@ export default class PokedexUiHandler extends MessageUiHandler { this.lastSpecies = species; } - if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs)) { - + if ( + species && + (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) + ) { this.pokemonNumberText.setText(i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4)); this.pokemonNameText.setText(species.name); if (this.speciesStarterDexEntry?.caughtAttr || globalScene.dexForDevs) { - this.startIconAnimation(this.cursor); const speciesForm = getPokemonSpeciesForm(species.speciesId, 0); @@ -1910,7 +2090,9 @@ export default class PokedexUiHandler extends MessageUiHandler { this.pokemonSprite.setTint(0x808080); } } else { - this.pokemonNumberText.setText(species ? i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4) : ""); + this.pokemonNumberText.setText( + species ? i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4) : "", + ); this.pokemonNameText.setText(species ? "???" : ""); this.pokemonFormText.setText(""); this.type1Icon.setVisible(false); @@ -1946,10 +2128,15 @@ export default class PokedexUiHandler extends MessageUiHandler { if (species) { const dexEntry = globalScene.gameData.dexData[species.speciesId]; - const caughtAttr = dexEntry.caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)].caughtAttr & species.getFullUnlocksData(); + const caughtAttr = + dexEntry.caughtAttr & + globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)].caughtAttr & + species.getFullUnlocksData(); if (caughtAttr) { - const props = this.getSanitizedProps(globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId))); + const props = this.getSanitizedProps( + globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), + ); if (shiny === undefined) { shiny = props.shiny; @@ -1972,7 +2159,8 @@ export default class PokedexUiHandler extends MessageUiHandler { this.assetLoadCancelled = assetLoadCancelled; if (shouldUpdateSprite) { - species.loadAssets(female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct? + species.loadAssets(female!, formIndex, shiny, variant, true).then(() => { + // TODO: is this bang correct? if (assetLoadCancelled.value) { return; } @@ -2020,16 +2208,14 @@ export default class PokedexUiHandler extends MessageUiHandler { this.showFormTrayLabel.setVisible(true); } this.canShowFormTray = true; - } else { + } else { this.showFormTrayIconElement.setVisible(false); this.showFormTrayLabel.setVisible(false); this.canShowFormTray = false; } - } else { this.setTypeIcons(null, null); } - } setTypeIcons(type1: PokemonType | null, type2: PokemonType | null): void { @@ -2086,18 +2272,24 @@ export default class PokedexUiHandler extends MessageUiHandler { this.blockInput = false; }; ui.showText(i18next.t("pokedexUiHandler:confirmExit"), null, () => { - ui.setModeWithoutClear(Mode.CONFIRM, () => { - ui.setMode(Mode.POKEDEX, "refresh"); - this.clearText(); - this.clear(); - ui.revertMode(); - }, cancel, null, null, 19); + ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + ui.setMode(Mode.POKEDEX, "refresh"); + this.clearText(); + this.clear(); + ui.revertMode(); + }, + cancel, + null, + null, + 19, + ); }); return true; } - /** * Creates a temporary dex attr props that will be used to * display the correct shiny, variant, and form based on the StarterPreferences @@ -2108,13 +2300,19 @@ export default class PokedexUiHandler extends MessageUiHandler { getCurrentDexProps(speciesId: number): bigint { let props = 0n; const species = allSpecies.find(sp => sp.speciesId === speciesId); - const caughtAttr = globalScene.gameData.dexData[speciesId].caughtAttr & globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & (species?.getFullUnlocksData() ?? 0n); + const caughtAttr = + globalScene.gameData.dexData[speciesId].caughtAttr & + globalScene.gameData.dexData[this.getStarterSpeciesId(speciesId)].caughtAttr & + (species?.getFullUnlocksData() ?? 0n); /* this checks the gender of the pokemon; this works by checking a) that the starter preferences for the species exist, and if so, is it female. If so, it'll add DexAttr.FEMALE to our temp props * It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props * If neither of these pass, we add DexAttr.MALE to our temp props */ - if (this.starterPreferences[speciesId]?.female || ((caughtAttr & DexAttr.FEMALE) > 0n && (caughtAttr & DexAttr.MALE) === 0n)) { + if ( + this.starterPreferences[speciesId]?.female || + ((caughtAttr & DexAttr.FEMALE) > 0n && (caughtAttr & DexAttr.MALE) === 0n) + ) { props += DexAttr.FEMALE; } else { props += DexAttr.MALE; @@ -2122,7 +2320,10 @@ export default class PokedexUiHandler extends MessageUiHandler { /* This part is very similar to above, but instead of for gender, it checks for shiny within starter preferences. * If they're not there, it enables shiny state by default if any shiny was caught */ - if (this.starterPreferences[speciesId]?.shiny || ((caughtAttr & DexAttr.SHINY) > 0n && this.starterPreferences[speciesId]?.shiny !== false)) { + if ( + this.starterPreferences[speciesId]?.shiny || + ((caughtAttr & DexAttr.SHINY) > 0n && this.starterPreferences[speciesId]?.shiny !== false) + ) { props += DexAttr.SHINY; if (this.starterPreferences[speciesId]?.variant !== undefined) { props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.variant)) * DexAttr.DEFAULT_VARIANT; @@ -2142,7 +2343,8 @@ export default class PokedexUiHandler extends MessageUiHandler { props += DexAttr.NON_SHINY; props += DexAttr.DEFAULT_VARIANT; // we add the default variant here because non shiny versions are listed as default variant } - if (this.starterPreferences[speciesId]?.form) { // this checks for the form of the pokemon + if (this.starterPreferences[speciesId]?.form) { + // this checks for the form of the pokemon props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM; } else { // Get the first unlocked form @@ -2173,9 +2375,18 @@ export default class PokedexUiHandler extends MessageUiHandler { this.blockInput = false; } - checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female: boolean, formIndex: number, shiny: boolean, variant: number) { + checkIconId( + icon: Phaser.GameObjects.Sprite, + species: PokemonSpecies, + female: boolean, + formIndex: number, + shiny: boolean, + variant: number, + ) { if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) { - console.log(`${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`); + console.log( + `${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`, + ); icon.setTexture(species.getIconAtlasKey(formIndex, false, variant)); icon.setFrame(species.getIconId(female, formIndex, false, variant)); } diff --git a/src/ui/pokemon-hatch-info-container.ts b/src/ui/pokemon-hatch-info-container.ts index eb0e0ed909b..99940b92351 100644 --- a/src/ui/pokemon-hatch-info-container.ts +++ b/src/ui/pokemon-hatch-info-container.ts @@ -26,16 +26,15 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { private pokemonEggMoveContainers: Phaser.GameObjects.Container[]; private pokemonEggMoveBgs: Phaser.GameObjects.NineSlice[]; private pokemonEggMoveLabels: Phaser.GameObjects.Text[]; - private pokemonHatchedIcon : Phaser.GameObjects.Sprite; + private pokemonHatchedIcon: Phaser.GameObjects.Sprite; private pokemonListContainer: Phaser.GameObjects.Container; private pokemonCandyIcon: Phaser.GameObjects.Sprite; private pokemonCandyOverlayIcon: Phaser.GameObjects.Sprite; private pokemonCandyCountText: Phaser.GameObjects.Text; - constructor(listContainer : Phaser.GameObjects.Container, x: number = 115, y: number = 9,) { + constructor(listContainer: Phaser.GameObjects.Container, x = 115, y = 9) { super(x, y); this.pokemonListContainer = listContainer; - } setup(): void { super.setup(); @@ -43,7 +42,10 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { this.currentPokemonSprite = globalScene.add.sprite(54, 80, "pkmn__sub"); this.currentPokemonSprite.setScale(0.8); - this.currentPokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + this.currentPokemonSprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); this.pokemonListContainer.add(this.currentPokemonSprite); // setup name and number @@ -51,7 +53,9 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { this.pokemonNumberText.setOrigin(0, 0); this.pokemonListContainer.add(this.pokemonNumberText); - this.pokemonNameText = addTextObject(7, 107.5, "", TextStyle.SUMMARY, { fontSize: 74 }); + this.pokemonNameText = addTextObject(7, 107.5, "", TextStyle.SUMMARY, { + fontSize: 74, + }); this.pokemonNameText.setOrigin(0, 0); this.pokemonListContainer.add(this.pokemonNameText); @@ -105,7 +109,6 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { } super.add(this.pokemonEggMoveContainers); - } /** @@ -127,7 +130,6 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { const variant = pokemon.variant; this.currentPokemonSprite.setVisible(false); species.loadAssets(female, formIndex, shiny, variant, true).then(() => { - getPokemonSpeciesForm(species.speciesId, pokemon.formIndex).cry(); this.currentPokemonSprite.play(species.getSpriteKey(female, formIndex, shiny, variant)); this.currentPokemonSprite.setPipelineData("shiny", shiny); @@ -167,7 +169,9 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { for (let em = 0; em < 4; em++) { const eggMove = hasEggMoves ? allMoves[speciesEggMoves[species.speciesId][em]] : null; const eggMoveUnlocked = eggMove && globalScene.gameData.starterData[species.speciesId].eggMoves & Math.pow(2, em); - this.pokemonEggMoveBgs[em].setFrame(PokemonType[eggMove ? eggMove.type : PokemonType.UNKNOWN].toString().toLowerCase()); + this.pokemonEggMoveBgs[em].setFrame( + PokemonType[eggMove ? eggMove.type : PokemonType.UNKNOWN].toString().toLowerCase(), + ); this.pokemonEggMoveLabels[em].setText(eggMove && eggMoveUnlocked ? eggMove.name : "???"); if (!(eggMove && hatchInfo.starterDataEntryBeforeUpdate.eggMoves & Math.pow(2, em)) && eggMoveUnlocked) { @@ -183,7 +187,5 @@ export default class PokemonHatchInfoContainer extends PokemonInfoContainer { } else { this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species)); } - } - } diff --git a/src/ui/pokemon-icon-anim-handler.ts b/src/ui/pokemon-icon-anim-handler.ts index 010d23315f2..c84ee2a0f9a 100644 --- a/src/ui/pokemon-icon-anim-handler.ts +++ b/src/ui/pokemon-icon-anim-handler.ts @@ -4,7 +4,7 @@ import * as Utils from "../utils"; export enum PokemonIconAnimMode { NONE, PASSIVE, - ACTIVE + ACTIVE, } type PokemonIcon = Phaser.GameObjects.Container | Phaser.GameObjects.Sprite; @@ -33,7 +33,7 @@ export default class PokemonIconAnimHandler { yoyo: true, repeat: -1, onRepeat: onAlternate, - onYoyo: onAlternate + onYoyo: onAlternate, }); } @@ -50,16 +50,14 @@ export default class PokemonIconAnimHandler { addOrUpdate(icons: PokemonIcon | PokemonIcon[], mode: PokemonIconAnimMode): void { if (!Array.isArray(icons)) { - icons = [ icons ]; + icons = [icons]; } for (const i of icons) { if (this.icons.has(i) && this.icons.get(i) === mode) { continue; } if (this.toggled) { - const lastYDelta = this.icons.has(i) - ? this.icons.get(i)! - : 0; + const lastYDelta = this.icons.has(i) ? this.icons.get(i)! : 0; const yDelta = this.getModeYDelta(mode); i.y += yDelta + lastYDelta; } @@ -69,7 +67,7 @@ export default class PokemonIconAnimHandler { remove(icons: PokemonIcon | PokemonIcon[]): void { if (!Array.isArray(icons)) { - icons = [ icons ]; + icons = [icons]; } for (const i of icons) { if (this.toggled) { diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 7e2932fecf9..64c743ec88d 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -21,7 +21,7 @@ interface LanguageSetting { } const languageSettings: { [key: string]: LanguageSetting } = { - "pt": { + pt: { infoContainerTextSize: "60px", infoContainerLabelXPos: -15, infoContainerTextXPos: -12, @@ -57,7 +57,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { public shown: boolean; - constructor(x: number = 372, y: number = 66) { + constructor(x = 372, y = 66) { super(globalScene, x, y); this.initialX = x; } @@ -85,7 +85,13 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { movesBg.setName("window-moves-bg"); this.pokemonMovesContainer.add(movesBg); - const movesLabel = addTextObject(-movesBg.width / 2, 6, i18next.t("pokemonInfoContainer:moveset"), TextStyle.WINDOW, { fontSize: "64px" }); + const movesLabel = addTextObject( + -movesBg.width / 2, + 6, + i18next.t("pokemonInfoContainer:moveset"), + TextStyle.WINDOW, + { fontSize: "64px" }, + ); movesLabel.setOrigin(0.5, 0); movesLabel.setName("text-moves"); this.pokemonMovesContainer.add(movesLabel); @@ -127,44 +133,74 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { // The font size should be set by language const infoContainerTextSize = textSettings?.infoContainerTextSize || "64px"; - this.pokemonFormLabelText = addTextObject(infoContainerLabelXPos, 19, i18next.t("pokemonInfoContainer:form"), TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonFormLabelText = addTextObject( + infoContainerLabelXPos, + 19, + i18next.t("pokemonInfoContainer:form"), + TextStyle.WINDOW, + { fontSize: infoContainerTextSize }, + ); this.pokemonFormLabelText.setOrigin(1, 0); this.pokemonFormLabelText.setVisible(false); this.add(this.pokemonFormLabelText); - this.pokemonFormText = addTextObject(infoContainerTextXPos, 19, "", TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonFormText = addTextObject(infoContainerTextXPos, 19, "", TextStyle.WINDOW, { + fontSize: infoContainerTextSize, + }); this.pokemonFormText.setOrigin(0, 0); this.pokemonFormText.setVisible(false); this.add(this.pokemonFormText); - this.pokemonGenderText = addTextObject(-42, -61, "", TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonGenderText = addTextObject(-42, -61, "", TextStyle.WINDOW, { + fontSize: infoContainerTextSize, + }); this.pokemonGenderText.setOrigin(0, 0); this.pokemonGenderText.setVisible(false); this.pokemonGenderText.setName("text-pkmn-gender"); this.add(this.pokemonGenderText); - this.pokemonGenderNewText = addTextObject(-36, -61, "", TextStyle.WINDOW, { fontSize: "64px" }); + this.pokemonGenderNewText = addTextObject(-36, -61, "", TextStyle.WINDOW, { + fontSize: "64px", + }); this.pokemonGenderNewText.setOrigin(0, 0); this.pokemonGenderNewText.setVisible(false); this.pokemonGenderNewText.setName("text-pkmn-new-gender"); this.add(this.pokemonGenderNewText); - this.pokemonAbilityLabelText = addTextObject(infoContainerLabelXPos, 29, i18next.t("pokemonInfoContainer:ability"), TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonAbilityLabelText = addTextObject( + infoContainerLabelXPos, + 29, + i18next.t("pokemonInfoContainer:ability"), + TextStyle.WINDOW, + { fontSize: infoContainerTextSize }, + ); this.pokemonAbilityLabelText.setOrigin(1, 0); this.pokemonAbilityLabelText.setName("text-pkmn-ability-label"); this.add(this.pokemonAbilityLabelText); - this.pokemonAbilityText = addTextObject(infoContainerTextXPos, 29, "", TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonAbilityText = addTextObject(infoContainerTextXPos, 29, "", TextStyle.WINDOW, { + fontSize: infoContainerTextSize, + }); this.pokemonAbilityText.setOrigin(0, 0); this.pokemonAbilityText.setName("text-pkmn-ability"); this.add(this.pokemonAbilityText); - this.pokemonNatureLabelText = addTextObject(infoContainerLabelXPos, 39, i18next.t("pokemonInfoContainer:nature"), TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonNatureLabelText = addTextObject( + infoContainerLabelXPos, + 39, + i18next.t("pokemonInfoContainer:nature"), + TextStyle.WINDOW, + { fontSize: infoContainerTextSize }, + ); this.pokemonNatureLabelText.setOrigin(1, 0); this.pokemonNatureLabelText.setName("text-pkmn-nature-label"); this.add(this.pokemonNatureLabelText); - this.pokemonNatureText = addBBCodeTextObject(infoContainerTextXPos, 39, "", TextStyle.WINDOW, { fontSize: infoContainerTextSize, lineSpacing: 3, maxLines: 2 }); + this.pokemonNatureText = addBBCodeTextObject(infoContainerTextXPos, 39, "", TextStyle.WINDOW, { + fontSize: infoContainerTextSize, + lineSpacing: 3, + maxLines: 2, + }); this.pokemonNatureText.setOrigin(0, 0); this.pokemonNatureText.setName("text-pkmn-nature"); this.add(this.pokemonNatureText); @@ -176,13 +212,23 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonShinyIcon.setName("img-pkmn-shiny-icon"); this.add(this.pokemonShinyIcon); - this.pokemonShinyNewIcon = addTextObject(this.pokemonShinyIcon.x + 12, this.pokemonShinyIcon.y, "", TextStyle.WINDOW, { fontSize: infoContainerTextSize }); + this.pokemonShinyNewIcon = addTextObject( + this.pokemonShinyIcon.x + 12, + this.pokemonShinyIcon.y, + "", + TextStyle.WINDOW, + { fontSize: infoContainerTextSize }, + ); this.pokemonShinyNewIcon.setOrigin(0, 0); this.pokemonShinyNewIcon.setName("text-pkmn-shiny-new-icon"); this.add(this.pokemonShinyNewIcon); this.pokemonShinyNewIcon.setVisible(false); - this.pokemonFusionShinyIcon = globalScene.add.image(this.pokemonShinyIcon.x, this.pokemonShinyIcon.y, "shiny_star_2"); + this.pokemonFusionShinyIcon = globalScene.add.image( + this.pokemonShinyIcon.x, + this.pokemonShinyIcon.y, + "shiny_star_2", + ); this.pokemonFusionShinyIcon.setOrigin(0, 0); this.pokemonFusionShinyIcon.setScale(0.75); this.pokemonFusionShinyIcon.setName("img-pkmn-fusion-shiny-icon"); @@ -191,7 +237,14 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.setVisible(false); } - show(pokemon: Pokemon, showMoves: boolean = false, speedMultiplier: number = 1, dexEntry?: DexEntry, starterEntry?: StarterDataEntry, eggInfo = false): Promise { + show( + pokemon: Pokemon, + showMoves = false, + speedMultiplier = 1, + dexEntry?: DexEntry, + starterEntry?: StarterDataEntry, + eggInfo = false, + ): Promise { return new Promise(resolve => { if (!dexEntry) { dexEntry = globalScene.gameData.dexData[pokemon.species.speciesId]; @@ -232,9 +285,16 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonFormLabelText.setShadowColor(getTextColor(TextStyle.WINDOW, true, globalScene.uiTheme)); } - this.pokemonFormText.setText(formName.length > this.numCharsBeforeCutoff ? formName.substring(0, this.numCharsBeforeCutoff - 3) + "..." : formName); + this.pokemonFormText.setText( + formName.length > this.numCharsBeforeCutoff + ? `${formName.substring(0, this.numCharsBeforeCutoff - 3)}...` + : formName, + ); if (formName.length > this.numCharsBeforeCutoff) { - this.pokemonFormText.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.pokemonFormText.width, this.pokemonFormText.height), Phaser.Geom.Rectangle.Contains); + this.pokemonFormText.setInteractive( + new Phaser.Geom.Rectangle(0, 0, this.pokemonFormText.width, this.pokemonFormText.height), + Phaser.Geom.Rectangle.Contains, + ); this.pokemonFormText.on("pointerover", () => globalScene.ui.showTooltip("", formName, true)); this.pokemonFormText.on("pointerout", () => globalScene.ui.hideTooltip()); } else { @@ -283,10 +343,17 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonShinyIcon.setVisible(pokemon.isShiny()); this.pokemonShinyIcon.setTint(getVariantTint(baseVariant)); if (this.pokemonShinyIcon.visible) { - const shinyDescriptor = doubleShiny || baseVariant ? - `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` - : ""; - this.pokemonShinyIcon.on("pointerover", () => globalScene.ui.showTooltip("", `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`, true)); + const shinyDescriptor = + doubleShiny || baseVariant + ? `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` + : ""; + this.pokemonShinyIcon.on("pointerover", () => + globalScene.ui.showTooltip( + "", + `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`, + true, + ), + ); this.pokemonShinyIcon.on("pointerout", () => globalScene.ui.hideTooltip()); const newShiny = BigInt(1 << (pokemon.shiny ? 1 : 0)); @@ -295,9 +362,10 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonShinyNewIcon.setText("(+)"); this.pokemonShinyNewIcon.setColor(getTextColor(TextStyle.SUMMARY_BLUE, false, globalScene.uiTheme)); this.pokemonShinyNewIcon.setShadowColor(getTextColor(TextStyle.SUMMARY_BLUE, true, globalScene.uiTheme)); - const newShinyOrVariant = ((newShiny & caughtAttr) === BigInt(0)) || ((newVariant & caughtAttr) === BigInt(0)); + const newShinyOrVariant = (newShiny & caughtAttr) === BigInt(0) || (newVariant & caughtAttr) === BigInt(0); this.pokemonShinyNewIcon.setVisible(!!newShinyOrVariant); - } else if ((caughtAttr & DexAttr.NON_SHINY) === BigInt(0) && ((caughtAttr & DexAttr.SHINY) === DexAttr.SHINY)) { //If the player has *only* caught any shiny variant of this species, not a non-shiny + } else if ((caughtAttr & DexAttr.NON_SHINY) === BigInt(0) && (caughtAttr & DexAttr.SHINY) === DexAttr.SHINY) { + //If the player has *only* caught any shiny variant of this species, not a non-shiny this.pokemonShinyNewIcon.setVisible(true); this.pokemonShinyNewIcon.setText("(+)"); this.pokemonShinyNewIcon.setColor(getTextColor(TextStyle.SUMMARY_BLUE, false, globalScene.uiTheme)); @@ -313,8 +381,13 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { } const starterSpeciesId = pokemon.species.getRootSpeciesId(); - const originalIvs: number[] | null = eggInfo ? (dexEntry.caughtAttr ? dexEntry.ivs : null) : (globalScene.gameData.dexData[starterSpeciesId].caughtAttr - ? globalScene.gameData.dexData[starterSpeciesId].ivs : null); + const originalIvs: number[] | null = eggInfo + ? dexEntry.caughtAttr + ? dexEntry.ivs + : null + : globalScene.gameData.dexData[starterSpeciesId].caughtAttr + ? globalScene.gameData.dexData[starterSpeciesId].ivs + : null; this.statsContainer.updateIvs(pokemon.ivs, originalIvs!); // TODO: is this bang correct? if (!eggInfo) { @@ -325,7 +398,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { x: this.initialX - this.infoWindowWidth, onComplete: () => { resolve(); - } + }, }); if (showMoves) { @@ -335,7 +408,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { duration: Utils.fixedInt(Math.floor(325 / speedMultiplier)), ease: "Cubic.easeInOut", x: this.movesContainerInitialX - 57, - onComplete: () => resolve() + onComplete: () => resolve(), }); } } @@ -383,8 +456,10 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonMovesContainer.setVisible(false); } - makeRoomForConfirmUi(speedMultiplier: number = 1, fromCatch: boolean = false): Promise { - const xPosition = fromCatch ? this.initialX - this.infoWindowWidth - 65 : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth; + makeRoomForConfirmUi(speedMultiplier = 1, fromCatch = false): Promise { + const xPosition = fromCatch + ? this.initialX - this.infoWindowWidth - 65 + : this.initialX - this.infoWindowWidth - ConfirmUiHandler.windowWidth; return new Promise(resolve => { globalScene.tweens.add({ targets: this, @@ -393,12 +468,12 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { x: xPosition, onComplete: () => { resolve(); - } + }, }); }); } - hide(speedMultiplier: number = 1): Promise { + hide(speedMultiplier = 1): Promise { return new Promise(resolve => { if (!this.shown) { globalScene.showEnemyModifierBar(); @@ -409,7 +484,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { targets: this.pokemonMovesContainer, duration: Utils.fixedInt(Math.floor(750 / speedMultiplier)), ease: "Cubic.easeInOut", - x: this.movesContainerInitialX + x: this.movesContainerInitialX, }); globalScene.tweens.add({ @@ -424,7 +499,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { globalScene.ui.hideTooltip(); globalScene.showEnemyModifierBar(); resolve(); - } + }, }); this.shown = false; diff --git a/src/ui/registration-form-ui-handler.ts b/src/ui/registration-form-ui-handler.ts index 3b229a47c38..74669bc1f44 100644 --- a/src/ui/registration-form-ui-handler.ts +++ b/src/ui/registration-form-ui-handler.ts @@ -7,39 +7,38 @@ import i18next from "i18next"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { globalScene } from "#app/global-scene"; - interface LanguageSetting { - inputFieldFontSize?: string, - warningMessageFontSize?: string, - errorMessageFontSize?: string, + inputFieldFontSize?: string; + warningMessageFontSize?: string; + errorMessageFontSize?: string; } const languageSettings: { [key: string]: LanguageSetting } = { "es-ES": { inputFieldFontSize: "50px", errorMessageFontSize: "40px", - } + }, }; export default class RegistrationFormUiHandler extends FormModalUiHandler { - getModalTitle(config?: ModalConfig): string { + getModalTitle(_config?: ModalConfig): string { return i18next.t("menu:register"); } - getWidth(config?: ModalConfig): number { + getWidth(_config?: ModalConfig): number { return 160; } - getMargin(config?: ModalConfig): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + getMargin(_config?: ModalConfig): [number, number, number, number] { + return [0, 0, 48, 0]; } getButtonTopMargin(): number { return 8; } - getButtonLabels(config?: ModalConfig): string[] { - return [ i18next.t("menu:register"), i18next.t("menu:backToLogin") ]; + getButtonLabels(_config?: ModalConfig): string[] { + return [i18next.t("menu:register"), i18next.t("menu:backToLogin")]; } getReadableErrorMessage(error: string): string { @@ -62,8 +61,14 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler { override getInputFieldConfigs(): InputFieldConfig[] { const inputFieldConfigs: InputFieldConfig[] = []; inputFieldConfigs.push({ label: i18next.t("menu:username") }); - inputFieldConfigs.push({ label: i18next.t("menu:password"), isPassword: true }); - inputFieldConfigs.push({ label: i18next.t("menu:confirmPassword"), isPassword: true }); + inputFieldConfigs.push({ + label: i18next.t("menu:password"), + isPassword: true, + }); + inputFieldConfigs.push({ + label: i18next.t("menu:confirmPassword"), + isPassword: true, + }); return inputFieldConfigs; } @@ -80,7 +85,9 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler { }); const warningMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.warningMessageFontSize ?? "42px"; - const label = addTextObject(10, 87, i18next.t("menu:registrationAgeWarning"), TextStyle.TOOLTIP_CONTENT, { fontSize: warningMessageFontSize }); + const label = addTextObject(10, 87, i18next.t("menu:registrationAgeWarning"), TextStyle.TOOLTIP_CONTENT, { + fontSize: warningMessageFontSize, + }); this.modalContainer.add(label); } @@ -90,11 +97,11 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler { const config = args[0] as ModalConfig; const originalRegistrationAction = this.submitAction; - this.submitAction = (_) => { + this.submitAction = _ => { // Prevent overlapping overrides on action modification this.submitAction = originalRegistrationAction; this.sanitizeInputs(); - globalScene.ui.setMode(Mode.LOADING, { buttonActions: []}); + globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] }); const onFail = error => { globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() })); globalScene.ui.playError(); @@ -112,14 +119,22 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler { if (this.inputs[1].text !== this.inputs[2].text) { return onFail(i18next.t("menu:passwordNotMatchingConfirmPassword")); } - const [ usernameInput, passwordInput ] = this.inputs; - pokerogueApi.account.register({ username: usernameInput.text, password: passwordInput.text }) + const [usernameInput, passwordInput] = this.inputs; + pokerogueApi.account + .register({ + username: usernameInput.text, + password: passwordInput.text, + }) .then(registerError => { if (!registerError) { - pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }) + pokerogueApi.account + .login({ + username: usernameInput.text, + password: passwordInput.text, + }) .then(loginError => { if (!loginError) { - originalRegistrationAction && originalRegistrationAction(); + originalRegistrationAction?.(); } else { onFail(loginError); } diff --git a/src/ui/rename-form-ui-handler.ts b/src/ui/rename-form-ui-handler.ts index 3004530063e..91c0025d283 100644 --- a/src/ui/rename-form-ui-handler.ts +++ b/src/ui/rename-form-ui-handler.ts @@ -5,20 +5,20 @@ import i18next from "i18next"; import type { PlayerPokemon } from "#app/field/pokemon"; export default class RenameFormUiHandler extends FormModalUiHandler { - getModalTitle(config?: ModalConfig): string { + getModalTitle(_config?: ModalConfig): string { return i18next.t("menu:renamePokemon"); } - getWidth(config?: ModalConfig): number { + getWidth(_config?: ModalConfig): number { return 160; } - getMargin(config?: ModalConfig): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + getMargin(_config?: ModalConfig): [number, number, number, number] { + return [0, 0, 48, 0]; } - getButtonLabels(config?: ModalConfig): string[] { - return [ i18next.t("menu:rename"), i18next.t("menu:cancel") ]; + getButtonLabels(_config?: ModalConfig): string[] { + return [i18next.t("menu:rename"), i18next.t("menu:cancel")]; } getReadableErrorMessage(error: string): string { @@ -42,7 +42,7 @@ export default class RenameFormUiHandler extends FormModalUiHandler { } else { this.inputs[0].text = args[1]; } - this.submitAction = (_) => { + this.submitAction = _ => { this.sanitizeInputs(); const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); config.buttonActions[0](sanitizedName); diff --git a/src/ui/run-history-ui-handler.ts b/src/ui/run-history-ui-handler.ts index 2a498f77b8d..85ea1e93e8d 100644 --- a/src/ui/run-history-ui-handler.ts +++ b/src/ui/run-history-ui-handler.ts @@ -25,7 +25,6 @@ export const RUN_HISTORY_LIMIT: number = 25; * The only valid input buttons are Button.ACTION and Button.CANCEL. */ export default class RunHistoryUiHandler extends MessageUiHandler { - private readonly maxRows = 3; private runSelectContainer: Phaser.GameObjects.Container; @@ -34,7 +33,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { private runSelectCallback: RunSelectCallback | null; - private scrollCursor: number = 0; + private scrollCursor = 0; private cursorObj: Phaser.GameObjects.NineSlice | null; @@ -51,7 +50,13 @@ export default class RunHistoryUiHandler extends MessageUiHandler { this.runSelectContainer.setVisible(false); ui.add(this.runSelectContainer); - const loadSessionBg = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, -globalScene.game.canvas.height / 6, 0x006860); + const loadSessionBg = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + -globalScene.game.canvas.height / 6, + 0x006860, + ); loadSessionBg.setOrigin(0, 0); this.runSelectContainer.add(loadSessionBg); @@ -101,7 +106,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { let success = false; const error = false; - if ([ Button.ACTION, Button.CANCEL ].includes(button)) { + if ([Button.ACTION, Button.CANCEL].includes(button)) { if (button === Button.ACTION) { const cursor = this.cursor + this.scrollCursor; if (this.runs[cursor]) { @@ -111,11 +116,10 @@ export default class RunHistoryUiHandler extends MessageUiHandler { } success = true; return success; - } else { - this.runSelectCallback = null; - success = true; - globalScene.ui.revertMode(); } + this.runSelectCallback = null; + success = true; + globalScene.ui.revertMode(); } else if (this.runs.length > 0) { switch (button) { case Button.UP: @@ -124,7 +128,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { } else if (this.scrollCursor) { success = this.setScrollCursor(this.scrollCursor - 1); } else if (this.runs.length > 1) { - // wrap around to the bottom + // wrap around to the bottom success = this.setCursor(Math.min(this.runs.length - 1, this.maxRows - 1)); success = this.setScrollCursor(Math.max(0, this.runs.length - this.maxRows)) || success; } @@ -135,7 +139,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { } else if (this.scrollCursor < this.runs.length - this.maxRows) { success = this.setScrollCursor(this.scrollCursor + 1); } else if (this.runs.length > 1) { - // wrap around to the top + // wrap around to the top success = this.setCursor(0); success = this.setScrollCursor(0) || success; } @@ -186,7 +190,9 @@ export default class RunHistoryUiHandler extends MessageUiHandler { const emptyWindow = addWindow(0, 0, 304, 165); this.runsContainer.add(emptyWindow); const emptyWindowCoordinates = emptyWindow.getCenter(); - const emptyText = addTextObject(0, 0, i18next.t("saveSlotSelectUiHandler:empty"), TextStyle.WINDOW, { fontSize: "128px" }); + const emptyText = addTextObject(0, 0, i18next.t("saveSlotSelectUiHandler:empty"), TextStyle.WINDOW, { + fontSize: "128px", + }); emptyText.setPosition(emptyWindowCoordinates.x - 18, emptyWindowCoordinates.y - 15); this.runsContainer.add(emptyText); } @@ -213,7 +219,7 @@ export default class RunHistoryUiHandler extends MessageUiHandler { targets: this.runsContainer, y: this.runContainerInitialY - 56 * scrollCursor, duration: Utils.fixedInt(325), - ease: "Sine.easeInOut" + ease: "Sine.easeInOut", }); } return changed; @@ -261,7 +267,6 @@ class RunEntryContainer extends Phaser.GameObjects.Container { this.entryData = entryData; this.setup(this.entryData); - } /** @@ -275,7 +280,6 @@ class RunEntryContainer extends Phaser.GameObjects.Container { * The player's party and their levels at the time of the last wave of the run are also displayed. */ private setup(run: RunEntry) { - const victory = run.isVictory; const data = globalScene.gameData.parseSessionData(JSON.stringify(run.entry)); @@ -286,22 +290,34 @@ class RunEntryContainer extends Phaser.GameObjects.Container { if (victory) { const gameOutcomeLabel = addTextObject(8, 5, `${i18next.t("runHistory:victory")}`, TextStyle.WINDOW); this.add(gameOutcomeLabel); - } else { // Run Result: Defeats + } else { + // Run Result: Defeats const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; const genderStr = PlayerGender[genderIndex].toLowerCase(); // Defeats from wild Pokemon battles will show the Pokemon responsible by the text of the run result. if (data.battleType === BattleType.WILD || (data.battleType === BattleType.MYSTERY_ENCOUNTER && !data.trainer)) { const enemyContainer = globalScene.add.container(8, 5); - const gameOutcomeLabel = addTextObject(0, 0, `${i18next.t("runHistory:defeatedWild", { context: genderStr })}`, TextStyle.WINDOW); + const gameOutcomeLabel = addTextObject( + 0, + 0, + `${i18next.t("runHistory:defeatedWild", { context: genderStr })}`, + TextStyle.WINDOW, + ); enemyContainer.add(gameOutcomeLabel); data.enemyParty.forEach((enemyData, e) => { - const enemyIconContainer = globalScene.add.container(65 + (e * 25), -8); + const enemyIconContainer = globalScene.add.container(65 + e * 25, -8); enemyIconContainer.setScale(0.75); enemyData.boss = false; enemyData["player"] = true; const enemy = enemyData.toPokemon(); const enemyIcon = globalScene.addPokemonIcon(enemy, 0, 0, 0, 0); - const enemyLevel = addTextObject(32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" }); + const enemyLevel = addTextObject( + 32, + 20, + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, + TextStyle.PARTY, + { fontSize: "54px", color: "#f8f8f8" }, + ); enemyLevel.setShadow(0, 0, undefined); enemyLevel.setStroke("#424242", 14); enemyLevel.setOrigin(1, 0); @@ -311,16 +327,30 @@ class RunEntryContainer extends Phaser.GameObjects.Container { enemy.destroy(); }); this.add(enemyContainer); - } else if (data.battleType === BattleType.TRAINER || (data.battleType === BattleType.MYSTERY_ENCOUNTER && data.trainer)) { // Defeats from Trainers show the trainer's title and name + } else if ( + data.battleType === BattleType.TRAINER || + (data.battleType === BattleType.MYSTERY_ENCOUNTER && data.trainer) + ) { + // Defeats from Trainers show the trainer's title and name const tObj = data.trainer.toTrainer(); // Because of the interesting mechanics behind rival names, the rival name and title have to be retrieved differently const RIVAL_TRAINER_ID_THRESHOLD = 375; if (data.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) { - const rivalName = (tObj.variant === TrainerVariant.FEMALE) ? "trainerNames:rival_female" : "trainerNames:rival"; - const gameOutcomeLabel = addTextObject(8, 5, `${i18next.t("runHistory:defeatedRival", { context: genderStr })} ${i18next.t(rivalName)}`, TextStyle.WINDOW); + const rivalName = tObj.variant === TrainerVariant.FEMALE ? "trainerNames:rival_female" : "trainerNames:rival"; + const gameOutcomeLabel = addTextObject( + 8, + 5, + `${i18next.t("runHistory:defeatedRival", { context: genderStr })} ${i18next.t(rivalName)}`, + TextStyle.WINDOW, + ); this.add(gameOutcomeLabel); } else { - const gameOutcomeLabel = addTextObject(8, 5, `${i18next.t("runHistory:defeatedTrainer", { context: genderStr })}${tObj.getName(0, true)}`, TextStyle.WINDOW); + const gameOutcomeLabel = addTextObject( + 8, + 5, + `${i18next.t("runHistory:defeatedTrainer", { context: genderStr })}${tObj.getName(0, true)}`, + TextStyle.WINDOW, + ); this.add(gameOutcomeLabel); } } @@ -375,7 +405,13 @@ class RunEntryContainer extends Phaser.GameObjects.Container { const pokemon = p.toPokemon(); const icon = globalScene.addPokemonIcon(pokemon, 0, 0, 0, 0); - const text = addTextObject(32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(pokemon.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" }); + const text = addTextObject( + 32, + 20, + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(pokemon.level, 1000)}`, + TextStyle.PARTY, + { fontSize: "54px", color: "#f8f8f8" }, + ); text.setShadow(0, 0, undefined); text.setStroke("#424242", 14); text.setOrigin(1, 0); diff --git a/src/ui/run-info-ui-handler.ts b/src/ui/run-info-ui-handler.ts index 3b4a0e3d335..364cb8e4003 100644 --- a/src/ui/run-info-ui-handler.ts +++ b/src/ui/run-info-ui-handler.ts @@ -35,12 +35,12 @@ import { globalScene } from "#app/global-scene"; enum RunInfoUiMode { MAIN, HALL_OF_FAME, - ENDING_ART + ENDING_ART, } export enum RunDisplayMode { RUN_HISTORY, - SESSION_PREVIEW + SESSION_PREVIEW, } /** @@ -64,7 +64,7 @@ export default class RunInfoUiHandler extends UiHandler { private hallofFameContainer: Phaser.GameObjects.Container; private endCardContainer: Phaser.GameObjects.Container; - private partyVisibility: Boolean; + private partyVisibility: boolean; private modifiersModule: any; constructor() { @@ -72,12 +72,12 @@ export default class RunInfoUiHandler extends UiHandler { } override async setup() { - this.runContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); + this.runContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); // The import of the modifiersModule is loaded here to sidestep async/await issues. this.modifiersModule = Modifier; this.runContainer.setVisible(false); globalScene.loadImage("encounter_exclaim", "mystery-encounters"); - } + } /** * This takes a run's RunEntry and uses the information provided to display essential information about the player's run. @@ -90,10 +90,16 @@ export default class RunInfoUiHandler extends UiHandler { * Party Container: * this.isVictory === true --> Hall of Fame Container: */ - override show(args: any[]): boolean { - super.show(args); + override show(args: any[]): boolean { + super.show(args); - const gameStatsBg = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width, globalScene.game.canvas.height, 0x006860); + const gameStatsBg = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width, + globalScene.game.canvas.height, + 0x006860, + ); gameStatsBg.setOrigin(0, 0); this.runContainer.add(gameStatsBg); @@ -112,7 +118,7 @@ export default class RunInfoUiHandler extends UiHandler { // Creates Header and adds to this.runContainer this.addHeader(); - this.statsBgWidth = ((globalScene.game.canvas.width / 6) - 2) / 3; + this.statsBgWidth = (globalScene.game.canvas.width / 6 - 2) / 3; // Creates Run Result Container this.runResultContainer = globalScene.add.container(0, 24); @@ -131,14 +137,17 @@ export default class RunInfoUiHandler extends UiHandler { const runInfoWindow = addWindow(0, 0, this.statsBgWidth - 11, 90); const runInfoWindowCoords = runInfoWindow.getBottomRight(); this.runInfoContainer.add(runInfoWindow); - this.parseRunInfo(runInfoWindowCoords.x, runInfoWindowCoords.y); + this.parseRunInfo(runInfoWindowCoords.x, runInfoWindowCoords.y); // Creates Player Party Container this.partyContainer = globalScene.add.container(this.statsBgWidth - 10, 23); this.parsePartyInfo(); this.showParty(true); - this.runContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.runContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); this.getUi().bringToTop(this.runContainer); this.runContainer.setVisible(true); @@ -155,7 +164,7 @@ export default class RunInfoUiHandler extends UiHandler { this.getUi().hideTooltip(); return true; - } + } /** * Creates and adds the header background, title text, and important buttons to RunInfoUiHandler @@ -163,22 +172,33 @@ export default class RunInfoUiHandler extends UiHandler { * It does not check if the run has any PokemonHeldItemModifiers though. */ private addHeader() { - const headerBg = addWindow(0, 0, (globalScene.game.canvas.width / 6) - 2, 24); + const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); headerBg.setOrigin(0, 0); this.runContainer.add(headerBg); if (this.runInfo.modifiers.length !== 0) { const headerBgCoords = headerBg.getTopRight(); const abilityButtonContainer = globalScene.add.container(0, 0); - const abilityButtonText = addTextObject(8, 0, i18next.t("runHistory:viewHeldItems"), TextStyle.WINDOW, { fontSize:"34px" }); + const abilityButtonText = addTextObject(8, 0, i18next.t("runHistory:viewHeldItems"), TextStyle.WINDOW, { + fontSize: "34px", + }); const gamepadType = this.getUi().getGamepadType(); let abilityButtonElement: Phaser.GameObjects.Sprite; if (gamepadType === "touch") { abilityButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 2, "keyboard", "E.png"); } else { - abilityButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 2, gamepadType, globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Ability)); + abilityButtonElement = new Phaser.GameObjects.Sprite( + globalScene, + 0, + 2, + gamepadType, + globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Ability), + ); } - abilityButtonContainer.add([ abilityButtonText, abilityButtonElement ]); - abilityButtonContainer.setPosition(headerBgCoords.x - abilityButtonText.displayWidth - abilityButtonElement.displayWidth - 8, 10); + abilityButtonContainer.add([abilityButtonText, abilityButtonElement]); + abilityButtonContainer.setPosition( + headerBgCoords.x - abilityButtonText.displayWidth - abilityButtonElement.displayWidth - 8, + 10, + ); this.runContainer.add(abilityButtonContainer); } const headerText = addTextObject(0, 0, i18next.t("runHistory:runInfo"), TextStyle.SETTINGS_LABEL); @@ -199,13 +219,25 @@ export default class RunInfoUiHandler extends UiHandler { const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; const genderStr = PlayerGender[genderIndex]; const runResultTextStyle = this.isVictory ? TextStyle.PERFECT_IV : TextStyle.SUMMARY_RED; - const runResultTitle = this.isVictory ? i18next.t("runHistory:victory") : i18next.t("runHistory:defeated", { context: genderStr }); - const runResultText = addTextObject(6, 5, `${runResultTitle} - ${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, runResultTextStyle, { fontSize : "65px", lineSpacing: 0.1 }); + const runResultTitle = this.isVictory + ? i18next.t("runHistory:victory") + : i18next.t("runHistory:defeated", { context: genderStr }); + const runResultText = addTextObject( + 6, + 5, + `${runResultTitle} - ${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, + runResultTextStyle, + { fontSize: "65px", lineSpacing: 0.1 }, + ); if (this.isVictory) { const hallofFameInstructionContainer = globalScene.add.container(0, 0); - const shinyButtonText = addTextObject(8, 0, i18next.t("runHistory:viewHallOfFame"), TextStyle.WINDOW, { fontSize:"65px" }); - const formButtonText = addTextObject(8, 12, i18next.t("runHistory:viewEndingSplash"), TextStyle.WINDOW, { fontSize:"65px" }); + const shinyButtonText = addTextObject(8, 0, i18next.t("runHistory:viewHallOfFame"), TextStyle.WINDOW, { + fontSize: "65px", + }); + const formButtonText = addTextObject(8, 12, i18next.t("runHistory:viewEndingSplash"), TextStyle.WINDOW, { + fontSize: "65px", + }); const gamepadType = this.getUi().getGamepadType(); let shinyButtonElement: Phaser.GameObjects.Sprite; let formButtonElement: Phaser.GameObjects.Sprite; @@ -213,12 +245,24 @@ export default class RunInfoUiHandler extends UiHandler { shinyButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 4, "keyboard", "R.png"); formButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 16, "keyboard", "F.png"); } else { - shinyButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 4, gamepadType, globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Shiny)); - formButtonElement = new Phaser.GameObjects.Sprite(globalScene, 0, 16, gamepadType, globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Form)); + shinyButtonElement = new Phaser.GameObjects.Sprite( + globalScene, + 0, + 4, + gamepadType, + globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Shiny), + ); + formButtonElement = new Phaser.GameObjects.Sprite( + globalScene, + 0, + 16, + gamepadType, + globalScene.inputController?.getIconForLatestInputRecorded(SettingKeyboard.Button_Cycle_Form), + ); } - hallofFameInstructionContainer.add([ shinyButtonText, shinyButtonElement ]); + hallofFameInstructionContainer.add([shinyButtonText, shinyButtonElement]); - hallofFameInstructionContainer.add([ formButtonText, formButtonElement ]); + hallofFameInstructionContainer.add([formButtonText, formButtonElement]); hallofFameInstructionContainer.setPosition(12, 25); this.runResultContainer.add(hallofFameInstructionContainer); @@ -229,18 +273,24 @@ export default class RunInfoUiHandler extends UiHandler { if (!this.isVictory) { const enemyContainer = globalScene.add.container(0, 0); // Wild - Single and Doubles - if (this.runInfo.battleType === BattleType.WILD || (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && !this.runInfo.trainer)) { + if ( + this.runInfo.battleType === BattleType.WILD || + (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && !this.runInfo.trainer) + ) { switch (this.runInfo.enemyParty.length) { case 1: - // Wild - Singles + // Wild - Singles this.parseWildSingleDefeat(enemyContainer); break; case 2: - //Wild - Doubles + //Wild - Doubles this.parseWildDoubleDefeat(enemyContainer); break; } - } else if (this.runInfo.battleType === BattleType.TRAINER || (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && this.runInfo.trainer)) { + } else if ( + this.runInfo.battleType === BattleType.TRAINER || + (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER && this.runInfo.trainer) + ) { this.parseTrainerDefeat(enemyContainer); } this.runResultContainer.add(enemyContainer); @@ -270,20 +320,30 @@ export default class RunInfoUiHandler extends UiHandler { const pokeball = globalScene.add.sprite(0, 0, "pb"); pokeball.setFrame(getPokeballAtlasKey(p.pokeball)); pokeball.setScale(0.5); - pokeball.setPosition(58 + ((i % row_limit) * 8), (i <= 2) ? 18 : 25); + pokeball.setPosition(58 + (i % row_limit) * 8, i <= 2 ? 18 : 25); enemyContainer.add(pokeball); }); const trainerObj = this.runInfo.trainer.toTrainer(); const RIVAL_TRAINER_ID_THRESHOLD = 375; let trainerName = ""; if (this.runInfo.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) { - trainerName = (trainerObj.variant === TrainerVariant.FEMALE) ? i18next.t("trainerNames:rival_female") : i18next.t("trainerNames:rival"); + trainerName = + trainerObj.variant === TrainerVariant.FEMALE + ? i18next.t("trainerNames:rival_female") + : i18next.t("trainerNames:rival"); } else { trainerName = trainerObj.getName(0, true); } - const boxString = i18next.t(trainerObj.variant !== TrainerVariant.DOUBLE ? "battle:trainerAppeared" : "battle:trainerAppearedDouble", { trainerName: trainerName }).replace(/\n/g, " "); + const boxString = i18next + .t(trainerObj.variant !== TrainerVariant.DOUBLE ? "battle:trainerAppeared" : "battle:trainerAppearedDouble", { + trainerName: trainerName, + }) + .replace(/\n/g, " "); const descContainer = globalScene.add.container(0, 0); - const textBox = addTextObject(0, 0, boxString, TextStyle.WINDOW, { fontSize : "35px", wordWrap: { width: 200 }}); + const textBox = addTextObject(0, 0, boxString, TextStyle.WINDOW, { + fontSize: "35px", + wordWrap: { width: 200 }, + }); descContainer.add(textBox); descContainer.setPosition(55, 32); this.runResultContainer.add(descContainer); @@ -294,25 +354,43 @@ export default class RunInfoUiHandler extends UiHandler { const subSprite = globalScene.add.sprite(56, -106, "pkmn__sub"); subSprite.setScale(0.65); subSprite.setPosition(34, 46); - const mysteryEncounterTitle = i18next.t(globalScene.getMysteryEncounter(this.runInfo.mysteryEncounterType as MysteryEncounterType, true).localizationKey + ":title"); + const mysteryEncounterTitle = i18next.t( + globalScene.getMysteryEncounter(this.runInfo.mysteryEncounterType as MysteryEncounterType, true) + .localizationKey + ":title", + ); const descContainer = globalScene.add.container(0, 0); - const textBox = addTextObject(0, 0, mysteryEncounterTitle, TextStyle.WINDOW, { fontSize : "45px", wordWrap: { width: 160 }}); + const textBox = addTextObject(0, 0, mysteryEncounterTitle, TextStyle.WINDOW, { + fontSize: "45px", + wordWrap: { width: 160 }, + }); descContainer.add(textBox); descContainer.setPosition(47, 37); - this.runResultContainer.add([ encounterExclaim, subSprite, descContainer ]); + this.runResultContainer.add([encounterExclaim, subSprite, descContainer]); } const runResultWindow = this.runResultContainer.getByName("Run_Result_Window") as Phaser.GameObjects.Image; const windowCenterX = runResultWindow.getTopCenter().x; const windowBottomY = runResultWindow.getBottomCenter().y; - const runStatusText = addTextObject(windowCenterX, 5, `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, TextStyle.WINDOW, { fontSize : "60px", lineSpacing: 0.1 }); + const runStatusText = addTextObject( + windowCenterX, + 5, + `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, + TextStyle.WINDOW, + { fontSize: "60px", lineSpacing: 0.1 }, + ); runStatusText.setOrigin(0.5, 0); - const currentBiomeText = addTextObject(windowCenterX, windowBottomY - 5, `${getBiomeName(this.runInfo.arena.biome)}`, TextStyle.WINDOW, { fontSize: "60px" }); + const currentBiomeText = addTextObject( + windowCenterX, + windowBottomY - 5, + `${getBiomeName(this.runInfo.arena.biome)}`, + TextStyle.WINDOW, + { fontSize: "60px" }, + ); currentBiomeText.setOrigin(0.5, 1); - this.runResultContainer.add([ runStatusText, currentBiomeText ]); + this.runResultContainer.add([runStatusText, currentBiomeText]); this.runContainer.add(this.runResultContainer); } @@ -330,7 +408,13 @@ export default class RunInfoUiHandler extends UiHandler { const enemy = enemyData.toPokemon(); const enemyIcon = globalScene.addPokemonIcon(enemy, 0, 0, 0, 0); const enemyLevelStyle = bossStatus ? TextStyle.PARTY_RED : TextStyle.PARTY; - const enemyLevel = addTextObject(36, 26, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, enemyLevelStyle, { fontSize: "44px", color: "#f8f8f8" }); + const enemyLevel = addTextObject( + 36, + 26, + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, + enemyLevelStyle, + { fontSize: "44px", color: "#f8f8f8" }, + ); enemyLevel.setShadow(0, 0, undefined); enemyLevel.setStroke("#424242", 14); enemyLevel.setOrigin(1, 0); @@ -354,7 +438,13 @@ export default class RunInfoUiHandler extends UiHandler { enemyData["player"] = true; const enemy = enemyData.toPokemon(); const enemyIcon = globalScene.addPokemonIcon(enemy, 0, 0, 0, 0); - const enemyLevel = addTextObject(36, 26, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, bossStatus ? TextStyle.PARTY_RED : TextStyle.PARTY, { fontSize: "44px", color: "#f8f8f8" }); + const enemyLevel = addTextObject( + 36, + 26, + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, + bossStatus ? TextStyle.PARTY_RED : TextStyle.PARTY, + { fontSize: "44px", color: "#f8f8f8" }, + ); enemyLevel.setShadow(0, 0, undefined); enemyLevel.setStroke("#424242", 14); enemyLevel.setOrigin(1, 0); @@ -386,8 +476,8 @@ export default class RunInfoUiHandler extends UiHandler { const tObjPartnerSprite = globalScene.add.sprite(5, -3, tObjPartnerSpriteKey); // Double Trainers have smaller sprites than Single Trainers if (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) { - tObjPartnerSprite.setScale(0.20); - tObjSprite.setScale(0.20); + tObjPartnerSprite.setScale(0.2); + tObjSprite.setScale(0.2); doubleContainer.add(tObjSprite); doubleContainer.add(tObjPartnerSprite); doubleContainer.setPosition(12, 38); @@ -395,13 +485,13 @@ export default class RunInfoUiHandler extends UiHandler { tObjSprite.setScale(0.55); tObjSprite.setPosition(-9, -3); tObjPartnerSprite.setScale(0.55); - doubleContainer.add([ tObjSprite, tObjPartnerSprite ]); + doubleContainer.add([tObjSprite, tObjPartnerSprite]); doubleContainer.setPosition(28, 34); } enemyContainer.add(doubleContainer); } else { - const scale = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? 0.35 : 0.55; - const position = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? [ 12, 28 ] : [ 30, 32 ]; + const scale = this.runDisplayMode === RunDisplayMode.RUN_HISTORY ? 0.35 : 0.55; + const position = this.runDisplayMode === RunDisplayMode.RUN_HISTORY ? [12, 28] : [30, 32]; tObjSprite.setScale(scale, scale); tObjSprite.setPosition(position[0], position[1]); enemyContainer.add(tObjSprite); @@ -433,8 +523,14 @@ export default class RunInfoUiHandler extends UiHandler { enemyData["player"] = true; const enemy = enemyData.toPokemon(); const enemyIcon = globalScene.addPokemonIcon(enemy, 0, 0, 0, 0); - enemyIcon.setPosition(39 * (e % 3) + 5, (35 * pokemonRowHeight)); - const enemyLevel = addTextObject(43 * (e % 3), (27 * (pokemonRowHeight + 1)), `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, isBoss ? TextStyle.PARTY_RED : TextStyle.PARTY, { fontSize: "54px" }); + enemyIcon.setPosition(39 * (e % 3) + 5, 35 * pokemonRowHeight); + const enemyLevel = addTextObject( + 43 * (e % 3), + 27 * (pokemonRowHeight + 1), + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(enemy.level, 1000)}`, + isBoss ? TextStyle.PARTY_RED : TextStyle.PARTY, + { fontSize: "54px" }, + ); enemyLevel.setShadow(0, 0, undefined); enemyLevel.setStroke("#424242", 14); enemyLevel.setOrigin(0, 0); @@ -457,7 +553,10 @@ export default class RunInfoUiHandler extends UiHandler { private async parseRunInfo(windowX: number, windowY: number) { // Parsing and displaying the mode. // In the future, parsing Challenges + Challenge Rules may have to be reworked as PokeRogue adds additional challenges and users can stack these challenges in various ways. - const modeText = addBBCodeTextObject(7, 0, "", TextStyle.WINDOW, { fontSize : "50px", lineSpacing:3 }); + const modeText = addBBCodeTextObject(7, 0, "", TextStyle.WINDOW, { + fontSize: "50px", + lineSpacing: 3, + }); modeText.setPosition(7, 5); modeText.appendText(i18next.t("runHistory:mode") + ": ", false); switch (this.runInfo.gameMode) { @@ -491,7 +590,10 @@ export default class RunInfoUiHandler extends UiHandler { } // If the player achieves a personal best in Endless, the mode text will be tinted similarly to SSS luck to celebrate their achievement. - if ((this.runInfo.gameMode === GameModes.ENDLESS || this.runInfo.gameMode === GameModes.SPLICED_ENDLESS) && this.runInfo.waveIndex === globalScene.gameData.gameStats.highestEndlessWave) { + if ( + (this.runInfo.gameMode === GameModes.ENDLESS || this.runInfo.gameMode === GameModes.SPLICED_ENDLESS) && + this.runInfo.waveIndex === globalScene.gameData.gameStats.highestEndlessWave + ) { modeText.appendText(` [${i18next.t("runHistory:personalBest")}]`); modeText.setTint(0xffef5c, 0x47ff69, 0x6b6bff, 0xff6969); } @@ -499,22 +601,35 @@ export default class RunInfoUiHandler extends UiHandler { // Duration + Money const runInfoTextContainer = globalScene.add.container(0, 0); // Japanese is set to a greater line spacing of 35px in addBBCodeTextObject() if lineSpacing < 12. - const lineSpacing = (i18next.resolvedLanguage === "ja") ? 12 : 3; - const runInfoText = addBBCodeTextObject(7, 0, "", TextStyle.WINDOW, { fontSize: "50px", lineSpacing: lineSpacing }); + const lineSpacing = i18next.resolvedLanguage === "ja" ? 12 : 3; + const runInfoText = addBBCodeTextObject(7, 0, "", TextStyle.WINDOW, { + fontSize: "50px", + lineSpacing: lineSpacing, + }); const runTime = Utils.getPlayTimeString(this.runInfo.playTime); runInfoText.appendText(`${i18next.t("runHistory:runLength")}: ${runTime}`, false); const runMoney = Utils.formatMoney(globalScene.moneyFormat, this.runInfo.money); const moneyTextColor = getTextColor(TextStyle.MONEY_WINDOW, false, globalScene.uiTheme); - runInfoText.appendText(`[color=${moneyTextColor}]${i18next.t("battleScene:moneyOwned", { formattedMoney : runMoney })}[/color]`); + runInfoText.appendText( + `[color=${moneyTextColor}]${i18next.t("battleScene:moneyOwned", { formattedMoney: runMoney })}[/color]`, + ); runInfoText.setPosition(7, 70); runInfoTextContainer.add(runInfoText); // Luck // Uses the parameters windowX and windowY to dynamically position the luck value neatly into the bottom right corner - const luckText = addBBCodeTextObject(0, 0, "", TextStyle.WINDOW, { fontSize: "55px" }); - const luckValue = Phaser.Math.Clamp(this.runInfo.party.map(p => p.toPokemon().getLuck()).reduce((total: number, value: number) => total += value, 0), 0, 14); + const luckText = addBBCodeTextObject(0, 0, "", TextStyle.WINDOW, { + fontSize: "55px", + }); + const luckValue = Phaser.Math.Clamp( + this.runInfo.party + .map(p => p.toPokemon().getLuck()) + .reduce((total: number, value: number) => (total += value), 0), + 0, + 14, + ); let luckInfo = i18next.t("runHistory:luck") + ": " + getLuckString(luckValue); if (luckValue < 14) { - luckInfo = "[color=#" + (getLuckTextTint(luckValue)).toString(16) + "]" + luckInfo + "[/color]"; + luckInfo = "[color=#" + getLuckTextTint(luckValue).toString(16) + "]" + luckInfo + "[/color]"; } else { luckText.setTint(0xffef5c, 0x47ff69, 0x6b6bff, 0xff6969); } @@ -527,7 +642,10 @@ export default class RunInfoUiHandler extends UiHandler { if (this.runInfo.modifiers.length) { let visibleModifierIndex = 0; - const modifierIconsContainer = globalScene.add.container(8, (this.runInfo.gameMode === GameModes.CHALLENGE) ? 20 : 15); + const modifierIconsContainer = globalScene.add.container( + 8, + this.runInfo.gameMode === GameModes.CHALLENGE ? 20 : 15, + ); modifierIconsContainer.setScale(0.45); for (const m of this.runInfo.modifiers) { const modifier = m.toModifier(this.modifiersModule[m.className]); @@ -537,7 +655,7 @@ export default class RunInfoUiHandler extends UiHandler { const icon = modifier?.getIcon(false); if (icon) { const rowHeightModifier = Math.floor(visibleModifierIndex / 7); - icon.setPosition(24 * (visibleModifierIndex % 7), 20 + (35 * rowHeightModifier)); + icon.setPosition(24 * (visibleModifierIndex % 7), 20 + 35 * rowHeightModifier); modifierIconsContainer.add(icon); } @@ -572,14 +690,18 @@ export default class RunInfoUiHandler extends UiHandler { const typeRule = PokemonType[this.runInfo.challenges[i].value - 1]; const typeTextColor = `[color=${TypeColor[typeRule]}]`; const typeShadowColor = `[shadow=${TypeShadow[typeRule]}]`; - const typeText = typeTextColor + typeShadowColor + i18next.t(`pokemonInfo:Type.${typeRule}`)! + "[/color]" + "[/shadow]"; + const typeText = + typeTextColor + typeShadowColor + i18next.t(`pokemonInfo:Type.${typeRule}`)! + "[/color]" + "[/shadow]"; rules.push(typeText); break; case Challenges.INVERSE_BATTLE: rules.push(i18next.t("challenges:inverseBattle.shortName")); break; default: - const localisationKey = Challenges[this.runInfo.challenges[i].id].split("_").map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join(""); + const localisationKey = Challenges[this.runInfo.challenges[i].id] + .split("_") + .map((f, i) => (i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase())) + .join(""); rules.push(i18next.t(`challenges:${localisationKey}.name`)); break; } @@ -593,22 +715,22 @@ export default class RunInfoUiHandler extends UiHandler { * Default Information: Icon, Level, Nature, Ability, Passive, Shiny Status, Fusion Status, Stats, and Moves. * B-Side Information: Icon + Held Items (Can be displayed to the user through pressing the abilityButton) */ - private parsePartyInfo(): void { + private parsePartyInfo(): void { const party = this.runInfo.party; const currentLanguage = i18next.resolvedLanguage ?? "en"; - const windowHeight = ((globalScene.game.canvas.height / 6) - 23) / 6; + const windowHeight = (globalScene.game.canvas.height / 6 - 23) / 6; - party.forEach((p: PokemonData, i: number) => { - const pokemonInfoWindow = new RoundRectangle(globalScene, 0, 14, (this.statsBgWidth * 2) + 10, windowHeight - 2, 3); + party.forEach((p: PokemonData, i: number) => { + const pokemonInfoWindow = new RoundRectangle(globalScene, 0, 14, this.statsBgWidth * 2 + 10, windowHeight - 2, 3); - const pokemon = p.toPokemon(); - const pokemonInfoContainer = globalScene.add.container(this.statsBgWidth + 5, (windowHeight - 0.5) * i); + const pokemon = p.toPokemon(); + const pokemonInfoContainer = globalScene.add.container(this.statsBgWidth + 5, (windowHeight - 0.5) * i); - const types = pokemon.getTypes(); - const type1 = getTypeRgb(types[0]); - const type1Color = new Phaser.Display.Color(type1[0], type1[1], type1[2]); + const types = pokemon.getTypes(); + const type1 = getTypeRgb(types[0]); + const type1Color = new Phaser.Display.Color(type1[0], type1[1], type1[2]); - const bgColor = type1Color.clone().darken(45); + const bgColor = type1Color.clone().darken(45); pokemonInfoWindow.setFillStyle(bgColor.color); const iconContainer = globalScene.add.container(0, 0); @@ -617,7 +739,9 @@ export default class RunInfoUiHandler extends UiHandler { icon.setPosition(-99, 1); const type2 = types[1] ? getTypeRgb(types[1]) : undefined; const type2Color = type2 ? new Phaser.Display.Color(type2[0], type2[1], type2[2]) : undefined; - type2Color ? pokemonInfoWindow.setStrokeStyle(1, type2Color.color, 0.95) : pokemonInfoWindow.setStrokeStyle(1, type1Color.color, 0.95); + type2Color + ? pokemonInfoWindow.setStrokeStyle(1, type2Color.color, 0.95) + : pokemonInfoWindow.setStrokeStyle(1, type1Color.color, 0.95); this.getUi().bringToTop(icon); @@ -630,7 +754,7 @@ export default class RunInfoUiHandler extends UiHandler { const pName = pokemon.getNameToRender(); //With the exception of Korean/Traditional Chinese/Simplified Chinese, the code shortens the terms for ability and passive to their first letter. //These languages are exempted because they are already short enough. - const exemptedLanguages = [ "ko", "zh_CN", "zh_TW" ]; + const exemptedLanguages = ["ko", "zh_CN", "zh_TW"]; let passiveLabel = i18next.t("starterSelectUiHandler:passive") ?? "-"; let abilityLabel = i18next.t("starterSelectUiHandler:ability") ?? "-"; if (!exemptedLanguages.includes(currentLanguage)) { @@ -640,9 +764,14 @@ export default class RunInfoUiHandler extends UiHandler { const pPassiveInfo = pokemon.passive ? passiveLabel + ": " + pokemon.getPassiveAbility().name : ""; const pAbilityInfo = abilityLabel + ": " + pokemon.getAbility().name; // Japanese is set to a greater line spacing of 35px in addBBCodeTextObject() if lineSpacing < 12. - const lineSpacing = (i18next.resolvedLanguage === "ja") ? 12 : 3; - const pokeInfoText = addBBCodeTextObject(0, 0, pName, TextStyle.SUMMARY, { fontSize: textContainerFontSize, lineSpacing: lineSpacing }); - pokeInfoText.appendText(`${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatFancyLargeNumber(pokemon.level, 1)} - ${pNatureName}`); + const lineSpacing = i18next.resolvedLanguage === "ja" ? 12 : 3; + const pokeInfoText = addBBCodeTextObject(0, 0, pName, TextStyle.SUMMARY, { + fontSize: textContainerFontSize, + lineSpacing: lineSpacing, + }); + pokeInfoText.appendText( + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatFancyLargeNumber(pokemon.level, 1)} - ${pNatureName}`, + ); pokeInfoText.appendText(pAbilityInfo); pokeInfoText.appendText(pPassiveInfo); pokeInfoTextContainer.add(pokeInfoText); @@ -650,27 +779,36 @@ export default class RunInfoUiHandler extends UiHandler { // Pokemon Stats // Colored Arrows (Red/Blue) are placed by stats that are boosted from natures const pokeStatTextContainer = globalScene.add.container(-35, 6); - const pStats : string[] = []; - pokemon.stats.forEach((element) => pStats.push(Utils.formatFancyLargeNumber(element, 1))); + const pStats: string[] = []; + pokemon.stats.forEach(element => pStats.push(Utils.formatFancyLargeNumber(element, 1))); for (let i = 0; i < pStats.length; i++) { const isMult = getNatureStatMultiplier(pNature, i); - pStats[i] = (isMult < 1) ? pStats[i] + "[color=#40c8f8]↓[/color]" : pStats[i]; - pStats[i] = (isMult > 1) ? pStats[i] + "[color=#f89890]↑[/color]" : pStats[i]; + pStats[i] = isMult < 1 ? pStats[i] + "[color=#40c8f8]↓[/color]" : pStats[i]; + pStats[i] = isMult > 1 ? pStats[i] + "[color=#f89890]↑[/color]" : pStats[i]; } const hp = i18next.t("pokemonInfo:Stat.HPshortened") + ": " + pStats[0]; const atk = i18next.t("pokemonInfo:Stat.ATKshortened") + ": " + pStats[1]; const def = i18next.t("pokemonInfo:Stat.DEFshortened") + ": " + pStats[2]; const spatk = i18next.t("pokemonInfo:Stat.SPATKshortened") + ": " + pStats[3]; const spdef = i18next.t("pokemonInfo:Stat.SPDEFshortened") + ": " + pStats[4]; - const speedLabel = (currentLanguage === "es-ES" || currentLanguage === "pt_BR") ? i18next.t("runHistory:SPDshortened") : i18next.t("pokemonInfo:Stat.SPDshortened"); + const speedLabel = + currentLanguage === "es-ES" || currentLanguage === "pt_BR" + ? i18next.t("runHistory:SPDshortened") + : i18next.t("pokemonInfo:Stat.SPDshortened"); const speed = speedLabel + ": " + pStats[5]; // Column 1: HP Atk Def - const pokeStatText1 = addBBCodeTextObject(-5, 0, hp, TextStyle.SUMMARY, { fontSize: textContainerFontSize, lineSpacing: lineSpacing }); + const pokeStatText1 = addBBCodeTextObject(-5, 0, hp, TextStyle.SUMMARY, { + fontSize: textContainerFontSize, + lineSpacing: lineSpacing, + }); pokeStatText1.appendText(atk); pokeStatText1.appendText(def); pokeStatTextContainer.add(pokeStatText1); // Column 2: SpAtk SpDef Speed - const pokeStatText2 = addBBCodeTextObject(25, 0, spatk, TextStyle.SUMMARY, { fontSize: textContainerFontSize, lineSpacing: lineSpacing }); + const pokeStatText2 = addBBCodeTextObject(25, 0, spatk, TextStyle.SUMMARY, { + fontSize: textContainerFontSize, + lineSpacing: lineSpacing, + }); pokeStatText2.appendText(spdef); pokeStatText2.appendText(speed); pokeStatTextContainer.add(pokeStatText2); @@ -681,7 +819,9 @@ export default class RunInfoUiHandler extends UiHandler { const splicedIcon = globalScene.add.image(0, 0, "icon_spliced"); splicedIcon.setScale(0.35); splicedIcon.setOrigin(0, 0); - pokemon.isShiny() ? splicedIcon.setPositionRelative(pokeInfoTextContainer, 35, 0) : splicedIcon.setPositionRelative(pokeInfoTextContainer, 28, 0); + pokemon.isShiny() + ? splicedIcon.setPositionRelative(pokeInfoTextContainer, 35, 0) + : splicedIcon.setPositionRelative(pokeInfoTextContainer, 28, 0); marksContainer.add(splicedIcon); this.getUi().bringToTop(splicedIcon); } @@ -709,32 +849,38 @@ export default class RunInfoUiHandler extends UiHandler { // Need to check if dynamically typed moves const pokemonMoveset = pokemon.getMoveset(); const movesetContainer = globalScene.add.container(70, -29); - const pokemonMoveBgs : Phaser.GameObjects.NineSlice[] = []; - const pokemonMoveLabels : Phaser.GameObjects.Text[] = []; - const movePos = [[ -6.5, 35.5 ], [ 37, 35.5 ], [ -6.5, 43.5 ], [ 37, 43.5 ]]; + const pokemonMoveBgs: Phaser.GameObjects.NineSlice[] = []; + const pokemonMoveLabels: Phaser.GameObjects.Text[] = []; + const movePos = [ + [-6.5, 35.5], + [37, 35.5], + [-6.5, 43.5], + [37, 43.5], + ]; for (let m = 0; m < pokemonMoveset?.length; m++) { - const moveContainer = globalScene.add.container(movePos[m][0], movePos[m][1]); + const moveContainer = globalScene.add.container(movePos[m][0], movePos[m][1]); moveContainer.setScale(0.5); - const moveBg = globalScene.add.nineslice(0, 0, "type_bgs", "unknown", 85, 15, 2, 2, 2, 2); - moveBg.setOrigin(1, 0); - const moveLabel = addTextObject(-moveBg.width / 2, 2, "-", TextStyle.PARTY); - moveLabel.setOrigin(0.5, 0); - moveLabel.setName("text-move-label"); - pokemonMoveBgs.push(moveBg); - pokemonMoveLabels.push(moveLabel); - moveContainer.add(moveBg); - moveContainer.add(moveLabel); - movesetContainer.add(moveContainer); - const move = pokemonMoveset[m]?.getMove(); + const moveBg = globalScene.add.nineslice(0, 0, "type_bgs", "unknown", 85, 15, 2, 2, 2, 2); + moveBg.setOrigin(1, 0); + const moveLabel = addTextObject(-moveBg.width / 2, 2, "-", TextStyle.PARTY); + moveLabel.setOrigin(0.5, 0); + moveLabel.setName("text-move-label"); + pokemonMoveBgs.push(moveBg); + pokemonMoveLabels.push(moveLabel); + moveContainer.add(moveBg); + moveContainer.add(moveLabel); + movesetContainer.add(moveContainer); + const move = pokemonMoveset[m]?.getMove(); pokemonMoveBgs[m].setFrame(PokemonType[move ? move.type : PokemonType.UNKNOWN].toString().toLowerCase()); pokemonMoveLabels[m].setText(move ? move.name : "-"); - } + } // Pokemon Held Items - not displayed by default // Endless/Endless Spliced have a different scale because Pokemon tend to accumulate more items in these runs. - const heldItemsScale = (this.runInfo.gameMode === GameModes.SPLICED_ENDLESS || this.runInfo.gameMode === GameModes.ENDLESS) ? 0.25 : 0.5; + const heldItemsScale = + this.runInfo.gameMode === GameModes.SPLICED_ENDLESS || this.runInfo.gameMode === GameModes.ENDLESS ? 0.25 : 0.5; const heldItemsContainer = globalScene.add.container(-82, 2); - const heldItemsList : Modifier.PokemonHeldItemModifier[] = []; + const heldItemsList: Modifier.PokemonHeldItemModifier[] = []; if (this.runInfo.modifiers.length) { for (const m of this.runInfo.modifiers) { const modifier = m.toModifier(this.modifiersModule[m.className]); @@ -746,14 +892,17 @@ export default class RunInfoUiHandler extends UiHandler { if (heldItemsList.length > 0) { (heldItemsList as Modifier.PokemonHeldItemModifier[]).sort(Modifier.modifierSortFunc); let row = 0; - for (const [ index, item ] of heldItemsList.entries()) { - if ( index > 36 ) { + for (const [index, item] of heldItemsList.entries()) { + if (index > 36) { const overflowIcon = addTextObject(182, 4, "+", TextStyle.WINDOW); heldItemsContainer.add(overflowIcon); break; } const itemIcon = item?.getIcon(true); - if (item?.stackCount < item?.getMaxHeldItemCount(pokemon) && itemIcon.list[1] instanceof Phaser.GameObjects.BitmapText) { + if ( + item?.stackCount < item?.getMaxHeldItemCount(pokemon) && + itemIcon.list[1] instanceof Phaser.GameObjects.BitmapText + ) { itemIcon.list[1].clearTint(); } itemIcon.setScale(heldItemsScale); @@ -784,9 +933,9 @@ export default class RunInfoUiHandler extends UiHandler { pokemonInfoContainer.setName("PkmnInfo"); this.partyContainer.add(pokemonInfoContainer); pokemon.destroy(); - }); + }); this.runContainer.add(this.partyContainer); - } + } /** * Changes what is displayed of the Pokemon's held items @@ -816,7 +965,13 @@ export default class RunInfoUiHandler extends UiHandler { const endCard = globalScene.add.image(0, 0, `end_${isFemale ? "f" : "m"}`); endCard.setOrigin(0); endCard.setScale(0.5); - const text = addTextObject(globalScene.game.canvas.width / 12, (globalScene.game.canvas.height / 6) - 16, i18next.t("battle:congratulations"), TextStyle.SUMMARY, { fontSize: "128px" }); + const text = addTextObject( + globalScene.game.canvas.width / 12, + globalScene.game.canvas.height / 6 - 16, + i18next.t("battle:congratulations"), + TextStyle.SUMMARY, + { fontSize: "128px" }, + ); text.setOrigin(0.5); this.endCardContainer.add(endCard); this.endCardContainer.add(text); @@ -847,8 +1002,13 @@ export default class RunInfoUiHandler extends UiHandler { this.hallofFameContainer.add(endCard); this.hallofFameContainer.add(hallofFameBg); - const hallofFameText = addTextObject(0, 0, i18next.t("runHistory:hallofFameText", { context: genderStr }), TextStyle.WINDOW); - hallofFameText.setPosition(endCardCoords.x - (hallofFameText.displayWidth / 2), 164); + const hallofFameText = addTextObject( + 0, + 0, + i18next.t("runHistory:hallofFameText", { context: genderStr }), + TextStyle.WINDOW, + ); + hallofFameText.setPosition(endCardCoords.x - hallofFameText.displayWidth / 2, 164); this.hallofFameContainer.add(hallofFameText); this.runInfo.party.forEach((p, i) => { const pkmn = p.toPokemon(); @@ -858,8 +1018,11 @@ export default class RunInfoUiHandler extends UiHandler { const formIndex = pkmn.formIndex; const variant = pkmn.variant; const species = pkmn.getSpeciesForm(); - const pokemonSprite: Phaser.GameObjects.Sprite = globalScene.add.sprite(60 + 40 * i, 40 + row * 80, "pkmn__sub"); - pokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + const pokemonSprite: Phaser.GameObjects.Sprite = globalScene.add.sprite(60 + 40 * i, 40 + row * 80, "pkmn__sub"); + pokemonSprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); this.hallofFameContainer.add(pokemonSprite); const speciesLoaded: Map = new Map(); speciesLoaded.set(id, false); @@ -874,7 +1037,7 @@ export default class RunInfoUiHandler extends UiHandler { pokemonSprite.setVisible(true); }); if (pkmn.isFusion()) { - const fusionIcon = globalScene.add.sprite(80 + 40 * i, 50 + row * 80, pkmn.getFusionIconAtlasKey()); + const fusionIcon = globalScene.add.sprite(80 + 40 * i, 50 + row * 80, pkmn.getFusionIconAtlasKey()); fusionIcon.setName("sprite-fusion-icon"); fusionIcon.setOrigin(0.5, 0); fusionIcon.setFrame(pkmn.getFusionIconId(true)); @@ -892,7 +1055,7 @@ export default class RunInfoUiHandler extends UiHandler { * Button.CANCEL, Button.LEFT - removes all containers related to RunInfo and returns the user to Run History * Button.CYCLE_FORM, Button.CYCLE_SHINY, Button.CYCLE_ABILITY - runs the function buttonCycleOption() */ - override processInput(button: Button): boolean { + override processInput(button: Button): boolean { const ui = this.getUi(); let success = false; @@ -986,4 +1149,3 @@ export default class RunInfoUiHandler extends UiHandler { } } } - diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index e746c9302d0..a1e9e5219b4 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -17,13 +17,12 @@ const SLOTS_ON_SCREEN = 3; export enum SaveSlotUiMode { LOAD, - SAVE + SAVE, } export type SaveSlotSelectCallback = (cursor: number) => void; export default class SaveSlotSelectUiHandler extends MessageUiHandler { - private saveSlotSelectContainer: Phaser.GameObjects.Container; private sessionSlotsContainer: Phaser.GameObjects.Container; private saveSlotSelectMessageBox: Phaser.GameObjects.NineSlice; @@ -33,7 +32,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { private uiMode: SaveSlotUiMode; private saveSlotSelectCallback: SaveSlotSelectCallback | null; - private scrollCursor: number = 0; + private scrollCursor = 0; private cursorObj: Phaser.GameObjects.Container | null; @@ -50,7 +49,13 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { this.saveSlotSelectContainer.setVisible(false); ui.add(this.saveSlotSelectContainer); - const loadSessionBg = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, -globalScene.game.canvas.height / 6, 0x006860); + const loadSessionBg = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + -globalScene.game.canvas.height / 6, + 0x006860, + ); loadSessionBg.setOrigin(0, 0); this.saveSlotSelectContainer.add(loadSessionBg); @@ -75,7 +80,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { } show(args: any[]): boolean { - if ((args.length < 2 || !(args[1] instanceof Function))) { + if (args.length < 2 || !(args[1] instanceof Function)) { return false; } @@ -108,31 +113,39 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { switch (this.uiMode) { case SaveSlotUiMode.LOAD: this.saveSlotSelectCallback = null; - originalCallback && originalCallback(cursor); + originalCallback?.(cursor); break; - case SaveSlotUiMode.SAVE: + case SaveSlotUiMode.SAVE: { const saveAndCallback = () => { const originalCallback = this.saveSlotSelectCallback; this.saveSlotSelectCallback = null; ui.revertMode(); ui.showText("", 0); ui.setMode(Mode.MESSAGE); - originalCallback && originalCallback(cursor); + originalCallback?.(cursor); }; if (this.sessionSlots[cursor].hasData) { ui.showText(i18next.t("saveSlotSelectUiHandler:overwriteData"), null, () => { - ui.setOverlayMode(Mode.CONFIRM, () => { - globalScene.gameData.deleteSession(cursor).then(response => { - if (response === false) { - globalScene.reset(true); - } else { - saveAndCallback(); - } - }); - }, () => { - ui.revertMode(); - ui.showText("", 0); - }, false, 0, 19, import.meta.env.DEV ? 300 : 2000); + ui.setOverlayMode( + Mode.CONFIRM, + () => { + globalScene.gameData.deleteSession(cursor).then(response => { + if (response === false) { + globalScene.reset(true); + } else { + saveAndCallback(); + } + }); + }, + () => { + ui.revertMode(); + ui.showText("", 0); + }, + false, + 0, + 19, + import.meta.env.DEV ? 300 : 2000, + ); }); } else if (this.sessionSlots[cursor].hasData === false) { saveAndCallback(); @@ -140,12 +153,13 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { return false; } break; + } } success = true; } } else { this.saveSlotSelectCallback = null; - originalCallback && originalCallback(-1); + originalCallback?.(-1); success = true; } } else { @@ -153,11 +167,11 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { switch (button) { case Button.UP: if (this.cursor) { - // Check to prevent cursor from accessing a negative index - success = (this.cursor === 0) ? this.setCursor(this.cursor) : this.setCursor(this.cursor - 1, cursorPosition); + // Check to prevent cursor from accessing a negative index + success = this.cursor === 0 ? this.setCursor(this.cursor) : this.setCursor(this.cursor - 1, cursorPosition); } else if (this.scrollCursor) { success = this.setScrollCursor(this.scrollCursor - 1, cursorPosition); - } else if ((this.cursor === 0) && (this.scrollCursor === 0)) { + } else if (this.cursor === 0 && this.scrollCursor === 0) { this.setScrollCursor(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN); // Revert to avoid an extra session slot sticking out this.revertSessionSlot(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN); @@ -166,11 +180,14 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { } break; case Button.DOWN: - if (this.cursor < (SLOTS_ON_SCREEN - 1)) { + if (this.cursor < SLOTS_ON_SCREEN - 1) { success = this.setCursor(this.cursor + 1, cursorPosition); } else if (this.scrollCursor < SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN) { success = this.setScrollCursor(this.scrollCursor + 1, cursorPosition); - } else if ((this.cursor === SLOTS_ON_SCREEN - 1) && (this.scrollCursor === SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN)) { + } else if ( + this.cursor === SLOTS_ON_SCREEN - 1 && + this.scrollCursor === SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN + ) { this.setScrollCursor(0); this.revertSessionSlot(SLOTS_ON_SCREEN - 1); this.setCursor(0); @@ -179,7 +196,11 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { break; case Button.RIGHT: if (this.sessionSlots[cursorPosition].hasData && this.sessionSlots[cursorPosition].saveData) { - globalScene.ui.setOverlayMode(Mode.RUN_INFO, this.sessionSlots[cursorPosition].saveData, RunDisplayMode.SESSION_PREVIEW); + globalScene.ui.setOverlayMode( + Mode.RUN_INFO, + this.sessionSlots[cursorPosition].saveData, + RunDisplayMode.SESSION_PREVIEW, + ); success = true; } } @@ -200,17 +221,24 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { globalScene.add.existing(sessionSlot); this.sessionSlotsContainer.add(sessionSlot); this.sessionSlots.push(sessionSlot); - sessionSlot.load().then((success) => { + sessionSlot.load().then(success => { // If the cursor was moved to this slot while the session was loading // call setCursor again to shift the slot position and show the arrow for save preview - if (success && (this.cursor + this.scrollCursor) === s) { + if (success && this.cursor + this.scrollCursor === s) { this.setCursor(s); } }); } } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number) { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + ) { super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); if (text?.indexOf("\n") === -1) { @@ -235,11 +263,22 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { if (!this.cursorObj) { this.cursorObj = globalScene.add.container(0, 0); - const cursorBox = globalScene.add.nineslice(0, 0, "select_cursor_highlight_thick", undefined, 296, 44, 6, 6, 6, 6); + const cursorBox = globalScene.add.nineslice( + 0, + 0, + "select_cursor_highlight_thick", + undefined, + 296, + 44, + 6, + 6, + 6, + 6, + ); const rightArrow = globalScene.add.image(0, 0, "cursor"); rightArrow.setPosition(160, 0); rightArrow.setName("rightArrow"); - this.cursorObj.add([ cursorBox, rightArrow ]); + this.cursorObj.add([cursorBox, rightArrow]); this.sessionSlotsContainer.add(this.cursorObj); } const cursorPosition = cursor + this.scrollCursor; @@ -301,7 +340,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { targets: this.sessionSlotsContainer, y: this.sessionSlotsContainerInitialY - 56 * scrollCursor, duration: Utils.fixedInt(325), - ease: "Sine.easeInOut" + ease: "Sine.easeInOut", }); } @@ -357,7 +396,12 @@ class SessionSlot extends Phaser.GameObjects.Container { async setupWithData(data: SessionSaveData) { this.remove(this.loadingLabel, true); - const gameModeLabel = addTextObject(8, 5, `${GameMode.getModeName(data.gameMode) || i18next.t("gameMode:unkown")} - ${i18next.t("saveSlotSelectUiHandler:wave")} ${data.waveIndex}`, TextStyle.WINDOW); + const gameModeLabel = addTextObject( + 8, + 5, + `${GameMode.getModeName(data.gameMode) || i18next.t("gameMode:unkown")} - ${i18next.t("saveSlotSelectUiHandler:wave")} ${data.waveIndex}`, + TextStyle.WINDOW, + ); this.add(gameModeLabel); const timestampLabel = addTextObject(8, 19, new Date(data.timestamp).toLocaleString(), TextStyle.WINDOW); @@ -374,7 +418,13 @@ class SessionSlot extends Phaser.GameObjects.Container { const pokemon = p.toPokemon(); const icon = globalScene.addPokemonIcon(pokemon, 0, 0, 0, 0); - const text = addTextObject(32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(pokemon.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" }); + const text = addTextObject( + 32, + 20, + `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(pokemon.level, 1000)}`, + TextStyle.PARTY, + { fontSize: "54px", color: "#f8f8f8" }, + ); text.setShadow(0, 0, undefined); text.setStroke("#424242", 14); text.setOrigin(1, 0); diff --git a/src/ui/saving-icon-handler.ts b/src/ui/saving-icon-handler.ts index ca7b1fb1aa8..4404ea423b1 100644 --- a/src/ui/saving-icon-handler.ts +++ b/src/ui/saving-icon-handler.ts @@ -45,7 +45,7 @@ export default class SavingIconHandler extends Phaser.GameObjects.Container { this.hide(); } }); - } + }, }); this.setVisible(true); @@ -72,7 +72,7 @@ export default class SavingIconHandler extends Phaser.GameObjects.Container { if (this.shown) { this.show(); } - } + }, }); this.shown = false; diff --git a/src/ui/scroll-bar.ts b/src/ui/scroll-bar.ts index eb74bfddfde..404553025e3 100644 --- a/src/ui/scroll-bar.ts +++ b/src/ui/scroll-bar.ts @@ -29,7 +29,18 @@ export class ScrollBar extends Phaser.GameObjects.Container { const borderSize = 2; width = Math.max(width, 4); - this.bg = globalScene.add.nineslice(0, 0, "scroll_bar", undefined, width, height, borderSize, borderSize, borderSize, borderSize); + this.bg = globalScene.add.nineslice( + 0, + 0, + "scroll_bar", + undefined, + width, + height, + borderSize, + borderSize, + borderSize, + borderSize, + ); this.bg.setOrigin(0, 0); this.add(this.bg); @@ -60,14 +71,16 @@ export class ScrollBar extends Phaser.GameObjects.Container { */ setTotalRows(rows: number): void { this.totalRows = rows; - this.handleBody.height = (this.bg.displayHeight - 1 - this.handleBottom.displayHeight) * this.maxRows / this.totalRows; + this.handleBody.height = + ((this.bg.displayHeight - 1 - this.handleBottom.displayHeight) * this.maxRows) / this.totalRows; this.updateHandlePosition(); this.setVisible(this.totalRows > this.maxRows); } private updateHandlePosition(): void { - this.handleBody.y = 1 + (this.bg.displayHeight - 1 - this.handleBottom.displayHeight) / this.totalRows * this.currentRow; + this.handleBody.y = + 1 + ((this.bg.displayHeight - 1 - this.handleBottom.displayHeight) / this.totalRows) * this.currentRow; this.handleBottom.y = this.handleBody.y + this.handleBody.displayHeight; } } diff --git a/src/ui/scrollable-grid-handler.ts b/src/ui/scrollable-grid-handler.ts index 04851ec002f..54f07d69fb7 100644 --- a/src/ui/scrollable-grid-handler.ts +++ b/src/ui/scrollable-grid-handler.ts @@ -111,7 +111,7 @@ export default class ScrollableGridUiHandler { } else if (this.scrollCursor > 0) { success = this.setScrollCursor(this.scrollCursor - 1); } else { - // wrap around to the last row + // wrap around to the last row let newCursor = this.cursor + (onScreenRows - 1) * this.COLUMNS; if (newCursor > lastVisibleIndex) { newCursor -= this.COLUMNS; @@ -121,13 +121,13 @@ export default class ScrollableGridUiHandler { break; case Button.DOWN: if (currentRowIndex < onScreenRows - 1) { - // Go down one row + // Go down one row success = this.setCursor(Math.min(this.cursor + this.COLUMNS, this.totalElements - itemOffset - 1)); } else if (this.scrollCursor < maxScrollCursor) { - // Scroll down one row + // Scroll down one row success = this.setScrollCursor(this.scrollCursor + 1); } else { - // Wrap around to the top row + // Wrap around to the top row success = this.setScrollCursor(0, this.cursor % this.COLUMNS); } break; @@ -192,5 +192,4 @@ export default class ScrollableGridUiHandler { return scrollChanged || cursorChanged; } - } diff --git a/src/ui/session-reload-modal-ui-handler.ts b/src/ui/session-reload-modal-ui-handler.ts index 640268f0480..d3b88da9e63 100644 --- a/src/ui/session-reload-modal-ui-handler.ts +++ b/src/ui/session-reload-modal-ui-handler.ts @@ -21,27 +21,33 @@ export default class SessionReloadModalUiHandler extends ModalUiHandler { } getMargin(): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + return [0, 0, 48, 0]; } getButtonLabels(): string[] { - return [ ]; + return []; } setup(): void { super.setup(); - const label = addTextObject(this.getWidth() / 2, this.getHeight() / 2, "Your session is out of date.\nYour data will be reloaded…", TextStyle.WINDOW, { fontSize: "48px", align: "center" }); + const label = addTextObject( + this.getWidth() / 2, + this.getHeight() / 2, + "Your session is out of date.\nYour data will be reloaded…", + TextStyle.WINDOW, + { fontSize: "48px", align: "center" }, + ); label.setOrigin(0.5, 0.5); this.modalContainer.add(label); } - show(args: any[]): boolean { + show(_args: any[]): boolean { const config: ModalConfig = { - buttonActions: [] + buttonActions: [], }; - return super.show([ config ]); + return super.show([config]); } } diff --git a/src/ui/settings/abstract-binding-ui-handler.ts b/src/ui/settings/abstract-binding-ui-handler.ts index e8c3e20c38f..62f78da89f5 100644 --- a/src/ui/settings/abstract-binding-ui-handler.ts +++ b/src/ui/settings/abstract-binding-ui-handler.ts @@ -29,7 +29,7 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { protected actionLabel: Phaser.GameObjects.Text; protected cancelLabel: Phaser.GameObjects.Text; - protected listening: boolean = false; + protected listening = false; protected buttonPressed: number | null = null; // Icons for displaying current and new button assignments. @@ -40,24 +40,24 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { protected cancelFn: CancelFn | null; abstract swapAction(): boolean; - protected timeLeftAutoClose: number = 5; + protected timeLeftAutoClose = 5; protected countdownTimer; // The specific setting being modified. protected target; /** - * Constructor for the AbstractBindingUiHandler. - * - * @param mode - The UI mode. - */ + * Constructor for the AbstractBindingUiHandler. + * + * @param mode - The UI mode. + */ constructor(mode: Mode | null = null) { super(mode); } /** - * Setup UI elements. - */ + * Setup UI elements. + */ setup() { const ui = this.getUi(); this.optionSelectContainer = globalScene.add.container(0, 0); @@ -71,11 +71,21 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { ui.add(this.actionsContainer); // Setup backgrounds and text objects for UI. - this.titleBg = addWindow((globalScene.game.canvas.width / 6) - this.getWindowWidth(), -(globalScene.game.canvas.height / 6) + 28 + 21, this.getWindowWidth(), 24); + this.titleBg = addWindow( + globalScene.game.canvas.width / 6 - this.getWindowWidth(), + -(globalScene.game.canvas.height / 6) + 28 + 21, + this.getWindowWidth(), + 24, + ); this.titleBg.setOrigin(0.5); this.optionSelectContainer.add(this.titleBg); - this.actionBg = addWindow((globalScene.game.canvas.width / 6) - this.getWindowWidth(), -(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28 + 21 + 21, this.getWindowWidth(), 24); + this.actionBg = addWindow( + globalScene.game.canvas.width / 6 - this.getWindowWidth(), + -(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28 + 21 + 21, + this.getWindowWidth(), + 24, + ); this.actionBg.setOrigin(0.5); this.actionsContainer.add(this.actionBg); @@ -87,10 +97,15 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { this.timerText = addTextObject(0, 0, "(5)", TextStyle.WINDOW); this.timerText.setOrigin(0, 0); - this.timerText.setPositionRelative(this.unlockText, (this.unlockText.width / 6) + 5, 0); + this.timerText.setPositionRelative(this.unlockText, this.unlockText.width / 6 + 5, 0); this.optionSelectContainer.add(this.timerText); - this.optionSelectBg = addWindow((globalScene.game.canvas.width / 6) - this.getWindowWidth(), -(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28, this.getWindowWidth(), this.getWindowHeight()); + this.optionSelectBg = addWindow( + globalScene.game.canvas.width / 6 - this.getWindowWidth(), + -(globalScene.game.canvas.height / 6) + this.getWindowHeight() + 28, + this.getWindowWidth(), + this.getWindowHeight(), + ); this.optionSelectBg.setOrigin(0.5); this.optionSelectContainer.add(this.optionSelectBg); @@ -108,17 +123,17 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { if (this.timeLeftAutoClose >= 0) { this.manageAutoCloseTimer(); } else { - this.cancelFn && this.cancelFn(); + this.cancelFn?.(); } }, 1000); } /** - * Show the UI with the provided arguments. - * - * @param args - Arguments to be passed to the show method. - * @returns `true` if successful. - */ + * Show the UI with the provided arguments. + * + * @param args - Arguments to be passed to the show method. + * @returns `true` if successful. + */ show(args: any[]): boolean { super.show(args); this.buttonPressed = null; @@ -139,29 +154,29 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { } /** - * Get the width of the window. - * - * @returns The window width. - */ + * Get the width of the window. + * + * @returns The window width. + */ getWindowWidth(): number { return 160; } /** - * Get the height of the window. - * - * @returns The window height. - */ + * Get the height of the window. + * + * @returns The window height. + */ getWindowHeight(): number { return 64; } /** - * Process the input for the given button. - * - * @param button - The button to process. - * @returns `true` if the input was processed successfully. - */ + * Process the input for the given button. + * + * @param button - The button to process. + * @returns `true` if the input was processed successfully. + */ processInput(button: Button): boolean { if (this.buttonPressed === null) { return false; // TODO: is false correct as default? (previously was `undefined`) @@ -170,19 +185,19 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { let success = false; switch (button) { case Button.LEFT: - case Button.RIGHT: - // Toggle between action and cancel options. - const cursor = this.cursor ? 0 : 1; - success = this.setCursor(cursor); + case Button.RIGHT: { + // Toggle between action and cancel options. + success = this.setCursor(this.cursor ? 0 : 1); break; + } case Button.ACTION: - // Process actions based on current cursor position. + // Process actions based on current cursor position. if (this.cursor === 0) { - this.cancelFn && this.cancelFn(); + this.cancelFn?.(); } else { success = this.swapAction(); NavigationManager.getInstance().updateIcons(); - this.cancelFn && this.cancelFn(success); + this.cancelFn?.(success); } break; } @@ -198,11 +213,11 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { } /** - * Set the cursor to the specified position. - * - * @param cursor - The cursor position to set. - * @returns `true` if the cursor was set successfully. - */ + * Set the cursor to the specified position. + * + * @param cursor - The cursor position to set. + * @returns `true` if the cursor was set successfully. + */ setCursor(cursor: number): boolean { this.cursor = cursor; if (cursor === 1) { @@ -220,8 +235,8 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { } /** - * Clear the UI elements and state. - */ + * Clear the UI elements and state. + */ clear() { super.clear(); clearTimeout(this.countdownTimer); @@ -237,12 +252,12 @@ export default abstract class AbstractBindingUiHandler extends UiHandler { } /** - * Handle input down events. - * - * @param buttonIcon - The icon of the button that was pressed. - * @param assignedButtonIcon - The icon of the button that is assigned. - * @param type - The type of button press. - */ + * Handle input down events. + * + * @param buttonIcon - The icon of the button that was pressed. + * @param assignedButtonIcon - The icon of the button that is assigned. + * @param type - The type of button press. + */ onInputDown(buttonIcon: string, assignedButtonIcon: string | null, type: string): void { clearTimeout(this.countdownTimer); this.timerText.setText(""); diff --git a/src/ui/settings/abstract-control-settings-ui-handler.ts b/src/ui/settings/abstract-control-settings-ui-handler.ts index 59af1abba2a..2c634e2c5bf 100644 --- a/src/ui/settings/abstract-control-settings-ui-handler.ts +++ b/src/ui/settings/abstract-control-settings-ui-handler.ts @@ -12,17 +12,17 @@ import i18next from "i18next"; import { globalScene } from "#app/global-scene"; export interface InputsIcons { - [key: string]: Phaser.GameObjects.Sprite; + [key: string]: Phaser.GameObjects.Sprite; } export interface LayoutConfig { - optionsContainer: Phaser.GameObjects.Container; - inputsIcons: InputsIcons; - settingLabels: Phaser.GameObjects.Text[]; - optionValueLabels: Phaser.GameObjects.Text[][]; - optionCursors: number[]; - keys: string[]; - bindingSettings: Array; + optionsContainer: Phaser.GameObjects.Container; + inputsIcons: InputsIcons; + settingLabels: Phaser.GameObjects.Text[]; + optionValueLabels: Phaser.GameObjects.Text[][]; + optionCursors: number[]; + keys: string[]; + bindingSettings: Array; } /** * Abstract class for handling UI elements related to control settings. @@ -49,10 +49,10 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler protected inputsIcons: InputsIcons; protected navigationIcons: InputsIcons; // list all the setting keys used in the selected layout (because dualshock has more buttons than xbox) - protected keys: Array; + protected keys: Array; // Store the specific settings related to key bindings for the current gamepad configuration. - protected bindingSettings: Array; + protected bindingSettings: Array; protected setting; protected settingBlacklisted; @@ -81,14 +81,16 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler getLocalStorageSetting(): object { // Retrieve the settings from local storage or use an empty object if none exist. - const settings: object = localStorage.hasOwnProperty(this.localStoragePropertyName) ? JSON.parse(localStorage.getItem(this.localStoragePropertyName)!) : {}; // TODO: is this bang correct? + const settings: object = localStorage.hasOwnProperty(this.localStoragePropertyName) + ? JSON.parse(localStorage.getItem(this.localStoragePropertyName)!) + : {}; // TODO: is this bang correct? return settings; } private camelize(string: string): string { - return string.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) { - return index === 0 ? word.toLowerCase() : word.toUpperCase(); - }).replace(/\s+/g, ""); + return string + .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => (index === 0 ? word.toLowerCase() : word.toUpperCase())) + .replace(/\s+/g, ""); } /** @@ -101,15 +103,27 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler this.settingsContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.settingsContainer.setName(`settings-${this.titleSelected}`); - this.settingsContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), Phaser.Geom.Rectangle.Contains); + this.settingsContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6), + Phaser.Geom.Rectangle.Contains, + ); this.navigationContainer = new NavigationMenu(0, 0); - this.optionsBg = addWindow(0, this.navigationContainer.height, (globalScene.game.canvas.width / 6) - 2, (globalScene.game.canvas.height / 6) - 16 - this.navigationContainer.height - 2); + this.optionsBg = addWindow( + 0, + this.navigationContainer.height, + globalScene.game.canvas.width / 6 - 2, + globalScene.game.canvas.height / 6 - 16 - this.navigationContainer.height - 2, + ); this.optionsBg.setOrigin(0, 0); - - this.actionsBg = addWindow(0, (globalScene.game.canvas.height / 6) - this.navigationContainer.height, (globalScene.game.canvas.width / 6) - 2, 22); + this.actionsBg = addWindow( + 0, + globalScene.game.canvas.height / 6 - this.navigationContainer.height, + globalScene.game.canvas.width / 6 - 2, + 22, + ); this.actionsBg.setOrigin(0, 0); const iconAction = globalScene.add.sprite(0, 0, "keyboard"); @@ -171,13 +185,21 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler const inputsIcons: InputsIcons = {}; // Fetch common setting keys such as 'Controller' and 'Gamepad Support' from gamepad settings. - const commonSettingKeys = Object.keys(this.setting).slice(0, this.commonSettingsCount).map(key => this.setting[key]); + const commonSettingKeys = Object.keys(this.setting) + .slice(0, this.commonSettingsCount) + .map(key => this.setting[key]); // Combine common and specific bindings into a single array. - const specificBindingKeys = [ ...commonSettingKeys, ...Object.keys(config.settings) ]; + const specificBindingKeys = [...commonSettingKeys, ...Object.keys(config.settings)]; // Fetch default values for these settings and prepare to highlight selected options. - const optionCursors = Object.values(Object.keys(this.settingDeviceDefaults).filter(s => specificBindingKeys.includes(s)).map(k => this.settingDeviceDefaults[k])); + const optionCursors = Object.values( + Object.keys(this.settingDeviceDefaults) + .filter(s => specificBindingKeys.includes(s)) + .map(k => this.settingDeviceDefaults[k]), + ); // Filter out settings that are not relevant to the current gamepad configuration. - const settingFiltered = Object.keys(this.setting).filter(_key => specificBindingKeys.includes(this.setting[_key])); + const settingFiltered = Object.keys(this.setting).filter(_key => + specificBindingKeys.includes(this.setting[_key]), + ); // Loop through the filtered settings to manage display and options. settingFiltered.forEach((setting, s) => { @@ -202,7 +224,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler const valueLabels: Phaser.GameObjects.GameObject[] = []; // Process each option for the current setting. - for (const [ o, option ] of this.settingDeviceOptions[this.setting[setting]].entries()) { + for (const [o, option] of this.settingDeviceOptions[this.setting[setting]].entries()) { // Check if the current setting is for binding keys. if (bindingSettings.includes(this.setting[setting])) { // Create a label for non-null options, typically indicating actionable options like 'change'. @@ -222,7 +244,12 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler continue; } // For regular settings like 'Gamepad support', create a label and determine if it is selected. - const valueLabel = addTextObject(0, 0, option, this.settingDeviceDefaults[this.setting[setting]] === o ? TextStyle.SETTINGS_SELECTED : TextStyle.WINDOW); + const valueLabel = addTextObject( + 0, + 0, + option, + this.settingDeviceDefaults[this.setting[setting]] === o ? TextStyle.SETTINGS_SELECTED : TextStyle.WINDOW, + ); valueLabel.setOrigin(0, 0); optionsContainer.add(valueLabel); @@ -235,14 +262,16 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler // Calculate the total width of all option labels within a specific setting // This is achieved by summing the width of each option label - const totalWidth = optionValueLabels[s].map((o) => (o as Phaser.GameObjects.Text).width).reduce((total, width) => total += width, 0); + const totalWidth = optionValueLabels[s] + .map(o => (o as Phaser.GameObjects.Text).width) + .reduce((total, width) => (total += width), 0); // Define the minimum width for a label, ensuring it's at least 78 pixels wide or the width of the setting label plus some padding const labelWidth = Math.max(130, settingLabels[s].displayWidth + 8); // Calculate the total available space for placing option labels next to their setting label // We reserve space for the setting label and then distribute the remaining space evenly - const totalSpace = (297 - labelWidth) - totalWidth / 6; + const totalSpace = 297 - labelWidth - totalWidth / 6; // Calculate the spacing between options based on the available space divided by the number of gaps between labels const optionSpacing = Math.floor(totalSpace / (optionValueLabels[s].length - 1)); @@ -272,7 +301,13 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler } // Add vertical scrollbar - this.scrollBar = new ScrollBar(this.optionsBg.width - 9, this.optionsBg.y + 5, 4, this.optionsBg.height - 11, this.rowsToDisplay); + this.scrollBar = new ScrollBar( + this.optionsBg.width - 9, + this.optionsBg.y + 5, + 4, + this.optionsBg.height - 11, + this.rowsToDisplay, + ); this.settingsContainer.add(this.scrollBar); // Add the settings container to the UI. @@ -296,7 +331,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler */ updateBindings(): void { // Hide the options container for all layouts to reset the UI visibility. - Object.keys(this.layout).forEach((key) => this.layout[key].optionsContainer.setVisible(false)); + Object.keys(this.layout).forEach(key => this.layout[key].optionsContainer.setVisible(false)); // Fetch the active gamepad configuration from the input controller. const activeConfig = this.getActiveConfig(); @@ -310,7 +345,10 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler // Update the cursor for each key based on the stored settings or default cursors. this.keys.forEach((key, index) => { - this.setOptionCursor(index, settings.hasOwnProperty(key as string) ? settings[key as string] : this.optionCursors[index]); + this.setOptionCursor( + index, + settings.hasOwnProperty(key as string) ? settings[key as string] : this.optionCursors[index], + ); }); // If the active configuration has no custom bindings set, exit the function early. @@ -338,8 +376,8 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler updateNavigationDisplay() { const specialIcons = { - "BUTTON_HOME": "HOME.png", - "BUTTON_DELETE": "DEL.png", + BUTTON_HOME: "HOME.png", + BUTTON_DELETE: "DEL.png", }; for (const settingName of Object.keys(this.navigationIcons)) { if (Object.keys(specialIcons).includes(settingName)) { @@ -462,15 +500,17 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler if (!this.optionValueLabels) { return false; } - if (cursor) { // If not at the top, move the cursor up. + if (cursor) { + // If not at the top, move the cursor up. if (this.cursor) { success = this.setCursor(this.cursor - 1); - } else {// If at the top of the visible items, scroll up. + } else { + // If at the top of the visible items, scroll up. success = this.setScrollCursor(this.scrollCursor - 1); } } else { - // When at the top of the menu and pressing UP, move to the bottommost item. - // First, set the cursor to the last visible element, preparing for the scroll to the end. + // When at the top of the menu and pressing UP, move to the bottommost item. + // First, set the cursor to the last visible element, preparing for the scroll to the end. const successA = this.setCursor(this.rowsToDisplay - 1); // Then, adjust the scroll to display the bottommost elements of the menu. const successB = this.setScrollCursor(this.optionValueLabels.length - this.rowsToDisplay); @@ -488,8 +528,8 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler success = this.setScrollCursor(this.scrollCursor + 1); } } else { - // When at the bottom of the menu and pressing DOWN, move to the topmost item. - // First, set the cursor to the first visible element, resetting the scroll to the top. + // When at the bottom of the menu and pressing DOWN, move to the topmost item. + // First, set the cursor to the first visible element, resetting the scroll to the top. const successA = this.setCursor(0); // Then, reset the scroll to start from the first element of the menu. const successB = this.setScrollCursor(0); @@ -555,7 +595,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler // Check if the cursor object exists, if not, create it. if (!this.cursorObj) { - const cursorWidth = (globalScene.game.canvas.width / 6) - (this.scrollBar.visible ? 16 : 10); + const cursorWidth = globalScene.game.canvas.width / 6 - (this.scrollBar.visible ? 16 : 10); this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1); this.cursorObj.setOrigin(0, 0); // Set the origin to the top-left corner. this.optionsContainer.add(this.cursorObj); // Add the cursor to the options container. @@ -681,5 +721,4 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler // Set the cursor object reference to null to fully dereference it. this.cursorObj = null; } - } diff --git a/src/ui/settings/abstract-settings-ui-handler.ts b/src/ui/settings/abstract-settings-ui-handler.ts index 7300b6d3266..0c14b91251e 100644 --- a/src/ui/settings/abstract-settings-ui-handler.ts +++ b/src/ui/settings/abstract-settings-ui-handler.ts @@ -11,7 +11,6 @@ import { Setting, SettingKeys } from "#app/system/settings/settings"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; - /** * Abstract class for handling UI elements related to settings. */ @@ -58,17 +57,30 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { this.settingsContainer = globalScene.add.container(1, -(globalScene.game.canvas.height / 6) + 1); this.settingsContainer.setName(`settings-${this.title}`); - this.settingsContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6 - 20), Phaser.Geom.Rectangle.Contains); + this.settingsContainer.setInteractive( + new Phaser.Geom.Rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6 - 20), + Phaser.Geom.Rectangle.Contains, + ); this.navigationIcons = {}; this.navigationContainer = new NavigationMenu(0, 0); - this.optionsBg = addWindow(0, this.navigationContainer.height, (globalScene.game.canvas.width / 6) - 2, (globalScene.game.canvas.height / 6) - 16 - this.navigationContainer.height - 2); + this.optionsBg = addWindow( + 0, + this.navigationContainer.height, + globalScene.game.canvas.width / 6 - 2, + globalScene.game.canvas.height / 6 - 16 - this.navigationContainer.height - 2, + ); this.optionsBg.setName("window-options-bg"); this.optionsBg.setOrigin(0, 0); - const actionsBg = addWindow(0, (globalScene.game.canvas.height / 6) - this.navigationContainer.height, (globalScene.game.canvas.width / 6) - 2, 22); + const actionsBg = addWindow( + 0, + globalScene.game.canvas.height / 6 - this.navigationContainer.height, + globalScene.game.canvas.width / 6 - 2, + 22, + ); actionsBg.setOrigin(0, 0); const iconAction = globalScene.add.sprite(0, 0, "keyboard"); @@ -96,44 +108,56 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { this.reloadSettings = this.settings.filter(s => s?.requireReload); - this.settings - .forEach((setting, s) => { - let settingName = setting.label; - if (setting?.requireReload) { - settingName += ` (${i18next.t("settings:requireReload")})`; - } + this.settings.forEach((setting, s) => { + let settingName = setting.label; + if (setting?.requireReload) { + settingName += ` (${i18next.t("settings:requireReload")})`; + } - this.settingLabels[s] = addTextObject(8, 28 + s * 16, settingName, TextStyle.SETTINGS_LABEL); - this.settingLabels[s].setOrigin(0, 0); + this.settingLabels[s] = addTextObject(8, 28 + s * 16, settingName, TextStyle.SETTINGS_LABEL); + this.settingLabels[s].setOrigin(0, 0); - this.optionsContainer.add(this.settingLabels[s]); - this.optionValueLabels.push(setting.options.map((option, o) => { - const valueLabel = addTextObject(0, 0, option.label, setting.default === o ? TextStyle.SETTINGS_SELECTED : TextStyle.SETTINGS_VALUE); + this.optionsContainer.add(this.settingLabels[s]); + this.optionValueLabels.push( + setting.options.map((option, o) => { + const valueLabel = addTextObject( + 0, + 0, + option.label, + setting.default === o ? TextStyle.SETTINGS_SELECTED : TextStyle.SETTINGS_VALUE, + ); valueLabel.setOrigin(0, 0); this.optionsContainer.add(valueLabel); return valueLabel; - })); + }), + ); - const totalWidth = this.optionValueLabels[s].map(o => o.width).reduce((total, width) => total += width, 0); + const totalWidth = this.optionValueLabels[s].map(o => o.width).reduce((total, width) => (total += width), 0); - const labelWidth = Math.max(78, this.settingLabels[s].displayWidth + 8); + const labelWidth = Math.max(78, this.settingLabels[s].displayWidth + 8); - const totalSpace = (297 - labelWidth) - totalWidth / 6; - const optionSpacing = Math.floor(totalSpace / (this.optionValueLabels[s].length - 1)); + const totalSpace = 297 - labelWidth - totalWidth / 6; + const optionSpacing = Math.floor(totalSpace / (this.optionValueLabels[s].length - 1)); - let xOffset = 0; + let xOffset = 0; - for (const value of this.optionValueLabels[s]) { - value.setPositionRelative(this.settingLabels[s], labelWidth + xOffset, 0); - xOffset += value.width / 6 + optionSpacing; - } - }); + for (const value of this.optionValueLabels[s]) { + value.setPositionRelative(this.settingLabels[s], labelWidth + xOffset, 0); + xOffset += value.width / 6 + optionSpacing; + } + }); this.optionCursors = this.settings.map(setting => setting.default); - this.scrollBar = new ScrollBar(this.optionsBg.width - 9, this.optionsBg.y + 5, 4, this.optionsBg.height - 11, this.rowsToDisplay); + this.scrollBar = new ScrollBar( + this.optionsBg.width - 9, + this.optionsBg.y + 5, + 4, + this.optionsBg.height - 11, + this.rowsToDisplay, + ); this.scrollBar.setTotalRows(this.settings.length); // Two-lines message box @@ -145,7 +169,9 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { settingsMessageBox.setOrigin(0, 1); this.messageBoxContainer.add(settingsMessageBox); - const messageText = addTextObject(8, -40, "", TextStyle.WINDOW, { maxLines: 2 }); + const messageText = addTextObject(8, -40, "", TextStyle.WINDOW, { + maxLines: 2, + }); messageText.setWordWrapWidth(globalScene.game.canvas.width - 60); messageText.setName("settings-message"); messageText.setOrigin(0, 0); @@ -200,14 +226,18 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { * * @param args - Arguments to be passed to the show method. * @returns `true` if successful. - */ + */ show(args: any[]): boolean { super.show(args); this.updateBindings(); - const settings: object = localStorage.hasOwnProperty(this.localStorageKey) ? JSON.parse(localStorage.getItem(this.localStorageKey)!) : {}; // TODO: is this bang correct? + const settings: object = localStorage.hasOwnProperty(this.localStorageKey) + ? JSON.parse(localStorage.getItem(this.localStorageKey)!) + : {}; // TODO: is this bang correct? - this.settings.forEach((setting, s) => this.setOptionCursor(s, settings.hasOwnProperty(setting.key) ? settings[setting.key] : this.settings[s].default)); + this.settings.forEach((setting, s) => + this.setOptionCursor(s, settings.hasOwnProperty(setting.key) ? settings[setting.key] : this.settings[s].default), + ); this.settingsContainer.setVisible(true); this.setCursor(0); @@ -251,8 +281,8 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { success = this.setScrollCursor(this.scrollCursor - 1); } } else { - // When at the top of the menu and pressing UP, move to the bottommost item. - // First, set the cursor to the last visible element, preparing for the scroll to the end. + // When at the top of the menu and pressing UP, move to the bottommost item. + // First, set the cursor to the last visible element, preparing for the scroll to the end. const successA = this.setCursor(this.rowsToDisplay - 1); // Then, adjust the scroll to display the bottommost elements of the menu. const successB = this.setScrollCursor(this.optionValueLabels.length - this.rowsToDisplay); @@ -261,14 +291,15 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { break; case Button.DOWN: if (cursor < this.optionValueLabels.length - 1) { - if (this.cursor < this.rowsToDisplay - 1) {// if the visual cursor is in the frame of 0 to 8 + if (this.cursor < this.rowsToDisplay - 1) { + // if the visual cursor is in the frame of 0 to 8 success = this.setCursor(this.cursor + 1); } else if (this.scrollCursor < this.optionValueLabels.length - this.rowsToDisplay) { success = this.setScrollCursor(this.scrollCursor + 1); } } else { - // When at the bottom of the menu and pressing DOWN, move to the topmost item. - // First, set the cursor to the first visible element, resetting the scroll to the top. + // When at the bottom of the menu and pressing DOWN, move to the topmost item. + // First, set the cursor to the first visible element, resetting the scroll to the top. const successA = this.setCursor(0); // Then, reset the scroll to start from the first element of the menu. const successB = this.setScrollCursor(0); @@ -276,12 +307,13 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { } break; case Button.LEFT: - if (this.optionCursors[cursor]) {// Moves the option cursor left, if possible. + if (this.optionCursors[cursor]) { + // Moves the option cursor left, if possible. success = this.setOptionCursor(cursor, this.optionCursors[cursor] - 1, true); } break; case Button.RIGHT: - // Moves the option cursor right, if possible. + // Moves the option cursor right, if possible. if (this.optionCursors[cursor] < this.optionValueLabels[cursor].length - 1) { success = this.setOptionCursor(cursor, this.optionCursors[cursor] + 1, true); } @@ -331,7 +363,7 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { const ret = super.setCursor(cursor); if (!this.cursorObj) { - const cursorWidth = (globalScene.game.canvas.width / 6) - (this.scrollBar.visible ? 16 : 10); + const cursorWidth = globalScene.game.canvas.width / 6 - (this.scrollBar.visible ? 16 : 10); this.cursorObj = globalScene.add.nineslice(0, 0, "summary_moves_cursor", undefined, cursorWidth, 16, 1, 1, 1, 1); this.cursorObj.setOrigin(0, 0); this.optionsContainer.add(this.cursorObj); @@ -390,7 +422,8 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { this.setOptionCursor(settingIndex, lastCursor, false); }; - const confirmationMessage = setting.options[cursor].confirmationMessage ?? i18next.t("settings:defaultConfirmMessage"); + 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); }); @@ -463,7 +496,14 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { this.cursorObj = null; } - override showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number) { + override showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + ) { this.messageBoxContainer.setVisible(!!text?.length); super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); } diff --git a/src/ui/settings/gamepad-binding-ui-handler.ts b/src/ui/settings/gamepad-binding-ui-handler.ts index b69c2f34e06..62bc2db7825 100644 --- a/src/ui/settings/gamepad-binding-ui-handler.ts +++ b/src/ui/settings/gamepad-binding-ui-handler.ts @@ -5,9 +5,7 @@ import { getIconWithSettingName, getKeyWithKeycode } from "#app/configs/inputs/c import { addTextObject, TextStyle } from "#app/ui/text"; import { globalScene } from "#app/global-scene"; - export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { - constructor(mode: Mode | null = null) { super(mode); globalScene.input.gamepad?.on("down", this.gamepadButtonDown, this); @@ -23,7 +21,11 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { this.swapText = addTextObject(0, 0, "will swap with", TextStyle.WINDOW); this.swapText.setOrigin(0.5); - this.swapText.setPositionRelative(this.optionSelectBg, this.optionSelectBg.width / 2 - 2, this.optionSelectBg.height / 2 - 2); + this.swapText.setPositionRelative( + this.optionSelectBg, + this.optionSelectBg.width / 2 - 2, + this.optionSelectBg.height / 2 - 2, + ); this.swapText.setVisible(false); this.targetButtonIcon = globalScene.add.sprite(0, 0, "xbox"); @@ -45,10 +47,15 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { return globalScene.inputController?.selectedDevice[Device.GAMEPAD]; } - gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, value: number): void { - const blacklist = [ 12, 13, 14, 15 ]; // d-pad buttons are blacklisted. + gamepadButtonDown(pad: Phaser.Input.Gamepad.Gamepad, button: Phaser.Input.Gamepad.Button, _value: number): void { + const blacklist = [12, 13, 14, 15]; // d-pad buttons are blacklisted. // Check conditions before processing the button press. - if (!this.listening || pad.id.toLowerCase() !== this.getSelectedDevice() || blacklist.includes(button.index) || this.buttonPressed !== null) { + if ( + !this.listening || + pad.id.toLowerCase() !== this.getSelectedDevice() || + blacklist.includes(button.index) || + this.buttonPressed !== null + ) { return; } const activeConfig = globalScene.inputController.getActiveConfig(Device.GAMEPAD); @@ -73,8 +80,8 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler { } /** - * Clear the UI elements and state. - */ + * Clear the UI elements and state. + */ clear() { super.clear(); this.targetButtonIcon.setVisible(false); diff --git a/src/ui/settings/keyboard-binding-ui-handler.ts b/src/ui/settings/keyboard-binding-ui-handler.ts index ddc60a15631..8735faeaaab 100644 --- a/src/ui/settings/keyboard-binding-ui-handler.ts +++ b/src/ui/settings/keyboard-binding-ui-handler.ts @@ -5,9 +5,7 @@ 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) { super(mode); // Listen to gamepad button down events to initiate binding. @@ -70,5 +68,4 @@ export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler { } return false; } - } diff --git a/src/ui/settings/move-touch-controls-handler.ts b/src/ui/settings/move-touch-controls-handler.ts index 48677122363..44377c8c2ab 100644 --- a/src/ui/settings/move-touch-controls-handler.ts +++ b/src/ui/settings/move-touch-controls-handler.ts @@ -6,27 +6,25 @@ import i18next from "i18next"; export const TOUCH_CONTROL_POSITIONS_LANDSCAPE = "touchControlPositionsLandscape"; export const TOUCH_CONTROL_POSITIONS_PORTRAIT = "touchControlPositionsPortrait"; - -type ControlPosition = { id: string, x: number, y: number }; +type ControlPosition = { id: string; x: number; y: number }; type ConfigurationEventListeners = { - "touchstart": EventListener[] - "touchmove": EventListener[] - "touchend": EventListener[] + touchstart: EventListener[]; + touchmove: EventListener[]; + touchend: EventListener[]; }; type ToolbarRefs = { - toolbar: HTMLDivElement, - saveButton: HTMLDivElement - resetButton: HTMLDivElement - cancelButton: HTMLDivElement + toolbar: HTMLDivElement; + saveButton: HTMLDivElement; + resetButton: HTMLDivElement; + cancelButton: HTMLDivElement; }; /** * Handles the dragging of touch controls around the screen. */ export default class MoveTouchControlsHandler { - /** The element that is currently being dragged */ private draggingElement: HTMLElement | null = null; @@ -41,9 +39,9 @@ export default class MoveTouchControlsHandler { * These are used to remove the event listeners when the configuration mode is disabled. */ private configurationEventListeners: ConfigurationEventListeners = { - "touchstart": [], - "touchmove": [], - "touchend": [] + touchstart: [], + touchmove: [], + touchend: [], }; private overlay: Phaser.GameObjects.Container; @@ -55,7 +53,7 @@ export default class MoveTouchControlsHandler { this.touchControls = touchControls; this.inConfigurationMode = false; this.setPositions(this.getSavedPositionsOfCurrentOrientation() ?? []); - window.addEventListener("resize", (event) => { + window.addEventListener("resize", _event => { const screenSize = this.getScreenSize(); if (screenSize.width > screenSize.height !== this.isLandscapeMode) { this.changeOrientation(screenSize.width > screenSize.height); @@ -72,7 +70,9 @@ export default class MoveTouchControlsHandler { if (this.inConfigurationMode) { const orientation = document.querySelector("#touchControls #orientation"); if (orientation) { - orientation.textContent = this.isLandscapeMode ? i18next.t("settings:landscape") : i18next.t("settings:portrait"); + orientation.textContent = this.isLandscapeMode + ? i18next.t("settings:landscape") + : i18next.t("settings:portrait"); } } const positions = this.getSavedPositionsOfCurrentOrientation() ?? []; @@ -150,7 +150,7 @@ export default class MoveTouchControlsHandler { toolbar, saveButton: toolbar.querySelector("#saveButton")!, resetButton: toolbar.querySelector("#resetButton")!, - cancelButton: toolbar.querySelector("#cancelButton")! + cancelButton: toolbar.querySelector("#cancelButton")!, }; } @@ -182,7 +182,9 @@ export default class MoveTouchControlsHandler { } const rect = this.draggingElement.getBoundingClientRect(); // Map the touch position to the center of the dragged element. - const xOffset = this.isLeft(this.draggingElement) ? touch.clientX - rect.width / 2 : window.innerWidth - touch.clientX - rect.width / 2; + const xOffset = this.isLeft(this.draggingElement) + ? touch.clientX - rect.width / 2 + : window.innerWidth - touch.clientX - rect.width / 2; const yOffset = window.innerHeight - touch.clientY - rect.height / 2; this.setPosition(this.draggingElement, xOffset, yOffset); }; @@ -204,8 +206,8 @@ export default class MoveTouchControlsHandler { .map((controlGroup: HTMLElement) => { return { id: controlGroup.id, - x: parseFloat(this.isLeft(controlGroup) ? controlGroup.style.left : controlGroup.style.right), - y: parseFloat(controlGroup.style.bottom), + x: Number.parseFloat(this.isLeft(controlGroup) ? controlGroup.style.left : controlGroup.style.right), + y: Number.parseFloat(controlGroup.style.bottom), }; }); } @@ -291,7 +293,7 @@ export default class MoveTouchControlsHandler { * @returns All control groups of the touch controls. */ private getControlGroupElements(): HTMLDivElement[] { - return [ ...document.querySelectorAll("#touchControls .control-group") ] as HTMLDivElement[]; + return [...document.querySelectorAll("#touchControls .control-group")] as HTMLDivElement[]; } /** @@ -301,21 +303,21 @@ export default class MoveTouchControlsHandler { */ private createConfigurationEventListeners(controlGroups: HTMLDivElement[]): ConfigurationEventListeners { return { - "touchstart": controlGroups.map((element: HTMLDivElement) => { + touchstart: controlGroups.map((element: HTMLDivElement) => { const startDrag = () => this.startDrag(element); element.addEventListener("touchstart", startDrag, { passive: true }); return startDrag; }), - "touchmove": controlGroups.map(() => { - const drag = (event) => this.drag(event.touches[0]); + touchmove: controlGroups.map(() => { + const drag = event => this.drag(event.touches[0]); window.addEventListener("touchmove", drag, { passive: true }); return drag; }), - "touchend": controlGroups.map(() => { + touchend: controlGroups.map(() => { const stopDrag = () => this.stopDrag(); window.addEventListener("touchend", stopDrag, { passive: true }); return stopDrag; - }) + }), }; } @@ -326,7 +328,15 @@ export default class MoveTouchControlsHandler { */ private createOverlay(ui: UI) { const container = new Phaser.GameObjects.Container(globalScene, 0, 0); - const overlay = new Phaser.GameObjects.Rectangle(globalScene, 0, 0, globalScene.game.canvas.width, globalScene.game.canvas.height, 0x000000, 0.5); + const overlay = new Phaser.GameObjects.Rectangle( + globalScene, + 0, + 0, + globalScene.game.canvas.width, + globalScene.game.canvas.height, + 0x000000, + 0.5, + ); overlay.setInteractive(); container.add(overlay); ui.add(container); @@ -337,9 +347,9 @@ export default class MoveTouchControlsHandler { } /** - * Allows the user to configure the touch controls by dragging buttons around the screen. - * @param ui The UI of the game. - */ + * Allows the user to configure the touch controls by dragging buttons around the screen. + * @param ui The UI of the game. + */ public enableConfigurationMode(ui: UI) { if (this.inConfigurationMode) { return; @@ -364,9 +374,11 @@ export default class MoveTouchControlsHandler { // Remove event listeners const { touchstart, touchmove, touchend } = this.configurationEventListeners; - this.getControlGroupElements().forEach((element, index) => element.removeEventListener("touchstart", touchstart[index])); - touchmove.forEach((listener) => window.removeEventListener("touchmove", listener)); - touchend.forEach((listener) => window.removeEventListener("touchend", listener)); + this.getControlGroupElements().forEach((element, index) => + element.removeEventListener("touchstart", touchstart[index]), + ); + touchmove.forEach(listener => window.removeEventListener("touchmove", listener)); + touchend.forEach(listener => window.removeEventListener("touchend", listener)); // Remove configuration toolbar const toolbar = document.querySelector("#touchControls #configToolbar"); @@ -377,5 +389,4 @@ export default class MoveTouchControlsHandler { document.querySelector("#touchControls")?.classList.remove("config-mode"); this.touchControls.enable(); } - } diff --git a/src/ui/settings/navigationMenu.ts b/src/ui/settings/navigationMenu.ts index 5fa53b7c270..1d2d71e1e20 100644 --- a/src/ui/settings/navigationMenu.ts +++ b/src/ui/settings/navigationMenu.ts @@ -33,7 +33,13 @@ export class NavigationManager { Mode.SETTINGS_GAMEPAD, Mode.SETTINGS_KEYBOARD, ]; - this.labels = [ i18next.t("settings:general"), i18next.t("settings:display"), i18next.t("settings:audio"), i18next.t("settings:gamepad"), i18next.t("settings:keyboard") ]; + this.labels = [ + i18next.t("settings:general"), + i18next.t("settings:display"), + i18next.t("settings:audio"), + i18next.t("settings:gamepad"), + i18next.t("settings:keyboard"), + ]; } public reset() { @@ -95,7 +101,6 @@ export class NavigationManager { public clearNavigationMenus() { this.navigationMenus.length = 0; } - } export default class NavigationMenu extends Phaser.GameObjects.Container { @@ -118,7 +123,7 @@ export default class NavigationMenu extends Phaser.GameObjects.Container { */ setup() { const navigationManager = NavigationManager.getInstance(); - const headerBg = addWindow(0, 0, (globalScene.game.canvas.width / 6) - 2, 24); + const headerBg = addWindow(0, 0, globalScene.game.canvas.width / 6 - 2, 24); headerBg.setOrigin(0, 0); this.add(headerBg); this.width = headerBg.width; @@ -161,7 +166,7 @@ export default class NavigationMenu extends Phaser.GameObjects.Container { const navigationManager = NavigationManager.getInstance(); const posSelected = navigationManager.modes.indexOf(navigationManager.selectedMode); - for (const [ index, title ] of this.headerTitles.entries()) { + for (const [index, title] of this.headerTitles.entries()) { setTextStyle(title, index === posSelected ? TextStyle.SETTINGS_SELECTED : TextStyle.SETTINGS_LABEL); } } @@ -171,8 +176,8 @@ export default class NavigationMenu extends Phaser.GameObjects.Container { */ updateIcons() { const specialIcons = { - "BUTTON_HOME": "HOME.png", - "BUTTON_DELETE": "DEL.png", + BUTTON_HOME: "HOME.png", + BUTTON_DELETE: "DEL.png", }; for (const settingName of Object.keys(this.navigationIcons)) { if (Object.keys(specialIcons).includes(settingName)) { diff --git a/src/ui/settings/settings-audio-ui-handler.ts b/src/ui/settings/settings-audio-ui-handler.ts index 3b591eab4b9..f8cb4da4ba2 100644 --- a/src/ui/settings/settings-audio-ui-handler.ts +++ b/src/ui/settings/settings-audio-ui-handler.ts @@ -1,7 +1,7 @@ import type { Mode } from "../ui"; import AbstractSettingsUiHandler from "./abstract-settings-ui-handler"; import { SettingType } from "#app/system/settings/settings"; -"#app/inputs-controller"; +("#app/inputs-controller"); export default class SettingsAudioUiHandler extends AbstractSettingsUiHandler { /** diff --git a/src/ui/settings/settings-display-ui-handler.ts b/src/ui/settings/settings-display-ui-handler.ts index 98fc16e2f96..b3505fe90f2 100644 --- a/src/ui/settings/settings-display-ui-handler.ts +++ b/src/ui/settings/settings-display-ui-handler.ts @@ -1,7 +1,7 @@ import type { Mode } from "../ui"; import AbstractSettingsUiHandler from "./abstract-settings-ui-handler"; import { SettingKeys, SettingType } from "#app/system/settings/settings"; -"#app/inputs-controller"; +("#app/inputs-controller"); export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler { /** diff --git a/src/ui/settings/settings-gamepad-ui-handler.ts b/src/ui/settings/settings-gamepad-ui-handler.ts index 3d23b7e99bb..0b3a7241ff2 100644 --- a/src/ui/settings/settings-gamepad-ui-handler.ts +++ b/src/ui/settings/settings-gamepad-ui-handler.ts @@ -5,7 +5,7 @@ import { SettingGamepad, settingGamepadBlackList, settingGamepadDefaults, - settingGamepadOptions + settingGamepadOptions, } from "../../system/settings/settings-gamepad"; import pad_xbox360 from "#app/configs/inputs/pad_xbox360"; import pad_dualshock from "#app/configs/inputs/pad_dualshock"; @@ -24,19 +24,18 @@ import { globalScene } from "#app/global-scene"; */ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiHandler { - /** - * Creates an instance of SettingsGamepadUiHandler. - * - * @param mode - The UI mode, optional. - */ + * Creates an instance of SettingsGamepadUiHandler. + * + * @param mode - The UI mode, optional. + */ constructor(mode: Mode | null = null) { super(mode); this.titleSelected = "Gamepad"; this.setting = SettingGamepad; this.settingDeviceDefaults = settingGamepadDefaults; this.settingDeviceOptions = settingGamepadOptions; - this.configs = [ pad_xbox360, pad_dualshock, pad_unlicensedSNES ]; + this.configs = [pad_xbox360, pad_dualshock, pad_unlicensedSNES]; this.commonSettingsCount = 2; this.localStoragePropertyName = "settingsGamepad"; this.settingBlacklisted = settingGamepadBlackList; @@ -46,8 +45,8 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH setSetting = setSettingGamepad; /** - * Setup UI elements. - */ + * Setup UI elements. + */ setup() { super.setup(); // If no gamepads are detected, set up a default UI prompt in the settings container. @@ -65,11 +64,11 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH } /** - * Set the layout for the active configuration. - * - * @param activeConfig - The active gamepad configuration. - * @returns `true` if the layout was successfully applied, otherwise `false`. - */ + * Set the layout for the active configuration. + * + * @param activeConfig - The active gamepad configuration. + * @returns `true` if the layout was successfully applied, otherwise `false`. + */ setLayout(activeConfig: InterfaceConfig): boolean { // Check if there is no active configuration (e.g., no gamepad connected). if (!activeConfig) { @@ -85,15 +84,15 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH } /** - * Update the display of the chosen gamepad. - */ + * Update the display of the chosen gamepad. + */ updateChosenGamepadDisplay(): void { // Update any bindings that might have changed since the last update. this.updateBindings(); this.resetScroll(); // Iterate over the keys in the settingDevice enumeration. - for (const [ index, key ] of Object.keys(this.setting).entries()) { + for (const [index, key] of Object.keys(this.setting).entries()) { const setting = this.setting[key]; // Get the actual setting value using the key. // Check if the current setting corresponds to the controller setting. @@ -106,21 +105,29 @@ export default class SettingsGamepadUiHandler extends AbstractControlSettingsUiH // Update the text of the first option label under the current setting to the name of the chosen gamepad, // truncating the name to 30 characters if necessary. - this.layout[_key].optionValueLabels[index][0].setText(truncateString(globalScene.inputController.selectedDevice[Device.GAMEPAD], 20)); + this.layout[_key].optionValueLabels[index][0].setText( + truncateString(globalScene.inputController.selectedDevice[Device.GAMEPAD], 20), + ); } } } } /** - * Save the setting to local storage. - * - * @param settingName - The setting to save. - * @param cursor - The cursor position to save. - */ + * Save the setting to local storage. + * + * @param settingName - The setting to save. + * @param cursor - The cursor position to save. + */ saveSettingToLocalStorage(settingName, cursor): void { if (this.setting[settingName] !== this.setting.Controller) { - globalScene.gameData.saveControlSetting(this.device, this.localStoragePropertyName, settingName, this.settingDeviceDefaults, cursor); + globalScene.gameData.saveControlSetting( + this.device, + this.localStoragePropertyName, + settingName, + this.settingDeviceDefaults, + cursor, + ); } } } diff --git a/src/ui/settings/settings-keyboard-ui-handler.ts b/src/ui/settings/settings-keyboard-ui-handler.ts index ad9f23cc0d9..a7837c8961e 100644 --- a/src/ui/settings/settings-keyboard-ui-handler.ts +++ b/src/ui/settings/settings-keyboard-ui-handler.ts @@ -5,7 +5,7 @@ import { SettingKeyboard, settingKeyboardBlackList, settingKeyboardDefaults, - settingKeyboardOptions + settingKeyboardOptions, } from "#app/system/settings/settings-keyboard"; import { reverseValueToKeySetting, truncateString } from "#app/utils"; import AbstractControlSettingsUiHandler from "#app/ui/settings/abstract-control-settings-ui-handler"; @@ -24,17 +24,17 @@ import { globalScene } from "#app/global-scene"; */ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUiHandler { /** - * Creates an instance of SettingsKeyboardUiHandler. - * - * @param mode - The UI mode, optional. - */ + * Creates an instance of SettingsKeyboardUiHandler. + * + * @param mode - The UI mode, optional. + */ constructor(mode: Mode | null = null) { super(mode); this.titleSelected = "Keyboard"; this.setting = SettingKeyboard; this.settingDeviceDefaults = settingKeyboardDefaults; this.settingDeviceOptions = settingKeyboardOptions; - this.configs = [ cfg_keyboard_qwerty ]; + this.configs = [cfg_keyboard_qwerty]; this.commonSettingsCount = 0; this.textureOverride = "keyboard"; this.localStoragePropertyName = "settingsKeyboard"; @@ -43,15 +43,15 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi const deleteEvent = globalScene.input.keyboard?.addKey(Phaser.Input.Keyboard.KeyCodes.DELETE); const restoreDefaultEvent = globalScene.input.keyboard?.addKey(Phaser.Input.Keyboard.KeyCodes.HOME); - deleteEvent && deleteEvent.on("up", this.onDeleteDown, this); - restoreDefaultEvent && restoreDefaultEvent.on("up", this.onHomeDown, this); + deleteEvent?.on("up", this.onDeleteDown, this); + restoreDefaultEvent?.on("up", this.onHomeDown, this); } setSetting = setSettingKeyboard; /** - * Setup UI elements. - */ + * Setup UI elements. + */ setup() { super.setup(); // If no gamepads are detected, set up a default UI prompt in the settings container. @@ -75,17 +75,16 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi this.settingsContainer.add(iconDelete); this.settingsContainer.add(deleteText); - // Map the 'noKeyboard' layout options for easy access. this.layout["noKeyboard"].optionsContainer = optionsContainer; this.layout["noKeyboard"].label = label; } /** - * Handle the home key press event. - */ + * Handle the home key press event. + */ onHomeDown(): void { - if (![ Mode.SETTINGS_KEYBOARD, Mode.SETTINGS_GAMEPAD ].includes(globalScene.ui.getMode())) { + if (![Mode.SETTINGS_KEYBOARD, Mode.SETTINGS_GAMEPAD].includes(globalScene.ui.getMode())) { return; } globalScene.gameData.resetMappingToFactory(); @@ -93,8 +92,8 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi } /** - * Handle the delete key press event. - */ + * Handle the delete key press event. + */ onDeleteDown(): void { if (globalScene.ui.getMode() !== Mode.SETTINGS_KEYBOARD) { return; @@ -113,11 +112,11 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi } /** - * Set the layout for the active configuration. - * - * @param activeConfig - The active keyboard configuration. - * @returns `true` if the layout was successfully applied, otherwise `false`. - */ + * Set the layout for the active configuration. + * + * @param activeConfig - The active keyboard configuration. + * @returns `true` if the layout was successfully applied, otherwise `false`. + */ setLayout(activeConfig: InterfaceConfig): boolean { // Check if there is no active configuration (e.g., no gamepad connected). if (!activeConfig) { @@ -133,14 +132,14 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi } /** - * Update the display of the chosen keyboard layout. - */ + * Update the display of the chosen keyboard layout. + */ updateChosenKeyboardDisplay(): void { // Update any bindings that might have changed since the last update. this.updateBindings(); // Iterate over the keys in the settingDevice enumeration. - for (const [ index, key ] of Object.keys(this.setting).entries()) { + for (const [index, key] of Object.keys(this.setting).entries()) { const setting = this.setting[key]; // Get the actual setting value using the key. // Check if the current setting corresponds to the layout setting. @@ -152,31 +151,38 @@ export default class SettingsKeyboardUiHandler extends AbstractControlSettingsUi } // Skip updating the no gamepad layout. // Update the text of the first option label under the current setting to the name of the chosen gamepad, // truncating the name to 30 characters if necessary. - this.layout[_key].optionValueLabels[index][0].setText(truncateString(globalScene.inputController.selectedDevice[Device.KEYBOARD], 22)); + this.layout[_key].optionValueLabels[index][0].setText( + truncateString(globalScene.inputController.selectedDevice[Device.KEYBOARD], 22), + ); } } } - } /** - * Save the custom keyboard mapping to local storage. - * - * @param config - The configuration to save. - */ + * Save the custom keyboard mapping to local storage. + * + * @param config - The configuration to save. + */ saveCustomKeyboardMappingToLocalStorage(config): void { globalScene.gameData.saveMappingConfigs(globalScene.inputController?.selectedDevice[Device.KEYBOARD], config); } /** - * Save the setting to local storage. - * - * @param settingName - The name of the setting to save. - * @param cursor - The cursor position to save. - */ + * Save the setting to local storage. + * + * @param settingName - The name of the setting to save. + * @param cursor - The cursor position to save. + */ saveSettingToLocalStorage(settingName, cursor): void { if (this.setting[settingName] !== this.setting.Default_Layout) { - globalScene.gameData.saveControlSetting(this.device, this.localStoragePropertyName, settingName, this.settingDeviceDefaults, cursor); + globalScene.gameData.saveControlSetting( + this.device, + this.localStoragePropertyName, + settingName, + this.settingDeviceDefaults, + cursor, + ); } } } diff --git a/src/ui/settings/shiny_icons.json b/src/ui/settings/shiny_icons.json index d6465cf2c3a..f40c606ca47 100644 --- a/src/ui/settings/shiny_icons.json +++ b/src/ui/settings/shiny_icons.json @@ -1,41 +1,41 @@ { - "textures": [ - { - "image": "shiny_icons.png", - "format": "RGBA8888", - "size": { - "w": 45, - "h": 14 - }, - "scale": 1, - "frames": [ - { - "filename": "0", - "rotated": false, - "trimmed": false, - "sourceSize": { - "w": 45, - "h": 14 - }, - "spriteSourceSize": { - "x": 0, - "y": 0, - "w": 15, - "h": 14 - }, - "frame": { - "x": 0, - "y": 0, - "w": 15, - "h": 14 - } - } - ] - } - ], - "meta": { - "app": "https://www.codeandweb.com/texturepacker", - "version": "3.0", - "smartupdate": "$TexturePacker:SmartUpdate:a3275c7504a9b35b288265e191b1d14c:420725f3fb73c2cac0ab3bbc0a46f2e1:3a8b8ca0f0e4be067dd46c07b78ee013$" - } + "textures": [ + { + "image": "shiny_icons.png", + "format": "RGBA8888", + "size": { + "w": 45, + "h": 14 + }, + "scale": 1, + "frames": [ + { + "filename": "0", + "rotated": false, + "trimmed": false, + "sourceSize": { + "w": 45, + "h": 14 + }, + "spriteSourceSize": { + "x": 0, + "y": 0, + "w": 15, + "h": 14 + }, + "frame": { + "x": 0, + "y": 0, + "w": 15, + "h": 14 + } + } + ] + } + ], + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "3.0", + "smartupdate": "$TexturePacker:SmartUpdate:a3275c7504a9b35b288265e191b1d14c:420725f3fb73c2cac0ab3bbc0a46f2e1:3a8b8ca0f0e4be067dd46c07b78ee013$" + } } diff --git a/src/ui/starter-container.ts b/src/ui/starter-container.ts index 792ce97e103..71e40844f38 100644 --- a/src/ui/starter-container.ts +++ b/src/ui/starter-container.ts @@ -13,7 +13,7 @@ export class StarterContainer extends Phaser.GameObjects.Container { public classicWinIcon: Phaser.GameObjects.Image; public candyUpgradeIcon: Phaser.GameObjects.Image; public candyUpgradeOverlayIcon: Phaser.GameObjects.Image; - public cost: number = 0; + public cost = 0; constructor(species: PokemonSpecies) { super(globalScene, 0, 0); @@ -32,10 +32,16 @@ export class StarterContainer extends Phaser.GameObjects.Container { this.starterPassiveBgs = starterPassiveBg; // icon - this.icon = globalScene.add.sprite(-2, 2, species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant)); + this.icon = globalScene.add.sprite( + -2, + 2, + species.getIconAtlasKey(defaultProps.formIndex, defaultProps.shiny, defaultProps.variant), + ); this.icon.setScale(0.5); this.icon.setOrigin(0, 0); - this.icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant)); + this.icon.setFrame( + species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant), + ); this.checkIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny, defaultProps.variant); this.icon.setTint(0); this.add(this.icon); @@ -51,7 +57,9 @@ export class StarterContainer extends Phaser.GameObjects.Container { this.add(this.shinyIcons); // value label - const label = addTextObject(1, 2, "0", TextStyle.WINDOW, { fontSize: "32px" }); + const label = addTextObject(1, 2, "0", TextStyle.WINDOW, { + fontSize: "32px", + }); label.setShadowOffset(2, 2); label.setOrigin(0, 0); label.setVisible(false); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index c2ed625f7e8..ccc56f38368 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -23,8 +23,14 @@ import { allSpecies, getPokemonSpeciesForm, getPokerusStarters } from "#app/data import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters"; import { PokemonType } from "#enums/pokemon-type"; import { GameModes } from "#app/game-mode"; -import type { DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences } from "#app/system/game-data"; -import { AbilityAttr, DexAttr, StarterPrefs } from "#app/system/game-data"; +import type { + DexAttrProps, + DexEntry, + StarterMoveset, + StarterAttributes, + StarterPreferences, +} from "#app/system/game-data"; +import { AbilityAttr, DexAttr, loadStarterPreferences, saveStarterPreferences } from "#app/system/game-data"; import { Tutorial, handleTutorial } from "#app/tutorial"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import MessageUiHandler from "#app/ui/message-ui-handler"; @@ -53,19 +59,34 @@ import { SelectChallengePhase } from "#app/phases/select-challenge-phase"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { TitlePhase } from "#app/phases/title-phase"; import { Abilities } from "#enums/abilities"; -import { getPassiveCandyCount, getValueReductionCandyCounts, getSameSpeciesEggCandyCounts } from "#app/data/balance/starters"; -import { BooleanHolder, fixedInt, getLocalizedSpriteKey, isNullOrUndefined, NumberHolder, padInt, randIntRange, rgbHexToRgba, toReadableString } from "#app/utils"; +import { + getPassiveCandyCount, + getValueReductionCandyCounts, + getSameSpeciesEggCandyCounts, +} from "#app/data/balance/starters"; +import { + BooleanHolder, + fixedInt, + getLocalizedSpriteKey, + isNullOrUndefined, + NumberHolder, + padInt, + randIntRange, + rgbHexToRgba, + toReadableString, +} from "#app/utils"; import type { Nature } from "#enums/nature"; import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; import { achvs } from "#app/system/achv"; import * as Utils from "../utils"; +import type { GameObjects } from "phaser"; export type StarterSelectCallback = (starters: Starter[]) => void; export interface Starter { species: PokemonSpecies; dexAttr: bigint; - abilityIndex: number, + abilityIndex: number; passive: boolean; nature: Nature; moveset?: StarterMoveset; @@ -75,59 +96,59 @@ export interface Starter { } interface LanguageSetting { - starterInfoTextSize: string, - instructionTextSize: string, - starterInfoXPos?: number, - starterInfoYOffset?: number + starterInfoTextSize: string; + instructionTextSize: string; + starterInfoXPos?: number; + starterInfoYOffset?: number; } const languageSettings: { [key: string]: LanguageSetting } = { - "en":{ + en: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "de":{ + de: { starterInfoTextSize: "48px", instructionTextSize: "35px", starterInfoXPos: 33, }, - "es-ES":{ + "es-ES": { starterInfoTextSize: "52px", instructionTextSize: "35px", }, - "fr":{ + fr: { starterInfoTextSize: "54px", instructionTextSize: "38px", }, - "it":{ + it: { starterInfoTextSize: "56px", instructionTextSize: "38px", }, - "pt_BR":{ + pt_BR: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoXPos: 33, }, - "zh":{ + zh: { starterInfoTextSize: "47px", instructionTextSize: "38px", starterInfoYOffset: 1, starterInfoXPos: 24, }, - "pt":{ + pt: { starterInfoTextSize: "48px", instructionTextSize: "42px", starterInfoXPos: 33, }, - "ko":{ + ko: { starterInfoTextSize: "52px", instructionTextSize: "38px", }, - "ja":{ + ja: { starterInfoTextSize: "51px", instructionTextSize: "38px", }, - "ca-ES":{ + "ca-ES": { starterInfoTextSize: "56px", instructionTextSize: "38px", }, @@ -149,7 +170,7 @@ const randomSelectionWindowHeight = 20; * @param index UI index to calculate the starter position of * @returns An interface with an x and y property */ -function calcStarterPosition(index: number, scrollCursor:number = 0): {x: number, y: number} { +function calcStarterPosition(index: number, scrollCursor = 0): { x: number; y: number } { const yOffset = 13; const height = 17; const x = (index % 9) * 18; @@ -175,7 +196,7 @@ function calcStarterIconY(index: number) { * @param teamSize how many Pokemon are in the team (0-6) * @returns index of the closest Pokemon in the team container */ -function findClosestStarterIndex(y: number, teamSize: number = 6): number { +function findClosestStarterIndex(y: number, teamSize = 6): number { let smallestDistance = teamWindowHeight; let closestStarterIndex = 0; for (let i = 0; i < teamSize; i++) { @@ -209,14 +230,14 @@ function findClosestStarterRow(index: number, numberOfRows: number) { } interface SpeciesDetails { - shiny?: boolean, - formIndex?: number - female?: boolean, - variant?: Variant, - abilityIndex?: number, - natureIndex?: number, - forSeen?: boolean, // default = false - teraType?: PokemonType, + shiny?: boolean; + formIndex?: number; + female?: boolean; + variant?: Variant; + abilityIndex?: number; + natureIndex?: number; + forSeen?: boolean; // default = false + teraType?: PokemonType; } export default class StarterSelectUiHandler extends MessageUiHandler { @@ -262,7 +283,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container; private pokemonCaughtCountText: Phaser.GameObjects.Text; private pokemonFormText: Phaser.GameObjects.Text; - private pokemonHatchedIcon : Phaser.GameObjects.Sprite; + private pokemonHatchedIcon: Phaser.GameObjects.Sprite; private pokemonHatchedCountText: Phaser.GameObjects.Text; private pokemonShinyIcon: Phaser.GameObjects.Sprite; private pokemonPassiveDisabledIcon: Phaser.GameObjects.Sprite; @@ -290,18 +311,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private starterSelectMessageBox: Phaser.GameObjects.NineSlice; private starterSelectMessageBoxContainer: Phaser.GameObjects.Container; private statsContainer: StatsContainer; - private moveInfoOverlay : MoveInfoOverlay; + private moveInfoOverlay: MoveInfoOverlay; private statsMode: boolean; - private starterIconsCursorXOffset: number = -3; - private starterIconsCursorYOffset: number = 1; + private starterIconsCursorXOffset = -3; + private starterIconsCursorYOffset = 1; private starterIconsCursorIndex: number; private filterMode: boolean; - private dexAttrCursor: bigint = 0n; - private abilityCursor: number = -1; - private natureCursor: number = -1; + private dexAttrCursor = 0n; + private abilityCursor = -1; + private natureCursor = -1; private teraCursor: PokemonType = PokemonType.UNKNOWN; - private filterBarCursor: number = 0; + private filterBarCursor = 0; private starterMoveset: StarterMoveset | null; private scrollCursor: number; @@ -347,7 +368,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private starterPreferences: StarterPreferences; - protected blockInput: boolean = false; + protected blockInput = false; constructor() { super(Mode.STARTER_SELECT); @@ -363,7 +384,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.setVisible(false); ui.add(this.starterSelectContainer); - const bgColor = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0x006860); + const bgColor = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0x006860, + ); bgColor.setOrigin(0, 0); this.starterSelectContainer.add(bgColor); @@ -377,13 +404,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.add(this.shinyOverlay); const starterContainerWindow = addWindow(speciesContainerX, filterBarHeight + 1, 175, 161); - const starterContainerBg = globalScene.add.image(speciesContainerX + 1, filterBarHeight + 2, "starter_container_bg"); + const starterContainerBg = globalScene.add.image( + speciesContainerX + 1, + filterBarHeight + 2, + "starter_container_bg", + ); starterContainerBg.setOrigin(0, 0); this.starterSelectContainer.add(starterContainerBg); - this.starterSelectContainer.add(addWindow(teamWindowX, teamWindowY - randomSelectionWindowHeight, teamWindowWidth, randomSelectionWindowHeight, true)); - this.starterSelectContainer.add(addWindow(teamWindowX, teamWindowY, teamWindowWidth, teamWindowHeight )); - this.starterSelectContainer.add(addWindow(teamWindowX, teamWindowY + teamWindowHeight, teamWindowWidth, teamWindowWidth, true)); + this.starterSelectContainer.add( + addWindow( + teamWindowX, + teamWindowY - randomSelectionWindowHeight, + teamWindowWidth, + randomSelectionWindowHeight, + true, + ), + ); + this.starterSelectContainer.add(addWindow(teamWindowX, teamWindowY, teamWindowWidth, teamWindowHeight)); + this.starterSelectContainer.add( + addWindow(teamWindowX, teamWindowY + teamWindowHeight, teamWindowWidth, teamWindowWidth, true), + ); this.starterSelectContainer.add(starterContainerWindow); // Create and initialise filter bar @@ -406,7 +447,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.filterBar.addFilter(DropDownColumn.GEN, i18next.t("filterBar:genFilter"), genDropDown); // type filter - const typeKeys = Object.keys(PokemonType).filter(v => isNaN(Number(v))); + const typeKeys = Object.keys(PokemonType).filter(v => Number.isNaN(Number(v))); const typeOptions: DropDownOption[] = []; typeKeys.forEach((type, index) => { if (index === 0 || index === 19) { @@ -417,7 +458,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { typeSprite.setFrame(type.toLowerCase()); typeOptions.push(new DropDownOption(index, new DropDownLabel("", typeSprite))); }); - this.filterBar.addFilter(DropDownColumn.TYPES, i18next.t("filterBar:typeFilter"), new DropDown(0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5)); + this.filterBar.addFilter( + DropDownColumn.TYPES, + i18next.t("filterBar:typeFilter"), + new DropDown(0, 0, typeOptions, this.updateStarters, DropDownType.HYBRID, 0.5), + ); // caught filter const shiny1Sprite = globalScene.add.sprite(0, 0, "shiny_icons"); @@ -441,10 +486,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { new DropDownOption("SHINY2", new DropDownLabel("", shiny2Sprite)), new DropDownOption("SHINY", new DropDownLabel("", shiny1Sprite)), new DropDownOption("NORMAL", new DropDownLabel(i18next.t("filterBar:normal"))), - new DropDownOption("UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught"))) + new DropDownOption("UNCAUGHT", new DropDownLabel(i18next.t("filterBar:uncaught"))), ]; - this.filterBar.addFilter(DropDownColumn.CAUGHT, i18next.t("filterBar:caughtFilter"), new DropDown(0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID)); + this.filterBar.addFilter( + DropDownColumn.CAUGHT, + i18next.t("filterBar:caughtFilter"), + new DropDown(0, 0, caughtOptions, this.updateStarters, DropDownType.HYBRID), + ); // unlocks filter const passiveLabels = [ @@ -468,7 +517,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { new DropDownOption("COST_REDUCTION", costReductionLabels), ]; - this.filterBar.addFilter(DropDownColumn.UNLOCKS, i18next.t("filterBar:unlocksFilter"), new DropDown(0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL)); + this.filterBar.addFilter( + DropDownColumn.UNLOCKS, + i18next.t("filterBar:unlocksFilter"), + new DropDown(0, 0, unlocksOptions, this.updateStarters, DropDownType.RADIAL), + ); // misc filter const favoriteLabels = [ @@ -501,19 +554,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler { new DropDownOption("EGG", eggLabels), new DropDownOption("POKERUS", pokerusLabels), ]; - this.filterBar.addFilter(DropDownColumn.MISC, i18next.t("filterBar:miscFilter"), new DropDown(0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL)); + this.filterBar.addFilter( + DropDownColumn.MISC, + i18next.t("filterBar:miscFilter"), + new DropDown(0, 0, miscOptions, this.updateStarters, DropDownType.RADIAL), + ); // sort filter const sortOptions = [ - new DropDownOption(SortCriteria.NUMBER, new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON)), + new DropDownOption( + SortCriteria.NUMBER, + new DropDownLabel(i18next.t("filterBar:sortByNumber"), undefined, DropDownState.ON), + ), new DropDownOption(SortCriteria.COST, new DropDownLabel(i18next.t("filterBar:sortByCost"))), new DropDownOption(SortCriteria.CANDY, new DropDownLabel(i18next.t("filterBar:sortByCandies"))), new DropDownOption(SortCriteria.IV, new DropDownLabel(i18next.t("filterBar:sortByIVs"))), new DropDownOption(SortCriteria.NAME, new DropDownLabel(i18next.t("filterBar:sortByName"))), new DropDownOption(SortCriteria.CAUGHT, new DropDownLabel(i18next.t("filterBar:sortByNumCaught"))), - new DropDownOption(SortCriteria.HATCHED, new DropDownLabel(i18next.t("filterBar:sortByNumHatched"))) + new DropDownOption(SortCriteria.HATCHED, new DropDownLabel(i18next.t("filterBar:sortByNumHatched"))), ]; - this.filterBar.addFilter(DropDownColumn.SORT, i18next.t("filterBar:sortFilter"), new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE)); + this.filterBar.addFilter( + DropDownColumn.SORT, + i18next.t("filterBar:sortFilter"), + new DropDown(0, 0, sortOptions, this.updateStarters, DropDownType.SINGLE), + ); this.filterBarContainer.add(this.filterBar); this.starterSelectContainer.add(this.filterBarContainer); @@ -536,7 +600,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonNameText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNameText); - this.pokemonGrowthRateLabelText = addTextObject(8, 106, i18next.t("starterSelectUiHandler:growthRate"), TextStyle.SUMMARY_ALT, { fontSize: "36px" }); + this.pokemonGrowthRateLabelText = addTextObject( + 8, + 106, + i18next.t("starterSelectUiHandler:growthRate"), + TextStyle.SUMMARY_ALT, + { fontSize: "36px" }, + ); this.pokemonGrowthRateLabelText.setOrigin(0, 0); this.pokemonGrowthRateLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonGrowthRateLabelText); @@ -549,11 +619,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonGenderText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonGenderText); - this.pokemonUncaughtText = addTextObject(6, 127, i18next.t("starterSelectUiHandler:uncaught"), TextStyle.SUMMARY_ALT, { fontSize: "56px" }); + this.pokemonUncaughtText = addTextObject( + 6, + 127, + i18next.t("starterSelectUiHandler:uncaught"), + TextStyle.SUMMARY_ALT, + { fontSize: "56px" }, + ); this.pokemonUncaughtText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonUncaughtText); - // The position should be set per language const starterInfoXPos = textSettings?.starterInfoXPos || 31; const starterInfoYOffset = textSettings?.starterInfoYOffset || 0; @@ -561,24 +636,40 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // The font size should be set per language const starterInfoTextSize = textSettings?.starterInfoTextSize || 56; - this.pokemonAbilityLabelText = addTextObject(6, 127 + starterInfoYOffset, i18next.t("starterSelectUiHandler:ability"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonAbilityLabelText = addTextObject( + 6, + 127 + starterInfoYOffset, + i18next.t("starterSelectUiHandler:ability"), + TextStyle.SUMMARY_ALT, + { fontSize: starterInfoTextSize }, + ); this.pokemonAbilityLabelText.setOrigin(0, 0); this.pokemonAbilityLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonAbilityLabelText); - this.pokemonAbilityText = addTextObject(starterInfoXPos, 127 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonAbilityText = addTextObject(starterInfoXPos, 127 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { + fontSize: starterInfoTextSize, + }); this.pokemonAbilityText.setOrigin(0, 0); this.pokemonAbilityText.setInteractive(new Phaser.Geom.Rectangle(0, 0, 250, 55), Phaser.Geom.Rectangle.Contains); this.starterSelectContainer.add(this.pokemonAbilityText); - this.pokemonPassiveLabelText = addTextObject(6, 136 + starterInfoYOffset, i18next.t("starterSelectUiHandler:passive"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonPassiveLabelText = addTextObject( + 6, + 136 + starterInfoYOffset, + i18next.t("starterSelectUiHandler:passive"), + TextStyle.SUMMARY_ALT, + { fontSize: starterInfoTextSize }, + ); this.pokemonPassiveLabelText.setOrigin(0, 0); this.pokemonPassiveLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonPassiveLabelText); - this.pokemonPassiveText = addTextObject(starterInfoXPos, 136 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonPassiveText = addTextObject(starterInfoXPos, 136 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { + fontSize: starterInfoTextSize, + }); this.pokemonPassiveText.setOrigin(0, 0); this.pokemonPassiveText.setInteractive(new Phaser.Geom.Rectangle(0, 0, 250, 55), Phaser.Geom.Rectangle.Contains); this.starterSelectContainer.add(this.pokemonPassiveText); @@ -595,12 +686,20 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonPassiveLockedIcon.setVisible(false); this.starterSelectContainer.add(this.pokemonPassiveLockedIcon); - this.pokemonNatureLabelText = addTextObject(6, 145 + starterInfoYOffset, i18next.t("starterSelectUiHandler:nature"), TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonNatureLabelText = addTextObject( + 6, + 145 + starterInfoYOffset, + i18next.t("starterSelectUiHandler:nature"), + TextStyle.SUMMARY_ALT, + { fontSize: starterInfoTextSize }, + ); this.pokemonNatureLabelText.setOrigin(0, 0); this.pokemonNatureLabelText.setVisible(false); this.starterSelectContainer.add(this.pokemonNatureLabelText); - this.pokemonNatureText = addBBCodeTextObject(starterInfoXPos, 145 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { fontSize: starterInfoTextSize }); + this.pokemonNatureText = addBBCodeTextObject(starterInfoXPos, 145 + starterInfoYOffset, "", TextStyle.SUMMARY_ALT, { + fontSize: starterInfoTextSize, + }); this.pokemonNatureText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonNatureText); @@ -620,16 +719,43 @@ export default class StarterSelectUiHandler extends MessageUiHandler { startLabel.setOrigin(0.5, 0); this.starterSelectContainer.add(startLabel); - this.startCursorObj = globalScene.add.nineslice(teamWindowX + 4, 160, "select_cursor", undefined, 26, 15, 6, 6, 6, 6); + this.startCursorObj = globalScene.add.nineslice( + teamWindowX + 4, + 160, + "select_cursor", + undefined, + 26, + 15, + 6, + 6, + 6, + 6, + ); this.startCursorObj.setVisible(false); this.startCursorObj.setOrigin(0, 0); this.starterSelectContainer.add(this.startCursorObj); - const randomSelectLabel = addTextObject(teamWindowX + 17, 23, i18next.t("starterSelectUiHandler:randomize"), TextStyle.TOOLTIP_CONTENT); + const randomSelectLabel = addTextObject( + teamWindowX + 17, + 23, + i18next.t("starterSelectUiHandler:randomize"), + TextStyle.TOOLTIP_CONTENT, + ); randomSelectLabel.setOrigin(0.5, 0); this.starterSelectContainer.add(randomSelectLabel); - this.randomCursorObj = globalScene.add.nineslice(teamWindowX + 4, 21, "select_cursor", undefined, 26, 15, 6, 6, 6, 6); + this.randomCursorObj = globalScene.add.nineslice( + teamWindowX + 4, + 21, + "select_cursor", + undefined, + 26, + 15, + 6, + 6, + 6, + 6, + ); this.randomCursorObj.setVisible(false); this.randomCursorObj.setOrigin(0, 0); this.starterSelectContainer.add(this.randomCursorObj); @@ -696,7 +822,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }); this.pokemonSprite = globalScene.add.sprite(53, 63, "pkmn__sub"); - this.pokemonSprite.setPipeline(globalScene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); + this.pokemonSprite.setPipeline(globalScene.spritePipeline, { + tone: [0.0, 0.0, 0.0, 0.0], + ignoreTimeTint: true, + }); this.starterSelectContainer.add(this.pokemonSprite); this.type1Icon = globalScene.add.sprite(8, 98, getLocalizedSpriteKey("types")); @@ -709,11 +838,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.type2Icon.setOrigin(0, 0); this.starterSelectContainer.add(this.type2Icon); - this.pokemonLuckLabelText = addTextObject(8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { fontSize: "56px" }); + this.pokemonLuckLabelText = addTextObject(8, 89, i18next.t("common:luckIndicator"), TextStyle.WINDOW_ALT, { + fontSize: "56px", + }); this.pokemonLuckLabelText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonLuckLabelText); - this.pokemonLuckText = addTextObject(8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { fontSize: "56px" }); + this.pokemonLuckText = addTextObject(8 + this.pokemonLuckLabelText.displayWidth + 2, 89, "0", TextStyle.WINDOW, { + fontSize: "56px", + }); this.pokemonLuckText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonLuckText); @@ -734,7 +867,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCandyDarknessOverlay.setScale(0.5); this.pokemonCandyDarknessOverlay.setOrigin(0, 0); this.pokemonCandyDarknessOverlay.setTint(0x000000); - this.pokemonCandyDarknessOverlay.setAlpha(0.50); + this.pokemonCandyDarknessOverlay.setAlpha(0.5); this.pokemonCandyContainer.add(this.pokemonCandyDarknessOverlay); this.pokemonCandyCountText = addTextObject(9.5, 0, "x0", TextStyle.WINDOW_ALT, { fontSize: "56px" }); @@ -744,7 +877,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCandyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, 30, 20), Phaser.Geom.Rectangle.Contains); this.starterSelectContainer.add(this.pokemonCandyContainer); - this.pokemonFormText = addTextObject(6, 42, "Form", TextStyle.WINDOW_ALT, { fontSize: "42px" }); + this.pokemonFormText = addTextObject(6, 42, "Form", TextStyle.WINDOW_ALT, { + fontSize: "42px", + }); this.pokemonFormText.setOrigin(0, 0); this.starterSelectContainer.add(this.pokemonFormText); @@ -797,7 +932,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonMovesContainer.add(moveContainer); } - this.pokemonAdditionalMoveCountLabel = addTextObject(-this.pokemonMoveBgs[0].width / 2, 56, "(+0)", TextStyle.PARTY); + this.pokemonAdditionalMoveCountLabel = addTextObject( + -this.pokemonMoveBgs[0].width / 2, + 56, + "(+0)", + TextStyle.PARTY, + ); this.pokemonAdditionalMoveCountLabel.setOrigin(0.5, 0); this.pokemonMovesContainer.add(this.pokemonAdditionalMoveCountLabel); @@ -848,53 +988,137 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // instruction rows that will be pushed into the container dynamically based on need // creating new sprites since they will be added to the scene later - this.shinyIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "R.png"); + this.shinyIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "R.png", + ); this.shinyIconElement.setName("sprite-shiny-icon-element"); this.shinyIconElement.setScale(0.675); this.shinyIconElement.setOrigin(0.0, 0.0); - this.shinyLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleShiny"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.shinyLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleShiny"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.shinyLabel.setName("text-shiny-label"); - this.formIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "F.png"); + this.formIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "F.png", + ); this.formIconElement.setName("sprite-form-icon-element"); this.formIconElement.setScale(0.675); this.formIconElement.setOrigin(0.0, 0.0); - this.formLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleForm"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.formLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleForm"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.formLabel.setName("text-form-label"); - this.genderIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "G.png"); + this.genderIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "G.png", + ); this.genderIconElement.setName("sprite-gender-icon-element"); this.genderIconElement.setScale(0.675); this.genderIconElement.setOrigin(0.0, 0.0); - this.genderLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleGender"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.genderLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleGender"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.genderLabel.setName("text-gender-label"); - this.abilityIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "E.png"); + this.abilityIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "E.png", + ); this.abilityIconElement.setName("sprite-ability-icon-element"); this.abilityIconElement.setScale(0.675); this.abilityIconElement.setOrigin(0.0, 0.0); - this.abilityLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleAbility"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.abilityLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleAbility"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.abilityLabel.setName("text-ability-label"); - this.natureIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "N.png"); + this.natureIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "N.png", + ); this.natureIconElement.setName("sprite-nature-icon-element"); this.natureIconElement.setScale(0.675); this.natureIconElement.setOrigin(0.0, 0.0); - this.natureLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleNature"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.natureLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleNature"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.natureLabel.setName("text-nature-label"); - this.teraIconElement = new Phaser.GameObjects.Sprite(globalScene, this.instructionRowX, this.instructionRowY, "keyboard", "V.png"); + this.teraIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.instructionRowX, + this.instructionRowY, + "keyboard", + "V.png", + ); this.teraIconElement.setName("sprite-tera-icon-element"); this.teraIconElement.setScale(0.675); this.teraIconElement.setOrigin(0.0, 0.0); - this.teraLabel = addTextObject(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY, i18next.t("starterSelectUiHandler:cycleTera"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.teraLabel = addTextObject( + this.instructionRowX + this.instructionRowTextOffset, + this.instructionRowY, + i18next.t("starterSelectUiHandler:cycleTera"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.teraLabel.setName("text-tera-label"); - this.goFilterIconElement = new Phaser.GameObjects.Sprite(globalScene, this.filterInstructionRowX, this.filterInstructionRowY, "keyboard", "C.png"); + this.goFilterIconElement = new Phaser.GameObjects.Sprite( + globalScene, + this.filterInstructionRowX, + this.filterInstructionRowY, + "keyboard", + "C.png", + ); this.goFilterIconElement.setName("sprite-goFilter-icon-element"); this.goFilterIconElement.setScale(0.675); this.goFilterIconElement.setOrigin(0.0, 0.0); - this.goFilterLabel = addTextObject(this.filterInstructionRowX + this.instructionRowTextOffset, this.filterInstructionRowY, i18next.t("starterSelectUiHandler:goFilter"), TextStyle.PARTY, { fontSize: instructionTextSize }); + this.goFilterLabel = addTextObject( + this.filterInstructionRowX + this.instructionRowTextOffset, + this.filterInstructionRowY, + i18next.t("starterSelectUiHandler:goFilter"), + TextStyle.PARTY, + { fontSize: instructionTextSize }, + ); this.goFilterLabel.setName("text-goFilter-label"); this.hideInstructions(); @@ -941,7 +1165,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.initTutorialOverlay(this.starterSelectContainer); this.starterSelectContainer.bringToTop(this.starterSelectMessageBoxContainer); - globalScene.eventTarget.addEventListener(BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED, (e) => this.onCandyUpgradeDisplayChanged(e)); + globalScene.eventTarget.addEventListener(BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED, e => + this.onCandyUpgradeDisplayChanged(e), + ); this.updateInstructions(); } @@ -949,7 +1175,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { show(args: any[]): boolean { if (!this.starterPreferences) { // starterPreferences haven't been loaded yet - this.starterPreferences = StarterPrefs.load(); + this.starterPreferences = loadStarterPreferences(); } this.moveInfoOverlay.clear(); // clear this when removing a menu; the cancel button doesn't seem to trigger this automatically on controllers this.pokerusSpecies = getPokerusStarters(); @@ -1016,29 +1242,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const hasNonShiny = caughtAttr & DexAttr.NON_SHINY; if (starterAttributes.shiny && !hasShiny) { // shiny form wasn't unlocked, purging shiny and variant setting - delete starterAttributes.shiny; - delete starterAttributes.variant; + starterAttributes.shiny = undefined; + starterAttributes.variant = undefined; } else if (starterAttributes.shiny === false && !hasNonShiny) { // non shiny form wasn't unlocked, purging shiny setting - delete starterAttributes.shiny; + starterAttributes.shiny = undefined; } if (starterAttributes.variant !== undefined) { const unlockedVariants = [ hasShiny && caughtAttr & DexAttr.DEFAULT_VARIANT, hasShiny && caughtAttr & DexAttr.VARIANT_2, - hasShiny && caughtAttr & DexAttr.VARIANT_3 + hasShiny && caughtAttr & DexAttr.VARIANT_3, ]; - if (isNaN(starterAttributes.variant) || starterAttributes.variant < 0 || !unlockedVariants[starterAttributes.variant]) { + if ( + Number.isNaN(starterAttributes.variant) || + starterAttributes.variant < 0 || + !unlockedVariants[starterAttributes.variant] + ) { // variant value is invalid or requested variant wasn't unlocked, purging setting - delete starterAttributes.variant; + starterAttributes.variant = undefined; } } if (starterAttributes.female !== undefined) { if (!(starterAttributes.female ? caughtAttr & DexAttr.FEMALE : caughtAttr & DexAttr.MALE)) { // requested gender wasn't unlocked, purging setting - delete starterAttributes.female; + starterAttributes.female = undefined; } } @@ -1053,25 +1283,29 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const unlockedAbilities = [ hasAbility1, speciesHasSingleAbility ? hasAbility2 && !hasAbility1 : hasAbility2, - hasHiddenAbility + hasHiddenAbility, ]; if (!unlockedAbilities[starterAttributes.ability]) { // requested ability wasn't unlocked, purging setting - delete starterAttributes.ability; + starterAttributes.ability = undefined; } } const selectedForm = starterAttributes.form; - if (selectedForm !== undefined && (!species.forms[selectedForm]?.isStarterSelectable || !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) { + if ( + selectedForm !== undefined && + (!species.forms[selectedForm]?.isStarterSelectable || + !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm))) + ) { // requested form wasn't unlocked/isn't a starter form, purging setting - delete starterAttributes.form; + starterAttributes.form = undefined; } if (starterAttributes.nature !== undefined) { const unlockedNatures = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr); if (unlockedNatures.indexOf(starterAttributes.nature as unknown as Nature) < 0) { // requested nature wasn't unlocked, purging setting - delete starterAttributes.nature; + starterAttributes.nature = undefined; } } @@ -1103,7 +1337,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number, moveToTop?: boolean) { + showText( + text: string, + delay?: number, + callback?: Function, + callbackDelay?: number, + prompt?: boolean, + promptDelay?: number, + moveToTop?: boolean, + ) { super.showText(text, delay, callback, callbackDelay, prompt, promptDelay); const singleLine = text?.indexOf("\n") === -1; @@ -1147,8 +1389,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[speciesId]; - return starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[speciesId]) - && !(starterData.passiveAttr & PassiveAttr.UNLOCKED); + return ( + starterData.candyCount >= getPassiveCandyCount(speciesStarterCosts[speciesId]) && + !(starterData.passiveAttr & PassiveAttr.UNLOCKED) + ); } /** @@ -1160,8 +1404,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // Get this species ID's starter data const starterData = globalScene.gameData.starterData[speciesId]; - return starterData.candyCount >= getValueReductionCandyCounts(speciesStarterCosts[speciesId])[starterData.valueReduction] - && starterData.valueReduction < valueReductionMax; + return ( + starterData.candyCount >= + getValueReductionCandyCounts(speciesStarterCosts[speciesId])[starterData.valueReduction] && + starterData.valueReduction < valueReductionMax + ); } /** @@ -1182,7 +1429,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { * @param species {@linkcode PokemonSpecies} of the icon used to check for upgrades * @param startPaused Should this animation be paused after it is added? */ - setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused: boolean = false): void { + setUpgradeAnimation(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, startPaused = false): void { globalScene.tweens.killTweensOf(icon); // Skip animations if they are disabled if (globalScene.candyUpgradeDisplay === 0 || species.speciesId !== species.getRootSpeciesId(false)) { @@ -1203,16 +1450,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { y: 2 - 5, duration: fixedInt(125), ease: "Cubic.easeOut", - yoyo: true + yoyo: true, }, { targets: icon, y: 2 - 3, duration: fixedInt(150), ease: "Cubic.easeOut", - yoyo: true - } - ], }; + yoyo: true, + }, + ], + }; const isPassiveAvailable = this.isPassiveAvailable(species.speciesId); const isValueReductionAvailable = this.isValueReductionAvailable(species.speciesId); @@ -1223,7 +1471,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (isPassiveAvailable) { globalScene.tweens.chain(tweenChain).paused = startPaused; } - // 'On' mode + // 'On' mode } else if (globalScene.candyUpgradeNotification === 2) { if (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable) { globalScene.tweens.chain(tweenChain).paused = startPaused; @@ -1238,7 +1486,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const species = starter.species; const slotVisible = !!species?.speciesId; - if (!species || globalScene.candyUpgradeNotification === 0 || species.speciesId !== species.getRootSpeciesId(false)) { + if ( + !species || + globalScene.candyUpgradeNotification === 0 || + species.speciesId !== species.getRootSpeciesId(false) + ) { starter.candyUpgradeIcon.setVisible(false); starter.candyUpgradeOverlayIcon.setVisible(false); return; @@ -1256,7 +1508,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // 'On' mode } else if (globalScene.candyUpgradeNotification === 2) { starter.candyUpgradeIcon.setVisible( - slotVisible && ( isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable )); + slotVisible && (isPassiveAvailable || isValueReductionAvailable || isSameSpeciesEggAvailable), + ); starter.candyUpgradeOverlayIcon.setVisible(slotVisible && starter.candyUpgradeIcon.visible); } } @@ -1266,7 +1519,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { * @param starterContainer the container for the Pokemon to update */ updateCandyUpgradeDisplay(starterContainer: StarterContainer) { - if (this.isUpgradeIconEnabled() ) { + if (this.isUpgradeIconEnabled()) { this.setUpgradeIcon(starterContainer); } if (this.isUpgradeAnimationEnabled()) { @@ -1286,7 +1539,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // Loop through all visible candy icons when set to 'Icon' mode if (globalScene.candyUpgradeDisplay === 0) { - this.filteredStarterContainers.forEach((starter) => { + this.filteredStarterContainers.forEach(starter => { this.setUpgradeIcon(starter); }); @@ -1312,7 +1565,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const numOfRows = Math.ceil(numberOfStarters / maxColumns); const currentRow = Math.floor(this.cursor / maxColumns); const onScreenFirstIndex = this.scrollCursor * maxColumns; // this is first starter index on the screen - const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + maxRows * maxColumns - 1); // this is the last starter index on the screen + const onScreenLastIndex = Math.min( + this.filteredStarterContainers.length - 1, + onScreenFirstIndex + maxRows * maxColumns - 1, + ); // this is the last starter index on the screen const onScreenNumberOfStarters = onScreenLastIndex - onScreenFirstIndex + 1; const onScreenNumberOfRows = Math.ceil(onScreenNumberOfStarters / maxColumns); const onScreenCurrentRow = Math.floor((this.cursor - onScreenFirstIndex) / maxColumns); @@ -1333,7 +1589,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // CANCEL with a filter menu open > close it this.filterBar.toggleDropDown(this.filterBarCursor); success = true; - } else if (this.filterMode && !this.filterBar.getFilter(this.filterBar.getColumn(this.filterBarCursor)).hasDefaultValues()) { + } else if ( + this.filterMode && + !this.filterBar.getFilter(this.filterBar.getColumn(this.filterBarCursor)).hasDefaultValues() + ) { if (this.filterBar.getColumn(this.filterBarCursor) === DropDownColumn.CAUGHT) { this.resetCaughtDropdown(); } else { @@ -1362,7 +1621,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.setFilterMode(true); this.filterBar.toggleDropDown(this.filterBarCursor); } - } else if (this.startCursorObj.visible) { // this checks to see if the start button is selected + } else if (this.startCursorObj.visible) { + // this checks to see if the start button is selected switch (button) { case Button.ACTION: if (this.tryStart(true)) { @@ -1372,7 +1632,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } break; case Button.UP: - // UP from start button: go to pokemon in team if any, otherwise filter + // UP from start button: go to pokemon in team if any, otherwise filter this.startCursorObj.setVisible(false); if (this.starterSpecies.length > 0) { this.starterIconsCursorIndex = this.starterSpecies.length - 1; @@ -1385,7 +1645,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { success = true; break; case Button.DOWN: - // DOWN from start button: Go to filters + // DOWN from start button: Go to filters this.startCursorObj.setVisible(false); this.filterBarCursor = Math.max(1, this.filterBar.numFilters - 1); this.setFilterMode(true); @@ -1427,8 +1687,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { case Button.UP: if (this.filterBar.openDropDown) { success = this.filterBar.decDropDownCursor(); - } else if (this.filterBarCursor === this.filterBar.numFilters - 1 ) { - // UP from the last filter, move to start button + } else if (this.filterBarCursor === this.filterBar.numFilters - 1) { + // UP from the last filter, move to start button this.setFilterMode(false); this.cursorObj.setVisible(false); if (this.starterSpecies.length > 0) { @@ -1445,9 +1705,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const proportion = (this.filterBarCursor + 0.5) / this.filterBar.numFilters; const targetCol = Math.min(8, Math.floor(proportion * 11)); if (numberOfStarters % 9 > targetCol) { - this.setCursor(numberOfStarters - (numberOfStarters) % 9 + targetCol); + this.setCursor(numberOfStarters - (numberOfStarters % 9) + targetCol); } else { - this.setCursor(Math.max(numberOfStarters - (numberOfStarters) % 9 + targetCol - 9, 0)); + this.setCursor(Math.max(numberOfStarters - (numberOfStarters % 9) + targetCol - 9, 0)); } success = true; } @@ -1456,13 +1716,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (this.filterBar.openDropDown) { success = this.filterBar.incDropDownCursor(); } else if (this.filterBarCursor === this.filterBar.numFilters - 1) { - // DOWN from the last filter, move to random selection label + // DOWN from the last filter, move to random selection label this.setFilterMode(false); this.cursorObj.setVisible(false); this.randomCursorObj.setVisible(true); success = true; } else if (numberOfStarters > 0) { - // DOWN from filter bar to top of Pokemon list + // DOWN from filter bar to top of Pokemon list this.setFilterMode(false); this.scrollCursor = 0; this.updateScroll(); @@ -1488,11 +1748,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { error = true; break; } - const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, _gen: number, i: number ) => total + globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); + const currentPartyValue = this.starterSpecies + .map(s => s.generation) + .reduce( + (total: number, _gen: number, i: number) => + total + globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), + 0, + ); // Filter valid starters const validStarters = this.filteredStarterContainers.filter(starter => { const species = starter.species; - const [ isDupe ] = this.isInParty(species); + const [isDupe] = this.isInParty(species); const starterCost = globalScene.gameData.getSpeciesStarterValue(species.speciesId); const isValidForChallenge = new BooleanHolder(true); Challenge.applyChallenges( @@ -1500,11 +1766,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, - globalScene.gameData.getSpeciesDexAttrProps( - species, - this.getCurrentDexProps(species.speciesId) - ), - this.isPartyValid() + globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), + this.isPartyValid(), ); const isCaught = globalScene.gameData.dexData[species.speciesId].caughtAttr; return ( @@ -1532,14 +1795,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const starterCost = globalScene.gameData.getSpeciesStarterValue(randomSpecies.speciesId); const speciesForm = getPokemonSpeciesForm(randomSpecies.speciesId, props.formIndex); // Load assets and add to party - speciesForm - .loadAssets(props.female, props.formIndex, props.shiny, props.variant, true) - .then(() => { - if (this.tryUpdateValue(starterCost, true)) { - this.addToParty(randomSpecies, dexAttr, abilityIndex, nature, moveset, teraType, true); - ui.playSelect(); - } - }); + speciesForm.loadAssets(props.female, props.formIndex, props.shiny, props.variant, true).then(() => { + if (this.tryUpdateValue(starterCost, true)) { + this.addToParty(randomSpecies, dexAttr, abilityIndex, nature, moveset, teraType, true); + ui.playSelect(); + } + }); break; case Button.UP: this.randomCursorObj.setVisible(false); @@ -1576,7 +1837,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { break; } } else { - let starterContainer; + let starterContainer: StarterContainer; const starterData = globalScene.gameData.starterData[this.lastSpecies.speciesId]; // prepare persistent starter data to store changes let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId]; @@ -1586,68 +1847,110 @@ export default class StarterSelectUiHandler extends MessageUiHandler { starterContainer = this.filteredStarterContainers[this.cursor]; } else { // if species is in filtered starters, get the starter container from the filtered starters, it can be undefined if the species is not in the filtered starters - starterContainer = this.filteredStarterContainers[this.filteredStarterContainers.findIndex(container => container.species === this.lastSpecies)]; + starterContainer = + this.filteredStarterContainers[ + this.filteredStarterContainers.findIndex(container => container.species === this.lastSpecies) + ]; } if (button === Button.ACTION) { if (!this.speciesStarterDexEntry?.caughtAttr) { error = true; - } else if (this.starterSpecies.length <= 6) { // checks to see if the party has 6 or fewer pokemon + } else if (this.starterSpecies.length <= 6) { + // checks to see if the party has 6 or fewer pokemon const ui = this.getUi(); let options: any[] = []; // TODO: add proper type - const [ isDupe, removeIndex ]: [boolean, number] = this.isInParty(this.lastSpecies); // checks to see if the pokemon is a duplicate; if it is, returns the index that will be removed + const [isDupe, removeIndex]: [boolean, number] = this.isInParty(this.lastSpecies); // checks to see if the pokemon is a duplicate; if it is, returns the index that will be removed const isPartyValid = this.isPartyValid(); const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, this.lastSpecies, isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)), isPartyValid); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + this.lastSpecies, + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps( + this.lastSpecies, + this.getCurrentDexProps(this.lastSpecies.speciesId), + ), + isPartyValid, + ); - const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, _gen: number, i: number) => total += globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); + const currentPartyValue = this.starterSpecies + .map(s => s.generation) + .reduce( + (total: number, _gen: number, i: number) => + (total += globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId)), + 0, + ); const newCost = globalScene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId); - if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < PLAYER_PARTY_MAX_SIZE) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party + if ( + !isDupe && + isValidForChallenge.value && + currentPartyValue + newCost <= this.getValueLimit() && + this.starterSpecies.length < PLAYER_PARTY_MAX_SIZE + ) { + // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party options = [ { label: i18next.t("starterSelectUiHandler:addToParty"), handler: () => { ui.setMode(Mode.STARTER_SELECT); - const isOverValueLimit = this.tryUpdateValue(globalScene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId), true); + const isOverValueLimit = this.tryUpdateValue( + globalScene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId), + true, + ); if (!isDupe && isValidForChallenge.value && isOverValueLimit) { const cursorObj = this.starterCursorObjs[this.starterSpecies.length]; cursorObj.setVisible(true); cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y); - this.addToParty(this.lastSpecies, this.dexAttrCursor, this.abilityCursor, this.natureCursor as unknown as Nature, this.starterMoveset?.slice(0) as StarterMoveset, this.teraCursor); + this.addToParty( + this.lastSpecies, + this.dexAttrCursor, + this.abilityCursor, + this.natureCursor as unknown as Nature, + this.starterMoveset?.slice(0) as StarterMoveset, + this.teraCursor, + ); ui.playSelect(); } else { ui.playError(); // this should be redundant as there is now a trigger for when a pokemon can't be added to party } return true; }, - overrideSound: true - }]; - } else if (isDupe) { // if it already exists in your party, it will give you the option to remove from your party - options = [{ - label: i18next.t("starterSelectUiHandler:removeFromParty"), - handler: () => { - this.popStarter(removeIndex); - ui.setMode(Mode.STARTER_SELECT); - return true; - } - }]; + overrideSound: true, + }, + ]; + } else if (isDupe) { + // if it already exists in your party, it will give you the option to remove from your party + options = [ + { + label: i18next.t("starterSelectUiHandler:removeFromParty"), + handler: () => { + this.popStarter(removeIndex); + ui.setMode(Mode.STARTER_SELECT); + return true; + }, + }, + ]; } - options.push( // this shows the IVs for the pokemon + options.push( + // this shows the IVs for the pokemon { label: i18next.t("starterSelectUiHandler:toggleIVs"), handler: () => { this.toggleStatsMode(); ui.setMode(Mode.STARTER_SELECT); return true; - } - }); - if (this.speciesStarterMoves.length > 1) { // this lets you change the pokemon moves + }, + }, + ); + if (this.speciesStarterMoves.length > 1) { + // this lets you change the pokemon moves const showSwapOptions = (moveset: StarterMoveset) => { - this.blockInput = true; ui.setMode(Mode.STARTER_SELECT).then(() => { @@ -1655,70 +1958,78 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.moveInfoOverlay.show(allMoves[moveset[0]]); ui.setModeWithoutClear(Mode.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.showText(`${i18next.t("starterSelectUiHandler:selectMoveSwapWith")} ${allMoves[m].name}.`, null, () => { - const possibleMoves = this.speciesStarterMoves.filter((sm: Moves) => sm !== m); - this.moveInfoOverlay.show(allMoves[possibleMoves[0]]); + 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.showText( + `${i18next.t("starterSelectUiHandler:selectMoveSwapWith")} ${allMoves[m].name}.`, + null, + () => { + const possibleMoves = this.speciesStarterMoves.filter((sm: Moves) => sm !== m); + this.moveInfoOverlay.show(allMoves[possibleMoves[0]]); - ui.setModeWithoutClear(Mode.OPTION_SELECT, { - options: possibleMoves.map(sm => { - // make an option for each available starter move - const option = { - label: allMoves[sm].name, - handler: () => { - this.switchMoveHandler(i, sm, m); - showSwapOptions(this.starterMoveset!); // TODO: is this bang correct? - return true; - }, - onHover: () => { - this.moveInfoOverlay.show(allMoves[sm]); - }, - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - showSwapOptions(this.starterMoveset!); // TODO: is this bang correct? - return true; - }, - onHover: () => { - this.moveInfoOverlay.clear(); - }, - }), - supportHover: true, - maxOptions: 8, - yOffset: 19 - }); - this.blockInput = false; + ui.setModeWithoutClear(Mode.OPTION_SELECT, { + options: possibleMoves + .map(sm => { + // make an option for each available starter move + const option = { + label: allMoves[sm].name, + handler: () => { + this.switchMoveHandler(i, sm, m); + showSwapOptions(this.starterMoveset!); // TODO: is this bang correct? + return true; + }, + onHover: () => { + this.moveInfoOverlay.show(allMoves[sm]); + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), + handler: () => { + showSwapOptions(this.starterMoveset!); // TODO: is this bang correct? + return true; + }, + onHover: () => { + this.moveInfoOverlay.clear(); + }, + }), + supportHover: true, + maxOptions: 8, + yOffset: 19, + }); + this.blockInput = false; + }, + ); }); - }); + return true; + }, + onHover: () => { + this.moveInfoOverlay.show(allMoves[m]); + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), + handler: () => { + this.moveInfoOverlay.clear(); + this.clearText(); + ui.setMode(Mode.STARTER_SELECT); return true; }, onHover: () => { - this.moveInfoOverlay.show(allMoves[m]); + this.moveInfoOverlay.clear(); }, - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - this.moveInfoOverlay.clear(); - this.clearText(); - ui.setMode(Mode.STARTER_SELECT); - return true; - }, - onHover: () => { - this.moveInfoOverlay.clear(); - }, - }), + }), supportHover: true, maxOptions: 8, - yOffset: 19 + yOffset: 19, }); this.blockInput = false; }); @@ -1729,48 +2040,51 @@ export default class StarterSelectUiHandler extends MessageUiHandler { handler: () => { showSwapOptions(this.starterMoveset!); // TODO: is this bang correct? return true; - } + }, }); } if (this.canCycleNature) { // if we could cycle natures, enable the improved nature menu const showNatureOptions = () => { - this.blockInput = true; ui.setMode(Mode.STARTER_SELECT).then(() => { ui.showText(i18next.t("starterSelectUiHandler:selectNature"), null, () => { const natures = globalScene.gameData.getNaturesForAttr(this.speciesStarterDexEntry?.natureAttr); ui.setModeWithoutClear(Mode.OPTION_SELECT, { - options: natures.map((n: Nature, _i: number) => { - const option: OptionSelectItem = { - label: getNatureName(n, true, true, true, globalScene.uiTheme), + options: natures + .map((n: Nature, _i: number) => { + const option: OptionSelectItem = { + label: getNatureName(n, true, true, true, globalScene.uiTheme), + handler: () => { + // update default nature in starter save data + if (!starterAttributes) { + starterAttributes = this.starterPreferences[this.lastSpecies.speciesId] = {}; + } + starterAttributes.nature = n; + this.clearText(); + ui.setMode(Mode.STARTER_SELECT); + // set nature for starter + this.setSpeciesDetails(this.lastSpecies, { + natureIndex: n, + }); + this.blockInput = false; + return true; + }, + }; + return option; + }) + .concat({ + label: i18next.t("menu:cancel"), handler: () => { - // update default nature in starter save data - if (!starterAttributes) { - starterAttributes = this.starterPreferences[this.lastSpecies.speciesId] = {}; - } - starterAttributes.nature = n; this.clearText(); ui.setMode(Mode.STARTER_SELECT); - // set nature for starter - this.setSpeciesDetails(this.lastSpecies, { natureIndex: n }); this.blockInput = false; return true; - } - }; - return option; - }).concat({ - label: i18next.t("menu:cancel"), - handler: () => { - this.clearText(); - ui.setMode(Mode.STARTER_SELECT); - this.blockInput = false; - return true; - } - }), + }, + }), maxOptions: 8, - yOffset: 19 + yOffset: 19, }); }); }); @@ -1780,12 +2094,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { handler: () => { showNatureOptions(); return true; - } + }, }); } const passiveAttr = starterData.passiveAttr; - if (passiveAttr & PassiveAttr.UNLOCKED) { // this is for enabling and disabling the passive + if (passiveAttr & PassiveAttr.UNLOCKED) { + // this is for enabling and disabling the passive if (!(passiveAttr & PassiveAttr.ENABLED)) { options.push({ label: i18next.t("starterSelectUiHandler:enablePassive"), @@ -1794,7 +2109,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { ui.setMode(Mode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies); return true; - } + }, }); } else { options.push({ @@ -1804,7 +2119,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { ui.setMode(Mode.STARTER_SELECT); this.setSpeciesDetails(this.lastSpecies); return true; - } + }, }); } } @@ -1821,7 +2136,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } ui.setMode(Mode.STARTER_SELECT); return true; - } + }, }); } else { options.push({ @@ -1834,7 +2149,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } ui.setMode(Mode.STARTER_SELECT); return true; - } + }, }); } options.push({ @@ -1843,26 +2158,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler { ui.playSelect(); let nickname = starterAttributes.nickname ? String(starterAttributes.nickname) : ""; nickname = decodeURIComponent(escape(atob(nickname))); - ui.setModeWithoutClear(Mode.RENAME_POKEMON, { - buttonActions: [ - (sanitizedName: string) => { - ui.playSelect(); - starterAttributes.nickname = sanitizedName; - const name = decodeURIComponent(escape(atob(starterAttributes.nickname))); - if (name.length > 0) { - this.pokemonNameText.setText(name); - } else { - this.pokemonNameText.setText(this.lastSpecies.name); - } - ui.setMode(Mode.STARTER_SELECT); - }, - () => { - ui.setMode(Mode.STARTER_SELECT); - } - ] - }, nickname); + ui.setModeWithoutClear( + Mode.RENAME_POKEMON, + { + buttonActions: [ + (sanitizedName: string) => { + ui.playSelect(); + starterAttributes.nickname = sanitizedName; + const name = decodeURIComponent(escape(atob(starterAttributes.nickname))); + if (name.length > 0) { + this.pokemonNameText.setText(name); + } else { + this.pokemonNameText.setText(this.lastSpecies.name); + } + ui.setMode(Mode.STARTER_SELECT); + }, + () => { + ui.setMode(Mode.STARTER_SELECT); + }, + ], + }, + nickname, + ); return true; - } + }, }); // Purchases with Candy @@ -1894,21 +2213,25 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // update the passive background and icon/animation for available upgrade if (starterContainer) { this.updateCandyUpgradeDisplay(starterContainer); - starterContainer.starterPassiveBgs.setVisible(!!globalScene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr); + starterContainer.starterPassiveBgs.setVisible( + !!globalScene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr, + ); } return true; } return false; }, item: "candy", - itemArgs: starterColors[this.lastSpecies.speciesId] + itemArgs: starterColors[this.lastSpecies.speciesId], }); } // Reduce cost option const valueReduction = starterData.valueReduction; if (valueReduction < valueReductionMax) { - const reductionCost = getValueReductionCandyCounts(speciesStarterCosts[this.lastSpecies.speciesId])[valueReduction]; + const reductionCost = getValueReductionCandyCounts(speciesStarterCosts[this.lastSpecies.speciesId])[ + valueReduction + ]; options.push({ label: `x${reductionCost} ${i18next.t("starterSelectUiHandler:reduceCost")}`, handler: () => { @@ -1937,7 +2260,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return false; }, item: "candy", - itemArgs: starterColors[this.lastSpecies.speciesId] + itemArgs: starterColors[this.lastSpecies.speciesId], }); } @@ -1949,7 +2272,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= sameSpeciesEggCost) { if (globalScene.gameData.eggs.length >= 99 && !Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) { // Egg list full, show error message at the top of the screen and abort - this.showText(i18next.t("egg:tooManyEggs"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), 2000, false, undefined, true); + this.showText( + i18next.t("egg:tooManyEggs"), + undefined, + () => this.showText("", 0, () => (this.tutorialActive = false)), + 2000, + false, + undefined, + true, + ); return false; } if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) { @@ -1957,7 +2288,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); - const egg = new Egg({ species: this.lastSpecies.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG }); + const egg = new Egg({ + species: this.lastSpecies.speciesId, + sourceType: EggSourceType.SAME_SPECIES_EGG, + }); egg.addEggToGameData(); globalScene.gameData.saveSystem().then(success => { @@ -1978,18 +2312,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return false; }, item: "candy", - itemArgs: starterColors[this.lastSpecies.speciesId] + itemArgs: starterColors[this.lastSpecies.speciesId], }); options.push({ label: i18next.t("menu:cancel"), handler: () => { ui.setMode(Mode.STARTER_SELECT); return true; - } + }, }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, - yOffset: 47 + yOffset: 47, }); }; options.push({ @@ -2000,12 +2334,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler { shiny: starterAttributes.shiny, variant: starterAttributes.variant, form: starterAttributes.form, - female: starterAttributes.female + female: starterAttributes.female, }; ui.setOverlayMode(Mode.POKEDEX_PAGE, this.lastSpecies, starterAttributes.form, attributes); }); return true; - } + }, }); if (!pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId)) { options.push({ @@ -2013,7 +2347,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { handler: () => { ui.setMode(Mode.STARTER_SELECT).then(() => showUseCandies()); return true; - } + }, }); } options.push({ @@ -2021,24 +2355,35 @@ export default class StarterSelectUiHandler extends MessageUiHandler { handler: () => { ui.setMode(Mode.STARTER_SELECT); return true; - } + }, }); ui.setModeWithoutClear(Mode.OPTION_SELECT, { options: options, - yOffset: 47 + yOffset: 47, }); success = true; } } else { - const props = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); + const props = globalScene.gameData.getSpeciesDexAttrProps( + this.lastSpecies, + this.getCurrentDexProps(this.lastSpecies.speciesId), + ); switch (button) { case Button.CYCLE_SHINY: if (this.canCycleShiny) { if (starterAttributes.shiny === false) { // If not shiny, we change to shiny and get the proper default variant - const newProps = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); - const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : newProps.variant; - this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant }); + const newProps = globalScene.gameData.getSpeciesDexAttrProps( + this.lastSpecies, + this.getCurrentDexProps(this.lastSpecies.speciesId), + ); + const newVariant = starterAttributes.variant + ? (starterAttributes.variant as Variant) + : newProps.variant; + this.setSpeciesDetails(this.lastSpecies, { + shiny: true, + variant: newVariant, + }); globalScene.playSound("se/sparkle"); // Cycle tint based on current sprite tint @@ -2054,29 +2399,37 @@ export default class StarterSelectUiHandler extends MessageUiHandler { do { newVariant = (newVariant + 1) % 3; if (newVariant === 0) { - if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.DEFAULT_VARIANT) { // TODO: is this bang correct? + if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.DEFAULT_VARIANT) { + // TODO: is this bang correct? break; } } else if (newVariant === 1) { - if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_2) { // TODO: is this bang correct? + if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_2) { + // TODO: is this bang correct? break; } } else { - if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_3) { // TODO: is this bang correct? + if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.VARIANT_3) { + // TODO: is this bang correct? break; } } } while (newVariant !== props.variant); starterAttributes.variant = newVariant; // store the selected variant - if ((this.speciesStarterDexEntry!.caughtAttr & DexAttr.NON_SHINY) && (newVariant <= props.variant)) { + if (this.speciesStarterDexEntry!.caughtAttr & DexAttr.NON_SHINY && newVariant <= props.variant) { // If we have run out of variants, go back to non shiny - this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 }); + this.setSpeciesDetails(this.lastSpecies, { + shiny: false, + variant: 0, + }); this.pokemonShinyIcon.setVisible(false); success = true; starterAttributes.shiny = false; } else { // If going to a higher variant, or only shiny forms are caught, go to next variant - this.setSpeciesDetails(this.lastSpecies, { variant: newVariant as Variant }); + this.setSpeciesDetails(this.lastSpecies, { + variant: newVariant as Variant, + }); // Cycle tint based on current sprite tint const tint = getVariantTint(newVariant as Variant); this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant)); @@ -2092,20 +2445,29 @@ export default class StarterSelectUiHandler extends MessageUiHandler { let newFormIndex = props.formIndex; do { newFormIndex = (newFormIndex + 1) % formCount; - if (this.lastSpecies.forms[newFormIndex].isStarterSelectable && this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(newFormIndex)) { // TODO: are those bangs correct? + if ( + this.lastSpecies.forms[newFormIndex].isStarterSelectable && + this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(newFormIndex) + ) { + // TODO: are those bangs correct? break; } } while (newFormIndex !== props.formIndex); starterAttributes.form = newFormIndex; // store the selected form starterAttributes.tera = this.lastSpecies.forms[newFormIndex].type1; - this.setSpeciesDetails(this.lastSpecies, { formIndex: newFormIndex, teraType: starterAttributes.tera }); + this.setSpeciesDetails(this.lastSpecies, { + formIndex: newFormIndex, + teraType: starterAttributes.tera, + }); success = true; } break; case Button.CYCLE_GENDER: if (this.canCycleGender) { starterAttributes.female = !props.female; - this.setSpeciesDetails(this.lastSpecies, { female: !props.female }); + this.setSpeciesDetails(this.lastSpecies, { + female: !props.female, + }); success = true; } break; @@ -2122,7 +2484,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { break; } } else if (newAbilityIndex === 1) { - // If ability 1 and 2 are the same and ability 1 is unlocked, skip over ability 2 + // If ability 1 and 2 are the same and ability 1 is unlocked, skip over ability 2 if (this.lastSpecies.ability1 === this.lastSpecies.ability2 && hasAbility1) { newAbilityIndex = (newAbilityIndex + 1) % abilityCount; } @@ -2142,7 +2504,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { globalScene.ui.editTooltip(`${newAbility.name}`, `${newAbility.description}`); } - this.setSpeciesDetails(this.lastSpecies, { abilityIndex: newAbilityIndex }); + this.setSpeciesDetails(this.lastSpecies, { + abilityIndex: newAbilityIndex, + }); success = true; } break; @@ -2153,7 +2517,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const newNature = natures[natureIndex < natures.length - 1 ? natureIndex + 1 : 0]; // store cycled nature as default starterAttributes.nature = newNature as unknown as number; - this.setSpeciesDetails(this.lastSpecies, { natureIndex: newNature }); + this.setSpeciesDetails(this.lastSpecies, { + natureIndex: newNature, + }); success = true; } break; @@ -2162,10 +2528,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const speciesForm = getPokemonSpeciesForm(this.lastSpecies.speciesId, starterAttributes.form ?? 0); if (speciesForm.type1 === this.teraCursor && !Utils.isNullOrUndefined(speciesForm.type2)) { starterAttributes.tera = speciesForm.type2!; - this.setSpeciesDetails(this.lastSpecies, { teraType: speciesForm.type2! }); + this.setSpeciesDetails(this.lastSpecies, { + teraType: speciesForm.type2!, + }); } else { starterAttributes.tera = speciesForm.type1; - this.setSpeciesDetails(this.lastSpecies, { teraType: speciesForm.type1 }); + this.setSpeciesDetails(this.lastSpecies, { + teraType: speciesForm.type1, + }); } success = true; } @@ -2185,7 +2555,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } else { if (this.starterIconsCursorIndex === 0) { - // Up from first Pokemon in the team > go to Random selection + // Up from first Pokemon in the team > go to Random selection this.starterIconsCursorObj.setVisible(false); this.setSpecies(null); this.randomCursorObj.setVisible(true); @@ -2198,19 +2568,21 @@ export default class StarterSelectUiHandler extends MessageUiHandler { break; case Button.DOWN: if (!this.starterIconsCursorObj.visible) { - if (currentRow < numOfRows - 1) { // not last row - if (currentRow - this.scrollCursor === 8) { // last row of visible starters + if (currentRow < numOfRows - 1) { + // not last row + if (currentRow - this.scrollCursor === 8) { + // last row of visible starters this.scrollCursor++; } success = this.setCursor(this.cursor + 9); this.updateScroll(); } else if (numOfRows > 1) { - // DOWN from last row of Pokemon > Wrap around to first row + // DOWN from last row of Pokemon > Wrap around to first row this.scrollCursor = 0; this.updateScroll(); success = this.setCursor(this.cursor % 9); } else { - // DOWN from single row of Pokemon > Go to filters + // DOWN from single row of Pokemon > Go to filters this.filterBarCursor = this.filterBar.getNearestFilter(this.filteredStarterContainers[this.cursor]); this.setFilterMode(true); success = true; @@ -2232,23 +2604,24 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (this.cursor % 9 !== 0) { success = this.setCursor(this.cursor - 1); } else { - // LEFT from filtered Pokemon, on the left edge - if ( onScreenCurrentRow === 0 ) { + // LEFT from filtered Pokemon, on the left edge + if (onScreenCurrentRow === 0) { // from the first row of starters we go to the random selection this.cursorObj.setVisible(false); this.randomCursorObj.setVisible(true); } else if (this.starterSpecies.length === 0) { - // no starter in team and not on first row > wrap around to the last column + // no starter in team and not on first row > wrap around to the last column success = this.setCursor(this.cursor + Math.min(8, numberOfStarters - this.cursor)); - } else if (onScreenCurrentRow < 7) { - // at least one pokemon in team > for the first 7 rows, go to closest starter + // at least one pokemon in team > for the first 7 rows, go to closest starter this.cursorObj.setVisible(false); - this.starterIconsCursorIndex = findClosestStarterIndex(this.cursorObj.y - 1, this.starterSpecies.length); + this.starterIconsCursorIndex = findClosestStarterIndex( + this.cursorObj.y - 1, + this.starterSpecies.length, + ); this.moveStarterIconsCursor(this.starterIconsCursorIndex); - } else { - // at least one pokemon in team > from the bottom 2 rows, go to start run button + // at least one pokemon in team > from the bottom 2 rows, go to start run button this.cursorObj.setVisible(false); this.setSpecies(null); this.startCursorObj.setVisible(true); @@ -2256,40 +2629,41 @@ export default class StarterSelectUiHandler extends MessageUiHandler { success = true; } } else if (numberOfStarters > 0) { - // LEFT from team > Go to closest filtered Pokemon + // LEFT from team > Go to closest filtered Pokemon const closestRowIndex = findClosestStarterRow(this.starterIconsCursorIndex, onScreenNumberOfRows); this.starterIconsCursorObj.setVisible(false); this.cursorObj.setVisible(true); this.setCursor(Math.min(onScreenFirstIndex + closestRowIndex * 9 + 8, onScreenLastIndex)); success = true; } else { - // LEFT from team and no Pokemon in filter > do nothing + // LEFT from team and no Pokemon in filter > do nothing success = false; } break; case Button.RIGHT: if (!this.starterIconsCursorObj.visible) { - // is not right edge + // is not right edge if (this.cursor % 9 < (currentRow < numOfRows - 1 ? 8 : (numberOfStarters - 1) % 9)) { success = this.setCursor(this.cursor + 1); } else { - // RIGHT from filtered Pokemon, on the right edge - if ( onScreenCurrentRow === 0 ) { + // RIGHT from filtered Pokemon, on the right edge + if (onScreenCurrentRow === 0) { // from the first row of starters we go to the random selection this.cursorObj.setVisible(false); this.randomCursorObj.setVisible(true); } else if (this.starterSpecies.length === 0) { - // no selected starter in team > wrap around to the first column + // no selected starter in team > wrap around to the first column success = this.setCursor(this.cursor - Math.min(8, this.cursor % 9)); - } else if (onScreenCurrentRow < 7) { - // at least one pokemon in team > for the first 7 rows, go to closest starter + // at least one pokemon in team > for the first 7 rows, go to closest starter this.cursorObj.setVisible(false); - this.starterIconsCursorIndex = findClosestStarterIndex(this.cursorObj.y - 1, this.starterSpecies.length); + this.starterIconsCursorIndex = findClosestStarterIndex( + this.cursorObj.y - 1, + this.starterSpecies.length, + ); this.moveStarterIconsCursor(this.starterIconsCursorIndex); - } else { - // at least one pokemon in team > from the bottom 2 rows, go to start run button + // at least one pokemon in team > from the bottom 2 rows, go to start run button this.cursorObj.setVisible(false); this.setSpecies(null); this.startCursorObj.setVisible(true); @@ -2297,14 +2671,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler { success = true; } } else if (numberOfStarters > 0) { - // RIGHT from team > Go to closest filtered Pokemon + // RIGHT from team > Go to closest filtered Pokemon const closestRowIndex = findClosestStarterRow(this.starterIconsCursorIndex, onScreenNumberOfRows); this.starterIconsCursorObj.setVisible(false); this.cursorObj.setVisible(true); - this.setCursor(Math.min(onScreenFirstIndex + closestRowIndex * 9, onScreenLastIndex - (onScreenLastIndex % 9))); + this.setCursor( + Math.min(onScreenFirstIndex + closestRowIndex * 9, onScreenLastIndex - (onScreenLastIndex % 9)), + ); success = true; } else { - // RIGHT from team and no Pokemon in filter > do nothing + // RIGHT from team and no Pokemon in filter > do nothing success = false; } break; @@ -2331,14 +2707,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { break; } } - return [ isDupe, removeIndex ]; + return [isDupe, removeIndex]; } - addToParty(species: PokemonSpecies, dexAttr: bigint, abilityIndex: number, nature: Nature, moveset: StarterMoveset, teraType: PokemonType, randomSelection: boolean = false) { + addToParty( + species: PokemonSpecies, + dexAttr: bigint, + abilityIndex: number, + nature: Nature, + moveset: StarterMoveset, + teraType: PokemonType, + randomSelection = false, + ) { const props = globalScene.gameData.getSpeciesDexAttrProps(species, dexAttr); - this.starterIcons[this.starterSpecies.length].setTexture(species.getIconAtlasKey(props.formIndex, props.shiny, props.variant)); - this.starterIcons[this.starterSpecies.length].setFrame(species.getIconId(props.female, props.formIndex, props.shiny, props.variant)); - this.checkIconId(this.starterIcons[this.starterSpecies.length], species, props.female, props.formIndex, props.shiny, props.variant); + this.starterIcons[this.starterSpecies.length].setTexture( + species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), + ); + this.starterIcons[this.starterSpecies.length].setFrame( + species.getIconId(props.female, props.formIndex, props.shiny, props.variant), + ); + this.checkIconId( + this.starterIcons[this.starterSpecies.length], + species, + props.female, + props.formIndex, + props.shiny, + props.variant, + ); this.starterSpecies.push(species); this.starterAttr.push(dexAttr); @@ -2346,7 +2741,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterNatures.push(nature); this.starterTeras.push(teraType); this.starterMovesets.push(moveset); - if (this.speciesLoaded.get(species.speciesId) || randomSelection ) { + if (this.speciesLoaded.get(species.speciesId) || randomSelection) { getPokemonSpeciesForm(species.speciesId, props.formIndex).cry(); } this.updateInstructions(); @@ -2370,21 +2765,30 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // species has different forms if (pokemonFormLevelMoves.hasOwnProperty(speciesId)) { // starterMoveData doesn't have base form moves or is using the single form format - if (!globalScene.gameData.starterData[speciesId].moveset || Array.isArray(globalScene.gameData.starterData[speciesId].moveset)) { - globalScene.gameData.starterData[speciesId].moveset = { [props.formIndex]: this.starterMoveset?.slice(0) as StarterMoveset }; + if ( + !globalScene.gameData.starterData[speciesId].moveset || + Array.isArray(globalScene.gameData.starterData[speciesId].moveset) + ) { + globalScene.gameData.starterData[speciesId].moveset = { + [props.formIndex]: this.starterMoveset?.slice(0) as StarterMoveset, + }; } const starterMoveData = globalScene.gameData.starterData[speciesId].moveset; // starterMoveData doesn't have active form moves if (!starterMoveData.hasOwnProperty(props.formIndex)) { - globalScene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset?.slice(0) as StarterMoveset; + globalScene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset?.slice( + 0, + ) as StarterMoveset; } // does the species' starter move data have its form's starter moves and has it been updated if (starterMoveData.hasOwnProperty(props.formIndex)) { // active form move hasn't been updated if (starterMoveData[props.formIndex][existingMoveIndex] !== newMove) { - globalScene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset?.slice(0) as StarterMoveset; + globalScene.gameData.starterData[speciesId].moveset[props.formIndex] = this.starterMoveset?.slice( + 0, + ) as StarterMoveset; } } } else { @@ -2403,8 +2807,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } - updateButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void { - let iconPath; + updateButtonIcon( + iconSetting: SettingKeyboard, + gamepadType: string, + iconElement: GameObjects.Sprite, + controlLabel: GameObjects.Text, + ): void { + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO + let iconPath: string; // touch controls cannot be rebound as is, and are just emulating a keyboard event. // Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls if (gamepadType === "touch") { @@ -2437,12 +2847,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } else { iconPath = globalScene.inputController?.getIconForLatestInputRecorded(iconSetting); } + // @ts-ignore: TODO can iconPath actually be undefined? iconElement.setTexture(gamepadType, iconPath); iconElement.setPosition(this.instructionRowX, this.instructionRowY); controlLabel.setPosition(this.instructionRowX + this.instructionRowTextOffset, this.instructionRowY); iconElement.setVisible(true); controlLabel.setVisible(true); - this.instructionsContainer.add([ iconElement, controlLabel ]); + this.instructionsContainer.add([iconElement, controlLabel]); this.instructionRowY += 8; if (this.instructionRowY >= 24) { this.instructionRowY = 0; @@ -2450,8 +2861,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } - updateFilterButtonIcon(iconSetting, gamepadType, iconElement, controlLabel): void { - let iconPath; + updateFilterButtonIcon( + iconSetting: SettingKeyboard, + gamepadType: string, + iconElement: GameObjects.Sprite, + controlLabel: GameObjects.Text, + ): void { + let iconPath: string; // touch controls cannot be rebound as is, and are just emulating a keyboard event. // Additionally, since keyboard controls can be rebound (and will be displayed when they are), we need to have special handling for the touch controls if (gamepadType === "touch") { @@ -2465,7 +2881,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { controlLabel.setPosition(this.filterInstructionRowX + this.instructionRowTextOffset, this.filterInstructionRowY); iconElement.setVisible(true); controlLabel.setVisible(true); - this.filterInstructionsContainer.add([ iconElement, controlLabel ]); + this.filterInstructionsContainer.add([iconElement, controlLabel]); this.filterInstructionRowY += 8; if (this.filterInstructionRowY >= 24) { this.filterInstructionRowY = 0; @@ -2481,9 +2897,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.hideInstructions(); this.instructionsContainer.removeAll(); this.filterInstructionsContainer.removeAll(); - let gamepadType; + let gamepadType: string; if (globalScene.inputMethod === "gamepad") { - gamepadType = globalScene.inputController.getConfig(globalScene.inputController.selectedDevice[Device.GAMEPAD]).padType; + gamepadType = globalScene.inputController.getConfig( + globalScene.inputController.selectedDevice[Device.GAMEPAD], + ).padType; } else { gamepadType = globalScene.inputMethod; } @@ -2500,13 +2918,28 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.updateButtonIcon(SettingKeyboard.Button_Cycle_Form, gamepadType, this.formIconElement, this.formLabel); } if (this.canCycleGender) { - this.updateButtonIcon(SettingKeyboard.Button_Cycle_Gender, gamepadType, this.genderIconElement, this.genderLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Cycle_Gender, + gamepadType, + this.genderIconElement, + this.genderLabel, + ); } if (this.canCycleAbility) { - this.updateButtonIcon(SettingKeyboard.Button_Cycle_Ability, gamepadType, this.abilityIconElement, this.abilityLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Cycle_Ability, + gamepadType, + this.abilityIconElement, + this.abilityLabel, + ); } if (this.canCycleNature) { - this.updateButtonIcon(SettingKeyboard.Button_Cycle_Nature, gamepadType, this.natureIconElement, this.natureLabel); + this.updateButtonIcon( + SettingKeyboard.Button_Cycle_Nature, + gamepadType, + this.natureIconElement, + this.natureLabel, + ); } if (this.canCycleTera) { this.updateButtonIcon(SettingKeyboard.Button_Cycle_Tera, gamepadType, this.teraIconElement, this.teraLabel); @@ -2515,9 +2948,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { // if filter mode is inactivated and gamepadType is not undefined, update the button icons if (!this.filterMode) { - this.updateFilterButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.goFilterIconElement, this.goFilterLabel); + this.updateFilterButtonIcon( + SettingKeyboard.Button_Stats, + gamepadType, + this.goFilterIconElement, + this.goFilterLabel, + ); } - } getValueLimit(): number { @@ -2554,16 +2991,33 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (species.forms?.length > 0) { for (let i = 0; i < species.forms.length; i++) { /* Here we are making a fake form index dex props for challenges - * Since some pokemon rely on forms to be valid (i.e. blaze tauros for fire challenges), we make a fake form and dex props to use in the challenge - */ + * Since some pokemon rely on forms to be valid (i.e. blaze tauros for fire challenges), we make a fake form and dex props to use in the challenge + */ const tempFormProps = BigInt(Math.pow(2, i)) * DexAttr.DEFAULT_FORM; const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, container.species, isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(species, tempFormProps), true); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + container.species, + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps(species, tempFormProps), + true, + ); allFormsValid = allFormsValid || isValidForChallenge.value; } } else { const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, container.species, isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(species, globalScene.gameData.getSpeciesDefaultDexAttr(container.species, false, true)), true); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + container.species, + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps( + species, + globalScene.gameData.getSpeciesDefaultDexAttr(container.species, false, true), + ), + true, + ); allFormsValid = isValidForChallenge.value; } if (allFormsValid) { @@ -2584,7 +3038,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const currentDexAttr = this.getCurrentDexProps(currentFilteredContainer.species.speciesId); const props = globalScene.gameData.getSpeciesDexAttrProps(currentFilteredContainer.species, currentDexAttr); - starterSprite.setTexture(currentFilteredContainer.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), currentFilteredContainer.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant)); + starterSprite.setTexture( + currentFilteredContainer.species.getIconAtlasKey(props.formIndex, props.shiny, props.variant), + currentFilteredContainer.species.getIconId(props.female!, props.formIndex, props.shiny, props.variant), + ); currentFilteredContainer.checkIconId(props.female, props.formIndex, props.shiny, props.variant); } @@ -2600,10 +3057,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const isStarterProgressable = speciesEggMoves.hasOwnProperty(container.species.speciesId); // Gen filter - const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation); + const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation); // Type filter - const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => container.species.isOfType((type as number) - 1)); + const fitsType = this.filterBar + .getVals(DropDownColumn.TYPES) + .some(type => container.species.isOfType((type as number) - 1)); // Caught / Shiny filter const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY); @@ -2615,13 +3074,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsCaught = this.filterBar.getVals(DropDownColumn.CAUGHT).some(caught => { if (caught === "SHINY3") { return isVariant3Caught; - } else if (caught === "SHINY2") { + } + if (caught === "SHINY2") { return isVariant2Caught && !isVariant3Caught; - } else if (caught === "SHINY") { + } + if (caught === "SHINY") { return isVariant1Caught && !isVariant2Caught && !isVariant3Caught; - } else if (caught === "NORMAL") { + } + if (caught === "NORMAL") { return isNonShinyCaught && !isVariant1Caught && !isVariant2Caught && !isVariant3Caught; - } else if (caught === "UNCAUGHT") { + } + if (caught === "UNCAUGHT") { return isUncaught; } }); @@ -2632,11 +3095,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsPassive = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => { if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.ON) { return isPassiveUnlocked; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.EXCLUDE) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.EXCLUDE) { return isStarterProgressable && !isPassiveUnlocked; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.UNLOCKABLE) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.UNLOCKABLE) { return isPassiveUnlockable; - } else if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.OFF) { + } + if (unlocks.val === "PASSIVE" && unlocks.state === DropDownState.OFF) { return true; } }); @@ -2648,15 +3114,20 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsCostReduction = this.filterBar.getVals(DropDownColumn.UNLOCKS).some(unlocks => { if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ON) { return isCostReducedByOne || isCostReducedByTwo; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ONE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.ONE) { return isCostReducedByOne; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.TWO) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.TWO) { return isCostReducedByTwo; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.EXCLUDE) { return isStarterProgressable && !(isCostReducedByOne || isCostReducedByTwo); - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.UNLOCKABLE) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.UNLOCKABLE) { return isCostReductionUnlockable; - } else if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) { + } + if (unlocks.val === "COST_REDUCTION" && unlocks.state === DropDownState.OFF) { return true; } }); @@ -2682,22 +3153,28 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsWin = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "WIN" && misc.state === DropDownState.ON) { return hasWon; - } else if (misc.val === "WIN" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "WIN" && misc.state === DropDownState.EXCLUDE) { return hasNotWon || isUndefined; - } else if (misc.val === "WIN" && misc.state === DropDownState.OFF) { + } + if (misc.val === "WIN" && misc.state === DropDownState.OFF) { return true; } }); // HA Filter - const speciesHasHiddenAbility = container.species.abilityHidden !== container.species.ability1 && container.species.abilityHidden !== Abilities.NONE; + const speciesHasHiddenAbility = + container.species.abilityHidden !== container.species.ability1 && + container.species.abilityHidden !== Abilities.NONE; const hasHA = starterData.abilityAttr & AbilityAttr.ABILITY_HIDDEN; const fitsHA = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.ON) { return hasHA; - } else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.EXCLUDE) { return speciesHasHiddenAbility && !hasHA; - } else if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.OFF) { + } + if (misc.val === "HIDDEN_ABILITY" && misc.state === DropDownState.OFF) { return true; } }); @@ -2707,9 +3184,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsEgg = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "EGG" && misc.state === DropDownState.ON) { return isEggPurchasable; - } else if (misc.val === "EGG" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "EGG" && misc.state === DropDownState.EXCLUDE) { return isStarterProgressable && !isEggPurchasable; - } else if (misc.val === "EGG" && misc.state === DropDownState.OFF) { + } + if (misc.val === "EGG" && misc.state === DropDownState.OFF) { return true; } }); @@ -2718,14 +3197,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const fitsPokerus = this.filterBar.getVals(DropDownColumn.MISC).some(misc => { if (misc.val === "POKERUS" && misc.state === DropDownState.ON) { return this.pokerusSpecies.includes(container.species); - } else if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) { + } + if (misc.val === "POKERUS" && misc.state === DropDownState.EXCLUDE) { return !this.pokerusSpecies.includes(container.species); - } else if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) { + } + if (misc.val === "POKERUS" && misc.state === DropDownState.OFF) { return true; } }); - if (fitsGen && fitsType && fitsCaught && fitsPassive && fitsCostReduction && fitsFavorite && fitsWin && fitsHA && fitsEgg && fitsPokerus) { + if ( + fitsGen && + fitsType && + fitsCaught && + fitsPassive && + fitsCostReduction && + fitsFavorite && + fitsWin && + fitsHA && + fitsEgg && + fitsPokerus + ) { this.filteredStarterContainers.push(container); } }); @@ -2737,26 +3229,38 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const sort = this.filterBar.getVals(DropDownColumn.SORT)[0]; this.filteredStarterContainers.sort((a, b) => { switch (sort.val) { - default: - break; case SortCriteria.NUMBER: return (a.species.speciesId - b.species.speciesId) * -sort.dir; case SortCriteria.COST: return (a.cost - b.cost) * -sort.dir; - case SortCriteria.CANDY: + case SortCriteria.CANDY: { const candyCountA = globalScene.gameData.starterData[a.species.speciesId].candyCount; const candyCountB = globalScene.gameData.starterData[b.species.speciesId].candyCount; return (candyCountA - candyCountB) * -sort.dir; - case SortCriteria.IV: - const avgIVsA = globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[a.species.speciesId].ivs.length; - const avgIVsB = globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / globalScene.gameData.dexData[b.species.speciesId].ivs.length; + } + case SortCriteria.IV: { + const avgIVsA = + globalScene.gameData.dexData[a.species.speciesId].ivs.reduce((a, b) => a + b, 0) / + globalScene.gameData.dexData[a.species.speciesId].ivs.length; + const avgIVsB = + globalScene.gameData.dexData[b.species.speciesId].ivs.reduce((a, b) => a + b, 0) / + globalScene.gameData.dexData[b.species.speciesId].ivs.length; return (avgIVsA - avgIVsB) * -sort.dir; + } case SortCriteria.NAME: return a.species.name.localeCompare(b.species.name) * -sort.dir; case SortCriteria.CAUGHT: - return (globalScene.gameData.dexData[a.species.speciesId].caughtCount - globalScene.gameData.dexData[b.species.speciesId].caughtCount) * -sort.dir; + return ( + (globalScene.gameData.dexData[a.species.speciesId].caughtCount - + globalScene.gameData.dexData[b.species.speciesId].caughtCount) * + -sort.dir + ); case SortCriteria.HATCHED: - return (globalScene.gameData.dexData[a.species.speciesId].hatchedCount - globalScene.gameData.dexData[b.species.speciesId].hatchedCount) * -sort.dir; + return ( + (globalScene.gameData.dexData[a.species.speciesId].hatchedCount - + globalScene.gameData.dexData[b.species.speciesId].hatchedCount) * + -sort.dir + ); } return 0; }); @@ -2773,7 +3277,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const maxColumns = 9; const maxRows = 9; const onScreenFirstIndex = this.scrollCursor * maxColumns; - const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + maxRows * maxColumns - 1); + const onScreenLastIndex = Math.min( + this.filteredStarterContainers.length - 1, + onScreenFirstIndex + maxRows * maxColumns - 1, + ); this.starterSelectScrollBar.setScrollCursor(this.scrollCursor); @@ -2795,57 +3302,65 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(false); } return; - } else { - container.setVisible(true); + } + container.setVisible(true); - if (this.pokerusSpecies.includes(container.species)) { - this.pokerusCursorObjs[pokerusCursorIndex].setPosition(pos.x - 1, pos.y + 1); - this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true); - pokerusCursorIndex++; - } + if (this.pokerusSpecies.includes(container.species)) { + this.pokerusCursorObjs[pokerusCursorIndex].setPosition(pos.x - 1, pos.y + 1); + this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true); + pokerusCursorIndex++; + } - if (this.starterSpecies.includes(container.species)) { - this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setPosition(pos.x - 1, pos.y + 1); - this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(true); - } + if (this.starterSpecies.includes(container.species)) { + this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setPosition(pos.x - 1, pos.y + 1); + this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(true); + } - const speciesId = container.species.speciesId; - this.updateStarterValueLabel(container); + const speciesId = container.species.speciesId; + this.updateStarterValueLabel(container); - container.label.setVisible(true); - const speciesVariants = speciesId && globalScene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY - ? [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => !!(globalScene.gameData.dexData[speciesId].caughtAttr & v)) + container.label.setVisible(true); + const speciesVariants = + speciesId && globalScene.gameData.dexData[speciesId].caughtAttr & DexAttr.SHINY + ? [DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3].filter( + v => !!(globalScene.gameData.dexData[speciesId].caughtAttr & v), + ) : []; - for (let v = 0; v < 3; v++) { - const hasVariant = speciesVariants.length > v; - container.shinyIcons[v].setVisible(hasVariant); - if (hasVariant) { - container.shinyIcons[v].setTint(getVariantTint(speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2)); - } + for (let v = 0; v < 3; v++) { + const hasVariant = speciesVariants.length > v; + container.shinyIcons[v].setVisible(hasVariant); + if (hasVariant) { + container.shinyIcons[v].setTint( + getVariantTint( + speciesVariants[v] === DexAttr.DEFAULT_VARIANT ? 0 : speciesVariants[v] === DexAttr.VARIANT_2 ? 1 : 2, + ), + ); + } + } + + container.starterPassiveBgs.setVisible(!!globalScene.gameData.starterData[speciesId].passiveAttr); + container.hiddenAbilityIcon.setVisible( + !!globalScene.gameData.dexData[speciesId].caughtAttr && + !!(globalScene.gameData.starterData[speciesId].abilityAttr & 4), + ); + container.classicWinIcon.setVisible(globalScene.gameData.starterData[speciesId].classicWinCount > 0); + container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false); + + // 'Candy Icon' mode + if (globalScene.candyUpgradeDisplay === 0) { + if (!starterColors[speciesId]) { + // Default to white if no colors are found + starterColors[speciesId] = ["ffffff", "ffffff"]; } - container.starterPassiveBgs.setVisible(!!globalScene.gameData.starterData[speciesId].passiveAttr); - container.hiddenAbilityIcon.setVisible(!!globalScene.gameData.dexData[speciesId].caughtAttr && !!(globalScene.gameData.starterData[speciesId].abilityAttr & 4)); - container.classicWinIcon.setVisible(globalScene.gameData.starterData[speciesId].classicWinCount > 0); - container.favoriteIcon.setVisible(this.starterPreferences[speciesId]?.favorite ?? false); + // Set the candy colors + container.candyUpgradeIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[speciesId][0]))); + container.candyUpgradeOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[speciesId][1]))); - // 'Candy Icon' mode - if (globalScene.candyUpgradeDisplay === 0) { - - if (!starterColors[speciesId]) { - // Default to white if no colors are found - starterColors[speciesId] = [ "ffffff", "ffffff" ]; - } - - // Set the candy colors - container.candyUpgradeIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[speciesId][0]))); - container.candyUpgradeOverlayIcon.setTint(argbFromRgba(rgbHexToRgba(starterColors[speciesId][1]))); - - this.setUpgradeIcon(container); - } else if (globalScene.candyUpgradeDisplay === 1) { - container.candyUpgradeIcon.setVisible(false); - container.candyUpgradeOverlayIcon.setVisible(false); - } + this.setUpgradeIcon(container); + } else if (globalScene.candyUpgradeDisplay === 1) { + container.candyUpgradeIcon.setVisible(false); + container.candyUpgradeOverlayIcon.setVisible(false); } }); }; @@ -2870,7 +3385,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (species) { const defaultDexAttr = this.getCurrentDexProps(species.speciesId); const defaultProps = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); - const variant = this.starterPreferences[species.speciesId]?.variant ? this.starterPreferences[species.speciesId].variant as Variant : defaultProps.variant; + const variant = this.starterPreferences[species.speciesId]?.variant + ? (this.starterPreferences[species.speciesId].variant as Variant) + : defaultProps.variant; const tint = getVariantTint(variant); this.pokemonShinyIcon.setFrame(getVariantIcon(variant)); this.pokemonShinyIcon.setTint(tint); @@ -2937,13 +3454,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonAbilityText.off("pointerover"); this.pokemonPassiveText.off("pointerover"); - const starterAttributes : StarterAttributes | null = species ? { ...this.starterPreferences[species.speciesId] } : null; + const starterAttributes: StarterAttributes | null = species + ? { ...this.starterPreferences[species.speciesId] } + : null; if (starterAttributes?.nature) { // load default nature from stater save data, if set this.natureCursor = starterAttributes.nature; } - if (starterAttributes?.ability && !isNaN(starterAttributes.ability)) { + if (starterAttributes?.ability && !Number.isNaN(starterAttributes.ability)) { // load default ability from stater save data, if set this.abilityCursor = starterAttributes.ability; } @@ -3000,7 +3519,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { let growthReadable = toReadableString(GrowthRate[species.growthRate]); const growthAux = growthReadable.replace(" ", "_"); if (i18next.exists("growth:" + growthAux)) { - growthReadable = i18next.t("growth:" + growthAux as any); + growthReadable = i18next.t(("growth:" + growthAux) as any); } this.pokemonGrowthRateText.setText(growthReadable); @@ -3033,11 +3552,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCaughtHatchedContainer.setY(16); this.pokemonShinyIcon.setY(135); this.pokemonShinyIcon.setFrame(getVariantIcon(variant)); - [ - this.pokemonCandyContainer, - this.pokemonHatchedIcon, - this.pokemonHatchedCountText - ].map(c => c.setVisible(false)); + [this.pokemonCandyContainer, this.pokemonHatchedIcon, this.pokemonHatchedCountText].map(c => + c.setVisible(false), + ); this.pokemonFormText.setY(25); } else { this.pokemonCaughtHatchedContainer.setY(25); @@ -3051,7 +3568,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonHatchedCountText.setVisible(true); const { currentFriendship, friendshipCap } = this.getFriendship(this.lastSpecies.speciesId); - const candyCropY = 16 - (16 * (currentFriendship / friendshipCap)); + const candyCropY = 16 - 16 * (currentFriendship / friendshipCap); this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY); this.pokemonCandyContainer.on("pointerover", () => { @@ -3062,10 +3579,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { globalScene.ui.hideTooltip(); this.activeTooltip = undefined; }); - } - // Pause the animation when the species is selected const speciesIndex = this.allSpecies.indexOf(species); const icon = this.starterContainers[speciesIndex].icon; @@ -3093,15 +3608,16 @@ export default class StarterSelectUiHandler extends MessageUiHandler { variant: props.variant, abilityIndex: this.starterAbilityIndexes[starterIndex], natureIndex: this.starterNatures[starterIndex], - teraType: this.starterTeras[starterIndex] + teraType: this.starterTeras[starterIndex], }); } else { const defaultDexAttr = this.getCurrentDexProps(species.speciesId); - const defaultAbilityIndex = starterAttributes?.ability ?? globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); + const defaultAbilityIndex = + starterAttributes?.ability ?? globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); // load default nature from stater save data, if set const defaultNature = starterAttributes?.nature || globalScene.gameData.getSpeciesDefaultNature(species); props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); - if (starterAttributes?.variant && !isNaN(starterAttributes.variant)) { + if (starterAttributes?.variant && !Number.isNaN(starterAttributes.variant)) { if (props.shiny) { props.variant = starterAttributes.variant as Variant; } @@ -3115,7 +3631,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { female: props.female, variant: props.variant, abilityIndex: defaultAbilityIndex, - natureIndex: defaultNature + natureIndex: defaultNature, }); } @@ -3155,7 +3671,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { variant: props.variant, abilityIndex: defaultAbilityIndex, natureIndex: defaultNature, - forSeen: true + forSeen: true, }); this.pokemonSprite.setTint(0x808080); } @@ -3178,13 +3694,14 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonFormText.setVisible(false); this.teraIcon.setVisible(false); - this.setSpeciesDetails(species!, { // TODO: is this bang correct? + this.setSpeciesDetails(species!, { + // TODO: is this bang correct? shiny: false, formIndex: 0, female: false, variant: 0, abilityIndex: 0, - natureIndex: 0 + natureIndex: 0, }); this.pokemonSprite.clearTint(); } @@ -3194,16 +3711,21 @@ export default class StarterSelectUiHandler extends MessageUiHandler { let { shiny, formIndex, female, variant, abilityIndex, natureIndex, teraType } = options; const forSeen: boolean = options.forSeen ?? false; const oldProps = species ? globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor) : null; - const oldAbilityIndex = this.abilityCursor > -1 ? this.abilityCursor : globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); - const oldNatureIndex = this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species); + const oldAbilityIndex = + this.abilityCursor > -1 ? this.abilityCursor : globalScene.gameData.getStarterSpeciesDefaultAbilityIndex(species); + const oldNatureIndex = + this.natureCursor > -1 ? this.natureCursor : globalScene.gameData.getSpeciesDefaultNature(species); this.dexAttrCursor = 0n; this.abilityCursor = -1; this.natureCursor = -1; this.teraCursor = PokemonType.UNKNOWN; // We will only update the sprite if there is a change to form, shiny/variant // or gender for species with gender sprite differences - const shouldUpdateSprite = (species?.genderDiffs && !isNullOrUndefined(female)) - || !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant); + const shouldUpdateSprite = + (species?.genderDiffs && !isNullOrUndefined(female)) || + !isNullOrUndefined(formIndex) || + !isNullOrUndefined(shiny) || + !isNullOrUndefined(variant); if (this.activeTooltip === "CANDY") { if (this.lastSpecies && this.pokemonCandyContainer.visible) { @@ -3223,14 +3745,24 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } if (species) { - this.dexAttrCursor |= (shiny !== undefined ? !shiny : !(shiny = oldProps?.shiny)) ? DexAttr.NON_SHINY : DexAttr.SHINY; - this.dexAttrCursor |= (female !== undefined ? !female : !(female = oldProps?.female)) ? DexAttr.MALE : DexAttr.FEMALE; - this.dexAttrCursor |= (variant !== undefined ? !variant : !(variant = oldProps?.variant)) ? DexAttr.DEFAULT_VARIANT : variant === 1 ? DexAttr.VARIANT_2 : DexAttr.VARIANT_3; - this.dexAttrCursor |= globalScene.gameData.getFormAttr(formIndex !== undefined ? formIndex : (formIndex = oldProps!.formIndex)); // TODO: is this bang correct? + this.dexAttrCursor |= (shiny !== undefined ? !shiny : !(shiny = oldProps?.shiny)) + ? DexAttr.NON_SHINY + : DexAttr.SHINY; + this.dexAttrCursor |= (female !== undefined ? !female : !(female = oldProps?.female)) + ? DexAttr.MALE + : DexAttr.FEMALE; + this.dexAttrCursor |= (variant !== undefined ? !variant : !(variant = oldProps?.variant)) + ? DexAttr.DEFAULT_VARIANT + : variant === 1 + ? DexAttr.VARIANT_2 + : DexAttr.VARIANT_3; + this.dexAttrCursor |= globalScene.gameData.getFormAttr( + formIndex !== undefined ? formIndex : (formIndex = oldProps!.formIndex), + ); // TODO: is this bang correct? this.abilityCursor = abilityIndex !== undefined ? abilityIndex : (abilityIndex = oldAbilityIndex); this.natureCursor = natureIndex !== undefined ? natureIndex : (natureIndex = oldNatureIndex); this.teraCursor = !Utils.isNullOrUndefined(teraType) ? teraType : (teraType = species.type1); - const [ isInParty, partyIndex ]: [boolean, number] = this.isInParty(species); // we use this to firstly check if the pokemon is in the party, and if so, to get the party index in order to update the icon image + const [isInParty, partyIndex]: [boolean, number] = this.isInParty(species); // we use this to firstly check if the pokemon is in the party, and if so, to get the party index in order to update the icon image if (isInParty) { this.updatePartyIcon(species, partyIndex); } @@ -3284,7 +3816,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default? this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false)); - this.pokemonNumberText.setShadowColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true)); + this.pokemonNumberText.setShadowColor( + this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true), + ); if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) { const starterIndex = this.starterSpecies.indexOf(species); @@ -3300,7 +3834,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.assetLoadCancelled = assetLoadCancelled; if (shouldUpdateSprite) { - species.loadAssets(female!, formIndex, shiny, variant, true).then(() => { // TODO: is this bang correct? + species.loadAssets(female!, formIndex, shiny, variant, true).then(() => { + // TODO: is this bang correct? if (assetLoadCancelled.value) { return; } @@ -3317,18 +3852,32 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), !!this.starterSpecies.length); - const currentFilteredContainer = this.filteredStarterContainers.find(p => p.species.speciesId === species.speciesId); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + species, + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), + !!this.starterSpecies.length, + ); + const currentFilteredContainer = this.filteredStarterContainers.find( + p => p.species.speciesId === species.speciesId, + ); if (currentFilteredContainer) { const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite; - starterSprite.setTexture(species.getIconAtlasKey(formIndex, shiny, variant), species.getIconId(female!, formIndex, shiny, variant)); + starterSprite.setTexture( + species.getIconAtlasKey(formIndex, shiny, variant), + species.getIconId(female!, formIndex, shiny, variant), + ); currentFilteredContainer.checkIconId(female, formIndex, shiny, variant); } const isNonShinyCaught = !!(caughtAttr & DexAttr.NON_SHINY); const isShinyCaught = !!(caughtAttr & DexAttr.SHINY); - const caughtVariants = [ DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3 ].filter(v => caughtAttr & v); + const caughtVariants = [DexAttr.DEFAULT_VARIANT, DexAttr.VARIANT_2, DexAttr.VARIANT_3].filter( + v => caughtAttr & v, + ); this.canCycleShiny = (isNonShinyCaught && isShinyCaught) || (isShinyCaught && caughtVariants.length > 1); const isMaleCaught = !!(caughtAttr & DexAttr.MALE); @@ -3348,12 +3897,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { hasAbility2 = 0; } - this.canCycleAbility = [ hasAbility1, hasAbility2, hasHiddenAbility ].filter(a => a).length > 1; + this.canCycleAbility = [hasAbility1, hasAbility2, hasHiddenAbility].filter(a => a).length > 1; - this.canCycleForm = species.forms.filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey)) - .map((_, f) => dexEntry.caughtAttr & globalScene.gameData.getFormAttr(f)).filter(f => f).length > 1; + this.canCycleForm = + species.forms + .filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey)) + .map((_, f) => dexEntry.caughtAttr & globalScene.gameData.getFormAttr(f)) + .filter(f => f).length > 1; this.canCycleNature = globalScene.gameData.getNaturesForAttr(dexEntry.natureAttr).length > 1; - this.canCycleTera = !this.statsMode && globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && !Utils.isNullOrUndefined(getPokemonSpeciesForm(species.speciesId, formIndex ?? 0).type2); + this.canCycleTera = + !this.statsMode && + globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && + !Utils.isNullOrUndefined(getPokemonSpeciesForm(species.speciesId, formIndex ?? 0).type2); } if (dexEntry.caughtAttr && species.malePercent !== null) { @@ -3376,7 +3931,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const isHidden = abilityIndex === (this.lastSpecies.ability2 ? 2 : 1); this.pokemonAbilityText.setColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD)); - this.pokemonAbilityText.setShadowColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true)); + this.pokemonAbilityText.setShadowColor( + this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true), + ); const passiveAttr = globalScene.gameData.starterData[species.speciesId].passiveAttr; const passiveAbility = allAbilities[this.lastSpecies.getPassiveAbility(formIndex)]; @@ -3429,22 +3986,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const iconPosition = { x: this.pokemonPassiveText.x + this.pokemonPassiveText.displayWidth + 1, - y: this.pokemonPassiveText.y + this.pokemonPassiveText.displayHeight / 2 + y: this.pokemonPassiveText.y + this.pokemonPassiveText.displayHeight / 2, }; this.pokemonPassiveDisabledIcon.setVisible(isUnlocked && !isEnabled); this.pokemonPassiveDisabledIcon.setPosition(iconPosition.x, iconPosition.y); this.pokemonPassiveLockedIcon.setVisible(!isUnlocked); this.pokemonPassiveLockedIcon.setPosition(iconPosition.x, iconPosition.y); - } else if (this.activeTooltip === "PASSIVE") { // No passive and passive tooltip is active > hide it globalScene.ui.hideTooltip(); } - this.pokemonNatureText.setText(getNatureName(natureIndex as unknown as Nature, true, true, false, globalScene.uiTheme)); + this.pokemonNatureText.setText( + getNatureName(natureIndex as unknown as Nature, true, true, false, globalScene.uiTheme), + ); let levelMoves: LevelMoves; - if (pokemonFormLevelMoves.hasOwnProperty(species.speciesId) && formIndex && pokemonFormLevelMoves[species.speciesId].hasOwnProperty(formIndex)) { + if ( + pokemonFormLevelMoves.hasOwnProperty(species.speciesId) && + formIndex && + pokemonFormLevelMoves[species.speciesId].hasOwnProperty(formIndex) + ) { levelMoves = pokemonFormLevelMoves[species.speciesId][formIndex]; } else { levelMoves = pokemonSpeciesLevelMoves[species.speciesId]; @@ -3464,18 +4026,29 @@ export default class StarterSelectUiHandler extends MessageUiHandler { ? speciesMoveData : speciesMoveData[formIndex!] // TODO: is this bang correct? : null; - const availableStarterMoves = this.speciesStarterMoves.concat(speciesEggMoves.hasOwnProperty(species.speciesId) ? speciesEggMoves[species.speciesId].filter((_, em: number) => globalScene.gameData.starterData[species.speciesId].eggMoves & (1 << em)) : []); - this.starterMoveset = (moveData || (this.speciesStarterMoves.slice(0, 4) as StarterMoveset)).filter(m => availableStarterMoves.find(sm => sm === m)) as StarterMoveset; + const availableStarterMoves = this.speciesStarterMoves.concat( + speciesEggMoves.hasOwnProperty(species.speciesId) + ? speciesEggMoves[species.speciesId].filter( + (_: any, em: number) => globalScene.gameData.starterData[species.speciesId].eggMoves & (1 << em), + ) + : [], + ); + this.starterMoveset = (moveData || (this.speciesStarterMoves.slice(0, 4) as StarterMoveset)).filter(m => + availableStarterMoves.find(sm => sm === m), + ) as StarterMoveset; // Consolidate move data if it contains an incompatible move if (this.starterMoveset.length < 4 && this.starterMoveset.length < availableStarterMoves.length) { - this.starterMoveset.push(...availableStarterMoves.filter(sm => this.starterMoveset?.indexOf(sm) === -1).slice(0, 4 - this.starterMoveset.length)); + this.starterMoveset.push( + ...availableStarterMoves + .filter(sm => this.starterMoveset?.indexOf(sm) === -1) + .slice(0, 4 - this.starterMoveset.length), + ); } // Remove duplicate moves - this.starterMoveset = this.starterMoveset.filter( - (move, i) => { - return this.starterMoveset?.indexOf(move) === i; - }) as StarterMoveset; + this.starterMoveset = this.starterMoveset.filter((move, i) => { + return this.starterMoveset?.indexOf(move) === i; + }) as StarterMoveset; const speciesForm = getPokemonSpeciesForm(species.speciesId, formIndex!); // TODO: is the bang correct? const formText = species.getFormNameToDisplay(formIndex); @@ -3484,7 +4057,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.setTypeIcons(speciesForm.type1, speciesForm.type2); this.teraIcon.setFrame(PokemonType[this.teraCursor].toLowerCase()); - this.teraIcon.setVisible(!this.statsMode && globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id)); + this.teraIcon.setVisible( + !this.statsMode && globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id), + ); } else { this.pokemonAbilityText.setText(""); this.pokemonPassiveText.setText(""); @@ -3520,7 +4095,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { for (let em = 0; em < 4; em++) { const eggMove = hasEggMoves ? allMoves[speciesEggMoves[species.speciesId][em]] : null; const eggMoveUnlocked = eggMove && globalScene.gameData.starterData[species.speciesId].eggMoves & (1 << em); - this.pokemonEggMoveBgs[em].setFrame(PokemonType[eggMove ? eggMove.type : PokemonType.UNKNOWN].toString().toLowerCase()); + this.pokemonEggMoveBgs[em].setFrame( + PokemonType[eggMove ? eggMove.type : PokemonType.UNKNOWN].toString().toLowerCase(), + ); this.pokemonEggMoveLabels[em].setText(eggMove && eggMoveUnlocked ? eggMove.name : "???"); } @@ -3633,7 +4210,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } tryUpdateValue(add?: number, addingToParty?: boolean): boolean { - const value = this.starterSpecies.map(s => s.generation).reduce((total: number, _gen: number, i: number) => total += globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); + const value = this.starterSpecies + .map(s => s.generation) + .reduce( + (total: number, _gen: number, i: number) => + (total += globalScene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId)), + 0, + ); const newValue = value + (add || 0); const valueLimit = this.getValueLimit(); const overLimit = newValue > valueLimit; @@ -3643,16 +4226,26 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } this.valueLimitLabel.setText(`${newValueStr}/${valueLimit}`); this.valueLimitLabel.setColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK)); - this.valueLimitLabel.setShadowColor(this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true)); + this.valueLimitLabel.setShadowColor( + this.getTextColor(!overLimit ? TextStyle.TOOLTIP_CONTENT : TextStyle.SUMMARY_PINK, true), + ); if (overLimit) { globalScene.time.delayedCall(fixedInt(500), () => this.tryUpdateValue()); return false; } let isPartyValid: boolean = this.isPartyValid(); // this checks to see if the party is valid - if (addingToParty) { // this does a check to see if the pokemon being added is valid; if so, it will update the isPartyValid boolean + if (addingToParty) { + // this does a check to see if the pokemon being added is valid; if so, it will update the isPartyValid boolean const isNewPokemonValid = new BooleanHolder(true); const species = this.filteredStarterContainers[this.cursor].species; - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isNewPokemonValid, globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), false); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + species, + isNewPokemonValid, + globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), + false, + ); isPartyValid = isPartyValid || isNewPokemonValid.value; } @@ -3678,19 +4271,29 @@ export default class StarterSelectUiHandler extends MessageUiHandler { * we change to can AddParty value to true since the user has enough cost to choose this pokemon and this pokemon registered too. */ const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, this.allSpecies[s], isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(this.allSpecies[s], this.getCurrentDexProps(this.allSpecies[s].speciesId)), isPartyValid); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + this.allSpecies[s], + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps( + this.allSpecies[s], + this.getCurrentDexProps(this.allSpecies[s].speciesId), + ), + isPartyValid, + ); const canBeChosen = remainValue >= speciesStarterValue && isValidForChallenge.value; const isPokemonInParty = this.isInParty(this.allSpecies[s])[0]; // this will get the valud of isDupe from isInParty. This will let us see if the pokemon in question is in our party already so we don't grey out the sprites if they're invalid /* This code does a check to tell whether or not a sprite should be lit up or greyed out. There are 3 ways a pokemon's sprite should be lit up: - * 1) If it's in your party, it's a valid pokemon (i.e. for challenge) and you have enough points to have it - * 2) If it's in your party, it's not valid (i.e. for challenges), and you have enough points to have it - * 3) If it's not in your party, but it's a valid pokemon and you have enough points for it - * Any other time, the sprite should be greyed out. - * For example, if it's in your party, valid, but costs too much, or if it's not in your party and not valid, regardless of cost - */ + * 1) If it's in your party, it's a valid pokemon (i.e. for challenge) and you have enough points to have it + * 2) If it's in your party, it's not valid (i.e. for challenges), and you have enough points to have it + * 3) If it's not in your party, but it's a valid pokemon and you have enough points for it + * Any other time, the sprite should be greyed out. + * For example, if it's in your party, valid, but costs too much, or if it's not in your party and not valid, regardless of cost + */ if (canBeChosen || (isPokemonInParty && remainValue >= speciesStarterValue)) { speciesSprite.setAlpha(1); } else { @@ -3715,24 +4318,31 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.blockInput = false; }; ui.showText(i18next.t("starterSelectUiHandler:confirmExit"), null, () => { - ui.setModeWithoutClear(Mode.CONFIRM, () => { - ui.setMode(Mode.STARTER_SELECT); - globalScene.clearPhaseQueue(); - if (globalScene.gameMode.isChallenge) { - globalScene.pushPhase(new SelectChallengePhase()); - globalScene.pushPhase(new EncounterPhase()); - } else { - globalScene.pushPhase(new TitlePhase()); - } - this.clearText(); - globalScene.getCurrentPhase()?.end(); - }, cancel, null, null, 19); + ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + ui.setMode(Mode.STARTER_SELECT); + globalScene.clearPhaseQueue(); + if (globalScene.gameMode.isChallenge) { + globalScene.pushPhase(new SelectChallengePhase()); + globalScene.pushPhase(new EncounterPhase()); + } else { + globalScene.pushPhase(new TitlePhase()); + } + this.clearText(); + globalScene.getCurrentPhase()?.end(); + }, + cancel, + null, + null, + 19, + ); }); return true; } - tryStart(manualTrigger: boolean = false): boolean { + tryStart(manualTrigger = false): boolean { if (!this.starterSpecies.length) { return false; } @@ -3751,47 +4361,72 @@ export default class StarterSelectUiHandler extends MessageUiHandler { if (canStart) { ui.showText(i18next.t("starterSelectUiHandler:confirmStartTeam"), null, () => { - ui.setModeWithoutClear(Mode.CONFIRM, () => { - const startRun = () => { - globalScene.money = globalScene.gameMode.getStartingMoney(); - ui.setMode(Mode.STARTER_SELECT); - const thisObj = this; - const originalStarterSelectCallback = this.starterSelectCallback; - this.starterSelectCallback = null; - originalStarterSelectCallback && originalStarterSelectCallback(new Array(this.starterSpecies.length).fill(0).map(function (_, i) { - const starterSpecies = thisObj.starterSpecies[i]; - return { - species: starterSpecies, - dexAttr: thisObj.starterAttr[i], - abilityIndex: thisObj.starterAbilityIndexes[i], - passive: !(globalScene.gameData.starterData[starterSpecies.speciesId].passiveAttr ^ (PassiveAttr.ENABLED | PassiveAttr.UNLOCKED)), - nature: thisObj.starterNatures[i] as Nature, - teraType: thisObj.starterTeras[i] as PokemonType, - moveset: thisObj.starterMovesets[i], - pokerus: thisObj.pokerusSpecies.includes(starterSpecies), - nickname: thisObj.starterPreferences[starterSpecies.speciesId]?.nickname, - }; - })); - }; - startRun(); - }, cancel, null, null, 19); + ui.setModeWithoutClear( + Mode.CONFIRM, + () => { + const startRun = () => { + globalScene.money = globalScene.gameMode.getStartingMoney(); + ui.setMode(Mode.STARTER_SELECT); + const thisObj = this; + const originalStarterSelectCallback = this.starterSelectCallback; + this.starterSelectCallback = null; + originalStarterSelectCallback?.( + new Array(this.starterSpecies.length).fill(0).map((_, i) => { + const starterSpecies = thisObj.starterSpecies[i]; + return { + species: starterSpecies, + dexAttr: thisObj.starterAttr[i], + abilityIndex: thisObj.starterAbilityIndexes[i], + passive: !( + globalScene.gameData.starterData[starterSpecies.speciesId].passiveAttr ^ + (PassiveAttr.ENABLED | PassiveAttr.UNLOCKED) + ), + nature: thisObj.starterNatures[i] as Nature, + teraType: thisObj.starterTeras[i] as PokemonType, + moveset: thisObj.starterMovesets[i], + pokerus: thisObj.pokerusSpecies.includes(starterSpecies), + nickname: thisObj.starterPreferences[starterSpecies.speciesId]?.nickname, + }; + }), + ); + }; + startRun(); + }, + cancel, + null, + null, + 19, + ); }); } else { this.tutorialActive = true; - this.showText(i18next.t("starterSelectUiHandler:invalidParty"), undefined, () => this.showText("", 0, () => this.tutorialActive = false), undefined, true); + this.showText( + i18next.t("starterSelectUiHandler:invalidParty"), + undefined, + () => this.showText("", 0, () => (this.tutorialActive = false)), + undefined, + true, + ); } return true; } /* This block checks to see if your party is valid * It checks each pokemon against the challenge - noting that due to monotype challenges it needs to check the pokemon while ignoring their evolutions/form change items - */ + */ isPartyValid(): boolean { let canStart = false; for (let s = 0; s < this.starterSpecies.length; s++) { const isValidForChallenge = new BooleanHolder(true); const species = this.starterSpecies[s]; - Challenge.applyChallenges(globalScene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), false); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + species, + isValidForChallenge, + globalScene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), + false, + ); canStart = canStart || isValidForChallenge.value; } return canStart; @@ -3812,7 +4447,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { * It then checks b) if the caughtAttr for the pokemon is female and NOT male - this means that the ONLY gender we've gotten is female, and we need to add DexAttr.FEMALE to our temp props * If neither of these pass, we add DexAttr.MALE to our temp props */ - if (this.starterPreferences[speciesId]?.female || ((caughtAttr & DexAttr.FEMALE) > 0n && (caughtAttr & DexAttr.MALE) === 0n)) { + if ( + this.starterPreferences[speciesId]?.female || + ((caughtAttr & DexAttr.FEMALE) > 0n && (caughtAttr & DexAttr.MALE) === 0n) + ) { props += DexAttr.FEMALE; } else { props += DexAttr.MALE; @@ -3820,7 +4458,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { /* This part is very similar to above, but instead of for gender, it checks for shiny within starter preferences. * If they're not there, it enables shiny state by default if any shiny was caught */ - if (this.starterPreferences[speciesId]?.shiny || ((caughtAttr & DexAttr.SHINY) > 0n && this.starterPreferences[speciesId]?.shiny !== false)) { + if ( + this.starterPreferences[speciesId]?.shiny || + ((caughtAttr & DexAttr.SHINY) > 0n && this.starterPreferences[speciesId]?.shiny !== false) + ) { props += DexAttr.SHINY; if (this.starterPreferences[speciesId]?.variant !== undefined) { props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.variant)) * DexAttr.DEFAULT_VARIANT; @@ -3840,7 +4481,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { props += DexAttr.NON_SHINY; props += DexAttr.DEFAULT_VARIANT; // we add the default variant here because non shiny versions are listed as default variant } - if (this.starterPreferences[speciesId]?.form) { // this checks for the form of the pokemon + if (this.starterPreferences[speciesId]?.form) { + // this checks for the form of the pokemon props += BigInt(Math.pow(2, this.starterPreferences[speciesId]?.form)) * DexAttr.DEFAULT_FORM; } else { // Get the first unlocked form @@ -3868,9 +4510,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { //@ts-ignore this.statsContainer.updateIvs(null); // TODO: resolve ts-ignore. !?!? this.teraIcon.setVisible(globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id)); - const props = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)); + const props = globalScene.gameData.getSpeciesDexAttrProps( + this.lastSpecies, + this.getCurrentDexProps(this.lastSpecies.speciesId), + ); const formIndex = props.formIndex; - this.canCycleTera = !this.statsMode && globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && !Utils.isNullOrUndefined(getPokemonSpeciesForm(this.lastSpecies.speciesId, formIndex ?? 0).type2); + this.canCycleTera = + !this.statsMode && + globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && + !Utils.isNullOrUndefined(getPokemonSpeciesForm(this.lastSpecies.speciesId, formIndex ?? 0).type2); this.updateInstructions(); } } @@ -3910,7 +4558,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { clear(): void { super.clear(); - StarterPrefs.save(this.starterPreferences); + saveStarterPreferences(this.starterPreferences); this.cursor = -1; this.hideInstructions(); this.activeTooltip = undefined; @@ -3928,9 +4576,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } } - checkIconId(icon: Phaser.GameObjects.Sprite, species: PokemonSpecies, female: boolean, formIndex: number, shiny: boolean, variant: number) { + checkIconId( + icon: Phaser.GameObjects.Sprite, + species: PokemonSpecies, + female: boolean, + formIndex: number, + shiny: boolean, + variant: number, + ) { if (icon.frame.name !== species.getIconId(female, formIndex, shiny, variant)) { - console.log(`${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`); + console.log( + `${species.name}'s icon ${icon.frame.name} does not match getIconId with female: ${female}, formIndex: ${formIndex}, shiny: ${shiny}, variant: ${variant}`, + ); icon.setTexture(species.getIconAtlasKey(formIndex, false, variant)); icon.setFrame(species.getIconId(female, formIndex, false, variant)); } diff --git a/src/ui/stats-container.ts b/src/ui/stats-container.ts index add7eeedbb8..8cc74e64e96 100644 --- a/src/ui/stats-container.ts +++ b/src/ui/stats-container.ts @@ -4,14 +4,20 @@ import { PERMANENT_STATS, getStatKey } from "#app/enums/stat"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; - const ivChartSize = 24; -const ivChartStatCoordMultipliers = [[ 0, -1 ], [ 0.825, -0.5 ], [ 0.825, 0.5 ], [ -0.825, -0.5 ], [ -0.825, 0.5 ], [ 0, 1 ]]; +const ivChartStatCoordMultipliers = [ + [0, -1], + [0.825, -0.5], + [0.825, 0.5], + [-0.825, -0.5], + [-0.825, 0.5], + [0, 1], +]; const speedLabelOffset = -3; const sideLabelOffset = 1; -const ivLabelOffset = [ 0, sideLabelOffset, -sideLabelOffset, sideLabelOffset, -sideLabelOffset, speedLabelOffset ]; -const ivChartLabelyOffset = [ 0, 5, 0, 5, 0, 0 ]; // doing this so attack does not overlap with (+N) -const ivChartStatIndexes = [ 0, 1, 2, 5, 4, 3 ]; // swap special attack and speed +const ivLabelOffset = [0, sideLabelOffset, -sideLabelOffset, sideLabelOffset, -sideLabelOffset, speedLabelOffset]; +const ivChartLabelyOffset = [0, 5, 0, 5, 0, 0]; // doing this so attack does not overlap with (+N) +const ivChartStatIndexes = [0, 1, 2, 5, 4, 3]; // swap special attack and speed const defaultIvChartData = new Array(12).fill(null).map(() => 0); @@ -31,17 +37,33 @@ export class StatsContainer extends Phaser.GameObjects.Container { setup() { this.setName("stats"); - const ivChartBgData = new Array(6).fill(null).map((_, i: number) => [ ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][0], ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][1] ] ).flat(); + const ivChartBgData = new Array(6) + .fill(null) + .flatMap((_, i: number) => [ + ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][0], + ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][1], + ]); const ivChartBg = globalScene.add.polygon(48, 44, ivChartBgData, 0xd8e0f0, 0.625); ivChartBg.setOrigin(0, 0); - const ivChartBorder = globalScene.add.polygon(ivChartBg.x, ivChartBg.y, ivChartBgData) - .setStrokeStyle(1, 0x484050); + const ivChartBorder = globalScene.add.polygon(ivChartBg.x, ivChartBg.y, ivChartBgData).setStrokeStyle(1, 0x484050); ivChartBorder.setOrigin(0, 0); - const ivChartBgLines = [[ 0, -1, 0, 1 ], [ -0.825, -0.5, 0.825, 0.5 ], [ 0.825, -0.5, -0.825, 0.5 ]].map(coords => { - const line = new Phaser.GameObjects.Line(globalScene, ivChartBg.x, ivChartBg.y, ivChartSize * coords[0], ivChartSize * coords[1], ivChartSize * coords[2], ivChartSize * coords[3], 0xffffff) - .setLineWidth(0.5); + const ivChartBgLines = [ + [0, -1, 0, 1], + [-0.825, -0.5, 0.825, 0.5], + [0.825, -0.5, -0.825, 0.5], + ].map(coords => { + const line = new Phaser.GameObjects.Line( + globalScene, + ivChartBg.x, + ivChartBg.y, + ivChartSize * coords[0], + ivChartSize * coords[1], + ivChartSize * coords[2], + ivChartSize * coords[3], + 0xffffff, + ).setLineWidth(0.5); line.setOrigin(0, 0); return line; }); @@ -58,17 +80,24 @@ export class StatsContainer extends Phaser.GameObjects.Container { for (const s of PERMANENT_STATS) { const statLabel = addTextObject( - ivChartBg.x + (ivChartSize) * ivChartStatCoordMultipliers[s][0] * 1.325 + (this.showDiff ? 0 : ivLabelOffset[s]), - ivChartBg.y + (ivChartSize) * ivChartStatCoordMultipliers[s][1] * 1.325 - 4 + (this.showDiff ? 0 : ivChartLabelyOffset[s]), + ivChartBg.x + ivChartSize * ivChartStatCoordMultipliers[s][0] * 1.325 + (this.showDiff ? 0 : ivLabelOffset[s]), + ivChartBg.y + + ivChartSize * ivChartStatCoordMultipliers[s][1] * 1.325 - + 4 + + (this.showDiff ? 0 : ivChartLabelyOffset[s]), i18next.t(getStatKey(s)), - TextStyle.TOOLTIP_CONTENT + TextStyle.TOOLTIP_CONTENT, ); statLabel.setOrigin(0.5); - this.ivStatValueTexts[s] = addBBCodeTextObject(statLabel.x - (this.showDiff ? 0 : ivLabelOffset[s]), statLabel.y + 8, "0", TextStyle.TOOLTIP_CONTENT); + this.ivStatValueTexts[s] = addBBCodeTextObject( + statLabel.x - (this.showDiff ? 0 : ivLabelOffset[s]), + statLabel.y + 8, + "0", + TextStyle.TOOLTIP_CONTENT, + ); this.ivStatValueTexts[s].setOrigin(0.5); - this.add(statLabel); this.add(this.ivStatValueTexts[s]); } @@ -76,7 +105,12 @@ export class StatsContainer extends Phaser.GameObjects.Container { updateIvs(ivs: number[], originalIvs?: number[]): void { if (ivs) { - const ivChartData = new Array(6).fill(null).map((_, i) => [ (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][0], (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][1] ] ).flat(); + const ivChartData = new Array(6) + .fill(null) + .flatMap((_, i) => [ + (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][0], + (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][1], + ]); const lastIvChartData = this.statsIvsCache || defaultIvChartData; const perfectIVColor: string = getTextColor(TextStyle.SUMMARY_GOLD, false, globalScene.uiTheme); this.statsIvsCache = ivChartData.slice(0); @@ -100,12 +134,12 @@ export class StatsContainer extends Phaser.GameObjects.Container { t.setText(`[shadow]${label}[/shadow]`); }); - const newColor = ivs.every(iv => iv === 31) ? parseInt(perfectIVColor.substr(1), 16) : 0x98d8a0; + const newColor = ivs.every(iv => iv === 31) ? Number.parseInt(perfectIVColor.substr(1), 16) : 0x98d8a0; const oldColor = this.ivChart.fillColor; - const interpolateColor = oldColor !== newColor ? [ - Phaser.Display.Color.IntegerToColor(oldColor), - Phaser.Display.Color.IntegerToColor(newColor) - ] : null; + const interpolateColor = + oldColor !== newColor + ? [Phaser.Display.Color.IntegerToColor(oldColor), Phaser.Display.Color.IntegerToColor(newColor)] + : null; globalScene.tweens.addCounter({ from: 0, @@ -114,16 +148,19 @@ export class StatsContainer extends Phaser.GameObjects.Container { ease: "Cubic.easeOut", onUpdate: (tween: Phaser.Tweens.Tween) => { const progress = tween.getValue(); - const interpolatedData = ivChartData.map((v: number, i: number) => v * progress + (lastIvChartData[i] * (1 - progress))); + const interpolatedData = ivChartData.map( + (v: number, i: number) => v * progress + lastIvChartData[i] * (1 - progress), + ); if (interpolateColor) { this.ivChart.setFillStyle( Phaser.Display.Color.ValueToColor( - Phaser.Display.Color.Interpolate.ColorWithColor(interpolateColor[0], interpolateColor[1], 1, progress) + Phaser.Display.Color.Interpolate.ColorWithColor(interpolateColor[0], interpolateColor[1], 1, progress), ).color, - 0.75); + 0.75, + ); } this.ivChart.setTo(interpolatedData); - } + }, }); } else { this.statsIvsCache = defaultIvChartData; diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 465f1e2c8ec..d42572cfef4 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -33,24 +33,24 @@ import { achvs } from "#app/system/achv"; enum Page { PROFILE, STATS, - MOVES + MOVES, } export enum SummaryUiMode { DEFAULT, - LEARN_MOVE + LEARN_MOVE, } /** Holds all objects related to an ability for each iteration */ interface abilityContainer { /** An image displaying the summary label */ - labelImage: Phaser.GameObjects.Image, + labelImage: Phaser.GameObjects.Image; /** The ability object */ - ability: Ability | null, + ability: Ability | null; /** The text object displaying the name of the ability */ - nameText: Phaser.GameObjects.Text | null, + nameText: Phaser.GameObjects.Text | null; /** The text object displaying the description of the ability */ - descriptionText: Phaser.GameObjects.Text | null, + descriptionText: Phaser.GameObjects.Text | null; } export default class SummaryUiHandler extends UiHandler { @@ -133,7 +133,7 @@ export default class SummaryUiHandler extends UiHandler { summaryBg.setOrigin(0, 1); this.summaryContainer.add(summaryBg); - this.tabSprite = globalScene.add.sprite(134, (-summaryBg.displayHeight) + 16, "summary_tabs_1"); + this.tabSprite = globalScene.add.sprite(134, -summaryBg.displayHeight + 16, "summary_tabs_1"); this.tabSprite.setOrigin(1, 1); this.summaryContainer.add(this.tabSprite); @@ -150,7 +150,12 @@ export default class SummaryUiHandler extends UiHandler { this.numberText.setOrigin(0, 1); this.summaryContainer.add(this.numberText); - this.pokemonSprite = globalScene.initPokemonSprite(globalScene.add.sprite(56, -106, "pkmn__sub"), undefined, false, true); + this.pokemonSprite = globalScene.initPokemonSprite( + globalScene.add.sprite(56, -106, "pkmn__sub"), + undefined, + false, + true, + ); this.summaryContainer.add(this.pokemonSprite); this.nameText = addTextObject(6, -54, "", TextStyle.SUMMARY); @@ -191,12 +196,14 @@ export default class SummaryUiHandler extends UiHandler { this.candyShadow = globalScene.add.sprite(13, -140, "candy"); this.candyShadow.setTint(0x000000); - this.candyShadow.setAlpha(0.50); + this.candyShadow.setAlpha(0.5); this.candyShadow.setScale(0.8); this.candyShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 30, 16), Phaser.Geom.Rectangle.Contains); this.summaryContainer.add(this.candyShadow); - this.candyCountText = addTextObject(20, -146, "x0", TextStyle.WINDOW_ALT, { fontSize: "76px" }); + this.candyCountText = addTextObject(20, -146, "x0", TextStyle.WINDOW_ALT, { + fontSize: "76px", + }); this.candyCountText.setOrigin(0, 0); this.summaryContainer.add(this.candyCountText); @@ -210,12 +217,14 @@ export default class SummaryUiHandler extends UiHandler { this.friendshipShadow = globalScene.add.sprite(13, -60, "friendship"); this.friendshipShadow.setTint(0x000000); - this.friendshipShadow.setAlpha(0.50); + this.friendshipShadow.setAlpha(0.5); this.friendshipShadow.setScale(0.8); this.friendshipShadow.setInteractive(new Phaser.Geom.Rectangle(0, 0, 50, 16), Phaser.Geom.Rectangle.Contains); this.summaryContainer.add(this.friendshipShadow); - this.friendshipText = addTextObject(20, -66, "x0", TextStyle.WINDOW_ALT, { fontSize: "76px" }); + this.friendshipText = addTextObject(20, -66, "x0", TextStyle.WINDOW_ALT, { + fontSize: "76px", + }); this.friendshipText.setOrigin(0, 0); this.summaryContainer.add(this.friendshipText); @@ -304,14 +313,14 @@ export default class SummaryUiHandler extends UiHandler { super.show(args); /* args[] information - * args[0] : the Pokemon displayed in the Summary-UI - * args[1] : the summaryUiMode (defaults to 0) - * args[2] : the start page (defaults to Page.PROFILE) - * args[3] : contains the function executed when the user exits out of Summary UI - * args[4] : optional boolean used to determine if the Pokemon is part of the player's party or not (defaults to true, necessary for PR #2921 to display all relevant information) - */ + * args[0] : the Pokemon displayed in the Summary-UI + * args[1] : the summaryUiMode (defaults to 0) + * args[2] : the start page (defaults to Page.PROFILE) + * args[3] : contains the function executed when the user exits out of Summary UI + * args[4] : optional boolean used to determine if the Pokemon is part of the player's party or not (defaults to true, necessary for PR #2921 to display all relevant information) + */ this.pokemon = args[0] as PlayerPokemon; - this.summaryUiMode = args.length > 1 ? args[1] as SummaryUiMode : SummaryUiMode.DEFAULT; + this.summaryUiMode = args.length > 1 ? (args[1] as SummaryUiMode) : SummaryUiMode.DEFAULT; this.playerParty = args[4] ?? true; globalScene.ui.bringToTop(this.summaryContainer); @@ -324,10 +333,11 @@ export default class SummaryUiHandler extends UiHandler { this.candyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0]))); this.candyOverlay.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[1]))); - this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4)); this.numberText.setColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD)); - this.numberText.setShadowColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true)); + this.numberText.setShadowColor( + this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true), + ); const spriteKey = this.pokemon.getSpriteKey(true); try { this.pokemonSprite.play(spriteKey); @@ -340,7 +350,7 @@ export default class SummaryUiHandler extends UiHandler { this.pokemonSprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey()); this.pokemonSprite.setPipelineData("shiny", this.pokemon.shiny); this.pokemonSprite.setPipelineData("variant", this.pokemon.variant); - [ "spriteColors", "fusionSpriteColors" ].map(k => { + ["spriteColors", "fusionSpriteColors"].map(k => { delete this.pokemonSprite.pipelineData[`${k}Base`]; if (this.pokemon?.summonData?.speciesForm) { k += "Base"; @@ -356,11 +366,20 @@ export default class SummaryUiHandler extends UiHandler { this.splicedIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + 2, 3); this.splicedIcon.setVisible(isFusion); if (this.splicedIcon.visible) { - this.splicedIcon.on("pointerover", () => globalScene.ui.showTooltip("", `${this.pokemon?.species.getName(this.pokemon.formIndex)}/${this.pokemon?.fusionSpecies?.getName(this.pokemon?.fusionFormIndex)}`, true)); + this.splicedIcon.on("pointerover", () => + globalScene.ui.showTooltip( + "", + `${this.pokemon?.species.getName(this.pokemon.formIndex)}/${this.pokemon?.fusionSpecies?.getName(this.pokemon?.fusionFormIndex)}`, + true, + ), + ); this.splicedIcon.on("pointerout", () => globalScene.ui.hideTooltip()); } - if (globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0) { + if ( + globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].classicWinCount > 0 && + globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId(true)].classicWinCount > 0 + ) { this.championRibbon.setVisible(true); } else { this.championRibbon.setVisible(false); @@ -372,38 +391,55 @@ export default class SummaryUiHandler extends UiHandler { } const friendshipCap = getStarterValueFriendshipCap(speciesStarterCosts[this.pokemon.species.getRootSpeciesId()]); - const candyCropY = 16 - (16 * (currentFriendship / friendshipCap)); + const candyCropY = 16 - 16 * (currentFriendship / friendshipCap); if (this.candyShadow.visible) { - this.candyShadow.on("pointerover", () => globalScene.ui.showTooltip("", `${currentFriendship}/${friendshipCap}`, true)); + this.candyShadow.on("pointerover", () => + globalScene.ui.showTooltip("", `${currentFriendship}/${friendshipCap}`, true), + ); this.candyShadow.on("pointerout", () => globalScene.ui.hideTooltip()); } - this.candyCountText.setText(`x${globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].candyCount}`); + this.candyCountText.setText( + `x${globalScene.gameData.starterData[this.pokemon.species.getRootSpeciesId()].candyCount}`, + ); this.candyShadow.setCrop(0, 0, 16, candyCropY); if (this.friendshipShadow.visible) { - this.friendshipShadow.on("pointerover", () => globalScene.ui.showTooltip("", `${i18next.t("pokemonSummary:friendship")}`, true)); + this.friendshipShadow.on("pointerover", () => + globalScene.ui.showTooltip("", `${i18next.t("pokemonSummary:friendship")}`, true), + ); this.friendshipShadow.on("pointerout", () => globalScene.ui.hideTooltip()); } this.friendshipText.setText(`${this.pokemon?.friendship || "0"} / 255`); - this.friendshipShadow.setCrop(0, 0, 16, 16 - (16 * ((this.pokemon?.friendship || 0) / 255))); + this.friendshipShadow.setCrop(0, 0, 16, 16 - 16 * ((this.pokemon?.friendship || 0) / 255)); const doubleShiny = isFusion && this.pokemon.shiny && this.pokemon.fusionShiny; const baseVariant = !doubleShiny ? this.pokemon.getVariant() : this.pokemon.variant; - this.shinyIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0) + 1, 3); + this.shinyIcon.setPositionRelative( + this.nameText, + this.nameText.displayWidth + (this.splicedIcon.visible ? this.splicedIcon.displayWidth + 1 : 0) + 1, + 3, + ); this.shinyIcon.setTexture(`shiny_star${doubleShiny ? "_1" : ""}`); this.shinyIcon.setVisible(this.pokemon.isShiny()); this.shinyIcon.setTint(getVariantTint(baseVariant)); if (this.shinyIcon.visible) { - const shinyDescriptor = doubleShiny || baseVariant ? - `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${this.pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : this.pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` - : ""; - this.shinyIcon.on("pointerover", () => globalScene.ui.showTooltip("", `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`, true)); + const shinyDescriptor = + doubleShiny || baseVariant + ? `${baseVariant === 2 ? i18next.t("common:epicShiny") : baseVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}${doubleShiny ? `/${this.pokemon.fusionVariant === 2 ? i18next.t("common:epicShiny") : this.pokemon.fusionVariant === 1 ? i18next.t("common:rareShiny") : i18next.t("common:commonShiny")}` : ""}` + : ""; + this.shinyIcon.on("pointerover", () => + globalScene.ui.showTooltip( + "", + `${i18next.t("common:shinyOnHover")}${shinyDescriptor ? ` (${shinyDescriptor})` : ""}`, + true, + ), + ); this.shinyIcon.on("pointerout", () => globalScene.ui.hideTooltip()); } @@ -420,14 +456,15 @@ export default class SummaryUiHandler extends UiHandler { this.genderText.setShadowColor(getGenderColor(this.pokemon.getGender(true), true)); switch (this.summaryUiMode) { - case SummaryUiMode.DEFAULT: - const page = args.length < 2 ? Page.PROFILE : args[2] as Page; + case SummaryUiMode.DEFAULT: { + const page = args.length < 2 ? Page.PROFILE : (args[2] as Page); this.hideMoveEffect(true); this.setCursor(page); if (args.length > 3) { this.selectCallback = args[3]; } break; + } case SummaryUiMode.LEARN_MOVE: this.newMove = args[2] as Move; this.moveSelectFunction = args[3] as Function; @@ -464,7 +501,7 @@ export default class SummaryUiHandler extends UiHandler { if (button === Button.ACTION) { if (this.pokemon && this.moveCursor < this.pokemon.moveset.length) { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { - this.moveSelectFunction && this.moveSelectFunction(this.moveCursor); + this.moveSelectFunction?.(this.moveCursor); } else { if (this.selectedMoveIndex === -1) { this.selectedMoveIndex = this.moveCursor; @@ -475,7 +512,9 @@ export default class SummaryUiHandler extends UiHandler { this.pokemon.moveset[this.selectedMoveIndex] = this.pokemon.moveset[this.moveCursor]; this.pokemon.moveset[this.moveCursor] = tempMove; - const selectedMoveRow = this.moveRowsContainer.getAt(this.selectedMoveIndex) as Phaser.GameObjects.Container; + const selectedMoveRow = this.moveRowsContainer.getAt( + this.selectedMoveIndex, + ) as Phaser.GameObjects.Container; const switchMoveRow = this.moveRowsContainer.getAt(this.moveCursor) as Phaser.GameObjects.Container; this.moveRowsContainer.moveTo(selectedMoveRow, this.moveCursor); @@ -517,11 +556,10 @@ export default class SummaryUiHandler extends UiHandler { this.destroyBlinkCursor(); success = true; break; - } else { - this.hideMoveSelect(); - success = true; - break; } + this.hideMoveSelect(); + success = true; + break; } } } else { @@ -565,10 +603,11 @@ export default class SummaryUiHandler extends UiHandler { const pages = Utils.getEnumValues(Page); switch (button) { case Button.UP: - case Button.DOWN: + case Button.DOWN: { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { break; - } else if (!fromPartyMode) { + } + if (!fromPartyMode) { break; } const isDown = button === Button.DOWN; @@ -577,9 +616,10 @@ export default class SummaryUiHandler extends UiHandler { if ((isDown && partyMemberIndex < party.length - 1) || (!isDown && partyMemberIndex)) { const page = this.cursor; this.clear(); - this.show([ party[partyMemberIndex + (isDown ? 1 : -1)], this.summaryUiMode, page ]); + this.show([party[partyMemberIndex + (isDown ? 1 : -1)], this.summaryUiMode, page]); } break; + } case Button.LEFT: if (this.cursor) { success = this.setCursor(this.cursor - 1); @@ -606,7 +646,7 @@ export default class SummaryUiHandler extends UiHandler { return success || error; } - setCursor(cursor: number, overrideChanged: boolean = false): boolean { + setCursor(cursor: number, overrideChanged = false): boolean { let changed: boolean = overrideChanged || this.moveCursor !== cursor; if (this.moveSelect) { @@ -639,7 +679,7 @@ export default class SummaryUiHandler extends UiHandler { loop: -1, hold: Utils.fixedInt(2000), duration: Utils.fixedInt((moveDescriptionLineCount - 3) * 2000), - y: `-=${14.83 * (moveDescriptionLineCount - 3)}` + y: `-=${14.83 * (moveDescriptionLineCount - 3)}`, }); } @@ -666,7 +706,7 @@ export default class SummaryUiHandler extends UiHandler { } this.moveCursorObj.setVisible(true); }); - } + }, }); if (this.selectedMoveIndex > -1) { if (!this.selectedMoveCursorObj) { @@ -713,7 +753,7 @@ export default class SummaryUiHandler extends UiHandler { } this.summaryPageTransitionContainer.setVisible(false); this.transitioning = false; - } + }, }); this.summaryPageTransitionContainer.setVisible(true); } else { @@ -739,7 +779,7 @@ export default class SummaryUiHandler extends UiHandler { }); pageContainer.removeBetween(1, undefined, true); } - const pageBg = (pageContainer.getAt(0) as Phaser.GameObjects.Sprite); + const pageBg = pageContainer.getAt(0) as Phaser.GameObjects.Sprite; pageBg.setTexture(this.getPageKey(page)); if (this.descriptionScrollTween) { @@ -748,16 +788,26 @@ export default class SummaryUiHandler extends UiHandler { } switch (page) { - case Page.PROFILE: + case Page.PROFILE: { const profileContainer = globalScene.add.container(0, -pageBg.height); pageContainer.add(profileContainer); // TODO: should add field for original trainer name to Pokemon object, to support gift/traded Pokemon from MEs - const trainerText = addBBCodeTextObject(7, 12, `${i18next.t("pokemonSummary:ot")}/${getBBCodeFrag(loggedInUser?.username || i18next.t("pokemonSummary:unknown"), globalScene.gameData.gender === PlayerGender.FEMALE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE)}`, TextStyle.SUMMARY_ALT); + const trainerText = addBBCodeTextObject( + 7, + 12, + `${i18next.t("pokemonSummary:ot")}/${getBBCodeFrag(loggedInUser?.username || i18next.t("pokemonSummary:unknown"), globalScene.gameData.gender === PlayerGender.FEMALE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE)}`, + TextStyle.SUMMARY_ALT, + ); trainerText.setOrigin(0, 0); profileContainer.add(trainerText); - const trainerIdText = addTextObject(141, 12, `${i18next.t("pokemonSummary:idNo")}${globalScene.gameData.trainerId.toString()}`, TextStyle.SUMMARY_ALT); + const trainerIdText = addTextObject( + 141, + 12, + `${i18next.t("pokemonSummary:idNo")}${globalScene.gameData.trainerId.toString()}`, + TextStyle.SUMMARY_ALT, + ); trainerIdText.setOrigin(0, 0); profileContainer.add(trainerIdText); @@ -765,7 +815,7 @@ export default class SummaryUiHandler extends UiHandler { typeLabel.setOrigin(0, 0); profileContainer.add(typeLabel); - const getTypeIcon = (index: number, type: PokemonType, tera: boolean = false) => { + const getTypeIcon = (index: number, type: PokemonType, tera = false) => { const xCoord = typeLabel.width * typeLabel.scale + 9 + 34 * index; const typeIcon = !tera ? globalScene.add.sprite(xCoord, 42, Utils.getLocalizedSpriteKey("types"), PokemonType[type].toLowerCase()) @@ -790,13 +840,21 @@ export default class SummaryUiHandler extends UiHandler { luckLabelText.setOrigin(0, 0); profileContainer.add(luckLabelText); - const luckText = addTextObject(141 + luckLabelText.displayWidth + 2, 28, this.pokemon.getLuck().toString(), TextStyle.SUMMARY); + const luckText = addTextObject( + 141 + luckLabelText.displayWidth + 2, + 28, + this.pokemon.getLuck().toString(), + TextStyle.SUMMARY, + ); luckText.setOrigin(0, 0); - luckText.setTint(getVariantTint((Math.min(this.pokemon.getLuck() - 1, 2)) as Variant)); + luckText.setTint(getVariantTint(Math.min(this.pokemon.getLuck() - 1, 2) as Variant)); profileContainer.add(luckText); } - if (globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && !Utils.isNullOrUndefined(this.pokemon)) { + if ( + globalScene.gameData.achvUnlocks.hasOwnProperty(achvs.TERASTALLIZE.id) && + !Utils.isNullOrUndefined(this.pokemon) + ) { const teraIcon = globalScene.add.sprite(123, 26, "button_tera"); teraIcon.setName("terrastallize-icon"); teraIcon.setFrame(PokemonType[this.pokemon.getTeraType()].toLowerCase()); @@ -807,20 +865,26 @@ export default class SummaryUiHandler extends UiHandler { labelImage: globalScene.add.image(0, 0, "summary_profile_ability"), ability: this.pokemon?.getAbility(true)!, // TODO: is this bang correct? nameText: null, - descriptionText: null }; + descriptionText: null, + }; - const allAbilityInfo = [ this.abilityContainer ]; // Creates an array to iterate through + const allAbilityInfo = [this.abilityContainer]; // Creates an array to iterate through // Only add to the array and set up displaying a passive if it's unlocked if (this.pokemon?.hasPassive()) { this.passiveContainer = { labelImage: globalScene.add.image(0, 0, "summary_profile_passive"), ability: this.pokemon.getPassiveAbility(), nameText: null, - descriptionText: null }; + descriptionText: null, + }; allAbilityInfo.push(this.passiveContainer); // Sets up the pixel button prompt image - this.abilityPrompt = globalScene.add.image(0, 0, !globalScene.inputController?.gamepadSupport ? "summary_profile_prompt_z" : "summary_profile_prompt_a"); + this.abilityPrompt = globalScene.add.image( + 0, + 0, + !globalScene.inputController?.gamepadSupport ? "summary_profile_prompt_z" : "summary_profile_prompt_a", + ); this.abilityPrompt.setPosition(8, 43); this.abilityPrompt.setVisible(true); this.abilityPrompt.setOrigin(0, 0); @@ -837,14 +901,16 @@ export default class SummaryUiHandler extends UiHandler { abilityInfo.nameText.setOrigin(0, 1); profileContainer.add(abilityInfo.nameText); - abilityInfo.descriptionText = addTextObject(7, 69, abilityInfo.ability?.description!, TextStyle.WINDOW_ALT, { wordWrap: { width: 1224 }}); // TODO: is this bang correct? + abilityInfo.descriptionText = addTextObject(7, 69, abilityInfo.ability?.description!, TextStyle.WINDOW_ALT, { + wordWrap: { width: 1224 }, + }); // TODO: is this bang correct? abilityInfo.descriptionText.setOrigin(0, 0); profileContainer.add(abilityInfo.descriptionText); // Sets up the mask that hides the description text to give an illusion of scrolling const descriptionTextMaskRect = globalScene.make.graphics({}); descriptionTextMaskRect.setScale(6); - descriptionTextMaskRect.fillStyle(0xFFFFFF); + descriptionTextMaskRect.fillStyle(0xffffff); descriptionTextMaskRect.beginPath(); descriptionTextMaskRect.fillRect(110, 90.5, 206, 31); @@ -863,7 +929,7 @@ export default class SummaryUiHandler extends UiHandler { loop: -1, hold: Utils.fixedInt(2000), duration: Utils.fixedInt((abilityDescriptionLineCount - 2) * 2000), - y: `-=${14.83 * (abilityDescriptionLineCount - 2)}` + y: `-=${14.83 * (abilityDescriptionLineCount - 2)}`, }); } }); @@ -877,19 +943,23 @@ export default class SummaryUiHandler extends UiHandler { const nature = `${getBBCodeFrag(Utils.toReadableString(getNatureName(this.pokemon?.getNature()!)), TextStyle.SUMMARY_RED)}${closeFragment}`; // TODO: is this bang correct? const memoString = i18next.t("pokemonSummary:memoString", { - metFragment: i18next.t(`pokemonSummary:metFragment.${this.pokemon?.metBiome === -1 ? "apparently" : "normal"}`, { - biome: `${getBBCodeFrag(getBiomeName(this.pokemon?.metBiome!), TextStyle.SUMMARY_RED)}${closeFragment}`, // TODO: is this bang correct? - level: `${getBBCodeFrag(this.pokemon?.metLevel.toString()!, TextStyle.SUMMARY_RED)}${closeFragment}`, // TODO: is this bang correct? - wave: `${getBBCodeFrag((this.pokemon?.metWave ? this.pokemon.metWave.toString()! : i18next.t("pokemonSummary:unknownTrainer")), TextStyle.SUMMARY_RED)}${closeFragment}`, - }), - natureFragment: i18next.t(`pokemonSummary:natureFragment.${rawNature}`, { nature: nature }) + metFragment: i18next.t( + `pokemonSummary:metFragment.${this.pokemon?.metBiome === -1 ? "apparently" : "normal"}`, + { + biome: `${getBBCodeFrag(getBiomeName(this.pokemon?.metBiome!), TextStyle.SUMMARY_RED)}${closeFragment}`, // TODO: is this bang correct? + level: `${getBBCodeFrag(this.pokemon?.metLevel.toString()!, TextStyle.SUMMARY_RED)}${closeFragment}`, // TODO: is this bang correct? + wave: `${getBBCodeFrag(this.pokemon?.metWave ? this.pokemon.metWave.toString()! : i18next.t("pokemonSummary:unknownTrainer"), TextStyle.SUMMARY_RED)}${closeFragment}`, + }, + ), + natureFragment: i18next.t(`pokemonSummary:natureFragment.${rawNature}`, { nature: nature }), }); const memoText = addBBCodeTextObject(7, 113, String(memoString), TextStyle.WINDOW_ALT); memoText.setOrigin(0, 0); profileContainer.add(memoText); break; - case Page.STATS: + } + case Page.STATS: { this.statsContainer = globalScene.add.container(0, -pageBg.height); pageContainer.add(this.statsContainer); this.permStatsContainer = globalScene.add.container(27, 56); @@ -905,17 +975,32 @@ export default class SummaryUiHandler extends UiHandler { const natureStatMultiplier = getNatureStatMultiplier(this.pokemon?.getNature()!, s); // TODO: is this bang correct? - const statLabel = addTextObject(115 * colIndex + (colIndex === 1 ? 5 : 0), 16 * rowIndex, statName, natureStatMultiplier === 1 ? TextStyle.SUMMARY : natureStatMultiplier > 1 ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY_BLUE); - const ivLabel = addTextObject(115 * colIndex + (colIndex === 1 ? 5 : 0), 16 * rowIndex, statName, this.pokemon?.ivs[stat] === 31 ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY); + const statLabel = addTextObject( + 115 * colIndex + (colIndex === 1 ? 5 : 0), + 16 * rowIndex, + statName, + natureStatMultiplier === 1 + ? TextStyle.SUMMARY + : natureStatMultiplier > 1 + ? TextStyle.SUMMARY_PINK + : TextStyle.SUMMARY_BLUE, + ); + const ivLabel = addTextObject( + 115 * colIndex + (colIndex === 1 ? 5 : 0), + 16 * rowIndex, + statName, + this.pokemon?.ivs[stat] === 31 ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, + ); statLabel.setOrigin(0.5, 0); ivLabel.setOrigin(0.5, 0); this.permStatsContainer.add(statLabel); this.ivContainer.add(ivLabel); - const statValueText = stat !== Stat.HP - ? Utils.formatStat(this.pokemon?.getStat(stat)!) // TODO: is this bang correct? - : `${Utils.formatStat(this.pokemon?.hp!, true)}/${Utils.formatStat(this.pokemon?.getMaxHp()!, true)}`; // TODO: are those bangs correct? + const statValueText = + stat !== Stat.HP + ? Utils.formatStat(this.pokemon?.getStat(stat)!) // TODO: is this bang correct? + : `${Utils.formatStat(this.pokemon?.hp!, true)}/${Utils.formatStat(this.pokemon?.getMaxHp()!, true)}`; // TODO: are those bangs correct? const ivText = `${this.pokemon?.ivs[stat]}/31`; const statValue = addTextObject(93 + 88 * colIndex, 16 * rowIndex, statValueText, TextStyle.WINDOW_ALT); @@ -927,9 +1012,12 @@ export default class SummaryUiHandler extends UiHandler { }); this.ivContainer.setVisible(false); - const itemModifiers = (globalScene.findModifiers(m => m instanceof PokemonHeldItemModifier - && m.pokemonId === this.pokemon?.id, this.playerParty) as PokemonHeldItemModifier[]) - .sort(modifierSortFunc); + const itemModifiers = ( + globalScene.findModifiers( + m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.pokemon?.id, + this.playerParty, + ) as PokemonHeldItemModifier[] + ).sort(modifierSortFunc); itemModifiers.forEach((item, i) => { const icon = item.getIcon(true); @@ -961,9 +1049,8 @@ export default class SummaryUiHandler extends UiHandler { expText.setOrigin(1, 0); this.statsContainer.add(expText); - const nextLvExp = pkmLvl < globalScene.getMaxExpLevel() - ? getLevelTotalExp(pkmLvl + 1, pkmSpeciesGrowthRate) - pkmExp - : 0; + const nextLvExp = + pkmLvl < globalScene.getMaxExpLevel() ? getLevelTotalExp(pkmLvl + 1, pkmSpeciesGrowthRate) - pkmExp : 0; const nextLvExpText = addTextObject(208, 128, nextLvExp.toString(), TextStyle.WINDOW_ALT); nextLvExpText.setOrigin(1, 0); this.statsContainer.add(nextLvExpText); @@ -974,20 +1061,25 @@ export default class SummaryUiHandler extends UiHandler { const expMaskRect = globalScene.make.graphics({}); expMaskRect.setScale(6); - expMaskRect.fillStyle(0xFFFFFF); + expMaskRect.fillStyle(0xffffff); expMaskRect.beginPath(); expMaskRect.fillRect(140 + pageContainer.x, 145 + pageContainer.y + 21, Math.floor(expRatio * 64), 3); const expMask = expMaskRect.createGeometryMask(); expOverlay.setMask(expMask); - this.abilityPrompt = globalScene.add.image(0, 0, !globalScene.inputController?.gamepadSupport ? "summary_profile_prompt_z" : "summary_profile_prompt_a"); + this.abilityPrompt = globalScene.add.image( + 0, + 0, + !globalScene.inputController?.gamepadSupport ? "summary_profile_prompt_z" : "summary_profile_prompt_a", + ); this.abilityPrompt.setPosition(8, 47); this.abilityPrompt.setVisible(true); this.abilityPrompt.setOrigin(0, 0); this.statsContainer.add(this.abilityPrompt); break; - case Page.MOVES: + } + case Page.MOVES: { this.movesContainer = globalScene.add.container(5, -pageBg.height + 26); pageContainer.add(this.movesContainer); @@ -999,8 +1091,14 @@ export default class SummaryUiHandler extends UiHandler { extraRowOverlay.setOrigin(0, 1); this.extraMoveRowContainer.add(extraRowOverlay); - const extraRowText = addTextObject(35, 0, this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.newMove ? this.newMove.name : i18next.t("pokemonSummary:cancel"), - this.summaryUiMode === SummaryUiMode.LEARN_MOVE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY); + const extraRowText = addTextObject( + 35, + 0, + this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.newMove + ? this.newMove.name + : i18next.t("pokemonSummary:cancel"), + this.summaryUiMode === SummaryUiMode.LEARN_MOVE ? TextStyle.SUMMARY_PINK : TextStyle.SUMMARY, + ); extraRowText.setOrigin(0, 1); this.extraMoveRowContainer.add(extraRowText); @@ -1028,7 +1126,8 @@ export default class SummaryUiHandler extends UiHandler { this.movesContainer.add(this.moveRowsContainer); for (let m = 0; m < 4; m++) { - const move: PokemonMove | null = this.pokemon && this.pokemon.moveset.length > m ? this.pokemon?.moveset[m] : null; + const move: PokemonMove | null = + this.pokemon && this.pokemon.moveset.length > m ? this.pokemon?.moveset[m] : null; const moveRowContainer = globalScene.add.container(0, 16 * m); this.moveRowsContainer.add(moveRowContainer); @@ -1060,12 +1159,12 @@ export default class SummaryUiHandler extends UiHandler { moveRowContainer.add(ppText); } - this.moveDescriptionText = addTextObject(2, 84, "", TextStyle.WINDOW_ALT, { wordWrap: { width: 1212 }}); + this.moveDescriptionText = addTextObject(2, 84, "", TextStyle.WINDOW_ALT, { wordWrap: { width: 1212 } }); this.movesContainer.add(this.moveDescriptionText); const moveDescriptionTextMaskRect = globalScene.make.graphics({}); moveDescriptionTextMaskRect.setScale(6); - moveDescriptionTextMaskRect.fillStyle(0xFFFFFF); + moveDescriptionTextMaskRect.fillStyle(0xffffff); moveDescriptionTextMaskRect.beginPath(); moveDescriptionTextMaskRect.fillRect(112, 130, 202, 46); @@ -1073,6 +1172,7 @@ export default class SummaryUiHandler extends UiHandler { this.moveDescriptionText.setMask(moveDescriptionTextMask); break; + } } } @@ -1085,7 +1185,7 @@ export default class SummaryUiHandler extends UiHandler { targets: this.statusContainer, x: 0, duration: instant ? 0 : 250, - ease: "Sine.easeOut" + ease: "Sine.easeOut", }); } @@ -1098,7 +1198,7 @@ export default class SummaryUiHandler extends UiHandler { targets: this.statusContainer, x: -106, duration: instant ? 0 : 250, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); } @@ -1109,7 +1209,8 @@ export default class SummaryUiHandler extends UiHandler { if (this.moveCursor < 4 && this.pokemon && this.moveCursor < this.pokemon.moveset.length) { return this.pokemon.moveset[this.moveCursor]!.getMove(); // TODO: is this bang correct? - } else if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.moveCursor === 4) { + } + if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE && this.moveCursor === 4) { return this.newMove; } return null; @@ -1125,7 +1226,7 @@ export default class SummaryUiHandler extends UiHandler { hideMoveSelect() { if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE) { - this.moveSelectFunction && this.moveSelectFunction(4); + this.moveSelectFunction?.(4); return; } @@ -1161,7 +1262,7 @@ export default class SummaryUiHandler extends UiHandler { targets: this.moveEffectContainer, x: 6, duration: instant ? 0 : 250, - ease: "Sine.easeOut" + ease: "Sine.easeOut", }); } @@ -1174,7 +1275,7 @@ export default class SummaryUiHandler extends UiHandler { targets: this.moveEffectContainer, x: 106, duration: instant ? 0 : 250, - ease: "Sine.easeIn" + ease: "Sine.easeIn", }); } diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index 1f2e4955081..d2f72ef4a4c 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -19,7 +19,7 @@ export default class TargetSelectUiHandler extends UiHandler { private cursor0: number; // associated with BattlerIndex.PLAYER private cursor1: number; // associated with BattlerIndex.PLAYER_2 - private isMultipleTargets: boolean = false; + private isMultipleTargets = false; private targets: BattlerIndex[]; private targetsHighlighted: Pokemon[]; private targetFlashTween: Phaser.Tweens.Tween | null; @@ -32,7 +32,7 @@ export default class TargetSelectUiHandler extends UiHandler { this.cursor = -1; } - setup(): void { } + setup(): void {} show(args: any[]): boolean { if (args.length < 3) { @@ -71,7 +71,7 @@ export default class TargetSelectUiHandler extends UiHandler { */ resetCursor(cursorN: number, user: Pokemon): void { if (!Utils.isNullOrUndefined(cursorN)) { - if ([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ].includes(cursorN) || user.battleSummonData.waveTurnCount === 1) { + if ([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2].includes(cursorN) || user.battleSummonData.waveTurnCount === 1) { // Reset cursor on the first turn of a fight or if an ally was targeted last turn cursorN = -1; } @@ -85,7 +85,7 @@ export default class TargetSelectUiHandler extends UiHandler { let success = false; if (button === Button.ACTION || button === Button.CANCEL) { - const targetIndexes: BattlerIndex[] = this.isMultipleTargets ? this.targets : [ this.cursor ]; + const targetIndexes: BattlerIndex[] = this.isMultipleTargets ? this.targets : [this.cursor]; this.targetSelectCallback(button === Button.ACTION ? targetIndexes : []); success = true; if (this.fieldIndex === BattlerIndex.PLAYER) { @@ -135,14 +135,14 @@ export default class TargetSelectUiHandler extends UiHandler { const singleTarget = globalScene.getField()[cursor]; const multipleTargets = this.targets.map(index => globalScene.getField()[index]); - this.targetsHighlighted = this.isMultipleTargets ? multipleTargets : [ singleTarget ]; + this.targetsHighlighted = this.isMultipleTargets ? multipleTargets : [singleTarget]; const ret = super.setCursor(cursor); if (this.targetFlashTween) { this.targetFlashTween.stop(); for (const pokemon of multipleTargets) { - pokemon.setAlpha(!!pokemon.getTag(SubstituteTag) ? 0.5 : 1); + pokemon.setAlpha(pokemon.getTag(SubstituteTag) ? 0.5 : 1); this.highlightItems(pokemon.id, 1); } } @@ -160,7 +160,7 @@ export default class TargetSelectUiHandler extends UiHandler { target.setAlpha(t.getValue()); this.highlightItems(target.id, t.getValue()); } - } + }, }); if (this.targetBattleInfoMoveTween.length >= 1) { @@ -173,14 +173,16 @@ export default class TargetSelectUiHandler extends UiHandler { const targetsBattleInfo = this.targetsHighlighted.map(target => target.getBattleInfo()); targetsBattleInfo.map(info => { - this.targetBattleInfoMoveTween.push(globalScene.tweens.add({ - targets: [ info ], - y: { start: info.getBaseY(), to: info.getBaseY() + 1 }, - loop: -1, - duration: Utils.fixedInt(250), - ease: "Linear", - yoyo: true - })); + this.targetBattleInfoMoveTween.push( + globalScene.tweens.add({ + targets: [info], + y: { start: info.getBaseY(), to: info.getBaseY() + 1 }, + loop: -1, + duration: Utils.fixedInt(250), + ease: "Linear", + yoyo: true, + }), + ); }); return ret; } @@ -192,7 +194,7 @@ export default class TargetSelectUiHandler extends UiHandler { } for (const pokemon of this.targetsHighlighted) { - pokemon.setAlpha(!!pokemon.getTag(SubstituteTag) ? 0.5 : 1); + pokemon.setAlpha(pokemon.getTag(SubstituteTag) ? 0.5 : 1); this.highlightItems(pokemon.id, 1); } @@ -205,7 +207,7 @@ export default class TargetSelectUiHandler extends UiHandler { } } - private highlightItems(targetId: number, val: number) : void { + private highlightItems(targetId: number, val: number): void { const targetItems = this.enemyModifiers.getAll("name", targetId.toString()); for (const item of targetItems as Phaser.GameObjects.Container[]) { item.setAlpha(val); diff --git a/src/ui/test-dialogue-ui-handler.ts b/src/ui/test-dialogue-ui-handler.ts index c7693ec954d..9fbfc01a317 100644 --- a/src/ui/test-dialogue-ui-handler.ts +++ b/src/ui/test-dialogue-ui-handler.ts @@ -8,7 +8,6 @@ import { isNullOrUndefined } from "#app/utils"; import { Mode } from "./ui"; export default class TestDialogueUiHandler extends FormModalUiHandler { - keys: string[]; constructor(mode) { @@ -19,41 +18,50 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { super.setup(); const flattenKeys = (object?: any, topKey?: string, midleKey?: string[]): Array => { - return Object.keys(object ?? {}).map((t, i) => { - const value = Object.values(object)[i]; + return Object.keys(object ?? {}) + .map((t, i) => { + const value = Object.values(object)[i]; - if (typeof value === "object" && !isNullOrUndefined(value)) { // we check for not null or undefined here because if the language json file has a null key, the typeof will still be an object, but that object will be null, causing issues - // If the value is an object, execute the same process - // si el valor es un objeto ejecuta el mismo proceso + if (typeof value === "object" && !isNullOrUndefined(value)) { + // we check for not null or undefined here because if the language json file has a null key, the typeof will still be an object, but that object will be null, causing issues + // If the value is an object, execute the same process + // si el valor es un objeto ejecuta el mismo proceso - return flattenKeys(value, topKey ?? t, topKey ? midleKey ? [ ...midleKey, t ] : [ t ] : undefined).filter((t) => t.length > 0); - } else if (typeof value === "string" || isNullOrUndefined(value)) { // we check for null or undefined here as per above - the typeof is still an object but the value is null so we need to exit out of this and pass the null key + return flattenKeys(value, topKey ?? t, topKey ? (midleKey ? [...midleKey, t] : [t]) : undefined).filter( + t => t.length > 0, + ); + } + if (typeof value === "string" || isNullOrUndefined(value)) { + // we check for null or undefined here as per above - the typeof is still an object but the value is null so we need to exit out of this and pass the null key - // Return in the format expected by i18next - return midleKey ? `${topKey}:${midleKey.map((m) => m).join(".")}.${t}` : `${topKey}:${t}`; - } - }).filter((t) => t); + // Return in the format expected by i18next + return midleKey ? `${topKey}:${midleKey.map(m => m).join(".")}.${t}` : `${topKey}:${t}`; + } + }) + .filter(t => t); }; - const keysInArrays = flattenKeys(i18next.getDataByLanguage(String(i18next.resolvedLanguage))).filter((t) => t.length > 0); // Array of arrays - const keys = keysInArrays.flat(Infinity).map(String); // One array of string + const keysInArrays = flattenKeys(i18next.getDataByLanguage(String(i18next.resolvedLanguage))).filter( + t => t.length > 0, + ); // Array of arrays + const keys = keysInArrays.flat(Number.POSITIVE_INFINITY).map(String); // One array of string this.keys = keys; } - getModalTitle(config?: ModalConfig): string { + getModalTitle(_config?: ModalConfig): string { return "Test Dialogue"; } - getWidth(config?: ModalConfig): number { + getWidth(_config?: ModalConfig): number { return 300; } - getMargin(config?: ModalConfig): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + getMargin(_config?: ModalConfig): [number, number, number, number] { + return [0, 0, 48, 0]; } - getButtonLabels(config?: ModalConfig): string[] { - return [ "Check", "Cancel" ]; + getButtonLabels(_config?: ModalConfig): string[] { + return ["Check", "Cancel"]; } getReadableErrorMessage(error: string): string { @@ -78,7 +86,10 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { input.setMaxLength(255); input.on("keydown", (inputObject, evt: KeyboardEvent) => { - if ([ "escape", "space" ].some((v) => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && ui.getMode() === Mode.AUTO_COMPLETE) { + if ( + ["escape", "space"].some(v => v === evt.key.toLowerCase() || v === evt.code.toLowerCase()) && + ui.getMode() === Mode.AUTO_COMPLETE + ) { // Delete autocomplete list and recovery focus. inputObject.on("blur", () => inputObject.node.focus(), { once: true }); ui.revertMode(); @@ -93,10 +104,12 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { let options: OptionSelectItem[] = []; const splitArr = inputObject.text.split(" "); - const filteredKeys = this.keys.filter((command) => command.toLowerCase().includes(splitArr[splitArr.length - 1].toLowerCase())); + const filteredKeys = this.keys.filter(command => + command.toLowerCase().includes(splitArr[splitArr.length - 1].toLowerCase()), + ); if (inputObject.text !== "" && filteredKeys.length > 0) { // if performance is required, you could reduce the number of total results by changing the slice below to not have all ~8000 inputs going - options = filteredKeys.slice(0).map((value) => { + options = filteredKeys.slice(0).map(value => { return { label: value, handler: () => { @@ -109,7 +122,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { } ui.revertMode(); return true; - } + }, }; }); } @@ -118,14 +131,12 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { const modalOpts = { options: options, maxOptions: 5, - modalContainer: this.modalContainer + modalContainer: this.modalContainer, }; ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOpts); } - }); - if (super.show(args)) { const config = args[0] as ModalConfig; this.inputs[0].resize(1150, 116); @@ -135,7 +146,7 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { } else { this.inputs[0].text = args[1]; } - this.submitAction = (_) => { + this.submitAction = _ => { if (ui.getMode() === Mode.TEST_DIALOGUE) { this.sanitizeInputs(); const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); diff --git a/src/ui/text.ts b/src/ui/text.ts index 19b0eddb494..d3afdef666f 100644 --- a/src/ui/text.ts +++ b/src/ui/text.ts @@ -42,19 +42,29 @@ export enum TextStyle { PERFECT_IV, ME_OPTION_DEFAULT, // Default style for choices in ME ME_OPTION_SPECIAL, // Style for choices with special requirements in ME - SHADOW_TEXT // To obscure unavailable options + SHADOW_TEXT, // To obscure unavailable options } export interface TextStyleOptions { - scale: number, - styleOptions: Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig, - shadowColor: string, - shadowXpos: number, - shadowYpos: number + scale: number; + styleOptions: Phaser.Types.GameObjects.Text.TextStyle | InputText.IConfig; + shadowColor: string; + shadowXpos: number; + shadowYpos: number; } -export function addTextObject(x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): Phaser.GameObjects.Text { - const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions(style, globalScene.uiTheme, extraStyleOptions); +export function addTextObject( + x: number, + y: number, + content: string, + style: TextStyle, + extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle, +): Phaser.GameObjects.Text { + const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions( + style, + globalScene.uiTheme, + extraStyleOptions, + ); const ret = globalScene.add.text(x, y, content, styleOptions); ret.setScale(scale); @@ -70,8 +80,16 @@ export function addTextObject(x: number, y: number, content: string, style: Text return ret; } -export function setTextStyle(obj: Phaser.GameObjects.Text, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) { - const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions(style, globalScene.uiTheme, extraStyleOptions); +export function setTextStyle( + obj: Phaser.GameObjects.Text, + style: TextStyle, + extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle, +) { + const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions( + style, + globalScene.uiTheme, + extraStyleOptions, + ); obj.setScale(scale); obj.setShadow(shadowXpos, shadowYpos, shadowColor); if (!(styleOptions as Phaser.Types.GameObjects.Text.TextStyle).lineSpacing) { @@ -83,8 +101,18 @@ export function setTextStyle(obj: Phaser.GameObjects.Text, style: TextStyle, ext } } -export function addBBCodeTextObject(x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): BBCodeText { - const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions(style, globalScene.uiTheme, extraStyleOptions); +export function addBBCodeTextObject( + x: number, + y: number, + content: string, + style: TextStyle, + extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle, +): BBCodeText { + const { scale, styleOptions, shadowColor, shadowXpos, shadowYpos } = getTextStyleOptions( + style, + globalScene.uiTheme, + extraStyleOptions, + ); const ret = new BBCodeText(globalScene, x, y, content, styleOptions as BBCodeText.TextStyle); globalScene.add.existing(ret); @@ -101,7 +129,14 @@ export function addBBCodeTextObject(x: number, y: number, content: string, style return ret; } -export function addTextInputObject(x: number, y: number, width: number, height: number, style: TextStyle, extraStyleOptions?: InputText.IConfig): InputText { +export function addTextInputObject( + x: number, + y: number, + width: number, + height: number, + style: TextStyle, + extraStyleOptions?: InputText.IConfig, +): InputText { const { scale, styleOptions } = getTextStyleOptions(style, globalScene.uiTheme, extraStyleOptions); const ret = new InputText(globalScene, x, y, width, height, styleOptions as InputText.IConfig); @@ -111,7 +146,11 @@ export function addTextInputObject(x: number, y: number, width: number, height: return ret; } -export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle): TextStyleOptions { +export function getTextStyleOptions( + style: TextStyle, + uiTheme: UiTheme, + extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle, +): TextStyleOptions { const lang = i18next.resolvedLanguage; let shadowXpos = 4; let shadowYpos = 5; @@ -123,13 +162,13 @@ export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraSty fontSize: 96, color: getTextColor(style, false, uiTheme), padding: { - bottom: 6 - } + bottom: 6, + }, }; if (i18next.resolvedLanguage === "ja") { scale = 0.1388888889; - styleOptions.padding = { top:2, bottom:4 }; + styleOptions.padding = { top: 2, bottom: 4 }; } switch (style) { @@ -148,7 +187,7 @@ export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraSty shadowXpos = 3; shadowYpos = 3; break; - case TextStyle.STATS_LABEL: + case TextStyle.STATS_LABEL: { let fontSizeLabel = "96px"; switch (lang) { case "de": @@ -160,9 +199,10 @@ export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraSty fontSizeLabel = "96px"; break; } - styleOptions.fontSize = fontSizeLabel; + styleOptions.fontSize = fontSizeLabel; break; - case TextStyle.STATS_VALUE: + } + case TextStyle.STATS_VALUE: { shadowXpos = 3; shadowYpos = 3; let fontSizeValue = "96px"; @@ -174,8 +214,9 @@ export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraSty fontSizeValue = "96px"; break; } - styleOptions.fontSize = fontSizeValue; + styleOptions.fontSize = fontSizeValue; break; + } case TextStyle.MESSAGE: case TextStyle.SETTINGS_LABEL: case TextStyle.SETTINGS_LOCKED: @@ -220,7 +261,9 @@ export function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraSty if (extraStyleOptions) { if (extraStyleOptions.fontSize) { - const sizeRatio = parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / parseInt(styleOptions.fontSize?.toString().slice(0, -2) ?? "1"); + const sizeRatio = + Number.parseInt(extraStyleOptions.fontSize.toString().slice(0, -2)) / + Number.parseInt(styleOptions.fontSize?.toString().slice(0, -2) ?? "1"); shadowXpos *= sizeRatio; } styleOptions = Object.assign(styleOptions, extraStyleOptions); @@ -249,10 +292,15 @@ export function getBBCodeFrag(content: string, textStyle: TextStyle, uiTheme: Ui * @param forWindow set to `true` if the text is to be displayed in a window ({@linkcode BattleScene.addWindow}) * it will replace all instances of the default MONEY TextStyle by {@linkcode TextStyle.MONEY_WINDOW} */ -export function getTextWithColors(content: string, primaryStyle: TextStyle, uiTheme: UiTheme, forWindow?: boolean): string { +export function getTextWithColors( + content: string, + primaryStyle: TextStyle, + uiTheme: UiTheme, + forWindow?: boolean, +): string { // Apply primary styling before anything else let text = getBBCodeFrag(content, primaryStyle, uiTheme) + "[/color][/shadow]"; - const primaryStyleString = [ ...text.match(new RegExp(/\[color=[^\[]*\]\[shadow=[^\[]*\]/i))! ][0]; + const primaryStyleString = [...text.match(new RegExp(/\[color=[^\[]*\]\[shadow=[^\[]*\]/i))!][0]; /* For money text displayed in game windows, we can't use the default {@linkcode TextStyle.MONEY} * or it will look wrong in legacy mode because of the different window background color @@ -262,14 +310,20 @@ export function getTextWithColors(content: string, primaryStyle: TextStyle, uiTh } // Set custom colors - text = text.replace(/@\[([^{]*)\]{([^}]*)}/gi, (substring, textStyle: string, textToColor: string) => { - return "[/color][/shadow]" + getBBCodeFrag(textToColor, TextStyle[textStyle], uiTheme) + "[/color][/shadow]" + primaryStyleString; + text = text.replace(/@\[([^{]*)\]{([^}]*)}/gi, (_substring, textStyle: string, textToColor: string) => { + return ( + "[/color][/shadow]" + + getBBCodeFrag(textToColor, TextStyle[textStyle], uiTheme) + + "[/color][/shadow]" + + primaryStyleString + ); }); // Remove extra style block at the end return text.replace(/\[color=[^\[]*\]\[shadow=[^\[]*\]\[\/color\]\[\/shadow\]/gi, ""); } +// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: This is a giant switch which is the best option. export function getTextColor(textStyle: TextStyle, shadow?: boolean, uiTheme: UiTheme = UiTheme.DEFAULT): string { const isLegacyTheme = uiTheme === UiTheme.LEGACY; switch (textStyle) { diff --git a/src/ui/time-of-day-widget.ts b/src/ui/time-of-day-widget.ts index 2a33b475385..bda1f750cb1 100644 --- a/src/ui/time-of-day-widget.ts +++ b/src/ui/time-of-day-widget.ts @@ -6,7 +6,6 @@ import { TimeOfDay } from "#enums/time-of-day"; /** A small self contained UI element that displays the time of day as an icon */ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { - /** The {@linkcode Phaser.GameObjects.Sprite} that represents the foreground of the current time of day */ private readonly timeOfDayIconFgs: Phaser.GameObjects.Sprite[] = new Array(2); /** The {@linkcode Phaser.GameObjects.Sprite} that represents the middle-ground of the current time of day */ @@ -19,9 +18,10 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { /** A map containing all timeOfDayIcon arrays with a matching string key for easier iteration */ private timeOfDayIconPairs: Map = new Map([ - [ "bg", this.timeOfDayIconBgs ], - [ "mg", this.timeOfDayIconMgs ], - [ "fg", this.timeOfDayIconFgs ],]); + ["bg", this.timeOfDayIconBgs], + ["mg", this.timeOfDayIconMgs], + ["fg", this.timeOfDayIconFgs], + ]); /** The current time of day */ private currentTime: TimeOfDay = TimeOfDay.ALL; @@ -38,16 +38,15 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { } /** On set, resumes any paused tweens if true */ public set parentVisible(visible: boolean) { - if (visible && !this._parentVisible) { // Only resume the tweens if parent is newly visible - this.timeOfDayIcons?.forEach( - icon => globalScene.tweens.getTweensOf(icon).forEach( - tween => tween.resume())); + if (visible && !this._parentVisible) { + // Only resume the tweens if parent is newly visible + this.timeOfDayIcons?.forEach(icon => globalScene.tweens.getTweensOf(icon).forEach(tween => tween.resume())); } this._parentVisible = visible; } - constructor(x: number = 0, y: number = 0) { + constructor(x = 0, y = 0) { super(globalScene, x, y); this.setVisible(globalScene.showTimeOfDayWidget); @@ -56,14 +55,13 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { } // Initialize all sprites - this.timeOfDayIconPairs.forEach( - (icons, key) => { - for (let i = 0; i < icons.length; i++) { - icons[i] = globalScene.add.sprite(0, 0, "dawn_icon_" + key).setOrigin(); - } - }); + this.timeOfDayIconPairs.forEach((icons, key) => { + for (let i = 0; i < icons.length; i++) { + icons[i] = globalScene.add.sprite(0, 0, "dawn_icon_" + key).setOrigin(); + } + }); // Store a flat array of all icons for later - this.timeOfDayIcons = [ this.timeOfDayIconBgs, this.timeOfDayIconMgs, this.timeOfDayIconFgs ].flat(); + this.timeOfDayIcons = [this.timeOfDayIconBgs, this.timeOfDayIconMgs, this.timeOfDayIconFgs].flat(); this.add(this.timeOfDayIcons); globalScene.eventTarget.addEventListener(BattleSceneEventType.ENCOUNTER_PHASE, this.onEncounterPhaseEvent); @@ -75,21 +73,21 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { */ private getBackTween(): Phaser.Types.Tweens.TweenBuilderConfig[] { const rotate = { - targets: [ this.timeOfDayIconMgs[0], this.timeOfDayIconMgs[1] ], + targets: [this.timeOfDayIconMgs[0], this.timeOfDayIconMgs[1]], angle: "+=90", duration: Utils.fixedInt(1500), ease: "Back.easeOut", paused: !this.parentVisible, }; const fade = { - targets: [ this.timeOfDayIconBgs[1], this.timeOfDayIconMgs[1], this.timeOfDayIconFgs[1] ], + targets: [this.timeOfDayIconBgs[1], this.timeOfDayIconMgs[1], this.timeOfDayIconFgs[1]], alpha: 0, duration: Utils.fixedInt(500), ease: "Linear", paused: !this.parentVisible, }; - return [ rotate, fade ]; + return [rotate, fade]; } /** @@ -98,21 +96,21 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { */ private getBounceTween(): Phaser.Types.Tweens.TweenBuilderConfig[] { const bounce = { - targets: [ this.timeOfDayIconMgs[0], this.timeOfDayIconMgs[1] ], + targets: [this.timeOfDayIconMgs[0], this.timeOfDayIconMgs[1]], angle: "+=90", duration: Utils.fixedInt(2000), ease: "Bounce.easeOut", paused: !this.parentVisible, }; const fade = { - targets: [ this.timeOfDayIconBgs[1], this.timeOfDayIconMgs[1], this.timeOfDayIconFgs[1] ], + targets: [this.timeOfDayIconBgs[1], this.timeOfDayIconMgs[1], this.timeOfDayIconFgs[1]], alpha: 0, duration: Utils.fixedInt(800), ease: "Linear", paused: !this.parentVisible, }; - return [ bounce, fade ]; + return [bounce, fade]; } /** Resets all icons to the proper depth, texture, and alpha so they are ready to tween */ @@ -121,11 +119,10 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { this.moveBelow(this.timeOfDayIconMgs[0], this.timeOfDayIconBgs[1]); this.moveBelow(this.timeOfDayIconFgs[0], this.timeOfDayIconFgs[1]); - this.timeOfDayIconPairs.forEach( - (icons, key) => { - icons[0].setTexture(TimeOfDay[this.currentTime].toLowerCase() + "_icon_" + key); - icons[1].setTexture(TimeOfDay[this.previousTime].toLowerCase() + "_icon_" + key); - }); + this.timeOfDayIconPairs.forEach((icons, key) => { + icons[0].setTexture(TimeOfDay[this.currentTime].toLowerCase() + "_icon_" + key); + icons[1].setTexture(TimeOfDay[this.previousTime].toLowerCase() + "_icon_" + key); + }); this.timeOfDayIconMgs[0].setRotation(-90 * (3.14 / 180)); this.timeOfDayIcons.forEach(icon => icon.setAlpha(1)); @@ -138,23 +135,23 @@ export default class TimeOfDayWidget extends Phaser.GameObjects.Container { this.resetIcons(); // Tween based on the player setting - (globalScene.timeOfDayAnimation === EaseType.BACK ? this.getBackTween() : this.getBounceTween()) - .forEach(tween => globalScene.tweens.add(tween)); + (globalScene.timeOfDayAnimation === EaseType.BACK ? this.getBackTween() : this.getBounceTween()).forEach(tween => + globalScene.tweens.add(tween), + ); // Swaps all elements of the icon arrays by shifting the first element onto the end of the array // This ensures index[0] is always the new time of day icon and index[1] is always the current one - this.timeOfDayIconPairs.forEach( - icons => { - const shifted = icons.shift(); - shifted && icons.push(shifted); - }); + this.timeOfDayIconPairs.forEach(icons => { + const shifted = icons.shift(); + shifted && icons.push(shifted); + }); } /** * Grabs the current time of day from the arena and calls {@linkcode tweenTimeOfDayIcon} - * @param event {@linkcode Event} being sent + * @param _event {@linkcode Event} being sent */ - private onEncounterPhase(event: Event) { + private onEncounterPhase(_event: Event) { const newTime = globalScene.arena.getTimeOfDay(); if (this.currentTime === newTime) { diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index 0d69eae0efc..2f797bb4bfb 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -36,7 +36,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.titleContainer.setAlpha(0); ui.add(this.titleContainer); - const logo = globalScene.add.image((globalScene.game.canvas.width / 6) / 2, 8, "logo"); + const logo = globalScene.add.image(globalScene.game.canvas.width / 6 / 2, 8, "logo"); logo.setOrigin(0.5, 0); this.titleContainer.add(logo); @@ -48,15 +48,18 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.playerCountLabel = addTextObject( // Actual y position will be determined after the title menu has been populated with options - (globalScene.game.canvas.width / 6) - 2, 0, + globalScene.game.canvas.width / 6 - 2, + 0, `? ${i18next.t("menu:playersOnline")}`, TextStyle.MESSAGE, - { fontSize: "54px" } + { fontSize: "54px" }, ); this.playerCountLabel.setOrigin(1, 0); this.titleContainer.add(this.playerCountLabel); - this.splashMessageText = addTextObject(logo.x + 64, logo.y + logo.displayHeight - 8, "", TextStyle.MONEY, { fontSize: "54px" }); + this.splashMessageText = addTextObject(logo.x + 64, logo.y + logo.displayHeight - 8, "", TextStyle.MONEY, { + fontSize: "54px", + }); this.splashMessageText.setOrigin(0.5, 0.5); this.splashMessageText.setAngle(-20); this.titleContainer.add(this.splashMessageText); @@ -71,14 +74,17 @@ export default class TitleUiHandler extends OptionSelectUiHandler { yoyo: true, }); - this.appVersionText = addTextObject(logo.x - 60, logo.y + logo.displayHeight + 4, "", TextStyle.MONEY, { fontSize: "54px" }); + this.appVersionText = addTextObject(logo.x - 60, logo.y + logo.displayHeight + 4, "", TextStyle.MONEY, { + fontSize: "54px", + }); this.appVersionText.setOrigin(0.5, 0.5); this.appVersionText.setAngle(0); this.titleContainer.add(this.appVersionText); } updateTitleStats(): void { - pokerogueApi.getGameTitleStats() + pokerogueApi + .getGameTitleStats() .then(stats => { if (stats) { this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`); @@ -97,10 +103,14 @@ export default class TitleUiHandler extends OptionSelectUiHandler { if (ret) { // Moving player count to top of the menu - this.playerCountLabel.setY((globalScene.game.canvas.height / 6) - 13 - this.getWindowHeight()); + this.playerCountLabel.setY(globalScene.game.canvas.height / 6 - 13 - this.getWindowHeight()); this.splashMessage = Utils.randItem(getSplashMessages()); - this.splashMessageText.setText(i18next.t(this.splashMessage, { count: TitleUiHandler.BATTLES_WON_FALLBACK })); + this.splashMessageText.setText( + i18next.t(this.splashMessage, { + count: TitleUiHandler.BATTLES_WON_FALLBACK, + }), + ); this.appVersionText.setText("v" + version); @@ -118,10 +128,10 @@ export default class TitleUiHandler extends OptionSelectUiHandler { }, 60000); globalScene.tweens.add({ - targets: [ this.titleContainer, ui.getMessageHandler().bg ], + targets: [this.titleContainer, ui.getMessageHandler().bg], duration: Utils.fixedInt(325), - alpha: (target: any) => target === this.titleContainer ? 1 : 0, - ease: "Sine.easeInOut" + alpha: (target: any) => (target === this.titleContainer ? 1 : 0), + ease: "Sine.easeInOut", }); } @@ -139,10 +149,10 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.titleStatsTimer = null; globalScene.tweens.add({ - targets: [ this.titleContainer, ui.getMessageHandler().bg ], + targets: [this.titleContainer, ui.getMessageHandler().bg], duration: Utils.fixedInt(325), - alpha: (target: any) => target === this.titleContainer ? 0 : 1, - ease: "Sine.easeInOut" + alpha: (target: any) => (target === this.titleContainer ? 0 : 1), + ease: "Sine.easeInOut", }); } } diff --git a/src/ui/ui-handler.ts b/src/ui/ui-handler.ts index f001ab5bd6f..433f85d0f92 100644 --- a/src/ui/ui-handler.ts +++ b/src/ui/ui-handler.ts @@ -9,8 +9,8 @@ import type { Button } from "#enums/buttons"; */ export default abstract class UiHandler { protected mode: number | null; - protected cursor: number = 0; - public active: boolean = false; + protected cursor = 0; + public active = false; /** * @param mode The mode of the UI element. These should be unique. @@ -33,7 +33,7 @@ export default abstract class UiHandler { return globalScene.ui; } - getTextColor(style: TextStyle, shadow: boolean = false): string { + getTextColor(style: TextStyle, shadow = false): string { return getTextColor(style, shadow, globalScene.uiTheme); } diff --git a/src/ui/ui-theme.ts b/src/ui/ui-theme.ts index 36e2e844a56..c3931aea23b 100644 --- a/src/ui/ui-theme.ts +++ b/src/ui/ui-theme.ts @@ -5,7 +5,7 @@ import { globalScene } from "#app/global-scene"; export enum WindowVariant { NORMAL, THIN, - XTHIN + XTHIN, } export function getWindowVariantSuffix(windowVariant: WindowVariant): string { @@ -21,29 +21,50 @@ export function getWindowVariantSuffix(windowVariant: WindowVariant): string { const windowTypeControlColors = { [UiTheme.DEFAULT]: { - 0: [ "#6b5a73", "#DD5748", "#7E4955" ], - 1: [ "#6b5a73", "#48DDAA", "#4D7574" ], - 2: [ "#6b5a73", "#C5C5C5", "#766D7E" ], - 3: [ "#6b5a73", "#EBC07C", "#836C66" ], - 4: [ "#686868", "#E8E8E8", "#919191" ] + 0: ["#6b5a73", "#DD5748", "#7E4955"], + 1: ["#6b5a73", "#48DDAA", "#4D7574"], + 2: ["#6b5a73", "#C5C5C5", "#766D7E"], + 3: ["#6b5a73", "#EBC07C", "#836C66"], + 4: ["#686868", "#E8E8E8", "#919191"], }, [UiTheme.LEGACY]: { - 0: [ "#706880", "#8888c8", "#484868" ], - 1: [ "#d04028", "#e0a028", "#902008" ], - 2: [ "#48b840", "#88d880", "#089040" ], - 3: [ "#2068d0", "#80b0e0", "#104888" ], - 4: [ "#706880", "#8888c8", "#484868" ] - } + 0: ["#706880", "#8888c8", "#484868"], + 1: ["#d04028", "#e0a028", "#902008"], + 2: ["#48b840", "#88d880", "#089040"], + 3: ["#2068d0", "#80b0e0", "#104888"], + 4: ["#706880", "#8888c8", "#484868"], + }, }; -export function addWindow(x: number, y: number, width: number, height: number, mergeMaskTop?: boolean, mergeMaskLeft?: boolean, maskOffsetX?: number, maskOffsetY?: number, windowVariant?: WindowVariant): Phaser.GameObjects.NineSlice { +export function addWindow( + x: number, + y: number, + width: number, + height: number, + mergeMaskTop?: boolean, + mergeMaskLeft?: boolean, + maskOffsetX?: number, + maskOffsetY?: number, + windowVariant?: WindowVariant, +): Phaser.GameObjects.NineSlice { if (windowVariant === undefined) { windowVariant = WindowVariant.NORMAL; } const borderSize = globalScene.uiTheme ? 6 : 8; - const window = globalScene.add.nineslice(x, y, `window_${globalScene.windowType}${getWindowVariantSuffix(windowVariant)}`, undefined, width, height, borderSize, borderSize, borderSize, borderSize); + const window = globalScene.add.nineslice( + x, + y, + `window_${globalScene.windowType}${getWindowVariantSuffix(windowVariant)}`, + undefined, + width, + height, + borderSize, + borderSize, + borderSize, + borderSize, + ); window.setOrigin(0, 0); if (mergeMaskLeft || mergeMaskTop || maskOffsetX || maskOffsetY) { @@ -55,11 +76,11 @@ export function addWindow(x: number, y: number, width: number, height: number, m */ const maskRect = new Phaser.GameObjects.Rectangle( globalScene, - 6 * (x - (mergeMaskLeft ? 2 : 0) - (maskOffsetX || 0)), + 6 * (x - (mergeMaskLeft ? 2 : 0) - (maskOffsetX || 0)), 6 * (y + (mergeMaskTop ? 2 : 0) + (maskOffsetY || 0)), width - (mergeMaskLeft ? 2 : 0), height - (mergeMaskTop ? 2 : 0), - 0xffffff + 0xffffff, ); maskRect.setOrigin(0); maskRect.setScale(6); @@ -85,7 +106,14 @@ export function updateWindowType(windowTypeIndex: number): void { } } else if (object instanceof Phaser.GameObjects.NineSlice) { if (object.texture.key.startsWith("window_")) { - windowObjects.push([ object, object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.XTHIN)) ? WindowVariant.XTHIN : object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.THIN)) ? WindowVariant.THIN : WindowVariant.NORMAL ]); + windowObjects.push([ + object, + object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.XTHIN)) + ? WindowVariant.XTHIN + : object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.THIN)) + ? WindowVariant.THIN + : WindowVariant.NORMAL, + ]); } else if (object.texture?.key === "namebox") { themedObjects.push(object); } @@ -101,11 +129,13 @@ export function updateWindowType(windowTypeIndex: number): void { globalScene.windowType = windowTypeIndex; const rootStyle = document.documentElement.style; - [ "base", "light", "dark" ].map((k, i) => rootStyle.setProperty(`--color-${k}`, windowTypeControlColors[globalScene.uiTheme][windowTypeIndex - 1][i])); + ["base", "light", "dark"].map((k, i) => + rootStyle.setProperty(`--color-${k}`, windowTypeControlColors[globalScene.uiTheme][windowTypeIndex - 1][i]), + ); const windowKey = `window_${windowTypeIndex}`; - for (const [ window, variant ] of windowObjects) { + for (const [window, variant] of windowObjects) { window.setTexture(`${windowKey}${getWindowVariantSuffix(variant)}`); } @@ -116,54 +146,91 @@ export function updateWindowType(windowTypeIndex: number): void { export function addUiThemeOverrides(): void { const originalAddImage = globalScene.add.image; - globalScene.add.image = function (x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Image { + globalScene.add.image = function ( + x: number, + y: number, + texture: string | Phaser.Textures.Texture, + frame?: string | number, + ): Phaser.GameObjects.Image { let legacy = false; if (typeof texture === "string" && globalScene.uiTheme && legacyCompatibleImages.includes(texture)) { legacy = true; texture += "_legacy"; } - const ret: Phaser.GameObjects.Image = originalAddImage.apply(this, [ x, y, texture, frame ]); + const ret: Phaser.GameObjects.Image = originalAddImage.apply(this, [x, y, texture, frame]); if (legacy) { const originalSetTexture = ret.setTexture; ret.setTexture = function (key: string, frame?: string | number) { key += "_legacy"; - return originalSetTexture.apply(this, [ key, frame ]); + return originalSetTexture.apply(this, [key, frame]); }; } return ret; }; const originalAddSprite = globalScene.add.sprite; - globalScene.add.sprite = function (x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite { + globalScene.add.sprite = function ( + x: number, + y: number, + texture: string | Phaser.Textures.Texture, + frame?: string | number, + ): Phaser.GameObjects.Sprite { let legacy = false; if (typeof texture === "string" && globalScene.uiTheme && legacyCompatibleImages.includes(texture)) { legacy = true; texture += "_legacy"; } - const ret: Phaser.GameObjects.Sprite = originalAddSprite.apply(this, [ x, y, texture, frame ]); + const ret: Phaser.GameObjects.Sprite = originalAddSprite.apply(this, [x, y, texture, frame]); if (legacy) { const originalSetTexture = ret.setTexture; ret.setTexture = function (key: string, frame?: string | number) { key += "_legacy"; - return originalSetTexture.apply(this, [ key, frame ]); + return originalSetTexture.apply(this, [key, frame]); }; } return ret; }; const originalAddNineslice = globalScene.add.nineslice; - globalScene.add.nineslice = function (x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number, width?: number, height?: number, leftWidth?: number, rightWidth?: number, topHeight?: number, bottomHeight?: number): Phaser.GameObjects.NineSlice { + globalScene.add.nineslice = function ( + x: number, + y: number, + texture: string | Phaser.Textures.Texture, + frame?: string | number, + width?: number, + height?: number, + leftWidth?: number, + rightWidth?: number, + topHeight?: number, + bottomHeight?: number, + ): Phaser.GameObjects.NineSlice { let legacy = false; if (typeof texture === "string" && globalScene.uiTheme && legacyCompatibleImages.includes(texture)) { legacy = true; texture += "_legacy"; } - const ret: Phaser.GameObjects.NineSlice = originalAddNineslice.apply(this, [ x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight ]); + const ret: Phaser.GameObjects.NineSlice = originalAddNineslice.apply(this, [ + x, + y, + texture, + frame, + width, + height, + leftWidth, + rightWidth, + topHeight, + bottomHeight, + ]); if (legacy) { const originalSetTexture = ret.setTexture; - ret.setTexture = function (key: string | Phaser.Textures.Texture, frame?: string | number, updateSize?: boolean, updateOrigin?: boolean) { + ret.setTexture = function ( + key: string | Phaser.Textures.Texture, + frame?: string | number, + updateSize?: boolean, + updateOrigin?: boolean, + ) { key += "_legacy"; - return originalSetTexture.apply(this, [ key, frame, updateSize, updateOrigin ]); + return originalSetTexture.apply(this, [key, frame, updateSize, updateOrigin]); }; } return ret; diff --git a/src/ui/ui.ts b/src/ui/ui.ts index 7fbd10b4668..7c202e9210d 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -103,7 +103,7 @@ export enum Mode { TEST_DIALOGUE, AUTO_COMPLETE, ADMIN, - MYSTERY_ENCOUNTER + MYSTERY_ENCOUNTER, } const transitionModes = [ @@ -147,7 +147,7 @@ const noTransitionModes = [ Mode.AUTO_COMPLETE, Mode.ADMIN, Mode.MYSTERY_ENCOUNTER, - Mode.RUN_INFO + Mode.RUN_INFO, ]; export default class UI extends Phaser.GameObjects.Container { @@ -226,19 +226,25 @@ export default class UI extends Phaser.GameObjects.Container { for (const handler of this.handlers) { handler.setup(); } - this.overlay = globalScene.add.rectangle(0, 0, globalScene.game.canvas.width / 6, globalScene.game.canvas.height / 6, 0); + this.overlay = globalScene.add.rectangle( + 0, + 0, + globalScene.game.canvas.width / 6, + globalScene.game.canvas.height / 6, + 0, + ); this.overlay.setName("rect-ui-overlay"); this.overlay.setOrigin(0, 0); globalScene.uiContainer.add(this.overlay); this.overlay.setVisible(false); this.setupTooltip(); - this.achvBar = new AchvBar; + this.achvBar = new AchvBar(); this.achvBar.setup(); globalScene.uiContainer.add(this.achvBar); - this.savingIcon = new SavingIconHandler; + this.savingIcon = new SavingIconHandler(); this.savingIcon.setup(); globalScene.uiContainer.add(this.savingIcon); @@ -281,7 +287,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 ([Mode.CONFIRM, Mode.COMMAND, Mode.FIGHT, Mode.MESSAGE, Mode.TARGET_SELECT].includes(this.mode)) { globalScene?.processInfoButton(pressed); return true; } @@ -308,15 +314,23 @@ export default class UI extends Phaser.GameObjects.Container { return handler.processInput(button); } - showTextPromise(text: string, callbackDelay: number = 0, prompt: boolean = true, promptDelay?: number | null): Promise { + showTextPromise(text: string, callbackDelay = 0, prompt = true, promptDelay?: number | null): Promise { return new Promise(resolve => { this.showText(text ?? "", null, () => resolve(), callbackDelay, prompt, promptDelay); }); } - showText(text: string, delay?: number | null, callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null): void { + showText( + text: string, + delay?: number | null, + callback?: Function | null, + callbackDelay?: number | null, + prompt?: boolean | null, + promptDelay?: number | null, + ): void { if (prompt && text.indexOf("$") > -1) { const messagePages = text.split(/\$/g).map(m => m.trim()); + // biome-ignore lint/complexity/useOptionalChain: optional chain would change this to be null instead of undefined. let showMessageAndCallback = () => callback && callback(); for (let p = messagePages.length - 1; p >= 0; p--) { const originalFunc = showMessageAndCallback; @@ -330,18 +344,24 @@ export default class UI extends Phaser.GameObjects.Container { } else { this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay); } - } } - showDialogue(keyOrText: string, name: string | undefined, delay: number | null = 0, callback: Function, callbackDelay?: number, promptDelay?: number): void { + showDialogue( + keyOrText: string, + name: string | undefined, + delay: number | null = 0, + callback: Function, + callbackDelay?: number, + promptDelay?: number, + ): void { // Get localized dialogue (if available) let hasi18n = false; let text = keyOrText; const genderIndex = globalScene.gameData.gender ?? PlayerGender.UNSET; const genderStr = PlayerGender[genderIndex].toLowerCase(); - if (i18next.exists(keyOrText) ) { + if (i18next.exists(keyOrText)) { const i18nKey = keyOrText; hasi18n = true; @@ -368,15 +388,31 @@ export default class UI extends Phaser.GameObjects.Container { } else { const handler = this.getHandler(); if (handler instanceof MessageUiHandler) { - (handler as MessageUiHandler).showDialogue(text, name, delay, showMessageAndCallback, callbackDelay, true, promptDelay); + (handler as MessageUiHandler).showDialogue( + text, + name, + delay, + showMessageAndCallback, + callbackDelay, + true, + promptDelay, + ); } else { - this.getMessageHandler().showDialogue(text, name, delay, showMessageAndCallback, callbackDelay, true, promptDelay); + this.getMessageHandler().showDialogue( + text, + name, + delay, + showMessageAndCallback, + callbackDelay, + true, + promptDelay, + ); } } } shouldSkipDialogue(i18nKey: string): boolean { - if (i18next.exists(i18nKey) ) { + if (i18next.exists(i18nKey)) { if (globalScene.skipSeenDialogues && globalScene.gameData.getSeenDialogues()[i18nKey] === true) { return true; } @@ -385,7 +421,11 @@ export default class UI extends Phaser.GameObjects.Container { } getTooltip(): { visible: boolean; title: string; content: string } { - return { visible: this.tooltipContainer.visible, title: this.tooltipTitle.text, content: this.tooltipContent.text }; + return { + visible: this.tooltipContainer.visible, + title: this.tooltipTitle.text, + content: this.tooltipContent.text, + }; } showTooltip(title: string, content: string, overlap?: boolean): void { @@ -403,7 +443,10 @@ export default class UI extends Phaser.GameObjects.Container { const wrappedContent = this.tooltipContent.runWordWrap(content); this.tooltipContent.setText(wrappedContent); this.tooltipContent.y = title ? 16 : 4; - this.tooltipBg.width = Math.min(Math.max(this.tooltipTitle.displayWidth, this.tooltipContent.displayWidth) + 12, 838); + this.tooltipBg.width = Math.min( + Math.max(this.tooltipTitle.displayWidth, this.tooltipContent.displayWidth) + 12, + 838, + ); this.tooltipBg.height = (title ? 31 : 19) + 10.5 * (wrappedContent.split("\n").length - 1); this.tooltipTitle.x = this.tooltipBg.width / 2; } @@ -485,7 +528,7 @@ export default class UI extends Phaser.GameObjects.Container { alpha: 1, duration: duration, ease: "Sine.easeOut", - onComplete: () => resolve() + onComplete: () => resolve(), }); }); } @@ -503,13 +546,19 @@ export default class UI extends Phaser.GameObjects.Container { onComplete: () => { this.overlay.setVisible(false); resolve(); - } + }, }); this.overlayActive = false; }); } - private setModeInternal(mode: Mode, clear: boolean, forceTransition: boolean, chainMode: boolean, args: any[]): Promise { + private setModeInternal( + mode: Mode, + clear: boolean, + forceTransition: boolean, + chainMode: boolean, + args: any[], + ): Promise { return new Promise(resolve => { if (this.mode === mode && !forceTransition) { resolve(); @@ -533,9 +582,13 @@ export default class UI extends Phaser.GameObjects.Container { } resolve(); }; - if (((!chainMode && ((transitionModes.indexOf(this.mode) > -1 || transitionModes.indexOf(mode) > -1) - && (noTransitionModes.indexOf(this.mode) === -1 && noTransitionModes.indexOf(mode) === -1))) - || (chainMode && noTransitionModes.indexOf(mode) === -1))) { + if ( + (!chainMode && + (transitionModes.indexOf(this.mode) > -1 || transitionModes.indexOf(mode) > -1) && + noTransitionModes.indexOf(this.mode) === -1 && + noTransitionModes.indexOf(mode) === -1) || + (chainMode && noTransitionModes.indexOf(mode) === -1) + ) { this.fadeOut(250).then(() => { globalScene.time.delayedCall(100, () => { doSetMode(); @@ -575,7 +628,6 @@ export default class UI extends Phaser.GameObjects.Container { revertMode(): Promise { return new Promise(resolve => { - if (!this?.modeChain?.length) { return resolve(false); } @@ -629,9 +681,8 @@ export default class UI extends Phaser.GameObjects.Container { public getGamepadType(): string { if (globalScene.inputMethod === "gamepad") { return globalScene.inputController.getConfig(globalScene.inputController.selectedDevice[Device.GAMEPAD]).padType; - } else { - return globalScene.inputMethod; } + return globalScene.inputMethod; } /** diff --git a/src/ui/unavailable-modal-ui-handler.ts b/src/ui/unavailable-modal-ui-handler.ts index 36f1a191b77..3007f7247f1 100644 --- a/src/ui/unavailable-modal-ui-handler.ts +++ b/src/ui/unavailable-modal-ui-handler.ts @@ -35,17 +35,23 @@ export default class UnavailableModalUiHandler extends ModalUiHandler { } getMargin(): [number, number, number, number] { - return [ 0, 0, 48, 0 ]; + return [0, 0, 48, 0]; } getButtonLabels(): string[] { - return [ ]; + return []; } setup(): void { super.setup(); - const label = addTextObject(this.getWidth() / 2, this.getHeight() / 2, i18next.t("menu:errorServerDown"), TextStyle.WINDOW, { fontSize: "48px", align: "center" }); + const label = addTextObject( + this.getWidth() / 2, + this.getHeight() / 2, + i18next.t("menu:errorServerDown"), + TextStyle.WINDOW, + { fontSize: "48px", align: "center" }, + ); label.setOrigin(0.5, 0.5); this.modalContainer.add(label); @@ -53,7 +59,7 @@ export default class UnavailableModalUiHandler extends ModalUiHandler { tryReconnect(): void { updateUserInfo().then(response => { - if (response[0] || [ 200, 400 ].includes(response[1])) { + if (response[0] || [200, 400].includes(response[1])) { this.reconnectTimer = null; this.reconnectDuration = this.minTime; globalScene.playSound("se/pb_bounce_1"); @@ -63,11 +69,11 @@ export default class UnavailableModalUiHandler extends ModalUiHandler { globalScene.reset(true, true); } else { this.reconnectDuration = Math.min(this.reconnectDuration * 2, this.maxTime); // Set a max delay so it isn't infinite - this.reconnectTimer = - setTimeout( - () => this.tryReconnect(), - // Adds a random factor to avoid pendulum effect during long total breakdown - this.reconnectDuration + (Math.random() * this.randVarianceTime)); + this.reconnectTimer = setTimeout( + () => this.tryReconnect(), + // Adds a random factor to avoid pendulum effect during long total breakdown + this.reconnectDuration + Math.random() * this.randVarianceTime, + ); } }); } @@ -75,14 +81,14 @@ export default class UnavailableModalUiHandler extends ModalUiHandler { show(args: any[]): boolean { if (args.length >= 1 && args[0] instanceof Function) { const config: ModalConfig = { - buttonActions: [] + buttonActions: [], }; this.reconnectCallback = args[0]; this.reconnectDuration = this.minTime; this.reconnectTimer = setTimeout(() => this.tryReconnect(), this.reconnectDuration); - return super.show([ config ]); + return super.show([config]); } return false; diff --git a/src/utils.test.ts b/src/utils.test.ts index 3f5b835b03b..cc3f2bb1a04 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -4,7 +4,6 @@ import { randomString, padInt } from "./utils"; import Phaser from "phaser"; describe("utils", () => { - beforeAll(() => { new Phaser.Game({ type: Phaser.HEADLESS, diff --git a/src/utils.ts b/src/utils.ts index 56df3f3f48e..7d3dea0247e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,10 +8,14 @@ export type nil = null | undefined; export const MissingTextureKey = "__MISSING"; export function toReadableString(str: string): string { - return str.replace(/\_/g, " ").split(" ").map(s => `${s.slice(0, 1)}${s.slice(1).toLowerCase()}`).join(" "); + return str + .replace(/\_/g, " ") + .split(" ") + .map(s => `${s.slice(0, 1)}${s.slice(1).toLowerCase()}`) + .join(" "); } -export function randomString(length: number, seeded: boolean = false) { +export function randomString(length: number, seeded = false) { const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; let result = ""; @@ -39,7 +43,7 @@ export function shiftCharCodes(str: string, shiftCount: number) { return newStr; } -export function randGauss(stdev: number, mean: number = 0): number { +export function randGauss(stdev: number, mean = 0): number { if (!stdev) { return 0; } @@ -49,7 +53,7 @@ export function randGauss(stdev: number, mean: number = 0): number { return z * stdev + mean; } -export function randSeedGauss(stdev: number, mean: number = 0): number { +export function randSeedGauss(stdev: number, mean = 0): number { if (!stdev) { return 0; } @@ -71,11 +75,11 @@ export function padInt(value: number, length: number, padWith?: string): string } /** -* Returns a random integer between min and min + range -* @param range The amount of possible numbers -* @param min The starting number -*/ -export function randInt(range: number, min: number = 0): number { + * Returns a random integer between min and min + range + * @param range The amount of possible numbers + * @param min The starting number + */ +export function randInt(range: number, min = 0): number { if (range === 1) { return min; } @@ -88,38 +92,32 @@ export function randInt(range: number, min: number = 0): number { * @param min The minimum integer to pick, default `0` * @returns A random integer between {@linkcode min} and ({@linkcode min} + {@linkcode range} - 1) */ -export function randSeedInt(range: number, min: number = 0): number { +export function randSeedInt(range: number, min = 0): number { if (range <= 1) { return min; } - return Phaser.Math.RND.integerInRange(min, (range - 1) + min); + return Phaser.Math.RND.integerInRange(min, range - 1 + min); } /** -* Returns a random integer between min and max (non-inclusive) -* @param min The lowest number -* @param max The highest number -*/ + * Returns a random integer between min and max (non-inclusive) + * @param min The lowest number + * @param max The highest number + */ export function randIntRange(min: number, max: number): number { return randInt(max - min, min); } export function randItem(items: T[]): T { - return items.length === 1 - ? items[0] - : items[randInt(items.length)]; + return items.length === 1 ? items[0] : items[randInt(items.length)]; } export function randSeedItem(items: T[]): T { - return items.length === 1 - ? items[0] - : Phaser.Math.RND.pick(items); + return items.length === 1 ? items[0] : Phaser.Math.RND.pick(items); } export function randSeedWeightedItem(items: T[]): T { - return items.length === 1 - ? items[0] - : Phaser.Math.RND.weightedPick(items); + return items.length === 1 ? items[0] : Phaser.Math.RND.weightedPick(items); } /** @@ -134,7 +132,7 @@ export function randSeedShuffle(items: T[]): T[] { const newArray = items.slice(0); for (let i = items.length - 1; i > 0; i--) { const j = Phaser.Math.RND.integerInRange(0, i); - [ newArray[i], newArray[j] ] = [ newArray[j], newArray[i] ]; + [newArray[i], newArray[j]] = [newArray[j], newArray[i]]; } return newArray; } @@ -145,15 +143,15 @@ export function getFrameMs(frameCount: number): number { export function getCurrentTime(): number { const date = new Date(); - return (((date.getHours() * 60 + date.getMinutes()) / 1440) + 0.675) % 1; + return ((date.getHours() * 60 + date.getMinutes()) / 1440 + 0.675) % 1; } const secondsInHour = 3600; export function getPlayTimeString(totalSeconds: number): string { const days = `${Math.floor(totalSeconds / (secondsInHour * 24))}`; - const hours = `${Math.floor(totalSeconds % (secondsInHour * 24) / secondsInHour)}`; - const minutes = `${Math.floor(totalSeconds % secondsInHour / 60)}`; + const hours = `${Math.floor((totalSeconds % (secondsInHour * 24)) / secondsInHour)}`; + const minutes = `${Math.floor((totalSeconds % secondsInHour) / 60)}`; const seconds = `${Math.floor(totalSeconds % 60)}`; return `${days.padStart(2, "0")}:${hours.padStart(2, "0")}:${minutes.padStart(2, "0")}:${seconds.padStart(2, "0")}`; @@ -167,12 +165,12 @@ export function getPlayTimeString(totalSeconds: number): string { */ export function getIvsFromId(id: number): number[] { return [ - (id & 0x3E000000) >>> 25, - (id & 0x01F00000) >>> 20, - (id & 0x000F8000) >>> 15, - (id & 0x00007C00) >>> 10, - (id & 0x000003E0) >>> 5, - (id & 0x0000001F) + (id & 0x3e000000) >>> 25, + (id & 0x01f00000) >>> 20, + (id & 0x000f8000) >>> 15, + (id & 0x00007c00) >>> 10, + (id & 0x000003e0) >>> 5, + id & 0x0000001f, ]; } @@ -210,9 +208,9 @@ export function formatLargeNumber(count: number, threshold: number): string { } // Abbreviations from 10^0 to 10^33 -const AbbreviationsLargeNumber: string[] = [ "", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d" ]; +const AbbreviationsLargeNumber: string[] = ["", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d"]; -export function formatFancyLargeNumber(number: number, rounded: number = 3): string { +export function formatFancyLargeNumber(number: number, rounded = 3): string { let exponent: number; if (number < 1000) { @@ -236,16 +234,20 @@ export function formatMoney(format: MoneyFormat, amount: number) { return amount.toLocaleString(); } -export function formatStat(stat: number, forHp: boolean = false): string { +export function formatStat(stat: number, forHp = false): string { return formatLargeNumber(stat, forHp ? 100000 : 1000000); } export function getEnumKeys(enumType: any): string[] { - return Object.values(enumType).filter(v => isNaN(parseInt(v!.toString()))).map(v => v!.toString()); + return Object.values(enumType) + .filter(v => Number.isNaN(Number.parseInt(v!.toString()))) + .map(v => v!.toString()); } export function getEnumValues(enumType: any): number[] { - return Object.values(enumType).filter(v => !isNaN(parseInt(v!.toString()))).map(v => parseInt(v!.toString())); + return Object.values(enumType) + .filter(v => !Number.isNaN(Number.parseInt(v!.toString()))) + .map(v => Number.parseInt(v!.toString())); } export function executeIf(condition: boolean, promiseFunc: () => Promise): Promise { @@ -254,15 +256,16 @@ export function executeIf(condition: boolean, promiseFunc: () => Promise): export const sessionIdKey = "pokerogue_sessionId"; // Check if the current hostname is 'localhost' or an IP address, and ensure a port is specified -export const isLocal = ( - (window.location.hostname === "localhost" || - /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) && - window.location.port !== "") || window.location.hostname === ""; +export const isLocal = + ((window.location.hostname === "localhost" || /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) && + window.location.port !== "") || + window.location.hostname === ""; /** * @deprecated Refer to [pokerogue-api.ts](./plugins/api/pokerogue-api.ts) instead */ -export const localServerUrl = import.meta.env.VITE_SERVER_URL ?? `http://${window.location.hostname}:${window.location.port + 1}`; +export const localServerUrl = + import.meta.env.VITE_SERVER_URL ?? `http://${window.location.hostname}:${window.location.port + 1}`; /** * Set the server URL based on whether it's local or not @@ -277,7 +280,7 @@ export const isBeta = import.meta.env.MODE === "beta"; // this checks to see if export function setCookie(cName: string, cValue: string): void { const expiration = new Date(); - expiration.setTime(new Date().getTime() + 3600000 * 24 * 30 * 3/*7*/); + 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()}`; } @@ -324,7 +327,7 @@ export async function localPing() { } /** Alias for the constructor of a class */ -export type Constructor = new(...args: unknown[]) => T; +export type Constructor = new (...args: unknown[]) => T; export class BooleanHolder { public value: boolean; @@ -372,14 +375,18 @@ export function toCamelCaseString(unformattedText: string): string { if (!unformattedText) { return ""; } - return unformattedText.split(/[_ ]/).filter(f => f).map((f, i) => i ? `${f[0].toUpperCase()}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join(""); + return unformattedText + .split(/[_ ]/) + .filter(f => f) + .map((f, i) => (i ? `${f[0].toUpperCase()}${f.slice(1).toLowerCase()}` : f.toLowerCase())) + .join(""); } export function rgbToHsv(r: number, g: number, b: number) { const v = Math.max(r, g, b); const c = v - Math.min(r, g, b); - const h = c && ((v === r) ? (g - b) / c : ((v === g) ? 2 + (b - r) / c : 4 + (r - g) / c)); - return [ 60 * (h < 0 ? h + 6 : h), v && c / v, v ]; + const h = c && (v === r ? (g - b) / c : v === g ? 2 + (b - r) / c : 4 + (r - g) / c); + return [60 * (h < 0 ? h + 6 : h), v && c / v, v]; } /** @@ -388,23 +395,23 @@ export function rgbToHsv(r: number, g: number, b: number) { * @param {Array} rgb2 Second RGB color in array */ export function deltaRgb(rgb1: number[], rgb2: number[]): number { - const [ r1, g1, b1 ] = rgb1; - const [ r2, g2, b2 ] = rgb2; + const [r1, g1, b1] = rgb1; + const [r2, g2, b2] = rgb2; const drp2 = Math.pow(r1 - r2, 2); const dgp2 = Math.pow(g1 - g2, 2); const dbp2 = Math.pow(b1 - b2, 2); const t = (r1 + r2) / 2; - return Math.ceil(Math.sqrt(2 * drp2 + 4 * dgp2 + 3 * dbp2 + t * (drp2 - dbp2) / 256)); + return Math.ceil(Math.sqrt(2 * drp2 + 4 * dgp2 + 3 * dbp2 + (t * (drp2 - dbp2)) / 256)); } export function rgbHexToRgba(hex: string) { - const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i) ?? [ "000000", "00", "00", "00" ]; + const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i) ?? ["000000", "00", "00", "00"]; return { - r: parseInt(color[1], 16), - g: parseInt(color[2], 16), - b: parseInt(color[3], 16), - a: 255 + r: Number.parseInt(color[1], 16), + g: Number.parseInt(color[2], 16), + b: Number.parseInt(color[3], 16), + a: 255, }; } @@ -427,7 +434,9 @@ export function hslToHex(h: number, s: number, l: number): string { const f = (n: number) => { const k = (n + h / 30) % 12; const rgb = l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)); - return Math.round(rgb * 255).toString(16).padStart(2, "0"); + return Math.round(rgb * 255) + .toString(16) + .padStart(2, "0"); }; return `#${f(0)}${f(8)}${f(4)}`; } @@ -438,7 +447,7 @@ export function hslToHex(h: number, s: number, l: number): string { * If the lang is not in the function, it usually means that lang is going to use the default english version * * English itself counts as not available -*/ + */ export function hasAllLocalizedSprites(lang?: string): boolean { // IMPORTANT - ONLY ADD YOUR LANG HERE IF YOU'VE ALREADY ADDED ALL THE NECESSARY IMAGES if (!lang) { @@ -466,12 +475,13 @@ export function hasAllLocalizedSprites(lang?: string): boolean { * @param container container with game objects inside it */ export function printContainerList(container: Phaser.GameObjects.Container): void { - console.log(container.list.map(go => { - return { type: go.type, name: go.name }; - })); + console.log( + container.list.map(go => { + return { type: go.type, name: go.name }; + }), + ); } - /** * Truncate a string to a specified maximum length and add an ellipsis if it exceeds that length. * @@ -479,7 +489,7 @@ export function printContainerList(container: Phaser.GameObjects.Container): voi * @param maxLength - The maximum length of the truncated string, defaults to 10. * @returns The truncated string with an ellipsis if it was longer than maxLength. */ -export function truncateString(str: String, maxLength: number = 10) { +export function truncateString(str: string, maxLength = 10) { // Check if the string length exceeds the maximum length if (str.length > maxLength) { // Truncate the string and add an ellipsis @@ -524,7 +534,7 @@ export function reverseValueToKeySetting(input) { * @param returnWithSpaces - Whether the returned string should have spaces between the words or not. * @returns The capitalized string. */ -export function capitalizeString(str: string, sep: string, lowerFirstChar: boolean = true, returnWithSpaces: boolean = false) { +export function capitalizeString(str: string, sep: string, lowerFirstChar = true, returnWithSpaces = false) { if (str) { const splitedStr = str.toLowerCase().split(sep); @@ -558,7 +568,7 @@ export function capitalizeFirstLetter(str: string) { * @param minValue - The minimum integer value to return. Defaults to 1. * @returns The converted value as an integer. */ -export function toDmgValue(value: number, minValue: number = 1) { +export function toDmgValue(value: number, minValue = 1) { return Math.max(Math.floor(value), minValue); } diff --git a/test/abilities/ability_duplication.test.ts b/test/abilities/ability_duplication.test.ts index 73092b41ce6..08b74f682f2 100644 --- a/test/abilities/ability_duplication.test.ts +++ b/test/abilities/ability_duplication.test.ts @@ -23,7 +23,7 @@ describe("Ability Duplication", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .battleType("single") .ability(Abilities.HUGE_POWER) .enemyAbility(Abilities.BALL_FETCH) @@ -33,9 +33,9 @@ describe("Ability Duplication", () => { it("huge power should only be applied once if both normal and passive", async () => { game.override.passiveAbility(Abilities.HUGE_POWER); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const [ magikarp ] = game.scene.getPlayerField(); + const [magikarp] = game.scene.getPlayerField(); const magikarpAttack = magikarp.getEffectiveStat(Stat.ATK); magikarp.summonData.abilitySuppressed = true; @@ -46,9 +46,9 @@ describe("Ability Duplication", () => { it("huge power should stack with pure power", async () => { game.override.passiveAbility(Abilities.PURE_POWER); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const [ magikarp ] = game.scene.getPlayerField(); + const [magikarp] = game.scene.getPlayerField(); const magikarpAttack = magikarp.getEffectiveStat(Stat.ATK); magikarp.summonData.abilitySuppressed = true; diff --git a/test/abilities/ability_timing.test.ts b/test/abilities/ability_timing.test.ts index 85332b9cd82..d59c4f7c38d 100644 --- a/test/abilities/ability_timing.test.ts +++ b/test/abilities/ability_timing.test.ts @@ -9,7 +9,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Ability Timing", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -37,12 +36,17 @@ describe("Ability Timing", () => { it("should trigger after switch check", async () => { game.settings.battleStyle = BattleStyle.SWITCH; - await game.classicMode.runToSummon([ Species.EEVEE, Species.FEEBAS ]); + await game.classicMode.runToSummon([Species.EEVEE, Species.FEEBAS]); - game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(TurnInitPhase)); + game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + game.setMode(Mode.MESSAGE); + game.endPhase(); + }, + () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(TurnInitPhase), + ); await game.phaseInterceptor.to("MessagePhase"); expect(i18next.t).toHaveBeenCalledWith("battle:statFell", expect.objectContaining({ count: 1 })); diff --git a/test/abilities/analytic.test.ts b/test/abilities/analytic.test.ts index 45f7bc55006..e488b467ce0 100644 --- a/test/abilities/analytic.test.ts +++ b/test/abilities/analytic.test.ts @@ -24,7 +24,7 @@ describe("Abilities - Analytic", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.TACKLE ]) + .moveset([Moves.SPLASH, Moves.TACKLE]) .ability(Abilities.ANALYTIC) .battleType("single") .disableCrits() @@ -36,45 +36,45 @@ describe("Abilities - Analytic", () => { }); it("should increase damage if the user moves last", async () => { - await game.classicMode.startBattle([ Species.ARCEUS ]); + await game.classicMode.startBattle([Species.ARCEUS]); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); const damage1 = enemy.getInverseHp(); enemy.hp = enemy.getMaxHp(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(isBetween(enemy.getInverseHp(), toDmgValue(damage1 * 1.3) - 3, toDmgValue(damage1 * 1.3) + 3)).toBe(true); }); it("should increase damage only if the user moves last in doubles", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.GENGAR, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.GENGAR, Species.SHUCKLE]); - const [ enemy, ] = game.scene.getEnemyField(); + const [enemy] = game.scene.getEnemyField(); game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.toNextTurn(); const damage1 = enemy.getInverseHp(); enemy.hp = enemy.getMaxHp(); game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(isBetween(enemy.getInverseHp(), toDmgValue(damage1 * 1.3) - 3, toDmgValue(damage1 * 1.3) + 3)).toBe(true); enemy.hp = enemy.getMaxHp(); game.move.select(Moves.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getInverseHp()).toBe(damage1); }); diff --git a/test/abilities/arena_trap.test.ts b/test/abilities/arena_trap.test.ts index dda6e60e886..e0d093a91aa 100644 --- a/test/abilities/arena_trap.test.ts +++ b/test/abilities/arena_trap.test.ts @@ -46,11 +46,7 @@ describe("Abilities - Arena Trap", () => { }); it("should guarantee double battle with any one LURE", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + game.override.startingModifier([{ name: "LURE" }]).startingWave(2); await game.classicMode.startBattle(); @@ -67,12 +63,12 @@ describe("Abilities - Arena Trap", () => { game.override .battleType("double") .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.ROAR, Moves.SPLASH ]) + .moveset([Moves.ROAR, Moves.SPLASH]) .ability(Abilities.BALL_FETCH); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.SUDOWOODO, Species.LUNATONE ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.SUDOWOODO, Species.LUNATONE]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + const [player1, player2] = game.scene.getPlayerField(); vi.spyOn(enemy1, "getAbility").mockReturnValue(allAbilities[Abilities.ARENA_TRAP]); diff --git a/test/abilities/aroma_veil.test.ts b/test/abilities/aroma_veil.test.ts index 111d682aabe..af8a0233a60 100644 --- a/test/abilities/aroma_veil.test.ts +++ b/test/abilities/aroma_veil.test.ts @@ -27,14 +27,14 @@ describe("Moves - Aroma Veil", () => { game.override .battleType("double") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.HEAL_BLOCK, Moves.IMPRISON, Moves.SPLASH ]) + .enemyMoveset([Moves.HEAL_BLOCK, Moves.IMPRISON, Moves.SPLASH]) .enemySpecies(Species.SHUCKLE) .ability(Abilities.AROMA_VEIL) - .moveset([ Moves.GROWL ]); + .moveset([Moves.GROWL]); }); it("Aroma Veil protects the Pokemon's side against most Move Restriction Battler Tags", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); const party = game.scene.getPlayerParty()! as PlayerPokemon[]; @@ -48,7 +48,7 @@ describe("Moves - Aroma Veil", () => { }); it("Aroma Veil does not protect against Imprison", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); const party = game.scene.getPlayerParty()! as PlayerPokemon[]; diff --git a/test/abilities/aura_break.test.ts b/test/abilities/aura_break.test.ts index 017bb2cea06..86b6c69ec8b 100644 --- a/test/abilities/aura_break.test.ts +++ b/test/abilities/aura_break.test.ts @@ -10,7 +10,7 @@ describe("Abilities - Aura Break", () => { let phaserGame: Phaser.Game; let game: GameManager; - const auraBreakMultiplier = 9 / 16 * 4 / 3; + const auraBreakMultiplier = ((9 / 16) * 4) / 3; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -25,7 +25,7 @@ describe("Abilities - Aura Break", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.moveset([ Moves.MOONBLAST, Moves.DARK_PULSE, Moves.MOONBLAST, Moves.DARK_PULSE ]); + game.override.moveset([Moves.MOONBLAST, Moves.DARK_PULSE, Moves.MOONBLAST, Moves.DARK_PULSE]); game.override.enemyMoveset(Moves.SPLASH); game.override.enemyAbility(Abilities.AURA_BREAK); game.override.enemySpecies(Species.SHUCKLE); @@ -38,7 +38,7 @@ describe("Abilities - Aura Break", () => { game.override.ability(Abilities.FAIRY_AURA); vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.MOONBLAST); await game.phaseInterceptor.to("MoveEffectPhase"); @@ -52,7 +52,7 @@ describe("Abilities - Aura Break", () => { game.override.ability(Abilities.DARK_AURA); vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.DARK_PULSE); await game.phaseInterceptor.to("MoveEffectPhase"); @@ -66,7 +66,7 @@ describe("Abilities - Aura Break", () => { game.override.ability(Abilities.BALL_FETCH); vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.MOONBLAST); await game.phaseInterceptor.to("MoveEffectPhase"); diff --git a/test/abilities/battery.test.ts b/test/abilities/battery.test.ts index 7ce37f472f0..cc7570c3d31 100644 --- a/test/abilities/battery.test.ts +++ b/test/abilities/battery.test.ts @@ -29,7 +29,7 @@ describe("Abilities - Battery", () => { game.override.battleType("double"); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.moveset([ Moves.TACKLE, Moves.BREAKING_SWIPE, Moves.SPLASH, Moves.DAZZLING_GLEAM ]); + game.override.moveset([Moves.TACKLE, Moves.BREAKING_SWIPE, Moves.SPLASH, Moves.DAZZLING_GLEAM]); game.override.enemyMoveset(Moves.SPLASH); }); @@ -39,7 +39,7 @@ describe("Abilities - Battery", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.PIKACHU, Species.CHARJABUG ]); + await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); game.move.select(Moves.DAZZLING_GLEAM); game.move.select(Moves.SPLASH, 1); @@ -54,7 +54,7 @@ describe("Abilities - Battery", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.PIKACHU, Species.CHARJABUG ]); + await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); game.move.select(Moves.BREAKING_SWIPE); game.move.select(Moves.SPLASH, 1); @@ -69,7 +69,7 @@ describe("Abilities - Battery", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.CHARJABUG, Species.PIKACHU ]); + await game.startBattle([Species.CHARJABUG, Species.PIKACHU]); game.move.select(Moves.DAZZLING_GLEAM); game.move.select(Moves.SPLASH, 1); diff --git a/test/abilities/battle_bond.test.ts b/test/abilities/battle_bond.test.ts index b2ba9ceedd9..6305d7dedc5 100644 --- a/test/abilities/battle_bond.test.ts +++ b/test/abilities/battle_bond.test.ts @@ -8,7 +8,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Abilities - BATTLE BOND", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,11 +27,12 @@ describe("Abilities - BATTLE BOND", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .startingWave(4) // Leads to arena reset on Wave 5 trainer battle .ability(Abilities.BATTLE_BOND) - .starterForms({ [Species.GRENINJA]: ashForm, }) - .moveset([ Moves.SPLASH, Moves.WATER_SHURIKEN ]) + .starterForms({ [Species.GRENINJA]: ashForm }) + .moveset([Moves.SPLASH, Moves.WATER_SHURIKEN]) .enemySpecies(Species.BULBASAUR) .enemyMoveset(Moves.SPLASH) .startingLevel(100) // Avoid levelling up @@ -40,7 +40,7 @@ describe("Abilities - BATTLE BOND", () => { }); it("check if fainted pokemon switches to base form on arena reset", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.GRENINJA ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.GRENINJA]); const greninja = game.scene.getPlayerParty()[1]; expect(greninja.formIndex).toBe(ashForm); @@ -59,7 +59,7 @@ describe("Abilities - BATTLE BOND", () => { }); it("should not keep buffing Water Shuriken after Greninja switches to base form", async () => { - await game.classicMode.startBattle([ Species.GRENINJA ]); + await game.classicMode.startBattle([Species.GRENINJA]); const waterShuriken = allMoves[Moves.WATER_SHURIKEN]; vi.spyOn(waterShuriken, "calculateBattlePower"); diff --git a/test/abilities/beast_boost.test.ts b/test/abilities/beast_boost.test.ts index c9877709467..b307a9eeeba 100644 --- a/test/abilities/beast_boost.test.ts +++ b/test/abilities/beast_boost.test.ts @@ -29,16 +29,16 @@ describe("Abilities - Beast Boost", () => { .enemyAbility(Abilities.BEAST_BOOST) .ability(Abilities.BEAST_BOOST) .startingLevel(2000) - .moveset([ Moves.FLAMETHROWER ]) + .moveset([Moves.FLAMETHROWER]) .enemyMoveset(Moves.SPLASH); }); - it("should prefer highest stat to boost its corresponding stat stage by 1 when winning a battle", async() => { - await game.classicMode.startBattle([ Species.SLOWBRO ]); + it("should prefer highest stat to boost its corresponding stat stage by 1 when winning a battle", async () => { + await game.classicMode.startBattle([Species.SLOWBRO]); const playerPokemon = game.scene.getPlayerPokemon()!; // Set the pokemon's highest stat to DEF, so it should be picked by Beast Boost - vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([ 10000, 100, 1000, 200, 100, 100 ]); + vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([10000, 100, 1000, 200, 100, 100]); console.log(playerPokemon.stats); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0); @@ -49,33 +49,33 @@ describe("Abilities - Beast Boost", () => { expect(playerPokemon.getStatStage(Stat.DEF)).toBe(1); }, 20000); - it("should use in-battle overriden stats when determining the stat stage to raise by 1", async() => { - game.override.enemyMoveset([ Moves.GUARD_SPLIT ]); + it("should use in-battle overriden stats when determining the stat stage to raise by 1", async () => { + game.override.enemyMoveset([Moves.GUARD_SPLIT]); - await game.classicMode.startBattle([ Species.SLOWBRO ]); + await game.classicMode.startBattle([Species.SLOWBRO]); const playerPokemon = game.scene.getPlayerPokemon()!; // If the opponent uses Guard Split, the pokemon's second highest stat (SPATK) should be chosen - vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([ 10000, 100, 201, 200, 100, 100 ]); + vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([10000, 100, 201, 200, 100, 100]); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0); game.move.select(Moves.FLAMETHROWER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("VictoryPhase"); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1); }, 20000); - it("should have order preference in case of stat ties", async() => { + it("should have order preference in case of stat ties", async () => { // Order preference follows the order of EFFECTIVE_STAT - await game.classicMode.startBattle([ Species.SLOWBRO ]); + await game.classicMode.startBattle([Species.SLOWBRO]); const playerPokemon = game.scene.getPlayerPokemon()!; // Set up tie between SPATK, SPDEF, and SPD, where SPATK should win - vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([ 10000, 1, 1, 100, 100, 100 ]); + vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([10000, 1, 1, 100, 100, 100]); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0); diff --git a/test/abilities/commander.test.ts b/test/abilities/commander.test.ts index 1b054bbd5ea..9d16d474dd4 100644 --- a/test/abilities/commander.test.ts +++ b/test/abilities/commander.test.ts @@ -32,7 +32,7 @@ describe("Abilities - Commander", () => { game.override .startingLevel(100) .enemyLevel(100) - .moveset([ Moves.LIQUIDATION, Moves.MEMENTO, Moves.SPLASH, Moves.FLIP_TURN ]) + .moveset([Moves.LIQUIDATION, Moves.MEMENTO, Moves.SPLASH, Moves.FLIP_TURN]) .ability(Abilities.COMMANDER) .battleType("double") .disableCrits() @@ -44,15 +44,15 @@ describe("Abilities - Commander", () => { }); it("causes the source to jump into Dondozo's mouth, granting a stat boost and hiding the source", async () => { - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); - const affectedStats: EffectiveStat[] = [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + const affectedStats: EffectiveStat[] = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); - affectedStats.forEach((stat) => expect(dondozo.getStatStage(stat)).toBe(2)); + affectedStats.forEach(stat => expect(dondozo.getStatStage(stat)).toBe(2)); game.move.select(Moves.SPLASH, 1); @@ -70,7 +70,7 @@ describe("Abilities - Commander", () => { it("should activate when a Dondozo switches in and cancel the source's move", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.MAGIKARP, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.MAGIKARP, Species.DONDOZO]); const tatsugiri = game.scene.getPlayerField()[0]; @@ -89,9 +89,9 @@ describe("Abilities - Commander", () => { }); it("source should reenter the field when Dondozo faints", async () => { - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); @@ -103,7 +103,7 @@ describe("Abilities - Commander", () => { await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("FaintPhase", false); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeUndefined(); @@ -114,13 +114,11 @@ describe("Abilities - Commander", () => { }); it("source should still take damage from Poison while hidden", async () => { - game.override - .statusEffect(StatusEffect.POISON) - .enemyMoveset(Moves.SPLASH); + game.override.statusEffect(StatusEffect.POISON).enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); @@ -136,9 +134,9 @@ describe("Abilities - Commander", () => { it("source should still take damage from Salt Cure while hidden", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); @@ -154,13 +152,11 @@ describe("Abilities - Commander", () => { }); it("source should still take damage from Sandstorm while hidden", async () => { - game.override - .weather(WeatherType.SANDSTORM) - .enemyMoveset(Moves.SPLASH); + game.override.weather(WeatherType.SANDSTORM).enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); @@ -174,11 +170,11 @@ describe("Abilities - Commander", () => { }); it("should make Dondozo immune to being forced out", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.WHIRLWIND]); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); @@ -196,11 +192,9 @@ describe("Abilities - Commander", () => { }); it("should interrupt the source's semi-invulnerability", async () => { - game.override - .moveset([ Moves.SPLASH, Moves.DIVE ]) - .enemyMoveset(Moves.SPLASH); + game.override.moveset([Moves.SPLASH, Moves.DIVE]).enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.MAGIKARP, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.MAGIKARP, Species.DONDOZO]); const tatsugiri = game.scene.getPlayerField()[0]; diff --git a/test/abilities/competitive.test.ts b/test/abilities/competitive.test.ts index e4baf9b9855..cad35be18f7 100644 --- a/test/abilities/competitive.test.ts +++ b/test/abilities/competitive.test.ts @@ -24,16 +24,17 @@ describe("Abilities - Competitive", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .enemySpecies(Species.BEEDRILL) .enemyMoveset(Moves.TICKLE) .startingLevel(1) - .moveset([ Moves.SPLASH, Moves.CLOSE_COMBAT ]) + .moveset([Moves.SPLASH, Moves.CLOSE_COMBAT]) .ability(Abilities.COMPETITIVE); }); it("lower atk and def by 1 via tickle, then increase spatk by 4 via competitive", async () => { - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); @@ -46,7 +47,7 @@ describe("Abilities - Competitive", () => { it("lowering your own stats should not trigger competitive", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.CLOSE_COMBAT); @@ -59,7 +60,7 @@ describe("Abilities - Competitive", () => { it("white herb should remove only the negative effects", async () => { game.override.startingHeldItems([{ name: "WHITE_HERB" }]); - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); diff --git a/test/abilities/contrary.test.ts b/test/abilities/contrary.test.ts index eaf8d885a83..19041eb2801 100644 --- a/test/abilities/contrary.test.ts +++ b/test/abilities/contrary.test.ts @@ -30,10 +30,8 @@ describe("Abilities - Contrary", () => { .enemyMoveset(Moves.SPLASH); }); - it("should invert stat changes when applied", async() => { - await game.classicMode.startBattle([ - Species.SLOWBRO - ]); + it("should invert stat changes when applied", async () => { + await game.classicMode.startBattle([Species.SLOWBRO]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -42,10 +40,8 @@ describe("Abilities - Contrary", () => { describe("With Clear Body", () => { it("should apply positive effects", async () => { - game.override - .enemyPassiveAbility(Abilities.CLEAR_BODY) - .moveset([ Moves.TAIL_WHIP ]); - await game.classicMode.startBattle([ Species.SLOWBRO ]); + game.override.enemyPassiveAbility(Abilities.CLEAR_BODY).moveset([Moves.TAIL_WHIP]); + await game.classicMode.startBattle([Species.SLOWBRO]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -60,9 +56,9 @@ describe("Abilities - Contrary", () => { it("should block negative effects", async () => { game.override .enemyPassiveAbility(Abilities.CLEAR_BODY) - .enemyMoveset([ Moves.HOWL, Moves.HOWL, Moves.HOWL, Moves.HOWL ]) - .moveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.SLOWBRO ]); + .enemyMoveset([Moves.HOWL, Moves.HOWL, Moves.HOWL, Moves.HOWL]) + .moveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.SLOWBRO]); const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/corrosion.test.ts b/test/abilities/corrosion.test.ts index 2829c3c3b41..b7f316fbe2d 100644 --- a/test/abilities/corrosion.test.ts +++ b/test/abilities/corrosion.test.ts @@ -22,7 +22,7 @@ describe("Abilities - Corrosion", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .battleType("single") .disableCrits() .enemySpecies(Species.GRIMER) @@ -32,7 +32,7 @@ describe("Abilities - Corrosion", () => { it("If a Poison- or Steel-type Pokémon with this Ability poisons a target with Synchronize, Synchronize does not gain the ability to poison Poison- or Steel-type Pokémon.", async () => { game.override.ability(Abilities.SYNCHRONIZE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); const enemyPokemon = game.scene.getEnemyPokemon(); diff --git a/test/abilities/costar.test.ts b/test/abilities/costar.test.ts index 09b724a07ec..c6a44bffe54 100644 --- a/test/abilities/costar.test.ts +++ b/test/abilities/costar.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - COSTAR", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,59 +26,52 @@ describe("Abilities - COSTAR", () => { game = new GameManager(phaserGame); game.override.battleType("double"); game.override.ability(Abilities.COSTAR); - game.override.moveset([ Moves.SPLASH, Moves.NASTY_PLOT ]); + game.override.moveset([Moves.SPLASH, Moves.NASTY_PLOT]); game.override.enemyMoveset(Moves.SPLASH); }); + test("ability copies positive stat stages", async () => { + game.override.enemyAbility(Abilities.BALL_FETCH); - test( - "ability copies positive stat stages", - async () => { - game.override.enemyAbility(Abilities.BALL_FETCH); + await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO]); - await game.startBattle([ Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO ]); + let [leftPokemon, rightPokemon] = game.scene.getPlayerField(); - let [ leftPokemon, rightPokemon ] = game.scene.getPlayerField(); + game.move.select(Moves.NASTY_PLOT); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); - game.move.select(Moves.NASTY_PLOT); - await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); - await game.toNextTurn(); + expect(leftPokemon.getStatStage(Stat.SPATK)).toBe(2); + expect(rightPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(leftPokemon.getStatStage(Stat.SPATK)).toBe(2); - expect(rightPokemon.getStatStage(Stat.SPATK)).toBe(0); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(CommandPhase); + game.doSwitchPokemon(2); + await game.phaseInterceptor.to(MessagePhase); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(CommandPhase); - game.doSwitchPokemon(2); - await game.phaseInterceptor.to(MessagePhase); + [leftPokemon, rightPokemon] = game.scene.getPlayerField(); + expect(leftPokemon.getStatStage(Stat.SPATK)).toBe(2); + expect(rightPokemon.getStatStage(Stat.SPATK)).toBe(2); + }); - [ leftPokemon, rightPokemon ] = game.scene.getPlayerField(); - expect(leftPokemon.getStatStage(Stat.SPATK)).toBe(2); - expect(rightPokemon.getStatStage(Stat.SPATK)).toBe(2); - }, - ); + test("ability copies negative stat stages", async () => { + game.override.enemyAbility(Abilities.INTIMIDATE); - test( - "ability copies negative stat stages", - async () => { - game.override.enemyAbility(Abilities.INTIMIDATE); + await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO]); - await game.startBattle([ Species.MAGIKARP, Species.MAGIKARP, Species.FLAMIGO ]); + let [leftPokemon, rightPokemon] = game.scene.getPlayerField(); - let [ leftPokemon, rightPokemon ] = game.scene.getPlayerField(); + expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); + expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); - expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); - expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(CommandPhase); + game.doSwitchPokemon(2); + await game.phaseInterceptor.to(MessagePhase); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(CommandPhase); - game.doSwitchPokemon(2); - await game.phaseInterceptor.to(MessagePhase); - - [ leftPokemon, rightPokemon ] = game.scene.getPlayerField(); - expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); - expect(rightPokemon.getStatStage(Stat.ATK)).toBe(-2); - }, - ); + [leftPokemon, rightPokemon] = game.scene.getPlayerField(); + expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); + expect(rightPokemon.getStatStage(Stat.ATK)).toBe(-2); + }); }); diff --git a/test/abilities/dancer.test.ts b/test/abilities/dancer.test.ts index 99d8a6d588d..56c357b2212 100644 --- a/test/abilities/dancer.test.ts +++ b/test/abilities/dancer.test.ts @@ -29,19 +29,16 @@ describe("Abilities - Dancer", () => { // Reference Link: https://bulbapedia.bulbagarden.net/wiki/Dancer_(Ability) it("triggers when dance moves are used, doesn't consume extra PP", async () => { - game.override - .enemyAbility(Abilities.DANCER) - .enemySpecies(Species.MAGIKARP) - .enemyMoveset(Moves.VICTORY_DANCE); - await game.classicMode.startBattle([ Species.ORICORIO, Species.FEEBAS ]); + game.override.enemyAbility(Abilities.DANCER).enemySpecies(Species.MAGIKARP).enemyMoveset(Moves.VICTORY_DANCE); + await game.classicMode.startBattle([Species.ORICORIO, Species.FEEBAS]); - const [ oricorio, feebas ] = game.scene.getPlayerField(); - game.move.changeMoveset(oricorio, [ Moves.SWORDS_DANCE, Moves.VICTORY_DANCE, Moves.SPLASH ]); - game.move.changeMoveset(feebas, [ Moves.SWORDS_DANCE, Moves.SPLASH ]); + const [oricorio, feebas] = game.scene.getPlayerField(); + game.move.changeMoveset(oricorio, [Moves.SWORDS_DANCE, Moves.VICTORY_DANCE, Moves.SPLASH]); + game.move.changeMoveset(feebas, [Moves.SWORDS_DANCE, Moves.SPLASH]); game.move.select(Moves.SPLASH); game.move.select(Moves.SWORDS_DANCE, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MovePhase"); // immediately copies ally move await game.phaseInterceptor.to("MovePhase", false); @@ -65,20 +62,20 @@ describe("Abilities - Dancer", () => { // TODO: Enable after Dancer rework to not push to move history it.todo("should not count as the last move used for mirror move/instruct", async () => { game.override - .moveset([ Moves.FIERY_DANCE, Moves.REVELATION_DANCE ]) - .enemyMoveset([ Moves.INSTRUCT, Moves.MIRROR_MOVE, Moves.SPLASH ]) + .moveset([Moves.FIERY_DANCE, Moves.REVELATION_DANCE]) + .enemyMoveset([Moves.INSTRUCT, Moves.MIRROR_MOVE, Moves.SPLASH]) .enemySpecies(Species.SHUCKLE) .enemyLevel(10); - await game.classicMode.startBattle([ Species.ORICORIO, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.ORICORIO, Species.FEEBAS]); - const [ oricorio ] = game.scene.getPlayerField(); - const [ , shuckle2 ] = game.scene.getEnemyField(); + const [oricorio] = game.scene.getPlayerField(); + const [, shuckle2] = game.scene.getEnemyField(); game.move.select(Moves.REVELATION_DANCE, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2); game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2); await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.MIRROR_MOVE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MovePhase"); // Oricorio rev dance await game.phaseInterceptor.to("MovePhase"); // Feebas fiery dance await game.phaseInterceptor.to("MovePhase"); // Oricorio fiery dance (from dancer) @@ -97,6 +94,5 @@ describe("Abilities - Dancer", () => { currentPhase = game.scene.getCurrentPhase() as MovePhase; expect(currentPhase.pokemon).toBe(oricorio); expect(currentPhase.move.moveId).toBe(Moves.REVELATION_DANCE); - }); }); diff --git a/test/abilities/defiant.test.ts b/test/abilities/defiant.test.ts index ce8c7bac8b3..a73002d999c 100644 --- a/test/abilities/defiant.test.ts +++ b/test/abilities/defiant.test.ts @@ -24,16 +24,17 @@ describe("Abilities - Defiant", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .enemySpecies(Species.BEEDRILL) .enemyMoveset(Moves.TICKLE) .startingLevel(1) - .moveset([ Moves.SPLASH, Moves.CLOSE_COMBAT ]) + .moveset([Moves.SPLASH, Moves.CLOSE_COMBAT]) .ability(Abilities.DEFIANT); }); it("lower atk and def by 1 via tickle, then increase atk by 4 via defiant", async () => { - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); @@ -45,7 +46,7 @@ describe("Abilities - Defiant", () => { it("lowering your own stats should not trigger defiant", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.CLOSE_COMBAT); @@ -58,7 +59,7 @@ describe("Abilities - Defiant", () => { it("white herb should remove only the negative effects", async () => { game.override.startingHeldItems([{ name: "WHITE_HERB" }]); - await game.classicMode.startBattle([ Species.FLYGON ]); + await game.classicMode.startBattle([Species.FLYGON]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); diff --git a/test/abilities/desolate-land.test.ts b/test/abilities/desolate-land.test.ts index 4aa44c97404..67d9ac1cdf5 100644 --- a/test/abilities/desolate-land.test.ts +++ b/test/abilities/desolate-land.test.ts @@ -36,14 +36,12 @@ describe("Abilities - Desolate Land", () => { * is forcefully moved out of the field from moves such as Roar {@linkcode Moves.ROAR} */ it("should lift only when all pokemon with this ability leave the field", async () => { - game.override - .battleType("double") - .enemyMoveset([ Moves.SPLASH, Moves.ROAR ]); - await game.classicMode.startBattle([ Species.MAGCARGO, Species.MAGCARGO, Species.MAGIKARP, Species.MAGIKARP ]); + game.override.battleType("double").enemyMoveset([Moves.SPLASH, Moves.ROAR]); + await game.classicMode.startBattle([Species.MAGCARGO, Species.MAGCARGO, Species.MAGIKARP, Species.MAGIKARP]); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); @@ -59,7 +57,7 @@ describe("Abilities - Desolate Land", () => { await game.toNextTurn(); - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min + 1; }); @@ -77,14 +75,14 @@ describe("Abilities - Desolate Land", () => { it("should lift when enemy faints", async () => { game.override .battleType("single") - .moveset([ Moves.SHEER_COLD ]) + .moveset([Moves.SHEER_COLD]) .ability(Abilities.NO_GUARD) .startingLevel(100) .enemyLevel(1) - .enemyMoveset([ Moves.SPLASH ]) + .enemyMoveset([Moves.SPLASH]) .enemySpecies(Species.MAGCARGO) .enemyHasPassiveAbility(true); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); @@ -96,11 +94,8 @@ describe("Abilities - Desolate Land", () => { }); it("should lift when pokemon returns upon switching from double to single battle", async () => { - game.override - .battleType("even-doubles") - .enemyMoveset([ Moves.SPLASH, Moves.MEMENTO ]) - .startingWave(12); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGCARGO ]); + game.override.battleType("even-doubles").enemyMoveset([Moves.SPLASH, Moves.MEMENTO]).startingWave(12); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGCARGO]); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); @@ -121,10 +116,10 @@ describe("Abilities - Desolate Land", () => { it("should lift when enemy is captured", async () => { game.override .battleType("single") - .enemyMoveset([ Moves.SPLASH ]) + .enemyMoveset([Moves.SPLASH]) .enemySpecies(Species.MAGCARGO) .enemyHasPassiveAbility(true); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.HARSH_SUN); diff --git a/test/abilities/disguise.test.ts b/test/abilities/disguise.test.ts index cb875e23019..a971f5c2733 100644 --- a/test/abilities/disguise.test.ts +++ b/test/abilities/disguise.test.ts @@ -8,7 +8,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Disguise", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -32,7 +31,7 @@ describe("Abilities - Disguise", () => { .enemySpecies(Species.MIMIKYU) .enemyMoveset(Moves.SPLASH) .starterSpecies(Species.REGIELEKI) - .moveset([ Moves.SHADOW_SNEAK, Moves.VACUUM_WAVE, Moves.TOXIC_THREAD, Moves.SPLASH ]); + .moveset([Moves.SHADOW_SNEAK, Moves.VACUUM_WAVE, Moves.TOXIC_THREAD, Moves.SPLASH]); }); it("takes no damage from attacking move and transforms to Busted form, takes 1/8 max HP damage from the disguise breaking", async () => { @@ -67,7 +66,7 @@ describe("Abilities - Disguise", () => { }); it("takes no damage from the first hit of a multihit move and transforms to Busted form, then takes damage from the second hit", async () => { - game.override.moveset([ Moves.SURGING_STRIKES ]); + game.override.moveset([Moves.SURGING_STRIKES]); game.override.enemyLevel(5); await game.classicMode.startBattle(); @@ -107,10 +106,10 @@ describe("Abilities - Disguise", () => { }); it("persists form change when switched out", async () => { - game.override.enemyMoveset([ Moves.SHADOW_SNEAK ]); + game.override.enemyMoveset([Moves.SHADOW_SNEAK]); game.override.starterSpecies(0); - await game.classicMode.startBattle([ Species.MIMIKYU, Species.FURRET ]); + await game.classicMode.startBattle([Species.MIMIKYU, Species.FURRET]); const mimikyu = game.scene.getPlayerPokemon()!; const maxHp = mimikyu.getMaxHp(); @@ -134,9 +133,9 @@ describe("Abilities - Disguise", () => { it("persists form change when wave changes with no arena reset", async () => { game.override.starterSpecies(0); game.override.starterForms({ - [Species.MIMIKYU]: bustedForm + [Species.MIMIKYU]: bustedForm, }); - await game.classicMode.startBattle([ Species.FURRET, Species.MIMIKYU ]); + await game.classicMode.startBattle([Species.FURRET, Species.MIMIKYU]); const mimikyu = game.scene.getPlayerParty()[1]!; expect(mimikyu.formIndex).toBe(bustedForm); @@ -152,7 +151,7 @@ describe("Abilities - Disguise", () => { game.override.startingWave(4); game.override.starterSpecies(Species.MIMIKYU); game.override.starterForms({ - [Species.MIMIKYU]: bustedForm + [Species.MIMIKYU]: bustedForm, }); await game.classicMode.startBattle(); @@ -172,10 +171,10 @@ describe("Abilities - Disguise", () => { game.override.startingWave(10); game.override.starterSpecies(0); game.override.starterForms({ - [Species.MIMIKYU]: bustedForm + [Species.MIMIKYU]: bustedForm, }); - await game.classicMode.startBattle([ Species.MIMIKYU, Species.FURRET ]); + await game.classicMode.startBattle([Species.MIMIKYU, Species.FURRET]); const mimikyu1 = game.scene.getPlayerPokemon()!; @@ -193,7 +192,7 @@ describe("Abilities - Disguise", () => { }); it("doesn't faint twice when fainting due to Disguise break damage, nor prevent faint from Disguise break damage if using Endure", async () => { - game.override.enemyMoveset([ Moves.ENDURE ]); + game.override.enemyMoveset([Moves.ENDURE]); await game.classicMode.startBattle(); const mimikyu = game.scene.getEnemyPokemon()!; @@ -208,7 +207,7 @@ describe("Abilities - Disguise", () => { it("activates when Aerilate circumvents immunity to the move's base type", async () => { game.override.ability(Abilities.AERILATE); - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); await game.classicMode.startBattle(); @@ -225,13 +224,11 @@ describe("Abilities - Disguise", () => { }); it("doesn't trigger if user is behind a substitute", async () => { - game.override - .enemyMoveset(Moves.SUBSTITUTE) - .moveset(Moves.POWER_TRIP); + game.override.enemyMoveset(Moves.SUBSTITUTE).moveset(Moves.POWER_TRIP); await game.classicMode.startBattle(); game.move.select(Moves.POWER_TRIP); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.formIndex).toBe(disguisedForm); diff --git a/test/abilities/dry_skin.test.ts b/test/abilities/dry_skin.test.ts index f3a67f0c1fd..9d8a29c431a 100644 --- a/test/abilities/dry_skin.test.ts +++ b/test/abilities/dry_skin.test.ts @@ -28,7 +28,7 @@ describe("Abilities - Dry Skin", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.CHARMANDER) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.SUNNY_DAY, Moves.RAIN_DANCE, Moves.SPLASH, Moves.WATER_GUN ]) + .moveset([Moves.SUNNY_DAY, Moves.RAIN_DANCE, Moves.SPLASH, Moves.WATER_GUN]) .starterSpecies(Species.CHANDELURE); }); @@ -69,7 +69,7 @@ describe("Abilities - Dry Skin", () => { }); it("opposing fire attacks do 25% more damage", async () => { - game.override.moveset([ Moves.FLAMETHROWER ]); + game.override.moveset([Moves.FLAMETHROWER]); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; @@ -105,7 +105,7 @@ describe("Abilities - Dry Skin", () => { }); it("opposing water attacks do not heal if they were protected from", async () => { - game.override.enemyMoveset([ Moves.PROTECT ]); + game.override.enemyMoveset([Moves.PROTECT]); await game.classicMode.startBattle(); @@ -119,7 +119,7 @@ describe("Abilities - Dry Skin", () => { }); it("multi-strike water attacks only heal once", async () => { - game.override.moveset([ Moves.WATER_GUN, Moves.WATER_SHURIKEN ]); + game.override.moveset([Moves.WATER_GUN, Moves.WATER_SHURIKEN]); await game.classicMode.startBattle(); diff --git a/test/abilities/early_bird.test.ts b/test/abilities/early_bird.test.ts index 5889cfe2f89..cc486672c95 100644 --- a/test/abilities/early_bird.test.ts +++ b/test/abilities/early_bird.test.ts @@ -25,7 +25,7 @@ describe("Abilities - Early Bird", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.REST, Moves.BELLY_DRUM, Moves.SPLASH ]) + .moveset([Moves.REST, Moves.BELLY_DRUM, Moves.SPLASH]) .ability(Abilities.EARLY_BIRD) .battleType("single") .disableCrits() @@ -35,7 +35,7 @@ describe("Abilities - Early Bird", () => { }); it("reduces Rest's sleep time to 1 turn", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; @@ -60,7 +60,7 @@ describe("Abilities - Early Bird", () => { }); it("reduces 3-turn sleep to 1 turn", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; player.status = new Status(StatusEffect.SLEEP, 0, 4); @@ -79,7 +79,7 @@ describe("Abilities - Early Bird", () => { }); it("reduces 1-turn sleep to 0 turns", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; player.status = new Status(StatusEffect.SLEEP, 0, 2); diff --git a/test/abilities/flash_fire.test.ts b/test/abilities/flash_fire.test.ts index 1c94c694b29..3cec9cd9cb7 100644 --- a/test/abilities/flash_fire.test.ts +++ b/test/abilities/flash_fire.test.ts @@ -35,10 +35,9 @@ describe("Abilities - Flash Fire", () => { .disableCrits(); }); - it("immune to Fire-type moves", async () => { - game.override.enemyMoveset([ Moves.EMBER ]).moveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.BLISSEY ]); + game.override.enemyMoveset([Moves.EMBER]).moveset(Moves.SPLASH); + await game.classicMode.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; @@ -48,8 +47,8 @@ describe("Abilities - Flash Fire", () => { }, 20000); it("not activate if the Pokémon is protected from the Fire-type move", async () => { - game.override.enemyMoveset([ Moves.EMBER ]).moveset([ Moves.PROTECT ]); - await game.classicMode.startBattle([ Species.BLISSEY ]); + game.override.enemyMoveset([Moves.EMBER]).moveset([Moves.PROTECT]); + await game.classicMode.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; @@ -59,8 +58,8 @@ describe("Abilities - Flash Fire", () => { }, 20000); it("activated by Will-O-Wisp", async () => { - game.override.enemyMoveset([ Moves.WILL_O_WISP ]).moveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.BLISSEY ]); + game.override.enemyMoveset([Moves.WILL_O_WISP]).moveset(Moves.SPLASH); + await game.classicMode.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; @@ -74,9 +73,9 @@ describe("Abilities - Flash Fire", () => { }, 20000); it("activated after being frozen", async () => { - game.override.enemyMoveset([ Moves.EMBER ]).moveset(Moves.SPLASH); + game.override.enemyMoveset([Moves.EMBER]).moveset(Moves.SPLASH); game.override.statusEffect(StatusEffect.FREEZE); - await game.classicMode.startBattle([ Species.BLISSEY ]); + await game.classicMode.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; @@ -87,12 +86,12 @@ describe("Abilities - Flash Fire", () => { }, 20000); it("not passing with baton pass", async () => { - game.override.enemyMoveset([ Moves.EMBER ]).moveset([ Moves.BATON_PASS ]); - await game.classicMode.startBattle([ Species.BLISSEY, Species.CHANSEY ]); + game.override.enemyMoveset([Moves.EMBER]).moveset([Moves.BATON_PASS]); + await game.classicMode.startBattle([Species.BLISSEY, Species.CHANSEY]); // ensure use baton pass after enemy moved game.move.select(Moves.BATON_PASS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); @@ -103,16 +102,16 @@ describe("Abilities - Flash Fire", () => { }, 20000); it("boosts Fire-type move when the ability is activated", async () => { - game.override.enemyMoveset([ Moves.FIRE_PLEDGE ]).moveset([ Moves.EMBER, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.FIRE_PLEDGE]).moveset([Moves.EMBER, Moves.SPLASH]); game.override.enemyAbility(Abilities.FLASH_FIRE).ability(Abilities.NONE); - await game.classicMode.startBattle([ Species.BLISSEY ]); + await game.classicMode.startBattle([Species.BLISSEY]); const blissey = game.scene.getPlayerPokemon()!; const initialHP = 1000; blissey.hp = initialHP; // first turn game.move.select(Moves.EMBER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(TurnEndPhase); const originalDmg = initialHP - blissey.hp; @@ -131,7 +130,7 @@ describe("Abilities - Flash Fire", () => { game.override.moveset(Moves.FIRE_PLEDGE).enemyMoveset(Moves.EMBER); game.override.enemyAbility(Abilities.NONE).ability(Abilities.FLASH_FIRE); game.override.enemySpecies(Species.BLISSEY); - await game.classicMode.startBattle([ Species.RATTATA ]); + await game.classicMode.startBattle([Species.RATTATA]); const blissey = game.scene.getEnemyPokemon()!; const initialHP = 1000; @@ -139,7 +138,7 @@ describe("Abilities - Flash Fire", () => { // first turn game.move.select(Moves.FIRE_PLEDGE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); await game.move.forceMiss(); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/test/abilities/flower_gift.test.ts b/test/abilities/flower_gift.test.ts index 99f4211eeaa..fff509a1f00 100644 --- a/test/abilities/flower_gift.test.ts +++ b/test/abilities/flower_gift.test.ts @@ -21,7 +21,7 @@ describe("Abilities - Flower Gift", () => { */ const testRevertFormAgainstAbility = async (game: GameManager, ability: Abilities) => { game.override.starterForms({ [Species.CASTFORM]: SUNSHINE_FORM }).enemyAbility(ability); - await game.classicMode.startBattle([ Species.CASTFORM ]); + await game.classicMode.startBattle([Species.CASTFORM]); game.move.select(Moves.SPLASH); @@ -41,7 +41,7 @@ describe("Abilities - Flower Gift", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.SKILL_SWAP ]) + .moveset([Moves.SPLASH, Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.SKILL_SWAP]) .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH); @@ -50,9 +50,9 @@ describe("Abilities - Flower Gift", () => { // TODO: Uncomment expect statements when the ability is implemented - currently does not increase stats of allies it("increases the ATK and SPDEF stat stages of the Pokémon with this Ability and its allies by 1.5× during Harsh Sunlight", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.CHERRIM, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.CHERRIM, Species.MAGIKARP]); - const [ cherrim ] = game.scene.getPlayerField(); + const [cherrim] = game.scene.getPlayerField(); const cherrimAtkStat = cherrim.getEffectiveStat(Stat.ATK); const cherrimSpDefStat = cherrim.getEffectiveStat(Stat.SPDEF); @@ -62,7 +62,7 @@ describe("Abilities - Flower Gift", () => { game.move.select(Moves.SUNNY_DAY, 0); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase"); expect(cherrim.formIndex).toBe(SUNSHINE_FORM); @@ -74,7 +74,7 @@ describe("Abilities - Flower Gift", () => { it("changes the Pokemon's form during Harsh Sunlight", async () => { game.override.weather(WeatherType.HARSH_SUN); - await game.classicMode.startBattle([ Species.CHERRIM ]); + await game.classicMode.startBattle([Species.CHERRIM]); const cherrim = game.scene.getPlayerPokemon()!; expect(cherrim.formIndex).toBe(SUNSHINE_FORM); @@ -91,9 +91,9 @@ describe("Abilities - Flower Gift", () => { }); it("reverts to Overcast Form when the Pokémon loses Flower Gift, changes form under Harsh Sunlight/Sunny when it regains it", async () => { - game.override.enemyMoveset([ Moves.SKILL_SWAP ]).weather(WeatherType.HARSH_SUN); + game.override.enemyMoveset([Moves.SKILL_SWAP]).weather(WeatherType.HARSH_SUN); - await game.classicMode.startBattle([ Species.CHERRIM ]); + await game.classicMode.startBattle([Species.CHERRIM]); const cherrim = game.scene.getPlayerPokemon()!; @@ -110,16 +110,16 @@ describe("Abilities - Flower Gift", () => { }); it("reverts to Overcast Form when the Flower Gift is suppressed, changes form under Harsh Sunlight/Sunny when it regains it", async () => { - game.override.enemyMoveset([ Moves.GASTRO_ACID ]).weather(WeatherType.HARSH_SUN); + game.override.enemyMoveset([Moves.GASTRO_ACID]).weather(WeatherType.HARSH_SUN); - await game.classicMode.startBattle([ Species.CHERRIM, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.CHERRIM, Species.MAGIKARP]); const cherrim = game.scene.getPlayerPokemon()!; expect(cherrim.formIndex).toBe(SUNSHINE_FORM); game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(cherrim.summonData.abilitySuppressed).toBe(true); @@ -140,7 +140,7 @@ describe("Abilities - Flower Gift", () => { it("should be in Overcast Form after the user is switched out", async () => { game.override.weather(WeatherType.SUNNY); - await game.classicMode.startBattle([ Species.CASTFORM, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.CASTFORM, Species.MAGIKARP]); const cherrim = game.scene.getPlayerPokemon()!; expect(cherrim.formIndex).toBe(SUNSHINE_FORM); diff --git a/test/abilities/forecast.test.ts b/test/abilities/forecast.test.ts index 31c9942cd98..bdc32604bba 100644 --- a/test/abilities/forecast.test.ts +++ b/test/abilities/forecast.test.ts @@ -30,7 +30,7 @@ describe("Abilities - Forecast", () => { */ const testWeatherFormChange = async (game: GameManager, weather: WeatherType, form: number, initialForm?: number) => { game.override.weather(weather).starterForms({ [Species.CASTFORM]: initialForm }); - await game.startBattle([ Species.CASTFORM ]); + await game.startBattle([Species.CASTFORM]); game.move.select(Moves.SPLASH); @@ -44,7 +44,7 @@ describe("Abilities - Forecast", () => { */ const testRevertFormAgainstAbility = async (game: GameManager, ability: Abilities) => { game.override.starterForms({ [Species.CASTFORM]: SUNNY_FORM }).enemyAbility(ability); - await game.startBattle([ Species.CASTFORM ]); + await game.startBattle([Species.CASTFORM]); game.move.select(Moves.SPLASH); @@ -64,121 +64,132 @@ describe("Abilities - Forecast", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.TACKLE ]) + .moveset([Moves.SPLASH, Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.TACKLE]) .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH); }); - it("changes form based on weather", async () => { - game.override - .moveset([ Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.SNOWSCAPE, Moves.SPLASH ]) - .battleType("double") - .starterForms({ - [Species.KYOGRE]: 1, - [Species.GROUDON]: 1, - [Species.RAYQUAZA]: 1 - }); - await game.startBattle([ Species.CASTFORM, Species.FEEBAS, Species.KYOGRE, Species.GROUDON, Species.RAYQUAZA, Species.ALTARIA ]); + it( + "changes form based on weather", + async () => { + game.override + .moveset([Moves.RAIN_DANCE, Moves.SUNNY_DAY, Moves.SNOWSCAPE, Moves.SPLASH]) + .battleType("double") + .starterForms({ + [Species.KYOGRE]: 1, + [Species.GROUDON]: 1, + [Species.RAYQUAZA]: 1, + }); + await game.startBattle([ + Species.CASTFORM, + Species.FEEBAS, + Species.KYOGRE, + Species.GROUDON, + Species.RAYQUAZA, + Species.ALTARIA, + ]); - vi.spyOn(game.scene.getPlayerParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]); + vi.spyOn(game.scene.getPlayerParty()[5], "getAbility").mockReturnValue(allAbilities[Abilities.CLOUD_NINE]); - const castform = game.scene.getPlayerField()[0]; - expect(castform.formIndex).toBe(NORMAL_FORM); + const castform = game.scene.getPlayerField()[0]; + expect(castform.formIndex).toBe(NORMAL_FORM); - game.move.select(Moves.RAIN_DANCE); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.RAIN_DANCE); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(RAINY_FORM); + expect(castform.formIndex).toBe(RAINY_FORM); - game.move.select(Moves.SUNNY_DAY); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SUNNY_DAY); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SUNNY_FORM); + expect(castform.formIndex).toBe(SUNNY_FORM); - game.move.select(Moves.SNOWSCAPE); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SNOWSCAPE); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SNOWY_FORM); + expect(castform.formIndex).toBe(SNOWY_FORM); - game.override.moveset([ Moves.HAIL, Moves.SANDSTORM, Moves.SNOWSCAPE, Moves.SPLASH ]); + game.override.moveset([Moves.HAIL, Moves.SANDSTORM, Moves.SNOWSCAPE, Moves.SPLASH]); - game.move.select(Moves.SANDSTORM); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SANDSTORM); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(NORMAL_FORM); + expect(castform.formIndex).toBe(NORMAL_FORM); - game.move.select(Moves.HAIL); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.HAIL); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SNOWY_FORM); + expect(castform.formIndex).toBe(SNOWY_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(2); // Feebas now 2, Kyogre 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(2); // Feebas now 2, Kyogre 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(RAINY_FORM); + expect(castform.formIndex).toBe(RAINY_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(3); // Kyogre now 3, Groudon 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(3); // Kyogre now 3, Groudon 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SUNNY_FORM); + expect(castform.formIndex).toBe(SUNNY_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(4); // Groudon now 4, Rayquaza 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(4); // Groudon now 4, Rayquaza 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(NORMAL_FORM); + expect(castform.formIndex).toBe(NORMAL_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(2); // Rayquaza now 2, Feebas 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(2); // Rayquaza now 2, Feebas 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(NORMAL_FORM); + expect(castform.formIndex).toBe(NORMAL_FORM); - game.move.select(Moves.SNOWSCAPE); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SNOWSCAPE); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SNOWY_FORM); + expect(castform.formIndex).toBe(SNOWY_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(5); // Feebas now 5, Altaria 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(5); // Feebas now 5, Altaria 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(NORMAL_FORM); + expect(castform.formIndex).toBe(NORMAL_FORM); - game.move.select(Moves.SPLASH); - game.doSwitchPokemon(5); // Altaria now 5, Feebas 1 - await game.phaseInterceptor.to("MovePhase"); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + game.doSwitchPokemon(5); // Altaria now 5, Feebas 1 + await game.phaseInterceptor.to("MovePhase"); + await game.toNextTurn(); - expect(castform.formIndex).toBe(SNOWY_FORM); + expect(castform.formIndex).toBe(SNOWY_FORM); - game.scene.arena.trySetWeather(WeatherType.FOG, false); - game.move.select(Moves.SPLASH); - game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("TurnStartPhase"); + game.scene.arena.trySetWeather(WeatherType.FOG, false); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); + await game.phaseInterceptor.to("TurnStartPhase"); - expect(castform.formIndex).toBe(NORMAL_FORM); - }, 30 * 1000); + expect(castform.formIndex).toBe(NORMAL_FORM); + }, + 30 * 1000, + ); it("reverts to Normal Form during Clear weather", async () => { await testWeatherFormChange(game, WeatherType.NONE, NORMAL_FORM, SUNNY_FORM); @@ -190,7 +201,7 @@ describe("Abilities - Forecast", () => { it("has no effect on Pokémon other than Castform", async () => { game.override.enemyAbility(Abilities.FORECAST).enemySpecies(Species.SHUCKLE); - await game.startBattle([ Species.CASTFORM ]); + await game.startBattle([Species.CASTFORM]); game.move.select(Moves.RAIN_DANCE); await game.phaseInterceptor.to(TurnEndPhase); @@ -200,8 +211,11 @@ describe("Abilities - Forecast", () => { }); it("reverts to Normal Form when Castform loses Forecast, changes form to match the weather when it regains it", async () => { - game.override.moveset([ Moves.SKILL_SWAP, Moves.WORRY_SEED, Moves.SPLASH ]).weather(WeatherType.RAIN).battleType("double"); - await game.startBattle([ Species.CASTFORM, Species.FEEBAS ]); + game.override + .moveset([Moves.SKILL_SWAP, Moves.WORRY_SEED, Moves.SPLASH]) + .weather(WeatherType.RAIN) + .battleType("double"); + await game.startBattle([Species.CASTFORM, Species.FEEBAS]); const castform = game.scene.getPlayerField()[0]; @@ -209,7 +223,7 @@ describe("Abilities - Forecast", () => { game.move.select(Moves.SKILL_SWAP, 0, BattlerIndex.PLAYER_2); game.move.select(Moves.SKILL_SWAP, 1, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); expect(castform.formIndex).toBe(NORMAL_FORM); @@ -221,22 +235,22 @@ describe("Abilities - Forecast", () => { game.move.select(Moves.SPLASH); game.move.select(Moves.WORRY_SEED, 1, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); expect(castform.formIndex).toBe(NORMAL_FORM); }); it("reverts to Normal Form when Forecast is suppressed, changes form to match the weather when it regains it", async () => { - game.override.enemyMoveset([ Moves.GASTRO_ACID ]).weather(WeatherType.RAIN); - await game.startBattle([ Species.CASTFORM, Species.PIKACHU ]); + game.override.enemyMoveset([Moves.GASTRO_ACID]).weather(WeatherType.RAIN); + await game.startBattle([Species.CASTFORM, Species.PIKACHU]); const castform = game.scene.getPlayerPokemon()!; expect(castform.formIndex).toBe(RAINY_FORM); // First turn - Forecast is suppressed game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.move.forceHit(); await game.phaseInterceptor.to(TurnEndPhase); @@ -259,8 +273,8 @@ describe("Abilities - Forecast", () => { }); it("does not change Castform's form until after Stealth Rock deals damage", async () => { - game.override.weather(WeatherType.RAIN).enemyMoveset([ Moves.STEALTH_ROCK ]); - await game.startBattle([ Species.PIKACHU, Species.CASTFORM ]); + game.override.weather(WeatherType.RAIN).enemyMoveset([Moves.STEALTH_ROCK]); + await game.startBattle([Species.PIKACHU, Species.CASTFORM]); // First turn - set up stealth rock game.move.select(Moves.SPLASH); @@ -284,7 +298,7 @@ describe("Abilities - Forecast", () => { it("should be in Normal Form after the user is switched out", async () => { game.override.weather(WeatherType.RAIN); - await game.startBattle([ Species.CASTFORM, Species.MAGIKARP ]); + await game.startBattle([Species.CASTFORM, Species.MAGIKARP]); const castform = game.scene.getPlayerPokemon()!; expect(castform.formIndex).toBe(RAINY_FORM); diff --git a/test/abilities/friend_guard.test.ts b/test/abilities/friend_guard.test.ts index 8cb7b0233c2..30175fe37e0 100644 --- a/test/abilities/friend_guard.test.ts +++ b/test/abilities/friend_guard.test.ts @@ -28,15 +28,15 @@ describe("Moves - Friend Guard", () => { game.override .battleType("double") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.TACKLE, Moves.SPLASH, Moves.DRAGON_RAGE ]) + .enemyMoveset([Moves.TACKLE, Moves.SPLASH, Moves.DRAGON_RAGE]) .enemySpecies(Species.SHUCKLE) - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .startingLevel(100); }); it("should reduce damage that other allied Pokémon receive from attacks (from any Pokémon) by 25%", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); - const [ player1, player2 ] = game.scene.getPlayerField(); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); + const [player1, player2] = game.scene.getPlayerField(); const spy = vi.spyOn(player1, "getAttackDamage"); const enemy1 = game.scene.getEnemyField()[0]; @@ -63,13 +63,15 @@ describe("Moves - Friend Guard", () => { // Get the last return value from `getAttackDamage` const turn2Damage = spy.mock.results[spy.mock.results.length - 1].value.damage; // With the ally's Friend Guard, damage should have been reduced from base damage by 25% - expect(turn2Damage).toBe(Math.floor(player1.getBaseDamage(enemy1, allMoves[Moves.TACKLE], MoveCategory.PHYSICAL) * 0.75)); + expect(turn2Damage).toBe( + Math.floor(player1.getBaseDamage(enemy1, allMoves[Moves.TACKLE], MoveCategory.PHYSICAL) * 0.75), + ); }); it("should NOT reduce damage to pokemon with friend guard", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); - const player2 = game.scene.getPlayerField()[1]; + const player2 = game.scene.getPlayerField()[1]; const spy = vi.spyOn(player2, "getAttackDamage"); game.move.select(Moves.SPLASH); @@ -93,9 +95,9 @@ describe("Moves - Friend Guard", () => { }); it("should NOT reduce damage from fixed damage attacks", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [player1, player2] = game.scene.getPlayerField(); const spy = vi.spyOn(player1, "getAttackDamage"); game.move.select(Moves.SPLASH); diff --git a/test/abilities/galvanize.test.ts b/test/abilities/galvanize.test.ts index 9ba57c296d9..c1e02c6c8d8 100644 --- a/test/abilities/galvanize.test.ts +++ b/test/abilities/galvanize.test.ts @@ -9,7 +9,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Abilities - Galvanize", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,7 +30,7 @@ describe("Abilities - Galvanize", () => { .battleType("single") .startingLevel(100) .ability(Abilities.GALVANIZE) - .moveset([ Moves.TACKLE, Moves.REVELATION_DANCE, Moves.FURY_SWIPES ]) + .moveset([Moves.TACKLE, Moves.REVELATION_DANCE, Moves.FURY_SWIPES]) .enemySpecies(Species.DUSCLOPS) .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) @@ -85,7 +84,7 @@ describe("Abilities - Galvanize", () => { it("should not change the type of variable-type moves", async () => { game.override.enemySpecies(Species.MIGHTYENA); - await game.startBattle([ Species.ESPEON ]); + await game.startBattle([Species.ESPEON]); const playerPokemon = game.scene.getPlayerPokemon()!; vi.spyOn(playerPokemon, "getMoveType"); @@ -111,7 +110,7 @@ describe("Abilities - Galvanize", () => { vi.spyOn(enemyPokemon, "apply"); game.move.select(Moves.FURY_SWIPES); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("MoveEffectPhase"); diff --git a/test/abilities/good_as_gold.test.ts b/test/abilities/good_as_gold.test.ts index e3367d5b7f8..7cc543c4a0d 100644 --- a/test/abilities/good_as_gold.test.ts +++ b/test/abilities/good_as_gold.test.ts @@ -30,7 +30,7 @@ describe("Abilities - Good As Gold", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.GOOD_AS_GOLD) .battleType("single") .disableCrits() @@ -40,8 +40,8 @@ describe("Abilities - Good As Gold", () => { }); it("should block normal status moves", async () => { - game.override.enemyMoveset( [ Moves.GROWL ] ); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.GROWL]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; @@ -54,8 +54,8 @@ describe("Abilities - Good As Gold", () => { }); it("should block memento and prevent the user from fainting", async () => { - game.override.enemyMoveset( [ Moves.MEMENTO ] ); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.MEMENTO]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.MEMENTO); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getPlayerPokemon()!.isFainted()).toBe(false); @@ -64,10 +64,10 @@ describe("Abilities - Good As Gold", () => { it("should not block any status moves that target the field, one side, or all pokemon", async () => { game.override.battleType("double"); - game.override.enemyMoveset( [ Moves.STEALTH_ROCK, Moves.HAZE ] ); - game.override.moveset([ Moves.SWORDS_DANCE, Moves.SAFEGUARD ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); - const [ good_as_gold, ball_fetch ] = game.scene.getPlayerField(); + game.override.enemyMoveset([Moves.STEALTH_ROCK, Moves.HAZE]); + game.override.moveset([Moves.SWORDS_DANCE, Moves.SAFEGUARD]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); + const [good_as_gold, ball_fetch] = game.scene.getPlayerField(); // Force second pokemon to have ball fetch to isolate to a single mon. vi.spyOn(ball_fetch, "getAbility").mockReturnValue(allAbilities[Abilities.BALL_FETCH]); @@ -76,7 +76,7 @@ describe("Abilities - Good As Gold", () => { game.move.select(Moves.SAFEGUARD, 1); await game.forceEnemyMove(Moves.STEALTH_ROCK); await game.forceEnemyMove(Moves.HAZE); - await game.setTurnOrder( [ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ] ); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(good_as_gold.getAbility().id).toBe(Abilities.GOOD_AS_GOLD); expect(good_as_gold.getStatStage(Stat.ATK)).toBe(0); @@ -86,8 +86,8 @@ describe("Abilities - Good As Gold", () => { it("should not block field targeted effects in singles", async () => { game.override.battleType("single"); - game.override.enemyMoveset( [ Moves.SPIKES ] ); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.SPIKES]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPLASH, 0); await game.phaseInterceptor.to("BerryPhase"); @@ -97,8 +97,8 @@ describe("Abilities - Good As Gold", () => { it("should block the ally's helping hand", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.HELPING_HAND, Moves.TACKLE ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + game.override.moveset([Moves.HELPING_HAND, Moves.TACKLE]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); game.move.select(Moves.HELPING_HAND, 0); game.move.select(Moves.TACKLE, 1); @@ -109,10 +109,10 @@ describe("Abilities - Good As Gold", () => { it("should block the ally's heal bell, but only if the good as gold user is on the field", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.HEAL_BELL, Moves.SPLASH ]); + game.override.moveset([Moves.HEAL_BELL, Moves.SPLASH]); game.override.statusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS, Species.ABRA ]); - const [ good_as_gold, ball_fetch ] = game.scene.getPlayerField(); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS, Species.ABRA]); + const [good_as_gold, ball_fetch] = game.scene.getPlayerField(); // Force second pokemon to have ball fetch to isolate to a single mon. vi.spyOn(ball_fetch, "getAbility").mockReturnValue(allAbilities[Abilities.BALL_FETCH]); @@ -131,9 +131,9 @@ describe("Abilities - Good As Gold", () => { it("should not block field targeted effects like rain dance", async () => { game.override.battleType("single"); - game.override.enemyMoveset( [ Moves.RAIN_DANCE ] ); + game.override.enemyMoveset([Moves.RAIN_DANCE]); game.override.weather(WeatherType.NONE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPLASH, 0); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/gorilla_tactics.test.ts b/test/abilities/gorilla_tactics.test.ts index e97bca6a725..48dab262b82 100644 --- a/test/abilities/gorilla_tactics.test.ts +++ b/test/abilities/gorilla_tactics.test.ts @@ -25,15 +25,15 @@ describe("Abilities - Gorilla Tactics", () => { game.override .battleType("single") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.DISABLE ]) + .enemyMoveset([Moves.SPLASH, Moves.DISABLE]) .enemySpecies(Species.MAGIKARP) .enemyLevel(30) - .moveset([ Moves.SPLASH, Moves.TACKLE, Moves.GROWL ]) + .moveset([Moves.SPLASH, Moves.TACKLE, Moves.GROWL]) .ability(Abilities.GORILLA_TACTICS); }); it("boosts the Pokémon's Attack by 50%, but limits the Pokémon to using only one move", async () => { - await game.classicMode.startBattle([ Species.GALAR_DARMANITAN ]); + await game.classicMode.startBattle([Species.GALAR_DARMANITAN]); const darmanitan = game.scene.getPlayerPokemon()!; const initialAtkStat = darmanitan.getStat(Stat.ATK); @@ -50,7 +50,7 @@ describe("Abilities - Gorilla Tactics", () => { }); it("should struggle if the only usable move is disabled", async () => { - await game.classicMode.startBattle([ Species.GALAR_DARMANITAN ]); + await game.classicMode.startBattle([Species.GALAR_DARMANITAN]); const darmanitan = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -64,7 +64,7 @@ describe("Abilities - Gorilla Tactics", () => { game.move.select(Moves.GROWL); await game.forceEnemyMove(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(enemy.getStatStage(Stat.ATK)).toBe(-1); // Only the effect of the first Growl should be applied @@ -73,7 +73,7 @@ describe("Abilities - Gorilla Tactics", () => { await game.toNextTurn(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(darmanitan.hp).toBeLessThan(darmanitan.getMaxHp()); diff --git a/test/abilities/gulp_missile.test.ts b/test/abilities/gulp_missile.test.ts index d34e86ddc08..8ebd583d3ab 100644 --- a/test/abilities/gulp_missile.test.ts +++ b/test/abilities/gulp_missile.test.ts @@ -25,7 +25,7 @@ describe("Abilities - Gulp Missile", () => { * @returns The effect damage of Gulp Missile */ const getEffectDamage = (pokemon: Pokemon): number => { - return Math.max(1, Math.floor(pokemon.getMaxHp() * 1 / 4)); + return Math.max(1, Math.floor((pokemon.getMaxHp() * 1) / 4)); }; beforeAll(() => { @@ -43,7 +43,7 @@ describe("Abilities - Gulp Missile", () => { game.override .disableCrits() .battleType("single") - .moveset([ Moves.SURF, Moves.DIVE, Moves.SPLASH, Moves.SUBSTITUTE ]) + .moveset([Moves.SURF, Moves.DIVE, Moves.SPLASH, Moves.SUBSTITUTE]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) @@ -51,7 +51,7 @@ describe("Abilities - Gulp Missile", () => { }); it("changes to Gulping Form if HP is over half when Surf or Dive is used", async () => { - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; game.move.select(Moves.DIVE); @@ -59,17 +59,17 @@ describe("Abilities - Gulp Missile", () => { game.move.select(Moves.DIVE); await game.phaseInterceptor.to("MoveEndPhase"); - expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(.5); + expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(0.5); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.formIndex).toBe(GULPING_FORM); }); it("changes to Gorging Form if HP is under half when Surf or Dive is used", async () => { - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.49); - expect(cramorant.getHpRatio()).toBe(.49); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.49); + expect(cramorant.getHpRatio()).toBe(0.49); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -79,7 +79,7 @@ describe("Abilities - Gulp Missile", () => { }); it("changes to base form when switched out after Surf or Dive is used", async () => { - await game.classicMode.startBattle([ Species.CRAMORANT, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.CRAMORANT, Species.MAGIKARP]); const cramorant = game.scene.getPlayerPokemon()!; game.move.select(Moves.SURF); @@ -94,7 +94,7 @@ describe("Abilities - Gulp Missile", () => { }); it("changes form during Dive's charge turn", async () => { - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; game.move.select(Moves.DIVE); @@ -106,7 +106,7 @@ describe("Abilities - Gulp Missile", () => { it("deals 1/4 of the attacker's maximum HP when hit by a damaging attack", async () => { game.override.enemyMoveset(Moves.TACKLE); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "damageAndUpdate"); @@ -119,10 +119,10 @@ describe("Abilities - Gulp Missile", () => { it("does not have any effect when hit by non-damaging attack", async () => { game.override.enemyMoveset(Moves.TAIL_WHIP); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.55); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -138,13 +138,13 @@ describe("Abilities - Gulp Missile", () => { it("lowers attacker's DEF stat stage by 1 when hit in Gulping form", async () => { game.override.enemyMoveset(Moves.TACKLE); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "damageAndUpdate"); - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.55); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -162,13 +162,13 @@ describe("Abilities - Gulp Missile", () => { it("paralyzes the enemy when hit in Gorging form", async () => { game.override.enemyMoveset(Moves.TACKLE); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "damageAndUpdate"); - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.45); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.45); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -186,7 +186,7 @@ describe("Abilities - Gulp Missile", () => { it("does not activate the ability when underwater", async () => { game.override.enemyMoveset(Moves.SURF); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; @@ -199,12 +199,12 @@ describe("Abilities - Gulp Missile", () => { it("prevents effect damage but inflicts secondary effect on attacker with Magic Guard", async () => { game.override.enemyMoveset(Moves.TACKLE).enemyAbility(Abilities.MAGIC_GUARD); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.55); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -223,7 +223,7 @@ describe("Abilities - Gulp Missile", () => { it("activates on faint", async () => { game.override.enemyMoveset(Moves.THUNDERBOLT); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; @@ -237,10 +237,8 @@ describe("Abilities - Gulp Missile", () => { }); it("doesn't trigger if user is behind a substitute", async () => { - game.override - .enemyAbility(Abilities.STURDY) - .enemyMoveset([ Moves.SPLASH, Moves.POWER_TRIP ]); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + game.override.enemyAbility(Abilities.STURDY).enemyMoveset([Moves.SPLASH, Moves.POWER_TRIP]); + await game.classicMode.startBattle([Species.CRAMORANT]); game.move.select(Moves.SURF); await game.forceEnemyMove(Moves.SPLASH); @@ -250,7 +248,7 @@ describe("Abilities - Gulp Missile", () => { game.move.select(Moves.SUBSTITUTE); await game.forceEnemyMove(Moves.POWER_TRIP); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); expect(game.scene.getPlayerPokemon()!.formIndex).toBe(GULPING_FORM); @@ -258,10 +256,10 @@ describe("Abilities - Gulp Missile", () => { it("cannot be suppressed", async () => { game.override.enemyMoveset(Moves.GASTRO_ACID); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.55); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -278,10 +276,10 @@ describe("Abilities - Gulp Missile", () => { it("cannot be swapped with another ability", async () => { game.override.enemyMoveset(Moves.SKILL_SWAP); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); const cramorant = game.scene.getPlayerPokemon()!; - vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); + vi.spyOn(cramorant, "getHpRatio").mockReturnValue(0.55); game.move.select(Moves.SURF); await game.phaseInterceptor.to("MoveEndPhase"); @@ -299,7 +297,7 @@ describe("Abilities - Gulp Missile", () => { it("cannot be copied", async () => { game.override.enemyAbility(Abilities.TRACE); - await game.classicMode.startBattle([ Species.CRAMORANT ]); + await game.classicMode.startBattle([Species.CRAMORANT]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnStartPhase"); diff --git a/test/abilities/heatproof.test.ts b/test/abilities/heatproof.test.ts index 6c41460535f..fa065d1ed03 100644 --- a/test/abilities/heatproof.test.ts +++ b/test/abilities/heatproof.test.ts @@ -33,7 +33,7 @@ describe("Abilities - Heatproof", () => { .enemyLevel(100) .starterSpecies(Species.CHANDELURE) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.FLAMETHROWER, Moves.SPLASH ]) + .moveset([Moves.FLAMETHROWER, Moves.SPLASH]) .startingLevel(100); }); @@ -55,14 +55,12 @@ describe("Abilities - Heatproof", () => { await game.phaseInterceptor.to(TurnEndPhase); const regularDamage = initialHP - enemy.hp; - expect(heatproofDamage).toBeLessThanOrEqual((regularDamage / 2) + 1); - expect(heatproofDamage).toBeGreaterThanOrEqual((regularDamage / 2) - 1); + expect(heatproofDamage).toBeLessThanOrEqual(regularDamage / 2 + 1); + expect(heatproofDamage).toBeGreaterThanOrEqual(regularDamage / 2 - 1); }); it("reduces Burn damage by half", async () => { - game.override - .enemyStatusEffect(StatusEffect.BURN) - .enemySpecies(Species.ABRA); + game.override.enemyStatusEffect(StatusEffect.BURN).enemySpecies(Species.ABRA); await game.startBattle(); const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/honey_gather.test.ts b/test/abilities/honey_gather.test.ts index a1cad453843..bea5c25c878 100644 --- a/test/abilities/honey_gather.test.ts +++ b/test/abilities/honey_gather.test.ts @@ -24,7 +24,7 @@ describe("Abilities - Honey Gather", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.ROAR, Moves.THUNDERBOLT ]) + .moveset([Moves.SPLASH, Moves.ROAR, Moves.THUNDERBOLT]) .startingLevel(100) .ability(Abilities.HONEY_GATHER) .passiveAbility(Abilities.RUN_AWAY) @@ -36,7 +36,7 @@ describe("Abilities - Honey Gather", () => { }); it("should give money when winning a battle", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); game.scene.money = 1000; game.move.select(Moves.THUNDERBOLT); @@ -46,7 +46,7 @@ describe("Abilities - Honey Gather", () => { }); it("should not give money when the enemy pokemon flees", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); game.scene.money = 1000; game.move.select(Moves.ROAR); @@ -57,7 +57,7 @@ describe("Abilities - Honey Gather", () => { }); it("should not give money when the player flees", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); game.scene.money = 1000; // something weird is going on with the test framework, so this is required to prevent a crash diff --git a/test/abilities/hustle.test.ts b/test/abilities/hustle.test.ts index 669e73961e3..40197cf9e97 100644 --- a/test/abilities/hustle.test.ts +++ b/test/abilities/hustle.test.ts @@ -25,7 +25,7 @@ describe("Abilities - Hustle", () => { game = new GameManager(phaserGame); game.override .ability(Abilities.HUSTLE) - .moveset([ Moves.TACKLE, Moves.GIGA_DRAIN, Moves.FISSURE ]) + .moveset([Moves.TACKLE, Moves.GIGA_DRAIN, Moves.FISSURE]) .disableCrits() .battleType("single") .enemyMoveset(Moves.SPLASH) @@ -34,7 +34,7 @@ describe("Abilities - Hustle", () => { }); it("increases the user's Attack stat by 50%", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const atk = pikachu.stats[Stat.ATK]; @@ -48,7 +48,7 @@ describe("Abilities - Hustle", () => { }); it("lowers the accuracy of the user's physical moves by 20%", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; vi.spyOn(pikachu, "getAccuracyMultiplier"); @@ -60,7 +60,7 @@ describe("Abilities - Hustle", () => { }); it("does not affect non-physical moves", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const spatk = pikachu.stats[Stat.SPATK]; @@ -78,7 +78,7 @@ describe("Abilities - Hustle", () => { game.override.startingLevel(100); game.override.enemyLevel(30); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/hyper_cutter.test.ts b/test/abilities/hyper_cutter.test.ts index c8c4c21c98f..fe5623e4e0f 100644 --- a/test/abilities/hyper_cutter.test.ts +++ b/test/abilities/hyper_cutter.test.ts @@ -24,7 +24,7 @@ describe("Abilities - Hyper Cutter", () => { game = new GameManager(phaserGame); game.override .battleType("single") - .moveset([ Moves.SAND_ATTACK, Moves.NOBLE_ROAR, Moves.DEFOG, Moves.OCTOLOCK ]) + .moveset([Moves.SAND_ATTACK, Moves.NOBLE_ROAR, Moves.DEFOG, Moves.OCTOLOCK]) .ability(Abilities.BALL_FETCH) .enemySpecies(Species.SHUCKLE) .enemyAbility(Abilities.HYPER_CUTTER) @@ -46,11 +46,13 @@ describe("Abilities - Hyper Cutter", () => { await game.toNextTurn(); game.move.select(Moves.SAND_ATTACK); await game.toNextTurn(); - game.override.moveset([ Moves.STRING_SHOT ]); + game.override.moveset([Moves.STRING_SHOT]); game.move.select(Moves.STRING_SHOT); await game.toNextTurn(); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); - [ Stat.ACC, Stat.DEF, Stat.EVA, Stat.SPATK, Stat.SPDEF, Stat.SPD ].forEach((stat: number) => expect(enemy.getStatStage(stat)).toBeLessThan(0)); + [Stat.ACC, Stat.DEF, Stat.EVA, Stat.SPATK, Stat.SPDEF, Stat.SPD].forEach((stat: number) => + expect(enemy.getStatStage(stat)).toBeLessThan(0), + ); }); }); diff --git a/test/abilities/ice_face.test.ts b/test/abilities/ice_face.test.ts index e4339cb8a28..e85794928d6 100644 --- a/test/abilities/ice_face.test.ts +++ b/test/abilities/ice_face.test.ts @@ -33,11 +33,11 @@ describe("Abilities - Ice Face", () => { game.override.battleType("single"); game.override.enemySpecies(Species.EISCUE); game.override.enemyAbility(Abilities.ICE_FACE); - game.override.moveset([ Moves.TACKLE, Moves.ICE_BEAM, Moves.TOXIC_THREAD, Moves.HAIL ]); + game.override.moveset([Moves.TACKLE, Moves.ICE_BEAM, Moves.TOXIC_THREAD, Moves.HAIL]); }); it("takes no damage from physical move and transforms to Noice", async () => { - await game.classicMode.startBattle([ Species.HITMONLEE ]); + await game.classicMode.startBattle([Species.HITMONLEE]); game.move.select(Moves.TACKLE); @@ -51,9 +51,9 @@ describe("Abilities - Ice Face", () => { }); it("takes no damage from the first hit of multihit physical move and transforms to Noice", async () => { - game.override.moveset([ Moves.SURGING_STRIKES ]); + game.override.moveset([Moves.SURGING_STRIKES]); game.override.enemyLevel(1); - await game.classicMode.startBattle([ Species.HITMONLEE ]); + await game.classicMode.startBattle([Species.HITMONLEE]); game.move.select(Moves.SURGING_STRIKES); @@ -79,7 +79,7 @@ describe("Abilities - Ice Face", () => { }); it("takes damage from special moves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.ICE_BEAM); @@ -93,7 +93,7 @@ describe("Abilities - Ice Face", () => { }); it("takes effects from status moves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.TOXIC_THREAD); @@ -106,10 +106,10 @@ describe("Abilities - Ice Face", () => { }); it("transforms to Ice Face when Hail or Snow starts", async () => { - game.override.moveset([ Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([ Moves.HAIL, Moves.HAIL, Moves.HAIL, Moves.HAIL ]); + game.override.moveset([Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.HAIL, Moves.HAIL, Moves.HAIL, Moves.HAIL]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.QUICK_ATTACK); @@ -128,10 +128,10 @@ describe("Abilities - Ice Face", () => { }); it("transforms to Ice Face when summoned on arena with active Snow or Hail", async () => { - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); - game.override.moveset([ Moves.SNOWSCAPE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); + game.override.moveset([Moves.SNOWSCAPE]); - await game.classicMode.startBattle([ Species.EISCUE, Species.NINJASK ]); + await game.classicMode.startBattle([Species.EISCUE, Species.NINJASK]); game.move.select(Moves.SNOWSCAPE); @@ -156,9 +156,9 @@ describe("Abilities - Ice Face", () => { it("will not revert to its Ice Face if there is already Hail when it changes into Noice", async () => { game.override.enemySpecies(Species.SHUCKLE); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); - await game.classicMode.startBattle([ Species.EISCUE ]); + await game.classicMode.startBattle([Species.EISCUE]); game.move.select(Moves.HAIL); const eiscue = game.scene.getPlayerPokemon()!; @@ -175,9 +175,9 @@ describe("Abilities - Ice Face", () => { }); it("persists form change when switched out", async () => { - game.override.enemyMoveset([ Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK ]); + game.override.enemyMoveset([Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK]); - await game.classicMode.startBattle([ Species.EISCUE, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.EISCUE, Species.MAGIKARP]); game.move.select(Moves.ICE_BEAM); @@ -206,7 +206,7 @@ describe("Abilities - Ice Face", () => { [Species.EISCUE]: noiceForm, }); - await game.classicMode.startBattle([ Species.EISCUE ]); + await game.classicMode.startBattle([Species.EISCUE]); const eiscue = game.scene.getPlayerPokemon()!; @@ -224,22 +224,20 @@ describe("Abilities - Ice Face", () => { }); it("doesn't trigger if user is behind a substitute", async () => { - game.override - .enemyMoveset(Moves.SUBSTITUTE) - .moveset(Moves.POWER_TRIP); + game.override.enemyMoveset(Moves.SUBSTITUTE).moveset(Moves.POWER_TRIP); await game.classicMode.startBattle(); game.move.select(Moves.POWER_TRIP); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.formIndex).toBe(icefaceForm); }); it("cannot be suppressed", async () => { - game.override.moveset([ Moves.GASTRO_ACID ]); + game.override.moveset([Moves.GASTRO_ACID]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GASTRO_ACID); @@ -253,9 +251,9 @@ describe("Abilities - Ice Face", () => { }); it("cannot be swapped with another ability", async () => { - game.override.moveset([ Moves.SKILL_SWAP ]); + game.override.moveset([Moves.SKILL_SWAP]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SKILL_SWAP); @@ -271,7 +269,7 @@ describe("Abilities - Ice Face", () => { it("cannot be copied", async () => { game.override.ability(Abilities.TRACE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SIMPLE_BEAM); diff --git a/test/abilities/illuminate.test.ts b/test/abilities/illuminate.test.ts index c4fbcd2c7a4..6518fec989b 100644 --- a/test/abilities/illuminate.test.ts +++ b/test/abilities/illuminate.test.ts @@ -45,11 +45,7 @@ describe("Abilities - Illuminate", () => { }); it("should guarantee double battle with any one LURE", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + game.override.startingModifier([{ name: "LURE" }]).startingWave(2); await game.classicMode.startBattle(); diff --git a/test/abilities/imposter.test.ts b/test/abilities/imposter.test.ts index d73b77feda9..b4469cd9042 100644 --- a/test/abilities/imposter.test.ts +++ b/test/abilities/imposter.test.ts @@ -36,7 +36,7 @@ describe("Abilities - Imposter", () => { }); it("should copy species, ability, gender, all stats except HP, all stat stages, moveset, and types of target", async () => { - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -75,9 +75,9 @@ describe("Abilities - Imposter", () => { }); it("should copy in-battle overridden stats", async () => { - game.override.enemyMoveset([ Moves.POWER_SPLIT ]); + game.override.enemyMoveset([Moves.POWER_SPLIT]); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -96,9 +96,9 @@ describe("Abilities - Imposter", () => { }); it("should set each move's pp to a maximum of 5", async () => { - game.override.enemyMoveset([ Moves.SWORDS_DANCE, Moves.GROWL, Moves.SKETCH, Moves.RECOVER ]); + game.override.enemyMoveset([Moves.SWORDS_DANCE, Moves.GROWL, Moves.SKETCH, Moves.RECOVER]); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); const player = game.scene.getPlayerPokemon()!; game.move.select(Moves.TACKLE); @@ -120,7 +120,7 @@ describe("Abilities - Imposter", () => { it("should activate its ability if it copies one that activates on summon", async () => { game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); game.move.select(Moves.TACKLE); await game.phaseInterceptor.to("MoveEndPhase"); diff --git a/test/abilities/infiltrator.test.ts b/test/abilities/infiltrator.test.ts index 35fa816b88b..6278439651c 100644 --- a/test/abilities/infiltrator.test.ts +++ b/test/abilities/infiltrator.test.ts @@ -28,7 +28,7 @@ describe("Abilities - Infiltrator", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.TACKLE, Moves.WATER_GUN, Moves.SPORE, Moves.BABY_DOLL_EYES ]) + .moveset([Moves.TACKLE, Moves.WATER_GUN, Moves.SPORE, Moves.BABY_DOLL_EYES]) .ability(Abilities.INFILTRATOR) .battleType("single") .disableCrits() @@ -40,11 +40,23 @@ describe("Abilities - Infiltrator", () => { }); it.each([ - { effectName: "Light Screen", tagType: ArenaTagType.LIGHT_SCREEN, move: Moves.WATER_GUN }, - { effectName: "Reflect", tagType: ArenaTagType.REFLECT, move: Moves.TACKLE }, - { effectName: "Aurora Veil", tagType: ArenaTagType.AURORA_VEIL, move: Moves.TACKLE } + { + effectName: "Light Screen", + tagType: ArenaTagType.LIGHT_SCREEN, + move: Moves.WATER_GUN, + }, + { + effectName: "Reflect", + tagType: ArenaTagType.REFLECT, + move: Moves.TACKLE, + }, + { + effectName: "Aurora Veil", + tagType: ArenaTagType.AURORA_VEIL, + move: Moves.TACKLE, + }, ])("should bypass the target's $effectName", async ({ tagType, move }) => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -60,7 +72,7 @@ describe("Abilities - Infiltrator", () => { }); it("should bypass the target's Safeguard", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -76,7 +88,7 @@ describe("Abilities - Infiltrator", () => { // TODO: fix this interaction to pass this test it.todo("should bypass the target's Mist", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -91,7 +103,7 @@ describe("Abilities - Infiltrator", () => { }); it("should bypass the target's Substitute", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/intimidate.test.ts b/test/abilities/intimidate.test.ts index eab59e7c1a2..53286d354c8 100644 --- a/test/abilities/intimidate.test.ts +++ b/test/abilities/intimidate.test.ts @@ -24,7 +24,8 @@ describe("Abilities - Intimidate", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .enemySpecies(Species.RATTATA) .enemyAbility(Abilities.INTIMIDATE) .enemyPassiveAbility(Abilities.HYDRATION) @@ -34,7 +35,7 @@ describe("Abilities - Intimidate", () => { }); it("should lower ATK stat stage by 1 of enemy Pokemon on entry and player switch", async () => { - await game.classicMode.runToSummon([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); game.onNextPrompt( "CheckSwitchPhase", Mode.CONFIRM, @@ -42,7 +43,7 @@ describe("Abilities - Intimidate", () => { game.setMode(Mode.MESSAGE); game.endPhase(); }, - () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase") + () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase"), ); await game.phaseInterceptor.to("CommandPhase", false); @@ -64,9 +65,8 @@ describe("Abilities - Intimidate", () => { }, 20000); it("should lower ATK stat stage by 1 for every enemy Pokemon in a double battle on entry", async () => { - game.override.battleType("double") - .startingWave(3); - await game.classicMode.runToSummon([ Species.MIGHTYENA, Species.POOCHYENA ]); + game.override.battleType("double").startingWave(3); + await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); game.onNextPrompt( "CheckSwitchPhase", Mode.CONFIRM, @@ -74,7 +74,7 @@ describe("Abilities - Intimidate", () => { game.setMode(Mode.MESSAGE); game.endPhase(); }, - () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase") + () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("TurnInitPhase"), ); await game.phaseInterceptor.to("CommandPhase", false); @@ -89,8 +89,8 @@ describe("Abilities - Intimidate", () => { it("should not activate again if there is no switch or new entry", async () => { game.override.startingWave(2); - game.override.moveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]); + game.override.moveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -106,10 +106,8 @@ describe("Abilities - Intimidate", () => { }, 20000); it("should lower ATK stat stage by 1 for every switch", async () => { - game.override.moveset([ Moves.SPLASH ]) - .enemyMoveset([ Moves.VOLT_SWITCH ]) - .startingWave(5); - await game.classicMode.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]); + game.override.moveset([Moves.SPLASH]).enemyMoveset([Moves.VOLT_SWITCH]).startingWave(5); + await game.classicMode.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); const playerPokemon = game.scene.getPlayerPokemon()!; let enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/intrepid_sword.test.ts b/test/abilities/intrepid_sword.test.ts index 0f4305d38b4..28d0cd02c7f 100644 --- a/test/abilities/intrepid_sword.test.ts +++ b/test/abilities/intrepid_sword.test.ts @@ -6,7 +6,6 @@ import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Intrepid Sword", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,10 +28,8 @@ describe("Abilities - Intrepid Sword", () => { game.override.ability(Abilities.INTREPID_SWORD); }); - it("should raise ATK stat stage by 1 on entry", async() => { - await game.classicMode.runToSummon([ - Species.ZACIAN, - ]); + it("should raise ATK stat stage by 1 on entry", async () => { + await game.classicMode.runToSummon([Species.ZACIAN]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/libero.test.ts b/test/abilities/libero.test.ts index d36422ade4a..22abf1c248f 100644 --- a/test/abilities/libero.test.ts +++ b/test/abilities/libero.test.ts @@ -13,7 +13,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - Libero", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -34,308 +33,263 @@ describe("Abilities - Libero", () => { game.override.ability(Abilities.LIBERO); game.override.startingLevel(100); game.override.enemySpecies(Species.RATTATA); - game.override.enemyMoveset([ Moves.ENDURE, Moves.ENDURE, Moves.ENDURE, Moves.ENDURE ]); + game.override.enemyMoveset([Moves.ENDURE, Moves.ENDURE, Moves.ENDURE, Moves.ENDURE]); }); - test( - "ability applies and changes a pokemon's type", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability applies and changes a pokemon's type", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + }); // Test for Gen9+ functionality, we are using previous funcionality - test.skip( - "ability applies only once per switch in", - async () => { - game.override.moveset([ Moves.SPLASH, Moves.AGILITY ]); + test.skip("ability applies only once per switch in", async () => { + game.override.moveset([Moves.SPLASH, Moves.AGILITY]); - await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR ]); + await game.startBattle([Species.MAGIKARP, Species.BULBASAUR]); - let leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + let leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - game.move.select(Moves.AGILITY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.AGILITY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.LIBERO)).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; - const moveType = PokemonType[allMoves[Moves.AGILITY].type]; - expect(leadPokemonType).not.toBe(moveType); + expect(leadPokemon.summonData.abilitiesApplied.filter(a => a === Abilities.LIBERO)).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; + const moveType = PokemonType[allMoves[Moves.AGILITY].type]; + expect(leadPokemonType).not.toBe(moveType); - await game.toNextTurn(); - game.doSwitchPokemon(1); - await game.toNextTurn(); - game.doSwitchPokemon(1); - await game.toNextTurn(); + await game.toNextTurn(); + game.doSwitchPokemon(1); + await game.toNextTurn(); + game.doSwitchPokemon(1); + await game.toNextTurn(); - leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + }); - test( - "ability applies correctly even if the pokemon's move has a variable type", - async () => { - game.override.moveset([ Moves.WEATHER_BALL ]); + test("ability applies correctly even if the pokemon's move has a variable type", async () => { + game.override.moveset([Moves.WEATHER_BALL]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.scene.arena.weather = new Weather(WeatherType.SUNNY); - game.move.select(Moves.WEATHER_BALL); - await game.phaseInterceptor.to(TurnEndPhase); + game.scene.arena.weather = new Weather(WeatherType.SUNNY); + game.move.select(Moves.WEATHER_BALL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); - expect(leadPokemon.getTypes()).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], - moveType = PokemonType[PokemonType.FIRE]; - expect(leadPokemonType).toBe(moveType); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); + expect(leadPokemon.getTypes()).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], + moveType = PokemonType[PokemonType.FIRE]; + expect(leadPokemonType).toBe(moveType); + }); - test( - "ability applies correctly even if the type has changed by another ability", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.passiveAbility(Abilities.REFRIGERATE); + test("ability applies correctly even if the type has changed by another ability", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.passiveAbility(Abilities.REFRIGERATE); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); - expect(leadPokemon.getTypes()).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], - moveType = PokemonType[PokemonType.ICE]; - expect(leadPokemonType).toBe(moveType); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); + expect(leadPokemon.getTypes()).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], + moveType = PokemonType[PokemonType.ICE]; + expect(leadPokemonType).toBe(moveType); + }); - test( - "ability applies correctly even if the pokemon's move calls another move", - async () => { - game.override.moveset([ Moves.NATURE_POWER ]); + test("ability applies correctly even if the pokemon's move calls another move", async () => { + game.override.moveset([Moves.NATURE_POWER]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.scene.arena.biomeType = Biome.MOUNTAIN; - game.move.select(Moves.NATURE_POWER); - await game.phaseInterceptor.to(TurnEndPhase); + game.scene.arena.biomeType = Biome.MOUNTAIN; + game.move.select(Moves.NATURE_POWER); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); + }); - test( - "ability applies correctly even if the pokemon's move is delayed / charging", - async () => { - game.override.moveset([ Moves.DIG ]); + test("ability applies correctly even if the pokemon's move is delayed / charging", async () => { + game.override.moveset([Moves.DIG]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.DIG); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.DIG); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); + }); - test( - "ability applies correctly even if the pokemon's move misses", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemyMoveset(Moves.SPLASH); + test("ability applies correctly even if the pokemon's move misses", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.move.forceMiss(); + await game.phaseInterceptor.to(TurnEndPhase); - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon.isFullHp()).toBe(true); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon.isFullHp()).toBe(true); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability applies correctly even if the pokemon's move is protected against", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemyMoveset([ Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT ]); + test("ability applies correctly even if the pokemon's move is protected against", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability applies correctly even if the pokemon's move fails because of type immunity", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemySpecies(Species.GASTLY); + test("ability applies correctly even if the pokemon's move fails because of type immunity", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemySpecies(Species.GASTLY); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability is not applied if pokemon's type is the same as the move's type", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability is not applied if pokemon's type is the same as the move's type", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - leadPokemon.summonData.types = [ allMoves[Moves.SPLASH].type ]; - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + leadPokemon.summonData.types = [allMoves[Moves.SPLASH].type]; + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); + }); - test( - "ability is not applied if pokemon is terastallized", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability is not applied if pokemon is terastallized", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - leadPokemon.isTerastallized = true; + leadPokemon.isTerastallized = true; - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); + }); - test( - "ability is not applied if pokemon uses struggle", - async () => { - game.override.moveset([ Moves.STRUGGLE ]); + test("ability is not applied if pokemon uses struggle", async () => { + game.override.moveset([Moves.STRUGGLE]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.STRUGGLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.STRUGGLE); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); + }); - test( - "ability is not applied if the pokemon's move fails", - async () => { - game.override.moveset([ Moves.BURN_UP ]); + test("ability is not applied if the pokemon's move fails", async () => { + game.override.moveset([Moves.BURN_UP]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.BURN_UP); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BURN_UP); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); + }); - test( - "ability applies correctly even if the pokemon's Trick-or-Treat fails", - async () => { - game.override.moveset([ Moves.TRICK_OR_TREAT ]); - game.override.enemySpecies(Species.GASTLY); + test("ability applies correctly even if the pokemon's Trick-or-Treat fails", async () => { + game.override.moveset([Moves.TRICK_OR_TREAT]); + game.override.enemySpecies(Species.GASTLY); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TRICK_OR_TREAT); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TRICK_OR_TREAT); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); + }); - test( - "ability applies correctly and the pokemon curses itself", - async () => { - game.override.moveset([ Moves.CURSE ]); + test("ability applies correctly and the pokemon curses itself", async () => { + game.override.moveset([Moves.CURSE]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.CURSE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CURSE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); - expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); + expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); + }); }); function testPokemonTypeMatchesDefaultMoveType(pokemon: PlayerPokemon, move: Moves) { diff --git a/test/abilities/magic_bounce.test.ts b/test/abilities/magic_bounce.test.ts index 398d0d530e1..f9a076776aa 100644 --- a/test/abilities/magic_bounce.test.ts +++ b/test/abilities/magic_bounce.test.ts @@ -31,7 +31,7 @@ describe("Abilities - Magic Bounce", () => { game.override .ability(Abilities.BALL_FETCH) .battleType("single") - .moveset( [ Moves.GROWL, Moves.SPLASH ]) + .moveset([Moves.GROWL, Moves.SPLASH]) .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.MAGIC_BOUNCE) @@ -39,7 +39,7 @@ describe("Abilities - Magic Bounce", () => { }); it("should reflect basic status moves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -47,13 +47,13 @@ describe("Abilities - Magic Bounce", () => { }); it("should not bounce moves while the target is in the semi-invulnerable state", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.GROWL ]); - game.override.enemyMoveset( [ Moves.FLY ]); + await game.classicMode.startBattle([Species.MAGIKARP]); + game.override.moveset([Moves.GROWL]); + game.override.enemyMoveset([Moves.FLY]); game.move.select(Moves.GROWL); await game.forceEnemyMove(Moves.FLY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getPlayerPokemon()!.getStatStage(Stat.ATK)).toBe(0); @@ -61,8 +61,8 @@ describe("Abilities - Magic Bounce", () => { it("should individually bounce back multi-target moves", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.GROWL, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.SPLASH]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.GROWL, 0); game.move.select(Moves.SPLASH, 1); @@ -73,9 +73,9 @@ describe("Abilities - Magic Bounce", () => { }); it("should still bounce back a move that would otherwise fail", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.scene.getEnemyPokemon()?.setStatStage(Stat.ATK, -6); - game.override.moveset([ Moves.GROWL ]); + game.override.moveset([Moves.GROWL]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -85,7 +85,7 @@ describe("Abilities - Magic Bounce", () => { it("should not bounce back a move that was just bounced", async () => { game.override.ability(Abilities.MAGIC_BOUNCE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -95,7 +95,7 @@ describe("Abilities - Magic Bounce", () => { it("should receive the stat change after reflecting a move back to a mirror armor user", async () => { game.override.ability(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -105,7 +105,7 @@ describe("Abilities - Magic Bounce", () => { it("should not bounce back a move from a mold breaker user", async () => { game.override.ability(Abilities.MOLD_BREAKER); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -115,9 +115,9 @@ describe("Abilities - Magic Bounce", () => { it("should bounce back a spread status move against both pokemon", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.GROWL, Moves.SPLASH ]); - game.override.enemyMoveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.SPLASH]); + game.override.enemyMoveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.GROWL, 0); game.move.select(Moves.SPLASH, 1); @@ -128,8 +128,8 @@ describe("Abilities - Magic Bounce", () => { it("should only bounce spikes back once in doubles when both targets have magic bounce", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.SPIKES ]); + await game.classicMode.startBattle([Species.MAGIKARP]); + game.override.moveset([Moves.SPIKES]); game.move.select(Moves.SPIKES); await game.phaseInterceptor.to("BerryPhase"); @@ -139,9 +139,9 @@ describe("Abilities - Magic Bounce", () => { }); it("should bounce spikes even when the target is protected", async () => { - game.override.moveset([ Moves.SPIKES ]); - game.override.enemyMoveset([ Moves.PROTECT ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPIKES]); + game.override.enemyMoveset([Moves.PROTECT]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPIKES); await game.phaseInterceptor.to("BerryPhase"); @@ -149,20 +149,20 @@ describe("Abilities - Magic Bounce", () => { }); it("should not bounce spikes when the target is in the semi-invulnerable state", async () => { - game.override.moveset([ Moves.SPIKES ]); - game.override.enemyMoveset([ Moves.FLY ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPIKES]); + game.override.enemyMoveset([Moves.FLY]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPIKES); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY)!["layers"]).toBe(1); }); - it("should not bounce back curse", async() => { + it("should not bounce back curse", async () => { game.override.starterSpecies(Species.GASTLY); - await game.classicMode.startBattle([ Species.GASTLY ]); - game.override.moveset([ Moves.CURSE ]); + await game.classicMode.startBattle([Species.GASTLY]); + game.override.moveset([Moves.CURSE]); game.move.select(Moves.CURSE); await game.phaseInterceptor.to("BerryPhase"); @@ -171,10 +171,10 @@ describe("Abilities - Magic Bounce", () => { }); it("should not cause encore to be interrupted after bouncing", async () => { - game.override.moveset([ Moves.SPLASH, Moves.GROWL, Moves.ENCORE ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.GROWL ]); + game.override.moveset([Moves.SPLASH, Moves.GROWL, Moves.ENCORE]); + game.override.enemyMoveset([Moves.TACKLE, Moves.GROWL]); // game.override.ability(Abilities.MOLD_BREAKER); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -184,34 +184,33 @@ describe("Abilities - Magic Bounce", () => { // turn 1 game.move.select(Moves.ENCORE); await game.forceEnemyMove(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyPokemon.getTag(BattlerTagType.ENCORE)!["moveId"]).toBe(Moves.TACKLE); // turn 2 vi.spyOn(playerPokemon, "getAbility").mockRestore(); game.move.select(Moves.GROWL); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon.getTag(BattlerTagType.ENCORE)!["moveId"]).toBe(Moves.TACKLE); expect(enemyPokemon.getLastXMoves()[0].move).toBe(Moves.TACKLE); - }); // TODO: encore is failing if the last move was virtual. it.todo("should not cause the bounced move to count for encore", async () => { - game.override.moveset([ Moves.SPLASH, Moves.GROWL, Moves.ENCORE ]); - game.override.enemyMoveset([ Moves.GROWL, Moves.TACKLE ]); + game.override.moveset([Moves.SPLASH, Moves.GROWL, Moves.ENCORE]); + game.override.enemyMoveset([Moves.GROWL, Moves.TACKLE]); game.override.enemyAbility(Abilities.MAGIC_BOUNCE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; // turn 1 game.move.select(Moves.GROWL); await game.forceEnemyMove(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); // Give the player MOLD_BREAKER for this turn to bypass Magic Bounce. @@ -220,7 +219,7 @@ describe("Abilities - Magic Bounce", () => { // turn 2 game.move.select(Moves.ENCORE); await game.forceEnemyMove(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon.getTag(BattlerTagType.ENCORE)!["moveId"]).toBe(Moves.TACKLE); expect(enemyPokemon.getLastXMoves()[0].move).toBe(Moves.TACKLE); @@ -229,8 +228,8 @@ describe("Abilities - Magic Bounce", () => { // TODO: stomping tantrum should consider moves that were bounced. it.todo("should cause stomping tantrum to double in power when the last move was bounced", async () => { game.override.battleType("single"); - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.STOMPING_TANTRUM, Moves.CHARM ]); + await game.classicMode.startBattle([Species.MAGIKARP]); + game.override.moveset([Moves.STOMPING_TANTRUM, Moves.CHARM]); const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; vi.spyOn(stomping_tantrum, "calculateBattlePower"); @@ -244,33 +243,36 @@ describe("Abilities - Magic Bounce", () => { }); // TODO: stomping tantrum should consider moves that were bounced. - it.todo("should properly cause the enemy's stomping tantrum to be doubled in power after bouncing and failing", async () => { - game.override.enemyMoveset([ Moves.STOMPING_TANTRUM, Moves.SPLASH, Moves.CHARM ]); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + it.todo( + "should properly cause the enemy's stomping tantrum to be doubled in power after bouncing and failing", + async () => { + game.override.enemyMoveset([Moves.STOMPING_TANTRUM, Moves.SPLASH, Moves.CHARM]); + await game.classicMode.startBattle([Species.BULBASAUR]); - const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; - const enemy = game.scene.getEnemyPokemon()!; - vi.spyOn(stomping_tantrum, "calculateBattlePower"); + const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; + const enemy = game.scene.getEnemyPokemon()!; + vi.spyOn(stomping_tantrum, "calculateBattlePower"); - game.move.select(Moves.SPORE); - await game.forceEnemyMove(Moves.CHARM); - await game.phaseInterceptor.to("TurnEndPhase"); - expect(enemy.getLastXMoves(1)[0].result).toBe("success"); + game.move.select(Moves.SPORE); + await game.forceEnemyMove(Moves.CHARM); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.getLastXMoves(1)[0].result).toBe("success"); - await game.phaseInterceptor.to("BerryPhase"); - expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); + await game.phaseInterceptor.to("BerryPhase"); + expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); - await game.toNextTurn(); - game.move.select(Moves.GROWL); - await game.phaseInterceptor.to("BerryPhase"); - expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); - }); + await game.toNextTurn(); + game.move.select(Moves.GROWL); + await game.phaseInterceptor.to("BerryPhase"); + expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); + }, + ); it("should respect immunities when bouncing a move", async () => { vi.spyOn(allMoves[Moves.THUNDER_WAVE], "accuracy", "get").mockReturnValue(100); - game.override.moveset([ Moves.THUNDER_WAVE, Moves.GROWL ]); + game.override.moveset([Moves.THUNDER_WAVE, Moves.GROWL]); game.override.ability(Abilities.SOUNDPROOF); - await game.classicMode.startBattle([ Species.PHANPY ]); + await game.classicMode.startBattle([Species.PHANPY]); // Turn 1 - thunder wave immunity test game.move.select(Moves.THUNDER_WAVE); @@ -284,8 +286,8 @@ describe("Abilities - Magic Bounce", () => { }); it("should bounce back a move before the accuracy check", async () => { - game.override.moveset([ Moves.SPORE ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPORE]); + await game.classicMode.startBattle([Species.MAGIKARP]); const attacker = game.scene.getPlayerPokemon()!; @@ -296,8 +298,8 @@ describe("Abilities - Magic Bounce", () => { }); it("should take the accuracy of the magic bounce user into account", async () => { - game.override.moveset([ Moves.SPORE ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPORE]); + await game.classicMode.startBattle([Species.MAGIKARP]); const opponent = game.scene.getEnemyPokemon()!; vi.spyOn(opponent, "getAccuracyMultiplier").mockReturnValue(0); @@ -308,10 +310,10 @@ describe("Abilities - Magic Bounce", () => { it("should always apply the leftmost available target's magic bounce when bouncing moves like sticky webs in doubles", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.STICKY_WEB, Moves.SPLASH, Moves.TRICK_ROOM ]); + game.override.moveset([Moves.STICKY_WEB, Moves.SPLASH, Moves.TRICK_ROOM]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); - const [ enemy_1, enemy_2 ] = game.scene.getEnemyField(); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); + const [enemy_1, enemy_2] = game.scene.getEnemyField(); // set speed just incase logic erroneously checks for speed order enemy_1.setStat(Stat.SPD, enemy_2.getStat(Stat.SPD) + 1); @@ -320,32 +322,41 @@ describe("Abilities - Magic Bounce", () => { game.move.select(Moves.TRICK_ROOM, 1); await game.phaseInterceptor.to("TurnEndPhase"); - expect(game.scene.arena.getTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER)?.getSourcePokemon()?.getBattlerIndex()).toBe(BattlerIndex.ENEMY); + expect( + game.scene.arena + .getTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER) + ?.getSourcePokemon() + ?.getBattlerIndex(), + ).toBe(BattlerIndex.ENEMY); game.scene.arena.removeTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER, true); // turn 2 game.move.select(Moves.STICKY_WEB, 0); game.move.select(Moves.TRICK_ROOM, 1); await game.phaseInterceptor.to("BerryPhase"); - expect(game.scene.arena.getTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER)?.getSourcePokemon()?.getBattlerIndex()).toBe(BattlerIndex.ENEMY); + expect( + game.scene.arena + .getTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER) + ?.getSourcePokemon() + ?.getBattlerIndex(), + ).toBe(BattlerIndex.ENEMY); }); it("should not bounce back status moves that hit through semi-invulnerable states", async () => { - game.override.moveset([ Moves.TOXIC, Moves.CHARM ]); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + game.override.moveset([Moves.TOXIC, Moves.CHARM]); + await game.classicMode.startBattle([Species.BULBASAUR]); game.move.select(Moves.TOXIC); await game.forceEnemyMove(Moves.FLY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.TOXIC); expect(game.scene.getPlayerPokemon()!.status).toBeUndefined(); game.override.ability(Abilities.NO_GUARD); game.move.select(Moves.CHARM); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(-2); expect(game.scene.getPlayerPokemon()!.getStatStage(Stat.ATK)).toBe(0); }); }); - diff --git a/test/abilities/magic_guard.test.ts b/test/abilities/magic_guard.test.ts index a2a88915419..96a9f4dab74 100644 --- a/test/abilities/magic_guard.test.ts +++ b/test/abilities/magic_guard.test.ts @@ -31,7 +31,7 @@ describe("Abilities - Magic Guard", () => { /** Player Pokemon overrides */ game.override.ability(Abilities.MAGIC_GUARD); - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); game.override.startingLevel(100); /** Enemy Pokemon overrides */ @@ -43,138 +43,123 @@ describe("Abilities - Magic Guard", () => { //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Magic_Guard_(Ability) - it( - "ability should prevent damage caused by weather", - async () => { - game.override.weather(WeatherType.SANDSTORM); + it("ability should prevent damage caused by weather", async () => { + game.override.weather(WeatherType.SANDSTORM); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon).toBeDefined(); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - /** - * Expect: - * - The player Pokemon (with Magic Guard) has not taken damage from weather - * - The enemy Pokemon (without Magic Guard) has taken damage from weather - */ - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + /** + * Expect: + * - The player Pokemon (with Magic Guard) has not taken damage from weather + * - The enemy Pokemon (without Magic Guard) has taken damage from weather + */ + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); - it( - "ability should prevent damage caused by status effects but other non-damage effects still apply", - async () => { - //Toxic keeps track of the turn counters -> important that Magic Guard keeps track of post-Toxic turns - game.override.statusEffect(StatusEffect.POISON); + it("ability should prevent damage caused by status effects but other non-damage effects still apply", async () => { + //Toxic keeps track of the turn counters -> important that Magic Guard keeps track of post-Toxic turns + game.override.statusEffect(StatusEffect.POISON); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - /** - * Expect: - * - The player Pokemon (with Magic Guard) has not taken damage from poison - * - The Pokemon's CatchRateMultiplier should be 1.5 - */ - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(getStatusEffectCatchRateMultiplier(leadPokemon.status!.effect)).toBe(1.5); - } - ); + /** + * Expect: + * - The player Pokemon (with Magic Guard) has not taken damage from poison + * - The Pokemon's CatchRateMultiplier should be 1.5 + */ + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(getStatusEffectCatchRateMultiplier(leadPokemon.status!.effect)).toBe(1.5); + }); - it( - "ability effect should not persist when the ability is replaced", - async () => { - game.override.enemyMoveset([ Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED ]); - game.override.statusEffect(StatusEffect.POISON); + it("ability effect should not persist when the ability is replaced", async () => { + game.override.enemyMoveset([Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED]); + game.override.statusEffect(StatusEffect.POISON); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - /** - * Expect: - * - The player Pokemon (that just lost its Magic Guard ability) has taken damage from poison - */ - expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); - } - ); + /** + * Expect: + * - The player Pokemon (that just lost its Magic Guard ability) has taken damage from poison + */ + expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); + }); + it("Magic Guard prevents damage caused by burn but other non-damaging effects are still applied", async () => { + game.override.enemyStatusEffect(StatusEffect.BURN); + game.override.enemyAbility(Abilities.MAGIC_GUARD); - it("Magic Guard prevents damage caused by burn but other non-damaging effects are still applied", - async () => { - game.override.enemyStatusEffect(StatusEffect.BURN); - game.override.enemyAbility(Abilities.MAGIC_GUARD); + await game.startBattle([Species.MAGIKARP]); - await game.startBattle([ Species.MAGIKARP ]); + game.move.select(Moves.SPLASH); - game.move.select(Moves.SPLASH); + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + await game.phaseInterceptor.to(TurnEndPhase); - await game.phaseInterceptor.to(TurnEndPhase); + /** + * Expect: + * - The enemy Pokemon (with Magic Guard) has not taken damage from burn + * - The enemy Pokemon's physical attack damage is halved (TBD) + * - The enemy Pokemon's hypothetical CatchRateMultiplier should be 1.5 + */ + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(getStatusEffectCatchRateMultiplier(enemyPokemon.status!.effect)).toBe(1.5); + }); - /** - * Expect: - * - The enemy Pokemon (with Magic Guard) has not taken damage from burn - * - The enemy Pokemon's physical attack damage is halved (TBD) - * - The enemy Pokemon's hypothetical CatchRateMultiplier should be 1.5 - */ - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(getStatusEffectCatchRateMultiplier(enemyPokemon.status!.effect)).toBe(1.5); - } - ); + it("Magic Guard prevents damage caused by toxic but other non-damaging effects are still applied", async () => { + game.override.enemyStatusEffect(StatusEffect.TOXIC); + game.override.enemyAbility(Abilities.MAGIC_GUARD); - it("Magic Guard prevents damage caused by toxic but other non-damaging effects are still applied", - async () => { - game.override.enemyStatusEffect(StatusEffect.TOXIC); - game.override.enemyAbility(Abilities.MAGIC_GUARD); + await game.startBattle([Species.MAGIKARP]); - await game.startBattle([ Species.MAGIKARP ]); + game.move.select(Moves.SPLASH); - game.move.select(Moves.SPLASH); + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const toxicStartCounter = enemyPokemon.status!.toxicTurnCount; + //should be 0 - const toxicStartCounter = enemyPokemon.status!.toxicTurnCount; - //should be 0 - - await game.phaseInterceptor.to(TurnEndPhase); - - /** - * Expect: - * - The enemy Pokemon (with Magic Guard) has not taken damage from toxic - * - The enemy Pokemon's status effect duration should be incremented - * - The enemy Pokemon's hypothetical CatchRateMultiplier should be 1.5 - */ - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(enemyPokemon.status!.toxicTurnCount).toBeGreaterThan(toxicStartCounter); - expect(getStatusEffectCatchRateMultiplier(enemyPokemon.status!.effect)).toBe(1.5); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + /** + * Expect: + * - The enemy Pokemon (with Magic Guard) has not taken damage from toxic + * - The enemy Pokemon's status effect duration should be incremented + * - The enemy Pokemon's hypothetical CatchRateMultiplier should be 1.5 + */ + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(enemyPokemon.status!.toxicTurnCount).toBeGreaterThan(toxicStartCounter); + expect(getStatusEffectCatchRateMultiplier(enemyPokemon.status!.effect)).toBe(1.5); + }); it("Magic Guard prevents damage caused by entry hazards", async () => { //Adds and applies Spikes to both sides of the arena const newTag = getArenaTag(ArenaTagType.SPIKES, 5, Moves.SPIKES, 0, 0, ArenaTagSide.BOTH)!; game.scene.arena.tags.push(newTag); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); @@ -184,14 +169,13 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) has not taken damage from spikes - * - The enemy Pokemon (without Magic Guard) has taken damage from spikes - */ + * Expect: + * - The player Pokemon (with Magic Guard) has not taken damage from spikes + * - The enemy Pokemon (without Magic Guard) has taken damage from spikes + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + }); it("Magic Guard does not prevent poison from Toxic Spikes", async () => { //Adds and applies Spikes to both sides of the arena @@ -200,7 +184,7 @@ describe("Abilities - Magic Guard", () => { game.scene.arena.tags.push(playerTag); game.scene.arena.tags.push(enemyTag); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); @@ -210,47 +194,44 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - Both Pokemon gain the poison status effect - * - The player Pokemon (with Magic Guard) has not taken damage from poison - * - The enemy Pokemon (without Magic Guard) has taken damage from poison - */ + * Expect: + * - Both Pokemon gain the poison status effect + * - The player Pokemon (with Magic Guard) has not taken damage from poison + * - The enemy Pokemon (without Magic Guard) has taken damage from poison + */ expect(leadPokemon.status!.effect).toBe(StatusEffect.POISON); expect(enemyPokemon.status!.effect).toBe(StatusEffect.POISON); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + }); - it("Magic Guard prevents against damage from volatile status effects", - async () => { - await game.startBattle([ Species.DUSKULL ]); - game.override.moveset([ Moves.CURSE ]); - game.override.enemyAbility(Abilities.MAGIC_GUARD); + it("Magic Guard prevents against damage from volatile status effects", async () => { + await game.startBattle([Species.DUSKULL]); + game.override.moveset([Moves.CURSE]); + game.override.enemyAbility(Abilities.MAGIC_GUARD); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.CURSE); + game.move.select(Moves.CURSE); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - /** - * Expect: - * - The player Pokemon (with Magic Guard) has cut its HP to inflict curse - * - The enemy Pokemon (with Magic Guard) is cursed - * - The enemy Pokemon (with Magic Guard) does not lose HP from being cursed - */ - expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); - expect(enemyPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + /** + * Expect: + * - The player Pokemon (with Magic Guard) has cut its HP to inflict curse + * - The enemy Pokemon (with Magic Guard) is cursed + * - The enemy Pokemon (with Magic Guard) does not lose HP from being cursed + */ + expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); + expect(enemyPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); it("Magic Guard prevents crash damage", async () => { - game.override.moveset([ Moves.HIGH_JUMP_KICK ]); - await game.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.HIGH_JUMP_KICK]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -260,16 +241,15 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) misses High Jump Kick but does not lose HP as a result - */ + * Expect: + * - The player Pokemon (with Magic Guard) misses High Jump Kick but does not lose HP as a result + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard prevents damage from recoil", async () => { - game.override.moveset([ Moves.TAKE_DOWN ]); - await game.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.TAKE_DOWN]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -278,16 +258,15 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) uses a recoil move but does not lose HP from recoil - */ + * Expect: + * - The player Pokemon (with Magic Guard) uses a recoil move but does not lose HP from recoil + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard does not prevent damage from Struggle's recoil", async () => { - game.override.moveset([ Moves.STRUGGLE ]); - await game.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.STRUGGLE]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -296,17 +275,16 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) uses Struggle but does lose HP from Struggle's recoil - */ + * Expect: + * - The player Pokemon (with Magic Guard) uses Struggle but does lose HP from Struggle's recoil + */ expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); - } - ); + }); //This tests different move attributes than the recoil tests above it("Magic Guard prevents self-damage from attacking moves", async () => { - game.override.moveset([ Moves.STEEL_BEAM ]); - await game.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.STEEL_BEAM]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -315,12 +293,11 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) uses a move with an HP cost but does not lose HP from using it - */ + * Expect: + * - The player Pokemon (with Magic Guard) uses a move with an HP cost but does not lose HP from using it + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); /* it("Magic Guard does not prevent self-damage from confusion", async () => { @@ -333,8 +310,8 @@ describe("Abilities - Magic Guard", () => { */ it("Magic Guard does not prevent self-damage from non-attacking moves", async () => { - game.override.moveset([ Moves.BELLY_DRUM ]); - await game.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.BELLY_DRUM]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -343,21 +320,20 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) uses a non-attacking move with an HP cost and thus loses HP from using it - */ + * Expect: + * - The player Pokemon (with Magic Guard) uses a non-attacking move with an HP cost and thus loses HP from using it + */ expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async () => { //Tests the ability Bad Dreams game.override.statusEffect(StatusEffect.SLEEP); //enemy pokemon is given Spore just in case player pokemon somehow awakens during test - game.override.enemyMoveset([ Moves.SPORE, Moves.SPORE, Moves.SPORE, Moves.SPORE ]); + game.override.enemyMoveset([Moves.SPORE, Moves.SPORE, Moves.SPORE, Moves.SPORE]); game.override.enemyAbility(Abilities.BAD_DREAMS); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -366,21 +342,20 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute - * - The player Pokemon is asleep - */ + * Expect: + * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute + * - The player Pokemon is asleep + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.status!.effect).toBe(StatusEffect.SLEEP); - } - ); + }); it("Magic Guard prevents damage from abilities with PostFaintContactDamageAbAttr", async () => { //Tests the abilities Innards Out/Aftermath - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.AFTERMATH); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -391,21 +366,20 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute - * - The enemy Pokemon has fainted - */ + * Expect: + * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute + * - The enemy Pokemon has fainted + */ expect(enemyPokemon.hp).toBe(0); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard prevents damage from abilities with PostDefendContactDamageAbAttr", async () => { //Tests the abilities Iron Barbs/Rough Skin - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.IRON_BARBS); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -415,21 +389,20 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute - * - The player Pokemon's move should have connected - */ + * Expect: + * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute + * - The player Pokemon's move should have connected + */ expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard prevents damage from abilities with ReverseDrainAbAttr", async () => { //Tests the ability Liquid Ooze - game.override.moveset([ Moves.ABSORB ]); + game.override.moveset([Moves.ABSORB]); game.override.enemyAbility(Abilities.LIQUID_OOZE); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; @@ -439,30 +412,28 @@ describe("Abilities - Magic Guard", () => { await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute - * - The player Pokemon's move should have connected - */ + * Expect: + * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute + * - The player Pokemon's move should have connected + */ expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); it("Magic Guard prevents HP loss from abilities with PostWeatherLapseDamageAbAttr", async () => { //Tests the abilities Solar Power/Dry Skin game.override.passiveAbility(Abilities.SOLAR_POWER); game.override.weather(WeatherType.SUNNY); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); /** - * Expect: - * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute - */ + * Expect: + * - The player Pokemon (with Magic Guard) should not lose HP due to this ability attribute + */ expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + }); }); diff --git a/test/abilities/mimicry.test.ts b/test/abilities/mimicry.test.ts index 63f8bb5b15e..df6f7905c83 100644 --- a/test/abilities/mimicry.test.ts +++ b/test/abilities/mimicry.test.ts @@ -23,7 +23,7 @@ describe("Abilities - Mimicry", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.MIMICRY) .battleType("single") .disableCrits() @@ -33,9 +33,9 @@ describe("Abilities - Mimicry", () => { it("Mimicry activates after the Pokémon with Mimicry is switched in while terrain is present, or whenever there is a change in terrain", async () => { game.override.enemyAbility(Abilities.MISTY_SURGE); - await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.ABRA]); - const [ playerPokemon1, playerPokemon2 ] = game.scene.getPlayerParty(); + const [playerPokemon1, playerPokemon2] = game.scene.getPlayerParty(); game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(playerPokemon1.getTypes().includes(PokemonType.FAIRY)).toBe(true); @@ -48,10 +48,10 @@ describe("Abilities - Mimicry", () => { it("Pokemon should revert back to its original, root type once terrain ends", async () => { game.override - .moveset([ Moves.SPLASH, Moves.TRANSFORM ]) + .moveset([Moves.SPLASH, Moves.TRANSFORM]) .enemyAbility(Abilities.MIMICRY) - .enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + .enemyMoveset([Moves.SPLASH, Moves.PSYCHIC_TERRAIN]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.TRANSFORM); @@ -70,9 +70,8 @@ describe("Abilities - Mimicry", () => { }); it("If the Pokemon is under the effect of a type-adding move and an equivalent terrain activates, the move's effect disappears", async () => { - game.override - .enemyMoveset([ Moves.FORESTS_CURSE, Moves.GRASSY_TERRAIN ]); - await game.classicMode.startBattle([ Species.FEEBAS ]); + game.override.enemyMoveset([Moves.FORESTS_CURSE, Moves.GRASSY_TERRAIN]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.SPLASH); diff --git a/test/abilities/mirror_armor.test.ts b/test/abilities/mirror_armor.test.ts index 1d103c45be1..6b0c3f10c84 100644 --- a/test/abilities/mirror_armor.test.ts +++ b/test/abilities/mirror_armor.test.ts @@ -26,19 +26,20 @@ describe("Ability - Mirror Armor", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .enemySpecies(Species.RATTATA) - .enemyMoveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ]) + .enemyMoveset([Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK]) .enemyAbility(Abilities.BALL_FETCH) .startingLevel(2000) - .moveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ]) + .moveset([Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK]) .ability(Abilities.BALL_FETCH); }); it("Player side + single battle Intimidate - opponent loses stats", async () => { game.override.ability(Abilities.MIRROR_ARMOR); game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -55,7 +56,7 @@ describe("Ability - Mirror Armor", () => { it("Enemy side + single battle Intimidate - player loses stats", async () => { game.override.enemyAbility(Abilities.MIRROR_ARMOR); game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -73,10 +74,10 @@ describe("Ability - Mirror Armor", () => { game.override.battleType("double"); game.override.ability(Abilities.MIRROR_ARMOR); game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + const [player1, player2] = game.scene.getPlayerField(); // Enemy has intimidate, enemy should lose -2 atk each game.move.select(Moves.SPLASH); @@ -95,10 +96,10 @@ describe("Ability - Mirror Armor", () => { game.override.battleType("double"); game.override.enemyAbility(Abilities.MIRROR_ARMOR); game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + const [player1, player2] = game.scene.getPlayerField(); // Enemy has intimidate, enemy should lose -1 atk game.move.select(Moves.SPLASH); @@ -116,7 +117,7 @@ describe("Ability - Mirror Armor", () => { it("Player side + single battle Intimidate + Tickle - opponent loses stats", async () => { game.override.ability(Abilities.MIRROR_ARMOR); game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -136,10 +137,10 @@ describe("Ability - Mirror Armor", () => { game.override.battleType("double"); game.override.ability(Abilities.MIRROR_ARMOR); game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + const [player1, player2] = game.scene.getPlayerField(); game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH, 1); @@ -155,13 +156,12 @@ describe("Ability - Mirror Armor", () => { expect(enemy1.getStatStage(Stat.DEF)).toBe(-1); expect(enemy2.getStatStage(Stat.ATK)).toBe(-3); expect(enemy2.getStatStage(Stat.DEF)).toBe(-1); - }); it("Enemy side + single battle Intimidate + Tickle - player loses stats", async () => { game.override.enemyAbility(Abilities.MIRROR_ARMOR); game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -180,7 +180,7 @@ describe("Ability - Mirror Armor", () => { it("Player side + single battle Intimidate + oppoenent has white smoke - no one loses stats", async () => { game.override.enemyAbility(Abilities.WHITE_SMOKE); game.override.ability(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -199,7 +199,7 @@ describe("Ability - Mirror Armor", () => { it("Enemy side + single battle Intimidate + player has white smoke - no one loses stats", async () => { game.override.ability(Abilities.WHITE_SMOKE); game.override.enemyAbility(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -217,7 +217,7 @@ describe("Ability - Mirror Armor", () => { it("Player side + single battle + opponent uses octolock - does not interact with mirror armor, player loses stats", async () => { game.override.ability(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -235,7 +235,7 @@ describe("Ability - Mirror Armor", () => { it("Enemy side + single battle + player uses octolock - does not interact with mirror armor, opponent loses stats", async () => { game.override.enemyAbility(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -255,7 +255,7 @@ describe("Ability - Mirror Armor", () => { game.override.enemyAbility(Abilities.MIRROR_ARMOR); game.override.ability(Abilities.MIRROR_ARMOR); game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -270,7 +270,7 @@ describe("Ability - Mirror Armor", () => { it("Single battle + sticky web applied player side - player switches out and enemy should lose -1 speed", async () => { game.override.ability(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); const enemyPokemon = game.scene.getEnemyPokemon()!; const userPokemon = game.scene.getPlayerPokemon()!; @@ -290,10 +290,10 @@ describe("Ability - Mirror Armor", () => { it("Double battle + sticky web applied player side - player switches out and enemy 1 should lose -1 speed", async () => { game.override.battleType("double"); game.override.ability(Abilities.MIRROR_ARMOR); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); - const [ player1, player2 ] = game.scene.getPlayerField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); + const [player1, player2] = game.scene.getPlayerField(); game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH, 1); diff --git a/test/abilities/moody.test.ts b/test/abilities/moody.test.ts index 64c2c7d8a07..da24899a4b0 100644 --- a/test/abilities/moody.test.ts +++ b/test/abilities/moody.test.ts @@ -32,57 +32,56 @@ describe("Abilities - Moody", () => { .moveset(Moves.SPLASH); }); - it("should increase one stat stage by 2 and decrease a different stat stage by 1", - async () => { - await game.classicMode.startBattle(); + it("should increase one stat stage by 2 and decrease a different stat stage by 1", async () => { + await game.classicMode.startBattle(); - const playerPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SPLASH); - await game.toNextTurn(); + const playerPokemon = game.scene.getPlayerPokemon()!; + game.move.select(Moves.SPLASH); + await game.toNextTurn(); - // Find the increased and decreased stats, make sure they are different. - const changedStats = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 2 || playerPokemon.getStatStage(s) === -1); + // Find the increased and decreased stats, make sure they are different. + const changedStats = EFFECTIVE_STATS.filter( + s => playerPokemon.getStatStage(s) === 2 || playerPokemon.getStatStage(s) === -1, + ); - expect(changedStats).toBeTruthy(); - expect(changedStats.length).toBe(2); - expect(changedStats[0] !== changedStats[1]).toBeTruthy(); - }); + expect(changedStats).toBeTruthy(); + expect(changedStats.length).toBe(2); + expect(changedStats[0] !== changedStats[1]).toBeTruthy(); + }); - it("should only increase one stat stage by 2 if all stat stages are at -6", - async () => { - await game.classicMode.startBattle(); + it("should only increase one stat stage by 2 if all stat stages are at -6", async () => { + await game.classicMode.startBattle(); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - // Set all stat stages to -6 - vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(-6)); + // Set all stat stages to -6 + vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(-6)); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); - // Should increase one stat stage by 2 (from -6, meaning it will be -4) - const increasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === -4); + // Should increase one stat stage by 2 (from -6, meaning it will be -4) + const increasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === -4); - expect(increasedStat).toBeTruthy(); - expect(increasedStat.length).toBe(1); - }); + expect(increasedStat).toBeTruthy(); + expect(increasedStat.length).toBe(1); + }); - it("should only decrease one stat stage by 1 stage if all stat stages are at 6", - async () => { - await game.classicMode.startBattle(); + it("should only decrease one stat stage by 1 stage if all stat stages are at 6", async () => { + await game.classicMode.startBattle(); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - // Set all stat stages to 6 - vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(6)); + // Set all stat stages to 6 + vi.spyOn(playerPokemon.summonData, "statStages", "get").mockReturnValue(new Array(BATTLE_STATS.length).fill(6)); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); - // Should decrease one stat stage by 1 (from 6, meaning it will be 5) - const decreasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 5); + // Should decrease one stat stage by 1 (from 6, meaning it will be 5) + const decreasedStat = EFFECTIVE_STATS.filter(s => playerPokemon.getStatStage(s) === 5); - expect(decreasedStat).toBeTruthy(); - expect(decreasedStat.length).toBe(1); - }); + expect(decreasedStat).toBeTruthy(); + expect(decreasedStat.length).toBe(1); + }); }); diff --git a/test/abilities/moxie.test.ts b/test/abilities/moxie.test.ts index c518c55671f..ec93aebd2c0 100644 --- a/test/abilities/moxie.test.ts +++ b/test/abilities/moxie.test.ts @@ -32,16 +32,13 @@ describe("Abilities - Moxie", () => { game.override.enemyAbility(Abilities.MOXIE); game.override.ability(Abilities.MOXIE); game.override.startingLevel(2000); - game.override.moveset([ moveToUse ]); + game.override.moveset([moveToUse]); game.override.enemyMoveset(Moves.SPLASH); }); - it("should raise ATK stat stage by 1 when winning a battle", async() => { + it("should raise ATK stat stage by 1 when winning a battle", async () => { const moveToUse = Moves.AERIAL_ACE; - await game.startBattle([ - Species.MIGHTYENA, - Species.MIGHTYENA, - ]); + await game.startBattle([Species.MIGHTYENA, Species.MIGHTYENA]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -54,25 +51,26 @@ describe("Abilities - Moxie", () => { }, 20000); // TODO: Activate this test when MOXIE is corrected to work on faint and not on battle victory - it.todo("should raise ATK stat stage by 1 when defeating an ally Pokemon", async() => { - game.override.battleType("double"); - const moveToUse = Moves.AERIAL_ACE; - await game.startBattle([ - Species.MIGHTYENA, - Species.MIGHTYENA, - ]); + it.todo( + "should raise ATK stat stage by 1 when defeating an ally Pokemon", + async () => { + game.override.battleType("double"); + const moveToUse = Moves.AERIAL_ACE; + await game.startBattle([Species.MIGHTYENA, Species.MIGHTYENA]); - const [ firstPokemon, secondPokemon ] = game.scene.getPlayerField(); + const [firstPokemon, secondPokemon] = game.scene.getPlayerField(); - expect(firstPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(firstPokemon.getStatStage(Stat.ATK)).toBe(0); - secondPokemon.hp = 1; + secondPokemon.hp = 1; - game.move.select(moveToUse); - game.selectTarget(BattlerIndex.PLAYER_2); + game.move.select(moveToUse); + game.selectTarget(BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - expect(firstPokemon.getStatStage(Stat.ATK)).toBe(1); - }, 20000); + expect(firstPokemon.getStatStage(Stat.ATK)).toBe(1); + }, + 20000, + ); }); diff --git a/test/abilities/mummy.test.ts b/test/abilities/mummy.test.ts index 96b5e170c14..0971353c14d 100644 --- a/test/abilities/mummy.test.ts +++ b/test/abilities/mummy.test.ts @@ -22,7 +22,7 @@ describe("Abilities - Mummy", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.MUMMY) .battleType("single") .disableCrits() @@ -32,7 +32,7 @@ describe("Abilities - Mummy", () => { }); it("should set the enemy's ability to mummy when hit by a contact move", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -42,7 +42,7 @@ describe("Abilities - Mummy", () => { it("should not change the enemy's ability hit by a non-contact move", async () => { game.override.enemyMoveset(Moves.EARTHQUAKE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/mycelium_might.test.ts b/test/abilities/mycelium_might.test.ts index 2c0bd39b32a..8c7796ec736 100644 --- a/test/abilities/mycelium_might.test.ts +++ b/test/abilities/mycelium_might.test.ts @@ -28,9 +28,9 @@ describe("Abilities - Mycelium Might", () => { game.override.disableCrits(); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.CLEAR_BODY); - game.override.enemyMoveset([ Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK ]); + game.override.enemyMoveset([Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK]); game.override.ability(Abilities.MYCELIUM_MIGHT); - game.override.moveset([ Moves.QUICK_ATTACK, Moves.BABY_DOLL_EYES ]); + game.override.moveset([Moves.QUICK_ATTACK, Moves.BABY_DOLL_EYES]); }); /** @@ -41,7 +41,7 @@ describe("Abilities - Mycelium Might", () => { **/ it("will move last in its priority bracket and ignore protective abilities", async () => { - await game.startBattle([ Species.REGIELEKI ]); + await game.startBattle([Species.REGIELEKI]); const enemyPokemon = game.scene.getEnemyPokemon(); const playerIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); @@ -55,8 +55,8 @@ describe("Abilities - Mycelium Might", () => { const commandOrder = phase.getCommandOrder(); // The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon. // The player Pokemon (with Mycelium Might) goes last despite having higher speed than the opponent. - expect(speedOrder).toEqual([ playerIndex, enemyIndex ]); - expect(commandOrder).toEqual([ enemyIndex, playerIndex ]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); await game.phaseInterceptor.to(TurnEndPhase); // Despite the opponent's ability (Clear Body), its ATK stat stage is still reduced. @@ -64,8 +64,8 @@ describe("Abilities - Mycelium Might", () => { }, 20000); it("will still go first if a status move that is in a higher priority bracket than the opponent's move is used", async () => { - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); - await game.startBattle([ Species.REGIELEKI ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); + await game.startBattle([Species.REGIELEKI]); const enemyPokemon = game.scene.getEnemyPokemon(); const playerIndex = game.scene.getPlayerPokemon()?.getBattlerIndex(); @@ -79,15 +79,15 @@ describe("Abilities - Mycelium Might", () => { const commandOrder = phase.getCommandOrder(); // The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent. // The enemy Pokemon goes second because its move is in a lower priority bracket. - expect(speedOrder).toEqual([ playerIndex, enemyIndex ]); - expect(commandOrder).toEqual([ playerIndex, enemyIndex ]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); await game.phaseInterceptor.to(TurnEndPhase); // Despite the opponent's ability (Clear Body), its ATK stat stage is still reduced. expect(enemyPokemon?.getStatStage(Stat.ATK)).toBe(-1); }, 20000); it("will not affect non-status moves", async () => { - await game.startBattle([ Species.REGIELEKI ]); + await game.startBattle([Species.REGIELEKI]); const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); @@ -101,7 +101,7 @@ describe("Abilities - Mycelium Might", () => { // The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move. // The enemy Pokemon (without M.M.) goes second because its speed is lower. // This means that the commandOrder should be identical to the speedOrder - expect(speedOrder).toEqual([ playerIndex, enemyIndex ]); - expect(commandOrder).toEqual([ playerIndex, enemyIndex ]); + expect(speedOrder).toEqual([playerIndex, enemyIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); }, 20000); }); diff --git a/test/abilities/neutralizing_gas.test.ts b/test/abilities/neutralizing_gas.test.ts index a0612078e64..2bba5b83987 100644 --- a/test/abilities/neutralizing_gas.test.ts +++ b/test/abilities/neutralizing_gas.test.ts @@ -26,7 +26,7 @@ describe("Abilities - Neutralizing Gas", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.NEUTRALIZING_GAS) .battleType("single") .disableCrits() @@ -37,7 +37,7 @@ describe("Abilities - Neutralizing Gas", () => { it("should prevent other abilities from activating", async () => { game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); @@ -48,7 +48,7 @@ describe("Abilities - Neutralizing Gas", () => { it("should allow the user's passive to activate", async () => { game.override.passiveAbility(Abilities.INTREPID_SWORD); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); @@ -57,11 +57,9 @@ describe("Abilities - Neutralizing Gas", () => { }); it.todo("should activate before other abilities", async () => { - game.override.enemySpecies(Species.ACCELGOR) - .enemyLevel(100) - .enemyAbility(Abilities.INTIMIDATE); + game.override.enemySpecies(Species.ACCELGOR).enemyLevel(100).enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); @@ -71,11 +69,12 @@ describe("Abilities - Neutralizing Gas", () => { }); it("should activate other abilities when removed", async () => { - game.override.enemyAbility(Abilities.INTREPID_SWORD) + game.override + .enemyAbility(Abilities.INTREPID_SWORD) .enemyPassiveAbility(Abilities.DAUNTLESS_SHIELD) .enemyMoveset(Moves.ENTRAINMENT); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemyPokemon = game.scene.getEnemyPokemon(); expect(enemyPokemon?.getStatStage(Stat.ATK)).toBe(0); @@ -89,10 +88,9 @@ describe("Abilities - Neutralizing Gas", () => { }); it("should not activate the user's other ability when removed", async () => { - game.override.passiveAbility(Abilities.INTIMIDATE) - .enemyMoveset(Moves.ENTRAINMENT); + game.override.passiveAbility(Abilities.INTIMIDATE).enemyMoveset(Moves.ENTRAINMENT); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); // Neutralising gas user's passive is still active const enemyPokemon = game.scene.getEnemyPokemon(); expect(enemyPokemon?.getStatStage(Stat.ATK)).toBe(-1); @@ -104,15 +102,14 @@ describe("Abilities - Neutralizing Gas", () => { }); it("should only deactivate when all setters are off the field", async () => { - game.override.enemyMoveset([ Moves.ENTRAINMENT, Moves.SPLASH ]) - .battleType("double"); + game.override.enemyMoveset([Moves.ENTRAINMENT, Moves.SPLASH]).battleType("double"); - await game.classicMode.startBattle([ Species.ACCELGOR, Species.ACCELGOR ]); + await game.classicMode.startBattle([Species.ACCELGOR, Species.ACCELGOR]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.SPLASH, 1); await game.forceEnemyMove(Moves.ENTRAINMENT, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined(); // Now one neut gas user is left @@ -120,7 +117,7 @@ describe("Abilities - Neutralizing Gas", () => { game.move.select(Moves.SPLASH, 1); await game.forceEnemyMove(Moves.ENTRAINMENT, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeUndefined(); // No neut gas users are left }); @@ -128,7 +125,7 @@ describe("Abilities - Neutralizing Gas", () => { it("should deactivate when suppressed by gastro acid", async () => { game.override.enemyMoveset(Moves.GASTRO_ACID); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -137,10 +134,9 @@ describe("Abilities - Neutralizing Gas", () => { }); it("should deactivate when the pokemon faints", async () => { - game.override.ability(Abilities.BALL_FETCH) - .enemyAbility(Abilities.NEUTRALIZING_GAS); + game.override.ability(Abilities.BALL_FETCH).enemyAbility(Abilities.NEUTRALIZING_GAS); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined(); await game.doKillOpponents(); @@ -149,11 +145,8 @@ describe("Abilities - Neutralizing Gas", () => { }); it("should deactivate upon catching a wild pokemon", async () => { - game.override - .battleType("single") - .enemyAbility(Abilities.NEUTRALIZING_GAS) - .ability(Abilities.BALL_FETCH); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.battleType("single").enemyAbility(Abilities.NEUTRALIZING_GAS).ability(Abilities.BALL_FETCH); + await game.classicMode.startBattle([Species.MAGIKARP]); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined(); game.scene.pokeballCounts[PokeballType.MASTER_BALL] = 1; diff --git a/test/abilities/no_guard.test.ts b/test/abilities/no_guard.test.ts index 1a319eb2611..41b8fbd27b9 100644 --- a/test/abilities/no_guard.test.ts +++ b/test/abilities/no_guard.test.ts @@ -35,13 +35,11 @@ describe("Abilities - No Guard", () => { it("should make moves always hit regardless of move accuracy", async () => { game.override.battleType("single"); - await game.classicMode.startBattle([ - Species.REGIELEKI - ]); + await game.classicMode.startBattle([Species.REGIELEKI]); game.move.select(Moves.ZAP_CANNON); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); @@ -54,11 +52,7 @@ describe("Abilities - No Guard", () => { }); it("should guarantee double battle with any one LURE", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - ]) - .startingWave(2); + game.override.startingModifier([{ name: "LURE" }]).startingWave(2); await game.classicMode.startBattle(); diff --git a/test/abilities/parental_bond.test.ts b/test/abilities/parental_bond.test.ts index 55dc39bfbbd..2aa24e78d6e 100644 --- a/test/abilities/parental_bond.test.ts +++ b/test/abilities/parental_bond.test.ts @@ -10,7 +10,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Abilities - Parental Bond", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -37,444 +36,380 @@ describe("Abilities - Parental Bond", () => { game.override.enemyLevel(100); }); - it( - "should add second strike to attack move", - async () => { - game.override.moveset([ Moves.TACKLE ]); + it("should add second strike to attack move", async () => { + game.override.moveset([Moves.TACKLE]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - let enemyStartingHp = enemyPokemon.hp; + let enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("DamageAnimPhase"); - const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp; - enemyStartingHp = enemyPokemon.hp; + await game.phaseInterceptor.to("DamageAnimPhase"); + const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp; + enemyStartingHp = enemyPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - const secondStrikeDamage = enemyStartingHp - enemyPokemon.hp; + const secondStrikeDamage = enemyStartingHp - enemyPokemon.hp; - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(secondStrikeDamage).toBe(toDmgValue(0.25 * firstStrikeDamage)); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(secondStrikeDamage).toBe(toDmgValue(0.25 * firstStrikeDamage)); + }); - it( - "should apply secondary effects to both strikes", - async () => { - game.override.moveset([ Moves.POWER_UP_PUNCH ]); - game.override.enemySpecies(Species.AMOONGUSS); + it("should apply secondary effects to both strikes", async () => { + game.override.moveset([Moves.POWER_UP_PUNCH]); + game.override.enemySpecies(Species.AMOONGUSS); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.POWER_UP_PUNCH); + game.move.select(Moves.POWER_UP_PUNCH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); + }); - it( - "should not apply to Status moves", - async () => { - game.override.moveset([ Moves.BABY_DOLL_EYES ]); + it("should not apply to Status moves", async () => { + game.override.moveset([Moves.BABY_DOLL_EYES]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BABY_DOLL_EYES); + game.move.select(Moves.BABY_DOLL_EYES); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1); - } - ); + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1); + }); - it( - "should not apply to multi-hit moves", - async () => { - game.override.moveset([ Moves.DOUBLE_HIT ]); + it("should not apply to multi-hit moves", async () => { + game.override.moveset([Moves.DOUBLE_HIT]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.DOUBLE_HIT); - await game.move.forceHit(); + game.move.select(Moves.DOUBLE_HIT); + await game.move.forceHit(); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(2); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(2); + }); - it( - "should not apply to self-sacrifice moves", - async () => { - game.override.moveset([ Moves.SELF_DESTRUCT ]); + it("should not apply to self-sacrifice moves", async () => { + game.override.moveset([Moves.SELF_DESTRUCT]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SELF_DESTRUCT); + game.move.select(Moves.SELF_DESTRUCT); - await game.phaseInterceptor.to("DamageAnimPhase", false); + await game.phaseInterceptor.to("DamageAnimPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(1); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(1); + }); - it( - "should not apply to Rollout", - async () => { - game.override.moveset([ Moves.ROLLOUT ]); + it("should not apply to Rollout", async () => { + game.override.moveset([Moves.ROLLOUT]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.ROLLOUT); - await game.move.forceHit(); + game.move.select(Moves.ROLLOUT); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase", false); + await game.phaseInterceptor.to("DamageAnimPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(1); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(1); + }); - it( - "should not apply multiplier to fixed-damage moves", - async () => { - game.override.moveset([ Moves.DRAGON_RAGE ]); + it("should not apply multiplier to fixed-damage moves", async () => { + game.override.moveset([Moves.DRAGON_RAGE]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.DRAGON_RAGE); - await game.phaseInterceptor.to("BerryPhase", false); + game.move.select(Moves.DRAGON_RAGE); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - 80); - } - ); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - 80); + }); - it( - "should not apply multiplier to counter moves", - async () => { - game.override.moveset([ Moves.COUNTER ]); - game.override.enemyMoveset([ Moves.TACKLE ]); + it("should not apply multiplier to counter moves", async () => { + game.override.moveset([Moves.COUNTER]); + game.override.enemyMoveset([Moves.TACKLE]); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.COUNTER); - await game.phaseInterceptor.to("DamageAnimPhase"); + game.move.select(Moves.COUNTER); + await game.phaseInterceptor.to("DamageAnimPhase"); - const playerDamage = leadPokemon.getMaxHp() - leadPokemon.hp; + const playerDamage = leadPokemon.getMaxHp() - leadPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - 4 * playerDamage); - } - ); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - 4 * playerDamage); + }); - it( - "should not apply to multi-target moves", - async () => { - game.override.battleType("double"); - game.override.moveset([ Moves.EARTHQUAKE ]); - game.override.passiveAbility(Abilities.LEVITATE); + it("should not apply to multi-target moves", async () => { + game.override.battleType("double"); + game.override.moveset([Moves.EARTHQUAKE]); + game.override.passiveAbility(Abilities.LEVITATE); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.EARTHQUAKE); - game.move.select(Moves.EARTHQUAKE, 1); + game.move.select(Moves.EARTHQUAKE); + game.move.select(Moves.EARTHQUAKE, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); - } - ); + playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); + }); - it( - "should apply to multi-target moves when hitting only one target", - async () => { - game.override.moveset([ Moves.EARTHQUAKE ]); + it("should apply to multi-target moves when hitting only one target", async () => { + game.override.moveset([Moves.EARTHQUAKE]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.EARTHQUAKE); - await game.phaseInterceptor.to("DamageAnimPhase", false); + game.move.select(Moves.EARTHQUAKE); + await game.phaseInterceptor.to("DamageAnimPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(2); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(2); + }); - it( - "should only trigger post-target move effects once", - async () => { - game.override.moveset([ Moves.MIND_BLOWN ]); + it("should only trigger post-target move effects once", async () => { + game.override.moveset([Moves.MIND_BLOWN]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.MIND_BLOWN); + game.move.select(Moves.MIND_BLOWN); - await game.phaseInterceptor.to("DamageAnimPhase", false); + await game.phaseInterceptor.to("DamageAnimPhase", false); - expect(leadPokemon.turnData.hitCount).toBe(2); + expect(leadPokemon.turnData.hitCount).toBe(2); - // This test will time out if the user faints - await game.phaseInterceptor.to("BerryPhase", false); + // This test will time out if the user faints + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(Math.ceil(leadPokemon.getMaxHp() / 2)); - } - ); + expect(leadPokemon.hp).toBe(Math.ceil(leadPokemon.getMaxHp() / 2)); + }); - it( - "Burn Up only removes type after the second strike", - async () => { - game.override.moveset([ Moves.BURN_UP ]); + it("Burn Up only removes type after the second strike", async () => { + game.override.moveset([Moves.BURN_UP]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BURN_UP); + game.move.select(Moves.BURN_UP); - await game.phaseInterceptor.to("MoveEffectPhase"); + await game.phaseInterceptor.to("MoveEffectPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(enemyPokemon.hp).toBeGreaterThan(0); - expect(leadPokemon.isOfType(PokemonType.FIRE)).toBe(true); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(enemyPokemon.hp).toBeGreaterThan(0); + expect(leadPokemon.isOfType(PokemonType.FIRE)).toBe(true); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.isOfType(PokemonType.FIRE)).toBe(false); - } - ); + expect(leadPokemon.isOfType(PokemonType.FIRE)).toBe(false); + }); - it( - "Moves boosted by this ability and Multi-Lens should strike 3 times", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); + it("Moves boosted by this ability and Multi-Lens should strike 3 times", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(3); - } - ); + expect(leadPokemon.turnData.hitCount).toBe(3); + }); - it( - "Seismic Toss boosted by this ability and Multi-Lens should strike 3 times", - async () => { - game.override.moveset([ Moves.SEISMIC_TOSS ]); - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); + it("Seismic Toss boosted by this ability and Multi-Lens should strike 3 times", async () => { + game.override.moveset([Moves.SEISMIC_TOSS]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyStartingHp = enemyPokemon.hp; + const enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.SEISMIC_TOSS); - await game.move.forceHit(); + game.move.select(Moves.SEISMIC_TOSS); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(3); + expect(leadPokemon.turnData.hitCount).toBe(3); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(enemyPokemon.hp).toBe(enemyStartingHp - 200); - } - ); + expect(enemyPokemon.hp).toBe(enemyStartingHp - 200); + }); - it( - "Hyper Beam boosted by this ability should strike twice, then recharge", - async () => { - game.override.moveset([ Moves.HYPER_BEAM ]); + it("Hyper Beam boosted by this ability should strike twice, then recharge", async () => { + game.override.moveset([Moves.HYPER_BEAM]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.HYPER_BEAM); - await game.move.forceHit(); + game.move.select(Moves.HYPER_BEAM); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("TurnEndPhase"); - expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined(); - } - ); + expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined(); + }); - it( - "Anchor Shot boosted by this ability should only trap the target after the second hit", - async () => { - game.override.moveset([ Moves.ANCHOR_SHOT ]); + it("Anchor Shot boosted by this ability should only trap the target after the second hit", async () => { + game.override.moveset([Moves.ANCHOR_SHOT]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.ANCHOR_SHOT); - await game.move.forceHit(); + game.move.select(Moves.ANCHOR_SHOT); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to("MoveEndPhase"); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + await game.phaseInterceptor.to("MoveEndPhase"); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("TurnEndPhase"); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + }); - it( - "Smack Down boosted by this ability should only ground the target after the second hit", - async () => { - game.override.moveset([ Moves.SMACK_DOWN ]); + it("Smack Down boosted by this ability should only ground the target after the second hit", async () => { + game.override.moveset([Moves.SMACK_DOWN]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.SMACK_DOWN); - await game.move.forceHit(); + game.move.select(Moves.SMACK_DOWN); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("TurnEndPhase"); - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); + }); - it( - "U-turn boosted by this ability should strike twice before forcing a switch", - async () => { - game.override.moveset([ Moves.U_TURN ]); + it("U-turn boosted by this ability should strike twice before forcing a switch", async () => { + game.override.moveset([Moves.U_TURN]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.U_TURN); - await game.move.forceHit(); + game.move.select(Moves.U_TURN); + await game.move.forceHit(); - await game.phaseInterceptor.to("MoveEffectPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); + await game.phaseInterceptor.to("MoveEffectPhase"); + expect(leadPokemon.turnData.hitCount).toBe(2); - // This will cause this test to time out if the switch was forced on the first hit. - await game.phaseInterceptor.to("MoveEffectPhase", false); - } - ); + // This will cause this test to time out if the switch was forced on the first hit. + await game.phaseInterceptor.to("MoveEffectPhase", false); + }); - it( - "Wake-Up Slap boosted by this ability should only wake up the target after the second hit", - async () => { - game.override.moveset([ Moves.WAKE_UP_SLAP ]).enemyStatusEffect(StatusEffect.SLEEP); + it("Wake-Up Slap boosted by this ability should only wake up the target after the second hit", async () => { + game.override.moveset([Moves.WAKE_UP_SLAP]).enemyStatusEffect(StatusEffect.SLEEP); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.WAKE_UP_SLAP); - await game.move.forceHit(); + game.move.select(Moves.WAKE_UP_SLAP); + await game.move.forceHit(); - await game.phaseInterceptor.to("DamageAnimPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); - expect(leadPokemon.turnData.hitCount).toBe(2); - expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP); + expect(leadPokemon.turnData.hitCount).toBe(2); + expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.status?.effect).toBeUndefined(); - } - ); + expect(enemyPokemon.status?.effect).toBeUndefined(); + }); - it( - "should not cause user to hit into King's Shield more than once", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemyMoveset([ Moves.KINGS_SHIELD ]); + it("should not cause user to hit into King's Shield more than once", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemyMoveset([Moves.KINGS_SHIELD]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(-1); - } - ); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(-1); + }); - it( - "should not cause user to hit into Storm Drain more than once", - async () => { - game.override.moveset([ Moves.WATER_GUN ]); - game.override.enemyAbility(Abilities.STORM_DRAIN); + it("should not cause user to hit into Storm Drain more than once", async () => { + game.override.moveset([Moves.WATER_GUN]); + game.override.enemyAbility(Abilities.STORM_DRAIN); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.WATER_GUN); + game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(1); - } - ); + expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(1); + }); it("should not allow Future Sight to hit infinitely many times if the user switches out", async () => { - game.override.enemyLevel(1000) - .moveset(Moves.FUTURE_SIGHT); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + game.override.enemyLevel(1000).moveset(Moves.FUTURE_SIGHT); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); const enemyPokemon = game.scene.getEnemyPokemon()!; vi.spyOn(enemyPokemon, "damageAndUpdate"); diff --git a/test/abilities/pastel_veil.test.ts b/test/abilities/pastel_veil.test.ts index cb73a79bae4..65e391b7c22 100644 --- a/test/abilities/pastel_veil.test.ts +++ b/test/abilities/pastel_veil.test.ts @@ -27,14 +27,14 @@ describe("Abilities - Pastel Veil", () => { game = new GameManager(phaserGame); game.override .battleType("double") - .moveset([ Moves.TOXIC_THREAD, Moves.SPLASH ]) + .moveset([Moves.TOXIC_THREAD, Moves.SPLASH]) .enemyAbility(Abilities.BALL_FETCH) .enemySpecies(Species.SUNKERN) .enemyMoveset(Moves.SPLASH); }); it("prevents the user and its allies from being afflicted by poison", async () => { - await game.startBattle([ Species.MAGIKARP, Species.GALAR_PONYTA ]); + await game.startBattle([Species.MAGIKARP, Species.GALAR_PONYTA]); const ponyta = game.scene.getPlayerField()[1]; const magikarp = game.scene.getPlayerField()[0]; ponyta.abilityIndex = 1; @@ -50,7 +50,7 @@ describe("Abilities - Pastel Veil", () => { }); it("it heals the poisoned status condition of allies if user is sent out into battle", async () => { - await game.startBattle([ Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA ]); + await game.startBattle([Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA]); const ponyta = game.scene.getPlayerParty()[2]; const magikarp = game.scene.getPlayerField()[0]; ponyta.abilityIndex = 1; diff --git a/test/abilities/perish_body.test.ts b/test/abilities/perish_body.test.ts index 7084076713a..424d35e2542 100644 --- a/test/abilities/perish_body.test.ts +++ b/test/abilities/perish_body.test.ts @@ -5,7 +5,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Perish Song", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,11 +29,11 @@ describe("Abilities - Perish Song", () => { game.override.starterSpecies(Species.CURSOLA); game.override.ability(Abilities.PERISH_BODY); - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); }); it("should trigger when hit with damaging move", async () => { - game.override.enemyMoveset([ Moves.AQUA_JET ]); + game.override.enemyMoveset([Moves.AQUA_JET]); await game.classicMode.startBattle(); const cursola = game.scene.getPlayerPokemon(); const magikarp = game.scene.getEnemyPokemon(); @@ -47,10 +46,8 @@ describe("Abilities - Perish Song", () => { }); it("should trigger even when fainting", async () => { - game.override.enemyMoveset([ Moves.AQUA_JET ]) - .enemyLevel(100) - .startingLevel(1); - await game.classicMode.startBattle([ Species.CURSOLA, Species.FEEBAS ]); + game.override.enemyMoveset([Moves.AQUA_JET]).enemyLevel(100).startingLevel(1); + await game.classicMode.startBattle([Species.CURSOLA, Species.FEEBAS]); const magikarp = game.scene.getEnemyPokemon(); game.move.select(Moves.SPLASH); @@ -61,8 +58,8 @@ describe("Abilities - Perish Song", () => { }); it("should not activate if attacker already has perish song", async () => { - game.override.enemyMoveset([ Moves.PERISH_SONG, Moves.AQUA_JET, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.FEEBAS, Species.CURSOLA ]); + game.override.enemyMoveset([Moves.PERISH_SONG, Moves.AQUA_JET, Moves.SPLASH]); + await game.classicMode.startBattle([Species.FEEBAS, Species.CURSOLA]); const feebas = game.scene.getPlayerPokemon(); const magikarp = game.scene.getEnemyPokemon(); @@ -87,14 +84,13 @@ describe("Abilities - Perish Song", () => { expect(cursola?.summonData.tags.length).toBe(0); expect(magikarp?.summonData.tags[0].turnCount).toBe(1); - }); it("should activate if cursola already has perish song, but not reset its counter", async () => { - game.override.enemyMoveset([ Moves.PERISH_SONG, Moves.AQUA_JET, Moves.SPLASH ]); - game.override.moveset([ Moves.WHIRLWIND, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.PERISH_SONG, Moves.AQUA_JET, Moves.SPLASH]); + game.override.moveset([Moves.WHIRLWIND, Moves.SPLASH]); game.override.startingWave(5); - await game.classicMode.startBattle([ Species.CURSOLA ]); + await game.classicMode.startBattle([Species.CURSOLA]); const cursola = game.scene.getPlayerPokemon(); game.move.select(Moves.WHIRLWIND); diff --git a/test/abilities/power_construct.test.ts b/test/abilities/power_construct.test.ts index b6b7be33753..c253f2ae4df 100644 --- a/test/abilities/power_construct.test.ts +++ b/test/abilities/power_construct.test.ts @@ -8,7 +8,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - POWER CONSTRUCT", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,67 +27,61 @@ describe("Abilities - POWER CONSTRUCT", () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.ability(Abilities.POWER_CONSTRUCT); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - test( - "check if fainted 50% Power Construct Pokemon switches to base form on arena reset", - async () => { - const baseForm = 2, - completeForm = 4; - game.override.startingWave(4); - game.override.starterForms({ - [Species.ZYGARDE]: completeForm, - }); + test("check if fainted 50% Power Construct Pokemon switches to base form on arena reset", async () => { + const baseForm = 2, + completeForm = 4; + game.override.startingWave(4); + game.override.starterForms({ + [Species.ZYGARDE]: completeForm, + }); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.ZYGARDE]); - const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE); - expect(zygarde).not.toBe(undefined); - expect(zygarde!.formIndex).toBe(completeForm); + const zygarde = game.scene.getPlayerParty().find(p => p.species.speciesId === Species.ZYGARDE); + expect(zygarde).not.toBe(undefined); + expect(zygarde!.formIndex).toBe(completeForm); - zygarde!.hp = 0; - zygarde!.status = new Status(StatusEffect.FAINT); - expect(zygarde!.isFainted()).toBe(true); + zygarde!.hp = 0; + zygarde!.status = new Status(StatusEffect.FAINT); + expect(zygarde!.isFainted()).toBe(true); - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); - game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.phaseInterceptor.to(TurnEndPhase); + game.doSelectModifier(); + await game.phaseInterceptor.to(QuietFormChangePhase); - expect(zygarde!.formIndex).toBe(baseForm); - }, - ); + expect(zygarde!.formIndex).toBe(baseForm); + }); - test( - "check if fainted 10% Power Construct Pokemon switches to base form on arena reset", - async () => { - const baseForm = 3, - completeForm = 5; - game.override.startingWave(4); - game.override.starterForms({ - [Species.ZYGARDE]: completeForm, - }); + test("check if fainted 10% Power Construct Pokemon switches to base form on arena reset", async () => { + const baseForm = 3, + completeForm = 5; + game.override.startingWave(4); + game.override.starterForms({ + [Species.ZYGARDE]: completeForm, + }); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.ZYGARDE ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.ZYGARDE]); - const zygarde = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.ZYGARDE); - expect(zygarde).not.toBe(undefined); - expect(zygarde!.formIndex).toBe(completeForm); + const zygarde = game.scene.getPlayerParty().find(p => p.species.speciesId === Species.ZYGARDE); + expect(zygarde).not.toBe(undefined); + expect(zygarde!.formIndex).toBe(completeForm); - zygarde!.hp = 0; - zygarde!.status = new Status(StatusEffect.FAINT); - expect(zygarde!.isFainted()).toBe(true); + zygarde!.hp = 0; + zygarde!.status = new Status(StatusEffect.FAINT); + expect(zygarde!.isFainted()).toBe(true); - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); - game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.phaseInterceptor.to(TurnEndPhase); + game.doSelectModifier(); + await game.phaseInterceptor.to(QuietFormChangePhase); - expect(zygarde!.formIndex).toBe(baseForm); - }, - ); + expect(zygarde!.formIndex).toBe(baseForm); + }); }); diff --git a/test/abilities/power_spot.test.ts b/test/abilities/power_spot.test.ts index d4035da33d9..e29b5ecf775 100644 --- a/test/abilities/power_spot.test.ts +++ b/test/abilities/power_spot.test.ts @@ -27,7 +27,7 @@ describe("Abilities - Power Spot", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([ Moves.TACKLE, Moves.BREAKING_SWIPE, Moves.SPLASH, Moves.DAZZLING_GLEAM ]); + game.override.moveset([Moves.TACKLE, Moves.BREAKING_SWIPE, Moves.SPLASH, Moves.DAZZLING_GLEAM]); game.override.enemyMoveset(Moves.SPLASH); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.BALL_FETCH); @@ -39,7 +39,7 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.REGIELEKI, Species.STONJOURNER ]); + await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); game.move.select(Moves.DAZZLING_GLEAM); game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); @@ -53,7 +53,7 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.REGIELEKI, Species.STONJOURNER ]); + await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); game.move.select(Moves.BREAKING_SWIPE); game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(MoveEffectPhase); @@ -67,7 +67,7 @@ describe("Abilities - Power Spot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.startBattle([ Species.STONJOURNER, Species.REGIELEKI ]); + await game.startBattle([Species.STONJOURNER, Species.REGIELEKI]); game.move.select(Moves.BREAKING_SWIPE); game.move.select(Moves.SPLASH, 1); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/test/abilities/protean.test.ts b/test/abilities/protean.test.ts index 6c200f757e9..574033bb13f 100644 --- a/test/abilities/protean.test.ts +++ b/test/abilities/protean.test.ts @@ -13,7 +13,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - Protean", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -34,308 +33,263 @@ describe("Abilities - Protean", () => { game.override.ability(Abilities.PROTEAN); game.override.startingLevel(100); game.override.enemySpecies(Species.RATTATA); - game.override.enemyMoveset([ Moves.ENDURE, Moves.ENDURE, Moves.ENDURE, Moves.ENDURE ]); + game.override.enemyMoveset([Moves.ENDURE, Moves.ENDURE, Moves.ENDURE, Moves.ENDURE]); }); - test( - "ability applies and changes a pokemon's type", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability applies and changes a pokemon's type", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + }); // Test for Gen9+ functionality, we are using previous funcionality - test.skip( - "ability applies only once per switch in", - async () => { - game.override.moveset([ Moves.SPLASH, Moves.AGILITY ]); + test.skip("ability applies only once per switch in", async () => { + game.override.moveset([Moves.SPLASH, Moves.AGILITY]); - await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR ]); + await game.startBattle([Species.MAGIKARP, Species.BULBASAUR]); - let leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + let leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - game.move.select(Moves.AGILITY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.AGILITY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.PROTEAN)).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; - const moveType = PokemonType[allMoves[Moves.AGILITY].type]; - expect(leadPokemonType).not.toBe(moveType); + expect(leadPokemon.summonData.abilitiesApplied.filter(a => a === Abilities.PROTEAN)).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; + const moveType = PokemonType[allMoves[Moves.AGILITY].type]; + expect(leadPokemonType).not.toBe(moveType); - await game.toNextTurn(); - game.doSwitchPokemon(1); - await game.toNextTurn(); - game.doSwitchPokemon(1); - await game.toNextTurn(); + await game.toNextTurn(); + game.doSwitchPokemon(1); + await game.toNextTurn(); + game.doSwitchPokemon(1); + await game.toNextTurn(); - leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); + }); - test( - "ability applies correctly even if the pokemon's move has a variable type", - async () => { - game.override.moveset([ Moves.WEATHER_BALL ]); + test("ability applies correctly even if the pokemon's move has a variable type", async () => { + game.override.moveset([Moves.WEATHER_BALL]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.scene.arena.weather = new Weather(WeatherType.SUNNY); - game.move.select(Moves.WEATHER_BALL); - await game.phaseInterceptor.to(TurnEndPhase); + game.scene.arena.weather = new Weather(WeatherType.SUNNY); + game.move.select(Moves.WEATHER_BALL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); - expect(leadPokemon.getTypes()).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], - moveType = PokemonType[PokemonType.FIRE]; - expect(leadPokemonType).toBe(moveType); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); + expect(leadPokemon.getTypes()).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], + moveType = PokemonType[PokemonType.FIRE]; + expect(leadPokemonType).toBe(moveType); + }); - test( - "ability applies correctly even if the type has changed by another ability", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.passiveAbility(Abilities.REFRIGERATE); + test("ability applies correctly even if the type has changed by another ability", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.passiveAbility(Abilities.REFRIGERATE); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); - expect(leadPokemon.getTypes()).toHaveLength(1); - const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], - moveType = PokemonType[PokemonType.ICE]; - expect(leadPokemonType).toBe(moveType); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); + expect(leadPokemon.getTypes()).toHaveLength(1); + const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]], + moveType = PokemonType[PokemonType.ICE]; + expect(leadPokemonType).toBe(moveType); + }); - test( - "ability applies correctly even if the pokemon's move calls another move", - async () => { - game.override.moveset([ Moves.NATURE_POWER ]); + test("ability applies correctly even if the pokemon's move calls another move", async () => { + game.override.moveset([Moves.NATURE_POWER]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.scene.arena.biomeType = Biome.MOUNTAIN; - game.move.select(Moves.NATURE_POWER); - await game.phaseInterceptor.to(TurnEndPhase); + game.scene.arena.biomeType = Biome.MOUNTAIN; + game.move.select(Moves.NATURE_POWER); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); + }); - test( - "ability applies correctly even if the pokemon's move is delayed / charging", - async () => { - game.override.moveset([ Moves.DIG ]); + test("ability applies correctly even if the pokemon's move is delayed / charging", async () => { + game.override.moveset([Moves.DIG]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.DIG); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.DIG); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); + }); - test( - "ability applies correctly even if the pokemon's move misses", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemyMoveset(Moves.SPLASH); + test("ability applies correctly even if the pokemon's move misses", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.move.forceMiss(); + await game.phaseInterceptor.to(TurnEndPhase); - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon.isFullHp()).toBe(true); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon.isFullHp()).toBe(true); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability applies correctly even if the pokemon's move is protected against", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemyMoveset([ Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT ]); + test("ability applies correctly even if the pokemon's move is protected against", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability applies correctly even if the pokemon's move fails because of type immunity", - async () => { - game.override.moveset([ Moves.TACKLE ]); - game.override.enemySpecies(Species.GASTLY); + test("ability applies correctly even if the pokemon's move fails because of type immunity", async () => { + game.override.moveset([Moves.TACKLE]); + game.override.enemySpecies(Species.GASTLY); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TACKLE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); + }); - test( - "ability is not applied if pokemon's type is the same as the move's type", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability is not applied if pokemon's type is the same as the move's type", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - leadPokemon.summonData.types = [ allMoves[Moves.SPLASH].type ]; - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + leadPokemon.summonData.types = [allMoves[Moves.SPLASH].type]; + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); + }); - test( - "ability is not applied if pokemon is terastallized", - async () => { - game.override.moveset([ Moves.SPLASH ]); + test("ability is not applied if pokemon is terastallized", async () => { + game.override.moveset([Moves.SPLASH]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - leadPokemon.isTerastallized = true; + leadPokemon.isTerastallized = true; - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); + }); - test( - "ability is not applied if pokemon uses struggle", - async () => { - game.override.moveset([ Moves.STRUGGLE ]); + test("ability is not applied if pokemon uses struggle", async () => { + game.override.moveset([Moves.STRUGGLE]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.STRUGGLE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.STRUGGLE); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); + }); - test( - "ability is not applied if the pokemon's move fails", - async () => { - game.override.moveset([ Moves.BURN_UP ]); + test("ability is not applied if the pokemon's move fails", async () => { + game.override.moveset([Moves.BURN_UP]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.BURN_UP); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BURN_UP); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); - }, - ); + expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); + }); - test( - "ability applies correctly even if the pokemon's Trick-or-Treat fails", - async () => { - game.override.moveset([ Moves.TRICK_OR_TREAT ]); - game.override.enemySpecies(Species.GASTLY); + test("ability applies correctly even if the pokemon's Trick-or-Treat fails", async () => { + game.override.moveset([Moves.TRICK_OR_TREAT]); + game.override.enemySpecies(Species.GASTLY); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.TRICK_OR_TREAT); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.TRICK_OR_TREAT); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); + }); - test( - "ability applies correctly and the pokemon curses itself", - async () => { - game.override.moveset([ Moves.CURSE ]); + test("ability applies correctly and the pokemon curses itself", async () => { + game.override.moveset([Moves.CURSE]); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - expect(leadPokemon).not.toBe(undefined); + const leadPokemon = game.scene.getPlayerPokemon()!; + expect(leadPokemon).not.toBe(undefined); - game.move.select(Moves.CURSE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CURSE); + await game.phaseInterceptor.to(TurnEndPhase); - testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); - expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); - }, - ); + testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); + expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); + }); }); function testPokemonTypeMatchesDefaultMoveType(pokemon: PlayerPokemon, move: Moves) { diff --git a/test/abilities/protosynthesis.test.ts b/test/abilities/protosynthesis.test.ts index a122fbad797..d0ae46cd951 100644 --- a/test/abilities/protosynthesis.test.ts +++ b/test/abilities/protosynthesis.test.ts @@ -25,7 +25,7 @@ describe("Abilities - Protosynthesis", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.TACKLE ]) + .moveset([Moves.SPLASH, Moves.TACKLE]) .ability(Abilities.PROTOSYNTHESIS) .battleType("single") .disableCrits() @@ -34,13 +34,14 @@ describe("Abilities - Protosynthesis", () => { .enemyMoveset(Moves.SPLASH); }); - it("should not consider temporary items when determining which stat to boost", async() => { + it("should not consider temporary items when determining which stat to boost", async () => { // Mew has uniform base stats - game.override.startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.DEF }]) + game.override + .startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.DEF }]) .enemyMoveset(Moves.SUNNY_DAY) .startingLevel(100) .enemyLevel(100); - await game.classicMode.startBattle([ Species.MEW ]); + await game.classicMode.startBattle([Species.MEW]); const mew = game.scene.getPlayerPokemon()!; // Nature of starting mon is randomized. We need to fix it to a neutral nature for the automated test. mew.setNature(Nature.HARDY); @@ -49,14 +50,14 @@ describe("Abilities - Protosynthesis", () => { const atk_before_boost = mew.getEffectiveStat(Stat.ATK, undefined, undefined, false, undefined, false, false, true); const initialHp = enemy.hp; game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); const unboosted_dmg = initialHp - enemy.hp; enemy.hp = initialHp; const def_after_boost = mew.getEffectiveStat(Stat.DEF, undefined, undefined, false, undefined, false, false, true); const atk_after_boost = mew.getEffectiveStat(Stat.ATK, undefined, undefined, false, undefined, false, false, true); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); const boosted_dmg = initialHp - enemy.hp; expect(boosted_dmg).toBeGreaterThan(unboosted_dmg); diff --git a/test/abilities/quick_draw.test.ts b/test/abilities/quick_draw.test.ts index c451218a56c..9969dc2aa75 100644 --- a/test/abilities/quick_draw.test.ts +++ b/test/abilities/quick_draw.test.ts @@ -27,14 +27,16 @@ describe("Abilities - Quick Draw", () => { game.override.starterSpecies(Species.MAGIKARP); game.override.ability(Abilities.QUICK_DRAW); - game.override.moveset([ Moves.TACKLE, Moves.TAIL_WHIP ]); + game.override.moveset([Moves.TACKLE, Moves.TAIL_WHIP]); game.override.enemyLevel(100); game.override.enemySpecies(Species.MAGIKARP); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); - vi.spyOn(allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0], "chance", "get").mockReturnValue(100); + vi.spyOn(allAbilities[Abilities.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0], "chance", "get").mockReturnValue( + 100, + ); }); test("makes pokemon going first in its priority bracket", async () => { @@ -54,28 +56,31 @@ describe("Abilities - Quick Draw", () => { expect(pokemon.battleData.abilitiesApplied).contain(Abilities.QUICK_DRAW); }, 20000); - test("does not triggered by non damage moves", { - retry: 5 - }, async () => { - await game.startBattle(); + test( + "does not triggered by non damage moves", + { + retry: 5, + }, + async () => { + await game.startBattle(); - const pokemon = game.scene.getPlayerPokemon()!; - const enemy = game.scene.getEnemyPokemon()!; + const pokemon = game.scene.getPlayerPokemon()!; + const enemy = game.scene.getEnemyPokemon()!; - pokemon.hp = 1; - enemy.hp = 1; + pokemon.hp = 1; + enemy.hp = 1; - game.move.select(Moves.TAIL_WHIP); - await game.phaseInterceptor.to(FaintPhase, false); + game.move.select(Moves.TAIL_WHIP); + await game.phaseInterceptor.to(FaintPhase, false); - expect(pokemon.isFainted()).toBe(true); - expect(enemy.isFainted()).toBe(false); - expect(pokemon.battleData.abilitiesApplied).not.contain(Abilities.QUICK_DRAW); - } + expect(pokemon.isFainted()).toBe(true); + expect(enemy.isFainted()).toBe(false); + expect(pokemon.battleData.abilitiesApplied).not.contain(Abilities.QUICK_DRAW); + }, ); test("does not increase priority", async () => { - game.override.enemyMoveset([ Moves.EXTREME_SPEED ]); + game.override.enemyMoveset([Moves.EXTREME_SPEED]); await game.startBattle(); diff --git a/test/abilities/sand_spit.test.ts b/test/abilities/sand_spit.test.ts index dafae695d3b..6896c286eed 100644 --- a/test/abilities/sand_spit.test.ts +++ b/test/abilities/sand_spit.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Sand Spit", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,11 +30,11 @@ describe("Abilities - Sand Spit", () => { game.override.starterSpecies(Species.SILICOBRA); game.override.ability(Abilities.SAND_SPIT); - game.override.moveset([ Moves.SPLASH, Moves.COIL ]); + game.override.moveset([Moves.SPLASH, Moves.COIL]); }); it("should trigger when hit with damaging move", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); await game.classicMode.startBattle(); game.move.select(Moves.SPLASH); @@ -45,10 +44,8 @@ describe("Abilities - Sand Spit", () => { }, 20000); it("should trigger even when fainting", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]) - .enemyLevel(100) - .startingLevel(1); - await game.classicMode.startBattle([ Species.SILICOBRA, Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.TACKLE]).enemyLevel(100).startingLevel(1); + await game.classicMode.startBattle([Species.SILICOBRA, Species.MAGIKARP]); game.move.select(Moves.SPLASH); game.doSelectPartyPokemon(1); @@ -58,7 +55,7 @@ describe("Abilities - Sand Spit", () => { }); it("should not trigger when targetted with status moves", async () => { - game.override.enemyMoveset([ Moves.GROWL ]); + game.override.enemyMoveset([Moves.GROWL]); await game.classicMode.startBattle(); game.move.select(Moves.COIL); diff --git a/test/abilities/sand_veil.test.ts b/test/abilities/sand_veil.test.ts index 0128276075b..5e0a3f567dd 100644 --- a/test/abilities/sand_veil.test.ts +++ b/test/abilities/sand_veil.test.ts @@ -11,7 +11,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; - describe("Abilities - Sand Veil", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,52 +27,47 @@ describe("Abilities - Sand Veil", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); game.override.enemySpecies(Species.MEOWSCARADA); game.override.enemyAbility(Abilities.INSOMNIA); - game.override.enemyMoveset([ Moves.TWISTER, Moves.TWISTER, Moves.TWISTER, Moves.TWISTER ]); + game.override.enemyMoveset([Moves.TWISTER, Moves.TWISTER, Moves.TWISTER, Moves.TWISTER]); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override - .weather(WeatherType.SANDSTORM) - .battleType("double"); + game.override.weather(WeatherType.SANDSTORM).battleType("double"); }); - test( - "ability should increase the evasiveness of the source", - async () => { - await game.startBattle([ Species.SNORLAX, Species.BLISSEY ]); + test("ability should increase the evasiveness of the source", async () => { + await game.startBattle([Species.SNORLAX, Species.BLISSEY]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - vi.spyOn(leadPokemon[0], "getAbility").mockReturnValue(allAbilities[Abilities.SAND_VEIL]); + vi.spyOn(leadPokemon[0], "getAbility").mockReturnValue(allAbilities[Abilities.SAND_VEIL]); - const sandVeilAttr = allAbilities[Abilities.SAND_VEIL].getAttrs(StatMultiplierAbAttr)[0]; - vi.spyOn(sandVeilAttr, "applyStatStage").mockImplementation( - (_pokemon, _passive, _simulated, stat, statValue, _args) => { - if (stat === Stat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { - statValue.value *= -1; // will make all attacks miss - return true; - } - return false; + const sandVeilAttr = allAbilities[Abilities.SAND_VEIL].getAttrs(StatMultiplierAbAttr)[0]; + vi.spyOn(sandVeilAttr, "applyStatStage").mockImplementation( + (_pokemon, _passive, _simulated, stat, statValue, _args) => { + if (stat === Stat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { + statValue.value *= -1; // will make all attacks miss + return true; } - ); + return false; + }, + ); - expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true); - expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false); + expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true); + expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to(MoveEffectPhase, false); - await game.phaseInterceptor.to(MoveEndPhase, false); + await game.phaseInterceptor.to(MoveEndPhase, false); - expect(leadPokemon[0].isFullHp()).toBe(true); - expect(leadPokemon[1].hp).toBeLessThan(leadPokemon[1].getMaxHp()); - } - ); + expect(leadPokemon[0].isFullHp()).toBe(true); + expect(leadPokemon[1].hp).toBeLessThan(leadPokemon[1].getMaxHp()); + }); }); diff --git a/test/abilities/sap_sipper.test.ts b/test/abilities/sap_sipper.test.ts index 8294d2e1d69..f4f02844cbc 100644 --- a/test/abilities/sap_sipper.test.ts +++ b/test/abilities/sap_sipper.test.ts @@ -28,7 +28,8 @@ describe("Abilities - Sap Sipper", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .disableCrits() .ability(Abilities.SAP_SIPPER) .enemySpecies(Species.RATTATA) @@ -36,12 +37,12 @@ describe("Abilities - Sap Sipper", () => { .enemyMoveset(Moves.SPLASH); }); - it("raises ATK stat stage by 1 and block effects when activated against a grass attack", async() => { + it("raises ATK stat stage by 1 and block effects when activated against a grass attack", async () => { const moveToUse = Moves.LEAFAGE; game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const initialEnemyHp = enemyPokemon.hp; @@ -54,12 +55,12 @@ describe("Abilities - Sap Sipper", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); }); - it("raises ATK stat stage by 1 and block effects when activated against a grass status move", async() => { + it("raises ATK stat stage by 1 and block effects when activated against a grass status move", async () => { const moveToUse = Moves.SPORE; game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -76,7 +77,7 @@ describe("Abilities - Sap Sipper", () => { game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); game.move.select(moveToUse); @@ -92,7 +93,7 @@ describe("Abilities - Sap Sipper", () => { game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const initialEnemyHp = enemyPokemon.hp; @@ -110,7 +111,7 @@ describe("Abilities - Sap Sipper", () => { game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -134,7 +135,7 @@ describe("Abilities - Sap Sipper", () => { game.override.moveset(moveToUse); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; const initialEnemyHp = enemyPokemon.hp; @@ -150,7 +151,7 @@ describe("Abilities - Sap Sipper", () => { it("still activates regardless of accuracy check", async () => { game.override.moveset(Moves.LEAF_BLADE); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/schooling.test.ts b/test/abilities/schooling.test.ts index a52c6a06f12..35244b08e4c 100644 --- a/test/abilities/schooling.test.ts +++ b/test/abilities/schooling.test.ts @@ -8,7 +8,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - SCHOOLING", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,37 +27,34 @@ describe("Abilities - SCHOOLING", () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.ability(Abilities.SCHOOLING); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - test( - "check if fainted pokemon switches to base form on arena reset", - async () => { - const soloForm = 0, - schoolForm = 1; - game.override.startingWave(4); - game.override.starterForms({ - [Species.WISHIWASHI]: schoolForm, - }); + test("check if fainted pokemon switches to base form on arena reset", async () => { + const soloForm = 0, + schoolForm = 1; + game.override.startingWave(4); + game.override.starterForms({ + [Species.WISHIWASHI]: schoolForm, + }); - await game.startBattle([ Species.MAGIKARP, Species.WISHIWASHI ]); + await game.startBattle([Species.MAGIKARP, Species.WISHIWASHI]); - const wishiwashi = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.WISHIWASHI)!; - expect(wishiwashi).not.toBe(undefined); - expect(wishiwashi.formIndex).toBe(schoolForm); + const wishiwashi = game.scene.getPlayerParty().find(p => p.species.speciesId === Species.WISHIWASHI)!; + expect(wishiwashi).not.toBe(undefined); + expect(wishiwashi.formIndex).toBe(schoolForm); - wishiwashi.hp = 0; - wishiwashi.status = new Status(StatusEffect.FAINT); - expect(wishiwashi.isFainted()).toBe(true); + wishiwashi.hp = 0; + wishiwashi.status = new Status(StatusEffect.FAINT); + expect(wishiwashi.isFainted()).toBe(true); - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); - game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.phaseInterceptor.to(TurnEndPhase); + game.doSelectModifier(); + await game.phaseInterceptor.to(QuietFormChangePhase); - expect(wishiwashi.formIndex).toBe(soloForm); - }, - ); + expect(wishiwashi.formIndex).toBe(soloForm); + }); }); diff --git a/test/abilities/screen_cleaner.test.ts b/test/abilities/screen_cleaner.test.ts index 9c182398765..d8be1d64697 100644 --- a/test/abilities/screen_cleaner.test.ts +++ b/test/abilities/screen_cleaner.test.ts @@ -30,10 +30,10 @@ describe("Abilities - Screen Cleaner", () => { }); it("removes Aurora Veil", async () => { - game.override.moveset([ Moves.HAIL ]); - game.override.enemyMoveset([ Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL ]); + game.override.moveset([Moves.HAIL]); + game.override.enemyMoveset([Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL]); - await game.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.HAIL); await game.phaseInterceptor.to(TurnEndPhase); @@ -48,9 +48,9 @@ describe("Abilities - Screen Cleaner", () => { }); it("removes Light Screen", async () => { - game.override.enemyMoveset([ Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN ]); + game.override.enemyMoveset([Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN]); - await game.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); @@ -65,9 +65,9 @@ describe("Abilities - Screen Cleaner", () => { }); it("removes Reflect", async () => { - game.override.enemyMoveset([ Moves.REFLECT, Moves.REFLECT, Moves.REFLECT, Moves.REFLECT ]); + game.override.enemyMoveset([Moves.REFLECT, Moves.REFLECT, Moves.REFLECT, Moves.REFLECT]); - await game.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/test/abilities/seed_sower.test.ts b/test/abilities/seed_sower.test.ts index 6e3acdf6093..d78007f7500 100644 --- a/test/abilities/seed_sower.test.ts +++ b/test/abilities/seed_sower.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Seed Sower", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,11 +30,11 @@ describe("Abilities - Seed Sower", () => { game.override.starterSpecies(Species.ARBOLIVA); game.override.ability(Abilities.SEED_SOWER); - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); }); it("should trigger when hit with damaging move", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); await game.classicMode.startBattle(); game.move.select(Moves.SPLASH); @@ -45,10 +44,8 @@ describe("Abilities - Seed Sower", () => { }); it("should trigger even when fainting", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]) - .enemyLevel(100) - .startingLevel(1); - await game.classicMode.startBattle([ Species.ARBOLIVA, Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.TACKLE]).enemyLevel(100).startingLevel(1); + await game.classicMode.startBattle([Species.ARBOLIVA, Species.MAGIKARP]); game.move.select(Moves.SPLASH); game.doSelectPartyPokemon(1); @@ -58,7 +55,7 @@ describe("Abilities - Seed Sower", () => { }); it("should not trigger when targetted with status moves", async () => { - game.override.enemyMoveset([ Moves.GROWL ]); + game.override.enemyMoveset([Moves.GROWL]); await game.classicMode.startBattle(); game.move.select(Moves.SPLASH); diff --git a/test/abilities/serene_grace.test.ts b/test/abilities/serene_grace.test.ts index 7444347401c..65ca96acbbc 100644 --- a/test/abilities/serene_grace.test.ts +++ b/test/abilities/serene_grace.test.ts @@ -28,22 +28,22 @@ describe("Abilities - Serene Grace", () => { .disableCrits() .battleType("single") .ability(Abilities.SERENE_GRACE) - .moveset([ Moves.AIR_SLASH ]) + .moveset([Moves.AIR_SLASH]) .enemySpecies(Species.ALOLA_GEODUDE) .enemyLevel(10) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH ]); + .enemyMoveset([Moves.SPLASH]); }); it("Serene Grace should double the secondary effect chance of a move", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); const airSlashMove = allMoves[Moves.AIR_SLASH]; const airSlashFlinchAttr = airSlashMove.getAttrs(FlinchAttr)[0]; vi.spyOn(airSlashFlinchAttr, "getMoveChance"); game.move.select(Moves.AIR_SLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/sheer_force.test.ts b/test/abilities/sheer_force.test.ts index 1f9a101f409..4a1c20cde5c 100644 --- a/test/abilities/sheer_force.test.ts +++ b/test/abilities/sheer_force.test.ts @@ -30,15 +30,15 @@ describe("Abilities - Sheer Force", () => { .ability(Abilities.SHEER_FORCE) .enemySpecies(Species.ONIX) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH ]) + .enemyMoveset([Moves.SPLASH]) .disableCrits(); }); const SHEER_FORCE_MULT = 5461 / 4096; it("Sheer Force should boost the power of the move but disable secondary effects", async () => { - game.override.moveset([ Moves.AIR_SLASH ]); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + game.override.moveset([Moves.AIR_SLASH]); + await game.classicMode.startBattle([Species.SHUCKLE]); const airSlashMove = allMoves[Moves.AIR_SLASH]; vi.spyOn(airSlashMove, "calculateBattlePower"); @@ -47,7 +47,7 @@ describe("Abilities - Sheer Force", () => { game.move.select(Moves.AIR_SLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("BerryPhase", false); @@ -56,15 +56,15 @@ describe("Abilities - Sheer Force", () => { }); it("Sheer Force does not affect the base damage or secondary effects of binding moves", async () => { - game.override.moveset([ Moves.BIND ]); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + game.override.moveset([Moves.BIND]); + await game.classicMode.startBattle([Species.SHUCKLE]); const bindMove = allMoves[Moves.BIND]; vi.spyOn(bindMove, "calculateBattlePower"); game.move.select(Moves.BIND); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("BerryPhase", false); @@ -72,14 +72,14 @@ describe("Abilities - Sheer Force", () => { }, 20000); it("Sheer Force does not boost the base damage of moves with no secondary effect", async () => { - game.override.moveset([ Moves.TACKLE ]); - await game.classicMode.startBattle([ Species.PIDGEOT ]); + game.override.moveset([Moves.TACKLE]); + await game.classicMode.startBattle([Species.PIDGEOT]); const tackleMove = allMoves[Moves.TACKLE]; vi.spyOn(tackleMove, "calculateBattlePower"); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("BerryPhase", false); @@ -88,12 +88,12 @@ describe("Abilities - Sheer Force", () => { it("Sheer Force can disable the on-hit activation of specific abilities", async () => { game.override - .moveset([ Moves.HEADBUTT ]) + .moveset([Moves.HEADBUTT]) .enemySpecies(Species.SQUIRTLE) .enemyLevel(10) .enemyAbility(Abilities.COLOR_CHANGE); - await game.classicMode.startBattle([ Species.PIDGEOT ]); + await game.classicMode.startBattle([Species.PIDGEOT]); const enemyPokemon = game.scene.getEnemyPokemon(); const headbuttMove = allMoves[Moves.HEADBUTT]; vi.spyOn(headbuttMove, "calculateBattlePower"); @@ -102,7 +102,7 @@ describe("Abilities - Sheer Force", () => { game.move.select(Moves.HEADBUTT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("BerryPhase", false); @@ -113,14 +113,13 @@ describe("Abilities - Sheer Force", () => { it("Two Pokemon with abilities disabled by Sheer Force hitting each other should not cause a crash", async () => { const moveToUse = Moves.CRUNCH; - game.override.enemyAbility(Abilities.COLOR_CHANGE) + game.override + .enemyAbility(Abilities.COLOR_CHANGE) .ability(Abilities.COLOR_CHANGE) .moveset(moveToUse) .enemyMoveset(moveToUse); - await game.classicMode.startBattle([ - Species.PIDGEOT - ]); + await game.classicMode.startBattle([Species.PIDGEOT]); const pidgeot = game.scene.getPlayerParty()[0]; const onix = game.scene.getEnemyParty()[0]; @@ -132,7 +131,7 @@ describe("Abilities - Sheer Force", () => { await game.toNextTurn(); // Check that both Pokemon's Color Change activated - const expectedTypes = [ allMoves[moveToUse].type ]; + const expectedTypes = [allMoves[moveToUse].type]; expect(pidgeot.getTypes()).toStrictEqual(expectedTypes); expect(onix.getTypes()).toStrictEqual(expectedTypes); }); @@ -140,10 +139,10 @@ describe("Abilities - Sheer Force", () => { it("Sheer Force should disable Meloetta's transformation from Relic Song", async () => { game.override .ability(Abilities.SHEER_FORCE) - .moveset([ Moves.RELIC_SONG ]) - .enemyMoveset([ Moves.SPLASH ]) + .moveset([Moves.RELIC_SONG]) + .enemyMoveset([Moves.SPLASH]) .enemyLevel(100); - await game.classicMode.startBattle([ Species.MELOETTA ]); + await game.classicMode.startBattle([Species.MELOETTA]); const playerPokemon = game.scene.getPlayerPokemon(); const formKeyStart = playerPokemon?.getFormKey(); diff --git a/test/abilities/shield_dust.test.ts b/test/abilities/shield_dust.test.ts index a63898b0c63..8e02b5a7713 100644 --- a/test/abilities/shield_dust.test.ts +++ b/test/abilities/shield_dust.test.ts @@ -1,5 +1,10 @@ import { BattlerIndex } from "#app/battle"; -import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; +import { + applyAbAttrs, + applyPreDefendAbAttrs, + IgnoreMoveEffectsAbAttr, + MoveEffectChanceMultiplierAbAttr, +} from "#app/data/ability"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { NumberHolder } from "#app/utils"; import { Abilities } from "#enums/abilities"; @@ -10,7 +15,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - Shield Dust", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -36,15 +40,14 @@ describe("Abilities - Shield Dust", () => { }); it("Shield Dust", async () => { - await game.classicMode.startBattle([ Species.PIDGEOT ]); - + await game.classicMode.startBattle([Species.PIDGEOT]); game.scene.getEnemyPokemon()!.stats[Stat.SPDEF] = 10000; expect(game.scene.getPlayerPokemon()!.formIndex).toBe(0); game.move.select(Moves.AIR_SLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); // Shield Dust negates secondary effect @@ -53,10 +56,26 @@ describe("Abilities - Shield Dust", () => { expect(move.id).toBe(Moves.AIR_SLASH); const chance = new NumberHolder(move.chance); - await applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); - await applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance); + await applyAbAttrs( + MoveEffectChanceMultiplierAbAttr, + phase.getUserPokemon()!, + null, + false, + chance, + move, + phase.getFirstTarget(), + false, + ); + await applyPreDefendAbAttrs( + IgnoreMoveEffectsAbAttr, + phase.getFirstTarget()!, + phase.getUserPokemon()!, + null, + null, + false, + chance, + ); expect(chance.value).toBe(0); - }); //TODO King's Rock Interaction Unit Test diff --git a/test/abilities/shields_down.test.ts b/test/abilities/shields_down.test.ts index 4e47a018471..4bdf22869cb 100644 --- a/test/abilities/shields_down.test.ts +++ b/test/abilities/shields_down.test.ts @@ -9,7 +9,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - SHIELDS DOWN", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,173 +28,153 @@ describe("Abilities - SHIELDS DOWN", () => { const moveToUse = Moves.SPLASH; game.override.battleType("single"); game.override.ability(Abilities.SHIELDS_DOWN); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE]); }); - test( - "check if fainted pokemon switched to base form on arena reset", - async () => { - const meteorForm = 0, - coreForm = 7; - game.override.startingWave(4); - game.override.starterForms({ - [Species.MINIOR]: coreForm, - }); + test("check if fainted pokemon switched to base form on arena reset", async () => { + const meteorForm = 0, + coreForm = 7; + game.override.startingWave(4); + game.override.starterForms({ + [Species.MINIOR]: coreForm, + }); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MINIOR ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MINIOR]); - const minior = game.scene.getPlayerParty().find((p) => p.species.speciesId === Species.MINIOR)!; - expect(minior).not.toBe(undefined); - expect(minior.formIndex).toBe(coreForm); + const minior = game.scene.getPlayerParty().find(p => p.species.speciesId === Species.MINIOR)!; + expect(minior).not.toBe(undefined); + expect(minior.formIndex).toBe(coreForm); - minior.hp = 0; - minior.status = new Status(StatusEffect.FAINT); - expect(minior.isFainted()).toBe(true); + minior.hp = 0; + minior.status = new Status(StatusEffect.FAINT); + expect(minior.isFainted()).toBe(true); - game.move.select(Moves.SPLASH); - await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); - game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + game.move.select(Moves.SPLASH); + await game.doKillOpponents(); + await game.phaseInterceptor.to(TurnEndPhase); + game.doSelectModifier(); + await game.phaseInterceptor.to(QuietFormChangePhase); - expect(minior.formIndex).toBe(meteorForm); - }, - ); + expect(minior.formIndex).toBe(meteorForm); + }); - test("should ignore non-volatile status moves", - async () => { - game.override.enemyMoveset([ Moves.SPORE ]); + test("should ignore non-volatile status moves", async () => { + game.override.enemyMoveset([Moves.SPORE]); - await game.classicMode.startBattle([ Species.MINIOR ]); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.classicMode.startBattle([Species.MINIOR]); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); - } - ); + expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); + }); - test("should still ignore non-volatile status moves used by a pokemon with mold breaker", - async () => { - game.override.enemyAbility(Abilities.MOLD_BREAKER); - game.override.enemyMoveset([ Moves.SPORE ]); + test("should still ignore non-volatile status moves used by a pokemon with mold breaker", async () => { + game.override.enemyAbility(Abilities.MOLD_BREAKER); + game.override.enemyMoveset([Moves.SPORE]); - await game.classicMode.startBattle([ Species.MINIOR ]); + await game.classicMode.startBattle([Species.MINIOR]); - game.move.select(Moves.SPLASH); - await game.forceEnemyMove(Moves.SPORE); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.SPORE); + await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); - } - ); + expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); + }); - test("should ignore non-volatile secondary status effects", - async() => { - game.override.enemyMoveset([ Moves.NUZZLE ]); + test("should ignore non-volatile secondary status effects", async () => { + game.override.enemyMoveset([Moves.NUZZLE]); - await game.classicMode.startBattle([ Species.MINIOR ]); + await game.classicMode.startBattle([Species.MINIOR]); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); - } - ); + expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); + }); - test("should ignore status moves even through mold breaker", - async () => { - game.override.enemyMoveset([ Moves.SPORE ]); - game.override.enemyAbility(Abilities.MOLD_BREAKER); + test("should ignore status moves even through mold breaker", async () => { + game.override.enemyMoveset([Moves.SPORE]); + game.override.enemyAbility(Abilities.MOLD_BREAKER); - await game.classicMode.startBattle([ Species.MINIOR ]); + await game.classicMode.startBattle([Species.MINIOR]); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); - - expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); + }); // toxic spikes currently does not poison flying types when gravity is in effect - test.todo("should become poisoned by toxic spikes when grounded", - async () => { - game.override.enemyMoveset([ Moves.GRAVITY, Moves.TOXIC_SPIKES, Moves.SPLASH ]); - game.override.moveset([ Moves.GRAVITY, Moves.SPLASH ]); + test.todo("should become poisoned by toxic spikes when grounded", async () => { + game.override.enemyMoveset([Moves.GRAVITY, Moves.TOXIC_SPIKES, Moves.SPLASH]); + game.override.moveset([Moves.GRAVITY, Moves.SPLASH]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MINIOR ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MINIOR]); - // turn 1 - game.move.select(Moves.GRAVITY); - await game.forceEnemyMove(Moves.TOXIC_SPIKES); - await game.toNextTurn(); + // turn 1 + game.move.select(Moves.GRAVITY); + await game.forceEnemyMove(Moves.TOXIC_SPIKES); + await game.toNextTurn(); - // turn 2 - game.doSwitchPokemon(1); - await game.forceEnemyMove(Moves.SPLASH); - await game.toNextTurn(); + // turn 2 + game.doSwitchPokemon(1); + await game.forceEnemyMove(Moves.SPLASH); + await game.toNextTurn(); - expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.MINIOR); - expect(game.scene.getPlayerPokemon()!.species.formIndex).toBe(0); - expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON); - } - ); + expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.MINIOR); + expect(game.scene.getPlayerPokemon()!.species.formIndex).toBe(0); + expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON); + }); - test("should ignore yawn", - async () => { - game.override.enemyMoveset([ Moves.YAWN ]); + test("should ignore yawn", async () => { + game.override.enemyMoveset([Moves.YAWN]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MINIOR ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MINIOR]); - game.move.select(Moves.SPLASH); - await game.forceEnemyMove(Moves.YAWN); + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.YAWN); - await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerPokemon()!.findTag( (tag ) => tag.tagType === BattlerTagType.DROWSY)).toBe(undefined); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.DROWSY)).toBe(undefined); + }); - test("should not ignore volatile status effects", - async () => { - game.override.enemyMoveset([ Moves.CONFUSE_RAY ]); + test("should not ignore volatile status effects", async () => { + game.override.enemyMoveset([Moves.CONFUSE_RAY]); - await game.classicMode.startBattle([ Species.MINIOR ]); + await game.classicMode.startBattle([Species.MINIOR]); - game.move.select(Moves.SPLASH); - await game.forceEnemyMove(Moves.CONFUSE_RAY); + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.CONFUSE_RAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getPlayerPokemon()!.findTag( (tag ) => tag.tagType === BattlerTagType.CONFUSED)).not.toBe(undefined); - } - ); + expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.CONFUSED)).not.toBe(undefined); + }); // the `NoTransformAbilityAbAttr` attribute is not checked anywhere, so this test cannot pass. - test.todo("ditto should not be immune to status after transforming", - async () => { - game.override.enemySpecies(Species.DITTO); - game.override.enemyAbility(Abilities.IMPOSTER); - game.override.moveset([ Moves.SPLASH, Moves.SPORE ]); + test.todo("ditto should not be immune to status after transforming", async () => { + game.override.enemySpecies(Species.DITTO); + game.override.enemyAbility(Abilities.IMPOSTER); + game.override.moveset([Moves.SPLASH, Moves.SPORE]); - await game.classicMode.startBattle([ Species.MINIOR ]); + await game.classicMode.startBattle([Species.MINIOR]); - game.move.select(Moves.SPORE); - await game.forceEnemyMove(Moves.SPLASH); + game.move.select(Moves.SPORE); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); - expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP); + }); test("should not prevent minior from receiving the fainted status effect in trainer battles", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); - game.override.moveset([ Moves.THUNDERBOLT ]); + game.override.enemyMoveset([Moves.TACKLE]); + game.override.moveset([Moves.THUNDERBOLT]); game.override.startingLevel(100); game.override.startingWave(5); game.override.enemySpecies(Species.MINIOR); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const minior = game.scene.getEnemyPokemon()!; game.move.select(Moves.THUNDERBOLT); @@ -203,5 +182,4 @@ describe("Abilities - SHIELDS DOWN", () => { expect(minior.isFainted()).toBe(true); expect(minior.status?.effect).toBe(StatusEffect.FAINT); }); - }); diff --git a/test/abilities/simple.test.ts b/test/abilities/simple.test.ts index e8d478655ab..b6c5fd116c0 100644 --- a/test/abilities/simple.test.ts +++ b/test/abilities/simple.test.ts @@ -30,10 +30,8 @@ describe("Abilities - Simple", () => { .enemyMoveset(Moves.SPLASH); }); - it("should double stat changes when applied", async() => { - await game.startBattle([ - Species.SLOWBRO - ]); + it("should double stat changes when applied", async () => { + await game.startBattle([Species.SLOWBRO]); const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/speed_boost.test.ts b/test/abilities/speed_boost.test.ts index 912bb62bca4..fa20e74108f 100644 --- a/test/abilities/speed_boost.test.ts +++ b/test/abilities/speed_boost.test.ts @@ -33,97 +33,83 @@ describe("Abilities - Speed Boost", () => { .enemyLevel(100) .ability(Abilities.SPEED_BOOST) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.SPLASH, Moves.U_TURN ]); + .moveset([Moves.SPLASH, Moves.U_TURN]); }); - it("should increase speed by 1 stage at end of turn", - async () => { - await game.classicMode.startBattle(); + it("should increase speed by 1 stage at end of turn", async () => { + await game.classicMode.startBattle(); - const playerPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SPLASH); - await game.toNextTurn(); + const playerPokemon = game.scene.getPlayerPokemon()!; + game.move.select(Moves.SPLASH); + await game.toNextTurn(); - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); - }); + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); + }); - it("should not trigger this turn if pokemon was switched into combat via attack, but the turn after", - async () => { - await game.classicMode.startBattle([ - Species.SHUCKLE, - Species.NINJASK - ]); + it("should not trigger this turn if pokemon was switched into combat via attack, but the turn after", async () => { + await game.classicMode.startBattle([Species.SHUCKLE, Species.NINJASK]); - game.move.select(Moves.U_TURN); - game.doSelectPartyPokemon(1); - await game.toNextTurn(); - const playerPokemon = game.scene.getPlayerPokemon()!; - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); + game.move.select(Moves.U_TURN); + game.doSelectPartyPokemon(1); + await game.toNextTurn(); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); - }); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); + }); - it("checking back to back swtiches", - async () => { - await game.classicMode.startBattle([ - Species.SHUCKLE, - Species.NINJASK - ]); + it("checking back to back swtiches", async () => { + await game.classicMode.startBattle([Species.SHUCKLE, Species.NINJASK]); - const [ shuckle, ninjask ] = game.scene.getPlayerParty(); + const [shuckle, ninjask] = game.scene.getPlayerParty(); - game.move.select(Moves.U_TURN); - game.doSelectPartyPokemon(1); - await game.toNextTurn(); - expect(game.scene.getPlayerPokemon()!).toBe(ninjask); - expect(ninjask.getStatStage(Stat.SPD)).toBe(0); + game.move.select(Moves.U_TURN); + game.doSelectPartyPokemon(1); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!).toBe(ninjask); + expect(ninjask.getStatStage(Stat.SPD)).toBe(0); - game.move.select(Moves.U_TURN); - game.doSelectPartyPokemon(1); - await game.toNextTurn(); - expect(game.scene.getPlayerPokemon()!).toBe(shuckle); - expect(shuckle.getStatStage(Stat.SPD)).toBe(0); + game.move.select(Moves.U_TURN); + game.doSelectPartyPokemon(1); + await game.toNextTurn(); + expect(game.scene.getPlayerPokemon()!).toBe(shuckle); + expect(shuckle.getStatStage(Stat.SPD)).toBe(0); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(shuckle.getStatStage(Stat.SPD)).toBe(1); - }); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(shuckle.getStatStage(Stat.SPD)).toBe(1); + }); - it("should not trigger this turn if pokemon was switched into combat via normal switch, but the turn after", - async () => { - await game.classicMode.startBattle([ - Species.SHUCKLE, - Species.NINJASK - ]); + it("should not trigger this turn if pokemon was switched into combat via normal switch, but the turn after", async () => { + await game.classicMode.startBattle([Species.SHUCKLE, Species.NINJASK]); - game.doSwitchPokemon(1); - await game.toNextTurn(); - const playerPokemon = game.scene.getPlayerPokemon()!; - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); + game.doSwitchPokemon(1); + await game.toNextTurn(); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); - }); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); + }); - it("should not trigger if pokemon fails to escape", - async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); + it("should not trigger if pokemon fails to escape", async () => { + await game.classicMode.startBattle([Species.SHUCKLE]); - const commandPhase = game.scene.getCurrentPhase() as CommandPhase; - commandPhase.handleCommand(Command.RUN, 0); - const runPhase = game.scene.getCurrentPhase() as AttemptRunPhase; - runPhase.forceFailEscape = true; - await game.phaseInterceptor.to(AttemptRunPhase); - await game.toNextTurn(); + const commandPhase = game.scene.getCurrentPhase() as CommandPhase; + commandPhase.handleCommand(Command.RUN, 0); + const runPhase = game.scene.getCurrentPhase() as AttemptRunPhase; + runPhase.forceFailEscape = true; + await game.phaseInterceptor.to(AttemptRunPhase); + await game.toNextTurn(); - const playerPokemon = game.scene.getPlayerPokemon()!; - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); - }); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); + }); }); diff --git a/test/abilities/stakeout.test.ts b/test/abilities/stakeout.test.ts index 67442ae1822..b464b3f1dfc 100644 --- a/test/abilities/stakeout.test.ts +++ b/test/abilities/stakeout.test.ts @@ -24,7 +24,7 @@ describe("Abilities - Stakeout", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.SURF ]) + .moveset([Moves.SPLASH, Moves.SURF]) .ability(Abilities.STAKEOUT) .battleType("single") .disableCrits() @@ -32,14 +32,14 @@ describe("Abilities - Stakeout", () => { .enemyLevel(100) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.FLIP_TURN ]) + .enemyMoveset([Moves.SPLASH, Moves.FLIP_TURN]) .startingWave(5); }); it("should do double damage to a pokemon that switched out", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); - const [ enemy1, ] = game.scene.getEnemyParty(); + const [enemy1] = game.scene.getEnemyParty(); game.move.select(Moves.SURF); await game.forceEnemyMove(Moves.SPLASH); @@ -56,13 +56,13 @@ describe("Abilities - Stakeout", () => { await game.toNextTurn(); expect(enemy1.isFainted()).toBe(false); - expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); + expect(isBetween(enemy1.getInverseHp(), damage1 * 2 - 5, damage1 * 2 + 5)).toBe(true); }); it("should do double damage to a pokemon that switched out via U-Turn/etc", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); - const [ enemy1, ] = game.scene.getEnemyParty(); + const [enemy1] = game.scene.getEnemyParty(); game.move.select(Moves.SURF); await game.forceEnemyMove(Moves.SPLASH); @@ -76,10 +76,10 @@ describe("Abilities - Stakeout", () => { game.move.select(Moves.SURF); await game.forceEnemyMove(Moves.FLIP_TURN); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemy1.isFainted()).toBe(false); - expect(isBetween(enemy1.getInverseHp(), (damage1 * 2) - 5, (damage1 * 2) + 5)).toBe(true); + expect(isBetween(enemy1.getInverseHp(), damage1 * 2 - 5, damage1 * 2 + 5)).toBe(true); }); }); diff --git a/test/abilities/stall.test.ts b/test/abilities/stall.test.ts index c0b71221071..5b67e5f4b7a 100644 --- a/test/abilities/stall.test.ts +++ b/test/abilities/stall.test.ts @@ -26,8 +26,8 @@ describe("Abilities - Stall", () => { game.override.disableCrits(); game.override.enemySpecies(Species.REGIELEKI); game.override.enemyAbility(Abilities.STALL); - game.override.enemyMoveset([ Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK ]); - game.override.moveset([ Moves.QUICK_ATTACK, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK, Moves.QUICK_ATTACK]); + game.override.moveset([Moves.QUICK_ATTACK, Moves.TACKLE]); }); /** @@ -37,7 +37,7 @@ describe("Abilities - Stall", () => { **/ it("Pokemon with Stall should move last in its priority bracket regardless of speed", async () => { - await game.startBattle([ Species.SHUCKLE ]); + await game.startBattle([Species.SHUCKLE]); const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); @@ -50,12 +50,12 @@ describe("Abilities - Stall", () => { const commandOrder = phase.getCommandOrder(); // The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon. - expect(speedOrder).toEqual([ enemyIndex, playerIndex ]); - expect(commandOrder).toEqual([ playerIndex, enemyIndex ]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([playerIndex, enemyIndex]); }, 20000); it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async () => { - await game.startBattle([ Species.SHUCKLE ]); + await game.startBattle([Species.SHUCKLE]); const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); @@ -68,13 +68,13 @@ describe("Abilities - Stall", () => { const commandOrder = phase.getCommandOrder(); // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. // The player Pokemon goes second because its move is in a lower priority bracket. - expect(speedOrder).toEqual([ enemyIndex, playerIndex ]); - expect(commandOrder).toEqual([ enemyIndex, playerIndex ]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); }, 20000); it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async () => { game.override.ability(Abilities.STALL); - await game.startBattle([ Species.SHUCKLE ]); + await game.startBattle([Species.SHUCKLE]); const playerIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); @@ -88,7 +88,7 @@ describe("Abilities - Stall", () => { // The opponent Pokemon (with Stall) goes first because it has a higher speed. // The player Pokemon (with Stall) goes second because its speed is lower. - expect(speedOrder).toEqual([ enemyIndex, playerIndex ]); - expect(commandOrder).toEqual([ enemyIndex, playerIndex ]); + expect(speedOrder).toEqual([enemyIndex, playerIndex]); + expect(commandOrder).toEqual([enemyIndex, playerIndex]); }, 20000); }); diff --git a/test/abilities/steely_spirit.test.ts b/test/abilities/steely_spirit.test.ts index beda5d34e8e..9b4d32efcae 100644 --- a/test/abilities/steely_spirit.test.ts +++ b/test/abilities/steely_spirit.test.ts @@ -29,13 +29,13 @@ describe("Abilities - Steely Spirit", () => { game.override.battleType("double"); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.moveset([ Moves.IRON_HEAD, Moves.SPLASH ]); + game.override.moveset([Moves.IRON_HEAD, Moves.SPLASH]); game.override.enemyMoveset(Moves.SPLASH); vi.spyOn(allMoves[moveToCheck], "calculateBattlePower"); }); it("increases Steel-type moves' power used by the user and its allies by 50%", async () => { - await game.classicMode.startBattle([ Species.PIKACHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.PIKACHU, Species.SHUCKLE]); const boostSource = game.scene.getPlayerField()[1]; const enemyToCheck = game.scene.getEnemyPokemon()!; @@ -51,7 +51,7 @@ describe("Abilities - Steely Spirit", () => { }); it("stacks if multiple users with this ability are on the field.", async () => { - await game.classicMode.startBattle([ Species.PIKACHU, Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU, Species.PIKACHU]); const enemyToCheck = game.scene.getEnemyPokemon()!; game.scene.getPlayerField().forEach(p => { @@ -64,11 +64,13 @@ describe("Abilities - Steely Spirit", () => { game.move.select(moveToCheck, 1, enemyToCheck.getBattlerIndex()); await game.phaseInterceptor.to("MoveEffectPhase"); - expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * Math.pow(steelySpiritMultiplier, 2)); + expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith( + ironHeadPower * Math.pow(steelySpiritMultiplier, 2), + ); }); it("does not take effect when suppressed", async () => { - await game.classicMode.startBattle([ Species.PIKACHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.PIKACHU, Species.SHUCKLE]); const boostSource = game.scene.getPlayerField()[1]; const enemyToCheck = game.scene.getEnemyPokemon()!; @@ -88,14 +90,12 @@ describe("Abilities - Steely Spirit", () => { }); it("affects variable-type moves if their resolved type is Steel", async () => { - game.override - .ability(Abilities.STEELY_SPIRIT) - .moveset([ Moves.REVELATION_DANCE ]); + game.override.ability(Abilities.STEELY_SPIRIT).moveset([Moves.REVELATION_DANCE]); const revelationDance = allMoves[Moves.REVELATION_DANCE]; vi.spyOn(revelationDance, "calculateBattlePower"); - await game.classicMode.startBattle([ Species.KLINKLANG ]); + await game.classicMode.startBattle([Species.KLINKLANG]); game.move.select(Moves.REVELATION_DANCE); diff --git a/test/abilities/sturdy.test.ts b/test/abilities/sturdy.test.ts index 36b098ab69e..7b7254cff15 100644 --- a/test/abilities/sturdy.test.ts +++ b/test/abilities/sturdy.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Abilities - Sturdy", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,64 +28,51 @@ describe("Abilities - Sturdy", () => { game.override.starterSpecies(Species.LUCARIO); game.override.startingLevel(100); - game.override.moveset([ Moves.CLOSE_COMBAT, Moves.FISSURE ]); + game.override.moveset([Moves.CLOSE_COMBAT, Moves.FISSURE]); game.override.enemySpecies(Species.ARON); game.override.enemyLevel(5); game.override.enemyAbility(Abilities.STURDY); }); - test( - "Sturdy activates when user is at full HP", - async () => { - await game.startBattle(); - game.move.select(Moves.CLOSE_COMBAT); - await game.phaseInterceptor.to(MoveEndPhase); - expect(game.scene.getEnemyParty()[0].hp).toBe(1); - }, - ); + test("Sturdy activates when user is at full HP", async () => { + await game.startBattle(); + game.move.select(Moves.CLOSE_COMBAT); + await game.phaseInterceptor.to(MoveEndPhase); + expect(game.scene.getEnemyParty()[0].hp).toBe(1); + }); - test( - "Sturdy doesn't activate when user is not at full HP", - async () => { - await game.startBattle(); + test("Sturdy doesn't activate when user is not at full HP", async () => { + await game.startBattle(); - const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; - enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; + enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; - game.move.select(Moves.CLOSE_COMBAT); - await game.phaseInterceptor.to(DamageAnimPhase); + game.move.select(Moves.CLOSE_COMBAT); + await game.phaseInterceptor.to(DamageAnimPhase); - expect(enemyPokemon.hp).toBe(0); - expect(enemyPokemon.isFainted()).toBe(true); - }, - ); + expect(enemyPokemon.hp).toBe(0); + expect(enemyPokemon.isFainted()).toBe(true); + }); - test( - "Sturdy pokemon should be immune to OHKO moves", - async () => { - await game.startBattle(); - game.move.select(Moves.FISSURE); - await game.phaseInterceptor.to(MoveEndPhase); + test("Sturdy pokemon should be immune to OHKO moves", async () => { + await game.startBattle(); + game.move.select(Moves.FISSURE); + await game.phaseInterceptor.to(MoveEndPhase); - const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; - expect(enemyPokemon.isFullHp()).toBe(true); - }, - ); + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; + expect(enemyPokemon.isFullHp()).toBe(true); + }); - test( - "Sturdy is ignored by pokemon with `Abilities.MOLD_BREAKER`", - async () => { - game.override.ability(Abilities.MOLD_BREAKER); + test("Sturdy is ignored by pokemon with `Abilities.MOLD_BREAKER`", async () => { + game.override.ability(Abilities.MOLD_BREAKER); - await game.startBattle(); - game.move.select(Moves.CLOSE_COMBAT); - await game.phaseInterceptor.to(DamageAnimPhase); - - const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; - expect(enemyPokemon.hp).toBe(0); - expect(enemyPokemon.isFainted()).toBe(true); - }, - ); + await game.startBattle(); + game.move.select(Moves.CLOSE_COMBAT); + await game.phaseInterceptor.to(DamageAnimPhase); + const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; + expect(enemyPokemon.hp).toBe(0); + expect(enemyPokemon.isFainted()).toBe(true); + }); }); diff --git a/test/abilities/supreme_overlord.test.ts b/test/abilities/supreme_overlord.test.ts index 18e0823a7cb..b70acbd8d17 100644 --- a/test/abilities/supreme_overlord.test.ts +++ b/test/abilities/supreme_overlord.test.ts @@ -34,40 +34,40 @@ describe("Abilities - Supreme Overlord", () => { .startingLevel(1) .enemyAbility(Abilities.BALL_FETCH) .ability(Abilities.SUPREME_OVERLORD) - .enemyMoveset([ Moves.SPLASH ]) - .moveset([ Moves.TACKLE, Moves.EXPLOSION, Moves.LUNAR_DANCE ]); + .enemyMoveset([Moves.SPLASH]) + .moveset([Moves.TACKLE, Moves.EXPLOSION, Moves.LUNAR_DANCE]); vi.spyOn(move, "calculateBattlePower"); }); - it("should increase Power by 20% if 2 Pokemon are fainted in the party", async() => { - await game.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + it("should increase Power by 20% if 2 Pokemon are fainted in the party", async () => { + await game.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(2); await game.toNextTurn(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.2); }); it("should increase Power by 30% if an ally fainted twice and another one once", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * Bulbasur faints once */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -76,7 +76,7 @@ describe("Abilities - Supreme Overlord", () => { */ game.doRevivePokemon(1); game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -84,31 +84,27 @@ describe("Abilities - Supreme Overlord", () => { * Bulbasur faints twice */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(2); await game.toNextTurn(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.3); }); it("should maintain its power during next battle if it is within the same arena encounter", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(1) - .enemyLevel(1) - .startingLevel(100); + game.override.enemySpecies(Species.MAGIKARP).startingWave(1).enemyLevel(1).startingLevel(100); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * The first Pokemon faints and another Pokemon in the party is selected. - */ + */ game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -116,61 +112,53 @@ describe("Abilities - Supreme Overlord", () => { * Enemy Pokemon faints and new wave is entered. */ game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("TurnEndPhase"); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower * 1.1); }); it("should reset playerFaints count if we enter new trainer battle", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(4) - .enemyLevel(1) - .startingLevel(100); + game.override.enemySpecies(Species.MAGIKARP).startingWave(4).enemyLevel(1).startingLevel(100); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); }); it("should reset playerFaints count if we enter new biome", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(10) - .enemyLevel(1) - .startingLevel(100); + game.override.enemySpecies(Species.MAGIKARP).startingWave(10).enemyLevel(1).startingLevel(100); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); diff --git a/test/abilities/sweet_veil.test.ts b/test/abilities/sweet_veil.test.ts index 14f4f79c3f0..650ee53a474 100644 --- a/test/abilities/sweet_veil.test.ts +++ b/test/abilities/sweet_veil.test.ts @@ -26,14 +26,14 @@ describe("Abilities - Sweet Veil", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([ Moves.SPLASH, Moves.REST, Moves.YAWN ]); + game.override.moveset([Moves.SPLASH, Moves.REST, Moves.YAWN]); game.override.enemySpecies(Species.MAGIKARP); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemyMoveset([ Moves.POWDER, Moves.POWDER, Moves.POWDER, Moves.POWDER ]); + game.override.enemyMoveset([Moves.POWDER, Moves.POWDER, Moves.POWDER, Moves.POWDER]); }); it("prevents the user and its allies from falling asleep", async () => { - await game.startBattle([ Species.SWIRLIX, Species.MAGIKARP ]); + await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH, 1); @@ -45,7 +45,7 @@ describe("Abilities - Sweet Veil", () => { it("causes Rest to fail when used by the user or its allies", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.SWIRLIX, Species.MAGIKARP ]); + await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); game.move.select(Moves.SPLASH); game.move.select(Moves.REST, 1); @@ -56,8 +56,8 @@ describe("Abilities - Sweet Veil", () => { }); it("causes Yawn to fail if used on the user or its allies", async () => { - game.override.enemyMoveset([ Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN ]); - await game.startBattle([ Species.SWIRLIX, Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]); + await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH, 1); @@ -73,7 +73,7 @@ describe("Abilities - Sweet Veil", () => { game.override.startingLevel(5); game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.SHUCKLE, Species.SHUCKLE, Species.SWIRLIX ]); + await game.startBattle([Species.SHUCKLE, Species.SHUCKLE, Species.SWIRLIX]); game.move.select(Moves.SPLASH); game.move.select(Moves.YAWN, 1, BattlerIndex.PLAYER); diff --git a/test/abilities/synchronize.test.ts b/test/abilities/synchronize.test.ts index 19b5560f61a..95ebf96f2fd 100644 --- a/test/abilities/synchronize.test.ts +++ b/test/abilities/synchronize.test.ts @@ -28,12 +28,12 @@ describe("Abilities - Synchronize", () => { .startingLevel(100) .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.SYNCHRONIZE) - .moveset([ Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT ]) + .moveset([Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT]) .ability(Abilities.NO_GUARD); }); it("does not trigger when no status is applied by opponent Pokemon", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -43,7 +43,7 @@ describe("Abilities - Synchronize", () => { }); it("sets the status of the source pokemon to Paralysis when paralyzed by it", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.THUNDER_WAVE); await game.phaseInterceptor.to("BerryPhase"); @@ -71,7 +71,7 @@ describe("Abilities - Synchronize", () => { .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Array(4).fill(Moves.TOXIC_SPIKES)); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); game.move.select(Moves.SPLASH); await game.toNextTurn(); @@ -85,7 +85,7 @@ describe("Abilities - Synchronize", () => { }); it("shows ability even if it fails to set the status of the opponent Pokemon", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.THUNDER_WAVE); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/tera_shell.test.ts b/test/abilities/tera_shell.test.ts index 38be70f511b..a99ecfd4ce1 100644 --- a/test/abilities/tera_shell.test.ts +++ b/test/abilities/tera_shell.test.ts @@ -26,107 +26,92 @@ describe("Abilities - Tera Shell", () => { game.override .battleType("single") .ability(Abilities.TERA_SHELL) - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.INSOMNIA) - .enemyMoveset([ Moves.MACH_PUNCH ]) + .enemyMoveset([Moves.MACH_PUNCH]) .startingLevel(100) .enemyLevel(100); }); - it( - "should change the effectiveness of non-resisted attacks when the source is at full HP", - async () => { - await game.classicMode.startBattle([ Species.SNORLAX ]); + it("should change the effectiveness of non-resisted attacks when the source is at full HP", async () => { + await game.classicMode.startBattle([Species.SNORLAX]); - const playerPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(playerPokemon, "getMoveEffectiveness"); + const playerPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(playerPokemon, "getMoveEffectiveness"); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("MoveEndPhase"); - expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.5); + await game.phaseInterceptor.to("MoveEndPhase"); + expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.5); - await game.toNextTurn(); + await game.toNextTurn(); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("MoveEndPhase"); - expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(2); + await game.phaseInterceptor.to("MoveEndPhase"); + expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(2); + }); + + it("should not override type immunities", async () => { + game.override.enemyMoveset([Moves.SHADOW_SNEAK]); + + await game.classicMode.startBattle([Species.SNORLAX]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(playerPokemon, "getMoveEffectiveness"); + + game.move.select(Moves.SPLASH); + + await game.phaseInterceptor.to("MoveEndPhase"); + expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0); + }); + + it("should not override type multipliers less than 0.5x", async () => { + game.override.enemyMoveset([Moves.QUICK_ATTACK]); + + await game.classicMode.startBattle([Species.AGGRON]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(playerPokemon, "getMoveEffectiveness"); + + game.move.select(Moves.SPLASH); + + await game.phaseInterceptor.to("MoveEndPhase"); + expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.25); + }); + + it("should not affect the effectiveness of fixed-damage moves", async () => { + game.override.enemyMoveset([Moves.DRAGON_RAGE]); + + await game.classicMode.startBattle([Species.CHARIZARD]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(playerPokemon, "apply"); + + game.move.select(Moves.SPLASH); + + await game.phaseInterceptor.to("BerryPhase", false); + expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.EFFECTIVE); + expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp() - 40); + }); + + it("should change the effectiveness of all strikes of a multi-strike move", async () => { + game.override.enemyMoveset([Moves.DOUBLE_HIT]); + + await game.classicMode.startBattle([Species.SNORLAX]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(playerPokemon, "apply"); + + game.move.select(Moves.SPLASH); + + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.move.forceHit(); + for (let i = 0; i < 2; i++) { + await game.phaseInterceptor.to("MoveEffectPhase"); + expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.NOT_VERY_EFFECTIVE); } - ); - - it( - "should not override type immunities", - async () => { - game.override.enemyMoveset([ Moves.SHADOW_SNEAK ]); - - await game.classicMode.startBattle([ Species.SNORLAX ]); - - const playerPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(playerPokemon, "getMoveEffectiveness"); - - game.move.select(Moves.SPLASH); - - await game.phaseInterceptor.to("MoveEndPhase"); - expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0); - } - ); - - it( - "should not override type multipliers less than 0.5x", - async () => { - game.override.enemyMoveset([ Moves.QUICK_ATTACK ]); - - await game.classicMode.startBattle([ Species.AGGRON ]); - - const playerPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(playerPokemon, "getMoveEffectiveness"); - - game.move.select(Moves.SPLASH); - - await game.phaseInterceptor.to("MoveEndPhase"); - expect(playerPokemon.getMoveEffectiveness).toHaveLastReturnedWith(0.25); - } - ); - - it( - "should not affect the effectiveness of fixed-damage moves", - async () => { - game.override.enemyMoveset([ Moves.DRAGON_RAGE ]); - - await game.classicMode.startBattle([ Species.CHARIZARD ]); - - const playerPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(playerPokemon, "apply"); - - game.move.select(Moves.SPLASH); - - await game.phaseInterceptor.to("BerryPhase", false); - expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.EFFECTIVE); - expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp() - 40); - } - ); - - it( - "should change the effectiveness of all strikes of a multi-strike move", - async () => { - game.override.enemyMoveset([ Moves.DOUBLE_HIT ]); - - await game.classicMode.startBattle([ Species.SNORLAX ]); - - const playerPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(playerPokemon, "apply"); - - game.move.select(Moves.SPLASH); - - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.move.forceHit(); - for (let i = 0; i < 2; i++) { - await game.phaseInterceptor.to("MoveEffectPhase"); - expect(playerPokemon.apply).toHaveLastReturnedWith(HitResult.NOT_VERY_EFFECTIVE); - } - expect(playerPokemon.apply).toHaveReturnedTimes(2); - } - ); + expect(playerPokemon.apply).toHaveReturnedTimes(2); + }); }); diff --git a/test/abilities/trace.test.ts b/test/abilities/trace.test.ts index e7059d2b0f1..5d569208d33 100644 --- a/test/abilities/trace.test.ts +++ b/test/abilities/trace.test.ts @@ -23,7 +23,7 @@ describe("Abilities - Trace", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.TRACE) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Abilities - Trace", () => { }); it("should copy the opponent's ability", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -43,7 +43,7 @@ describe("Abilities - Trace", () => { it("should activate a copied post-summon ability", async () => { game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/unburden.test.ts b/test/abilities/unburden.test.ts index a2134a96f4d..8f18604011c 100644 --- a/test/abilities/unburden.test.ts +++ b/test/abilities/unburden.test.ts @@ -13,7 +13,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Abilities - Unburden", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -25,9 +24,8 @@ describe("Abilities - Unburden", () => { const stackCounts = pokemon.getHeldItems().map(m => m.getStackCount()); if (stackCounts.length) { return stackCounts.reduce((a, b) => a + b); - } else { - return 0; } + return 0; } beforeAll(() => { @@ -46,7 +44,7 @@ describe("Abilities - Unburden", () => { .battleType("single") .startingLevel(1) .ability(Abilities.UNBURDEN) - .moveset([ Moves.SPLASH, Moves.KNOCK_OFF, Moves.PLUCK, Moves.FALSE_SWIPE ]) + .moveset([Moves.SPLASH, Moves.KNOCK_OFF, Moves.PLUCK, Moves.FALSE_SWIPE]) .startingHeldItems([ { name: "BERRY", count: 1, type: BerryType.SITRUS }, { name: "BERRY", count: 2, type: BerryType.APICOT }, @@ -62,12 +60,12 @@ describe("Abilities - Unburden", () => { { name: "BERRY", type: BerryType.LUM, count: 1 }, ]); // For the various tests that use Thief, give it a 100% steal rate - vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); + vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([new StealHeldItemChanceAttr(1.0)]); }); it("should activate when a berry is eaten", async () => { game.override.enemyMoveset(Moves.FALSE_SWIPE); - await game.classicMode.startBattle([ Species.TREECKO ]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -82,9 +80,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when a berry is eaten, even if Berry Pouch preserves the berry", async () => { - game.override.enemyMoveset(Moves.FALSE_SWIPE) - .startingModifier([{ name: "BERRY_POUCH", count: 5850 }]); - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.enemyMoveset(Moves.FALSE_SWIPE).startingModifier([{ name: "BERRY_POUCH", count: 5850 }]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -99,7 +96,7 @@ describe("Abilities - Unburden", () => { }); it("should activate for the target, and not the stealer, when a berry is stolen", async () => { - await game.classicMode.startBattle([ Species.TREECKO ]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const initialPlayerSpeed = playerPokemon.getStat(Stat.SPD); @@ -117,7 +114,7 @@ describe("Abilities - Unburden", () => { }); it("should activate when an item is knocked off", async () => { - await game.classicMode.startBattle([ Species.TREECKO ]); + await game.classicMode.startBattle([Species.TREECKO]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyHeldItemCt = getHeldItemCount(enemyPokemon); @@ -132,10 +129,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when an item is stolen via attacking ability", async () => { - game.override - .ability(Abilities.MAGICIAN) - .startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.ability(Abilities.MAGICIAN).startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items + await game.classicMode.startBattle([Species.TREECKO]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyHeldItemCt = getHeldItemCount(enemyPokemon); @@ -150,10 +145,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when an item is stolen via defending ability", async () => { - game.override - .enemyAbility(Abilities.PICKPOCKET) - .enemyHeldItems([]); // Remove opponent's full stacks of held items so it can steal player's held items - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.enemyAbility(Abilities.PICKPOCKET).enemyHeldItems([]); // Remove opponent's full stacks of held items so it can steal player's held items + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -168,9 +161,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when an item is stolen via move", async () => { - game.override.moveset(Moves.THIEF) - .startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.moveset(Moves.THIEF).startingHeldItems([]); // Remove player's full stacks of held items so it can steal opponent's held items + await game.classicMode.startBattle([Species.TREECKO]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyHeldItemCt = getHeldItemCount(enemyPokemon); @@ -185,11 +177,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when an item is stolen via grip claw", async () => { - game.override - .startingHeldItems([ - { name: "GRIP_CLAW", count: 1 }, - ]); - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.startingHeldItems([{ name: "GRIP_CLAW", count: 1 }]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier; @@ -208,9 +197,8 @@ describe("Abilities - Unburden", () => { }); it("should not activate when a neutralizing ability is present", async () => { - game.override.enemyAbility(Abilities.NEUTRALIZING_GAS) - .enemyMoveset(Moves.FALSE_SWIPE); - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.enemyAbility(Abilities.NEUTRALIZING_GAS).enemyMoveset(Moves.FALSE_SWIPE); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -227,7 +215,7 @@ describe("Abilities - Unburden", () => { it("should activate when a move that consumes a berry is used", async () => { game.override.moveset(Moves.STUFF_CHEEKS); - await game.classicMode.startBattle([ Species.TREECKO ]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItemCt = getHeldItemCount(playerPokemon); @@ -243,13 +231,10 @@ describe("Abilities - Unburden", () => { }); it("should deactivate temporarily when a neutralizing gas user is on the field", async () => { - game.override - .battleType("double") - .ability(Abilities.NONE); // Disable ability override so that we can properly set abilities below - await game.classicMode.startBattle([ Species.TREECKO, Species.MEOWTH, Species.WEEZING ]); + game.override.battleType("double").ability(Abilities.NONE); // Disable ability override so that we can properly set abilities below + await game.classicMode.startBattle([Species.TREECKO, Species.MEOWTH, Species.WEEZING]); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [ treecko, _meowth, weezing ] = game.scene.getPlayerParty(); + const [treecko, _meowth, weezing] = game.scene.getPlayerParty(); treecko.abilityIndex = 2; // Treecko has Unburden weezing.abilityIndex = 1; // Weezing has Neutralizing Gas const playerHeldItems = getHeldItemCount(treecko); @@ -285,11 +270,10 @@ describe("Abilities - Unburden", () => { }); it("should not activate when passing a baton to a teammate switching in", async () => { - game.override.startingHeldItems([{ name: "BATON" }]) - .moveset(Moves.BATON_PASS); - await game.classicMode.startBattle([ Species.TREECKO, Species.PURRLOIN ]); + game.override.startingHeldItems([{ name: "BATON" }]).moveset(Moves.BATON_PASS); + await game.classicMode.startBattle([Species.TREECKO, Species.PURRLOIN]); - const [ treecko, purrloin ] = game.scene.getPlayerParty(); + const [treecko, purrloin] = game.scene.getPlayerParty(); const initialTreeckoSpeed = treecko.getStat(Stat.SPD); const initialPurrloinSpeed = purrloin.getStat(Stat.SPD); const unburdenAttr = treecko.getAbilityAttrs(PostItemLostAbAttr)[0]; @@ -308,8 +292,8 @@ describe("Abilities - Unburden", () => { }); it("should not speed up a Pokemon after it loses the ability Unburden", async () => { - game.override.enemyMoveset([ Moves.FALSE_SWIPE, Moves.WORRY_SEED ]); - await game.classicMode.startBattle([ Species.PURRLOIN ]); + game.override.enemyMoveset([Moves.FALSE_SWIPE, Moves.WORRY_SEED]); + await game.classicMode.startBattle([Species.PURRLOIN]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -333,9 +317,8 @@ describe("Abilities - Unburden", () => { }); it("should activate when a reviver seed is used", async () => { - game.override.startingHeldItems([{ name: "REVIVER_SEED" }]) - .enemyMoveset([ Moves.WING_ATTACK ]); - await game.classicMode.startBattle([ Species.TREECKO ]); + game.override.startingHeldItems([{ name: "REVIVER_SEED" }]).enemyMoveset([Moves.WING_ATTACK]); + await game.classicMode.startBattle([Species.TREECKO]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerHeldItems = getHeldItemCount(playerPokemon); @@ -351,8 +334,8 @@ describe("Abilities - Unburden", () => { // test for `.bypassFaint()` - singles it("shouldn't persist when revived normally if activated while fainting", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.THIEF ]); - await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.THIEF]); + await game.classicMode.startBattle([Species.TREECKO, Species.FEEBAS]); const treecko = game.scene.getPlayerPokemon()!; const treeckoInitialHeldItems = getHeldItemCount(treecko); @@ -377,10 +360,10 @@ describe("Abilities - Unburden", () => { it("shouldn't persist when revived by revival blessing if activated while fainting", async () => { game.override .battleType("double") - .enemyMoveset([ Moves.SPLASH, Moves.THIEF ]) - .moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING ]) + .enemyMoveset([Moves.SPLASH, Moves.THIEF]) + .moveset([Moves.SPLASH, Moves.REVIVAL_BLESSING]) .startingHeldItems([{ name: "WIDE_LENS" }]); - await game.classicMode.startBattle([ Species.TREECKO, Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.TREECKO, Species.FEEBAS, Species.MILOTIC]); const treecko = game.scene.getPlayerField()[0]; const treeckoInitialHeldItems = getHeldItemCount(treecko); @@ -390,7 +373,7 @@ describe("Abilities - Unburden", () => { game.move.select(Moves.REVIVAL_BLESSING, 1); await game.forceEnemyMove(Moves.THIEF, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2]); game.doSelectPartyPokemon(0, "RevivalBlessingPhase"); await game.toNextTurn(); diff --git a/test/abilities/unseen_fist.test.ts b/test/abilities/unseen_fist.test.ts index de93aef0988..73ae25ff3b0 100644 --- a/test/abilities/unseen_fist.test.ts +++ b/test/abilities/unseen_fist.test.ts @@ -8,7 +8,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BerryPhase } from "#app/phases/berry-phase"; - describe("Abilities - Unseen Fist", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,63 +27,54 @@ describe("Abilities - Unseen Fist", () => { game.override.battleType("single"); game.override.starterSpecies(Species.URSHIFU); game.override.enemySpecies(Species.SNORLAX); - game.override.enemyMoveset([ Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT ]); + game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); game.override.startingLevel(100); game.override.enemyLevel(100); }); - it( - "should cause a contact move to ignore Protect", - () => testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, true), - ); + it("should cause a contact move to ignore Protect", () => + testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, true)); - it( - "should not cause a non-contact move to ignore Protect", - () => testUnseenFistHitResult(game, Moves.ABSORB, Moves.PROTECT, false), - ); + it("should not cause a non-contact move to ignore Protect", () => + testUnseenFistHitResult(game, Moves.ABSORB, Moves.PROTECT, false)); - it( - "should not apply if the source has Long Reach", - async () => { - game.override.passiveAbility(Abilities.LONG_REACH); - await testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, false); - } - ); + it("should not apply if the source has Long Reach", async () => { + game.override.passiveAbility(Abilities.LONG_REACH); + await testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, false); + }); - it( - "should cause a contact move to ignore Wide Guard", - () => testUnseenFistHitResult(game, Moves.BREAKING_SWIPE, Moves.WIDE_GUARD, true), - ); + it("should cause a contact move to ignore Wide Guard", () => + testUnseenFistHitResult(game, Moves.BREAKING_SWIPE, Moves.WIDE_GUARD, true)); - it( - "should not cause a non-contact move to ignore Wide Guard", - () => testUnseenFistHitResult(game, Moves.BULLDOZE, Moves.WIDE_GUARD, false), - ); + it("should not cause a non-contact move to ignore Wide Guard", () => + testUnseenFistHitResult(game, Moves.BULLDOZE, Moves.WIDE_GUARD, false)); - it( - "should cause a contact move to ignore Protect, but not Substitute", - async () => { - game.override.enemyLevel(1); - game.override.moveset([ Moves.TACKLE ]); + it("should cause a contact move to ignore Protect, but not Substitute", async () => { + game.override.enemyLevel(1); + game.override.moveset([Moves.TACKLE]); - await game.classicMode.startBattle(); + await game.classicMode.startBattle(); - const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id); + const enemyPokemon = game.scene.getEnemyPokemon()!; + enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id); - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined(); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined(); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); }); -async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, protectMove: Moves, shouldSucceed: boolean = true): Promise { - game.override.moveset([ attackMove ]); - game.override.enemyMoveset([ protectMove, protectMove, protectMove, protectMove ]); +async function testUnseenFistHitResult( + game: GameManager, + attackMove: Moves, + protectMove: Moves, + shouldSucceed = true, +): Promise { + game.override.moveset([attackMove]); + game.override.enemyMoveset([protectMove, protectMove, protectMove, protectMove]); await game.classicMode.startBattle(); diff --git a/test/abilities/volt_absorb.test.ts b/test/abilities/volt_absorb.test.ts index 2221619af07..10735f31987 100644 --- a/test/abilities/volt_absorb.test.ts +++ b/test/abilities/volt_absorb.test.ts @@ -34,9 +34,9 @@ describe("Abilities - Volt Absorb", () => { const moveToUse = Moves.CHARGE; const ability = Abilities.VOLT_ABSORB; - game.override.moveset([ moveToUse ]); + game.override.moveset([moveToUse]); game.override.ability(ability); - game.override.enemyMoveset([ Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]); game.override.enemySpecies(Species.DUSKULL); game.override.enemyAbility(Abilities.BALL_FETCH); @@ -65,7 +65,7 @@ describe("Abilities - Volt Absorb", () => { game.move.select(Moves.THUNDERBOLT); enemyPokemon.hp = enemyPokemon.hp - 1; - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEffectPhase"); await game.move.forceMiss(); @@ -85,7 +85,7 @@ describe("Abilities - Volt Absorb", () => { game.move.select(Moves.THUNDERBOLT); enemyPokemon.hp = enemyPokemon.hp - 1; - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); diff --git a/test/abilities/wandering_spirit.test.ts b/test/abilities/wandering_spirit.test.ts index 48c7afa5751..375faa41972 100644 --- a/test/abilities/wandering_spirit.test.ts +++ b/test/abilities/wandering_spirit.test.ts @@ -23,7 +23,7 @@ describe("Abilities - Wandering Spirit", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.WANDERING_SPIRIT) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Abilities - Wandering Spirit", () => { }); it("should exchange abilities when hit with a contact move", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -44,7 +44,7 @@ describe("Abilities - Wandering Spirit", () => { it("should not exchange abilities when hit with a non-contact move", async () => { game.override.enemyMoveset(Moves.EARTHQUAKE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); @@ -55,7 +55,7 @@ describe("Abilities - Wandering Spirit", () => { it("should activate post-summon abilities", async () => { game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/abilities/wimp_out.test.ts b/test/abilities/wimp_out.test.ts index a37885834c4..ef201cbf8dd 100644 --- a/test/abilities/wimp_out.test.ts +++ b/test/abilities/wimp_out.test.ts @@ -37,13 +37,13 @@ describe("Abilities - Wimp Out", () => { .enemyPassiveAbility(Abilities.NO_GUARD) .startingLevel(90) .enemyLevel(70) - .moveset([ Moves.SPLASH, Moves.FALSE_SWIPE, Moves.ENDURE ]) + .moveset([Moves.SPLASH, Moves.FALSE_SWIPE, Moves.ENDURE]) .enemyMoveset(Moves.FALSE_SWIPE) .disableCrits(); }); function confirmSwitch(): void { - const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty(); + const [pokemon1, pokemon2] = game.scene.getPlayerParty(); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); @@ -55,7 +55,7 @@ describe("Abilities - Wimp Out", () => { } function confirmNoSwitch(): void { - const [ pokemon1, pokemon2 ] = game.scene.getPlayerParty(); + const [pokemon1, pokemon2] = game.scene.getPlayerParty(); expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase"); @@ -67,14 +67,8 @@ describe("Abilities - Wimp Out", () => { } it("triggers regenerator passive single time when switching out with wimp out", async () => { - game.override - .passiveAbility(Abilities.REGENERATOR) - .startingLevel(5) - .enemyLevel(100); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.passiveAbility(Abilities.REGENERATOR).startingLevel(5).enemyLevel(100); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const wimpod = game.scene.getPlayerPokemon()!; @@ -88,10 +82,7 @@ describe("Abilities - Wimp Out", () => { it("It makes wild pokemon flee if triggered", async () => { game.override.enemyAbility(Abilities.WIMP_OUT); - await game.classicMode.startBattle([ - Species.GOLISOPOD, - Species.TYRUNT - ]); + await game.classicMode.startBattle([Species.GOLISOPOD, Species.TYRUNT]); const enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon.hp *= 0.52; @@ -105,10 +96,7 @@ describe("Abilities - Wimp Out", () => { }); it("Does not trigger when HP already below half", async () => { - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const wimpod = game.scene.getPlayerPokemon()!; wimpod.hp = 5; @@ -120,14 +108,8 @@ describe("Abilities - Wimp Out", () => { }); it("Trapping moves do not prevent Wimp Out from activating.", async () => { - game.override - .enemyMoveset([ Moves.SPIRIT_SHACKLE ]) - .startingLevel(53) - .enemyLevel(45); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset([Moves.SPIRIT_SHACKLE]).startingLevel(53).enemyLevel(45); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.move.select(Moves.SPLASH); game.doSelectPartyPokemon(1); @@ -141,13 +123,8 @@ describe("Abilities - Wimp Out", () => { }); it("If this Ability activates due to being hit by U-turn or Volt Switch, the user of that move will not be switched out.", async () => { - game.override - .startingLevel(95) - .enemyMoveset([ Moves.U_TURN ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.startingLevel(95).enemyMoveset([Moves.U_TURN]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.move.select(Moves.SPLASH); game.doSelectPartyPokemon(1); @@ -160,14 +137,8 @@ describe("Abilities - Wimp Out", () => { }); it("If this Ability does not activate due to being hit by U-turn or Volt Switch, the user of that move will be switched out.", async () => { - game.override - .startingLevel(190) - .startingWave(8) - .enemyMoveset([ Moves.U_TURN ]); - await game.classicMode.startBattle([ - Species.GOLISOPOD, - Species.TYRUNT - ]); + game.override.startingLevel(190).startingWave(8).enemyMoveset([Moves.U_TURN]); + await game.classicMode.startBattle([Species.GOLISOPOD, Species.TYRUNT]); const RIVAL_NINJASK1 = game.scene.getEnemyPokemon()?.id; game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase", false); @@ -175,13 +146,8 @@ describe("Abilities - Wimp Out", () => { }); it("Dragon Tail and Circle Throw switch out Pokémon before the Ability activates.", async () => { - game.override - .startingLevel(69) - .enemyMoveset([ Moves.DRAGON_TAIL ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.startingLevel(69).enemyMoveset([Moves.DRAGON_TAIL]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const wimpod = game.scene.getPlayerPokemon()!; @@ -197,13 +163,8 @@ describe("Abilities - Wimp Out", () => { }); it("triggers when recoil damage is taken", async () => { - game.override - .moveset([ Moves.HEAD_SMASH ]) - .enemyMoveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.moveset([Moves.HEAD_SMASH]).enemyMoveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.move.select(Moves.HEAD_SMASH); game.doSelectPartyPokemon(1); @@ -213,13 +174,8 @@ describe("Abilities - Wimp Out", () => { }); it("It does not activate when the Pokémon cuts its own HP", async () => { - game.override - .moveset([ Moves.SUBSTITUTE ]) - .enemyMoveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.moveset([Moves.SUBSTITUTE]).enemyMoveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const wimpod = game.scene.getPlayerPokemon()!; wimpod.hp *= 0.52; @@ -231,13 +187,8 @@ describe("Abilities - Wimp Out", () => { }); it("Does not trigger when neutralized", async () => { - game.override - .enemyAbility(Abilities.NEUTRALIZING_GAS) - .startingLevel(5); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyAbility(Abilities.NEUTRALIZING_GAS).startingLevel(5); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); @@ -252,10 +203,10 @@ describe("Abilities - Wimp Out", () => { "If it falls below half and recovers back above half from a Shell Bell, Wimp Out will activate even after the Shell Bell recovery", async () => { game.override - .moveset([ Moves.DOUBLE_EDGE ]) - .enemyMoveset([ Moves.SPLASH ]) + .moveset([Moves.DOUBLE_EDGE]) + .enemyMoveset([Moves.SPLASH]) .startingHeldItems([{ name: "SHELL_BELL", count: 4 }]); - await game.classicMode.startBattle([ Species.WIMPOD, Species.TYRUNT ]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const wimpod = game.scene.getPlayerPokemon()!; @@ -273,13 +224,8 @@ describe("Abilities - Wimp Out", () => { ); it("Wimp Out will activate due to weather damage", async () => { - game.override - .weather(WeatherType.HAIL) - .enemyMoveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.weather(WeatherType.HAIL).enemyMoveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -291,14 +237,8 @@ describe("Abilities - Wimp Out", () => { }); it("Does not trigger when enemy has sheer force", async () => { - game.override - .enemyAbility(Abilities.SHEER_FORCE) - .enemyMoveset(Moves.SLUDGE_BOMB) - .startingLevel(95); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyAbility(Abilities.SHEER_FORCE).enemyMoveset(Moves.SLUDGE_BOMB).startingLevel(95); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -309,13 +249,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to post turn status damage", async () => { - game.override - .statusEffect(StatusEffect.POISON) - .enemyMoveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.statusEffect(StatusEffect.POISON).enemyMoveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -327,13 +262,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to bad dreams", async () => { - game.override - .statusEffect(StatusEffect.SLEEP) - .enemyAbility(Abilities.BAD_DREAMS); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.statusEffect(StatusEffect.SLEEP).enemyAbility(Abilities.BAD_DREAMS); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.52; @@ -345,12 +275,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to leech seed", async () => { - game.override - .enemyMoveset([ Moves.LEECH_SEED ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset([Moves.LEECH_SEED]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.52; game.move.select(Moves.SPLASH); @@ -361,13 +287,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to curse damage", async () => { - game.override - .enemySpecies(Species.DUSKNOIR) - .enemyMoveset([ Moves.CURSE ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemySpecies(Species.DUSKNOIR).enemyMoveset([Moves.CURSE]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.52; game.move.select(Moves.SPLASH); @@ -378,15 +299,9 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to salt cure damage", async () => { - game.override - .enemySpecies(Species.NACLI) - .enemyMoveset([ Moves.SALT_CURE ]) - .enemyLevel(1); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); - game.scene.getPlayerPokemon()!.hp *= 0.70; + game.override.enemySpecies(Species.NACLI).enemyMoveset([Moves.SALT_CURE]).enemyLevel(1); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); + game.scene.getPlayerPokemon()!.hp *= 0.7; game.move.select(Moves.SPLASH); game.doSelectPartyPokemon(1); @@ -396,14 +311,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out will activate due to damaging trap damage", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .enemyMoveset([ Moves.WHIRLPOOL ]) - .enemyLevel(1); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemySpecies(Species.MAGIKARP).enemyMoveset([Moves.WHIRLPOOL]).enemyLevel(1); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.55; game.move.select(Moves.SPLASH); @@ -418,13 +327,10 @@ describe("Abilities - Wimp Out", () => { game.scene.arena.addTag(ArenaTagType.SPIKES, 1, Moves.SPIKES, 0, ArenaTagSide.ENEMY); game.override .passiveAbility(Abilities.MAGIC_GUARD) - .enemyMoveset([ Moves.LEECH_SEED ]) + .enemyMoveset([Moves.LEECH_SEED]) .weather(WeatherType.HAIL) .statusEffect(StatusEffect.POISON); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; game.move.select(Moves.SPLASH); @@ -436,15 +342,8 @@ describe("Abilities - Wimp Out", () => { }); it("Wimp Out activating should not cancel a double battle", async () => { - game.override - .battleType("double") - .enemyAbility(Abilities.WIMP_OUT) - .enemyMoveset([ Moves.SPLASH ]) - .enemyLevel(1); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.battleType("double").enemyAbility(Abilities.WIMP_OUT).enemyMoveset([Moves.SPLASH]).enemyLevel(1); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); const enemyLeadPokemon = game.scene.getEnemyParty()[0]; const enemySecPokemon = game.scene.getEnemyParty()[1]; @@ -464,15 +363,12 @@ describe("Abilities - Wimp Out", () => { it("Wimp Out will activate due to aftermath", async () => { game.override - .moveset([ Moves.THUNDER_PUNCH ]) + .moveset([Moves.THUNDER_PUNCH]) .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.AFTERMATH) - .enemyMoveset([ Moves.SPLASH ]) + .enemyMoveset([Moves.SPLASH]) .enemyLevel(1); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; game.move.select(Moves.THUNDER_PUNCH); @@ -485,26 +381,16 @@ describe("Abilities - Wimp Out", () => { it("Activates due to entry hazards", async () => { game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0, ArenaTagSide.ENEMY); game.scene.arena.addTag(ArenaTagType.SPIKES, 1, Moves.SPIKES, 0, ArenaTagSide.ENEMY); - game.override - .enemySpecies(Species.CENTISKORCH) - .enemyAbility(Abilities.WIMP_OUT) - .startingWave(4); - await game.classicMode.startBattle([ - Species.TYRUNT - ]); + game.override.enemySpecies(Species.CENTISKORCH).enemyAbility(Abilities.WIMP_OUT).startingWave(4); + await game.classicMode.startBattle([Species.TYRUNT]); expect(game.phaseInterceptor.log).not.toContain("MovePhase"); expect(game.phaseInterceptor.log).toContain("BattleEndPhase"); }); it("Wimp Out will activate due to Nightmare", async () => { - game.override - .enemyMoveset([ Moves.NIGHTMARE ]) - .statusEffect(StatusEffect.SLEEP); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset([Moves.NIGHTMARE]).statusEffect(StatusEffect.SLEEP); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.65; game.move.select(Moves.SPLASH); @@ -515,13 +401,8 @@ describe("Abilities - Wimp Out", () => { }); it("triggers status on the wimp out user before a new pokemon is switched in", async () => { - game.override - .enemyMoveset(Moves.SLUDGE_BOMB) - .startingLevel(80); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset(Moves.SLUDGE_BOMB).startingLevel(80); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); vi.spyOn(allMoves[Moves.SLUDGE_BOMB], "chance", "get").mockReturnValue(100); game.move.select(Moves.SPLASH); @@ -533,13 +414,8 @@ describe("Abilities - Wimp Out", () => { }); it("triggers after last hit of multi hit move", async () => { - game.override - .enemyMoveset(Moves.BULLET_SEED) - .enemyAbility(Abilities.SKILL_LINK); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset(Moves.BULLET_SEED).enemyAbility(Abilities.SKILL_LINK); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -554,13 +430,8 @@ describe("Abilities - Wimp Out", () => { }); it("triggers after last hit of multi hit move (multi lens)", async () => { - game.override - .enemyMoveset(Moves.TACKLE) - .enemyHeldItems([{ name: "MULTI_LENS", count: 1 }]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset(Moves.TACKLE).enemyHeldItems([{ name: "MULTI_LENS", count: 1 }]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -574,13 +445,8 @@ describe("Abilities - Wimp Out", () => { confirmSwitch(); }); it("triggers after last hit of Parental Bond", async () => { - game.override - .enemyMoveset(Moves.TACKLE) - .enemyAbility(Abilities.PARENTAL_BOND); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); + game.override.enemyMoveset(Moves.TACKLE).enemyAbility(Abilities.PARENTAL_BOND); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); game.scene.getPlayerPokemon()!.hp *= 0.51; @@ -595,34 +461,30 @@ describe("Abilities - Wimp Out", () => { }); // TODO: This interaction is not implemented yet - it.todo("Wimp Out will not activate if the Pokémon's HP falls below half due to hurting itself in confusion", async () => { - game.override - .moveset([ Moves.SWORDS_DANCE ]) - .enemyMoveset([ Moves.SWAGGER ]); - await game.classicMode.startBattle([ - Species.WIMPOD, - Species.TYRUNT - ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.hp *= 0.51; - playerPokemon.setStatStage(Stat.ATK, 6); - playerPokemon.addTag(BattlerTagType.CONFUSED); + it.todo( + "Wimp Out will not activate if the Pokémon's HP falls below half due to hurting itself in confusion", + async () => { + game.override.moveset([Moves.SWORDS_DANCE]).enemyMoveset([Moves.SWAGGER]); + await game.classicMode.startBattle([Species.WIMPOD, Species.TYRUNT]); + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.hp *= 0.51; + playerPokemon.setStatStage(Stat.ATK, 6); + playerPokemon.addTag(BattlerTagType.CONFUSED); - // TODO: add helper function to force confusion self-hits + // TODO: add helper function to force confusion self-hits - while (playerPokemon.getHpRatio() > 0.49) { - game.move.select(Moves.SWORDS_DANCE); - await game.phaseInterceptor.to("TurnEndPhase"); - } + while (playerPokemon.getHpRatio() > 0.49) { + game.move.select(Moves.SWORDS_DANCE); + await game.phaseInterceptor.to("TurnEndPhase"); + } - confirmNoSwitch(); - }); + confirmNoSwitch(); + }, + ); it("should not activate on wave X0 bosses", async () => { - game.override.enemyAbility(Abilities.WIMP_OUT) - .startingLevel(5850) - .startingWave(10); - await game.classicMode.startBattle([ Species.GOLISOPOD ]); + game.override.enemyAbility(Abilities.WIMP_OUT).startingLevel(5850).startingWave(10); + await game.classicMode.startBattle([Species.GOLISOPOD]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -642,20 +504,17 @@ describe("Abilities - Wimp Out", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.WIMPOD) .enemyAbility(Abilities.WIMP_OUT) - .moveset([ Moves.MATCHA_GOTCHA, Moves.FALSE_SWIPE ]) + .moveset([Moves.MATCHA_GOTCHA, Moves.FALSE_SWIPE]) .startingLevel(50) .enemyLevel(1) .battleType("double") .startingWave(wave); - await game.classicMode.startBattle([ - Species.RAICHU, - Species.PIKACHU - ]); - const [ wimpod0, wimpod1 ] = game.scene.getEnemyField(); + await game.classicMode.startBattle([Species.RAICHU, Species.PIKACHU]); + const [wimpod0, wimpod1] = game.scene.getEnemyField(); game.move.select(Moves.FALSE_SWIPE, 0, BattlerIndex.ENEMY); game.move.select(Moves.MATCHA_GOTCHA, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase"); expect(wimpod0.hp).toBeGreaterThan(0); diff --git a/test/abilities/wind_power.test.ts b/test/abilities/wind_power.test.ts index f9be5393d15..b28ac3362eb 100644 --- a/test/abilities/wind_power.test.ts +++ b/test/abilities/wind_power.test.ts @@ -26,12 +26,12 @@ describe("Abilities - Wind Power", () => { game.override.battleType("single"); game.override.enemySpecies(Species.SHIFTRY); game.override.enemyAbility(Abilities.WIND_POWER); - game.override.moveset([ Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM ]); + game.override.moveset([Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM]); game.override.enemyMoveset(Moves.SPLASH); }); it("it becomes charged when hit by wind moves", async () => { - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const shiftry = game.scene.getEnemyPokemon()!; expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); @@ -46,7 +46,7 @@ describe("Abilities - Wind Power", () => { game.override.ability(Abilities.WIND_POWER); game.override.enemySpecies(Species.MAGIKARP); - await game.startBattle([ Species.SHIFTRY ]); + await game.startBattle([Species.SHIFTRY]); const shiftry = game.scene.getPlayerPokemon()!; expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); @@ -61,7 +61,7 @@ describe("Abilities - Wind Power", () => { game.override.enemySpecies(Species.MAGIKARP); game.override.ability(Abilities.WIND_POWER); - await game.startBattle([ Species.SHIFTRY ]); + await game.startBattle([Species.SHIFTRY]); const magikarp = game.scene.getEnemyPokemon()!; const shiftry = game.scene.getPlayerPokemon()!; @@ -79,7 +79,7 @@ describe("Abilities - Wind Power", () => { it("does not interact with Sandstorm", async () => { game.override.enemySpecies(Species.MAGIKARP); - await game.startBattle([ Species.SHIFTRY ]); + await game.startBattle([Species.SHIFTRY]); const shiftry = game.scene.getPlayerPokemon()!; expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); diff --git a/test/abilities/wind_rider.test.ts b/test/abilities/wind_rider.test.ts index 7cebd70a11a..8fdae1b24ec 100644 --- a/test/abilities/wind_rider.test.ts +++ b/test/abilities/wind_rider.test.ts @@ -26,12 +26,12 @@ describe("Abilities - Wind Rider", () => { .battleType("single") .enemySpecies(Species.SHIFTRY) .enemyAbility(Abilities.WIND_RIDER) - .moveset([ Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM ]) + .moveset([Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM]) .enemyMoveset(Moves.SPLASH); }); it("takes no damage from wind moves and its ATK stat stage is raised by 1 when hit by one", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const shiftry = game.scene.getEnemyPokemon()!; expect(shiftry.getStatStage(Stat.ATK)).toBe(0); @@ -45,11 +45,9 @@ describe("Abilities - Wind Rider", () => { }); it("ATK stat stage is raised by 1 when Tailwind is present on its side", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .ability(Abilities.WIND_RIDER); + game.override.enemySpecies(Species.MAGIKARP).ability(Abilities.WIND_RIDER); - await game.classicMode.startBattle([ Species.SHIFTRY ]); + await game.classicMode.startBattle([Species.SHIFTRY]); const shiftry = game.scene.getPlayerPokemon()!; expect(shiftry.getStatStage(Stat.ATK)).toBe(0); @@ -62,11 +60,9 @@ describe("Abilities - Wind Rider", () => { }); it("does not raise ATK stat stage when Tailwind is present on opposing side", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .ability(Abilities.WIND_RIDER); + game.override.enemySpecies(Species.MAGIKARP).ability(Abilities.WIND_RIDER); - await game.classicMode.startBattle([ Species.SHIFTRY ]); + await game.classicMode.startBattle([Species.SHIFTRY]); const magikarp = game.scene.getEnemyPokemon()!; const shiftry = game.scene.getPlayerPokemon()!; @@ -82,11 +78,9 @@ describe("Abilities - Wind Rider", () => { }); it("does not raise ATK stat stage when Tailwind is present on opposing side", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .ability(Abilities.WIND_RIDER); + game.override.enemySpecies(Species.MAGIKARP).ability(Abilities.WIND_RIDER); - await game.classicMode.startBattle([ Species.SHIFTRY ]); + await game.classicMode.startBattle([Species.SHIFTRY]); const magikarp = game.scene.getEnemyPokemon()!; const shiftry = game.scene.getPlayerPokemon()!; @@ -104,7 +98,7 @@ describe("Abilities - Wind Rider", () => { it("does not interact with Sandstorm", async () => { game.override.enemySpecies(Species.MAGIKARP); - await game.classicMode.startBattle([ Species.SHIFTRY ]); + await game.classicMode.startBattle([Species.SHIFTRY]); const shiftry = game.scene.getPlayerPokemon()!; expect(shiftry.getStatStage(Stat.ATK)).toBe(0); diff --git a/test/abilities/wonder_skin.test.ts b/test/abilities/wonder_skin.test.ts index d6c49ed4abe..f2cb0faed72 100644 --- a/test/abilities/wonder_skin.test.ts +++ b/test/abilities/wonder_skin.test.ts @@ -25,7 +25,7 @@ describe("Abilities - Wonder Skin", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.moveset([ Moves.TACKLE, Moves.CHARM ]); + game.override.moveset([Moves.TACKLE, Moves.CHARM]); game.override.ability(Abilities.BALL_FETCH); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.WONDER_SKIN); @@ -37,7 +37,7 @@ describe("Abilities - Wonder Skin", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); - await game.startBattle([ Species.PIKACHU ]); + await game.startBattle([Species.PIKACHU]); game.move.select(Moves.CHARM); await game.phaseInterceptor.to(MoveEffectPhase); @@ -49,14 +49,14 @@ describe("Abilities - Wonder Skin", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); - await game.startBattle([ Species.PIKACHU ]); + await game.startBattle([Species.PIKACHU]); game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); }); - const bypassAbilities = [ Abilities.MOLD_BREAKER, Abilities.TERAVOLT, Abilities.TURBOBLAZE ]; + const bypassAbilities = [Abilities.MOLD_BREAKER, Abilities.TERAVOLT, Abilities.TURBOBLAZE]; bypassAbilities.forEach(ability => { it(`does not affect pokemon with ${allAbilities[ability].name}`, async () => { @@ -65,7 +65,7 @@ describe("Abilities - Wonder Skin", () => { game.override.ability(ability); vi.spyOn(moveToCheck, "calculateBattleAccuracy"); - await game.startBattle([ Species.PIKACHU ]); + await game.startBattle([Species.PIKACHU]); game.move.select(Moves.CHARM); await game.phaseInterceptor.to(MoveEffectPhase); diff --git a/test/abilities/zen_mode.test.ts b/test/abilities/zen_mode.test.ts index cb4c82e00dc..d552d8c88ca 100644 --- a/test/abilities/zen_mode.test.ts +++ b/test/abilities/zen_mode.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - ZEN MODE", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -38,7 +37,7 @@ describe("Abilities - ZEN MODE", () => { }); it("shouldn't change form when taking damage if not dropping below 50% HP", async () => { - await game.classicMode.startBattle([ Species.DARMANITAN ]); + await game.classicMode.startBattle([Species.DARMANITAN]); const darmanitan = game.scene.getPlayerPokemon()!; expect(darmanitan.formIndex).toBe(baseForm); @@ -51,10 +50,10 @@ describe("Abilities - ZEN MODE", () => { }); it("should change form when falling below 50% HP", async () => { - await game.classicMode.startBattle([ Species.DARMANITAN ]); + await game.classicMode.startBattle([Species.DARMANITAN]); const darmanitan = game.scene.getPlayerPokemon()!; - darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1; + darmanitan.hp = darmanitan.getMaxHp() / 2 + 1; expect(darmanitan.formIndex).toBe(baseForm); game.move.select(Moves.SPLASH); @@ -65,9 +64,9 @@ describe("Abilities - ZEN MODE", () => { }); it("should stay zen mode when fainted", async () => { - await game.classicMode.startBattle([ Species.DARMANITAN, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.DARMANITAN, Species.CHARIZARD]); const darmanitan = game.scene.getPlayerPokemon()!; - darmanitan.hp = (darmanitan.getMaxHp() / 2) + 1; + darmanitan.hp = darmanitan.getMaxHp() / 2 + 1; expect(darmanitan.formIndex).toBe(baseForm); game.move.select(Moves.SPLASH); @@ -91,7 +90,7 @@ describe("Abilities - ZEN MODE", () => { [Species.DARMANITAN]: zenForm, }); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.DARMANITAN ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.DARMANITAN]); const darmanitan = game.scene.getPlayerParty()[1]; darmanitan.hp = 1; diff --git a/test/abilities/zero_to_hero.test.ts b/test/abilities/zero_to_hero.test.ts index 338ebd6344f..4565aa3e8b2 100644 --- a/test/abilities/zero_to_hero.test.ts +++ b/test/abilities/zero_to_hero.test.ts @@ -8,7 +8,6 @@ import { StatusEffect } from "#enums/status-effect"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Abilities - ZERO TO HERO", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -40,7 +39,7 @@ describe("Abilities - ZERO TO HERO", () => { [Species.PALAFIN]: heroForm, }); - await game.startBattle([ Species.FEEBAS, Species.PALAFIN, Species.PALAFIN ]); + await game.startBattle([Species.FEEBAS, Species.PALAFIN, Species.PALAFIN]); const palafin1 = game.scene.getPlayerParty()[1]; const palafin2 = game.scene.getPlayerParty()[2]; @@ -62,7 +61,7 @@ describe("Abilities - ZERO TO HERO", () => { }); it("should swap to Hero form when switching out during a battle", async () => { - await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]); + await game.startBattle([Species.PALAFIN, Species.FEEBAS]); const palafin = game.scene.getPlayerPokemon()!; expect(palafin.formIndex).toBe(baseForm); @@ -73,7 +72,7 @@ describe("Abilities - ZERO TO HERO", () => { }); it("should not swap to Hero form if switching due to faint", async () => { - await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]); + await game.startBattle([Species.PALAFIN, Species.FEEBAS]); const palafin = game.scene.getPlayerPokemon()!; expect(palafin.formIndex).toBe(baseForm); @@ -90,7 +89,7 @@ describe("Abilities - ZERO TO HERO", () => { [Species.PALAFIN]: heroForm, }); - await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]); + await game.startBattle([Species.PALAFIN, Species.FEEBAS]); const palafin = game.scene.getPlayerPokemon()!; expect(palafin.formIndex).toBe(heroForm); diff --git a/test/account.test.ts b/test/account.test.ts index 099564ce7a8..3f6b9f3f80b 100644 --- a/test/account.test.ts +++ b/test/account.test.ts @@ -17,7 +17,7 @@ describe("account", () => { it("should set loggedInUser! to Guest if bypassLogin is true", async () => { vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); - const [ success, status ] = await updateUserInfo(); + const [success, status] = await updateUserInfo(); expect(success).toBe(true); expect(status).toBe(200); @@ -38,7 +38,7 @@ describe("account", () => { 200, ]); - const [ success, status ] = await updateUserInfo(); + const [success, status] = await updateUserInfo(); expect(success).toBe(true); expect(status).toBe(200); @@ -48,9 +48,9 @@ describe("account", () => { it("should handle resolved API errors", async () => { vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); - vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([ null, 401 ]); + vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 401]); - const [ success, status ] = await updateUserInfo(); + const [success, status] = await updateUserInfo(); expect(success).toBe(false); expect(status).toBe(401); @@ -58,9 +58,9 @@ describe("account", () => { it("should handle 500 API errors", async () => { vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(false); - vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([ null, 500 ]); + vi.spyOn(pokerogueApi.account, "getInfo").mockResolvedValue([null, 500]); - const [ success, status ] = await updateUserInfo(); + const [success, status] = await updateUserInfo(); expect(success).toBe(false); expect(status).toBe(500); diff --git a/test/achievements/achievement.test.ts b/test/achievements/achievement.test.ts index 3c6dc8aefe8..26d33adb00a 100644 --- a/test/achievements/achievement.test.ts +++ b/test/achievements/achievement.test.ts @@ -1,5 +1,15 @@ import { TurnHeldItemTransferModifier } from "#app/modifier/modifier"; -import { Achv, AchvTier, DamageAchv, HealAchv, LevelAchv, ModifierAchv, MoneyAchv, RibbonAchv, achvs } from "#app/system/achv"; +import { + Achv, + AchvTier, + DamageAchv, + HealAchv, + LevelAchv, + ModifierAchv, + MoneyAchv, + RibbonAchv, + achvs, +} from "#app/system/achv"; import { NumberHolder } from "#app/utils"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; @@ -7,13 +17,12 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import BattleScene from "#app/battle-scene"; describe("check some Achievement related stuff", () => { - it ("should check Achievement creation", () => { + it("should check Achievement creation", () => { const ach = new MoneyAchv("", "Achievement", 1000, null!, 100); expect(ach.name).toBe("Achievement"); }); }); - describe("Achv", () => { let achv: Achv; @@ -61,8 +70,8 @@ describe("Achv", () => { const conditionFunc = vi.fn((args: any[]) => args[0] === 10); const achv = new Achv("", "Test Achievement", "Test Description", "test_icon", 10, conditionFunc); - expect(achv.validate([ 5 ])).toBe(false); - expect(achv.validate([ 10 ])).toBe(true); + expect(achv.validate([5])).toBe(false); + expect(achv.validate([10])).toBe(true); expect(conditionFunc).toHaveBeenCalledTimes(2); }); }); @@ -140,10 +149,10 @@ describe("DamageAchv", () => { const damageAchv = new DamageAchv("", "Test Damage Achievement", 250, "damage_icon", 10); const numberHolder = new NumberHolder(200); - expect(damageAchv.validate([ numberHolder ])).toBe(false); + expect(damageAchv.validate([numberHolder])).toBe(false); numberHolder.value = 300; - expect(damageAchv.validate([ numberHolder ])).toBe(true); + expect(damageAchv.validate([numberHolder])).toBe(true); }); }); @@ -158,10 +167,10 @@ describe("HealAchv", () => { const healAchv = new HealAchv("", "Test Heal Achievement", 250, "heal_icon", 10); const numberHolder = new NumberHolder(200); - expect(healAchv.validate([ numberHolder ])).toBe(false); + expect(healAchv.validate([numberHolder])).toBe(false); numberHolder.value = 300; - expect(healAchv.validate([ numberHolder ])).toBe(true); + expect(healAchv.validate([numberHolder])).toBe(true); }); }); @@ -176,25 +185,39 @@ describe("LevelAchv", () => { const levelAchv = new LevelAchv("", "Test Level Achievement", 100, "level_icon", 10); const integerHolder = new NumberHolder(50); - expect(levelAchv.validate([ integerHolder ])).toBe(false); + expect(levelAchv.validate([integerHolder])).toBe(false); integerHolder.value = 150; - expect(levelAchv.validate([ integerHolder ])).toBe(true); + expect(levelAchv.validate([integerHolder])).toBe(true); }); }); describe("ModifierAchv", () => { it("should create an instance of ModifierAchv", () => { - const modifierAchv = new ModifierAchv("", "Test Modifier Achievement", "Test Description", "modifier_icon", 10, () => true); + const modifierAchv = new ModifierAchv( + "", + "Test Modifier Achievement", + "Test Description", + "modifier_icon", + 10, + () => true, + ); expect(modifierAchv).toBeInstanceOf(ModifierAchv); expect(modifierAchv instanceof Achv).toBe(true); }); it("should validate the achievement based on the modifier function", () => { - const modifierAchv = new ModifierAchv("", "Test Modifier Achievement", "Test Description", "modifier_icon", 10, () => true); + const modifierAchv = new ModifierAchv( + "", + "Test Modifier Achievement", + "Test Description", + "modifier_icon", + 10, + () => true, + ); const modifier = new TurnHeldItemTransferModifier(null!, 3, 1); - expect(modifierAchv.validate([ modifier ])).toBe(true); + expect(modifierAchv.validate([modifier])).toBe(true); }); }); @@ -243,7 +266,6 @@ describe("achvs", () => { }); it("should initialize the achievements with IDs and parent IDs", () => { - expect(achvs._10K_MONEY.id).toBe("_10K_MONEY"); expect(achvs._10K_MONEY.hasParent).toBe(undefined); expect(achvs._100K_MONEY.id).toBe("_100K_MONEY"); diff --git a/test/arena/arena_gravity.test.ts b/test/arena/arena_gravity.test.ts index 4bacf51f094..a5ce84667f0 100644 --- a/test/arena/arena_gravity.test.ts +++ b/test/arena/arena_gravity.test.ts @@ -27,7 +27,7 @@ describe("Arena - Gravity", () => { game = new GameManager(phaserGame); game.override .battleType("single") - .moveset([ Moves.TACKLE, Moves.GRAVITY, Moves.FISSURE ]) + .moveset([Moves.TACKLE, Moves.GRAVITY, Moves.FISSURE]) .ability(Abilities.UNNERVE) .enemyAbility(Abilities.BALL_FETCH) .enemySpecies(Species.SHUCKLE) @@ -43,7 +43,7 @@ describe("Arena - Gravity", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); // Setup Gravity on first turn - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.GRAVITY); await game.phaseInterceptor.to("TurnEndPhase"); @@ -64,7 +64,7 @@ describe("Arena - Gravity", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); // Setup Gravity on first turn - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.GRAVITY); await game.phaseInterceptor.to("TurnEndPhase"); @@ -80,11 +80,9 @@ describe("Arena - Gravity", () => { describe("Against flying types", () => { it("can be hit by ground-type moves now", async () => { - game.override - .enemySpecies(Species.PIDGEOT) - .moveset([ Moves.GRAVITY, Moves.EARTHQUAKE ]); + game.override.enemySpecies(Species.PIDGEOT).moveset([Moves.GRAVITY, Moves.EARTHQUAKE]); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pidgeot = game.scene.getEnemyPokemon()!; vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); @@ -111,11 +109,9 @@ describe("Arena - Gravity", () => { }); it("keeps super-effective moves super-effective after using gravity", async () => { - game.override - .enemySpecies(Species.PIDGEOT) - .moveset([ Moves.GRAVITY, Moves.THUNDERBOLT ]); + game.override.enemySpecies(Species.PIDGEOT).moveset([Moves.GRAVITY, Moves.THUNDERBOLT]); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pidgeot = game.scene.getEnemyPokemon()!; vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); @@ -136,12 +132,9 @@ describe("Arena - Gravity", () => { }); it("cancels Fly if its user is semi-invulnerable", async () => { - game.override - .enemySpecies(Species.SNORLAX) - .enemyMoveset(Moves.FLY) - .moveset([ Moves.GRAVITY, Moves.SPLASH ]); + game.override.enemySpecies(Species.SNORLAX).enemyMoveset(Moves.FLY).moveset([Moves.GRAVITY, Moves.SPLASH]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const charizard = game.scene.getPlayerPokemon()!; const snorlax = game.scene.getEnemyPokemon()!; @@ -152,7 +145,7 @@ describe("Arena - Gravity", () => { expect(snorlax.getTag(BattlerTagType.FLYING)).toBeDefined(); game.move.select(Moves.GRAVITY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(snorlax.getTag(BattlerTagType.INTERRUPTED)).toBeDefined(); diff --git a/test/arena/grassy_terrain.test.ts b/test/arena/grassy_terrain.test.ts index a9a955efdfe..d92fb24be5a 100644 --- a/test/arena/grassy_terrain.test.ts +++ b/test/arena/grassy_terrain.test.ts @@ -28,12 +28,12 @@ describe("Arena - Grassy Terrain", () => { .enemySpecies(Species.SHUCKLE) .enemyAbility(Abilities.STURDY) .enemyMoveset(Moves.FLY) - .moveset([ Moves.GRASSY_TERRAIN, Moves.EARTHQUAKE ]) + .moveset([Moves.GRASSY_TERRAIN, Moves.EARTHQUAKE]) .ability(Abilities.NO_GUARD); }); it("halves the damage of Earthquake", async () => { - await game.classicMode.startBattle([ Species.TAUROS ]); + await game.classicMode.startBattle([Species.TAUROS]); const eq = allMoves[Moves.EARTHQUAKE]; vi.spyOn(eq, "calculateBattlePower"); @@ -53,7 +53,7 @@ describe("Arena - Grassy Terrain", () => { }); it("Does not halve the damage of Earthquake if opponent is not grounded", async () => { - await game.classicMode.startBattle([ Species.NINJASK ]); + await game.classicMode.startBattle([Species.NINJASK]); const eq = allMoves[Moves.EARTHQUAKE]; vi.spyOn(eq, "calculateBattlePower"); diff --git a/test/arena/weather_fog.test.ts b/test/arena/weather_fog.test.ts index 1b98b791aec..784c4886648 100644 --- a/test/arena/weather_fog.test.ts +++ b/test/arena/weather_fog.test.ts @@ -24,14 +24,12 @@ describe("Weather - Fog", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override - .weather(WeatherType.FOG) - .battleType("single"); - game.override.moveset([ Moves.TACKLE ]); + game.override.weather(WeatherType.FOG).battleType("single"); + game.override.moveset([Moves.TACKLE]); game.override.ability(Abilities.BALL_FETCH); game.override.enemyAbility(Abilities.BALL_FETCH); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); }); it("move accuracy is multiplied by 90%", async () => { @@ -39,7 +37,7 @@ describe("Weather - Fog", () => { vi.spyOn(moveToCheck, "calculateBattleAccuracy"); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); game.move.select(Moves.TACKLE); await game.phaseInterceptor.to(MoveEffectPhase); diff --git a/test/arena/weather_hail.test.ts b/test/arena/weather_hail.test.ts index 137c7622517..7af2edf26f2 100644 --- a/test/arena/weather_hail.test.ts +++ b/test/arena/weather_hail.test.ts @@ -31,10 +31,10 @@ describe("Weather - Hail", () => { }); it("inflicts damage equal to 1/16 of Pokemon's max HP at turn end", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); @@ -44,11 +44,11 @@ describe("Weather - Hail", () => { }); it("does not inflict damage to a Pokemon that is underwater (Dive) or underground (Dig)", async () => { - game.override.moveset([ Moves.DIG ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.DIG]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.DIG); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); @@ -60,7 +60,7 @@ describe("Weather - Hail", () => { }); it("does not inflict damage to Ice type Pokemon", async () => { - await game.classicMode.startBattle([ Species.CLOYSTER ]); + await game.classicMode.startBattle([Species.CLOYSTER]); game.move.select(Moves.SPLASH); diff --git a/test/arena/weather_sandstorm.test.ts b/test/arena/weather_sandstorm.test.ts index 6420117d107..d43983c4c01 100644 --- a/test/arena/weather_sandstorm.test.ts +++ b/test/arena/weather_sandstorm.test.ts @@ -32,7 +32,7 @@ describe("Weather - Sandstorm", () => { }); it("inflicts damage equal to 1/16 of Pokemon's max HP at turn end", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPLASH); @@ -44,8 +44,8 @@ describe("Weather - Sandstorm", () => { }); it("does not inflict damage to a Pokemon that is underwater (Dive) or underground (Dig)", async () => { - game.override.moveset([ Moves.DIVE ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.DIVE]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.DIVE); @@ -65,7 +65,7 @@ describe("Weather - Sandstorm", () => { .ability(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH); - await game.classicMode.startBattle([ Species.ROCKRUFF, Species.KLINK ]); + await game.classicMode.startBattle([Species.ROCKRUFF, Species.KLINK]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.SPLASH, 1); @@ -78,7 +78,7 @@ describe("Weather - Sandstorm", () => { }); it("increases Rock type Pokemon Sp.Def by 50%", async () => { - await game.classicMode.startBattle([ Species.ROCKRUFF ]); + await game.classicMode.startBattle([Species.ROCKRUFF]); const playerPokemon = game.scene.getPlayerPokemon()!; const playerSpdef = playerPokemon.getStat(Stat.SPDEF); diff --git a/test/arena/weather_strong_winds.test.ts b/test/arena/weather_strong_winds.test.ts index edc3025111d..3a9235d9eb9 100644 --- a/test/arena/weather_strong_winds.test.ts +++ b/test/arena/weather_strong_winds.test.ts @@ -28,13 +28,13 @@ describe("Weather - Strong Winds", () => { game.override.startingLevel(10); game.override.enemySpecies(Species.TAILLOW); game.override.enemyAbility(Abilities.DELTA_STREAM); - game.override.moveset([ Moves.THUNDERBOLT, Moves.ICE_BEAM, Moves.ROCK_SLIDE ]); + game.override.moveset([Moves.THUNDERBOLT, Moves.ICE_BEAM, Moves.ROCK_SLIDE]); }); it("electric type move is not very effective on Rayquaza", async () => { game.override.enemySpecies(Species.RAYQUAZA); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -45,7 +45,7 @@ describe("Weather - Strong Winds", () => { }); it("electric type move is neutral for flying type pokemon", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -56,7 +56,7 @@ describe("Weather - Strong Winds", () => { }); it("ice type move is neutral for flying type pokemon", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -67,7 +67,7 @@ describe("Weather - Strong Winds", () => { }); it("rock type move is neutral for flying type pokemon", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const pikachu = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -80,7 +80,7 @@ describe("Weather - Strong Winds", () => { it("weather goes away when last trainer pokemon dies to indirect damage", async () => { game.override.enemyStatusEffect(StatusEffect.POISON); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 1; diff --git a/test/battle/ability_swap.test.ts b/test/battle/ability_swap.test.ts index ff3f7c002bc..b9c609e89f6 100644 --- a/test/battle/ability_swap.test.ts +++ b/test/battle/ability_swap.test.ts @@ -24,7 +24,7 @@ describe("Test Ability Swapping", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -34,7 +34,7 @@ describe("Test Ability Swapping", () => { }); it("should activate post-summon abilities", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); game.scene.getPlayerPokemon()?.setTempAbility(allAbilities[Abilities.INTIMIDATE]); @@ -45,7 +45,7 @@ describe("Test Ability Swapping", () => { it("should remove primal weather when the setter's ability is removed", async () => { game.override.ability(Abilities.DESOLATE_LAND); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); game.scene.getPlayerPokemon()?.setTempAbility(allAbilities[Abilities.BALL_FETCH]); @@ -56,7 +56,7 @@ describe("Test Ability Swapping", () => { it("should not activate passive abilities", async () => { game.override.passiveAbility(Abilities.INTREPID_SWORD); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SPLASH); game.scene.getPlayerPokemon()?.setTempAbility(allAbilities[Abilities.BALL_FETCH]); diff --git a/test/battle/battle-order.test.ts b/test/battle/battle-order.test.ts index 165a2fc916c..012f1ecd4bd 100644 --- a/test/battle/battle-order.test.ts +++ b/test/battle/battle-order.test.ts @@ -28,18 +28,16 @@ describe("Battle order", () => { game.override.enemySpecies(Species.MEWTWO); game.override.enemyAbility(Abilities.INSOMNIA); game.override.ability(Abilities.INSOMNIA); - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); }); it("opponent faster than player 50 vs 150", async () => { - await game.startBattle([ - Species.BULBASAUR, - ]); + await game.startBattle([Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 50 ]); // set playerPokemon's speed to 50 - vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ]); // set enemyPokemon's speed to 150 + vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set playerPokemon's speed to 50 + vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150 game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); @@ -53,14 +51,12 @@ describe("Battle order", () => { }, 20000); it("Player faster than opponent 150 vs 50", async () => { - await game.startBattle([ - Species.BULBASAUR, - ]); + await game.startBattle([Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ]); // set playerPokemon's speed to 150 - vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 50 ]); // set enemyPokemon's speed to 50 + vi.spyOn(playerPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set playerPokemon's speed to 150 + vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set enemyPokemon's speed to 50 game.move.select(Moves.TACKLE); await game.phaseInterceptor.run(EnemyCommandPhase); @@ -75,16 +71,13 @@ describe("Battle order", () => { it("double - both opponents faster than player 50/50 vs 150/150", async () => { game.override.battleType("double"); - await game.startBattle([ - Species.BULBASAUR, - Species.BLASTOISE, - ]); + await game.startBattle([Species.BULBASAUR, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 50 ])); // set both playerPokemons' speed to 50 - enemyPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ])); // set both enemyPokemons' speed to 150 + playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50])); // set both playerPokemons' speed to 50 + enemyPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150])); // set both enemyPokemons' speed to 150 const playerIndices = playerPokemon.map(p => p?.getBattlerIndex()); const enemyIndices = enemyPokemon.map(p => p?.getBattlerIndex()); @@ -102,16 +95,13 @@ describe("Battle order", () => { it("double - speed tie except 1 - 100/100 vs 100/150", async () => { game.override.battleType("double"); - await game.startBattle([ - Species.BULBASAUR, - Species.BLASTOISE, - ]); + await game.startBattle([Species.BULBASAUR, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 100 ])); //set both playerPokemons' speed to 100 - vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 100 ]); // set enemyPokemon's speed to 100 - vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ]); // set enemyPokemon's speed to 150 + playerPokemon.forEach(p => vi.spyOn(p, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100])); //set both playerPokemons' speed to 100 + vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set enemyPokemon's speed to 100 + vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150 const playerIndices = playerPokemon.map(p => p?.getBattlerIndex()); const enemyIndices = enemyPokemon.map(p => p?.getBattlerIndex()); @@ -129,17 +119,14 @@ describe("Battle order", () => { it("double - speed tie 100/150 vs 100/150", async () => { game.override.battleType("double"); - await game.startBattle([ - Species.BULBASAUR, - Species.BLASTOISE, - ]); + await game.startBattle([Species.BULBASAUR, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); - vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 100 ]); // set one playerPokemon's speed to 100 - vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ]); // set other playerPokemon's speed to 150 - vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 100 ]); // set one enemyPokemon's speed to 100 - vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, 150 ]); // set other enemyPokemon's speed to 150 + vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set one playerPokemon's speed to 100 + vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set other playerPokemon's speed to 150 + vi.spyOn(enemyPokemon[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 100]); // set one enemyPokemon's speed to 100 + vi.spyOn(enemyPokemon[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set other enemyPokemon's speed to 150 const playerIndices = playerPokemon.map(p => p?.getBattlerIndex()); const enemyIndices = enemyPokemon.map(p => p?.getBattlerIndex()); diff --git a/test/battle/battle.test.ts b/test/battle/battle.test.ts index edd04cf8ed0..36d197d1289 100644 --- a/test/battle/battle.test.ts +++ b/test/battle/battle.test.ts @@ -59,7 +59,6 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(TitlePhase); await game.waitMode(Mode.TITLE); - expect(game.scene.ui?.getMode()).toBe(Mode.TITLE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); @@ -81,7 +80,6 @@ describe("Test Battle Phase", () => { await game.phaseInterceptor.run(TitlePhase); await game.waitMode(Mode.TITLE); - expect(game.scene.ui?.getMode()).toBe(Mode.TITLE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); }, 20000); @@ -96,12 +94,10 @@ describe("Test Battle Phase", () => { game.override.starterSpecies(Species.MEWTWO); game.override.enemySpecies(Species.RATTATA); game.override.startingLevel(2000); - game.override - .startingWave(3) - .battleType("single"); - game.override.moveset([ Moves.TACKLE ]); + game.override.startingWave(3).battleType("single"); + game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.HYDRATION); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle(); game.move.select(Moves.TACKLE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(SelectModifierPhase, false); @@ -112,9 +108,9 @@ describe("Test Battle Phase", () => { game.override.enemySpecies(Species.RATTATA); game.override.startingLevel(5); game.override.startingWave(3); - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.HYDRATION); - game.override.enemyMoveset([ Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP ]); + game.override.enemyMoveset([Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP]); game.override.battleType("single"); await game.startBattle(); game.move.select(Moves.TACKLE); @@ -123,7 +119,7 @@ describe("Test Battle Phase", () => { it("load 100% data file", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -131,11 +127,7 @@ describe("Test Battle Phase", () => { }, 20000); it("start battle with selected team", async () => { - await game.startBattle([ - Species.CHARIZARD, - Species.CHANSEY, - Species.MEW - ]); + await game.startBattle([Species.CHARIZARD, Species.CHANSEY, Species.MEW]); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(Species.CHARIZARD); expect(game.scene.getPlayerParty()[1].species.speciesId).toBe(Species.CHANSEY); expect(game.scene.getPlayerParty()[2].species.speciesId).toBe(Species.MEW); @@ -150,7 +142,7 @@ describe("Test Battle Phase", () => { it("wrong phase", async () => { await game.phaseInterceptor.run(LoginPhase); - await game.phaseInterceptor.run(LoginPhase).catch((e) => { + await game.phaseInterceptor.run(LoginPhase).catch(e => { expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase"); }); }, 20000); @@ -162,29 +154,44 @@ describe("Test Battle Phase", () => { it("good run", async () => { await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, () => game.isCurrentPhase(TitlePhase)); + game.onNextPrompt( + "SelectGenderPhase", + Mode.OPTION_SELECT, + () => { + game.scene.gameData.gender = PlayerGender.MALE; + game.endPhase(); + }, + () => game.isCurrentPhase(TitlePhase), + ); await game.phaseInterceptor.run(SelectGenderPhase, () => game.isCurrentPhase(TitlePhase)); await game.phaseInterceptor.run(TitlePhase); }, 20000); it("good run from select gender to title", async () => { await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, () => game.isCurrentPhase(TitlePhase)); + game.onNextPrompt( + "SelectGenderPhase", + Mode.OPTION_SELECT, + () => { + game.scene.gameData.gender = PlayerGender.MALE; + game.endPhase(); + }, + () => game.isCurrentPhase(TitlePhase), + ); await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase); }, 20000); it("good run to SummonPhase phase", async () => { await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, () => game.isCurrentPhase(TitlePhase)); + game.onNextPrompt( + "SelectGenderPhase", + Mode.OPTION_SELECT, + () => { + game.scene.gameData.gender = PlayerGender.MALE; + game.endPhase(); + }, + () => game.isCurrentPhase(TitlePhase), + ); game.onNextPrompt("TitlePhase", Mode.TITLE, () => { game.scene.gameMode = getGameMode(GameModes.CLASSIC); const starters = generateStarter(game.scene); @@ -200,10 +207,7 @@ describe("Test Battle Phase", () => { game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -213,9 +217,7 @@ describe("Test Battle Phase", () => { game.override.enemySpecies(Species.MIGHTYENA); game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); - await game.startBattle([ - Species.BLASTOISE, - ]); + await game.startBattle([Species.BLASTOISE]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -226,10 +228,7 @@ describe("Test Battle Phase", () => { game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); game.override.startingWave(3); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -240,12 +239,7 @@ describe("Test Battle Phase", () => { game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); game.override.startingWave(3); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - Species.DARKRAI, - Species.GABITE, - ]); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); @@ -259,12 +253,9 @@ describe("Test Battle Phase", () => { game.override.ability(Abilities.ZEN_MODE); game.override.startingLevel(2000); game.override.startingWave(3); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); - await game.startBattle([ - Species.DARMANITAN, - Species.CHARIZARD, - ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); + await game.startBattle([Species.DARMANITAN, Species.CHARIZARD]); game.move.select(moveToUse); await game.phaseInterceptor.to(DamageAnimPhase, false); @@ -282,8 +273,8 @@ describe("Test Battle Phase", () => { game.override.ability(Abilities.ZEN_MODE); game.override.startingLevel(2000); game.override.startingWave(3); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.startBattle(); const turn = game.scene.currentBattle.turn; game.move.select(moveToUse); @@ -302,8 +293,8 @@ describe("Test Battle Phase", () => { .startingLevel(2000) .startingWave(3) .startingBiome(Biome.LAKE) - .moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + .moveset([moveToUse]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); await game.classicMode.startBattle(); const waveIndex = game.scene.currentBattle.waveIndex; game.move.select(moveToUse); @@ -323,7 +314,7 @@ describe("Test Battle Phase", () => { .enemySpecies(Species.RATTATA) .startingWave(1) .startingLevel(100) - .moveset([ moveToUse ]) + .moveset([moveToUse]) .enemyMoveset(Moves.SPLASH) .startingHeldItems([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]); @@ -335,10 +326,14 @@ describe("Test Battle Phase", () => { game.doRevivePokemon(0); // pretend max revive was picked game.doSelectModifier(); - game.onNextPrompt("SwitchPhase", Mode.PARTY, () => { - expect.fail("Switch was forced"); - }, () => game.isCurrentPhase(NextEncounterPhase)); + game.onNextPrompt( + "SwitchPhase", + Mode.PARTY, + () => { + expect.fail("Switch was forced"); + }, + () => game.isCurrentPhase(NextEncounterPhase), + ); await game.phaseInterceptor.to(SwitchPhase); }, 20000); }); - diff --git a/test/battle/damage_calculation.test.ts b/test/battle/damage_calculation.test.ts index 111a53a0c9b..dab1fc81caa 100644 --- a/test/battle/damage_calculation.test.ts +++ b/test/battle/damage_calculation.test.ts @@ -33,11 +33,11 @@ describe("Battle Mechanics - Damage Calculation", () => { .startingLevel(100) .enemyLevel(100) .disableCrits() - .moveset([ Moves.TACKLE, Moves.DRAGON_RAGE, Moves.FISSURE, Moves.JUMP_KICK ]); + .moveset([Moves.TACKLE, Moves.DRAGON_RAGE, Moves.FISSURE, Moves.JUMP_KICK]); }); it("Tackle deals expected base damage", async () => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const playerPokemon = game.scene.getPlayerPokemon()!; vi.spyOn(playerPokemon, "getEffectiveStat").mockReturnValue(80); @@ -51,11 +51,9 @@ describe("Battle Mechanics - Damage Calculation", () => { }); it("Attacks deal 1 damage at minimum", async () => { - game.override - .startingLevel(1) - .enemySpecies(Species.AGGRON); + game.override.startingLevel(1).enemySpecies(Species.AGGRON); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const aggron = game.scene.getEnemyPokemon()!; @@ -68,13 +66,9 @@ describe("Battle Mechanics - Damage Calculation", () => { }); it("Attacks deal 1 damage at minimum even with many tokens", async () => { - game.override - .startingLevel(1) - .enemySpecies(Species.AGGRON) - .enemyAbility(Abilities.STURDY) - .enemyLevel(10000); + game.override.startingLevel(1).enemySpecies(Species.AGGRON).enemyAbility(Abilities.STURDY).enemyLevel(10000); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); const dmg_redux_modifier = modifierTypes.ENEMY_DAMAGE_REDUCTION().newModifier() as EnemyPersistentModifier; dmg_redux_modifier.stackCount = 1000; @@ -90,11 +84,9 @@ describe("Battle Mechanics - Damage Calculation", () => { }); it("Fixed-damage moves ignore damage multipliers", async () => { - game.override - .enemySpecies(Species.DRAGONITE) - .enemyAbility(Abilities.MULTISCALE); + game.override.enemySpecies(Species.DRAGONITE).enemyAbility(Abilities.MULTISCALE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const magikarp = game.scene.getPlayerPokemon()!; const dragonite = game.scene.getEnemyPokemon()!; @@ -103,11 +95,9 @@ describe("Battle Mechanics - Damage Calculation", () => { }); it("One-hit KO moves ignore damage multipliers", async () => { - game.override - .enemySpecies(Species.AGGRON) - .enemyAbility(Abilities.MULTISCALE); + game.override.enemySpecies(Species.AGGRON).enemyAbility(Abilities.MULTISCALE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const magikarp = game.scene.getPlayerPokemon()!; const aggron = game.scene.getEnemyPokemon()!; @@ -116,11 +106,9 @@ describe("Battle Mechanics - Damage Calculation", () => { }); it("When the user fails to use Jump Kick with Wonder Guard ability, the damage should be 1.", async () => { - game.override - .enemySpecies(Species.GASTLY) - .ability(Abilities.WONDER_GUARD); + game.override.enemySpecies(Species.GASTLY).ability(Abilities.WONDER_GUARD); - await game.classicMode.startBattle([ Species.SHEDINJA ]); + await game.classicMode.startBattle([Species.SHEDINJA]); const shedinja = game.scene.getPlayerPokemon()!; @@ -131,15 +119,11 @@ describe("Battle Mechanics - Damage Calculation", () => { expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1); }); - it("Charizard with odd HP survives Stealth Rock damage twice", async () => { game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0); - game.override - .seed("Charizard Stealth Rock test") - .enemySpecies(Species.CHARIZARD) - .enemyAbility(Abilities.BLAZE); + game.override.seed("Charizard Stealth Rock test").enemySpecies(Species.CHARIZARD).enemyAbility(Abilities.BLAZE); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const charizard = game.scene.getEnemyPokemon()!; diff --git a/test/battle/double_battle.test.ts b/test/battle/double_battle.test.ts index de65245698e..21d27573d22 100644 --- a/test/battle/double_battle.test.ts +++ b/test/battle/double_battle.test.ts @@ -34,11 +34,7 @@ describe("Double Battles", () => { // (There were bugs that either only summon one when can summon two, player stuck in switchPhase etc) it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async () => { game.override.battleType("double").enemyMoveset(Moves.SPLASH).moveset(Moves.SPLASH); - await game.startBattle([ - Species.BULBASAUR, - Species.CHARIZARD, - Species.SQUIRTLE, - ]); + await game.startBattle([Species.BULBASAUR, Species.CHARIZARD, Species.SQUIRTLE]); game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH, 1); @@ -70,13 +66,14 @@ describe("Double Battles", () => { return rngSweepProgress * (max - min) + min; }); - game.override.enemyMoveset(Moves.SPLASH) + game.override + .enemyMoveset(Moves.SPLASH) .moveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH); // Play through endless, waves 1 to 9, counting number of double battles from waves 2 to 9 - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); game.scene.gameMode = getGameMode(GameModes.ENDLESS); for (let i = 0; i < DOUBLE_CHANCE; i++) { diff --git a/test/battle/inverse_battle.test.ts b/test/battle/inverse_battle.test.ts index 9d23a34a45e..83109c35740 100644 --- a/test/battle/inverse_battle.test.ts +++ b/test/battle/inverse_battle.test.ts @@ -10,7 +10,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Inverse Battle", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -40,10 +39,7 @@ describe("Inverse Battle", () => { }); it("Immune types are 2x effective - Thunderbolt against Ground Type", async () => { - game.override - .moveset([ Moves.THUNDERBOLT ]) - .enemySpecies(Species.SANDSHREW); - + game.override.moveset([Moves.THUNDERBOLT]).enemySpecies(Species.SANDSHREW); await game.challengeMode.startBattle(); @@ -51,16 +47,14 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.THUNDERBOLT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("2x effective types are 0.5x effective - Thunderbolt against Flying Type", async () => { - game.override - .moveset([ Moves.THUNDERBOLT ]) - .enemySpecies(Species.PIDGEY); + game.override.moveset([Moves.THUNDERBOLT]).enemySpecies(Species.PIDGEY); await game.challengeMode.startBattle(); @@ -68,16 +62,14 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.THUNDERBOLT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(0.5); }); it("0.5x effective types are 2x effective - Thunderbolt against Electric Type", async () => { - game.override - .moveset([ Moves.THUNDERBOLT ]) - .enemySpecies(Species.CHIKORITA); + game.override.moveset([Moves.THUNDERBOLT]).enemySpecies(Species.CHIKORITA); await game.challengeMode.startBattle(); @@ -85,7 +77,7 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.THUNDERBOLT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); @@ -93,9 +85,7 @@ describe("Inverse Battle", () => { it("Stealth Rock follows the inverse matchups - Stealth Rock against Charizard deals 1/32 of max HP", async () => { game.scene.arena.addTag(ArenaTagType.STEALTH_ROCK, 1, Moves.STEALTH_ROCK, 0); - game.override - .enemySpecies(Species.CHARIZARD) - .enemyLevel(100); + game.override.enemySpecies(Species.CHARIZARD).enemyLevel(100); await game.challengeMode.startBattle(); @@ -107,14 +97,17 @@ describe("Inverse Battle", () => { const currentHp = charizard.hp; const expectedHP = maxHp - damage_prediction; - console.log("Charizard's max HP: " + maxHp, "Damage: " + damage_prediction, "Current HP: " + currentHp, "Expected HP: " + expectedHP); - expect(currentHp).toBeGreaterThan(maxHp * 31 / 32 - 1); + console.log( + "Charizard's max HP: " + maxHp, + "Damage: " + damage_prediction, + "Current HP: " + currentHp, + "Expected HP: " + expectedHP, + ); + expect(currentHp).toBeGreaterThan((maxHp * 31) / 32 - 1); }); it("Freeze Dry is 2x effective against Water Type like other Ice type Move - Freeze Dry against Squirtle", async () => { - game.override - .moveset([ Moves.FREEZE_DRY ]) - .enemySpecies(Species.SQUIRTLE); + game.override.moveset([Moves.FREEZE_DRY]).enemySpecies(Species.SQUIRTLE); await game.challengeMode.startBattle(); @@ -122,39 +115,35 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("Water Absorb should heal against water moves - Water Absorb against Water gun", async () => { - game.override - .moveset([ Moves.WATER_GUN ]) - .enemyAbility(Abilities.WATER_ABSORB); + game.override.moveset([Moves.WATER_GUN]).enemyAbility(Abilities.WATER_ABSORB); await game.challengeMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; enemy.hp = enemy.getMaxHp() - 1; game.move.select(Moves.WATER_GUN); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.hp).toBe(enemy.getMaxHp()); }); it("Fire type does not get burned - Will-O-Wisp against Charmander", async () => { - game.override - .moveset([ Moves.WILL_O_WISP ]) - .enemySpecies(Species.CHARMANDER); + game.override.moveset([Moves.WILL_O_WISP]).enemySpecies(Species.CHARMANDER); await game.challengeMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.WILL_O_WISP); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("MoveEndPhase"); @@ -162,45 +151,36 @@ describe("Inverse Battle", () => { }); it("Electric type does not get paralyzed - Nuzzle against Pikachu", async () => { - game.override - .moveset([ Moves.NUZZLE ]) - .enemySpecies(Species.PIKACHU) - .enemyLevel(50); + game.override.moveset([Moves.NUZZLE]).enemySpecies(Species.PIKACHU).enemyLevel(50); await game.challengeMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.NUZZLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.status?.effect).not.toBe(StatusEffect.PARALYSIS); }); it("Ground type is not immune to Thunder Wave - Thunder Wave against Sandshrew", async () => { - game.override - .moveset([ Moves.THUNDER_WAVE ]) - .enemySpecies(Species.SANDSHREW); + game.override.moveset([Moves.THUNDER_WAVE]).enemySpecies(Species.SANDSHREW); await game.challengeMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.THUNDER_WAVE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.status?.effect).toBe(StatusEffect.PARALYSIS); }); - it("Anticipation should trigger on 2x effective moves - Anticipation against Thunderbolt", async () => { - game.override - .moveset([ Moves.THUNDERBOLT ]) - .enemySpecies(Species.SANDSHREW) - .enemyAbility(Abilities.ANTICIPATION); + game.override.moveset([Moves.THUNDERBOLT]).enemySpecies(Species.SANDSHREW).enemyAbility(Abilities.ANTICIPATION); await game.challengeMode.startBattle(); @@ -209,15 +189,15 @@ describe("Inverse Battle", () => { it("Conversion 2 should change the type to the resistive type - Conversion 2 against Dragonite", async () => { game.override - .moveset([ Moves.CONVERSION_2 ]) - .enemyMoveset([ Moves.DRAGON_CLAW, Moves.DRAGON_CLAW, Moves.DRAGON_CLAW, Moves.DRAGON_CLAW ]); + .moveset([Moves.CONVERSION_2]) + .enemyMoveset([Moves.DRAGON_CLAW, Moves.DRAGON_CLAW, Moves.DRAGON_CLAW, Moves.DRAGON_CLAW]); await game.challengeMode.startBattle(); const player = game.scene.getPlayerPokemon()!; game.move.select(Moves.CONVERSION_2); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); @@ -225,9 +205,7 @@ describe("Inverse Battle", () => { }); it("Flying Press should be 0.25x effective against Grass + Dark Type - Flying Press against Meowscarada", async () => { - game.override - .moveset([ Moves.FLYING_PRESS ]) - .enemySpecies(Species.MEOWSCARADA); + game.override.moveset([Moves.FLYING_PRESS]).enemySpecies(Species.MEOWSCARADA); await game.challengeMode.startBattle(); @@ -235,17 +213,14 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FLYING_PRESS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(0.25); }); it("Scrappy ability has no effect - Tackle against Ghost Type still 2x effective with Scrappy", async () => { - game.override - .moveset([ Moves.TACKLE ]) - .ability(Abilities.SCRAPPY) - .enemySpecies(Species.GASTLY); + game.override.moveset([Moves.TACKLE]).ability(Abilities.SCRAPPY).enemySpecies(Species.GASTLY); await game.challengeMode.startBattle(); @@ -253,16 +228,14 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("FORESIGHT has no effect - Tackle against Ghost Type still 2x effective with Foresight", async () => { - game.override - .moveset([ Moves.FORESIGHT, Moves.TACKLE ]) - .enemySpecies(Species.GASTLY); + game.override.moveset([Moves.FORESIGHT, Moves.TACKLE]).enemySpecies(Species.GASTLY); await game.challengeMode.startBattle(); @@ -270,11 +243,11 @@ describe("Inverse Battle", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FORESIGHT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); diff --git a/test/battle/special_battle.test.ts b/test/battle/special_battle.test.ts index df24626766c..cf7f3733484 100644 --- a/test/battle/special_battle.test.ts +++ b/test/battle/special_battle.test.ts @@ -25,119 +25,72 @@ describe("Test Battle Phase", () => { game = new GameManager(phaserGame); game.override.enemySpecies(Species.RATTATA); game.override.startingLevel(2000); - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.HYDRATION); game.override.ability(Abilities.HYDRATION); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); - it("startBattle 2vs1 boss", async() => { - game.override - .battleType("single") - .startingWave(10); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs1 boss", async () => { + game.override.battleType("single").startingWave(10); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs2 boss", async() => { - game.override - .battleType("double") - .startingWave(10); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs2 boss", async () => { + game.override.battleType("double").startingWave(10); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs2 trainer", async() => { - game.override - .battleType("double") - .startingWave(5); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs2 trainer", async () => { + game.override.battleType("double").startingWave(5); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs1 trainer", async() => { - game.override - .battleType("single") - .startingWave(5); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs1 trainer", async () => { + game.override.battleType("single").startingWave(5); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs1 rival", async() => { - game.override - .battleType("single") - .startingWave(8); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs1 rival", async () => { + game.override.battleType("single").startingWave(8); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs2 rival", async() => { - game.override - .battleType("double") - .startingWave(8); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs2 rival", async () => { + game.override.battleType("double").startingWave(8); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 1vs1 trainer", async() => { - game.override - .battleType("single") - .startingWave(5); - await game.startBattle([ - Species.BLASTOISE, - ]); + it("startBattle 1vs1 trainer", async () => { + game.override.battleType("single").startingWave(5); + await game.startBattle([Species.BLASTOISE]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 2vs2 trainer", async() => { - game.override - .battleType("double") - .startingWave(5); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - ]); + it("startBattle 2vs2 trainer", async () => { + game.override.battleType("double").startingWave(5); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); - it("startBattle 4vs2 trainer", async() => { - game.override - .battleType("double") - .startingWave(5); - await game.startBattle([ - Species.BLASTOISE, - Species.CHARIZARD, - Species.DARKRAI, - Species.GABITE, - ]); + it("startBattle 4vs2 trainer", async () => { + game.override.battleType("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.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); }, 20000); }); - diff --git a/test/battlerTags/octolock.test.ts b/test/battlerTags/octolock.test.ts index f161d90d466..6189bd7febe 100644 --- a/test/battlerTags/octolock.test.ts +++ b/test/battlerTags/octolock.test.ts @@ -31,7 +31,7 @@ describe("BattlerTag - OctolockTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementation(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(-1); - expect((phase as StatStageChangePhase)["stats"]).toEqual([ Stat.DEF, Stat.SPDEF ]); + expect((phase as StatStageChangePhase)["stats"]).toEqual([Stat.DEF, Stat.SPDEF]); }); subject.lapse(mockPokemon, BattlerTagLapseType.TURN_END); @@ -40,7 +40,7 @@ describe("BattlerTag - OctolockTag", () => { }); }); - it ("traps its target (extends TrappedTag)", async () => { + it("traps its target (extends TrappedTag)", async () => { expect(new OctolockTag(1)).toBeInstanceOf(TrappedTag); }); }); diff --git a/test/battlerTags/stockpiling.test.ts b/test/battlerTags/stockpiling.test.ts index 5970b5abbc6..20fade13d92 100644 --- a/test/battlerTags/stockpiling.test.ts +++ b/test/battlerTags/stockpiling.test.ts @@ -39,9 +39,9 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementation(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); - (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [ Stat.DEF, Stat.SPDEF ], [ 1, 1 ]); + (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [Stat.DEF, Stat.SPDEF], [1, 1]); }); subject.onAdd(mockPokemon); @@ -65,9 +65,9 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementation(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); - (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [ Stat.DEF, Stat.SPDEF ], [ 1, 1 ]); + (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [Stat.DEF, Stat.SPDEF], [1, 1]); }); subject.onAdd(mockPokemon); @@ -89,9 +89,9 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementation(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); - (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [ Stat.DEF, Stat.SPDEF ], [ 1, 1 ]); + (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [Stat.DEF, Stat.SPDEF], [1, 1]); }); subject.onOverlap(mockPokemon); @@ -117,10 +117,10 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementationOnce(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); // def doesn't change - (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [ Stat.SPDEF ], [ 1 ]); + (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [Stat.SPDEF], [1]); }); subject.onAdd(mockPokemon); @@ -129,10 +129,10 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementationOnce(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); // def doesn't change - (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [ Stat.SPDEF ], [ 1 ]); + (phase as StatStageChangePhase)["onChange"]!(mockPokemon, [Stat.SPDEF], [1]); }); subject.onOverlap(mockPokemon); @@ -141,7 +141,7 @@ describe("BattlerTag - StockpilingTag", () => { vi.spyOn(game.scene, "unshiftPhase").mockImplementationOnce(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(1); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.DEF, Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.DEF, Stat.SPDEF])); // neither stat changes, stack count should still increase }); @@ -156,13 +156,16 @@ describe("BattlerTag - StockpilingTag", () => { // fourth stack should not be applied subject.onOverlap(mockPokemon); expect(subject.stockpiledCount).toBe(3); - expect(subject.statChangeCounts).toMatchObject({ [Stat.DEF]: 0, [Stat.SPDEF]: 2 }); + expect(subject.statChangeCounts).toMatchObject({ + [Stat.DEF]: 0, + [Stat.SPDEF]: 2, + }); // removing tag should reverse stat changes vi.spyOn(game.scene, "unshiftPhase").mockImplementationOnce(phase => { expect(phase).toBeInstanceOf(StatStageChangePhase); expect((phase as StatStageChangePhase)["stages"]).toEqual(-2); - expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([ Stat.SPDEF ])); + expect((phase as StatStageChangePhase)["stats"]).toEqual(expect.arrayContaining([Stat.SPDEF])); }); subject.onRemove(mockPokemon); diff --git a/test/battlerTags/substitute.test.ts b/test/battlerTags/substitute.test.ts index 7e27cf9a826..e80453d2933 100644 --- a/test/battlerTags/substitute.test.ts +++ b/test/battlerTags/substitute.test.ts @@ -20,65 +20,58 @@ describe("BattlerTag - SubstituteTag", () => { hp: 101, id: 0, getMaxHp: vi.fn().mockReturnValue(101) as Pokemon["getMaxHp"], - findAndRemoveTags: vi.fn().mockImplementation((tagFilter) => { + findAndRemoveTags: vi.fn().mockImplementation(tagFilter => { // simulate a Trapped tag set by another Pokemon, then expect the filter to catch it. const trapTag = new BindTag(5, 0); expect(tagFilter(trapTag)).toBeTruthy(); return true; - }) as Pokemon["findAndRemoveTags"] + }) as Pokemon["findAndRemoveTags"], } as unknown as Pokemon; vi.spyOn(messages, "getPokemonNameWithAffix").mockReturnValue(""); - vi.spyOn(mockPokemon.scene as BattleScene, "getPokemonById").mockImplementation(pokemonId => mockPokemon.id === pokemonId ? mockPokemon : null); + vi.spyOn(mockPokemon.scene as BattleScene, "getPokemonById").mockImplementation(pokemonId => + mockPokemon.id === pokemonId ? mockPokemon : null, + ); }); - it( - "sets the tag's HP to 1/4 of the source's max HP (rounded down)", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("sets the tag's HP to 1/4 of the source's max HP (rounded down)", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - subject.onAdd(mockPokemon); + subject.onAdd(mockPokemon); - expect(subject.hp).toBe(25); - } - ); + expect(subject.hp).toBe(25); + }); - it( - "triggers on-add effects that bring the source out of focus", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("triggers on-add effects that bring the source out of focus", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( - (pokemon, battleAnimType, fieldAssets?, delayed?) => { - expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_ADD); - return true; - } - ); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( + (_pokemon, battleAnimType, _fieldAssets?, _delayed?) => { + expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_ADD); + return true; + }, + ); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - subject.onAdd(mockPokemon); + subject.onAdd(mockPokemon); - expect(subject.sourceInFocus).toBeFalsy(); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); - expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); - } - ); + expect(subject.sourceInFocus).toBeFalsy(); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); + expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); + }); - it( - "removes effects that trap the source", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("removes effects that trap the source", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - subject.onAdd(mockPokemon); - expect(mockPokemon.findAndRemoveTags).toHaveBeenCalledTimes(1); - } - ); + subject.onAdd(mockPokemon); + expect(mockPokemon.findAndRemoveTags).toHaveBeenCalledTimes(1); + }); }); describe("onRemove behavior", () => { @@ -87,33 +80,30 @@ describe("BattlerTag - SubstituteTag", () => { scene: new BattleScene(), hp: 101, id: 0, - isFainted: vi.fn().mockReturnValue(false) as Pokemon["isFainted"] + isFainted: vi.fn().mockReturnValue(false) as Pokemon["isFainted"], } as unknown as Pokemon; vi.spyOn(messages, "getPokemonNameWithAffix").mockReturnValue(""); }); - it( - "triggers on-remove animation and message", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - subject.sourceInFocus = false; + it("triggers on-remove animation and message", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + subject.sourceInFocus = false; - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( - (pokemon, battleAnimType, fieldAssets?, delayed?) => { - expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_REMOVE); - return true; - } - ); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( + (_pokemon, battleAnimType, _fieldAssets?, _delayed?) => { + expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_REMOVE); + return true; + }, + ); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - subject.onRemove(mockPokemon); + subject.onRemove(mockPokemon); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); - expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); - } - ); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); + expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); + }); }); describe("lapse behavior", () => { @@ -123,109 +113,98 @@ describe("BattlerTag - SubstituteTag", () => { hp: 101, id: 0, turnData: { acted: true } as PokemonTurnData, - getLastXMoves: vi.fn().mockReturnValue([ { move: Moves.TACKLE, result: MoveResult.SUCCESS } as TurnMove ]) as Pokemon["getLastXMoves"], + getLastXMoves: vi + .fn() + .mockReturnValue([ + { move: Moves.TACKLE, result: MoveResult.SUCCESS } as TurnMove, + ]) as Pokemon["getLastXMoves"], } as unknown as Pokemon; vi.spyOn(messages, "getPokemonNameWithAffix").mockReturnValue(""); }); - it( - "PRE_MOVE lapse triggers pre-move animation", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("PRE_MOVE lapse triggers pre-move animation", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( - (pokemon, battleAnimType, fieldAssets?, delayed?) => { - expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_PRE_MOVE); - return true; - } - ); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( + (_pokemon, battleAnimType, _fieldAssets?, _delayed?) => { + expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_PRE_MOVE); + return true; + }, + ); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - expect(subject.lapse(mockPokemon, BattlerTagLapseType.PRE_MOVE)).toBeTruthy(); + expect(subject.lapse(mockPokemon, BattlerTagLapseType.PRE_MOVE)).toBeTruthy(); - expect(subject.sourceInFocus).toBeTruthy(); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); - expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); - } - ); + expect(subject.sourceInFocus).toBeTruthy(); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); + expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); + }); - it( - "AFTER_MOVE lapse triggers post-move animation", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("AFTER_MOVE lapse triggers post-move animation", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( - (pokemon, battleAnimType, fieldAssets?, delayed?) => { - expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_POST_MOVE); - return true; - } - ); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockImplementation( + (_pokemon, battleAnimType, _fieldAssets?, _delayed?) => { + expect(battleAnimType).toBe(PokemonAnimType.SUBSTITUTE_POST_MOVE); + return true; + }, + ); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - expect(subject.lapse(mockPokemon, BattlerTagLapseType.AFTER_MOVE)).toBeTruthy(); + expect(subject.lapse(mockPokemon, BattlerTagLapseType.AFTER_MOVE)).toBeTruthy(); - expect(subject.sourceInFocus).toBeFalsy(); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); - expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); - } - ); + expect(subject.sourceInFocus).toBeFalsy(); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).toHaveBeenCalledTimes(1); + expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); + }); // TODO: Figure out how to mock a MoveEffectPhase correctly for this test - it.todo( - "HIT lapse triggers on-hit message", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it.todo("HIT lapse triggers on-hit message", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - const pokemonMove = { - getMove: vi.fn().mockReturnValue(allMoves[Moves.TACKLE]) as PokemonMove["getMove"] - } as PokemonMove; + const pokemonMove = { + getMove: vi.fn().mockReturnValue(allMoves[Moves.TACKLE]) as PokemonMove["getMove"], + } as PokemonMove; - const moveEffectPhase = { - move: pokemonMove, - getUserPokemon: vi.fn().mockReturnValue(undefined) as MoveEffectPhase["getUserPokemon"] - } as MoveEffectPhase; + const moveEffectPhase = { + move: pokemonMove, + getUserPokemon: vi.fn().mockReturnValue(undefined) as MoveEffectPhase["getUserPokemon"], + } as MoveEffectPhase; - vi.spyOn(mockPokemon.scene as BattleScene, "getCurrentPhase").mockReturnValue(moveEffectPhase); - vi.spyOn(allMoves[Moves.TACKLE], "hitsSubstitute").mockReturnValue(true); + vi.spyOn(mockPokemon.scene as BattleScene, "getCurrentPhase").mockReturnValue(moveEffectPhase); + vi.spyOn(allMoves[Moves.TACKLE], "hitsSubstitute").mockReturnValue(true); - expect(subject.lapse(mockPokemon, BattlerTagLapseType.HIT)).toBeTruthy(); + expect(subject.lapse(mockPokemon, BattlerTagLapseType.HIT)).toBeTruthy(); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).not.toHaveBeenCalled(); - expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); - } - ); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).not.toHaveBeenCalled(); + expect((mockPokemon.scene as BattleScene).queueMessage).toHaveBeenCalledTimes(1); + }); - it( - "CUSTOM lapse flags the tag for removal", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("CUSTOM lapse flags the tag for removal", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - expect(subject.lapse(mockPokemon, BattlerTagLapseType.CUSTOM)).toBeFalsy(); - } - ); + expect(subject.lapse(mockPokemon, BattlerTagLapseType.CUSTOM)).toBeFalsy(); + }); - it( - "Unsupported lapse type does nothing", - async () => { - const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); + it("Unsupported lapse type does nothing", async () => { + const subject = new SubstituteTag(Moves.SUBSTITUTE, mockPokemon.id); - vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); - vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); + vi.spyOn(mockPokemon.scene as BattleScene, "triggerPokemonBattleAnim").mockReturnValue(true); + vi.spyOn(mockPokemon.scene as BattleScene, "queueMessage").mockReturnValue(); - expect(subject.lapse(mockPokemon, BattlerTagLapseType.TURN_END)).toBeTruthy(); + expect(subject.lapse(mockPokemon, BattlerTagLapseType.TURN_END)).toBeTruthy(); - expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).not.toHaveBeenCalled(); - expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); - } - ); + expect((mockPokemon.scene as BattleScene).triggerPokemonBattleAnim).not.toHaveBeenCalled(); + expect((mockPokemon.scene as BattleScene).queueMessage).not.toHaveBeenCalled(); + }); }); }); diff --git a/test/boss-pokemon.test.ts b/test/boss-pokemon.test.ts index ea5a9000000..6b150de2d2b 100644 --- a/test/boss-pokemon.test.ts +++ b/test/boss-pokemon.test.ts @@ -33,7 +33,7 @@ describe("Boss Pokemon / Shields", () => { .enemyMoveset(Moves.SPLASH) .enemyHeldItems([]) .startingLevel(1000) - .moveset([ Moves.FALSE_SWIPE, Moves.SUPER_FANG, Moves.SPLASH, Moves.PSYCHIC ]) + .moveset([Moves.FALSE_SWIPE, Moves.SUPER_FANG, Moves.SPLASH, Moves.PSYCHIC]) .ability(Abilities.NO_GUARD); }); @@ -63,11 +63,9 @@ describe("Boss Pokemon / Shields", () => { }); it("should reduce the number of shields if we are in a double battle", async () => { - game.override - .battleType("double") - .startingWave(150); // Floor 150 > 2 shields / 3 health segments + game.override.battleType("double").startingWave(150); // Floor 150 > 2 shields / 3 health segments - await game.classicMode.startBattle([ Species.MEWTWO ]); + await game.classicMode.startBattle([Species.MEWTWO]); const boss1: EnemyPokemon = game.scene.getEnemyParty()[0]!; const boss2: EnemyPokemon = game.scene.getEnemyParty()[1]!; @@ -80,7 +78,7 @@ describe("Boss Pokemon / Shields", () => { it("shields should stop overflow damage and give stat stage boosts when broken", async () => { game.override.startingWave(150); // Floor 150 > 2 shields / 3 health segments - await game.classicMode.startBattle([ Species.MEWTWO ]); + await game.classicMode.startBattle([Species.MEWTWO]); const enemyPokemon = game.scene.getEnemyPokemon()!; const segmentHp = enemyPokemon.getMaxHp() / enemyPokemon.bossSegments; @@ -104,15 +102,12 @@ describe("Boss Pokemon / Shields", () => { expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp() - toDmgValue(2 * segmentHp)); // Breaking the last shield gives a +2 boost to ATK, DEF, SP ATK, SP DEF or SPD expect(getTotalStatStageBoosts(enemyPokemon)).toBe(3); - }); it("breaking multiple shields at once requires extra damage", async () => { - game.override - .battleType("double") - .enemyHealthSegments(5); + game.override.battleType("double").enemyHealthSegments(5); - await game.classicMode.startBattle([ Species.MEWTWO ]); + await game.classicMode.startBattle([Species.MEWTWO]); // In this test we want to break through 3 shields at once const brokenShields = 3; @@ -140,17 +135,14 @@ describe("Boss Pokemon / Shields", () => { boss2.damageAndUpdate(Math.ceil(requiredDamageBoss2)); expect(boss2.bossSegmentIndex).toBe(0); expect(boss2.hp).toBe(boss2.getMaxHp() - toDmgValue(boss2SegmentHp * 4)); - }); it("the number of stat stage boosts is consistent when several shields are broken at once", async () => { const shieldsToBreak = 4; - game.override - .battleType("double") - .enemyHealthSegments(shieldsToBreak + 1); + game.override.battleType("double").enemyHealthSegments(shieldsToBreak + 1); - await game.classicMode.startBattle([ Species.MEWTWO ]); + await game.classicMode.startBattle([Species.MEWTWO]); const boss1: EnemyPokemon = game.scene.getEnemyParty()[0]!; const boss1SegmentHp = boss1.getMaxHp() / boss1.bossSegments; @@ -160,7 +152,6 @@ describe("Boss Pokemon / Shields", () => { expect(boss1.bossSegmentIndex).toBe(shieldsToBreak); expect(getTotalStatStageBoosts(boss1)).toBe(0); - let totalStatStages = 0; // Break the shields one by one @@ -193,15 +184,12 @@ describe("Boss Pokemon / Shields", () => { game.move.select(Moves.SPLASH); await game.toNextTurn(); expect(getTotalStatStageBoosts(boss2)).toBe(totalStatStages); - }); it("the boss enduring does not proc an extra stat boost", async () => { - game.override - .enemyHealthSegments(2) - .enemyAbility(Abilities.STURDY); + game.override.enemyHealthSegments(2).enemyAbility(Abilities.STURDY); - await game.classicMode.startBattle([ Species.MEWTWO ]); + await game.classicMode.startBattle([Species.MEWTWO]); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon.isBoss()).toBe(true); @@ -215,7 +203,6 @@ describe("Boss Pokemon / Shields", () => { expect(enemyPokemon.bossSegmentIndex).toBe(0); expect(enemyPokemon.hp).toBe(1); expect(getTotalStatStageBoosts(enemyPokemon)).toBe(1); - }); /** @@ -231,4 +218,3 @@ describe("Boss Pokemon / Shields", () => { return boosts; } }); - diff --git a/test/daily_mode.test.ts b/test/daily_mode.test.ts index 95c01b51434..c530fca61a6 100644 --- a/test/daily_mode.test.ts +++ b/test/daily_mode.test.ts @@ -34,7 +34,7 @@ describe("Daily Mode", () => { const party = game.scene.getPlayerParty(); expect(party).toHaveLength(3); - party.forEach((pkm) => { + party.forEach(pkm => { expect(pkm.level).toBe(20); expect(pkm.moveset.length).toBeGreaterThan(0); }); @@ -60,11 +60,9 @@ describe("Shop modifications", async () => { .battleType("single") .startingLevel(100) // Avoid levelling up .disableTrainerWaves() - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .enemyMoveset(Moves.SPLASH); - game.modifiers - .addCheck("EVIOLITE") - .addCheck("MINI_BLACK_HOLE"); + game.modifiers.addCheck("EVIOLITE").addCheck("MINI_BLACK_HOLE"); vi.spyOn(pokerogueApi.daily, "getSeed").mockResolvedValue("test-seed"); }); @@ -74,15 +72,13 @@ describe("Shop modifications", async () => { }); it("should not have Eviolite and Mini Black Hole available in Classic if not unlocked", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to("BattleEndPhase"); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); - game.modifiers - .testCheck("EVIOLITE", false) - .testCheck("MINI_BLACK_HOLE", false); + game.modifiers.testCheck("EVIOLITE", false).testCheck("MINI_BLACK_HOLE", false); }); }); @@ -93,9 +89,7 @@ describe("Shop modifications", async () => { await game.phaseInterceptor.to("BattleEndPhase"); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); - game.modifiers - .testCheck("EVIOLITE", true) - .testCheck("MINI_BLACK_HOLE", true); + game.modifiers.testCheck("EVIOLITE", true).testCheck("MINI_BLACK_HOLE", true); }); }); }); diff --git a/test/data/splash_messages.test.ts b/test/data/splash_messages.test.ts index b9ed5b9d365..8ae13366670 100644 --- a/test/data/splash_messages.test.ts +++ b/test/data/splash_messages.test.ts @@ -9,7 +9,7 @@ describe("Data - Splash Messages", () => { // make sure to adjust this test if the weight it changed! it("should add contain 10 `battlesWon` splash messages", () => { - const battlesWonMessages = getSplashMessages().filter((message) => message === "splashMessages:battlesWon"); + const battlesWonMessages = getSplashMessages().filter(message => message === "splashMessages:battlesWon"); expect(battlesWonMessages).toHaveLength(10); }); @@ -51,8 +51,8 @@ function testSeason(startDate: Date, endDate: Date, prefix: string) { const afterDate = new Date(endDate); afterDate.setDate(endDate.getDate() + 1); - const dates: Date[] = [ beforeDate, startDate, endDate, afterDate ]; - const [ before, start, end, after ] = dates.map((date) => { + const dates: Date[] = [beforeDate, startDate, endDate, afterDate]; + const [before, start, end, after] = dates.map(date => { vi.setSystemTime(date); console.log("System time set to", date); const count = getSplashMessages().filter(filterFn).length; diff --git a/test/data/status_effect.test.ts b/test/data/status_effect.test.ts index e94cb193f0a..61dafc1c9b8 100644 --- a/test/data/status_effect.test.ts +++ b/test/data/status_effect.test.ts @@ -328,13 +328,13 @@ describe("Status Effects", () => { .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.QUICK_ATTACK ]) + .moveset([Moves.QUICK_ATTACK]) .ability(Abilities.BALL_FETCH) .statusEffect(StatusEffect.PARALYSIS); }); it("causes the pokemon's move to fail when activated", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.QUICK_ATTACK); await game.move.forceStatusActivation(true); @@ -362,7 +362,7 @@ describe("Status Effects", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -372,7 +372,7 @@ describe("Status Effects", () => { }); it("should last the appropriate number of turns", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; player.status = new Status(StatusEffect.SLEEP, 0, 4); @@ -418,7 +418,7 @@ describe("Status Effects", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -429,7 +429,7 @@ describe("Status Effects", () => { }); it("should not inflict a 0 HP mon with a status", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); const player = game.scene.getPlayerPokemon()!; player.hp = 0; diff --git a/test/eggs/egg.test.ts b/test/eggs/egg.test.ts index e4a7cc31709..8875300780b 100644 --- a/test/eggs/egg.test.ts +++ b/test/eggs/egg.test.ts @@ -55,7 +55,12 @@ describe("Egg Generation Tests", () => { let gachaSpeciesCount = 0; for (let i = 0; i < EGG_HATCH_COUNT; i++) { - const result = new Egg({ scene, timestamp, sourceType: EggSourceType.GACHA_LEGENDARY, tier: EggTier.LEGENDARY }).generatePlayerPokemon().species.speciesId; + const result = new Egg({ + scene, + timestamp, + sourceType: EggSourceType.GACHA_LEGENDARY, + tier: EggTier.LEGENDARY, + }).generatePlayerPokemon().species.speciesId; if (result === expectedSpecies) { gachaSpeciesCount++; } @@ -74,7 +79,10 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedSpecies = Species.ARCEUS; - const result = new Egg({ scene, species: expectedSpecies }).generatePlayerPokemon().species.speciesId; + const result = new Egg({ + scene, + species: expectedSpecies, + }).generatePlayerPokemon().species.speciesId; expect(result).toBe(expectedSpecies); }); @@ -122,7 +130,11 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedResult = true; - const result = new Egg({ scene, tier: EggTier.COMMON, id: 204 }).isManaphyEgg(); + const result = new Egg({ + scene, + tier: EggTier.COMMON, + id: 204, + }).isManaphyEgg(); expect(result).toBe(expectedResult); }); @@ -138,7 +150,13 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedResult = true; - const result = new Egg({ scene, isShiny: expectedResult, species: Species.BULBASAUR }).generatePlayerPokemon().isShiny(); + const result = new Egg({ + scene, + isShiny: expectedResult, + species: Species.BULBASAUR, + }) + .generatePlayerPokemon() + .isShiny(); expect(result).toBe(expectedResult); }); @@ -146,7 +164,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedVariantTier = VariantTier.STANDARD; - const result = new Egg({ scene, isShiny: true, variantTier: expectedVariantTier, species: Species.BULBASAUR }).generatePlayerPokemon().variant; + const result = new Egg({ + scene, + isShiny: true, + variantTier: expectedVariantTier, + species: Species.BULBASAUR, + }).generatePlayerPokemon().variant; expect(result).toBe(expectedVariantTier); }); @@ -154,7 +177,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedVariantTier = VariantTier.RARE; - const result = new Egg({ scene, isShiny: true, variantTier: expectedVariantTier, species: Species.BULBASAUR }).generatePlayerPokemon().variant; + const result = new Egg({ + scene, + isShiny: true, + variantTier: expectedVariantTier, + species: Species.BULBASAUR, + }).generatePlayerPokemon().variant; expect(result).toBe(expectedVariantTier); }); @@ -162,7 +190,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedVariantTier = VariantTier.EPIC; - const result = new Egg({ scene, isShiny: true, variantTier: expectedVariantTier, species: Species.BULBASAUR }).generatePlayerPokemon().variant; + const result = new Egg({ + scene, + isShiny: true, + variantTier: expectedVariantTier, + species: Species.BULBASAUR, + }).generatePlayerPokemon().variant; expect(result).toBe(expectedVariantTier); }); @@ -185,7 +218,11 @@ describe("Egg Generation Tests", () => { it("should return a hatched pokemon with a hidden ability", () => { const scene = game.scene; - const playerPokemon = new Egg({ scene, overrideHiddenAbility: true, species: Species.BULBASAUR }).generatePlayerPokemon(); + const playerPokemon = new Egg({ + scene, + overrideHiddenAbility: true, + species: Species.BULBASAUR, + }).generatePlayerPokemon(); const expectedAbilityIndex = playerPokemon.species.ability2 ? 2 : 1; const result = playerPokemon.abilityIndex; @@ -206,7 +243,11 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedEggTier = EggTier.COMMON; - const result = new Egg({ scene, tier: EggTier.LEGENDARY, species: Species.BULBASAUR }).tier; + const result = new Egg({ + scene, + tier: EggTier.LEGENDARY, + species: Species.BULBASAUR, + }).tier; expect(result).toBe(expectedEggTier); }); @@ -214,7 +255,11 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const expectedHatchWaves = 10; - const result = new Egg({ scene, tier: EggTier.LEGENDARY, species: Species.BULBASAUR }).hatchWaves; + const result = new Egg({ + scene, + tier: EggTier.LEGENDARY, + species: Species.BULBASAUR, + }).hatchWaves; expect(result).toBe(expectedHatchWaves); }); @@ -243,9 +288,14 @@ describe("Egg Generation Tests", () => { }); it("should increase egg pity", () => { const scene = game.scene; - const startPityValues = [ ...scene.gameData.eggPity ]; + const startPityValues = [...scene.gameData.eggPity]; - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, tier: EggTier.COMMON }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + tier: EggTier.COMMON, + }); expect(scene.gameData.eggPity[EggTier.RARE]).toBe(startPityValues[EggTier.RARE] + 1); expect(scene.gameData.eggPity[EggTier.EPIC]).toBe(startPityValues[EggTier.EPIC] + 1); @@ -253,9 +303,14 @@ describe("Egg Generation Tests", () => { }); it("should increase legendary egg pity by two", () => { const scene = game.scene; - const startPityValues = [ ...scene.gameData.eggPity ]; + const startPityValues = [...scene.gameData.eggPity]; - new Egg({ scene, sourceType: EggSourceType.GACHA_LEGENDARY, pulled: true, tier: EggTier.COMMON }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_LEGENDARY, + pulled: true, + tier: EggTier.COMMON, + }); expect(scene.gameData.eggPity[EggTier.RARE]).toBe(startPityValues[EggTier.RARE] + 1); expect(scene.gameData.eggPity[EggTier.EPIC]).toBe(startPityValues[EggTier.EPIC] + 1); @@ -266,7 +321,12 @@ describe("Egg Generation Tests", () => { const startingManaphyEggCount = scene.gameData.gameStats.manaphyEggsPulled; for (let i = 0; i < 200; i++) { - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, species: Species.BULBASAUR }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + species: Species.BULBASAUR, + }); } expect(scene.gameData.gameStats.manaphyEggsPulled).toBe(startingManaphyEggCount); @@ -275,7 +335,13 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const startingManaphyEggCount = scene.gameData.gameStats.manaphyEggsPulled; - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, id: 204, tier: EggTier.COMMON }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + id: 204, + tier: EggTier.COMMON, + }); expect(scene.gameData.gameStats.manaphyEggsPulled).toBe(startingManaphyEggCount + 1); }); @@ -283,7 +349,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const startingRareEggsPulled = scene.gameData.gameStats.rareEggsPulled; - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, tier: EggTier.RARE }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + tier: EggTier.RARE, + }); expect(scene.gameData.gameStats.rareEggsPulled).toBe(startingRareEggsPulled + 1); }); @@ -291,7 +362,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const startingEpicEggsPulled = scene.gameData.gameStats.epicEggsPulled; - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, tier: EggTier.EPIC }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + tier: EggTier.EPIC, + }); expect(scene.gameData.gameStats.epicEggsPulled).toBe(startingEpicEggsPulled + 1); }); @@ -299,7 +375,12 @@ describe("Egg Generation Tests", () => { const scene = game.scene; const startingLegendaryEggsPulled = scene.gameData.gameStats.legendaryEggsPulled; - new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true, tier: EggTier.LEGENDARY }); + new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + tier: EggTier.LEGENDARY, + }); expect(scene.gameData.gameStats.legendaryEggsPulled).toBe(startingLegendaryEggsPulled + 1); }); @@ -310,8 +391,16 @@ describe("Egg Generation Tests", () => { const expectedTier1 = EggTier.LEGENDARY; const expectedTier2 = EggTier.EPIC; - const result1 = new Egg({ scene, sourceType: EggSourceType.GACHA_LEGENDARY, pulled: true }).tier; - const result2 = new Egg({ scene, sourceType: EggSourceType.GACHA_MOVE, pulled: true }).tier; + const result1 = new Egg({ + scene, + sourceType: EggSourceType.GACHA_LEGENDARY, + pulled: true, + }).tier; + const result2 = new Egg({ + scene, + sourceType: EggSourceType.GACHA_MOVE, + pulled: true, + }).tier; expect(result1).toBe(expectedTier1); expect(result2).toBe(expectedTier2); @@ -319,7 +408,12 @@ describe("Egg Generation Tests", () => { it("should generate an epic shiny from pokemon with a different form", () => { const scene = game.scene; - const egg = new Egg({ scene, isShiny: true, variantTier: VariantTier.EPIC, species: Species.MIRAIDON }); + const egg = new Egg({ + scene, + isShiny: true, + variantTier: VariantTier.EPIC, + species: Species.MIRAIDON, + }); expect(egg.variantTier).toBe(VariantTier.EPIC); }); @@ -329,7 +423,11 @@ describe("Egg Generation Tests", () => { scene.setSeed("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); scene.resetSeed(); - const firstEgg = new Egg({ scene, sourceType: EggSourceType.GACHA_SHINY, tier: EggTier.COMMON }); + const firstEgg = new Egg({ + scene, + sourceType: EggSourceType.GACHA_SHINY, + tier: EggTier.COMMON, + }); const firstHatch = firstEgg.generatePlayerPokemon(); let diffEggMove = false; let diffSpecies = false; @@ -340,12 +438,16 @@ describe("Egg Generation Tests", () => { scene.setSeed("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); scene.resetSeed(); // Make sure that eggs are unpredictable even if using same seed - const newEgg = new Egg({ scene, sourceType: EggSourceType.GACHA_SHINY, tier: EggTier.COMMON }); + const newEgg = new Egg({ + scene, + sourceType: EggSourceType.GACHA_SHINY, + tier: EggTier.COMMON, + }); const newHatch = newEgg.generatePlayerPokemon(); - diffEggMove = diffEggMove || (newEgg.eggMoveIndex !== firstEgg.eggMoveIndex); - diffSpecies = diffSpecies || (newHatch.species.speciesId !== firstHatch.species.speciesId); - diffShiny = diffShiny || (newHatch.shiny !== firstHatch.shiny); - diffAbility = diffAbility || (newHatch.abilityIndex !== firstHatch.abilityIndex); + diffEggMove = diffEggMove || newEgg.eggMoveIndex !== firstEgg.eggMoveIndex; + diffSpecies = diffSpecies || newHatch.species.speciesId !== firstHatch.species.speciesId; + diffShiny = diffShiny || newHatch.shiny !== firstHatch.shiny; + diffAbility = diffAbility || newHatch.abilityIndex !== firstHatch.abilityIndex; } expect(diffEggMove).toBe(true); @@ -371,10 +473,10 @@ describe("Egg Generation Tests", () => { const newEgg = new Egg({ scene, species: Species.BULBASAUR }); const newHatch = newEgg.generatePlayerPokemon(); - diffEggMove = diffEggMove || (newEgg.eggMoveIndex !== firstEgg.eggMoveIndex); - diffSpecies = diffSpecies || (newHatch.species.speciesId !== firstHatch.species.speciesId); - diffShiny = diffShiny || (newHatch.shiny !== firstHatch.shiny); - diffAbility = diffAbility || (newHatch.abilityIndex !== firstHatch.abilityIndex); + diffEggMove = diffEggMove || newEgg.eggMoveIndex !== firstEgg.eggMoveIndex; + diffSpecies = diffSpecies || newHatch.species.speciesId !== firstHatch.species.speciesId; + diffShiny = diffShiny || newHatch.shiny !== firstHatch.shiny; + diffAbility = diffAbility || newHatch.abilityIndex !== firstHatch.abilityIndex; } expect(diffEggMove).toBe(true); diff --git a/test/eggs/manaphy-egg.test.ts b/test/eggs/manaphy-egg.test.ts index c63dbae7780..1e7f67a7bb5 100644 --- a/test/eggs/manaphy-egg.test.ts +++ b/test/eggs/manaphy-egg.test.ts @@ -10,7 +10,7 @@ describe("Manaphy Eggs", () => { let phaserGame: Phaser.Game; let game: GameManager; const EGG_HATCH_COUNT: number = 48; - let rngSweepProgress: number = 0; + let rngSweepProgress = 0; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -47,7 +47,12 @@ describe("Manaphy Eggs", () => { for (let i = 0; i < EGG_HATCH_COUNT; i++) { rngSweepProgress = (2 * i + 1) / (2 * EGG_HATCH_COUNT); - const newEgg = new Egg({ scene, tier: EggTier.COMMON, sourceType: EggSourceType.GACHA_SHINY, id: 204 }); + const newEgg = new Egg({ + scene, + tier: EggTier.COMMON, + sourceType: EggSourceType.GACHA_SHINY, + id: 204, + }); const newHatch = newEgg.generatePlayerPokemon(); if (newHatch.species.speciesId === Species.MANAPHY) { manaphyCount++; @@ -60,8 +65,8 @@ describe("Manaphy Eggs", () => { } expect(manaphyCount + phioneCount).toBe(EGG_HATCH_COUNT); - expect(manaphyCount).toBe(1 / 8 * EGG_HATCH_COUNT); - expect(rareEggMoveCount).toBe(1 / 12 * EGG_HATCH_COUNT); + expect(manaphyCount).toBe((1 / 8) * EGG_HATCH_COUNT); + expect(rareEggMoveCount).toBe((1 / 12) * EGG_HATCH_COUNT); }); it("should have correct Manaphy rates and Rare Egg Move rates, from Phione species eggs", () => { @@ -73,7 +78,11 @@ describe("Manaphy Eggs", () => { for (let i = 0; i < EGG_HATCH_COUNT; i++) { rngSweepProgress = (2 * i + 1) / (2 * EGG_HATCH_COUNT); - const newEgg = new Egg({ scene, species: Species.PHIONE, sourceType: EggSourceType.SAME_SPECIES_EGG }); + const newEgg = new Egg({ + scene, + species: Species.PHIONE, + sourceType: EggSourceType.SAME_SPECIES_EGG, + }); const newHatch = newEgg.generatePlayerPokemon(); if (newHatch.species.speciesId === Species.MANAPHY) { manaphyCount++; @@ -86,8 +95,8 @@ describe("Manaphy Eggs", () => { } expect(manaphyCount + phioneCount).toBe(EGG_HATCH_COUNT); - expect(manaphyCount).toBe(1 / 8 * EGG_HATCH_COUNT); - expect(rareEggMoveCount).toBe(1 / 6 * EGG_HATCH_COUNT); + expect(manaphyCount).toBe((1 / 8) * EGG_HATCH_COUNT); + expect(rareEggMoveCount).toBe((1 / 6) * EGG_HATCH_COUNT); }); it("should have correct Manaphy rates and Rare Egg Move rates, from Manaphy species eggs", () => { @@ -99,7 +108,11 @@ describe("Manaphy Eggs", () => { for (let i = 0; i < EGG_HATCH_COUNT; i++) { rngSweepProgress = (2 * i + 1) / (2 * EGG_HATCH_COUNT); - const newEgg = new Egg({ scene, species: Species.MANAPHY, sourceType: EggSourceType.SAME_SPECIES_EGG }); + const newEgg = new Egg({ + scene, + species: Species.MANAPHY, + sourceType: EggSourceType.SAME_SPECIES_EGG, + }); const newHatch = newEgg.generatePlayerPokemon(); if (newHatch.species.speciesId === Species.MANAPHY) { manaphyCount++; @@ -113,6 +126,6 @@ describe("Manaphy Eggs", () => { expect(phioneCount).toBe(0); expect(manaphyCount).toBe(EGG_HATCH_COUNT); - expect(rareEggMoveCount).toBe(1 / 6 * EGG_HATCH_COUNT); + expect(rareEggMoveCount).toBe((1 / 6) * EGG_HATCH_COUNT); }); }); diff --git a/test/endless_boss.test.ts b/test/endless_boss.test.ts index ab7df412c12..4be1e379215 100644 --- a/test/endless_boss.test.ts +++ b/test/endless_boss.test.ts @@ -6,7 +6,7 @@ import GameManager from "#test/testUtils/gameManager"; const EndlessBossWave = { Minor: 250, - Major: 1000 + Major: 1000, }; describe("Endless Boss", () => { @@ -21,9 +21,7 @@ describe("Endless Boss", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override - .startingBiome(Biome.END) - .disableCrits(); + game.override.startingBiome(Biome.END).disableCrits(); }); afterEach(() => { @@ -32,7 +30,7 @@ describe("Endless Boss", () => { it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Endless`, async () => { game.override.startingWave(EndlessBossWave.Minor); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.ENDLESS); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS); expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -44,7 +42,7 @@ describe("Endless Boss", () => { it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Endless`, async () => { game.override.startingWave(EndlessBossWave.Major); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.ENDLESS); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS); expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -56,7 +54,7 @@ describe("Endless Boss", () => { it(`should spawn a minor boss every ${EndlessBossWave.Minor} waves in END biome in Spliced Endless`, async () => { game.override.startingWave(EndlessBossWave.Minor); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.SPLICED_ENDLESS); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.SPLICED_ENDLESS); expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Minor); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -68,7 +66,7 @@ describe("Endless Boss", () => { it(`should spawn a major boss every ${EndlessBossWave.Major} waves in END biome in Spliced Endless`, async () => { game.override.startingWave(EndlessBossWave.Major); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.SPLICED_ENDLESS); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.SPLICED_ENDLESS); expect(game.scene.currentBattle.waveIndex).toBe(EndlessBossWave.Major); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -80,7 +78,7 @@ describe("Endless Boss", () => { it(`should NOT spawn major or minor boss outside wave ${EndlessBossWave.Minor}s in END biome`, async () => { game.override.startingWave(EndlessBossWave.Minor - 1); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.ENDLESS); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.ENDLESS); expect(game.scene.currentBattle.waveIndex).not.toBe(EndlessBossWave.Minor); expect(game.scene.getEnemyPokemon()!.species.speciesId).not.toBe(Species.ETERNATUS); diff --git a/test/enemy_command.test.ts b/test/enemy_command.test.ts index 2d6a65e3edd..6d5cc2698a3 100644 --- a/test/enemy_command.test.ts +++ b/test/enemy_command.test.ts @@ -26,8 +26,8 @@ function getEnemyMoveChoices(pokemon: EnemyPokemon, moveChoices: MoveChoiceSet): moveChoices[queuedMove.move]++; } - for (const [ moveId, count ] of Object.entries(moveChoices)) { - console.log(`Move: ${allMoves[moveId].name} Count: ${count} (${count / NUM_TRIALS * 100}%)`); + for (const [moveId, count] of Object.entries(moveChoices)) { + console.log(`Move: ${allMoves[moveId].name} Count: ${count} (${(count / NUM_TRIALS) * 100}%)`); } } @@ -49,62 +49,54 @@ describe("Enemy Commands - Move Selection", () => { game = new GameManager(phaserGame); globalScene = game.scene; - game.override - .ability(Abilities.BALL_FETCH) - .enemyAbility(Abilities.BALL_FETCH); + game.override.ability(Abilities.BALL_FETCH).enemyAbility(Abilities.BALL_FETCH); }); - it( - "should never use Status moves if an attack can KO", - async () => { - game.override - .enemySpecies(Species.ETERNATUS) - .enemyMoveset([ Moves.ETERNABEAM, Moves.SLUDGE_BOMB, Moves.DRAGON_DANCE, Moves.COSMIC_POWER ]) - .startingLevel(1) - .enemyLevel(100); + it("should never use Status moves if an attack can KO", async () => { + game.override + .enemySpecies(Species.ETERNATUS) + .enemyMoveset([Moves.ETERNABEAM, Moves.SLUDGE_BOMB, Moves.DRAGON_DANCE, Moves.COSMIC_POWER]) + .startingLevel(1) + .enemyLevel(100); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.aiType = AiType.SMART_RANDOM; + const enemyPokemon = game.scene.getEnemyPokemon()!; + enemyPokemon.aiType = AiType.SMART_RANDOM; - const moveChoices: MoveChoiceSet = {}; - const enemyMoveset = enemyPokemon.getMoveset(); - enemyMoveset.forEach(mv => moveChoices[mv!.moveId] = 0); - getEnemyMoveChoices(enemyPokemon, moveChoices); + const moveChoices: MoveChoiceSet = {}; + const enemyMoveset = enemyPokemon.getMoveset(); + enemyMoveset.forEach(mv => (moveChoices[mv!.moveId] = 0)); + getEnemyMoveChoices(enemyPokemon, moveChoices); - enemyMoveset.forEach(mv => { - if (mv?.getMove().category === MoveCategory.STATUS) { - expect(moveChoices[mv.moveId]).toBe(0); - } - }); - } - ); + enemyMoveset.forEach(mv => { + if (mv?.getMove().category === MoveCategory.STATUS) { + expect(moveChoices[mv.moveId]).toBe(0); + } + }); + }); - it( - "should not select Last Resort if it would fail, even if the move KOs otherwise", - async () => { - game.override - .enemySpecies(Species.KANGASKHAN) - .enemyMoveset([ Moves.LAST_RESORT, Moves.GIGA_IMPACT, Moves.SPLASH, Moves.SWORDS_DANCE ]) - .startingLevel(1) - .enemyLevel(100); + it("should not select Last Resort if it would fail, even if the move KOs otherwise", async () => { + game.override + .enemySpecies(Species.KANGASKHAN) + .enemyMoveset([Moves.LAST_RESORT, Moves.GIGA_IMPACT, Moves.SPLASH, Moves.SWORDS_DANCE]) + .startingLevel(1) + .enemyLevel(100); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.aiType = AiType.SMART_RANDOM; + const enemyPokemon = game.scene.getEnemyPokemon()!; + enemyPokemon.aiType = AiType.SMART_RANDOM; - const moveChoices: MoveChoiceSet = {}; - const enemyMoveset = enemyPokemon.getMoveset(); - enemyMoveset.forEach(mv => moveChoices[mv!.moveId] = 0); - getEnemyMoveChoices(enemyPokemon, moveChoices); + const moveChoices: MoveChoiceSet = {}; + const enemyMoveset = enemyPokemon.getMoveset(); + enemyMoveset.forEach(mv => (moveChoices[mv!.moveId] = 0)); + getEnemyMoveChoices(enemyPokemon, moveChoices); - enemyMoveset.forEach(mv => { - if (mv?.getMove().category === MoveCategory.STATUS || mv?.moveId === Moves.LAST_RESORT) { - expect(moveChoices[mv.moveId]).toBe(0); - } - }); - } - ); + enemyMoveset.forEach(mv => { + if (mv?.getMove().category === MoveCategory.STATUS || mv?.moveId === Moves.LAST_RESORT) { + expect(moveChoices[mv.moveId]).toBe(0); + } + }); + }); }); diff --git a/test/escape-calculations.test.ts b/test/escape-calculations.test.ts index 6c5c8777d01..0cbf11dd230 100644 --- a/test/escape-calculations.test.ts +++ b/test/escape-calculations.test.ts @@ -32,13 +32,13 @@ describe("Escape chance calculations", () => { }); it("single non-boss opponent", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerField(); const enemyField = game.scene.getEnemyField(); const enemySpeed = 100; // set enemyPokemon's speed to 100 - vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemySpeed ]); + vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemySpeed]); const commandPhase = game.scene.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); @@ -48,7 +48,11 @@ describe("Escape chance calculations", () => { const escapePercentage = new Utils.NumberHolder(0); // this sets up an object for multiple attempts. The pokemonSpeedRatio is your speed divided by the enemy speed, the escapeAttempts are the number of escape attempts and the expectedEscapeChance is the chance it should be escaping - const escapeChances: { pokemonSpeedRatio: number, escapeAttempts: number, expectedEscapeChance: number }[] = [ + const escapeChances: { + pokemonSpeedRatio: number; + escapeAttempts: number; + expectedEscapeChance: number; + }[] = [ { pokemonSpeedRatio: 0.01, escapeAttempts: 0, expectedEscapeChance: 5 }, { pokemonSpeedRatio: 0.1, escapeAttempts: 0, expectedEscapeChance: 7 }, { pokemonSpeedRatio: 0.25, escapeAttempts: 0, expectedEscapeChance: 11 }, @@ -79,7 +83,14 @@ describe("Escape chance calculations", () => { // sets the number of escape attempts to the required amount game.scene.currentBattle.escapeAttempts = escapeChances[i].escapeAttempts; // set playerPokemon's speed to a multiple of the enemySpeed - vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, escapeChances[i].pokemonSpeedRatio * enemySpeed ]); + vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + escapeChances[i].pokemonSpeedRatio * enemySpeed, + ]); phase.attemptRunAway(playerPokemon, enemyField, escapePercentage); expect(escapePercentage.value).toBe(escapeChances[i].expectedEscapeChance); } @@ -87,7 +98,7 @@ describe("Escape chance calculations", () => { it("double non-boss opponent", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.ABOMASNOW ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.ABOMASNOW]); const playerPokemon = game.scene.getPlayerField(); const enemyField = game.scene.getEnemyField(); @@ -98,9 +109,9 @@ describe("Escape chance calculations", () => { // this is used to find the ratio of the player's first pokemon const playerASpeedPercentage = 0.4; // set enemyAPokemon's speed to 70 - vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemyASpeed ]); + vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemyASpeed]); // set enemyBPokemon's speed to 30 - vi.spyOn(enemyField[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemyBSpeed ]); + vi.spyOn(enemyField[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemyBSpeed]); const commandPhase = game.scene.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); @@ -110,7 +121,11 @@ describe("Escape chance calculations", () => { const escapePercentage = new Utils.NumberHolder(0); // this sets up an object for multiple attempts. The pokemonSpeedRatio is your speed divided by the enemy speed, the escapeAttempts are the number of escape attempts and the expectedEscapeChance is the chance it should be escaping - const escapeChances: { pokemonSpeedRatio: number, escapeAttempts: number, expectedEscapeChance: number }[] = [ + const escapeChances: { + pokemonSpeedRatio: number; + escapeAttempts: number; + expectedEscapeChance: number; + }[] = [ { pokemonSpeedRatio: 0.3, escapeAttempts: 0, expectedEscapeChance: 12 }, { pokemonSpeedRatio: 0.7, escapeAttempts: 0, expectedEscapeChance: 21 }, { pokemonSpeedRatio: 1.5, escapeAttempts: 0, expectedEscapeChance: 39 }, @@ -134,33 +149,48 @@ describe("Escape chance calculations", () => { { pokemonSpeedRatio: 2.4, escapeAttempts: 9, expectedEscapeChance: 95 }, { pokemonSpeedRatio: 1.8, escapeAttempts: 7, expectedEscapeChance: 95 }, { pokemonSpeedRatio: 2, escapeAttempts: 10, expectedEscapeChance: 95 }, - ]; for (let i = 0; i < escapeChances.length; i++) { // sets the number of escape attempts to the required amount game.scene.currentBattle.escapeAttempts = escapeChances[i].escapeAttempts; // set the first playerPokemon's speed to a multiple of the enemySpeed - vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, Math.floor(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed * playerASpeedPercentage) ]); + vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + Math.floor(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed * playerASpeedPercentage), + ]); // set the second playerPokemon's speed to the remaining value of speed - vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, escapeChances[i].pokemonSpeedRatio * totalEnemySpeed - playerPokemon[0].stats[5] ]); + vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + escapeChances[i].pokemonSpeedRatio * totalEnemySpeed - playerPokemon[0].stats[5], + ]); phase.attemptRunAway(playerPokemon, enemyField, escapePercentage); // checks to make sure the escape values are the same expect(escapePercentage.value).toBe(escapeChances[i].expectedEscapeChance); // checks to make sure the sum of the player's speed for all pokemon is equal to the appropriate ratio of the total enemy speed - expect(playerPokemon[0].stats[5] + playerPokemon[1].stats[5]).toBe(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed); + expect(playerPokemon[0].stats[5] + playerPokemon[1].stats[5]).toBe( + escapeChances[i].pokemonSpeedRatio * totalEnemySpeed, + ); } }, 20000); it("single boss opponent", async () => { game.override.startingWave(10); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerField()!; const enemyField = game.scene.getEnemyField()!; const enemySpeed = 100; // set enemyPokemon's speed to 100 - vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemySpeed ]); + vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemySpeed]); const commandPhase = game.scene.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); @@ -170,7 +200,11 @@ describe("Escape chance calculations", () => { const escapePercentage = new Utils.NumberHolder(0); // this sets up an object for multiple attempts. The pokemonSpeedRatio is your speed divided by the enemy speed, the escapeAttempts are the number of escape attempts and the expectedEscapeChance is the chance it should be escaping - const escapeChances: { pokemonSpeedRatio: number, escapeAttempts: number, expectedEscapeChance: number }[] = [ + const escapeChances: { + pokemonSpeedRatio: number; + escapeAttempts: number; + expectedEscapeChance: number; + }[] = [ { pokemonSpeedRatio: 0.01, escapeAttempts: 0, expectedEscapeChance: 5 }, { pokemonSpeedRatio: 0.1, escapeAttempts: 0, expectedEscapeChance: 5 }, { pokemonSpeedRatio: 0.25, escapeAttempts: 0, expectedEscapeChance: 6 }, @@ -208,14 +242,20 @@ describe("Escape chance calculations", () => { { pokemonSpeedRatio: 6, escapeAttempts: 0, expectedEscapeChance: 25 }, { pokemonSpeedRatio: 5.9, escapeAttempts: 2, expectedEscapeChance: 25 }, { pokemonSpeedRatio: 6.1, escapeAttempts: 3, expectedEscapeChance: 25 }, - ]; for (let i = 0; i < escapeChances.length; i++) { // sets the number of escape attempts to the required amount game.scene.currentBattle.escapeAttempts = escapeChances[i].escapeAttempts; // set playerPokemon's speed to a multiple of the enemySpeed - vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, escapeChances[i].pokemonSpeedRatio * enemySpeed ]); + vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + escapeChances[i].pokemonSpeedRatio * enemySpeed, + ]); phase.attemptRunAway(playerPokemon, enemyField, escapePercentage); expect(escapePercentage.value).toBe(escapeChances[i].expectedEscapeChance); } @@ -224,7 +264,7 @@ describe("Escape chance calculations", () => { it("double boss opponent", async () => { game.override.battleType("double"); game.override.startingWave(10); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.ABOMASNOW ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.ABOMASNOW]); const playerPokemon = game.scene.getPlayerField(); const enemyField = game.scene.getEnemyField(); @@ -235,9 +275,9 @@ describe("Escape chance calculations", () => { // this is used to find the ratio of the player's first pokemon const playerASpeedPercentage = 0.8; // set enemyAPokemon's speed to 70 - vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemyASpeed ]); + vi.spyOn(enemyField[0], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemyASpeed]); // set enemyBPokemon's speed to 30 - vi.spyOn(enemyField[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, enemyBSpeed ]); + vi.spyOn(enemyField[1], "stats", "get").mockReturnValue([20, 20, 20, 20, 20, enemyBSpeed]); const commandPhase = game.scene.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); @@ -247,7 +287,11 @@ describe("Escape chance calculations", () => { const escapePercentage = new Utils.NumberHolder(0); // this sets up an object for multiple attempts. The pokemonSpeedRatio is your speed divided by the enemy speed, the escapeAttempts are the number of escape attempts and the expectedEscapeChance is the chance it should be escaping - const escapeChances: { pokemonSpeedRatio: number, escapeAttempts: number, expectedEscapeChance: number }[] = [ + const escapeChances: { + pokemonSpeedRatio: number; + escapeAttempts: number; + expectedEscapeChance: number; + }[] = [ { pokemonSpeedRatio: 0.3, escapeAttempts: 0, expectedEscapeChance: 6 }, { pokemonSpeedRatio: 0.7, escapeAttempts: 0, expectedEscapeChance: 7 }, { pokemonSpeedRatio: 1.5, escapeAttempts: 0, expectedEscapeChance: 10 }, @@ -283,21 +327,36 @@ describe("Escape chance calculations", () => { { pokemonSpeedRatio: 6.5, escapeAttempts: 1, expectedEscapeChance: 25 }, { pokemonSpeedRatio: 12, escapeAttempts: 4, expectedEscapeChance: 25 }, { pokemonSpeedRatio: 5.2, escapeAttempts: 2, expectedEscapeChance: 25 }, - ]; for (let i = 0; i < escapeChances.length; i++) { // sets the number of escape attempts to the required amount game.scene.currentBattle.escapeAttempts = escapeChances[i].escapeAttempts; // set the first playerPokemon's speed to a multiple of the enemySpeed - vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, Math.floor(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed * playerASpeedPercentage) ]); + vi.spyOn(playerPokemon[0], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + Math.floor(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed * playerASpeedPercentage), + ]); // set the second playerPokemon's speed to the remaining value of speed - vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([ 20, 20, 20, 20, 20, escapeChances[i].pokemonSpeedRatio * totalEnemySpeed - playerPokemon[0].stats[5] ]); + vi.spyOn(playerPokemon[1], "stats", "get").mockReturnValue([ + 20, + 20, + 20, + 20, + 20, + escapeChances[i].pokemonSpeedRatio * totalEnemySpeed - playerPokemon[0].stats[5], + ]); phase.attemptRunAway(playerPokemon, enemyField, escapePercentage); // checks to make sure the escape values are the same expect(escapePercentage.value).toBe(escapeChances[i].expectedEscapeChance); // checks to make sure the sum of the player's speed for all pokemon is equal to the appropriate ratio of the total enemy speed - expect(playerPokemon[0].stats[5] + playerPokemon[1].stats[5]).toBe(escapeChances[i].pokemonSpeedRatio * totalEnemySpeed); + expect(playerPokemon[0].stats[5] + playerPokemon[1].stats[5]).toBe( + escapeChances[i].pokemonSpeedRatio * totalEnemySpeed, + ); } }, 20000); }); diff --git a/test/evolution.test.ts b/test/evolution.test.ts index dbd4ef3a0d7..dd6795bf161 100644 --- a/test/evolution.test.ts +++ b/test/evolution.test.ts @@ -1,4 +1,8 @@ -import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/balance/pokemon-evolutions"; +import { + pokemonEvolutions, + SpeciesFormEvolution, + SpeciesWildEvolutionDelay, +} from "#app/data/balance/pokemon-evolutions"; import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; @@ -33,7 +37,7 @@ describe("Evolution", () => { }); it("should keep hidden ability after evolving", async () => { - await game.classicMode.runToSummon([ Species.EEVEE, Species.TRAPINCH ]); + await game.classicMode.runToSummon([Species.EEVEE, Species.TRAPINCH]); const eevee = game.scene.getPlayerParty()[0]; const trapinch = game.scene.getPlayerParty()[1]; @@ -48,7 +52,7 @@ describe("Evolution", () => { }); it("should keep same ability slot after evolving", async () => { - await game.classicMode.runToSummon([ Species.BULBASAUR, Species.CHARMANDER ]); + await game.classicMode.runToSummon([Species.BULBASAUR, Species.CHARMANDER]); const bulbasaur = game.scene.getPlayerParty()[0]; const charmander = game.scene.getPlayerParty()[1]; @@ -63,7 +67,7 @@ describe("Evolution", () => { }); it("should handle illegal abilityIndex values", async () => { - await game.classicMode.runToSummon([ Species.SQUIRTLE ]); + await game.classicMode.runToSummon([Species.SQUIRTLE]); const squirtle = game.scene.getPlayerPokemon()!; squirtle.abilityIndex = 5; @@ -73,7 +77,7 @@ describe("Evolution", () => { }); it("should handle nincada's unique evolution", async () => { - await game.classicMode.runToSummon([ Species.NINCADA ]); + await game.classicMode.runToSummon([Species.NINCADA]); const nincada = game.scene.getPlayerPokemon()!; nincada.abilityIndex = 2; @@ -98,14 +102,15 @@ describe("Evolution", () => { }); it("should increase both HP and max HP when evolving", async () => { - game.override.moveset([ Moves.SURF ]) + game.override + .moveset([Moves.SURF]) .enemySpecies(Species.GOLEM) .enemyMoveset(Moves.SPLASH) .startingWave(21) .startingLevel(16) .enemyLevel(50); - await game.startBattle([ Species.TOTODILE ]); + await game.startBattle([Species.TOTODILE]); const totodile = game.scene.getPlayerPokemon()!; const hpBefore = totodile.hp; @@ -125,14 +130,15 @@ describe("Evolution", () => { }); it("should not fully heal HP when evolving", async () => { - game.override.moveset([ Moves.SURF ]) + game.override + .moveset([Moves.SURF]) .enemySpecies(Species.GOLEM) .enemyMoveset(Moves.SPLASH) .startingWave(21) .startingLevel(13) .enemyLevel(30); - await game.startBattle([ Species.CYNDAQUIL ]); + await game.startBattle([Species.CYNDAQUIL]); const cyndaquil = game.scene.getPlayerPokemon()!; cyndaquil.hp = Math.floor(cyndaquil.getMaxHp() / 2); @@ -165,7 +171,7 @@ describe("Evolution", () => { * If the value is 0, it's a 3 family maushold, whereas if the value is * 1, 2 or 3, it's a 4 family maushold */ - await game.startBattle([ Species.TANDEMAUS ]); // starts us off with a tandemaus + await game.startBattle([Species.TANDEMAUS]); // starts us off with a tandemaus const playerPokemon = game.scene.getPlayerPokemon()!; playerPokemon.level = 25; // tandemaus evolves at level 25 vi.spyOn(Utils, "randSeedInt").mockReturnValue(0); // setting the random generator to be 0 to force a three family maushold diff --git a/test/field/pokemon.test.ts b/test/field/pokemon.test.ts index 0ea1e08c31d..85128a31f7f 100644 --- a/test/field/pokemon.test.ts +++ b/test/field/pokemon.test.ts @@ -26,7 +26,7 @@ describe("Spec - Pokemon", () => { }); it("should not crash when trying to set status of undefined", async () => { - await game.classicMode.runToSummon([ Species.ABRA ]); + await game.classicMode.runToSummon([Species.ABRA]); const pkm = game.scene.getPlayerPokemon()!; expect(pkm).toBeDefined(); @@ -39,7 +39,7 @@ describe("Spec - Pokemon", () => { beforeEach(async () => { game.override.enemySpecies(Species.ZUBAT); - await game.classicMode.runToSummon([ Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA ]); // 5 Abra, only 1 slot left + await game.classicMode.runToSummon([Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA, Species.ABRA]); // 5 Abra, only 1 slot left scene = game.scene; }); @@ -49,7 +49,7 @@ describe("Spec - Pokemon", () => { const party = scene.getPlayerParty(); expect(party).toHaveLength(6); - party.forEach((pkm, index) =>{ + party.forEach((pkm, index) => { expect(pkm.species.speciesId).toBe(index === 5 ? Species.ZUBAT : Species.ABRA); }); }); @@ -61,7 +61,7 @@ describe("Spec - Pokemon", () => { const party = scene.getPlayerParty(); expect(party).toHaveLength(6); - party.forEach((pkm, index) =>{ + party.forEach((pkm, index) => { expect(pkm.species.speciesId).toBe(index === slotIndex ? Species.ZUBAT : Species.ABRA); }); }); @@ -70,7 +70,7 @@ describe("Spec - Pokemon", () => { it("should not share tms between different forms", async () => { game.override.starterForms({ [Species.ROTOM]: 4 }); - await game.classicMode.startBattle([ Species.ROTOM ]); + await game.classicMode.startBattle([Species.ROTOM]); const fanRotom = game.scene.getPlayerPokemon()!; @@ -97,12 +97,12 @@ describe("Spec - Pokemon", () => { expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.FIRE); - pokemon.customPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.NORMAL ]; + pokemon.customPokemonData.types = [PokemonType.UNKNOWN, PokemonType.NORMAL]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.FIRE); - pokemon.customPokemonData.types = [ PokemonType.NORMAL, PokemonType.UNKNOWN ]; + pokemon.customPokemonData.types = [PokemonType.NORMAL, PokemonType.UNKNOWN]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.NORMAL); expect(types[1]).toBe(PokemonType.FIRE); @@ -112,18 +112,18 @@ describe("Spec - Pokemon", () => { } pokemon.customPokemonData.types = []; - pokemon.fusionCustomPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.NORMAL ]; + pokemon.fusionCustomPokemonData.types = [PokemonType.UNKNOWN, PokemonType.NORMAL]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.NORMAL); - pokemon.fusionCustomPokemonData.types = [ PokemonType.NORMAL, PokemonType.UNKNOWN ]; + pokemon.fusionCustomPokemonData.types = [PokemonType.NORMAL, PokemonType.UNKNOWN]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.NORMAL); - pokemon.customPokemonData.types = [ PokemonType.NORMAL, PokemonType.UNKNOWN ]; - pokemon.fusionCustomPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.NORMAL ]; + pokemon.customPokemonData.types = [PokemonType.NORMAL, PokemonType.UNKNOWN]; + pokemon.fusionCustomPokemonData.types = [PokemonType.UNKNOWN, PokemonType.NORMAL]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.NORMAL); expect(types[1]).toBe(PokemonType.FIRE); @@ -172,13 +172,13 @@ describe("Spec - Pokemon", () => { expect(types[1]).toBe(PokemonType.FIRE); // Natu Psychic/Grass - pokemon.customPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.GRASS ]; + pokemon.customPokemonData.types = [PokemonType.UNKNOWN, PokemonType.GRASS]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.FIRE); // Natu Grass/Flying - pokemon.customPokemonData.types = [ PokemonType.GRASS, PokemonType.UNKNOWN ]; + pokemon.customPokemonData.types = [PokemonType.GRASS, PokemonType.UNKNOWN]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.GRASS); expect(types[1]).toBe(PokemonType.FIRE); @@ -189,21 +189,21 @@ describe("Spec - Pokemon", () => { pokemon.customPokemonData.types = []; // Houndour Dark/Grass - pokemon.fusionCustomPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.GRASS ]; + pokemon.fusionCustomPokemonData.types = [PokemonType.UNKNOWN, PokemonType.GRASS]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.GRASS); // Houndour Grass/Fire - pokemon.fusionCustomPokemonData.types = [ PokemonType.GRASS, PokemonType.UNKNOWN ]; + pokemon.fusionCustomPokemonData.types = [PokemonType.GRASS, PokemonType.UNKNOWN]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.PSYCHIC); expect(types[1]).toBe(PokemonType.FIRE); // Natu Grass/Flying // Houndour Dark/Grass - pokemon.customPokemonData.types = [ PokemonType.GRASS, PokemonType.UNKNOWN ]; - pokemon.fusionCustomPokemonData.types = [ PokemonType.UNKNOWN, PokemonType.GRASS ]; + pokemon.customPokemonData.types = [PokemonType.GRASS, PokemonType.UNKNOWN]; + pokemon.fusionCustomPokemonData.types = [PokemonType.UNKNOWN, PokemonType.GRASS]; types = pokemon.getTypes(); expect(types[0]).toBe(PokemonType.GRASS); expect(types[1]).toBe(PokemonType.DARK); diff --git a/test/final_boss.test.ts b/test/final_boss.test.ts index f7675c17005..1b0cdce60a0 100644 --- a/test/final_boss.test.ts +++ b/test/final_boss.test.ts @@ -29,7 +29,7 @@ describe("Final Boss", () => { .startingBiome(Biome.END) .disableCrits() .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.SPLASH, Moves.WILL_O_WISP, Moves.DRAGON_PULSE ]) + .moveset([Moves.SPLASH, Moves.WILL_O_WISP, Moves.DRAGON_PULSE]) .startingLevel(10000); }); @@ -38,7 +38,7 @@ describe("Final Boss", () => { }); it("should spawn Eternatus on wave 200 in END biome", async () => { - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC); expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -47,7 +47,7 @@ describe("Final Boss", () => { it("should NOT spawn Eternatus before wave 200 in END biome", async () => { game.override.startingWave(FinalWave.Classic - 1); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC); expect(game.scene.currentBattle.waveIndex).not.toBe(FinalWave.Classic); expect(game.scene.arena.biomeType).toBe(Biome.END); @@ -56,7 +56,7 @@ describe("Final Boss", () => { it("should NOT spawn Eternatus outside of END biome", async () => { game.override.startingBiome(Biome.FOREST); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC); expect(game.scene.currentBattle.waveIndex).toBe(FinalWave.Classic); expect(game.scene.arena.biomeType).not.toBe(Biome.END); @@ -64,7 +64,7 @@ describe("Final Boss", () => { }); it("should not have passive enabled on Eternatus", async () => { - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC); const eternatus = game.scene.getEnemyPokemon()!; expect(eternatus.species.speciesId).toBe(Species.ETERNATUS); @@ -72,7 +72,7 @@ describe("Final Boss", () => { }); it("should change form on direct hit down to last boss fragment", async () => { - await game.runToFinalBossEncounter([ Species.KYUREM ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.KYUREM], GameModes.CLASSIC); await game.phaseInterceptor.to("CommandPhase"); // Eternatus phase 1 @@ -101,7 +101,7 @@ describe("Final Boss", () => { it("should change form on status damage down to last boss fragment", async () => { game.override.ability(Abilities.NO_GUARD); - await game.runToFinalBossEncounter([ Species.BIDOOF ], GameModes.CLASSIC); + await game.runToFinalBossEncounter([Species.BIDOOF], GameModes.CLASSIC); await game.phaseInterceptor.to("CommandPhase"); // Eternatus phase 1 @@ -140,5 +140,4 @@ describe("Final Boss", () => { expect(miniBlackHole).toBeDefined(); expect(miniBlackHole?.stackCount).toBe(1); }); - }); diff --git a/test/game-mode.test.ts b/test/game-mode.test.ts index 3f5819f9a38..a2da7d1690a 100644 --- a/test/game-mode.test.ts +++ b/test/game-mode.test.ts @@ -28,9 +28,7 @@ describe("game-mode", () => { it("does NOT spawn trainers within 3 waves of fixed battle", () => { const { arena } = game.scene; /** set wave 16 to be a fixed trainer fight meaning wave 13-19 don't allow trainer spawns */ - vi.spyOn(classicGameMode, "isFixedBattle").mockImplementation( - (n: number) => (n === 16 ? true : false) - ); + vi.spyOn(classicGameMode, "isFixedBattle").mockImplementation((n: number) => n === 16); vi.spyOn(arena, "getTrainerChance").mockReturnValue(1); vi.spyOn(Utils, "randSeedInt").mockReturnValue(0); expect(classicGameMode.isWaveTrainer(11, arena)).toBeFalsy(); diff --git a/test/imports.test.ts b/test/imports.test.ts index 305eccdc465..128308dbd14 100644 --- a/test/imports.test.ts +++ b/test/imports.test.ts @@ -32,4 +32,3 @@ describe("tests to debug the import, with trace", () => { expect(module.Species).toBeDefined(); }); }); - diff --git a/test/inputs/inputs.test.ts b/test/inputs/inputs.test.ts index 2cdab4b3eb2..1f566672f00 100644 --- a/test/inputs/inputs.test.ts +++ b/test/inputs/inputs.test.ts @@ -5,7 +5,6 @@ import InputsHandler from "#test/testUtils/inputsHandler"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Inputs", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -52,39 +51,38 @@ describe("Inputs", () => { expect(game.inputsHandler.log.length).toBe(5); }); - it("keyboard - test input holding for 200ms - 1 input", async() => { + it("keyboard - test input holding for 200ms - 1 input", async () => { await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 200); expect(game.inputsHandler.log.length).toBe(1); }); - it("keyboard - test input holding for 300ms - 2 input", async() => { + it("keyboard - test input holding for 300ms - 2 input", async () => { await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 300); expect(game.inputsHandler.log.length).toBe(2); }); - it("keyboard - test input holding for 1000ms - 4 input", async() => { + it("keyboard - test input holding for 1000ms - 4 input", async () => { await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 1050); expect(game.inputsHandler.log.length).toBe(5); }); - it("gamepad - test input holding for 1ms - 1 input", async() => { + it("gamepad - test input holding for 1ms - 1 input", async () => { await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 1); expect(game.inputsHandler.log.length).toBe(1); }); - it("gamepad - test input holding for 200ms - 1 input", async() => { + it("gamepad - test input holding for 200ms - 1 input", async () => { await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 200); expect(game.inputsHandler.log.length).toBe(1); }); - it("gamepad - test input holding for 300ms - 2 input", async() => { + it("gamepad - test input holding for 300ms - 2 input", async () => { await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 300); expect(game.inputsHandler.log.length).toBe(2); }); - it("gamepad - test input holding for 1000ms - 4 input", async() => { + it("gamepad - test input holding for 1000ms - 4 input", async () => { await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 1050); expect(game.inputsHandler.log.length).toBe(5); }); }); - diff --git a/test/internals.test.ts b/test/internals.test.ts index 2cc827a8906..558b363caf0 100644 --- a/test/internals.test.ts +++ b/test/internals.test.ts @@ -23,7 +23,7 @@ describe("Internals", () => { }); it("should provide Eevee with 3 defined abilities", async () => { - await game.classicMode.runToSummon([ Species.EEVEE ]); + await game.classicMode.runToSummon([Species.EEVEE]); const eevee = game.scene.getPlayerPokemon()!; expect(eevee.getSpeciesForm().getAbilityCount()).toBe(3); @@ -34,7 +34,7 @@ describe("Internals", () => { }); it("should set Eeeve abilityIndex between 0-2", async () => { - await game.classicMode.runToSummon([ Species.EEVEE ]); + await game.classicMode.runToSummon([Species.EEVEE]); const eevee = game.scene.getPlayerPokemon()!; expect(eevee.abilityIndex).toBeGreaterThanOrEqual(0); diff --git a/test/items/dire_hit.test.ts b/test/items/dire_hit.test.ts index 4a94030ab93..038d88ddc73 100644 --- a/test/items/dire_hit.test.ts +++ b/test/items/dire_hit.test.ts @@ -34,17 +34,14 @@ describe("Items - Dire Hit", () => { game.override .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.POUND ]) + .moveset([Moves.POUND]) .startingHeldItems([{ name: "DIRE_HIT" }]) .battleType("single") .disableCrits(); - }, 20000); it("should raise CRIT stage by 1", async () => { - await game.startBattle([ - Species.GASTLY - ]); + await game.startBattle([Species.GASTLY]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -57,12 +54,10 @@ describe("Items - Dire Hit", () => { expect(enemyPokemon.getCritStage).toHaveReturnedWith(1); }, 20000); - it("should renew how many battles are left of existing DIRE_HIT when picking up new DIRE_HIT", async() => { + it("should renew how many battles are left of existing DIRE_HIT when picking up new DIRE_HIT", async () => { game.override.itemRewards([{ name: "DIRE_HIT" }]); - await game.startBattle([ - Species.PIKACHU - ]); + await game.startBattle([Species.PIKACHU]); game.move.select(Moves.SPLASH); @@ -74,13 +69,19 @@ describe("Items - Dire Hit", () => { expect(modifier.getBattleCount()).toBe(4); // Forced DIRE_HIT to spawn in the first slot with override - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { - const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; - // Traverse to first modifier slot - handler.setCursor(0); - handler.setRowCursor(ShopCursorTarget.REWARDS); - handler.processInput(Button.ACTION); - }, () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(NewBattlePhase), true); + game.onNextPrompt( + "SelectModifierPhase", + Mode.MODIFIER_SELECT, + () => { + const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; + // Traverse to first modifier slot + handler.setCursor(0); + handler.setRowCursor(ShopCursorTarget.REWARDS); + handler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(NewBattlePhase), + true, + ); await game.phaseInterceptor.to(TurnInitPhase); diff --git a/test/items/double_battle_chance_booster.test.ts b/test/items/double_battle_chance_booster.test.ts index 2a86a151685..b4818e7e7ba 100644 --- a/test/items/double_battle_chance_booster.test.ts +++ b/test/items/double_battle_chance_booster.test.ts @@ -27,12 +27,7 @@ describe("Items - Double Battle Chance Boosters", () => { }); it("should guarantee double battle with 2 unique tiers", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - { name: "SUPER_LURE" } - ]) - .startingWave(2); + game.override.startingModifier([{ name: "LURE" }, { name: "SUPER_LURE" }]).startingWave(2); await game.classicMode.startBattle(); @@ -40,13 +35,7 @@ describe("Items - Double Battle Chance Boosters", () => { }); it("should guarantee double boss battle with 3 unique tiers", async () => { - game.override - .startingModifier([ - { name: "LURE" }, - { name: "SUPER_LURE" }, - { name: "MAX_LURE" } - ]) - .startingWave(10); + game.override.startingModifier([{ name: "LURE" }, { name: "SUPER_LURE" }, { name: "MAX_LURE" }]).startingWave(10); await game.classicMode.startBattle(); @@ -57,16 +46,14 @@ describe("Items - Double Battle Chance Boosters", () => { expect(enemyField[1].isBoss()).toBe(true); }); - it("should renew how many battles are left of existing booster when picking up new booster of same tier", async() => { + it("should renew how many battles are left of existing booster when picking up new booster of same tier", async () => { game.override .startingModifier([{ name: "LURE" }]) .itemRewards([{ name: "LURE" }]) .moveset(Moves.SPLASH) .startingLevel(200); - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.SPLASH); @@ -74,17 +61,25 @@ describe("Items - Double Battle Chance Boosters", () => { await game.phaseInterceptor.to("BattleEndPhase"); - const modifier = game.scene.findModifier(m => m instanceof DoubleBattleChanceBoosterModifier) as DoubleBattleChanceBoosterModifier; + const modifier = game.scene.findModifier( + m => m instanceof DoubleBattleChanceBoosterModifier, + ) as DoubleBattleChanceBoosterModifier; expect(modifier.getBattleCount()).toBe(9); // Forced LURE to spawn in the first slot with override - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { - const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; - // Traverse to first modifier slot - handler.setCursor(0); - handler.setRowCursor(ShopCursorTarget.REWARDS); - handler.processInput(Button.ACTION); - }, () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("NewBattlePhase"), true); + game.onNextPrompt( + "SelectModifierPhase", + Mode.MODIFIER_SELECT, + () => { + const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; + // Traverse to first modifier slot + handler.setCursor(0); + handler.setRowCursor(ShopCursorTarget.REWARDS); + handler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("NewBattlePhase"), + true, + ); await game.phaseInterceptor.to("TurnInitPhase"); diff --git a/test/items/eviolite.test.ts b/test/items/eviolite.test.ts index 64038cc9b82..2b82e2145e9 100644 --- a/test/items/eviolite.test.ts +++ b/test/items/eviolite.test.ts @@ -22,13 +22,11 @@ describe("Items - Eviolite", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override - .battleType("single") - .startingHeldItems([{ name: "EVIOLITE" }]); + game.override.battleType("single").startingHeldItems([{ name: "EVIOLITE" }]); }); - it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async() => { - await game.classicMode.startBattle([ Species.PICHU ]); + it("should provide 50% boost to DEF and SPDEF for unevolved, unfused pokemon", async () => { + await game.classicMode.startBattle([Species.PICHU]); const partyMember = game.scene.getPlayerPokemon()!; @@ -48,8 +46,8 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.5)); }); - it("should not provide a boost for fully evolved, unfused pokemon", async() => { - await game.classicMode.startBattle([ Species.RAICHU ]); + it("should not provide a boost for fully evolved, unfused pokemon", async () => { + await game.classicMode.startBattle([Species.RAICHU]); const partyMember = game.scene.getPlayerPokemon()!; @@ -67,13 +65,12 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.DEF)).toBe(defStat); expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(spDefStat); - }); - it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async() => { - await game.classicMode.startBattle([ Species.PICHU, Species.CLEFFA ]); + it("should provide 50% boost to DEF and SPDEF for completely unevolved, fused pokemon", async () => { + await game.classicMode.startBattle([Species.PICHU, Species.CLEFFA]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -100,10 +97,10 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.5)); }); - it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async() => { - await game.classicMode.startBattle([ Species.PICHU, Species.CLEFABLE ]); + it("should provide 25% boost to DEF and SPDEF for partially unevolved (base), fused pokemon", async () => { + await game.classicMode.startBattle([Species.PICHU, Species.CLEFABLE]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -130,10 +127,10 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.25)); }); - it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async() => { - await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFFA ]); + it("should provide 25% boost to DEF and SPDEF for partially unevolved (fusion), fused pokemon", async () => { + await game.classicMode.startBattle([Species.RAICHU, Species.CLEFFA]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -160,10 +157,10 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(Math.floor(spDefStat * 1.25)); }); - it("should not provide a boost for fully evolved, fused pokemon", async() => { - await game.classicMode.startBattle([ Species.RAICHU, Species.CLEFABLE ]); + it("should not provide a boost for fully evolved, fused pokemon", async () => { + await game.classicMode.startBattle([Species.RAICHU, Species.CLEFABLE]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -190,17 +187,17 @@ describe("Items - Eviolite", () => { expect(partyMember.getEffectiveStat(Stat.SPDEF)).toBe(spDefStat); }); - it("should not provide a boost for Gigantamax Pokémon", async() => { + it("should not provide a boost for Gigantamax Pokémon", async () => { game.override.starterForms({ [Species.PIKACHU]: 8, [Species.EEVEE]: 2, [Species.DURALUDON]: 1, - [Species.MEOWTH]: 1 + [Species.MEOWTH]: 1, }); - const gMaxablePokemon = [ Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH ]; + const gMaxablePokemon = [Species.PIKACHU, Species.EEVEE, Species.DURALUDON, Species.MEOWTH]; - await game.classicMode.startBattle([ randItem(gMaxablePokemon) ]); + await game.classicMode.startBattle([randItem(gMaxablePokemon)]); const partyMember = game.scene.getPlayerPokemon()!; diff --git a/test/items/exp_booster.test.ts b/test/items/exp_booster.test.ts index 4519df29b01..e4491b22637 100644 --- a/test/items/exp_booster.test.ts +++ b/test/items/exp_booster.test.ts @@ -27,7 +27,7 @@ describe("EXP Modifier Items", () => { game.override.battleType("single"); }); - it("EXP booster items stack multiplicatively", async() => { + it("EXP booster items stack multiplicatively", async () => { game.override.startingHeldItems([{ name: "LUCKY_EGG", count: 3 }, { name: "GOLDEN_EGG" }]); await game.startBattle(); diff --git a/test/items/grip_claw.test.ts b/test/items/grip_claw.test.ts index 854e0998d3b..1d169006116 100644 --- a/test/items/grip_claw.test.ts +++ b/test/items/grip_claw.test.ts @@ -28,10 +28,8 @@ describe("Items - Grip Claw", () => { game.override .battleType("double") - .moveset([ Moves.TACKLE, Moves.SPLASH, Moves.ATTRACT ]) - .startingHeldItems([ - { name: "GRIP_CLAW", count: 1 }, - ]) + .moveset([Moves.TACKLE, Moves.SPLASH, Moves.ATTRACT]) + .startingHeldItems([{ name: "GRIP_CLAW", count: 1 }]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.UNNERVE) .ability(Abilities.UNNERVE) @@ -41,13 +39,12 @@ describe("Items - Grip Claw", () => { { name: "BERRY", type: BerryType.LUM, count: 2 }, ]) .enemyLevel(100); - }); it("should steal items on contact and only from the attack target", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); - const [ playerPokemon, ] = game.scene.getPlayerField(); + const [playerPokemon] = game.scene.getPlayerField(); const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier; vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100); @@ -74,9 +71,9 @@ describe("Items - Grip Claw", () => { }); it("should not steal items when using a targetted, non attack move", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); - const [ playerPokemon, ] = game.scene.getPlayerField(); + const [playerPokemon] = game.scene.getPlayerField(); const gripClaw = playerPokemon.getHeldItems()[0] as ContactHeldItemTransferChanceModifier; vi.spyOn(gripClaw, "chance", "get").mockReturnValue(100); @@ -109,4 +106,3 @@ describe("Items - Grip Claw", () => { function getHeldItemCount(pokemon: Pokemon) { return pokemon.getHeldItems().reduce((currentTotal, item) => currentTotal + item.getStackCount(), 0); } - diff --git a/test/items/leek.test.ts b/test/items/leek.test.ts index a3c509d19dd..ec4d075fe19 100644 --- a/test/items/leek.test.ts +++ b/test/items/leek.test.ts @@ -25,17 +25,15 @@ describe("Items - Leek", () => { game.override .enemySpecies(Species.MAGIKARP) - .enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]) + .enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]) .startingHeldItems([{ name: "LEEK" }]) - .moveset([ Moves.TACKLE ]) + .moveset([Moves.TACKLE]) .disableCrits() .battleType("single"); }); it("should raise CRIT stage by 2 when held by FARFETCHD", async () => { - await game.startBattle([ - Species.FARFETCHD - ]); + await game.startBattle([Species.FARFETCHD]); const enemyMember = game.scene.getEnemyPokemon()!; @@ -49,9 +47,7 @@ describe("Items - Leek", () => { }, 20000); it("should raise CRIT stage by 2 when held by GALAR_FARFETCHD", async () => { - await game.startBattle([ - Species.GALAR_FARFETCHD - ]); + await game.startBattle([Species.GALAR_FARFETCHD]); const enemyMember = game.scene.getEnemyPokemon()!; @@ -65,9 +61,7 @@ describe("Items - Leek", () => { }, 20000); it("should raise CRIT stage by 2 when held by SIRFETCHD", async () => { - await game.startBattle([ - Species.SIRFETCHD - ]); + await game.startBattle([Species.SIRFETCHD]); const enemyMember = game.scene.getEnemyPokemon()!; @@ -82,14 +76,11 @@ describe("Items - Leek", () => { it("should raise CRIT stage by 2 when held by FARFETCHD line fused with Pokemon", async () => { // Randomly choose from the Farfetch'd line - const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; + const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD]; - await game.startBattle([ - species[Utils.randInt(species.length)], - Species.PIKACHU, - ]); + await game.startBattle([species[Utils.randInt(species.length)], Species.PIKACHU]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -113,14 +104,11 @@ describe("Items - Leek", () => { it("should raise CRIT stage by 2 when held by Pokemon fused with FARFETCHD line", async () => { // Randomly choose from the Farfetch'd line - const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; + const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD]; - await game.startBattle([ - Species.PIKACHU, - species[Utils.randInt(species.length)] - ]); + await game.startBattle([Species.PIKACHU, species[Utils.randInt(species.length)]]); - const [ partyMember, ally ] = game.scene.getPlayerParty(); + const [partyMember, ally] = game.scene.getPlayerParty(); // Fuse party members (taken from PlayerPokemon.fuse(...) function) partyMember.fusionSpecies = ally.species; @@ -131,7 +119,6 @@ describe("Items - Leek", () => { partyMember.fusionGender = ally.gender; partyMember.fusionLuck = ally.luck; - const enemyMember = game.scene.getEnemyPokemon()!; vi.spyOn(enemyMember, "getCritStage"); @@ -144,9 +131,7 @@ describe("Items - Leek", () => { }, 20000); it("should not raise CRIT stage when held by a Pokemon outside of FARFETCHD line", async () => { - await game.startBattle([ - Species.PIKACHU - ]); + await game.startBattle([Species.PIKACHU]); const enemyMember = game.scene.getEnemyPokemon()!; diff --git a/test/items/leftovers.test.ts b/test/items/leftovers.test.ts index 8d74301968f..ad22e9c3cae 100644 --- a/test/items/leftovers.test.ts +++ b/test/items/leftovers.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Items - Leftovers", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,15 +26,15 @@ describe("Items - Leftovers", () => { game.override.battleType("single"); game.override.startingLevel(2000); game.override.ability(Abilities.UNNERVE); - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.UNNERVE); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.startingHeldItems([{ name: "LEFTOVERS", count: 1 }]); }); it("leftovers works", async () => { - await game.startBattle([ Species.ARCANINE ]); + await game.startBattle([Species.ARCANINE]); // Make sure leftovers are there expect(game.scene.modifiers[0].type.id).toBe("LEFTOVERS"); diff --git a/test/items/light_ball.test.ts b/test/items/light_ball.test.ts index 8dff8001ffc..e4959002904 100644 --- a/test/items/light_ball.test.ts +++ b/test/items/light_ball.test.ts @@ -28,45 +28,61 @@ describe("Items - Light Ball", () => { game.override.battleType("single"); }); - it("LIGHT_BALL activates in battle correctly", async() => { + it("LIGHT_BALL activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "LIGHT_BALL" }]); const consoleSpy = vi.spyOn(console, "log"); - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerParty()[0]; // Checking console log to make sure Light Ball is applied when getEffectiveStat (with the appropriate stat) is called partyMember.getEffectiveStat(Stat.DEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), + "", + ); // Printing dummy console messages along the way so subsequent checks don't pass because of the first console.log(""); partyMember.getEffectiveStat(Stat.SPDEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.ATK); - expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), ""); + expect(consoleSpy).toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPATK); - expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), ""); + expect(consoleSpy).toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPD); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.LIGHT_BALL.name"), + "", + ); }); - it("LIGHT_BALL held by PIKACHU", async() => { - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + it("LIGHT_BALL held by PIKACHU", async () => { + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerParty()[0]; @@ -83,7 +99,10 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["LIGHT_BALL"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); @@ -91,11 +110,8 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(2); }, 20000); - it("LIGHT_BALL held by fused PIKACHU (base)", async() => { - await game.classicMode.startBattle([ - Species.PIKACHU, - Species.MAROWAK - ]); + it("LIGHT_BALL held by fused PIKACHU (base)", async () => { + await game.classicMode.startBattle([Species.PIKACHU, Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -122,7 +138,10 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["LIGHT_BALL"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); @@ -130,11 +149,8 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(2); }, 20000); - it("LIGHT_BALL held by fused PIKACHU (part)", async() => { - await game.startBattle([ - Species.MAROWAK, - Species.PIKACHU - ]); + it("LIGHT_BALL held by fused PIKACHU (part)", async () => { + await game.startBattle([Species.MAROWAK, Species.PIKACHU]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -161,7 +177,10 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["LIGHT_BALL"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); @@ -169,10 +188,8 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(2); }, 20000); - it("LIGHT_BALL not held by PIKACHU", async() => { - await game.startBattle([ - Species.MAROWAK - ]); + it("LIGHT_BALL not held by PIKACHU", async () => { + await game.startBattle([Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; @@ -189,7 +206,10 @@ describe("Items - Light Ball", () => { expect(spAtkValue.value / spAtkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["LIGHT_BALL"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); diff --git a/test/items/lock_capsule.test.ts b/test/items/lock_capsule.test.ts index 4cdd3b8a8a0..4e4182b3038 100644 --- a/test/items/lock_capsule.test.ts +++ b/test/items/lock_capsule.test.ts @@ -27,14 +27,19 @@ describe("Items - Lock Capsule", () => { game.override .battleType("single") .startingLevel(200) - .moveset([ Moves.SURF ]) + .moveset([Moves.SURF]) .enemyAbility(Abilities.BALL_FETCH) .startingModifier([{ name: "LOCK_CAPSULE" }]); }); it("doesn't set the cost of common tier items to 0", async () => { await game.classicMode.startBattle(); - game.scene.overridePhase(new SelectModifierPhase(0, undefined, { guaranteedModifierTiers: [ ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.COMMON ], fillRemaining: false })); + game.scene.overridePhase( + new SelectModifierPhase(0, undefined, { + guaranteedModifierTiers: [ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.COMMON], + fillRemaining: false, + }), + ); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { const selectModifierPhase = game.scene.getCurrentPhase() as SelectModifierPhase; diff --git a/test/items/metal_powder.test.ts b/test/items/metal_powder.test.ts index c1345af35df..460a95d0f06 100644 --- a/test/items/metal_powder.test.ts +++ b/test/items/metal_powder.test.ts @@ -28,45 +28,61 @@ describe("Items - Metal Powder", () => { game.override.battleType("single"); }); - it("METAL_POWDER activates in battle correctly", async() => { + it("METAL_POWDER activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "METAL_POWDER" }]); const consoleSpy = vi.spyOn(console, "log"); - await game.classicMode.startBattle([ - Species.DITTO - ]); + await game.classicMode.startBattle([Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; // Checking console log to make sure Metal Powder is applied when getEffectiveStat (with the appropriate stat) is called partyMember.getEffectiveStat(Stat.DEF); - expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), ""); + expect(consoleSpy).toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), + "", + ); // Printing dummy console messages along the way so subsequent checks don't pass because of the first console.log(""); partyMember.getEffectiveStat(Stat.SPDEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.ATK); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPATK); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPD); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.METAL_POWDER.name"), + "", + ); }); - it("METAL_POWDER held by DITTO", async() => { - await game.startBattle([ - Species.DITTO - ]); + it("METAL_POWDER held by DITTO", async () => { + await game.startBattle([Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; @@ -79,17 +95,17 @@ describe("Items - Metal Powder", () => { expect(defValue.value / defStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["METAL_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); expect(defValue.value / defStat).toBe(2); }, 20000); - it("METAL_POWDER held by fused DITTO (base)", async() => { - await game.startBattle([ - Species.DITTO, - Species.MAROWAK - ]); + it("METAL_POWDER held by fused DITTO (base)", async () => { + await game.startBattle([Species.DITTO, Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -112,17 +128,17 @@ describe("Items - Metal Powder", () => { expect(defValue.value / defStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["METAL_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); expect(defValue.value / defStat).toBe(2); }, 20000); - it("METAL_POWDER held by fused DITTO (part)", async() => { - await game.startBattle([ - Species.MAROWAK, - Species.DITTO - ]); + it("METAL_POWDER held by fused DITTO (part)", async () => { + await game.startBattle([Species.MAROWAK, Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -145,16 +161,17 @@ describe("Items - Metal Powder", () => { expect(defValue.value / defStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["METAL_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); expect(defValue.value / defStat).toBe(2); }, 20000); - it("METAL_POWDER not held by DITTO", async() => { - await game.startBattle([ - Species.MAROWAK - ]); + it("METAL_POWDER not held by DITTO", async () => { + await game.startBattle([Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; @@ -167,7 +184,10 @@ describe("Items - Metal Powder", () => { expect(defValue.value / defStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["METAL_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); expect(defValue.value / defStat).toBe(1); diff --git a/test/items/multi_lens.test.ts b/test/items/multi_lens.test.ts index 01447a29544..90e73ae88ea 100644 --- a/test/items/multi_lens.test.ts +++ b/test/items/multi_lens.test.ts @@ -24,7 +24,7 @@ describe("Items - Multi Lens", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.TACKLE, Moves.TRAILBLAZE, Moves.TACHYON_CUTTER, Moves.FUTURE_SIGHT ]) + .moveset([Moves.TACKLE, Moves.TRAILBLAZE, Moves.TACHYON_CUTTER, Moves.FUTURE_SIGHT]) .ability(Abilities.BALL_FETCH) .startingHeldItems([{ name: "MULTI_LENS" }]) .battleType("single") @@ -38,19 +38,20 @@ describe("Items - Multi Lens", () => { it.each([ { stackCount: 1, firstHitDamage: 0.75 }, - { stackCount: 2, firstHitDamage: 0.50 } - ])("$stackCount count: should deal {$firstHitDamage}x damage on the first hit, then hit $stackCount times for 0.25x", + { stackCount: 2, firstHitDamage: 0.5 }, + ])( + "$stackCount count: should deal {$firstHitDamage}x damage on the first hit, then hit $stackCount times for 0.25x", async ({ stackCount, firstHitDamage }) => { game.override.startingHeldItems([{ name: "MULTI_LENS", count: stackCount }]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyPokemon = game.scene.getEnemyPokemon()!; const spy = vi.spyOn(enemyPokemon, "getAttackDamage"); vi.spyOn(enemyPokemon, "getBaseDamage").mockReturnValue(100); game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); const damageResults = spy.mock.results.map(result => result.value?.damage); @@ -58,24 +59,25 @@ describe("Items - Multi Lens", () => { expect(damageResults).toHaveLength(1 + stackCount); expect(damageResults[0]).toBe(firstHitDamage * 100); damageResults.slice(1).forEach(dmg => expect(dmg).toBe(25)); - }); + }, + ); it("should stack additively with Parental Bond", async () => { game.override.ability(Abilities.PARENTAL_BOND); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(playerPokemon.turnData.hitCount).toBe(3); }); it("should apply secondary effects on each hit", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -86,7 +88,7 @@ describe("Items - Multi Lens", () => { }); it("should not enhance multi-hit moves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -97,18 +99,16 @@ describe("Items - Multi Lens", () => { }); it("should enhance multi-target moves", async () => { - game.override - .battleType("double") - .moveset([ Moves.SWIFT, Moves.SPLASH ]); + game.override.battleType("double").moveset([Moves.SWIFT, Moves.SPLASH]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); - const [ magikarp, ] = game.scene.getPlayerField(); + const [magikarp] = game.scene.getPlayerField(); game.move.select(Moves.SWIFT, 0); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); @@ -116,17 +116,16 @@ describe("Items - Multi Lens", () => { }); it("should enhance fixed-damage moves while also applying damage reduction", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]) - .moveset(Moves.SEISMIC_TOSS); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]).moveset(Moves.SEISMIC_TOSS); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; const spy = vi.spyOn(enemyPokemon, "getAttackDamage"); game.move.select(Moves.SEISMIC_TOSS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); const damageResults = spy.mock.results.map(result => result.value?.damage); @@ -137,42 +136,45 @@ describe("Items - Multi Lens", () => { }); it("should result in correct damage for hp% attacks with 1 lens", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]) + game.override + .startingHeldItems([{ name: "MULTI_LENS", count: 1 }]) .moveset(Moves.SUPER_FANG) .ability(Abilities.COMPOUND_EYES) .enemyLevel(1000) .enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SUPER_FANG); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 5); }); it("should result in correct damage for hp% attacks with 2 lenses", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) + game.override + .startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) .moveset(Moves.SUPER_FANG) .ability(Abilities.COMPOUND_EYES) .enemyMoveset(Moves.SPLASH) .enemyLevel(1000) .enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SUPER_FANG); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.5, 5); }); it("should result in correct damage for hp% attacks with 2 lenses + Parental Bond", async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) + game.override + .startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) .moveset(Moves.SUPER_FANG) .ability(Abilities.PARENTAL_BOND) .passiveAbility(Abilities.COMPOUND_EYES) @@ -180,19 +182,19 @@ describe("Items - Multi Lens", () => { .enemyLevel(1000) .enemySpecies(Species.BLISSEY); // allows for unrealistically high levels of accuracy - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SUPER_FANG); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.getHpRatio()).toBeCloseTo(0.25, 5); }); it("should not allow Future Sight to hit infinitely many times if the user switches out", async () => { game.override.enemyLevel(1000); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); const enemyPokemon = game.scene.getEnemyPokemon()!; vi.spyOn(enemyPokemon, "damageAndUpdate"); diff --git a/test/items/quick_powder.test.ts b/test/items/quick_powder.test.ts index 80ff0d7ba33..26faf5a0f4f 100644 --- a/test/items/quick_powder.test.ts +++ b/test/items/quick_powder.test.ts @@ -28,45 +28,61 @@ describe("Items - Quick Powder", () => { game.override.battleType("single"); }); - it("QUICK_POWDER activates in battle correctly", async() => { + it("QUICK_POWDER activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "QUICK_POWDER" }]); const consoleSpy = vi.spyOn(console, "log"); - await game.classicMode.startBattle([ - Species.DITTO - ]); + await game.classicMode.startBattle([Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; // Checking console log to make sure Quick Powder is applied when getEffectiveStat (with the appropriate stat) is called partyMember.getEffectiveStat(Stat.DEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), + "", + ); // Printing dummy console messages along the way so subsequent checks don't pass because of the first console.log(""); partyMember.getEffectiveStat(Stat.SPDEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.ATK); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPATK); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPD); - expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), ""); + expect(consoleSpy).toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.QUICK_POWDER.name"), + "", + ); }); - it("QUICK_POWDER held by DITTO", async() => { - await game.classicMode.startBattle([ - Species.DITTO - ]); + it("QUICK_POWDER held by DITTO", async () => { + await game.classicMode.startBattle([Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; @@ -79,17 +95,17 @@ describe("Items - Quick Powder", () => { expect(spdValue.value / spdStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["QUICK_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); expect(spdValue.value / spdStat).toBe(2); }); - it("QUICK_POWDER held by fused DITTO (base)", async() => { - await game.classicMode.startBattle([ - Species.DITTO, - Species.MAROWAK - ]); + it("QUICK_POWDER held by fused DITTO (base)", async () => { + await game.classicMode.startBattle([Species.DITTO, Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -112,17 +128,17 @@ describe("Items - Quick Powder", () => { expect(spdValue.value / spdStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["QUICK_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); expect(spdValue.value / spdStat).toBe(2); }); - it("QUICK_POWDER held by fused DITTO (part)", async() => { - await game.classicMode.startBattle([ - Species.MAROWAK, - Species.DITTO - ]); + it("QUICK_POWDER held by fused DITTO (part)", async () => { + await game.classicMode.startBattle([Species.MAROWAK, Species.DITTO]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -145,16 +161,17 @@ describe("Items - Quick Powder", () => { expect(spdValue.value / spdStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["QUICK_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); expect(spdValue.value / spdStat).toBe(2); }); - it("QUICK_POWDER not held by DITTO", async() => { - await game.classicMode.startBattle([ - Species.MAROWAK - ]); + it("QUICK_POWDER not held by DITTO", async () => { + await game.classicMode.startBattle([Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; @@ -167,7 +184,10 @@ describe("Items - Quick Powder", () => { expect(spdValue.value / spdStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["QUICK_POWDER"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); expect(spdValue.value / spdStat).toBe(1); diff --git a/test/items/scope_lens.test.ts b/test/items/scope_lens.test.ts index 98e374b6969..abd5cd7e75c 100644 --- a/test/items/scope_lens.test.ts +++ b/test/items/scope_lens.test.ts @@ -25,17 +25,14 @@ describe("Items - Scope Lens", () => { game.override .enemySpecies(Species.MAGIKARP) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.POUND ]) + .moveset([Moves.POUND]) .startingHeldItems([{ name: "SCOPE_LENS" }]) .battleType("single") .disableCrits(); - }, 20000); it("should raise CRIT stage by 1", async () => { - await game.startBattle([ - Species.GASTLY - ]); + await game.startBattle([Species.GASTLY]); const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/items/temp_stat_stage_booster.test.ts b/test/items/temp_stat_stage_booster.test.ts index 8bbd9f4f29d..6417f898e3e 100644 --- a/test/items/temp_stat_stage_booster.test.ts +++ b/test/items/temp_stat_stage_booster.test.ts @@ -12,7 +12,6 @@ import { Button } from "#app/enums/buttons"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; - describe("Items - Temporary Stat Stage Boosters", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -35,14 +34,12 @@ describe("Items - Temporary Stat Stage Boosters", () => { .enemySpecies(Species.SHUCKLE) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.TACKLE, Moves.SPLASH, Moves.HONE_CLAWS, Moves.BELLY_DRUM ]) + .moveset([Moves.TACKLE, Moves.SPLASH, Moves.HONE_CLAWS, Moves.BELLY_DRUM]) .startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }]); }); - it("should provide a x1.3 stat stage multiplier", async() => { - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + it("should provide a x1.3 stat stage multiplier", async () => { + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerPokemon()!; @@ -55,14 +52,10 @@ describe("Items - Temporary Stat Stage Boosters", () => { expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.3); }, 20000); - it("should increase existing ACC stat stage by 1 for X_ACCURACY only", async() => { - game.override - .startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]) - .ability(Abilities.SIMPLE); + it("should increase existing ACC stat stage by 1 for X_ACCURACY only", async () => { + game.override.startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }]).ability(Abilities.SIMPLE); - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerPokemon()!; @@ -81,11 +74,8 @@ describe("Items - Temporary Stat Stage Boosters", () => { expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(2); }, 20000); - - it("should increase existing stat stage multiplier by 3/10 for the rest of the boosters", async() => { - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + it("should increase existing stat stage multiplier by 3/10 for the rest of the boosters", async () => { + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerPokemon()!; @@ -104,13 +94,14 @@ describe("Items - Temporary Stat Stage Boosters", () => { expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.8); }, 20000); - it("should not increase past maximum stat stage multiplier", async() => { - game.override.startingModifier([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }, { name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }]); - - await game.classicMode.startBattle([ - Species.PIKACHU + it("should not increase past maximum stat stage multiplier", async () => { + game.override.startingModifier([ + { name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ACC }, + { name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }, ]); + await game.classicMode.startBattle([Species.PIKACHU]); + const partyMember = game.scene.getPlayerPokemon()!; vi.spyOn(partyMember, "getStatStageMultiplier"); @@ -127,14 +118,10 @@ describe("Items - Temporary Stat Stage Boosters", () => { expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(4); }, 20000); - it("should renew how many battles are left of existing booster when picking up new booster of same type", async() => { - game.override - .startingLevel(200) - .itemRewards([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }]); + it("should renew how many battles are left of existing booster when picking up new booster of same type", async () => { + game.override.startingLevel(200).itemRewards([{ name: "TEMP_STAT_STAGE_BOOSTER", type: Stat.ATK }]); - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + await game.classicMode.startBattle([Species.PIKACHU]); game.move.select(Moves.SPLASH); @@ -142,17 +129,25 @@ describe("Items - Temporary Stat Stage Boosters", () => { await game.phaseInterceptor.to("BattleEndPhase"); - const modifier = game.scene.findModifier(m => m instanceof TempStatStageBoosterModifier) as TempStatStageBoosterModifier; + const modifier = game.scene.findModifier( + m => m instanceof TempStatStageBoosterModifier, + ) as TempStatStageBoosterModifier; expect(modifier.getBattleCount()).toBe(4); // Forced X_ATTACK to spawn in the first slot with override - game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { - const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; - // Traverse to first modifier slot - handler.setCursor(0); - handler.setRowCursor(ShopCursorTarget.REWARDS); - handler.processInput(Button.ACTION); - }, () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("NewBattlePhase"), true); + game.onNextPrompt( + "SelectModifierPhase", + Mode.MODIFIER_SELECT, + () => { + const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler; + // Traverse to first modifier slot + handler.setCursor(0); + handler.setRowCursor(ShopCursorTarget.REWARDS); + handler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase("CommandPhase") || game.isCurrentPhase("NewBattlePhase"), + true, + ); await game.phaseInterceptor.to("TurnInitPhase"); diff --git a/test/items/thick_club.test.ts b/test/items/thick_club.test.ts index f18c0bd073e..9edbbcdc7d9 100644 --- a/test/items/thick_club.test.ts +++ b/test/items/thick_club.test.ts @@ -28,45 +28,61 @@ describe("Items - Thick Club", () => { game.override.battleType("single"); }); - it("THICK_CLUB activates in battle correctly", async() => { + it("THICK_CLUB activates in battle correctly", async () => { game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]); const consoleSpy = vi.spyOn(console, "log"); - await game.classicMode.startBattle([ - Species.CUBONE - ]); + await game.classicMode.startBattle([Species.CUBONE]); const partyMember = game.scene.getPlayerParty()[0]; // Checking console log to make sure Thick Club is applied when getEffectiveStat (with the appropriate stat) is called partyMember.getEffectiveStat(Stat.DEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), + "", + ); // Printing dummy console messages along the way so subsequent checks don't pass because of the first console.log(""); partyMember.getEffectiveStat(Stat.SPDEF); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.ATK); - expect(consoleSpy).toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), ""); + expect(consoleSpy).toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPATK); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), + "", + ); console.log(""); partyMember.getEffectiveStat(Stat.SPD); - expect(consoleSpy).not.toHaveBeenLastCalledWith("Applied", i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), ""); + expect(consoleSpy).not.toHaveBeenLastCalledWith( + "Applied", + i18next.t("modifierType:SpeciesBoosterItem.THICK_CLUB.name"), + "", + ); }); - it("THICK_CLUB held by CUBONE", async() => { - await game.classicMode.startBattle([ - Species.CUBONE - ]); + it("THICK_CLUB held by CUBONE", async () => { + await game.classicMode.startBattle([Species.CUBONE]); const partyMember = game.scene.getPlayerParty()[0]; @@ -79,16 +95,17 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(2); }); - it("THICK_CLUB held by MAROWAK", async() => { - await game.classicMode.startBattle([ - Species.MAROWAK - ]); + it("THICK_CLUB held by MAROWAK", async () => { + await game.classicMode.startBattle([Species.MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; @@ -101,16 +118,17 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(2); }); - it("THICK_CLUB held by ALOLA_MAROWAK", async() => { - await game.classicMode.startBattle([ - Species.ALOLA_MAROWAK - ]); + it("THICK_CLUB held by ALOLA_MAROWAK", async () => { + await game.classicMode.startBattle([Species.ALOLA_MAROWAK]); const partyMember = game.scene.getPlayerParty()[0]; @@ -123,21 +141,21 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(2); }); - it("THICK_CLUB held by fused CUBONE line (base)", async() => { + it("THICK_CLUB held by fused CUBONE line (base)", async () => { // Randomly choose from the Cubone line - const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ]; + const species = [Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK]; const randSpecies = Utils.randInt(species.length); - await game.classicMode.startBattle([ - species[randSpecies], - Species.PIKACHU - ]); + await game.classicMode.startBattle([species[randSpecies], Species.PIKACHU]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -160,21 +178,21 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(2); }); - it("THICK_CLUB held by fused CUBONE line (part)", async() => { + it("THICK_CLUB held by fused CUBONE line (part)", async () => { // Randomly choose from the Cubone line - const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ]; + const species = [Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK]; const randSpecies = Utils.randInt(species.length); - await game.classicMode.startBattle([ - Species.PIKACHU, - species[randSpecies] - ]); + await game.classicMode.startBattle([Species.PIKACHU, species[randSpecies]]); const partyMember = game.scene.getPlayerParty()[0]; const ally = game.scene.getPlayerParty()[1]; @@ -197,16 +215,17 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(2); }); - it("THICK_CLUB not held by CUBONE", async() => { - await game.classicMode.startBattle([ - Species.PIKACHU - ]); + it("THICK_CLUB not held by CUBONE", async () => { + await game.classicMode.startBattle([Species.PIKACHU]); const partyMember = game.scene.getPlayerParty()[0]; @@ -219,7 +238,10 @@ describe("Items - Thick Club", () => { expect(atkValue.value / atkStat).toBe(1); // Giving Eviolite to party member and testing if it applies - await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); + await game.scene.addModifier( + modifierTypes.SPECIES_STAT_BOOSTER().generateType([], ["THICK_CLUB"])!.newModifier(partyMember), + true, + ); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); expect(atkValue.value / atkStat).toBe(1); diff --git a/test/items/toxic_orb.test.ts b/test/items/toxic_orb.test.ts index 8201036b927..57e6b651b66 100644 --- a/test/items/toxic_orb.test.ts +++ b/test/items/toxic_orb.test.ts @@ -30,15 +30,17 @@ describe("Items - Toxic orb", () => { .enemyAbility(Abilities.BALL_FETCH) .moveset(Moves.SPLASH) .enemyMoveset(Moves.SPLASH) - .startingHeldItems([{ - name: "TOXIC_ORB", - }]); + .startingHeldItems([ + { + name: "TOXIC_ORB", + }, + ]); vi.spyOn(i18next, "t"); }); it("should badly poison the holder", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; expect(player.getHeldItems()[0].type.id).toBe("TOXIC_ORB"); diff --git a/test/misc.test.ts b/test/misc.test.ts index f2b89418ef5..12ed165d9d9 100644 --- a/test/misc.test.ts +++ b/test/misc.test.ts @@ -24,14 +24,16 @@ describe("Test misc", () => { it("test fetch mock async", async () => { const spy = vi.fn(); - await fetch("https://localhost:8080/account/info").then(response => { - expect(response.status).toBe(200); - expect(response.ok).toBe(true); - return response.json(); - }).then(data => { - spy(); // Call the spy function - expect(data).toEqual({ "username": "greenlamp", "lastSessionSlot": 0 }); - }); + await fetch("https://localhost:8080/account/info") + .then(response => { + expect(response.status).toBe(200); + expect(response.ok).toBe(true); + return response.json(); + }) + .then(data => { + spy(); // Call the spy function + expect(data).toEqual({ username: "greenlamp", lastSessionSlot: 0 }); + }); expect(spy).toHaveBeenCalled(); }); @@ -54,7 +56,7 @@ describe("Test misc", () => { expect(response.ok).toBe(true); expect(response.status).toBe(200); - expect(data).toEqual({ "username": "greenlamp", "lastSessionSlot": 0 }); + expect(data).toEqual({ username: "greenlamp", lastSessionSlot: 0 }); }); it("test apifetch mock sync", async () => { @@ -64,7 +66,7 @@ describe("Test misc", () => { it("testing wait phase queue", async () => { const fakeScene = { - phaseQueue: [ 1, 2, 3 ] // Initially not empty + phaseQueue: [1, 2, 3], // Initially not empty }; setTimeout(() => { fakeScene.phaseQueue = []; diff --git a/test/moves/after_you.test.ts b/test/moves/after_you.test.ts index bf030027436..fde19b87b5d 100644 --- a/test/moves/after_you.test.ts +++ b/test/moves/after_you.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - After You", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -32,11 +31,11 @@ describe("Moves - After You", () => { .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.AFTER_YOU, Moves.SPLASH ]); + .moveset([Moves.AFTER_YOU, Moves.SPLASH]); }); it("makes the target move immediately after the user", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.SHUCKLE]); game.move.select(Moves.AFTER_YOU, 0, BattlerIndex.PLAYER_2); game.move.select(Moves.SPLASH, 1); @@ -50,7 +49,7 @@ describe("Moves - After You", () => { it("fails if target already moved", async () => { game.override.enemySpecies(Species.SHUCKLE); - await game.classicMode.startBattle([ Species.REGIELEKI, Species.PIKACHU ]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.PIKACHU]); game.move.select(Moves.SPLASH); game.move.select(Moves.AFTER_YOU, 1, BattlerIndex.PLAYER); diff --git a/test/moves/alluring_voice.test.ts b/test/moves/alluring_voice.test.ts index bf5a9f90f82..777078e4786 100644 --- a/test/moves/alluring_voice.test.ts +++ b/test/moves/alluring_voice.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Alluring Voice", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,13 +29,12 @@ describe("Moves - Alluring Voice", () => { .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.ICE_SCALES) - .enemyMoveset([ Moves.HOWL ]) + .enemyMoveset([Moves.HOWL]) .startingLevel(10) .enemyLevel(10) .starterSpecies(Species.FEEBAS) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.ALLURING_VOICE ]); - + .moveset([Moves.ALLURING_VOICE]); }); it("should confuse the opponent if their stat stages were raised", async () => { @@ -45,7 +43,7 @@ describe("Moves - Alluring Voice", () => { const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.ALLURING_VOICE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(BerryPhase); expect(enemy.getTag(BattlerTagType.CONFUSED)?.tagType).toBe("CONFUSED"); diff --git a/test/moves/aromatherapy.test.ts b/test/moves/aromatherapy.test.ts index e70384355a0..fe7a008249f 100644 --- a/test/moves/aromatherapy.test.ts +++ b/test/moves/aromatherapy.test.ts @@ -24,7 +24,7 @@ describe("Moves - Aromatherapy", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.AROMATHERAPY, Moves.SPLASH ]) + .moveset([Moves.AROMATHERAPY, Moves.SPLASH]) .statusEffect(StatusEffect.BURN) .battleType("double") .enemyAbility(Abilities.BALL_FETCH) @@ -32,8 +32,8 @@ describe("Moves - Aromatherapy", () => { }); it("should cure status effect of the user, its ally, and all party pokemon", async () => { - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty(); vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus"); @@ -55,8 +55,8 @@ describe("Moves - Aromatherapy", () => { it("should not cure status effect of the target/target's allies", async () => { game.override.enemyStatusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA ]); - const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftOpp, rightOpp] = game.scene.getEnemyField(); vi.spyOn(leftOpp, "resetStatus"); vi.spyOn(rightOpp, "resetStatus"); @@ -78,8 +78,8 @@ describe("Moves - Aromatherapy", () => { it("should not cure status effect of allies ON FIELD with Sap Sipper, should still cure allies in party", async () => { game.override.ability(Abilities.SAP_SIPPER); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty(); vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus"); diff --git a/test/moves/assist.test.ts b/test/moves/assist.test.ts index 4168ec6295a..68322a7f193 100644 --- a/test/moves/assist.test.ts +++ b/test/moves/assist.test.ts @@ -39,16 +39,16 @@ describe("Moves - Assist", () => { it("should only use an ally's moves", async () => { game.override.enemyMoveset(Moves.SWORDS_DANCE); - await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.SHUCKLE]); - const [ feebas, shuckle ] = game.scene.getPlayerField(); + const [feebas, shuckle] = game.scene.getPlayerField(); // These are all moves Assist cannot call; Sketch will be used to test that it can call other moves properly - game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); - game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + game.move.changeMoveset(feebas, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); + game.move.changeMoveset(shuckle, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); game.move.select(Moves.ASSIST, 0); game.move.select(Moves.SKETCH, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER]); // Player_2 uses Sketch, copies Swords Dance, Player_1 uses Assist, uses Player_2's Sketched Swords Dance await game.toNextTurn(); @@ -56,10 +56,10 @@ describe("Moves - Assist", () => { }); it("should fail if there are no allies", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const feebas = game.scene.getPlayerPokemon()!; - game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + game.move.changeMoveset(feebas, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); game.move.select(Moves.ASSIST, 0); await game.toNextTurn(); @@ -68,15 +68,15 @@ describe("Moves - Assist", () => { it("should fail if ally has no usable moves and user has usable moves", async () => { game.override.enemyMoveset(Moves.SWORDS_DANCE); - await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.SHUCKLE]); - const [ feebas, shuckle ] = game.scene.getPlayerField(); - game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); - game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + const [feebas, shuckle] = game.scene.getPlayerField(); + game.move.changeMoveset(feebas, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); + game.move.changeMoveset(shuckle, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); game.move.select(Moves.SKETCH, 0); game.move.select(Moves.PROTECT, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); // Player uses Sketch to copy Swords Dance, Player_2 stalls a turn. Player will attempt Assist and should have no usable moves await game.toNextTurn(); game.move.select(Moves.ASSIST, 0); @@ -88,12 +88,12 @@ describe("Moves - Assist", () => { }); it("should apply secondary effects of a move", async () => { - game.override.moveset([ Moves.ASSIST, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER ]); - await game.classicMode.startBattle([ Species.FEEBAS, Species.SHUCKLE ]); + game.override.moveset([Moves.ASSIST, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER, Moves.WOOD_HAMMER]); + await game.classicMode.startBattle([Species.FEEBAS, Species.SHUCKLE]); - const [ feebas, shuckle ] = game.scene.getPlayerField(); - game.move.changeMoveset(feebas, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); - game.move.changeMoveset(shuckle, [ Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL ]); + const [feebas, shuckle] = game.scene.getPlayerField(); + game.move.changeMoveset(feebas, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); + game.move.changeMoveset(shuckle, [Moves.ASSIST, Moves.SKETCH, Moves.PROTECT, Moves.DRAGON_TAIL]); game.move.select(Moves.ASSIST, 0); await game.phaseInterceptor.to(CommandPhase); diff --git a/test/moves/astonish.test.ts b/test/moves/astonish.test.ts index f6e447ec7c5..53922060ae6 100644 --- a/test/moves/astonish.test.ts +++ b/test/moves/astonish.test.ts @@ -11,7 +11,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; - describe("Moves - Astonish", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,43 +28,40 @@ describe("Moves - Astonish", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.moveset([ Moves.ASTONISH, Moves.SPLASH ]); + game.override.moveset([Moves.ASTONISH, Moves.SPLASH]); game.override.enemySpecies(Species.BLASTOISE); game.override.enemyAbility(Abilities.INSOMNIA); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.startingLevel(100); game.override.enemyLevel(100); vi.spyOn(allMoves[Moves.ASTONISH], "chance", "get").mockReturnValue(100); }); - test( - "move effect should cancel the target's move on the turn it applies", - async () => { - await game.startBattle([ Species.MEOWSCARADA ]); + test("move effect should cancel the target's move on the turn it applies", async () => { + await game.startBattle([Species.MEOWSCARADA]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.ASTONISH); + game.move.select(Moves.ASTONISH); - await game.phaseInterceptor.to(MoveEndPhase, false); + await game.phaseInterceptor.to(MoveEndPhase, false); - expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeUndefined(); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeUndefined(); - await game.phaseInterceptor.to(CommandPhase, false); + await game.phaseInterceptor.to(CommandPhase, false); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); - } - ); + expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); + }); }); diff --git a/test/moves/aurora_veil.test.ts b/test/moves/aurora_veil.test.ts index eb77cdc3a44..31f6497bae5 100644 --- a/test/moves/aurora_veil.test.ts +++ b/test/moves/aurora_veil.test.ts @@ -37,22 +37,26 @@ describe("Moves - Aurora Veil", () => { globalScene = game.scene; game.override.battleType("single"); game.override.ability(Abilities.NONE); - game.override.moveset([ Moves.ABSORB, Moves.ROCK_SLIDE, Moves.TACKLE ]); + game.override.moveset([Moves.ABSORB, Moves.ROCK_SLIDE, Moves.TACKLE]); game.override.enemyLevel(100); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL ]); + game.override.enemyMoveset([Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL, Moves.AURORA_VEIL]); game.override.disableCrits(); game.override.weather(WeatherType.HAIL); }); it("reduces damage of physical attacks by half in a single battle", async () => { const moveToUse = Moves.TACKLE; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); @@ -61,26 +65,34 @@ describe("Moves - Aurora Veil", () => { game.override.battleType("double"); const moveToUse = Moves.ROCK_SLIDE; - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); game.move.select(moveToUse); game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); it("reduces damage of special attacks by half in a single battle", async () => { const moveToUse = Moves.ABSORB; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); @@ -89,39 +101,51 @@ describe("Moves - Aurora Veil", () => { game.override.battleType("double"); const moveToUse = Moves.DAZZLING_GLEAM; - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); game.move.select(moveToUse); game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); it("does not affect physical critical hits", async () => { - game.override.moveset([ Moves.WICKED_BLOW ]); + game.override.moveset([Moves.WICKED_BLOW]); const moveToUse = Moves.WICKED_BLOW; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); it("does not affect critical hits", async () => { - game.override.moveset([ Moves.FROST_BREATH ]); + game.override.moveset([Moves.FROST_BREATH]); const moveToUse = Moves.FROST_BREATH; vi.spyOn(allMoves[Moves.FROST_BREATH], "accuracy", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); }); @@ -141,7 +165,14 @@ const getMockedMoveDamage = (defender: Pokemon, attacker: Pokemon, move: Move) = if (globalScene.arena.getTagOnSide(ArenaTagType.AURORA_VEIL, side)) { if (move.getAttrs(CritOnlyAttr).length === 0) { - globalScene.arena.applyTagsForSide(ArenaTagType.AURORA_VEIL, side, false, attacker, move.category, multiplierHolder); + globalScene.arena.applyTagsForSide( + ArenaTagType.AURORA_VEIL, + side, + false, + attacker, + move.category, + multiplierHolder, + ); } } diff --git a/test/moves/autotomize.test.ts b/test/moves/autotomize.test.ts index 29d2edbcf4e..62ef185dea8 100644 --- a/test/moves/autotomize.test.ts +++ b/test/moves/autotomize.test.ts @@ -23,76 +23,87 @@ describe("Moves - Autotomize", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.AUTOTOMIZE, Moves.KINGS_SHIELD, Moves.FALSE_SWIPE ]) + .moveset([Moves.AUTOTOMIZE, Moves.KINGS_SHIELD, Moves.FALSE_SWIPE]) .battleType("single") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH); }); - it("Autotomize should reduce weight", async () => { - const baseDracozoltWeight = 190; - const oneAutotomizeDracozoltWeight = 90; - const twoAutotomizeDracozoltWeight = 0.1; - const threeAutotomizeDracozoltWeight = 0.1; + it( + "Autotomize should reduce weight", + async () => { + const baseDracozoltWeight = 190; + const oneAutotomizeDracozoltWeight = 90; + const twoAutotomizeDracozoltWeight = 0.1; + const threeAutotomizeDracozoltWeight = 0.1; - await game.classicMode.startBattle([ Species.DRACOZOLT ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(oneAutotomizeDracozoltWeight); + await game.classicMode.startBattle([Species.DRACOZOLT]); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(oneAutotomizeDracozoltWeight); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(twoAutotomizeDracozoltWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(twoAutotomizeDracozoltWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight); + }, + TIMEOUT, + ); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight); - }, TIMEOUT); + it( + "Changing forms should revert weight", + async () => { + const baseAegislashWeight = 53; + const autotomizeAegislashWeight = 0.1; - it("Changing forms should revert weight", async () => { - const baseAegislashWeight = 53; - const autotomizeAegislashWeight = 0.1; + await game.classicMode.startBattle([Species.AEGISLASH]); + const playerPokemon = game.scene.getPlayerPokemon()!; - await game.classicMode.startBattle([ Species.AEGISLASH ]); - const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); - expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + // Transform to sword form + game.move.select(Moves.FALSE_SWIPE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); - // Transform to sword form - game.move.select(Moves.FALSE_SWIPE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + // Transform to shield form + game.move.select(Moves.KINGS_SHIELD); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); - // Transform to shield form - game.move.select(Moves.KINGS_SHIELD); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + }, + TIMEOUT, + ); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); - }, TIMEOUT); - - it("Autotomize should interact with light metal correctly", async () => { - const baseLightGroudonWeight = 475; - const autotomizeLightGroudonWeight = 425; - game.override.ability(Abilities.LIGHT_METAL); - await game.classicMode.startBattle([ Species.GROUDON ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - expect(playerPokemon.getWeight()).toBe(baseLightGroudonWeight); - game.move.select(Moves.AUTOTOMIZE); - await game.toNextTurn(); - expect(playerPokemon.getWeight()).toBe(autotomizeLightGroudonWeight); - }, TIMEOUT); + it( + "Autotomize should interact with light metal correctly", + async () => { + const baseLightGroudonWeight = 475; + const autotomizeLightGroudonWeight = 425; + game.override.ability(Abilities.LIGHT_METAL); + await game.classicMode.startBattle([Species.GROUDON]); + const playerPokemon = game.scene.getPlayerPokemon()!; + expect(playerPokemon.getWeight()).toBe(baseLightGroudonWeight); + game.move.select(Moves.AUTOTOMIZE); + await game.toNextTurn(); + expect(playerPokemon.getWeight()).toBe(autotomizeLightGroudonWeight); + }, + TIMEOUT, + ); }); diff --git a/test/moves/baddy_bad.test.ts b/test/moves/baddy_bad.test.ts index 78e7c63d49f..cba13c7ac68 100644 --- a/test/moves/baddy_bad.test.ts +++ b/test/moves/baddy_bad.test.ts @@ -21,7 +21,7 @@ describe("Moves - Baddy Bad", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .battleType("single") .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) @@ -31,7 +31,7 @@ describe("Moves - Baddy Bad", () => { it("should not activate Reflect if the move fails due to Protect", async () => { game.override.enemyMoveset(Moves.PROTECT); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.BADDY_BAD); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/baneful_bunker.test.ts b/test/moves/baneful_bunker.test.ts index 55b4b7d985e..4624d77dc42 100644 --- a/test/moves/baneful_bunker.test.ts +++ b/test/moves/baneful_bunker.test.ts @@ -7,7 +7,6 @@ import { Moves } from "#enums/moves"; import { BattlerIndex } from "#app/battle"; import { StatusEffect } from "#app/enums/status-effect"; - describe("Moves - Baneful Bunker", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -36,57 +35,48 @@ describe("Moves - Baneful Bunker", () => { game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user and poison attackers that make contact", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + test("should protect the user and poison attackers that make contact", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.SLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); - } - ); - test( - "should protect the user and poison attackers that make contact, regardless of accuracy checks", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + game.move.select(Moves.SLASH); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.phaseInterceptor.to("BerryPhase", false); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); + }); + test("should protect the user and poison attackers that make contact, regardless of accuracy checks", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.SLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.phaseInterceptor.to("MoveEffectPhase"); + game.move.select(Moves.SLASH); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.phaseInterceptor.to("MoveEffectPhase"); - await game.move.forceMiss(); - await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); - } - ); + await game.move.forceMiss(); + await game.phaseInterceptor.to("BerryPhase", false); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); + }); - test( - "should not poison attackers that don't make contact", - async () => { - game.override.moveset(Moves.FLASH_CANNON); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + test("should not poison attackers that don't make contact", async () => { + game.override.moveset(Moves.FLASH_CANNON); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.FLASH_CANNON); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.phaseInterceptor.to("MoveEffectPhase"); + game.move.select(Moves.FLASH_CANNON); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.phaseInterceptor.to("MoveEffectPhase"); - await game.move.forceMiss(); - await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy(); - } - ); + await game.move.forceMiss(); + await game.phaseInterceptor.to("BerryPhase", false); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy(); + }); }); diff --git a/test/moves/baton_pass.test.ts b/test/moves/baton_pass.test.ts index 6abd2d95f7b..9db6ec7c518 100644 --- a/test/moves/baton_pass.test.ts +++ b/test/moves/baton_pass.test.ts @@ -28,7 +28,7 @@ describe("Moves - Baton Pass", () => { .battleType("single") .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.BATON_PASS, Moves.NASTY_PLOT, Moves.SPLASH ]) + .moveset([Moves.BATON_PASS, Moves.NASTY_PLOT, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) .disableCrits(); @@ -36,7 +36,7 @@ describe("Moves - Baton Pass", () => { it("transfers all stat stages when player uses it", async () => { // arrange - await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); // round 1 - buff game.move.select(Moves.NASTY_PLOT); @@ -59,10 +59,8 @@ describe("Moves - Baton Pass", () => { it("passes stat stage buffs when AI uses it", async () => { // arrange - game.override - .startingWave(5) - .enemyMoveset(new Array(4).fill([ Moves.NASTY_PLOT ])); - await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]); + game.override.startingWave(5).enemyMoveset(new Array(4).fill([Moves.NASTY_PLOT])); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); // round 1 - ai buffs game.move.select(Moves.SPLASH); @@ -70,7 +68,7 @@ describe("Moves - Baton Pass", () => { // round 2 - baton pass game.scene.getEnemyPokemon()!.hp = 100; - game.override.enemyMoveset([ Moves.BATON_PASS ]); + game.override.enemyMoveset([Moves.BATON_PASS]); // Force moveset to update mid-battle // TODO: replace with enemy ai control function when it's added game.scene.getEnemyParty()[0].getMoveset(); @@ -87,35 +85,35 @@ describe("Moves - Baton Pass", () => { "MoveEffectPhase", "SwitchSummonPhase", "SummonPhase", - "PostSummonPhase" + "PostSummonPhase", ]); }, 20000); it("doesn't transfer effects that aren't transferrable", async () => { - game.override.enemyMoveset([ Moves.SALT_CURE ]); - await game.classicMode.startBattle([ Species.PIKACHU, Species.FEEBAS ]); + game.override.enemyMoveset([Moves.SALT_CURE]); + await game.classicMode.startBattle([Species.PIKACHU, Species.FEEBAS]); - const [ player1, player2 ] = game.scene.getPlayerParty(); + const [player1, player2] = game.scene.getPlayerParty(); game.move.select(Moves.BATON_PASS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase"); - expect(player1.findTag((t) => t.tagType === BattlerTagType.SALT_CURED)).toBeTruthy(); + expect(player1.findTag(t => t.tagType === BattlerTagType.SALT_CURED)).toBeTruthy(); game.doSelectPartyPokemon(1); await game.toNextTurn(); - expect(player2.findTag((t) => t.tagType === BattlerTagType.SALT_CURED)).toBeUndefined(); + expect(player2.findTag(t => t.tagType === BattlerTagType.SALT_CURED)).toBeUndefined(); }, 20000); it("doesn't allow binding effects from the user to persist", async () => { - game.override.moveset([ Moves.FIRE_SPIN, Moves.BATON_PASS ]); + game.override.moveset([Moves.FIRE_SPIN, Moves.BATON_PASS]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.FIRE_SPIN); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.toNextTurn(); @@ -123,7 +121,7 @@ describe("Moves - Baton Pass", () => { expect(enemy.getTag(BattlerTagType.FIRE_SPIN)).toBeDefined(); game.move.select(Moves.BATON_PASS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); diff --git a/test/moves/beak_blast.test.ts b/test/moves/beak_blast.test.ts index 177610182b0..9f8b1e3d5c3 100644 --- a/test/moves/beak_blast.test.ts +++ b/test/moves/beak_blast.test.ts @@ -10,7 +10,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Beak Blast", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,106 +29,91 @@ describe("Moves - Beak Blast", () => { game.override .battleType("single") .ability(Abilities.UNNERVE) - .moveset([ Moves.BEAK_BLAST ]) + .moveset([Moves.BEAK_BLAST]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.INSOMNIA) - .enemyMoveset([ Moves.TACKLE ]) + .enemyMoveset([Moves.TACKLE]) .startingLevel(100) .enemyLevel(100); }); - it( - "should add a charge effect that burns attackers on contact", - async () => { - await game.startBattle([ Species.BLASTOISE ]); + it("should add a charge effect that burns attackers on contact", async () => { + await game.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); - expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); + await game.phaseInterceptor.to(MovePhase, false); + expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); + }); - it( - "should still charge and burn opponents if the user is sleeping", - async () => { - game.override.statusEffect(StatusEffect.SLEEP); + it("should still charge and burn opponents if the user is sleeping", async () => { + game.override.statusEffect(StatusEffect.SLEEP); - await game.startBattle([ Species.BLASTOISE ]); + await game.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); - expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); + await game.phaseInterceptor.to(MovePhase, false); + expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); + }); - it( - "should not burn attackers that don't make contact", - async () => { - game.override.enemyMoveset([ Moves.WATER_GUN ]); + it("should not burn attackers that don't make contact", async () => { + game.override.enemyMoveset([Moves.WATER_GUN]); - await game.startBattle([ Species.BLASTOISE ]); + await game.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); - expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); + await game.phaseInterceptor.to(MovePhase, false); + expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.BURN); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.BURN); + }); - it( - "should only hit twice with Multi-Lens", - async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); + it("should only hit twice with Multi-Lens", async () => { + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); - await game.startBattle([ Species.BLASTOISE ]); + await game.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.turnData.hitCount).toBe(2); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(leadPokemon.turnData.hitCount).toBe(2); + }); - it( - "should be blocked by Protect", - async () => { - game.override.enemyMoveset([ Moves.PROTECT ]); + it("should be blocked by Protect", async () => { + game.override.enemyMoveset([Moves.PROTECT]); - await game.startBattle([ Species.BLASTOISE ]); + await game.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); - expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); + await game.phaseInterceptor.to(MovePhase, false); + expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeUndefined(); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeUndefined(); + }); }); diff --git a/test/moves/beat_up.test.ts b/test/moves/beat_up.test.ts index 1ac2ae238b8..7e67f2ea363 100644 --- a/test/moves/beat_up.test.ts +++ b/test/moves/beat_up.test.ts @@ -27,51 +27,59 @@ describe("Moves - Beat Up", () => { game.override.enemySpecies(Species.SNORLAX); game.override.enemyLevel(100); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); - game.override.moveset([ Moves.BEAT_UP ]); + game.override.moveset([Moves.BEAT_UP]); }); - it( - "should hit once for each healthy player Pokemon", - async () => { - await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE ]); + it("should hit once for each healthy player Pokemon", async () => { + await game.startBattle([ + Species.MAGIKARP, + Species.BULBASAUR, + Species.CHARMANDER, + Species.SQUIRTLE, + Species.PIKACHU, + Species.EEVEE, + ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; - let enemyStartingHp = enemyPokemon.hp; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + let enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.BEAT_UP); + game.move.select(Moves.BEAT_UP); + await game.phaseInterceptor.to(MoveEffectPhase); + + expect(playerPokemon.turnData.hitCount).toBe(6); + expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); + + while (playerPokemon.turnData.hitsLeft > 0) { + enemyStartingHp = enemyPokemon.hp; await game.phaseInterceptor.to(MoveEffectPhase); - - expect(playerPokemon.turnData.hitCount).toBe(6); expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - - while (playerPokemon.turnData.hitsLeft > 0) { - enemyStartingHp = enemyPokemon.hp; - await game.phaseInterceptor.to(MoveEffectPhase); - expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - } } - ); + }); - it( - "should not count player Pokemon with status effects towards hit count", - async () => { - await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE ]); + it("should not count player Pokemon with status effects towards hit count", async () => { + await game.startBattle([ + Species.MAGIKARP, + Species.BULBASAUR, + Species.CHARMANDER, + Species.SQUIRTLE, + Species.PIKACHU, + Species.EEVEE, + ]); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - game.scene.getPlayerParty()[1].trySetStatus(StatusEffect.BURN); + game.scene.getPlayerParty()[1].trySetStatus(StatusEffect.BURN); - game.move.select(Moves.BEAT_UP); + game.move.select(Moves.BEAT_UP); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(MoveEffectPhase); - expect(playerPokemon.turnData.hitCount).toBe(5); - } - ); + expect(playerPokemon.turnData.hitCount).toBe(5); + }); }); diff --git a/test/moves/belly_drum.test.ts b/test/moves/belly_drum.test.ts index 7d8b17262d7..f01a50f8a79 100644 --- a/test/moves/belly_drum.test.ts +++ b/test/moves/belly_drum.test.ts @@ -8,7 +8,6 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { Abilities } from "#app/enums/abilities"; - // RATIO : HP Cost of Move const RATIO = 2; // PREDAMAGE : Amount of extra HP lost @@ -35,77 +34,69 @@ describe("Moves - BELLY DRUM", () => { .enemySpecies(Species.SNORLAX) .startingLevel(100) .enemyLevel(100) - .moveset([ Moves.BELLY_DRUM ]) + .moveset([Moves.BELLY_DRUM]) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH); }); // Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Belly_Drum_(move) - test("raises the user's ATK stat stage to its max, at the cost of 1/2 of its maximum HP", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("raises the user's ATK stat stage to its max, at the cost of 1/2 of its maximum HP", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - game.move.select(Moves.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BELLY_DRUM); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + }); - test("will still take effect if an uninvolved stat stage is at max", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("will still take effect if an uninvolved stat stage is at max", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - // Here - Stat.ATK -> -3 and Stat.SPATK -> 6 - leadPokemon.setStatStage(Stat.ATK, -3); - leadPokemon.setStatStage(Stat.SPATK, 6); + // Here - Stat.ATK -> -3 and Stat.SPATK -> 6 + leadPokemon.setStatStage(Stat.ATK, -3); + leadPokemon.setStatStage(Stat.SPATK, 6); - game.move.select(Moves.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BELLY_DRUM); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); + }); - test("fails if the pokemon's ATK stat stage is at its maximum", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("fails if the pokemon's ATK stat stage is at its maximum", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.setStatStage(Stat.ATK, 6); + leadPokemon.setStatStage(Stat.ATK, 6); - game.move.select(Moves.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BELLY_DRUM); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + }); - test("fails if the user's health is less than 1/2", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("fails if the user's health is less than 1/2", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - leadPokemon.hp = hpLost - PREDAMAGE; + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + leadPokemon.hp = hpLost - PREDAMAGE; - game.move.select(Moves.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.BELLY_DRUM); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); - } - ); + expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); + }); }); diff --git a/test/moves/burning_jealousy.test.ts b/test/moves/burning_jealousy.test.ts index acdce23db92..60387df4226 100644 --- a/test/moves/burning_jealousy.test.ts +++ b/test/moves/burning_jealousy.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Burning Jealousy", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,13 +29,12 @@ describe("Moves - Burning Jealousy", () => { .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.ICE_SCALES) - .enemyMoveset([ Moves.HOWL ]) + .enemyMoveset([Moves.HOWL]) .startingLevel(10) .enemyLevel(10) .starterSpecies(Species.FEEBAS) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.BURNING_JEALOUSY, Moves.GROWL ]); - + .moveset([Moves.BURNING_JEALOUSY, Moves.GROWL]); }); it("should burn the opponent if their stat stages were raised", async () => { @@ -45,33 +43,28 @@ describe("Moves - Burning Jealousy", () => { const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.BURNING_JEALOUSY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.status?.effect).toBe(StatusEffect.BURN); }); it("should still burn the opponent if their stat stages were both raised and lowered in the same turn", async () => { - game.override - .starterSpecies(0) - .battleType("double"); - await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]); + game.override.starterSpecies(0).battleType("double"); + await game.classicMode.startBattle([Species.FEEBAS, Species.ABRA]); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.BURNING_JEALOUSY); game.move.select(Moves.GROWL, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.status?.effect).toBe(StatusEffect.BURN); }); it("should ignore stat stages raised by IMPOSTER", async () => { - game.override - .enemySpecies(Species.DITTO) - .enemyAbility(Abilities.IMPOSTER) - .enemyMoveset(Moves.SPLASH); + game.override.enemySpecies(Species.DITTO).enemyAbility(Abilities.IMPOSTER).enemyMoveset(Moves.SPLASH); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; @@ -88,15 +81,15 @@ describe("Moves - Burning Jealousy", () => { }); it("should be boosted by Sheer Force even if opponent didn't raise stat stages", async () => { - game.override - .ability(Abilities.SHEER_FORCE) - .enemyMoveset(Moves.SPLASH); + game.override.ability(Abilities.SHEER_FORCE).enemyMoveset(Moves.SPLASH); vi.spyOn(allMoves[Moves.BURNING_JEALOUSY], "calculateBattlePower"); await game.classicMode.startBattle(); game.move.select(Moves.BURNING_JEALOUSY); await game.phaseInterceptor.to("BerryPhase"); - expect(allMoves[Moves.BURNING_JEALOUSY].calculateBattlePower).toHaveReturnedWith(allMoves[Moves.BURNING_JEALOUSY].power * 5461 / 4096); + expect(allMoves[Moves.BURNING_JEALOUSY].calculateBattlePower).toHaveReturnedWith( + (allMoves[Moves.BURNING_JEALOUSY].power * 5461) / 4096, + ); }); }); diff --git a/test/moves/camouflage.test.ts b/test/moves/camouflage.test.ts index b329170cc42..0bbab6a629a 100644 --- a/test/moves/camouflage.test.ts +++ b/test/moves/camouflage.test.ts @@ -25,7 +25,7 @@ describe("Moves - Camouflage", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.CAMOUFLAGE ]) + .moveset([Moves.CAMOUFLAGE]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -35,12 +35,12 @@ describe("Moves - Camouflage", () => { }); it("Camouflage should look at terrain first when selecting a type to change into", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.CAMOUFLAGE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.arena.getTerrainType()).toBe(TerrainType.PSYCHIC); const pokemonType = playerPokemon.getTypes()[0]; diff --git a/test/moves/ceaseless_edge.test.ts b/test/moves/ceaseless_edge.test.ts index 2d929221e0b..d54f1bd9f21 100644 --- a/test/moves/ceaseless_edge.test.ts +++ b/test/moves/ceaseless_edge.test.ts @@ -10,7 +10,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; - describe("Moves - Ceaseless Edge", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -33,86 +32,76 @@ describe("Moves - Ceaseless Edge", () => { game.override.enemyPassiveAbility(Abilities.RUN_AWAY); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]); + game.override.moveset([Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR]); game.override.enemyMoveset(Moves.SPLASH); vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); - }); - test( - "move should hit and apply spikes", - async () => { - await game.classicMode.startBattle([ Species.ILLUMISE ]); + test("move should hit and apply spikes", async () => { + await game.classicMode.startBattle([Species.ILLUMISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyStartingHp = enemyPokemon.hp; + const enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.CEASELESS_EDGE); + game.move.select(Moves.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); - // Spikes should not have any layers before move effect is applied - const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); + await game.phaseInterceptor.to(MoveEffectPhase, false); + // Spikes should not have any layers before move effect is applied + const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); - await game.phaseInterceptor.to(TurnEndPhase); - const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); - expect(tagAfter.layers).toBe(1); - expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); + expect(tagAfter.layers).toBe(1); + expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); + }); - test( - "move should hit twice with multi lens and apply two layers of spikes", - async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS" }]); - await game.classicMode.startBattle([ Species.ILLUMISE ]); + test("move should hit twice with multi lens and apply two layers of spikes", async () => { + game.override.startingHeldItems([{ name: "MULTI_LENS" }]); + await game.classicMode.startBattle([Species.ILLUMISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyStartingHp = enemyPokemon.hp; + const enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.CEASELESS_EDGE); + game.move.select(Moves.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); - // Spikes should not have any layers before move effect is applied - const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); + await game.phaseInterceptor.to(MoveEffectPhase, false); + // Spikes should not have any layers before move effect is applied + const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); - await game.phaseInterceptor.to(TurnEndPhase); - const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); - expect(tagAfter.layers).toBe(2); - expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); + expect(tagAfter.layers).toBe(2); + expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); + }); - test( - "trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", - async () => { - game.override.startingHeldItems([{ name: "MULTI_LENS" }]); - game.override.startingWave(25); + test("trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", async () => { + game.override.startingHeldItems([{ name: "MULTI_LENS" }]); + game.override.startingWave(25); - await game.classicMode.startBattle([ Species.ILLUMISE ]); + await game.classicMode.startBattle([Species.ILLUMISE]); - game.move.select(Moves.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); - // Spikes should not have any layers before move effect is applied - const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); + game.move.select(Moves.CEASELESS_EDGE); + await game.phaseInterceptor.to(MoveEffectPhase, false); + // Spikes should not have any layers before move effect is applied + const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); - await game.toNextTurn(); - const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; - expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); - expect(tagAfter.layers).toBe(2); + await game.toNextTurn(); + const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; + expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); + expect(tagAfter.layers).toBe(2); - const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp; - // Check HP of pokemon that WILL BE switched in (index 1) - game.forceEnemyToSwitch(); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); - expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes); - } - ); + const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp; + // Check HP of pokemon that WILL BE switched in (index 1) + game.forceEnemyToSwitch(); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(TurnEndPhase, false); + expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes); + }); }); diff --git a/test/moves/chilly_reception.test.ts b/test/moves/chilly_reception.test.ts index 0d99175a9bc..f90aaf6bb02 100644 --- a/test/moves/chilly_reception.test.ts +++ b/test/moves/chilly_reception.test.ts @@ -23,16 +23,16 @@ describe("Moves - Chilly Reception", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") - .moveset([ Moves.CHILLY_RECEPTION, Moves.SNOWSCAPE ]) + game.override + .battleType("single") + .moveset([Moves.CHILLY_RECEPTION, Moves.SNOWSCAPE]) .enemyMoveset(Array(4).fill(Moves.SPLASH)) .enemyAbility(Abilities.NONE) .ability(Abilities.NONE); - }); it("should still change the weather if user can't switch out", async () => { - await game.classicMode.startBattle([ Species.SLOWKING ]); + await game.classicMode.startBattle([Species.SLOWKING]); game.move.select(Moves.CHILLY_RECEPTION); @@ -41,7 +41,7 @@ describe("Moves - Chilly Reception", () => { }); it("should switch out even if it's snowing", async () => { - await game.classicMode.startBattle([ Species.SLOWKING, Species.MEOWTH ]); + await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]); // first turn set up snow with snowscape, try chilly reception on second turn game.move.select(Moves.SNOWSCAPE); await game.phaseInterceptor.to("BerryPhase", false); @@ -57,8 +57,7 @@ describe("Moves - Chilly Reception", () => { }); it("happy case - switch out and weather changes", async () => { - - await game.classicMode.startBattle([ Species.SLOWKING, Species.MEOWTH ]); + await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]); game.move.select(Moves.CHILLY_RECEPTION); game.doSelectPartyPokemon(1); @@ -70,12 +69,13 @@ describe("Moves - Chilly Reception", () => { // enemy uses another move and weather doesn't change it("check case - enemy not selecting chilly reception doesn't change weather ", async () => { - game.override.battleType("single") - .enemyMoveset([ Moves.CHILLY_RECEPTION, Moves.TACKLE ]) + game.override + .battleType("single") + .enemyMoveset([Moves.CHILLY_RECEPTION, Moves.TACKLE]) .enemyAbility(Abilities.NONE) .moveset(Array(4).fill(Moves.SPLASH)); - await game.classicMode.startBattle([ Species.SLOWKING, Species.MEOWTH ]); + await game.classicMode.startBattle([Species.SLOWKING, Species.MEOWTH]); game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.TACKLE); @@ -85,14 +85,15 @@ describe("Moves - Chilly Reception", () => { }); it("enemy trainer - expected behavior ", async () => { - game.override.battleType("single") + game.override + .battleType("single") .startingWave(8) .enemyMoveset(Array(4).fill(Moves.CHILLY_RECEPTION)) .enemyAbility(Abilities.NONE) .enemySpecies(Species.MAGIKARP) - .moveset([ Moves.SPLASH, Moves.THUNDERBOLT ]); + .moveset([Moves.SPLASH, Moves.THUNDERBOLT]); - await game.classicMode.startBattle([ Species.JOLTEON ]); + await game.classicMode.startBattle([Species.JOLTEON]); const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id; game.move.select(Moves.SPLASH); @@ -119,6 +120,5 @@ describe("Moves - Chilly Reception", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("BerryPhase", false); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW); - }); }); diff --git a/test/moves/chloroblast.test.ts b/test/moves/chloroblast.test.ts index ee01935291a..f08eca100c4 100644 --- a/test/moves/chloroblast.test.ts +++ b/test/moves/chloroblast.test.ts @@ -22,7 +22,7 @@ describe("Moves - Chloroblast", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.CHLOROBLAST ]) + .moveset([Moves.CHLOROBLAST]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -32,7 +32,7 @@ describe("Moves - Chloroblast", () => { }); it("should not deal recoil damage if the opponent uses protect", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.CHLOROBLAST); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/clangorous_soul.test.ts b/test/moves/clangorous_soul.test.ts index 6bb50b9ba59..56f19a0e088 100644 --- a/test/moves/clangorous_soul.test.ts +++ b/test/moves/clangorous_soul.test.ts @@ -6,7 +6,6 @@ import { Moves } from "#enums/moves"; import { Species } from "#enums/species"; import { Stat } from "#enums/stat"; - /** HP Cost of Move */ const RATIO = 3; /** Amount of extra HP lost */ @@ -32,97 +31,89 @@ describe("Moves - Clangorous Soul", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.CLANGOROUS_SOUL ]); + game.override.moveset([Moves.CLANGOROUS_SOUL]); game.override.enemyMoveset(Moves.SPLASH); }); //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Clangorous_Soul_(move) - it("raises the user's ATK, DEF, SPATK, SPDEF, and SPD stat stages by 1 each at the cost of 1/3 of its maximum HP", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + it("raises the user's ATK, DEF, SPATK, SPDEF, and SPD stat stages by 1 each at the cost of 1/3 of its maximum HP", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); - game.move.select(Moves.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CLANGOROUS_SOUL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(1); - expect(leadPokemon.getStatStage(Stat.DEF)).toBe(1); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(1); - expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(1); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(1); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(1); + expect(leadPokemon.getStatStage(Stat.DEF)).toBe(1); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(1); + expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(1); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(1); + }); - it("will still take effect if one or more of the involved stat stages are not at max", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + it("will still take effect if one or more of the involved stat stages are not at max", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); - //Here - Stat.SPD -> 0 and Stat.SPDEF -> 4 - leadPokemon.setStatStage(Stat.ATK, 6); - leadPokemon.setStatStage(Stat.DEF, 6); - leadPokemon.setStatStage(Stat.SPATK, 6); - leadPokemon.setStatStage(Stat.SPDEF, 4); + //Here - Stat.SPD -> 0 and Stat.SPDEF -> 4 + leadPokemon.setStatStage(Stat.ATK, 6); + leadPokemon.setStatStage(Stat.DEF, 6); + leadPokemon.setStatStage(Stat.SPATK, 6); + leadPokemon.setStatStage(Stat.SPDEF, 4); - game.move.select(Moves.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CLANGOROUS_SOUL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.DEF)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(5); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(1); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.DEF)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(5); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(1); + }); - it("fails if all stat stages involved are at max", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + it("fails if all stat stages involved are at max", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.setStatStage(Stat.ATK, 6); - leadPokemon.setStatStage(Stat.DEF, 6); - leadPokemon.setStatStage(Stat.SPATK, 6); - leadPokemon.setStatStage(Stat.SPDEF, 6); - leadPokemon.setStatStage(Stat.SPD, 6); + leadPokemon.setStatStage(Stat.ATK, 6); + leadPokemon.setStatStage(Stat.DEF, 6); + leadPokemon.setStatStage(Stat.SPATK, 6); + leadPokemon.setStatStage(Stat.SPDEF, 6); + leadPokemon.setStatStage(Stat.SPD, 6); - game.move.select(Moves.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CLANGOROUS_SOUL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.DEF)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(6); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.DEF)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(6); + }); - it("fails if the user's health is less than 1/3", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + it("fails if the user's health is less than 1/3", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); - leadPokemon.hp = hpLost - PREDAMAGE; + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); + leadPokemon.hp = hpLost - PREDAMAGE; - game.move.select(Moves.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.CLANGOROUS_SOUL); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); - expect(leadPokemon.getStatStage(Stat.DEF)).toBe(0); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(0); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(0); - } - ); + expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(leadPokemon.getStatStage(Stat.DEF)).toBe(0); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(0); + expect(leadPokemon.getStatStage(Stat.SPDEF)).toBe(0); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(0); + }); }); diff --git a/test/moves/copycat.test.ts b/test/moves/copycat.test.ts index f682aeb7b5e..c7242f0940e 100644 --- a/test/moves/copycat.test.ts +++ b/test/moves/copycat.test.ts @@ -28,7 +28,7 @@ describe("Moves - Copycat", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.COPYCAT, Moves.SPIKY_SHIELD, Moves.SWORDS_DANCE, Moves.SPLASH ]) + .moveset([Moves.COPYCAT, Moves.SPIKY_SHIELD, Moves.SWORDS_DANCE, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -65,14 +65,12 @@ describe("Moves - Copycat", () => { }); it("should copy the called move when the last move successfully calls another", async () => { - game.override - .moveset([ Moves.SPLASH, Moves.METRONOME ]) - .enemyMoveset(Moves.COPYCAT); + game.override.moveset([Moves.SPLASH, Moves.METRONOME]).enemyMoveset(Moves.COPYCAT); await game.classicMode.startBattle(); vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.SWORDS_DANCE); game.move.select(Moves.METRONOME); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); // Player moves first, so enemy can copy Swords Dance + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); // Player moves first, so enemy can copy Swords Dance await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(2); @@ -83,7 +81,7 @@ describe("Moves - Copycat", () => { await game.classicMode.startBattle(); game.move.select(Moves.COPYCAT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPDEF)).toBe(-2); diff --git a/test/moves/crafty_shield.test.ts b/test/moves/crafty_shield.test.ts index 054d19debf8..3a2df6a3446 100644 --- a/test/moves/crafty_shield.test.ts +++ b/test/moves/crafty_shield.test.ts @@ -9,7 +9,6 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BerryPhase } from "#app/phases/berry-phase"; import { CommandPhase } from "#app/phases/command-phase"; - describe("Moves - Crafty Shield", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,95 +28,83 @@ describe("Moves - Crafty Shield", () => { game.override.battleType("double"); - game.override.moveset([ Moves.CRAFTY_SHIELD, Moves.SPLASH, Moves.SWORDS_DANCE ]); + game.override.moveset([Moves.CRAFTY_SHIELD, Moves.SPLASH, Moves.SWORDS_DANCE]); game.override.enemySpecies(Species.SNORLAX); - game.override.enemyMoveset([ Moves.GROWL ]); + game.override.enemyMoveset([Moves.GROWL]); game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user and allies from status moves", - async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + test("should protect the user and allies from status moves", async () => { + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.CRAFTY_SHIELD); + game.move.select(Moves.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); - } - ); + leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); + }); - test( - "should not protect the user and allies from attack moves", - async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + test("should not protect the user and allies from attack moves", async () => { + game.override.enemyMoveset([Moves.TACKLE]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.CRAFTY_SHIELD); + game.move.select(Moves.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); - } - ); + expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); + }); - test( - "should protect the user and allies from moves that ignore other protection", - async () => { - game.override.enemySpecies(Species.DUSCLOPS); - game.override.enemyMoveset([ Moves.CURSE ]); + test("should protect the user and allies from moves that ignore other protection", async () => { + game.override.enemySpecies(Species.DUSCLOPS); + game.override.enemyMoveset([Moves.CURSE]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.CRAFTY_SHIELD); + game.move.select(Moves.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined()); - } - ); + leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined()); + }); - test( - "should not block allies' self-targeted moves", - async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + test("should not block allies' self-targeted moves", async () => { + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.CRAFTY_SHIELD); + game.move.select(Moves.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SWORDS_DANCE, 1); + game.move.select(Moves.SWORDS_DANCE, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0); - expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2); - } - ); + expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0); + expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2); + }); }); diff --git a/test/moves/defog.test.ts b/test/moves/defog.test.ts index 52c51df657a..64904e964c4 100644 --- a/test/moves/defog.test.ts +++ b/test/moves/defog.test.ts @@ -23,17 +23,17 @@ describe("Moves - Defog", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.MIST, Moves.SAFEGUARD, Moves.SPLASH ]) + .moveset([Moves.MIST, Moves.SAFEGUARD, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() .enemySpecies(Species.SHUCKLE) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.DEFOG, Moves.GROWL ]); + .enemyMoveset([Moves.DEFOG, Moves.GROWL]); }); it("should not allow Safeguard to be active", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerField(); const enemyPokemon = game.scene.getEnemyField(); @@ -44,13 +44,11 @@ describe("Moves - Defog", () => { expect(playerPokemon[0].isSafeguarded(enemyPokemon[0])).toBe(false); - expect(true).toBe(true); }); - it("should not allow Mist to be active", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerField(); diff --git a/test/moves/destiny_bond.test.ts b/test/moves/destiny_bond.test.ts index a64065178ce..c39d40427ad 100644 --- a/test/moves/destiny_bond.test.ts +++ b/test/moves/destiny_bond.test.ts @@ -12,14 +12,13 @@ import { BattlerIndex } from "#app/battle"; import { StatusEffect } from "#enums/status-effect"; import { PokemonInstantReviveModifier } from "#app/modifier/modifier"; - describe("Moves - Destiny Bond", () => { let phaserGame: Phaser.Game; let game: GameManager; - const defaultParty = [ Species.BULBASAUR, Species.SQUIRTLE ]; - const enemyFirst = [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]; - const playerFirst = [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]; + const defaultParty = [Species.BULBASAUR, Species.SQUIRTLE]; + const enemyFirst = [BattlerIndex.ENEMY, BattlerIndex.PLAYER]; + const playerFirst = [BattlerIndex.PLAYER, BattlerIndex.ENEMY]; beforeAll(() => { phaserGame = new Phaser.Game({ @@ -33,7 +32,8 @@ describe("Moves - Destiny Bond", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .ability(Abilities.UNNERVE) // Pre-emptively prevent flakiness from opponent berries .enemySpecies(Species.RATTATA) .enemyAbility(Abilities.RUN_AWAY) @@ -62,7 +62,7 @@ describe("Moves - Destiny Bond", () => { it("should KO the opponent on the next turn", async () => { const moveToUse = Moves.TACKLE; - game.override.moveset([ Moves.SPLASH, moveToUse ]); + game.override.moveset([Moves.SPLASH, moveToUse]); await game.classicMode.startBattle(defaultParty); const enemyPokemon = game.scene.getEnemyPokemon(); @@ -88,7 +88,7 @@ describe("Moves - Destiny Bond", () => { it("should fail if used twice in a row", async () => { const moveToUse = Moves.TACKLE; - game.override.moveset([ Moves.SPLASH, moveToUse ]); + game.override.moveset([Moves.SPLASH, moveToUse]); await game.classicMode.startBattle(defaultParty); const enemyPokemon = game.scene.getEnemyPokemon(); @@ -115,8 +115,7 @@ describe("Moves - Destiny Bond", () => { // Opponent will be reduced to 1 HP by False Swipe, then faint to Sandstorm const moveToUse = Moves.FALSE_SWIPE; - game.override.moveset(moveToUse) - .ability(Abilities.SAND_STREAM); + game.override.moveset(moveToUse).ability(Abilities.SAND_STREAM); await game.classicMode.startBattle(defaultParty); const enemyPokemon = game.scene.getEnemyPokemon(); @@ -133,7 +132,7 @@ describe("Moves - Destiny Bond", () => { it("should not KO the opponent if the user had another turn", async () => { const moveToUse = Moves.TACKLE; - game.override.moveset([ Moves.SPORE, moveToUse ]); + game.override.moveset([Moves.SPORE, moveToUse]); await game.classicMode.startBattle(defaultParty); const enemyPokemon = game.scene.getEnemyPokemon(); @@ -158,9 +157,8 @@ describe("Moves - Destiny Bond", () => { }); it("should not KO an ally", async () => { - game.override.moveset([ Moves.DESTINY_BOND, Moves.CRUNCH ]) - .battleType("double"); - await game.classicMode.startBattle([ Species.SHEDINJA, Species.BULBASAUR, Species.SQUIRTLE ]); + game.override.moveset([Moves.DESTINY_BOND, Moves.CRUNCH]).battleType("double"); + await game.classicMode.startBattle([Species.SHEDINJA, Species.BULBASAUR, Species.SQUIRTLE]); const enemyPokemon0 = game.scene.getEnemyField()[0]; const enemyPokemon1 = game.scene.getEnemyField()[1]; @@ -170,7 +168,7 @@ describe("Moves - Destiny Bond", () => { // Shedinja uses Destiny Bond, then ally Bulbasaur KO's Shedinja with Crunch game.move.select(Moves.DESTINY_BOND, 0); game.move.select(Moves.CRUNCH, 1, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon0?.isFainted()).toBe(false); @@ -203,8 +201,7 @@ describe("Moves - Destiny Bond", () => { }); it("should not cause a crash if the user is KO'd by Pledge moves", async () => { - game.override.moveset([ Moves.GRASS_PLEDGE, Moves.WATER_PLEDGE ]) - .battleType("double"); + game.override.moveset([Moves.GRASS_PLEDGE, Moves.WATER_PLEDGE]).battleType("double"); await game.classicMode.startBattle(defaultParty); const enemyPokemon0 = game.scene.getEnemyField()[0]; @@ -214,7 +211,7 @@ describe("Moves - Destiny Bond", () => { game.move.select(Moves.GRASS_PLEDGE, 0, BattlerIndex.ENEMY); game.move.select(Moves.WATER_PLEDGE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon0?.isFainted()).toBe(true); @@ -235,8 +232,7 @@ describe("Moves - Destiny Bond", () => { it("should not allow the opponent to revive via Reviver Seed", async () => { const moveToUse = Moves.TACKLE; - game.override.moveset(moveToUse) - .startingHeldItems([{ name: "REVIVER_SEED" }]); + game.override.moveset(moveToUse).startingHeldItems([{ name: "REVIVER_SEED" }]); await game.classicMode.startBattle(defaultParty); const enemyPokemon = game.scene.getEnemyPokemon(); @@ -250,7 +246,9 @@ describe("Moves - Destiny Bond", () => { expect(playerPokemon?.isFainted()).toBe(true); // Check that the Tackle user's Reviver Seed did not activate - const revSeeds = game.scene.getModifiers(PokemonInstantReviveModifier).filter(m => m.pokemonId === playerPokemon?.id); + const revSeeds = game.scene + .getModifiers(PokemonInstantReviveModifier) + .filter(m => m.pokemonId === playerPokemon?.id); expect(revSeeds.length).toBe(1); }); }); diff --git a/test/moves/diamond_storm.test.ts b/test/moves/diamond_storm.test.ts index 3c81f8221ba..2363122f0d7 100644 --- a/test/moves/diamond_storm.test.ts +++ b/test/moves/diamond_storm.test.ts @@ -24,7 +24,7 @@ describe("Moves - Diamond Storm", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.DIAMOND_STORM ]) + .moveset([Moves.DIAMOND_STORM]) .battleType("single") .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) @@ -36,7 +36,7 @@ describe("Moves - Diamond Storm", () => { const diamondStorm = allMoves[Moves.DIAMOND_STORM]; vi.spyOn(diamondStorm, "chance", "get").mockReturnValue(100); vi.spyOn(diamondStorm, "accuracy", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.DIAMOND_STORM); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/dig.test.ts b/test/moves/dig.test.ts index d9cf4845a67..81339111656 100644 --- a/test/moves/dig.test.ts +++ b/test/moves/dig.test.ts @@ -36,7 +36,7 @@ describe("Moves - Dig", () => { }); it("should make the user semi-invulnerable, then attack over 2 turns", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -62,7 +62,7 @@ describe("Moves - Dig", () => { it("should not allow the user to evade attacks from Pokemon with No Guard", async () => { game.override.enemyAbility(Abilities.NO_GUARD); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -75,11 +75,9 @@ describe("Moves - Dig", () => { }); it("should not expend PP when the attack phase is cancelled", async () => { - game.override - .enemyAbility(Abilities.NO_GUARD) - .enemyMoveset(Moves.SPORE); + game.override.enemyAbility(Abilities.NO_GUARD).enemyMoveset(Moves.SPORE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -94,7 +92,7 @@ describe("Moves - Dig", () => { }); it("should cause the user to take double damage from Earthquake", async () => { - await game.classicMode.startBattle([ Species.DONDOZO ]); + await game.classicMode.startBattle([Species.DONDOZO]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -102,7 +100,7 @@ describe("Moves - Dig", () => { const preDigEarthquakeDmg = playerPokemon.getAttackDamage(enemyPokemon, allMoves[Moves.EARTHQUAKE]).damage; game.move.select(Moves.DIG); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); diff --git a/test/moves/disable.test.ts b/test/moves/disable.test.ts index 044cfc762cd..fdfb748df9d 100644 --- a/test/moves/disable.test.ts +++ b/test/moves/disable.test.ts @@ -12,7 +12,7 @@ describe("Moves - Disable", () => { beforeAll(() => { phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS + type: Phaser.HEADLESS, }); }); @@ -26,7 +26,7 @@ describe("Moves - Disable", () => { .battleType("single") .ability(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.DISABLE, Moves.SPLASH ]) + .moveset([Moves.DISABLE, Moves.SPLASH]) .enemyMoveset(Moves.SPLASH) .starterSpecies(Species.PIKACHU) .enemySpecies(Species.SHUCKLE); @@ -38,34 +38,37 @@ describe("Moves - Disable", () => { const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyMon.getMoveHistory()).toHaveLength(1); expect(enemyMon.isMoveRestricted(Moves.SPLASH)).toBe(true); }); - it("fails if enemy has no move history", async() => { + it("fails if enemy has no move history", async () => { await game.classicMode.startBattle(); const playerMon = game.scene.getPlayerPokemon()!; const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); - expect(playerMon.getMoveHistory()[0]).toMatchObject({ move: Moves.DISABLE, result: MoveResult.FAIL }); + expect(playerMon.getMoveHistory()[0]).toMatchObject({ + move: Moves.DISABLE, + result: MoveResult.FAIL, + }); expect(enemyMon.isMoveRestricted(Moves.SPLASH)).toBe(false); }, 20000); - it("causes STRUGGLE if all usable moves are disabled", async() => { + it("causes STRUGGLE if all usable moves are disabled", async () => { await game.classicMode.startBattle(); const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); game.move.select(Moves.SPLASH); @@ -77,15 +80,15 @@ describe("Moves - Disable", () => { expect(enemyHistory[1].move).toBe(Moves.STRUGGLE); }, 20000); - it("cannot disable STRUGGLE", async() => { - game.override.enemyMoveset([ Moves.STRUGGLE ]); + it("cannot disable STRUGGLE", async () => { + game.override.enemyMoveset([Moves.STRUGGLE]); await game.classicMode.startBattle(); const playerMon = game.scene.getPlayerPokemon()!; const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(playerMon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); @@ -93,7 +96,7 @@ describe("Moves - Disable", () => { expect(enemyMon.isMoveRestricted(Moves.STRUGGLE)).toBe(false); }, 20000); - it("interrupts target's move when target moves after", async() => { + it("interrupts target's move when target moves after", async () => { await game.classicMode.startBattle(); const enemyMon = game.scene.getEnemyPokemon()!; @@ -103,43 +106,46 @@ describe("Moves - Disable", () => { // Both mons just used Splash last turn; now have player use Disable. game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); const enemyHistory = enemyMon.getMoveHistory(); expect(enemyHistory).toHaveLength(2); - expect(enemyHistory[0]).toMatchObject({ move: Moves.SPLASH, result: MoveResult.SUCCESS }); + expect(enemyHistory[0]).toMatchObject({ + move: Moves.SPLASH, + result: MoveResult.SUCCESS, + }); expect(enemyHistory[1].result).toBe(MoveResult.FAIL); }, 20000); - it("disables NATURE POWER, not the move invoked by it", async() => { - game.override.enemyMoveset([ Moves.NATURE_POWER ]); + it("disables NATURE POWER, not the move invoked by it", async () => { + game.override.enemyMoveset([Moves.NATURE_POWER]); await game.classicMode.startBattle(); const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.DISABLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyMon.isMoveRestricted(Moves.NATURE_POWER)).toBe(true); expect(enemyMon.isMoveRestricted(enemyMon.getLastXMoves(2)[0].move)).toBe(false); }, 20000); - it("disables most recent move", async() => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.TACKLE ]); + it("disables most recent move", async () => { + game.override.enemyMoveset([Moves.SPLASH, Moves.TACKLE]); await game.classicMode.startBattle(); const enemyMon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); game.move.select(Moves.DISABLE); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyMon.isMoveRestricted(Moves.TACKLE)).toBe(true); diff --git a/test/moves/dive.test.ts b/test/moves/dive.test.ts index e8febaa72f6..8d7b0f9dd00 100644 --- a/test/moves/dive.test.ts +++ b/test/moves/dive.test.ts @@ -36,7 +36,7 @@ describe("Moves - Dive", () => { }); it("should make the user semi-invulnerable, then attack over 2 turns", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -62,7 +62,7 @@ describe("Moves - Dive", () => { it("should not allow the user to evade attacks from Pokemon with No Guard", async () => { game.override.enemyAbility(Abilities.NO_GUARD); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -75,11 +75,9 @@ describe("Moves - Dive", () => { }); it("should not expend PP when the attack phase is cancelled", async () => { - game.override - .enemyAbility(Abilities.NO_GUARD) - .enemyMoveset(Moves.SPORE); + game.override.enemyAbility(Abilities.NO_GUARD).enemyMoveset(Moves.SPORE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -94,11 +92,9 @@ describe("Moves - Dive", () => { }); it("should trigger on-contact post-defend ability effects", async () => { - game.override - .enemyAbility(Abilities.ROUGH_SKIN) - .enemyMoveset(Moves.SPLASH); + game.override.enemyAbility(Abilities.ROUGH_SKIN).enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -115,7 +111,7 @@ describe("Moves - Dive", () => { it("should cancel attack after Harsh Sunlight is set", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/moves/doodle.test.ts b/test/moves/doodle.test.ts index 6272a822094..822e415c918 100644 --- a/test/moves/doodle.test.ts +++ b/test/moves/doodle.test.ts @@ -24,7 +24,7 @@ describe("Moves - Doodle", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.DOODLE ]) + .moveset([Moves.SPLASH, Moves.DOODLE]) .ability(Abilities.ADAPTABILITY) .battleType("single") .disableCrits() @@ -34,7 +34,7 @@ describe("Moves - Doodle", () => { }); it("should copy the opponent's ability in singles", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.DOODLE); await game.phaseInterceptor.to("BerryPhase"); @@ -44,7 +44,7 @@ describe("Moves - Doodle", () => { it("should copy the opponent's ability to itself and its ally in doubles", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); game.move.select(Moves.DOODLE, 0, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1); @@ -55,10 +55,9 @@ describe("Moves - Doodle", () => { }); it("should activate post-summon abilities", async () => { - game.override.battleType("double") - .enemyAbility(Abilities.INTIMIDATE); + game.override.battleType("double").enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); game.move.select(Moves.DOODLE, 0, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1); diff --git a/test/moves/double_team.test.ts b/test/moves/double_team.test.ts index 9145265bf93..f6791573132 100644 --- a/test/moves/double_team.test.ts +++ b/test/moves/double_team.test.ts @@ -24,16 +24,16 @@ describe("Moves - Double Team", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.moveset([ Moves.DOUBLE_TEAM ]); + game.override.moveset([Moves.DOUBLE_TEAM]); game.override.disableCrits(); game.override.ability(Abilities.BALL_FETCH); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemyMoveset([ Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); }); it("raises the user's EVA stat stage by 1", async () => { - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const ally = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -46,6 +46,6 @@ describe("Moves - Double Team", () => { await game.toNextTurn(); expect(ally.getStatStage(Stat.EVA)).toBe(1); - expect(enemy.getAccuracyMultiplier).toHaveReturnedWith(.75); + expect(enemy.getAccuracyMultiplier).toHaveReturnedWith(0.75); }); }); diff --git a/test/moves/dragon_cheer.test.ts b/test/moves/dragon_cheer.test.ts index 0c5b0d69675..30d5af3a51b 100644 --- a/test/moves/dragon_cheer.test.ts +++ b/test/moves/dragon_cheer.test.ts @@ -27,11 +27,11 @@ describe("Moves - Dragon Cheer", () => { .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) .enemyLevel(20) - .moveset([ Moves.DRAGON_CHEER, Moves.TACKLE, Moves.SPLASH ]); + .moveset([Moves.DRAGON_CHEER, Moves.TACKLE, Moves.SPLASH]); }); it("increases the user's allies' critical hit ratio by one stage", async () => { - await game.classicMode.startBattle([ Species.DRAGONAIR, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.DRAGONAIR, Species.MAGIKARP]); const enemy = game.scene.getEnemyField()[0]; @@ -40,7 +40,7 @@ describe("Moves - Dragon Cheer", () => { game.move.select(Moves.DRAGON_CHEER, 0); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); // After Tackle await game.phaseInterceptor.to("TurnEndPhase"); @@ -48,7 +48,7 @@ describe("Moves - Dragon Cheer", () => { }); it("increases the user's Dragon-type allies' critical hit ratio by two stages", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.DRAGONAIR ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.DRAGONAIR]); const enemy = game.scene.getEnemyField()[0]; @@ -57,7 +57,7 @@ describe("Moves - Dragon Cheer", () => { game.move.select(Moves.DRAGON_CHEER, 0); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); // After Tackle await game.phaseInterceptor.to("TurnEndPhase"); @@ -65,7 +65,7 @@ describe("Moves - Dragon Cheer", () => { }); it("applies the effect based on the allies' type upon use of the move, and do not change if the allies' type changes later in battle", async () => { - await game.classicMode.startBattle([ Species.DRAGONAIR, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.DRAGONAIR, Species.MAGIKARP]); const magikarp = game.scene.getPlayerField()[1]; const enemy = game.scene.getEnemyField()[0]; @@ -75,7 +75,7 @@ describe("Moves - Dragon Cheer", () => { game.move.select(Moves.DRAGON_CHEER, 0); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); // After Tackle await game.phaseInterceptor.to("TurnEndPhase"); @@ -84,13 +84,13 @@ describe("Moves - Dragon Cheer", () => { await game.toNextTurn(); // Change Magikarp's type to Dragon - vi.spyOn(magikarp, "getTypes").mockReturnValue([ PokemonType.DRAGON ]); - expect(magikarp.getTypes()).toEqual([ PokemonType.DRAGON ]); + vi.spyOn(magikarp, "getTypes").mockReturnValue([PokemonType.DRAGON]); + expect(magikarp.getTypes()).toEqual([PokemonType.DRAGON]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.getCritStage).toHaveReturnedWith(1); // getCritStage is called on defender diff --git a/test/moves/dragon_rage.test.ts b/test/moves/dragon_rage.test.ts index 6540bc2f327..99d66421463 100644 --- a/test/moves/dragon_rage.test.ts +++ b/test/moves/dragon_rage.test.ts @@ -34,7 +34,7 @@ describe("Moves - Dragon Rage", () => { game.override.battleType("single"); game.override.starterSpecies(Species.SNORLAX); - game.override.moveset([ Moves.DRAGON_RAGE ]); + game.override.moveset([Moves.DRAGON_RAGE]); game.override.ability(Abilities.BALL_FETCH); game.override.passiveAbility(Abilities.BALL_FETCH); game.override.startingLevel(100); @@ -53,7 +53,7 @@ describe("Moves - Dragon Rage", () => { it("ignores weaknesses", async () => { game.override.disableCrits(); - vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([ PokemonType.DRAGON ]); + vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([PokemonType.DRAGON]); game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); @@ -63,7 +63,7 @@ describe("Moves - Dragon Rage", () => { it("ignores resistances", async () => { game.override.disableCrits(); - vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([ PokemonType.STEEL ]); + vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([PokemonType.STEEL]); game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); @@ -83,7 +83,7 @@ describe("Moves - Dragon Rage", () => { it("ignores stab", async () => { game.override.disableCrits(); - vi.spyOn(partyPokemon, "getTypes").mockReturnValue([ PokemonType.DRAGON ]); + vi.spyOn(partyPokemon, "getTypes").mockReturnValue([PokemonType.DRAGON]); game.move.select(Moves.DRAGON_RAGE); await game.phaseInterceptor.to(TurnEndPhase); diff --git a/test/moves/dragon_tail.test.ts b/test/moves/dragon_tail.test.ts index 545ad9fe8eb..37e8aa2fe1b 100644 --- a/test/moves/dragon_tail.test.ts +++ b/test/moves/dragon_tail.test.ts @@ -27,8 +27,9 @@ describe("Moves - Dragon Tail", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") - .moveset([ Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER ]) + game.override + .battleType("single") + .moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]) .enemySpecies(Species.WAILORD) .enemyMoveset(Moves.SPLASH) .startingLevel(5) @@ -38,7 +39,7 @@ describe("Moves - Dragon Tail", () => { }); it("should cause opponent to flee, and not crash", async () => { - await game.classicMode.startBattle([ Species.DRATINI ]); + await game.classicMode.startBattle([Species.DRATINI]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -56,7 +57,7 @@ describe("Moves - Dragon Tail", () => { it("should cause opponent to flee, display ability, and not crash", async () => { game.override.enemyAbility(Abilities.ROUGH_SKIN); - await game.classicMode.startBattle([ Species.DRATINI ]); + await game.classicMode.startBattle([Species.DRATINI]); const leadPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -72,10 +73,8 @@ describe("Moves - Dragon Tail", () => { }); it("should proceed without crashing in a double battle", async () => { - game.override - .battleType("double").enemyMoveset(Moves.SPLASH) - .enemyAbility(Abilities.ROUGH_SKIN); - await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]); + game.override.battleType("double").enemyMoveset(Moves.SPLASH).enemyAbility(Abilities.ROUGH_SKIN); + await game.classicMode.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]); const leadPokemon = game.scene.getPlayerParty()[0]!; @@ -103,11 +102,8 @@ describe("Moves - Dragon Tail", () => { }); it("should redirect targets upon opponent flee", async () => { - game.override - .battleType("double") - .enemyMoveset(Moves.SPLASH) - .enemyAbility(Abilities.ROUGH_SKIN); - await game.classicMode.startBattle([ Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD ]); + game.override.battleType("double").enemyMoveset(Moves.SPLASH).enemyAbility(Abilities.ROUGH_SKIN); + await game.classicMode.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]); const leadPokemon = game.scene.getPlayerParty()[0]!; const secPokemon = game.scene.getPlayerParty()[1]!; @@ -134,7 +130,7 @@ describe("Moves - Dragon Tail", () => { it("doesn't switch out if the target has suction cups", async () => { game.override.enemyAbility(Abilities.SUCTION_CUPS); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const enemy = game.scene.getEnemyPokemon()!; @@ -145,9 +141,8 @@ describe("Moves - Dragon Tail", () => { }); it("should force a switch upon fainting an opponent normally", async () => { - game.override.startingWave(5) - .startingLevel(1000); // To make sure Dragon Tail KO's the opponent - await game.classicMode.startBattle([ Species.DRATINI ]); + game.override.startingWave(5).startingLevel(1000); // To make sure Dragon Tail KO's the opponent + await game.classicMode.startBattle([Species.DRATINI]); game.move.select(Moves.DRAGON_TAIL); @@ -165,10 +160,11 @@ describe("Moves - Dragon Tail", () => { }); it("should not cause a softlock when activating an opponent trainer's reviver seed", async () => { - game.override.startingWave(5) + game.override + .startingWave(5) .enemyHeldItems([{ name: "REVIVER_SEED" }]) .startingLevel(1000); // To make sure Dragon Tail KO's the opponent - await game.classicMode.startBattle([ Species.DRATINI ]); + await game.classicMode.startBattle([Species.DRATINI]); game.move.select(Moves.DRAGON_TAIL); @@ -182,10 +178,11 @@ describe("Moves - Dragon Tail", () => { }); it("should not cause a softlock when activating a player's reviver seed", async () => { - game.override.startingHeldItems([{ name: "REVIVER_SEED" }]) + game.override + .startingHeldItems([{ name: "REVIVER_SEED" }]) .enemyMoveset(Moves.DRAGON_TAIL) .enemyLevel(1000); // To make sure Dragon Tail KO's the player - await game.classicMode.startBattle([ Species.DRATINI, Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.DRATINI, Species.BULBASAUR]); game.move.select(Moves.SPLASH); @@ -199,15 +196,13 @@ describe("Moves - Dragon Tail", () => { }); it("should force switches randomly", async () => { - game.override.enemyMoveset(Moves.DRAGON_TAIL) - .startingLevel(100) - .enemyLevel(1); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + game.override.enemyMoveset(Moves.DRAGON_TAIL).startingLevel(100).enemyLevel(1); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); - const [ bulbasaur, charmander, squirtle ] = game.scene.getPlayerParty(); + const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty(); // Turn 1: Mock an RNG call that calls for switching to 1st backup Pokemon (Charmander) - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -220,7 +215,7 @@ describe("Moves - Dragon Tail", () => { expect(bulbasaur.getInverseHp()).toBeGreaterThan(0); // Turn 2: Mock an RNG call that calls for switching to 2nd backup Pokemon (Squirtle) - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min + 1; }); game.move.select(Moves.SPLASH); @@ -233,17 +228,15 @@ describe("Moves - Dragon Tail", () => { }); it("should not force a switch to a challenge-ineligible Pokemon", async () => { - game.override.enemyMoveset(Moves.DRAGON_TAIL) - .startingLevel(100) - .enemyLevel(1); + game.override.enemyMoveset(Moves.DRAGON_TAIL).startingLevel(100).enemyLevel(1); // Mono-Water challenge, Eevee is ineligible game.challengeMode.addChallenge(Challenges.SINGLE_TYPE, PokemonType.WATER + 1, 0); - await game.challengeMode.startBattle([ Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA ]); + await game.challengeMode.startBattle([Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA]); - const [ lapras, eevee, toxapex, primarina ] = game.scene.getPlayerParty(); + const [lapras, eevee, toxapex, primarina] = game.scene.getPlayerParty(); // Turn 1: Mock an RNG call that would normally call for switching to Eevee, but it is ineligible - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -257,12 +250,10 @@ describe("Moves - Dragon Tail", () => { }); it("should not force a switch to a fainted Pokemon", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.DRAGON_TAIL ]) - .startingLevel(100) - .enemyLevel(1); - await game.classicMode.startBattle([ Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.DRAGON_TAIL]).startingLevel(100).enemyLevel(1); + await game.classicMode.startBattle([Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA]); - const [ lapras, eevee, toxapex, primarina ] = game.scene.getPlayerParty(); + const [lapras, eevee, toxapex, primarina] = game.scene.getPlayerParty(); // Turn 1: Eevee faints eevee.hp = 0; @@ -273,7 +264,7 @@ describe("Moves - Dragon Tail", () => { await game.toNextTurn(); // Turn 2: Mock an RNG call that would normally call for switching to Eevee, but it is fainted - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -288,12 +279,10 @@ describe("Moves - Dragon Tail", () => { }); it("should not force a switch if there are no available Pokemon to switch into", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.DRAGON_TAIL ]) - .startingLevel(100) - .enemyLevel(1); - await game.classicMode.startBattle([ Species.LAPRAS, Species.EEVEE ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.DRAGON_TAIL]).startingLevel(100).enemyLevel(1); + await game.classicMode.startBattle([Species.LAPRAS, Species.EEVEE]); - const [ lapras, eevee ] = game.scene.getPlayerParty(); + const [lapras, eevee] = game.scene.getPlayerParty(); // Turn 1: Eevee faints eevee.hp = 0; @@ -304,7 +293,7 @@ describe("Moves - Dragon Tail", () => { await game.toNextTurn(); // Turn 2: Mock an RNG call that would normally call for switching to Eevee, but it is fainted - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); diff --git a/test/moves/dynamax_cannon.test.ts b/test/moves/dynamax_cannon.test.ts index 63e88808218..0ff0712710d 100644 --- a/test/moves/dynamax_cannon.test.ts +++ b/test/moves/dynamax_cannon.test.ts @@ -27,7 +27,7 @@ describe("Moves - Dynamax Cannon", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ dynamaxCannon.id ]); + game.override.moveset([dynamaxCannon.id]); game.override.startingLevel(200); // Note that, for Waves 1-10, the level cap is 10 @@ -36,16 +36,14 @@ describe("Moves - Dynamax Cannon", () => { game.override.disableCrits(); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); vi.spyOn(dynamaxCannon, "calculateBattlePower"); }); it("should return 100 power against an enemy below level cap", async () => { game.override.enemyLevel(1); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -57,9 +55,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 100 power against an enemy at level cap", async () => { game.override.enemyLevel(10); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -71,9 +67,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 120 power against an enemy 1% above level cap", async () => { game.override.enemyLevel(101); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -88,9 +82,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 140 power against an enemy 2% above level capp", async () => { game.override.enemyLevel(102); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -105,9 +97,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 160 power against an enemy 3% above level cap", async () => { game.override.enemyLevel(103); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -122,9 +112,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 180 power against an enemy 4% above level cap", async () => { game.override.enemyLevel(104); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -139,9 +127,7 @@ describe("Moves - Dynamax Cannon", () => { it("should return 200 power against an enemy 5% above level cap", async () => { game.override.enemyLevel(105); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); @@ -156,12 +142,10 @@ describe("Moves - Dynamax Cannon", () => { it("should return 200 power against an enemy way above level cap", async () => { game.override.enemyLevel(999); - await game.startBattle([ - Species.ETERNATUS, - ]); + await game.startBattle([Species.ETERNATUS]); game.move.select(dynamaxCannon.id); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); diff --git a/test/moves/effectiveness.test.ts b/test/moves/effectiveness.test.ts index 31c8ee715c6..dc55392f8bf 100644 --- a/test/moves/effectiveness.test.ts +++ b/test/moves/effectiveness.test.ts @@ -10,8 +10,14 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; -function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Species, - expected: number, targetAbility: Abilities = Abilities.BALL_FETCH, teraType?: PokemonType): void { +function testMoveEffectiveness( + game: GameManager, + move: Moves, + targetSpecies: Species, + expected: number, + targetAbility: Abilities = Abilities.BALL_FETCH, + teraType?: PokemonType, +): void { // Suppress getPokemonNameWithAffix because it calls on a null battle spec vi.spyOn(Messages, "getPokemonNameWithAffix").mockReturnValue(""); game.override.enemyAbility(targetAbility); @@ -46,65 +52,49 @@ describe("Moves - Type Effectiveness", () => { game.phaseInterceptor.restoreOg(); }); - it("Normal-type attacks are neutrally effective against Normal-type Pokemon", - () => testMoveEffectiveness(game, Moves.TACKLE, Species.SNORLAX, 1) - ); + it("Normal-type attacks are neutrally effective against Normal-type Pokemon", () => + testMoveEffectiveness(game, Moves.TACKLE, Species.SNORLAX, 1)); - it("Normal-type attacks are not very effective against Steel-type Pokemon", - () => testMoveEffectiveness(game, Moves.TACKLE, Species.REGISTEEL, 0.5) - ); + it("Normal-type attacks are not very effective against Steel-type Pokemon", () => + testMoveEffectiveness(game, Moves.TACKLE, Species.REGISTEEL, 0.5)); - it("Normal-type attacks are doubly resisted by Steel/Rock-type Pokemon", - () => testMoveEffectiveness(game, Moves.TACKLE, Species.AGGRON, 0.25) - ); + it("Normal-type attacks are doubly resisted by Steel/Rock-type Pokemon", () => + testMoveEffectiveness(game, Moves.TACKLE, Species.AGGRON, 0.25)); - it("Normal-type attacks have no effect on Ghost-type Pokemon", - () => testMoveEffectiveness(game, Moves.TACKLE, Species.DUSCLOPS, 0) - ); + it("Normal-type attacks have no effect on Ghost-type Pokemon", () => + testMoveEffectiveness(game, Moves.TACKLE, Species.DUSCLOPS, 0)); - it("Normal-type status moves are not affected by type matchups", - () => testMoveEffectiveness(game, Moves.GROWL, Species.DUSCLOPS, 1) - ); + it("Normal-type status moves are not affected by type matchups", () => + testMoveEffectiveness(game, Moves.GROWL, Species.DUSCLOPS, 1)); - it("Electric-type attacks are super-effective against Water-type Pokemon", - () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.BLASTOISE, 2) - ); + it("Electric-type attacks are super-effective against Water-type Pokemon", () => + testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.BLASTOISE, 2)); - it("Ghost-type attacks have no effect on Normal-type Pokemon", - () => testMoveEffectiveness(game, Moves.SHADOW_BALL, Species.URSALUNA, 0) - ); + it("Ghost-type attacks have no effect on Normal-type Pokemon", () => + testMoveEffectiveness(game, Moves.SHADOW_BALL, Species.URSALUNA, 0)); - it("Electric-type attacks are doubly super-effective against Water/Flying-type Pokemon", - () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 4) - ); + it("Electric-type attacks are doubly super-effective against Water/Flying-type Pokemon", () => + testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 4)); - it("Electric-type attacks are negated by Volt Absorb", - () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB) - ); + it("Electric-type attacks are negated by Volt Absorb", () => + testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.GYARADOS, 0, Abilities.VOLT_ABSORB)); - it("Electric-type attacks are super-effective against Tera-Water Pokemon", - () => testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.EXCADRILL, 2, Abilities.BALL_FETCH, PokemonType.WATER) - ); + it("Electric-type attacks are super-effective against Tera-Water Pokemon", () => + testMoveEffectiveness(game, Moves.THUNDERBOLT, Species.EXCADRILL, 2, Abilities.BALL_FETCH, PokemonType.WATER)); - it("Powder moves have no effect on Grass-type Pokemon", - () => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.AMOONGUSS, 0) - ); + it("Powder moves have no effect on Grass-type Pokemon", () => + testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.AMOONGUSS, 0)); - it("Powder moves have no effect on Tera-Grass Pokemon", - () => testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.SNORLAX, 0, Abilities.BALL_FETCH, PokemonType.GRASS) - ); + it("Powder moves have no effect on Tera-Grass Pokemon", () => + testMoveEffectiveness(game, Moves.SLEEP_POWDER, Species.SNORLAX, 0, Abilities.BALL_FETCH, PokemonType.GRASS)); - it("Prankster-boosted status moves have no effect on Dark-type Pokemon", - () => { - game.override.ability(Abilities.PRANKSTER); - testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.MIGHTYENA, 0); - } - ); + it("Prankster-boosted status moves have no effect on Dark-type Pokemon", () => { + game.override.ability(Abilities.PRANKSTER); + testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.MIGHTYENA, 0); + }); - it("Prankster-boosted status moves have no effect on Tera-Dark Pokemon", - () => { - game.override.ability(Abilities.PRANKSTER); - testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.SNORLAX, 0, Abilities.BALL_FETCH, PokemonType.DARK); - } - ); + it("Prankster-boosted status moves have no effect on Tera-Dark Pokemon", () => { + game.override.ability(Abilities.PRANKSTER); + testMoveEffectiveness(game, Moves.BABY_DOLL_EYES, Species.SNORLAX, 0, Abilities.BALL_FETCH, PokemonType.DARK); + }); }); diff --git a/test/moves/electrify.test.ts b/test/moves/electrify.test.ts index 7f6221f4036..69e7504b406 100644 --- a/test/moves/electrify.test.ts +++ b/test/moves/electrify.test.ts @@ -34,7 +34,7 @@ describe("Moves - Electrify", () => { }); it("should convert attacks to Electric type", async () => { - await game.classicMode.startBattle([ Species.EXCADRILL ]); + await game.classicMode.startBattle([Species.EXCADRILL]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -42,7 +42,7 @@ describe("Moves - Electrify", () => { game.move.select(Moves.ELECTRIFY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getMoveType).toHaveLastReturnedWith(PokemonType.ELECTRIC); @@ -52,7 +52,7 @@ describe("Moves - Electrify", () => { it("should override type changes from abilities", async () => { game.override.enemyAbility(Abilities.PIXILATE); - await game.classicMode.startBattle([ Species.EXCADRILL ]); + await game.classicMode.startBattle([Species.EXCADRILL]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getPlayerPokemon()!; @@ -60,7 +60,7 @@ describe("Moves - Electrify", () => { game.move.select(Moves.ELECTRIFY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getMoveType).toHaveLastReturnedWith(PokemonType.ELECTRIC); diff --git a/test/moves/electro_shot.test.ts b/test/moves/electro_shot.test.ts index 7cc7e793f4a..05ab9c24a7c 100644 --- a/test/moves/electro_shot.test.ts +++ b/test/moves/electro_shot.test.ts @@ -36,7 +36,7 @@ describe("Moves - Electro Shot", () => { }); it("should increase the user's Sp. Atk on the first turn, then attack on the second turn", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -62,11 +62,11 @@ describe("Moves - Electro Shot", () => { it.each([ { weatherType: WeatherType.RAIN, name: "Rain" }, - { weatherType: WeatherType.HEAVY_RAIN, name: "Heavy Rain" } + { weatherType: WeatherType.HEAVY_RAIN, name: "Heavy Rain" }, ])("should fully resolve in one turn if $name is active", async ({ weatherType }) => { game.override.weather(weatherType); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -87,11 +87,9 @@ describe("Moves - Electro Shot", () => { }); it("should only increase Sp. Atk once with Multi-Lens", async () => { - game.override - .weather(WeatherType.RAIN) - .startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); + game.override.weather(WeatherType.RAIN).startingHeldItems([{ name: "MULTI_LENS", count: 1 }]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/encore.test.ts b/test/moves/encore.test.ts index 4cf466a7f2a..43b9eb6a77f 100644 --- a/test/moves/encore.test.ts +++ b/test/moves/encore.test.ts @@ -25,19 +25,19 @@ describe("Moves - Encore", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.ENCORE ]) + .moveset([Moves.SPLASH, Moves.ENCORE]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.TACKLE ]) + .enemyMoveset([Moves.SPLASH, Moves.TACKLE]) .startingLevel(100) .enemyLevel(100); }); it("should prevent the target from using any move except the last used move", async () => { - await game.classicMode.startBattle([ Species.SNORLAX ]); + await game.classicMode.startBattle([Species.SNORLAX]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -61,26 +61,24 @@ describe("Moves - Encore", () => { { moveId: Moves.MIMIC, name: "Mimic", delay: true }, { moveId: Moves.SKETCH, name: "Sketch", delay: true }, { moveId: Moves.ENCORE, name: "Encore", delay: false }, - { moveId: Moves.STRUGGLE, name: "Struggle", delay: false } + { moveId: Moves.STRUGGLE, name: "Struggle", delay: false }, ])("$name", async ({ moveId, delay }) => { game.override.enemyMoveset(moveId); - await game.classicMode.startBattle([ Species.SNORLAX ]); + await game.classicMode.startBattle([Species.SNORLAX]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; if (delay) { game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); } game.move.select(Moves.ENCORE); - const turnOrder = delay - ? [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ] - : [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]; + const turnOrder = delay ? [BattlerIndex.PLAYER, BattlerIndex.ENEMY] : [BattlerIndex.ENEMY, BattlerIndex.PLAYER]; await game.setTurnOrder(turnOrder); await game.phaseInterceptor.to("BerryPhase", false); @@ -90,9 +88,9 @@ describe("Moves - Encore", () => { }); it("Pokemon under both Encore and Torment should alternate between Struggle and restricted move", async () => { - const turnOrder = [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]; - game.override.moveset([ Moves.ENCORE, Moves.TORMENT, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.FEEBAS ]); + const turnOrder = [BattlerIndex.ENEMY, BattlerIndex.PLAYER]; + game.override.moveset([Moves.ENCORE, Moves.TORMENT, Moves.SPLASH]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemyPokemon = game.scene.getEnemyPokemon(); game.move.select(Moves.ENCORE); diff --git a/test/moves/endure.test.ts b/test/moves/endure.test.ts index 8514470d59c..8151128479d 100644 --- a/test/moves/endure.test.ts +++ b/test/moves/endure.test.ts @@ -22,7 +22,7 @@ describe("Moves - Endure", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.THUNDER, Moves.BULLET_SEED, Moves.TOXIC ]) + .moveset([Moves.THUNDER, Moves.BULLET_SEED, Moves.TOXIC]) .ability(Abilities.SKILL_LINK) .startingLevel(100) .battleType("single") @@ -33,7 +33,7 @@ describe("Moves - Endure", () => { }); it("should let the pokemon survive with 1 HP", async () => { - await game.classicMode.startBattle([ Species.ARCEUS ]); + await game.classicMode.startBattle([Species.ARCEUS]); game.move.select(Moves.THUNDER); await game.phaseInterceptor.to("BerryPhase"); @@ -42,7 +42,7 @@ describe("Moves - Endure", () => { }); it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => { - await game.classicMode.startBattle([ Species.ARCEUS ]); + await game.classicMode.startBattle([Species.ARCEUS]); game.move.select(Moves.BULLET_SEED); await game.phaseInterceptor.to("BerryPhase"); @@ -52,7 +52,7 @@ describe("Moves - Endure", () => { it("shouldn't prevent fainting from indirect damage", async () => { game.override.enemyLevel(100); - await game.classicMode.startBattle([ Species.ARCEUS ]); + await game.classicMode.startBattle([Species.ARCEUS]); const enemy = game.scene.getEnemyPokemon()!; enemy.hp = 2; diff --git a/test/moves/entrainment.test.ts b/test/moves/entrainment.test.ts index 608c6ef3676..b2a0baf3e27 100644 --- a/test/moves/entrainment.test.ts +++ b/test/moves/entrainment.test.ts @@ -23,7 +23,7 @@ describe("Moves - Entrainment", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.ENTRAINMENT ]) + .moveset([Moves.SPLASH, Moves.ENTRAINMENT]) .ability(Abilities.ADAPTABILITY) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Moves - Entrainment", () => { }); it("gives its ability to the target", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.ENTRAINMENT); await game.phaseInterceptor.to("BerryPhase"); @@ -43,7 +43,7 @@ describe("Moves - Entrainment", () => { it("should activate post-summon abilities", async () => { game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.ENTRAINMENT); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/fairy_lock.test.ts b/test/moves/fairy_lock.test.ts index 627eac401cc..a47143add4f 100644 --- a/test/moves/fairy_lock.test.ts +++ b/test/moves/fairy_lock.test.ts @@ -24,17 +24,17 @@ describe("Moves - Fairy Lock", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.FAIRY_LOCK, Moves.SPLASH ]) + .moveset([Moves.FAIRY_LOCK, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("double") .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.U_TURN ]); + .enemyMoveset([Moves.SPLASH, Moves.U_TURN]); }); it("Applies Fairy Lock tag for two turns", async () => { - await game.classicMode.startBattle([ Species.KLEFKI, Species.TYRUNT ]); + await game.classicMode.startBattle([Species.KLEFKI, Species.TYRUNT]); const playerPokemon = game.scene.getPlayerField(); const enemyField = game.scene.getEnemyField(); @@ -66,7 +66,7 @@ describe("Moves - Fairy Lock", () => { }); it("Ghost types can escape Fairy Lock", async () => { - await game.classicMode.startBattle([ Species.DUSKNOIR, Species.GENGAR, Species.TYRUNT ]); + await game.classicMode.startBattle([Species.DUSKNOIR, Species.GENGAR, Species.TYRUNT]); game.move.select(Moves.FAIRY_LOCK); game.move.select(Moves.SPLASH, 1); @@ -93,8 +93,8 @@ describe("Moves - Fairy Lock", () => { }); it("Phasing moves will still switch out", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]); - await game.classicMode.startBattle([ Species.KLEFKI, Species.TYRUNT, Species.ZYGARDE ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.WHIRLWIND]); + await game.classicMode.startBattle([Species.KLEFKI, Species.TYRUNT, Species.ZYGARDE]); game.move.select(Moves.FAIRY_LOCK); game.move.select(Moves.SPLASH, 1); @@ -120,8 +120,8 @@ describe("Moves - Fairy Lock", () => { }); it("If a Pokemon faints and is replaced the replacement is also trapped", async () => { - game.override.moveset([ Moves.FAIRY_LOCK, Moves.SPLASH, Moves.MEMENTO ]); - await game.classicMode.startBattle([ Species.KLEFKI, Species.GUZZLORD, Species.TYRUNT, Species.ZYGARDE ]); + game.override.moveset([Moves.FAIRY_LOCK, Moves.SPLASH, Moves.MEMENTO]); + await game.classicMode.startBattle([Species.KLEFKI, Species.GUZZLORD, Species.TYRUNT, Species.ZYGARDE]); game.move.select(Moves.FAIRY_LOCK); game.move.select(Moves.MEMENTO, 1); diff --git a/test/moves/fake_out.test.ts b/test/moves/fake_out.test.ts index 21a129b6410..929c760ee5b 100644 --- a/test/moves/fake_out.test.ts +++ b/test/moves/fake_out.test.ts @@ -23,15 +23,15 @@ describe("Moves - Fake Out", () => { game.override .battleType("single") .enemySpecies(Species.CORVIKNIGHT) - .moveset([ Moves.FAKE_OUT, Moves.SPLASH ]) + .moveset([Moves.FAKE_OUT, Moves.SPLASH]) .enemyMoveset(Moves.SPLASH) .enemyLevel(10) .startingLevel(10) // prevent LevelUpPhase from happening .disableCrits(); }); - it("can only be used on the first turn a pokemon is sent out in a battle", async() => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + it("can only be used on the first turn a pokemon is sent out in a battle", async () => { + await game.classicMode.startBattle([Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; @@ -48,8 +48,8 @@ describe("Moves - Fake Out", () => { }, 20000); // This is a PokeRogue buff to Fake Out - it("can be used at the start of every wave even if the pokemon wasn't recalled", async() => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + it("can be used at the start of every wave even if the pokemon wasn't recalled", async () => { + await game.classicMode.startBattle([Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; enemy.damageAndUpdate(enemy.getMaxHp() - 1); @@ -63,9 +63,9 @@ describe("Moves - Fake Out", () => { expect(game.scene.getEnemyPokemon()!.isFullHp()).toBe(false); }, 20000); - it("can be used again if recalled and sent back out", async() => { + it("can be used again if recalled and sent back out", async () => { game.override.startingWave(4); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); const enemy1 = game.scene.getEnemyPokemon()!; diff --git a/test/moves/fell_stinger.test.ts b/test/moves/fell_stinger.test.ts index c7cd616a95e..2ffa44c5a3a 100644 --- a/test/moves/fell_stinger.test.ts +++ b/test/moves/fell_stinger.test.ts @@ -9,7 +9,6 @@ import { StatusEffect } from "#app/enums/status-effect"; import { WeatherType } from "#app/enums/weather-type"; import { allMoves } from "#app/data/moves/move"; - describe("Moves - Fell Stinger", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,13 +26,9 @@ describe("Moves - Fell Stinger", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") - .moveset([ - Moves.FELL_STINGER, - Moves.SALT_CURE, - Moves.BIND, - Moves.LEECH_SEED - ]) + game.override + .battleType("single") + .moveset([Moves.FELL_STINGER, Moves.SALT_CURE, Moves.BIND, Moves.LEECH_SEED]) .startingLevel(50) .disableCrits() .enemyAbility(Abilities.STURDY) @@ -43,9 +38,9 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if opponent gets KO'd by recoil", async () => { - game.override.enemyMoveset([ Moves.DOUBLE_EDGE ]); + game.override.enemyMoveset([Moves.DOUBLE_EDGE]); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.FELL_STINGER); @@ -55,11 +50,9 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy is KO'd by status effect", async () => { - game.override - .enemyMoveset(Moves.SPLASH) - .enemyStatusEffect(StatusEffect.BURN); + game.override.enemyMoveset(Moves.SPLASH).enemyStatusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.FELL_STINGER); @@ -71,7 +64,7 @@ describe("Moves - Fell Stinger", () => { it("should not grant stat boost if enemy is KO'd by damaging weather", async () => { game.override.weather(WeatherType.HAIL); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.FELL_STINGER); @@ -82,12 +75,9 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy is KO'd by Dry Skin + Harsh Sunlight", async () => { - game.override - .enemyPassiveAbility(Abilities.STURDY) - .enemyAbility(Abilities.DRY_SKIN) - .weather(WeatherType.HARSH_SUN); + game.override.enemyPassiveAbility(Abilities.STURDY).enemyAbility(Abilities.DRY_SKIN).weather(WeatherType.HARSH_SUN); - await game.challengeMode.startBattle([ Species.LEAVANNY ]); + await game.challengeMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.FELL_STINGER); @@ -98,11 +88,9 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy is saved by Reviver Seed", async () => { - game.override - .enemyAbility(Abilities.BALL_FETCH) - .enemyHeldItems([{ name: "REVIVER_SEED" }]); + game.override.enemyAbility(Abilities.BALL_FETCH).enemyHeldItems([{ name: "REVIVER_SEED" }]); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.FELL_STINGER); @@ -111,14 +99,13 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy is KO'd by Salt Cure", async () => { - game.override.battleType("double") - .startingLevel(5); + game.override.battleType("double").startingLevel(5); const saltCure = allMoves[Moves.SALT_CURE]; const fellStinger = allMoves[Moves.FELL_STINGER]; vi.spyOn(saltCure, "accuracy", "get").mockReturnValue(100); vi.spyOn(fellStinger, "power", "get").mockReturnValue(50000); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; const leftEnemy = game.scene.getEnemyField()[0]!; @@ -137,12 +124,11 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy dies to Bind or a similar effect", async () => { - game.override.battleType("double") - .startingLevel(5); + game.override.battleType("double").startingLevel(5); vi.spyOn(allMoves[Moves.BIND], "accuracy", "get").mockReturnValue(100); vi.spyOn(allMoves[Moves.FELL_STINGER], "power", "get").mockReturnValue(50000); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; const leftEnemy = game.scene.getEnemyField()[0]!; @@ -161,12 +147,11 @@ describe("Moves - Fell Stinger", () => { }); it("should not grant stat boost if enemy dies to Leech Seed", async () => { - game.override.battleType("double") - .startingLevel(5); + game.override.battleType("double").startingLevel(5); vi.spyOn(allMoves[Moves.LEECH_SEED], "accuracy", "get").mockReturnValue(100); vi.spyOn(allMoves[Moves.FELL_STINGER], "power", "get").mockReturnValue(50000); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon()!; const leftEnemy = game.scene.getEnemyField()[0]!; @@ -187,7 +172,7 @@ describe("Moves - Fell Stinger", () => { it("should grant stat boost if enemy dies directly to hit", async () => { game.override.enemyAbility(Abilities.KLUTZ); - await game.classicMode.startBattle([ Species.LEAVANNY ]); + await game.classicMode.startBattle([Species.LEAVANNY]); const leadPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.FELL_STINGER); diff --git a/test/moves/fillet_away.test.ts b/test/moves/fillet_away.test.ts index 076a3011afa..cc462b3746a 100644 --- a/test/moves/fillet_away.test.ts +++ b/test/moves/fillet_away.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - /** HP Cost of Move */ const RATIO = 2; /** Amount of extra HP lost */ @@ -33,85 +32,77 @@ describe("Moves - FILLET AWAY", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FILLET_AWAY ]); + game.override.moveset([Moves.FILLET_AWAY]); game.override.enemyMoveset(Moves.SPLASH); }); //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/fillet_away_(move) - test("raises the user's ATK, SPATK, and SPD stat stages by 2 each, at the cost of 1/2 of its maximum HP", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("raises the user's ATK, SPATK, and SPD stat stages by 2 each, at the cost of 1/2 of its maximum HP", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - game.move.select(Moves.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.FILLET_AWAY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(2); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(2); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(2); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(2); + }); - test("still takes effect if one or more of the involved stat stages are not at max", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("still takes effect if one or more of the involved stat stages are not at max", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - //Here - Stat.SPD -> 0 and Stat.SPATK -> 3 - leadPokemon.setStatStage(Stat.ATK, 6); - leadPokemon.setStatStage(Stat.SPATK, 3); + //Here - Stat.SPD -> 0 and Stat.SPATK -> 3 + leadPokemon.setStatStage(Stat.ATK, 6); + leadPokemon.setStatStage(Stat.SPATK, 3); - game.move.select(Moves.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.FILLET_AWAY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(5); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(2); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(5); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(2); + }); - test("fails if all stat stages involved are at max", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("fails if all stat stages involved are at max", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.setStatStage(Stat.ATK, 6); - leadPokemon.setStatStage(Stat.SPATK, 6); - leadPokemon.setStatStage(Stat.SPD, 6); + leadPokemon.setStatStage(Stat.ATK, 6); + leadPokemon.setStatStage(Stat.SPATK, 6); + leadPokemon.setStatStage(Stat.SPD, 6); - game.move.select(Moves.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.FILLET_AWAY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(6); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(6); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(6); + }); - test("fails if the user's health is less than 1/2", - async() => { - await game.startBattle([ Species.MAGIKARP ]); + test("fails if the user's health is less than 1/2", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); - leadPokemon.hp = hpLost - PREDAMAGE; + const leadPokemon = game.scene.getPlayerPokemon()!; + const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); + leadPokemon.hp = hpLost - PREDAMAGE; - game.move.select(Moves.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.FILLET_AWAY); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); - expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(leadPokemon.getStatStage(Stat.SPD)).toBe(0); - } - ); + expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(leadPokemon.getStatStage(Stat.SPATK)).toBe(0); + expect(leadPokemon.getStatStage(Stat.SPD)).toBe(0); + }); }); diff --git a/test/moves/fissure.test.ts b/test/moves/fissure.test.ts index 07f2a3bfacb..63de58eb2e7 100644 --- a/test/moves/fissure.test.ts +++ b/test/moves/fissure.test.ts @@ -32,7 +32,7 @@ describe("Moves - Fissure", () => { game.override.disableCrits(); game.override.starterSpecies(Species.SNORLAX); - game.override.moveset([ Moves.FISSURE ]); + game.override.moveset([Moves.FISSURE]); game.override.passiveAbility(Abilities.BALL_FETCH); game.override.startingLevel(100); diff --git a/test/moves/flame_burst.test.ts b/test/moves/flame_burst.test.ts index 7bcf06d92ae..b6a425e7bb5 100644 --- a/test/moves/flame_burst.test.ts +++ b/test/moves/flame_burst.test.ts @@ -20,7 +20,7 @@ describe("Moves - Flame Burst", () => { * @returns Effect damage of Flame Burst */ const getEffectDamage = (pokemon: Pokemon): number => { - return Math.max(1, Math.floor(pokemon.getMaxHp() * 1 / 16)); + return Math.max(1, Math.floor((pokemon.getMaxHp() * 1) / 16)); }; beforeAll(() => { @@ -36,18 +36,18 @@ describe("Moves - Flame Burst", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([ Moves.FLAME_BURST, Moves.SPLASH ]); + game.override.moveset([Moves.FLAME_BURST, Moves.SPLASH]); game.override.disableCrits(); game.override.ability(Abilities.UNNERVE); game.override.startingWave(4); game.override.enemySpecies(Species.SHUCKLE); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); }); it("inflicts damage to the target's ally equal to 1/16 of its max HP", async () => { - await game.startBattle([ Species.PIKACHU, Species.PIKACHU ]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + await game.startBattle([Species.PIKACHU, Species.PIKACHU]); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(Moves.SPLASH, 1); @@ -60,8 +60,8 @@ describe("Moves - Flame Burst", () => { it("does not inflict damage to the target's ally if the target was not affected by Flame Burst", async () => { game.override.enemyAbility(Abilities.FLASH_FIRE); - await game.startBattle([ Species.PIKACHU, Species.PIKACHU ]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + await game.startBattle([Species.PIKACHU, Species.PIKACHU]); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); game.move.select(Moves.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(Moves.SPLASH, 1); @@ -72,8 +72,8 @@ describe("Moves - Flame Burst", () => { }); it("does not interact with the target ally's abilities", async () => { - await game.startBattle([ Species.PIKACHU, Species.PIKACHU ]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + await game.startBattle([Species.PIKACHU, Species.PIKACHU]); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.FLASH_FIRE]); @@ -86,8 +86,8 @@ describe("Moves - Flame Burst", () => { }); it("effect damage is prevented by Magic Guard", async () => { - await game.startBattle([ Species.PIKACHU, Species.PIKACHU ]); - const [ leftEnemy, rightEnemy ] = game.scene.getEnemyField(); + await game.startBattle([Species.PIKACHU, Species.PIKACHU]); + const [leftEnemy, rightEnemy] = game.scene.getEnemyField(); vi.spyOn(rightEnemy, "getAbility").mockReturnValue(allAbilities[Abilities.MAGIC_GUARD]); @@ -99,7 +99,11 @@ describe("Moves - Flame Burst", () => { expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp()); }); - it("is not affected by protection moves and Endure", async () => { - // TODO: update this test when it's possible to select move for each enemy - }, { skip: true }); + it( + "is not affected by protection moves and Endure", + async () => { + // TODO: update this test when it's possible to select move for each enemy + }, + { skip: true }, + ); }); diff --git a/test/moves/flower_shield.test.ts b/test/moves/flower_shield.test.ts index f51cb8a085e..b66847651c1 100644 --- a/test/moves/flower_shield.test.ts +++ b/test/moves/flower_shield.test.ts @@ -29,14 +29,14 @@ describe("Moves - Flower Shield", () => { game.override.ability(Abilities.NONE); game.override.enemyAbility(Abilities.NONE); game.override.battleType("single"); - game.override.moveset([ Moves.FLOWER_SHIELD, Moves.SPLASH ]); + game.override.moveset([Moves.FLOWER_SHIELD, Moves.SPLASH]); game.override.enemyMoveset(Moves.SPLASH); }); it("raises DEF stat stage by 1 for all Grass-type Pokemon on the field by one stage - single battle", async () => { game.override.enemySpecies(Species.CHERRIM); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const cherrim = game.scene.getEnemyPokemon()!; const magikarp = game.scene.getPlayerPokemon()!; @@ -53,7 +53,7 @@ describe("Moves - Flower Shield", () => { it("raises DEF stat stage by 1 for all Grass-type Pokemon on the field by one stage - double battle", async () => { game.override.enemySpecies(Species.MAGIKARP).startingBiome(Biome.GRASS).battleType("double"); - await game.startBattle([ Species.CHERRIM, Species.MAGIKARP ]); + await game.startBattle([Species.CHERRIM, Species.MAGIKARP]); const field = game.scene.getField(true); const grassPokemons = field.filter(p => p.getTypes().includes(PokemonType.GRASS)); @@ -72,13 +72,13 @@ describe("Moves - Flower Shield", () => { /** * See semi-vulnerable state tags. {@linkcode SemiInvulnerableTag} - */ + */ it("does not raise DEF stat stage for a Pokemon in semi-vulnerable state", async () => { game.override.enemySpecies(Species.PARAS); - game.override.enemyMoveset([ Moves.DIG, Moves.DIG, Moves.DIG, Moves.DIG ]); + game.override.enemyMoveset([Moves.DIG, Moves.DIG, Moves.DIG, Moves.DIG]); game.override.enemyLevel(50); - await game.startBattle([ Species.CHERRIM ]); + await game.startBattle([Species.CHERRIM]); const paras = game.scene.getEnemyPokemon()!; const cherrim = game.scene.getPlayerPokemon()!; @@ -97,7 +97,7 @@ describe("Moves - Flower Shield", () => { it("does nothing if there are no Grass-type Pokemon on the field", async () => { game.override.enemySpecies(Species.MAGIKARP); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const enemy = game.scene.getEnemyPokemon()!; const ally = game.scene.getPlayerPokemon()!; diff --git a/test/moves/fly.test.ts b/test/moves/fly.test.ts index 2471372f97c..0bd7d22b2a7 100644 --- a/test/moves/fly.test.ts +++ b/test/moves/fly.test.ts @@ -39,7 +39,7 @@ describe("Moves - Fly", () => { }); it("should make the user semi-invulnerable, then attack over 2 turns", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -65,7 +65,7 @@ describe("Moves - Fly", () => { it("should not allow the user to evade attacks from Pokemon with No Guard", async () => { game.override.enemyAbility(Abilities.NO_GUARD); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -78,11 +78,9 @@ describe("Moves - Fly", () => { }); it("should not expend PP when the attack phase is cancelled", async () => { - game.override - .enemyAbility(Abilities.NO_GUARD) - .enemyMoveset(Moves.SPORE); + game.override.enemyAbility(Abilities.NO_GUARD).enemyMoveset(Moves.SPORE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -97,9 +95,9 @@ describe("Moves - Fly", () => { }); it("should be cancelled when another Pokemon uses Gravity", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.GRAVITY ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.GRAVITY]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -110,7 +108,7 @@ describe("Moves - Fly", () => { await game.toNextTurn(); await game.forceEnemyMove(Moves.GRAVITY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL); diff --git a/test/moves/focus_punch.test.ts b/test/moves/focus_punch.test.ts index 1f14a19fbd7..2dc5f20f2bf 100644 --- a/test/moves/focus_punch.test.ts +++ b/test/moves/focus_punch.test.ts @@ -11,7 +11,6 @@ import i18next from "i18next"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Focus Punch", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,7 +30,7 @@ describe("Moves - Focus Punch", () => { game.override .battleType("single") .ability(Abilities.UNNERVE) - .moveset([ Moves.FOCUS_PUNCH ]) + .moveset([Moves.FOCUS_PUNCH]) .enemySpecies(Species.GROUDON) .enemyAbility(Abilities.INSOMNIA) .enemyMoveset(Moves.SPLASH) @@ -39,101 +38,89 @@ describe("Moves - Focus Punch", () => { .enemyLevel(100); }); - it( - "should deal damage at the end of turn if uninterrupted", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + it("should deal damage at the end of turn if uninterrupted", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyStartingHp = enemyPokemon.hp; + const enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.FOCUS_PUNCH); + game.move.select(Moves.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to(MessagePhase); - expect(enemyPokemon.hp).toBe(enemyStartingHp); - expect(leadPokemon.getMoveHistory().length).toBe(0); + expect(enemyPokemon.hp).toBe(enemyStartingHp); + expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - expect(leadPokemon.getMoveHistory().length).toBe(1); - expect(leadPokemon.turnData.totalDamageDealt).toBe(enemyStartingHp - enemyPokemon.hp); - } - ); + expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); + expect(leadPokemon.getMoveHistory().length).toBe(1); + expect(leadPokemon.turnData.totalDamageDealt).toBe(enemyStartingHp - enemyPokemon.hp); + }); - it( - "should fail if the user is hit", - async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + it("should fail if the user is hit", async () => { + game.override.enemyMoveset([Moves.TACKLE]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const enemyStartingHp = enemyPokemon.hp; + const enemyStartingHp = enemyPokemon.hp; - game.move.select(Moves.FOCUS_PUNCH); + game.move.select(Moves.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to(MessagePhase); - expect(enemyPokemon.hp).toBe(enemyStartingHp); - expect(leadPokemon.getMoveHistory().length).toBe(0); + expect(enemyPokemon.hp).toBe(enemyStartingHp); + expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.hp).toBe(enemyStartingHp); - expect(leadPokemon.getMoveHistory().length).toBe(1); - expect(leadPokemon.turnData.totalDamageDealt).toBe(0); - } - ); + expect(enemyPokemon.hp).toBe(enemyStartingHp); + expect(leadPokemon.getMoveHistory().length).toBe(1); + expect(leadPokemon.turnData.totalDamageDealt).toBe(0); + }); - it( - "should be cancelled if the user falls asleep mid-turn", - async () => { - game.override.enemyMoveset([ Moves.SPORE ]); + it("should be cancelled if the user falls asleep mid-turn", async () => { + game.override.enemyMoveset([Moves.SPORE]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.FOCUS_PUNCH); + game.move.select(Moves.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); // Header message + await game.phaseInterceptor.to(MessagePhase); // Header message - expect(leadPokemon.getMoveHistory().length).toBe(0); + expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.getMoveHistory().length).toBe(1); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + expect(leadPokemon.getMoveHistory().length).toBe(1); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should not queue its pre-move message before an enemy switches", - async () => { - /** Guarantee a Trainer battle with multiple enemy Pokemon */ - game.override.startingWave(25); + it("should not queue its pre-move message before an enemy switches", async () => { + /** Guarantee a Trainer battle with multiple enemy Pokemon */ + game.override.startingWave(25); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - game.forceEnemyToSwitch(); - game.move.select(Moves.FOCUS_PUNCH); + game.forceEnemyToSwitch(); + game.move.select(Moves.FOCUS_PUNCH); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to(TurnStartPhase); - expect(game.scene.getCurrentPhase() instanceof SwitchSummonPhase).toBeTruthy(); - expect(game.scene.phaseQueue.find(phase => phase instanceof MoveHeaderPhase)).toBeDefined(); - } - ); + expect(game.scene.getCurrentPhase() instanceof SwitchSummonPhase).toBeTruthy(); + expect(game.scene.phaseQueue.find(phase => phase instanceof MoveHeaderPhase)).toBeDefined(); + }); it("should replace the 'but it failed' text when the user gets hit", async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + game.override.enemyMoveset([Moves.TACKLE]); + await game.classicMode.startBattle([Species.CHARIZARD]); game.move.select(Moves.FOCUS_PUNCH); await game.phaseInterceptor.to("MoveEndPhase", true); diff --git a/test/moves/follow_me.test.ts b/test/moves/follow_me.test.ts index bef9b9ddb01..eeb11b36f24 100644 --- a/test/moves/follow_me.test.ts +++ b/test/moves/follow_me.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Moves - Follow Me", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,99 +30,87 @@ describe("Moves - Follow Me", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([ Moves.TACKLE, Moves.FOLLOW_ME, Moves.SPLASH ]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.TACKLE, Moves.FOLLOW_ME, Moves.SPLASH]); }); - test( - "move should redirect enemy attacks to the user", - async () => { - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + test("move should redirect enemy attacks to the user", async () => { + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.FOLLOW_ME); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY); - // Force both enemies to target the player Pokemon that did not use Follow Me - await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); + // Force both enemies to target the player Pokemon that did not use Follow Me + await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); + await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to(TurnEndPhase, false); - expect(playerPokemon[0].hp).toBeLessThan(playerPokemon[0].getMaxHp()); - expect(playerPokemon[1].hp).toBe(playerPokemon[1].getMaxHp()); - } - ); + expect(playerPokemon[0].hp).toBeLessThan(playerPokemon[0].getMaxHp()); + expect(playerPokemon[1].hp).toBe(playerPokemon[1].getMaxHp()); + }); - test( - "move should redirect enemy attacks to the first ally that uses it", - async () => { - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + test("move should redirect enemy attacks to the first ally that uses it", async () => { + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.FOLLOW_ME); - game.move.select(Moves.FOLLOW_ME, 1); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.FOLLOW_ME, 1); - // Each player is targeted by an enemy - await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); - await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); + // Each player is targeted by an enemy + await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to(TurnEndPhase, false); - playerPokemon.sort((a, b) => a.getEffectiveStat(Stat.SPD) - b.getEffectiveStat(Stat.SPD)); + playerPokemon.sort((a, b) => a.getEffectiveStat(Stat.SPD) - b.getEffectiveStat(Stat.SPD)); - expect(playerPokemon[1].hp).toBeLessThan(playerPokemon[1].getMaxHp()); - expect(playerPokemon[0].hp).toBe(playerPokemon[0].getMaxHp()); - } - ); + expect(playerPokemon[1].hp).toBeLessThan(playerPokemon[1].getMaxHp()); + expect(playerPokemon[0].hp).toBe(playerPokemon[0].getMaxHp()); + }); - test( - "move effect should be bypassed by Stalwart", - async () => { - game.override.ability(Abilities.STALWART); - game.override.moveset([ Moves.QUICK_ATTACK ]); + test("move effect should be bypassed by Stalwart", async () => { + game.override.ability(Abilities.STALWART); + game.override.moveset([Moves.QUICK_ATTACK]); - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); - // Target doesn't need to be specified if the move is self-targeted - await game.forceEnemyMove(Moves.FOLLOW_ME); - await game.forceEnemyMove(Moves.SPLASH); + // Target doesn't need to be specified if the move is self-targeted + await game.forceEnemyMove(Moves.FOLLOW_ME); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to(TurnEndPhase, false); - // If redirection was bypassed, both enemies should be damaged - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); - } - ); + // If redirection was bypassed, both enemies should be damaged + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); + }); - test( - "move effect should be bypassed by Snipe Shot", - async () => { - game.override.moveset([ Moves.SNIPE_SHOT ]); + test("move effect should be bypassed by Snipe Shot", async () => { + game.override.moveset([Moves.SNIPE_SHOT]); - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SNIPE_SHOT, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.SNIPE_SHOT, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SNIPE_SHOT, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.FOLLOW_ME); - await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.FOLLOW_ME); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to(TurnEndPhase, false); - // If redirection was bypassed, both enemies should be damaged - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); - } - ); + // If redirection was bypassed, both enemies should be damaged + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); + }); }); diff --git a/test/moves/foresight.test.ts b/test/moves/foresight.test.ts index 7dccd0fefca..d33a00bf136 100644 --- a/test/moves/foresight.test.ts +++ b/test/moves/foresight.test.ts @@ -27,7 +27,7 @@ describe("Moves - Foresight", () => { .enemyMoveset(Moves.SPLASH) .enemyLevel(5) .starterSpecies(Species.MAGIKARP) - .moveset([ Moves.FORESIGHT, Moves.QUICK_ATTACK, Moves.MACH_PUNCH ]); + .moveset([Moves.FORESIGHT, Moves.QUICK_ATTACK, Moves.MACH_PUNCH]); }); it("should allow Normal and Fighting moves to hit Ghost types", async () => { @@ -54,7 +54,7 @@ describe("Moves - Foresight", () => { }); it("should ignore target's evasiveness boosts", async () => { - game.override.enemyMoveset([ Moves.MINIMIZE ]); + game.override.enemyMoveset([Moves.MINIMIZE]); await game.startBattle(); const pokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/forests_curse.test.ts b/test/moves/forests_curse.test.ts index f275db8d2bb..8850b92662d 100644 --- a/test/moves/forests_curse.test.ts +++ b/test/moves/forests_curse.test.ts @@ -23,7 +23,7 @@ describe("Moves - Forest's Curse", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.FORESTS_CURSE, Moves.TRICK_OR_TREAT ]) + .moveset([Moves.FORESTS_CURSE, Moves.TRICK_OR_TREAT]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Moves - Forest's Curse", () => { }); it("will replace the added type from Trick Or Treat", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemyPokemon = game.scene.getEnemyPokemon(); game.move.select(Moves.TRICK_OR_TREAT); diff --git a/test/moves/freeze_dry.test.ts b/test/moves/freeze_dry.test.ts index 62375393563..8cab56ddfd2 100644 --- a/test/moves/freeze_dry.test.ts +++ b/test/moves/freeze_dry.test.ts @@ -30,7 +30,7 @@ describe("Moves - Freeze-Dry", () => { .enemyMoveset(Moves.SPLASH) .starterSpecies(Species.FEEBAS) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.FREEZE_DRY, Moves.FORESTS_CURSE, Moves.SOAK ]); + .moveset([Moves.FREEZE_DRY, Moves.FORESTS_CURSE, Moves.SOAK]); }); it("should deal 2x damage to pure water types", async () => { @@ -40,7 +40,7 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); @@ -54,7 +54,7 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4); @@ -68,7 +68,7 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(1); @@ -82,14 +82,14 @@ describe("Moves - Freeze-Dry", () => { .enemySpecies(Species.SHEDINJA) .enemyMoveset(Moves.SPLASH) .starterSpecies(Species.MAGIKARP) - .moveset([ Moves.SOAK, Moves.FREEZE_DRY ]); + .moveset([Moves.SOAK, Moves.FREEZE_DRY]); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.SOAK); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); game.move.select(Moves.FREEZE_DRY); @@ -110,7 +110,7 @@ describe("Moves - Freeze-Dry", () => { await game.toNextTurn(); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(8); @@ -126,7 +126,7 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); @@ -142,15 +142,14 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5); }); it("should deal 0.5x damage to water type Terapagos with Tera Shell", async () => { - game.override.enemySpecies(Species.TERAPAGOS) - .enemyAbility(Abilities.TERA_SHELL); + game.override.enemySpecies(Species.TERAPAGOS).enemyAbility(Abilities.TERA_SHELL); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; @@ -160,7 +159,7 @@ describe("Moves - Freeze-Dry", () => { await game.toNextTurn(); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.5); @@ -174,130 +173,114 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); }); it("should deal 0.25x damage to rock/steel type under Normalize", async () => { - game.override - .ability(Abilities.NORMALIZE) - .enemySpecies(Species.SHIELDON); + game.override.ability(Abilities.NORMALIZE).enemySpecies(Species.SHIELDON); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25); }); it("should deal 0x damage to water/ghost type under Normalize", async () => { - game.override - .ability(Abilities.NORMALIZE) - .enemySpecies(Species.JELLICENT); + game.override.ability(Abilities.NORMALIZE).enemySpecies(Species.JELLICENT); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0); }); it("should deal 2x damage to water type under Electrify", async () => { - game.override.enemyMoveset([ Moves.ELECTRIFY ]); + game.override.enemyMoveset([Moves.ELECTRIFY]); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); }); it("should deal 4x damage to water/flying type under Electrify", async () => { - game.override - .enemyMoveset([ Moves.ELECTRIFY ]) - .enemySpecies(Species.GYARADOS); + game.override.enemyMoveset([Moves.ELECTRIFY]).enemySpecies(Species.GYARADOS); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4); }); it("should deal 0x damage to water/ground type under Electrify", async () => { - game.override - .enemyMoveset([ Moves.ELECTRIFY ]) - .enemySpecies(Species.BARBOACH); + game.override.enemyMoveset([Moves.ELECTRIFY]).enemySpecies(Species.BARBOACH); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0); }); it("should deal 0.25x damage to Grass/Dragon type under Electrify", async () => { - game.override - .enemyMoveset([ Moves.ELECTRIFY ]) - .enemySpecies(Species.FLAPPLE); + game.override.enemyMoveset([Moves.ELECTRIFY]).enemySpecies(Species.FLAPPLE); await game.classicMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(0.25); }); it("should deal 2x damage to Water type during inverse battle", async () => { - game.override - .moveset([ Moves.FREEZE_DRY ]) - .enemySpecies(Species.MAGIKARP); + game.override.moveset([Moves.FREEZE_DRY]).enemySpecies(Species.MAGIKARP); game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1); - await game.challengeMode.startBattle(); const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("should deal 2x damage to Water type during inverse battle under Normalize", async () => { - game.override - .moveset([ Moves.FREEZE_DRY ]) - .ability(Abilities.NORMALIZE) - .enemySpecies(Species.MAGIKARP); + game.override.moveset([Moves.FREEZE_DRY]).ability(Abilities.NORMALIZE).enemySpecies(Species.MAGIKARP); game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1); await game.challengeMode.startBattle(); @@ -306,17 +289,14 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("should deal 2x damage to Water type during inverse battle under Electrify", async () => { - game.override - .moveset([ Moves.FREEZE_DRY ]) - .enemySpecies(Species.MAGIKARP) - .enemyMoveset([ Moves.ELECTRIFY ]); + game.override.moveset([Moves.FREEZE_DRY]).enemySpecies(Species.MAGIKARP).enemyMoveset([Moves.ELECTRIFY]); game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1); await game.challengeMode.startBattle(); @@ -325,16 +305,14 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.getMoveEffectiveness).toHaveLastReturnedWith(2); }); it("should deal 1x damage to water/flying type during inverse battle under Electrify", async () => { - game.override - .enemyMoveset([ Moves.ELECTRIFY ]) - .enemySpecies(Species.GYARADOS); + game.override.enemyMoveset([Moves.ELECTRIFY]).enemySpecies(Species.GYARADOS); game.challengeMode.addChallenge(Challenges.INVERSE_BATTLE, 1, 1); @@ -344,7 +322,7 @@ describe("Moves - Freeze-Dry", () => { vi.spyOn(enemy, "getMoveEffectiveness"); game.move.select(Moves.FREEZE_DRY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(1); diff --git a/test/moves/freezy_frost.test.ts b/test/moves/freezy_frost.test.ts index fe7fee10ad1..c1ac4054e70 100644 --- a/test/moves/freezy_frost.test.ts +++ b/test/moves/freezy_frost.test.ts @@ -27,79 +27,73 @@ describe("Moves - Freezy Frost", () => { .battleType("single") .enemySpecies(Species.RATTATA) .enemyLevel(100) - .enemyMoveset([ Moves.HOWL, Moves.HOWL, Moves.HOWL, Moves.HOWL ]) + .enemyMoveset([Moves.HOWL, Moves.HOWL, Moves.HOWL, Moves.HOWL]) .enemyAbility(Abilities.BALL_FETCH) .startingLevel(100) - .moveset([ Moves.FREEZY_FROST, Moves.HOWL, Moves.SPLASH ]) + .moveset([Moves.FREEZY_FROST, Moves.HOWL, Moves.SPLASH]) .ability(Abilities.BALL_FETCH); vi.spyOn(allMoves[Moves.FREEZY_FROST], "accuracy", "get").mockReturnValue(100); }); - it( - "should clear stat changes of user and opponent", - async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); - const user = game.scene.getPlayerPokemon()!; - const enemy = game.scene.getEnemyPokemon()!; + it("should clear stat changes of user and opponent", async () => { + await game.classicMode.startBattle([Species.SHUCKLE]); + const user = game.scene.getPlayerPokemon()!; + const enemy = game.scene.getEnemyPokemon()!; - game.move.select(Moves.HOWL); - await game.toNextTurn(); + game.move.select(Moves.HOWL); + await game.toNextTurn(); - expect(user.getStatStage(Stat.ATK)).toBe(1); - expect(enemy.getStatStage(Stat.ATK)).toBe(1); + expect(user.getStatStage(Stat.ATK)).toBe(1); + expect(enemy.getStatStage(Stat.ATK)).toBe(1); - game.move.select(Moves.FREEZY_FROST); - await game.toNextTurn(); + game.move.select(Moves.FREEZY_FROST); + await game.toNextTurn(); - expect(user.getStatStage(Stat.ATK)).toBe(0); - expect(enemy.getStatStage(Stat.ATK)).toBe(0); - }); + expect(user.getStatStage(Stat.ATK)).toBe(0); + expect(enemy.getStatStage(Stat.ATK)).toBe(0); + }); - it( - "should clear all stat changes even when enemy uses the move", - async () => { - game.override.enemyMoveset([ Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST ]); - await game.classicMode.startBattle([ Species.SHUCKLE ]); // Shuckle for slower Howl on first turn so Freezy Frost doesn't affect it. - const user = game.scene.getPlayerPokemon()!; + it("should clear all stat changes even when enemy uses the move", async () => { + game.override.enemyMoveset([Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST, Moves.FREEZY_FROST]); + await game.classicMode.startBattle([Species.SHUCKLE]); // Shuckle for slower Howl on first turn so Freezy Frost doesn't affect it. + const user = game.scene.getPlayerPokemon()!; - game.move.select(Moves.HOWL); - await game.toNextTurn(); + game.move.select(Moves.HOWL); + await game.toNextTurn(); - const userAtkBefore = user.getStatStage(Stat.ATK); - expect(userAtkBefore).toBe(1); + const userAtkBefore = user.getStatStage(Stat.ATK); + expect(userAtkBefore).toBe(1); - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(user.getStatStage(Stat.ATK)).toBe(0); - }); + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(user.getStatStage(Stat.ATK)).toBe(0); + }); - it( - "should clear all stat changes in double battle", - async () => { - game.override.battleType("double"); - await game.classicMode.startBattle([ Species.SHUCKLE, Species.RATTATA ]); - const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField(); - const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + it("should clear all stat changes in double battle", async () => { + game.override.battleType("double"); + await game.classicMode.startBattle([Species.SHUCKLE, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); + const [leftOpp, rightOpp] = game.scene.getEnemyField(); - game.move.select(Moves.HOWL, 0); - await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); - await game.toNextTurn(); + game.move.select(Moves.HOWL, 0); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); - expect(leftPlayer.getStatStage(Stat.ATK)).toBe(1); - expect(rightPlayer.getStatStage(Stat.ATK)).toBe(1); - expect(leftOpp.getStatStage(Stat.ATK)).toBe(2); // Both enemies use Howl - expect(rightOpp.getStatStage(Stat.ATK)).toBe(2); + expect(leftPlayer.getStatStage(Stat.ATK)).toBe(1); + expect(rightPlayer.getStatStage(Stat.ATK)).toBe(1); + expect(leftOpp.getStatStage(Stat.ATK)).toBe(2); // Both enemies use Howl + expect(rightOpp.getStatStage(Stat.ATK)).toBe(2); - game.move.select(Moves.FREEZY_FROST, 0, leftOpp.getBattlerIndex()); - await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); - await game.toNextTurn(); + game.move.select(Moves.FREEZY_FROST, 0, leftOpp.getBattlerIndex()); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); - expect(leftPlayer.getStatStage(Stat.ATK)).toBe(0); - expect(rightPlayer.getStatStage(Stat.ATK)).toBe(0); - expect(leftOpp.getStatStage(Stat.ATK)).toBe(0); - expect(rightOpp.getStatStage(Stat.ATK)).toBe(0); - }); + expect(leftPlayer.getStatStage(Stat.ATK)).toBe(0); + expect(rightPlayer.getStatStage(Stat.ATK)).toBe(0); + expect(leftOpp.getStatStage(Stat.ATK)).toBe(0); + expect(rightOpp.getStatStage(Stat.ATK)).toBe(0); + }); }); diff --git a/test/moves/fusion_bolt.test.ts b/test/moves/fusion_bolt.test.ts index 9bb53ef8fb0..fc47a0f04be 100644 --- a/test/moves/fusion_bolt.test.ts +++ b/test/moves/fusion_bolt.test.ts @@ -23,12 +23,12 @@ describe("Moves - Fusion Bolt", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionBolt ]); + game.override.moveset([fusionBolt]); game.override.startingLevel(1); game.override.enemySpecies(Species.RESHIRAM); game.override.enemyAbility(Abilities.ROUGH_SKIN); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); game.override.battleType("single"); game.override.startingWave(97); @@ -36,9 +36,7 @@ describe("Moves - Fusion Bolt", () => { }); it("should not make contact", async () => { - await game.startBattle([ - Species.ZEKROM, - ]); + await game.startBattle([Species.ZEKROM]); const partyMember = game.scene.getPlayerPokemon()!; const initialHp = partyMember.hp; diff --git a/test/moves/fusion_flare.test.ts b/test/moves/fusion_flare.test.ts index 02f5b19d97f..17653cf58bc 100644 --- a/test/moves/fusion_flare.test.ts +++ b/test/moves/fusion_flare.test.ts @@ -24,11 +24,11 @@ describe("Moves - Fusion Flare", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionFlare ]); + game.override.moveset([fusionFlare]); game.override.startingLevel(1); game.override.enemySpecies(Species.RATTATA); - game.override.enemyMoveset([ Moves.REST, Moves.REST, Moves.REST, Moves.REST ]); + game.override.enemyMoveset([Moves.REST, Moves.REST, Moves.REST, Moves.REST]); game.override.battleType("single"); game.override.startingWave(97); @@ -36,9 +36,7 @@ describe("Moves - Fusion Flare", () => { }); it("should thaw freeze status condition", async () => { - await game.startBattle([ - Species.RESHIRAM, - ]); + await game.startBattle([Species.RESHIRAM]); const partyMember = game.scene.getPlayerPokemon()!; diff --git a/test/moves/fusion_flare_bolt.test.ts b/test/moves/fusion_flare_bolt.test.ts index aa2b0cb1bc3..9a379cb4588 100644 --- a/test/moves/fusion_flare_bolt.test.ts +++ b/test/moves/fusion_flare_bolt.test.ts @@ -30,11 +30,11 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ fusionFlare.id, fusionBolt.id ]); + game.override.moveset([fusionFlare.id, fusionBolt.id]); game.override.startingLevel(1); game.override.enemySpecies(Species.RESHIRAM); - game.override.enemyMoveset([ Moves.REST, Moves.REST, Moves.REST, Moves.REST ]); + game.override.enemyMoveset([Moves.REST, Moves.REST, Moves.REST, Moves.REST]); game.override.battleType("double"); game.override.startingWave(97); @@ -45,16 +45,13 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }); it("FUSION_FLARE should double power of subsequent FUSION_BOLT", async () => { - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); game.move.select(fusionFlare.id, 0, BattlerIndex.ENEMY); game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -68,16 +65,13 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_BOLT should double power of subsequent FUSION_FLARE", async () => { - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); game.move.select(fusionBolt.id, 0, BattlerIndex.ENEMY); game.move.select(fusionFlare.id, 1, BattlerIndex.ENEMY); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -91,16 +85,13 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_FLARE should double power of subsequent FUSION_BOLT if a move failed in between", async () => { - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); game.move.select(fusionFlare.id, 0, BattlerIndex.PLAYER); game.move.select(fusionBolt.id, 1, BattlerIndex.PLAYER); // Force first enemy to act (and fail) in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -119,17 +110,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_FLARE should not double power of subsequent FUSION_BOLT if a move succeeded in between", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); game.move.select(fusionFlare.id, 0, BattlerIndex.ENEMY); game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionFlare.id); @@ -147,16 +135,13 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_FLARE should double power of subsequent FUSION_BOLT if moves are aimed at allies", async () => { - await game.startBattle([ - Species.ZEKROM, - Species.RESHIRAM - ]); + await game.startBattle([Species.ZEKROM, Species.RESHIRAM]); game.move.select(fusionBolt.id, 0, BattlerIndex.PLAYER_2); game.move.select(fusionFlare.id, 1, BattlerIndex.PLAYER); // Force user party to act before enemy party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -170,11 +155,8 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves", async () => { - game.override.enemyMoveset([ fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id ]); - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + game.override.enemyMoveset([fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); const party = game.scene.getPlayerParty(); const enemyParty = game.scene.getEnemyParty(); @@ -185,19 +167,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Mock stats by replacing entries in copy with desired values for specific stats const stats = { - enemy: [ - [ ...enemyParty[0].stats ], - [ ...enemyParty[1].stats ], - ], - player: [ - [ ...party[0].stats ], - [ ...party[1].stats ], - ] + enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]], + player: [[...party[0].stats], [...party[1].stats]], }; // Ensure survival by reducing enemy Sp. Atk and boosting party Sp. Def - vi.spyOn(enemyParty[0], "stats", "get").mockReturnValue(stats.enemy[0].map((val, i) => (i === Stat.SPATK ? 1 : val))); - vi.spyOn(enemyParty[1], "stats", "get").mockReturnValue(stats.enemy[1].map((val, i) => (i === Stat.SPATK ? 1 : val))); + vi.spyOn(enemyParty[0], "stats", "get").mockReturnValue( + stats.enemy[0].map((val, i) => (i === Stat.SPATK ? 1 : val)), + ); + vi.spyOn(enemyParty[1], "stats", "get").mockReturnValue( + stats.enemy[1].map((val, i) => (i === Stat.SPATK ? 1 : val)), + ); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[0].map((val, i) => (i === Stat.SPDEF ? 250 : val))); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[1].map((val, i) => (i === Stat.SPDEF ? 250 : val))); @@ -205,7 +185,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { game.move.select(fusionBolt.id, 1, BattlerIndex.ENEMY); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); @@ -229,11 +209,8 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { }, 20000); it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves if moves are aimed at allies", async () => { - game.override.enemyMoveset([ fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id ]); - await game.startBattle([ - Species.ZEKROM, - Species.ZEKROM - ]); + game.override.enemyMoveset([fusionFlare.id, fusionFlare.id, fusionFlare.id, fusionFlare.id]); + await game.startBattle([Species.ZEKROM, Species.ZEKROM]); const party = game.scene.getPlayerParty(); const enemyParty = game.scene.getEnemyParty(); @@ -244,19 +221,17 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Mock stats by replacing entries in copy with desired values for specific stats const stats = { - enemy: [ - [ ...enemyParty[0].stats ], - [ ...enemyParty[1].stats ], - ], - player: [ - [ ...party[0].stats ], - [ ...party[1].stats ], - ] + enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]], + player: [[...party[0].stats], [...party[1].stats]], }; // Ensure survival by reducing enemy Sp. Atk and boosting party Sp. Def - vi.spyOn(enemyParty[0], "stats", "get").mockReturnValue(stats.enemy[0].map((val, i) => (i === Stat.SPATK ? 1 : val))); - vi.spyOn(enemyParty[1], "stats", "get").mockReturnValue(stats.enemy[1].map((val, i) => (i === Stat.SPATK ? 1 : val))); + vi.spyOn(enemyParty[0], "stats", "get").mockReturnValue( + stats.enemy[0].map((val, i) => (i === Stat.SPATK ? 1 : val)), + ); + vi.spyOn(enemyParty[1], "stats", "get").mockReturnValue( + stats.enemy[1].map((val, i) => (i === Stat.SPATK ? 1 : val)), + ); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[0].map((val, i) => (i === Stat.SPDEF ? 250 : val))); vi.spyOn(party[1], "stats", "get").mockReturnValue(stats.player[1].map((val, i) => (i === Stat.SPDEF ? 250 : val))); @@ -264,7 +239,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { game.move.select(fusionBolt.id, 1, BattlerIndex.PLAYER); // Force first enemy to act in between party - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase, false); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(fusionBolt.id); diff --git a/test/moves/future_sight.test.ts b/test/moves/future_sight.test.ts index e0a9a1efd04..40a940447e4 100644 --- a/test/moves/future_sight.test.ts +++ b/test/moves/future_sight.test.ts @@ -23,7 +23,7 @@ describe("Moves - Future Sight", () => { game = new GameManager(phaserGame); game.override .startingLevel(50) - .moveset([ Moves.FUTURE_SIGHT, Moves.SPLASH ]) + .moveset([Moves.FUTURE_SIGHT, Moves.SPLASH]) .battleType("single") .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.STURDY) @@ -31,7 +31,7 @@ describe("Moves - Future Sight", () => { }); it("hits 2 turns after use, ignores user switch out", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); game.move.select(Moves.FUTURE_SIGHT); await game.toNextTurn(); diff --git a/test/moves/gastro_acid.test.ts b/test/moves/gastro_acid.test.ts index 2e4f7938306..c9f2428845e 100644 --- a/test/moves/gastro_acid.test.ts +++ b/test/moves/gastro_acid.test.ts @@ -6,7 +6,6 @@ import { MoveResult } from "#app/field/pokemon"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Gastro Acid", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,7 +26,7 @@ describe("Moves - Gastro Acid", () => { game.override.startingLevel(1); game.override.enemyLevel(100); game.override.ability(Abilities.NONE); - game.override.moveset([ Moves.GASTRO_ACID, Moves.WATER_GUN, Moves.SPLASH, Moves.CORE_ENFORCER ]); + game.override.moveset([Moves.GASTRO_ACID, Moves.WATER_GUN, Moves.SPLASH, Moves.CORE_ENFORCER]); game.override.enemySpecies(Species.BIDOOF); game.override.enemyMoveset(Moves.SPLASH); game.override.enemyAbility(Abilities.WATER_ABSORB); @@ -68,7 +67,7 @@ describe("Moves - Gastro Acid", () => { game.move.select(Moves.CORE_ENFORCER); // Force player to be slower to enable Core Enforcer to proc its suppression effect - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnInitPhase"); diff --git a/test/moves/geomancy.test.ts b/test/moves/geomancy.test.ts index 914e4f7188a..34281c96c60 100644 --- a/test/moves/geomancy.test.ts +++ b/test/moves/geomancy.test.ts @@ -35,31 +35,31 @@ describe("Moves - Geomancy", () => { }); it("should boost the user's stats on the second turn of use", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; - const affectedStats: EffectiveStat[] = [ Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + const affectedStats: EffectiveStat[] = [Stat.SPATK, Stat.SPDEF, Stat.SPD]; game.move.select(Moves.GEOMANCY); await game.phaseInterceptor.to("TurnEndPhase"); - affectedStats.forEach((stat) => expect(player.getStatStage(stat)).toBe(0)); + affectedStats.forEach(stat => expect(player.getStatStage(stat)).toBe(0)); expect(player.getLastXMoves(1)[0].result).toBe(MoveResult.OTHER); await game.phaseInterceptor.to("TurnEndPhase"); - affectedStats.forEach((stat) => expect(player.getStatStage(stat)).toBe(2)); + affectedStats.forEach(stat => expect(player.getStatStage(stat)).toBe(2)); expect(player.getMoveHistory()).toHaveLength(2); expect(player.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS); - const playerGeomancy = player.getMoveset().find((mv) => mv && mv.moveId === Moves.GEOMANCY); + const playerGeomancy = player.getMoveset().find(mv => mv && mv.moveId === Moves.GEOMANCY); expect(playerGeomancy?.ppUsed).toBe(1); }); it("should execute over 2 turns between waves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const player = game.scene.getPlayerPokemon()!; - const affectedStats: EffectiveStat[] = [ Stat.SPATK, Stat.SPDEF, Stat.SPD ]; + const affectedStats: EffectiveStat[] = [Stat.SPATK, Stat.SPDEF, Stat.SPD]; game.move.select(Moves.GEOMANCY); @@ -69,11 +69,11 @@ describe("Moves - Geomancy", () => { await game.toNextWave(); await game.phaseInterceptor.to("TurnEndPhase"); - affectedStats.forEach((stat) => expect(player.getStatStage(stat)).toBe(2)); + affectedStats.forEach(stat => expect(player.getStatStage(stat)).toBe(2)); expect(player.getMoveHistory()).toHaveLength(2); expect(player.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS); - const playerGeomancy = player.getMoveset().find((mv) => mv && mv.moveId === Moves.GEOMANCY); + const playerGeomancy = player.getMoveset().find(mv => mv && mv.moveId === Moves.GEOMANCY); expect(playerGeomancy?.ppUsed).toBe(1); }); }); diff --git a/test/moves/gigaton_hammer.test.ts b/test/moves/gigaton_hammer.test.ts index 37735b29a3b..a6f7438a0a2 100644 --- a/test/moves/gigaton_hammer.test.ts +++ b/test/moves/gigaton_hammer.test.ts @@ -25,20 +25,20 @@ describe("Moves - Gigaton Hammer", () => { .battleType("single") .enemySpecies(Species.MAGIKARP) .starterSpecies(Species.FEEBAS) - .moveset([ Moves.GIGATON_HAMMER ]) + .moveset([Moves.GIGATON_HAMMER]) .startingLevel(10) .enemyLevel(100) .enemyMoveset(Moves.SPLASH) .disableCrits(); }); - it("can't be used two turns in a row", async() => { + it("can't be used two turns in a row", async () => { await game.classicMode.startBattle(); const enemy1 = game.scene.getEnemyPokemon()!; game.move.select(Moves.GIGATON_HAMMER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy1.hp).toBeLessThan(enemy1.getMaxHp()); @@ -54,14 +54,14 @@ describe("Moves - Gigaton Hammer", () => { expect(enemy2.hp).toBe(enemy2.getMaxHp()); }, 20000); - it("can be used again if recalled and sent back out", async() => { + it("can be used again if recalled and sent back out", async () => { game.override.startingWave(4); await game.classicMode.startBattle(); const enemy1 = game.scene.getEnemyPokemon()!; game.move.select(Moves.GIGATON_HAMMER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy1.hp).toBeLessThan(enemy1.getMaxHp()); diff --git a/test/moves/glaive_rush.test.ts b/test/moves/glaive_rush.test.ts index 278cea86c83..d3531b172e2 100644 --- a/test/moves/glaive_rush.test.ts +++ b/test/moves/glaive_rush.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Glaive Rush", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,10 +27,10 @@ describe("Moves - Glaive Rush", () => { .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.GLAIVE_RUSH ]) + .enemyMoveset([Moves.GLAIVE_RUSH]) .starterSpecies(Species.KLINK) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.SHADOW_SNEAK, Moves.AVALANCHE, Moves.SPLASH, Moves.GLAIVE_RUSH ]); + .moveset([Moves.SHADOW_SNEAK, Moves.AVALANCHE, Moves.SPLASH, Moves.GLAIVE_RUSH]); }); it("takes double damage from attacks", async () => { @@ -46,8 +45,7 @@ describe("Moves - Glaive Rush", () => { await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to("DamageAnimPhase"); - expect(enemy.hp).toBeLessThanOrEqual(1001 - (damageDealt * 3)); - + expect(enemy.hp).toBeLessThanOrEqual(1001 - damageDealt * 3); }); it("always gets hit by attacks", async () => { @@ -60,13 +58,10 @@ describe("Moves - Glaive Rush", () => { game.move.select(Moves.AVALANCHE); await game.phaseInterceptor.to("TurnEndPhase"); expect(enemy.hp).toBeLessThan(1000); - }); it("interacts properly with multi-lens", async () => { - game.override - .startingHeldItems([{ name: "MULTI_LENS", count: 2 }]) - .enemyMoveset([ Moves.AVALANCHE ]); + game.override.startingHeldItems([{ name: "MULTI_LENS", count: 2 }]).enemyMoveset([Moves.AVALANCHE]); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -83,11 +78,10 @@ describe("Moves - Glaive Rush", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); expect(player.hp).toBe(1000); - }); it("secondary effects only last until next move", async () => { - game.override.enemyMoveset([ Moves.SHADOW_SNEAK ]); + game.override.enemyMoveset([Moves.SHADOW_SNEAK]); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -109,14 +103,11 @@ describe("Moves - Glaive Rush", () => { game.move.select(Moves.SPLASH); await game.phaseInterceptor.to("TurnEndPhase"); expect(player.hp).toBe(damagedHp); - }); it("secondary effects are removed upon switching", async () => { - game.override - .enemyMoveset([ Moves.SHADOW_SNEAK ]) - .starterSpecies(0); - await game.classicMode.startBattle([ Species.KLINK, Species.FEEBAS ]); + game.override.enemyMoveset([Moves.SHADOW_SNEAK]).starterSpecies(0); + await game.classicMode.startBattle([Species.KLINK, Species.FEEBAS]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -133,11 +124,10 @@ describe("Moves - Glaive Rush", () => { game.doSwitchPokemon(1); await game.phaseInterceptor.to("TurnEndPhase"); expect(player.hp).toBe(player.getMaxHp()); - }); it("secondary effects don't activate if move fails", async () => { - game.override.moveset([ Moves.SHADOW_SNEAK, Moves.PROTECT, Moves.SPLASH, Moves.GLAIVE_RUSH ]); + game.override.moveset([Moves.SHADOW_SNEAK, Moves.PROTECT, Moves.SPLASH, Moves.GLAIVE_RUSH]); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -151,7 +141,7 @@ describe("Moves - Glaive Rush", () => { game.move.select(Moves.SHADOW_SNEAK); await game.phaseInterceptor.to("TurnEndPhase"); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); const damagedHP1 = 1000 - enemy.hp; enemy.hp = 1000; @@ -159,6 +149,6 @@ describe("Moves - Glaive Rush", () => { await game.phaseInterceptor.to("TurnEndPhase"); const damagedHP2 = 1000 - enemy.hp; - expect(damagedHP2).toBeGreaterThanOrEqual((damagedHP1 * 2) - 1); + expect(damagedHP2).toBeGreaterThanOrEqual(damagedHP1 * 2 - 1); }); }); diff --git a/test/moves/growth.test.ts b/test/moves/growth.test.ts index dfc41acd757..926593a4f72 100644 --- a/test/moves/growth.test.ts +++ b/test/moves/growth.test.ts @@ -27,14 +27,12 @@ describe("Moves - Growth", () => { game.override.battleType("single"); game.override.enemyAbility(Abilities.MOXIE); game.override.ability(Abilities.INSOMNIA); - game.override.moveset([ Moves.GROWTH ]); + game.override.moveset([Moves.GROWTH]); game.override.enemyMoveset(Moves.SPLASH); }); - it("should raise SPATK stat stage by 1", async() => { - await game.startBattle([ - Species.MIGHTYENA - ]); + it("should raise SPATK stat stage by 1", async () => { + await game.startBattle([Species.MIGHTYENA]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/grudge.test.ts b/test/moves/grudge.test.ts index 4b9683dd417..ebd062a76ee 100644 --- a/test/moves/grudge.test.ts +++ b/test/moves/grudge.test.ts @@ -23,22 +23,22 @@ describe("Moves - Grudge", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.EMBER, Moves.SPLASH ]) + .moveset([Moves.EMBER, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() .enemySpecies(Species.SHEDINJA) .enemyAbility(Abilities.WONDER_GUARD) - .enemyMoveset([ Moves.GRUDGE, Moves.SPLASH ]); + .enemyMoveset([Moves.GRUDGE, Moves.SPLASH]); }); it("should reduce the PP of the Pokemon's move to 0 when the user has fainted", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.EMBER); await game.forceEnemyMove(Moves.GRUDGE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); const playerMove = playerPokemon?.getMoveset().find(m => m?.moveId === Moves.EMBER); @@ -47,17 +47,17 @@ describe("Moves - Grudge", () => { }); it("should remain in effect until the user's next move", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.GRUDGE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); game.move.select(Moves.EMBER); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); const playerMove = playerPokemon?.getMoveset().find(m => m?.moveId === Moves.EMBER); @@ -68,18 +68,18 @@ describe("Moves - Grudge", () => { it("should not reduce the opponent's PP if the user dies to weather/indirect damage", async () => { // Opponent will be reduced to 1 HP by False Swipe, then faint to Sandstorm game.override - .moveset([ Moves.FALSE_SWIPE ]) + .moveset([Moves.FALSE_SWIPE]) .startingLevel(100) .ability(Abilities.SAND_STREAM) .enemySpecies(Species.RATTATA); - await game.classicMode.startBattle([ Species.GEODUDE ]); + await game.classicMode.startBattle([Species.GEODUDE]); const enemyPokemon = game.scene.getEnemyPokemon(); const playerPokemon = game.scene.getPlayerPokemon(); game.move.select(Moves.FALSE_SWIPE); await game.forceEnemyMove(Moves.GRUDGE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon?.isFainted()).toBe(true); diff --git a/test/moves/guard_split.test.ts b/test/moves/guard_split.test.ts index af5023608d3..5db07e4e82c 100644 --- a/test/moves/guard_split.test.ts +++ b/test/moves/guard_split.test.ts @@ -28,15 +28,13 @@ describe("Moves - Guard Split", () => { .enemyAbility(Abilities.NONE) .enemySpecies(Species.MEW) .enemyLevel(200) - .moveset([ Moves.GUARD_SPLIT ]) + .moveset([Moves.GUARD_SPLIT]) .ability(Abilities.NONE); }); it("should average the user's DEF and SPDEF stats with those of the target", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ - Species.INDEEDEE - ]); + await game.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -55,10 +53,8 @@ describe("Moves - Guard Split", () => { }, 20000); it("should be idempotent", async () => { - game.override.enemyMoveset([ Moves.GUARD_SPLIT ]); - await game.startBattle([ - Species.INDEEDEE - ]); + game.override.enemyMoveset([Moves.GUARD_SPLIT]); + await game.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/guard_swap.test.ts b/test/moves/guard_swap.test.ts index 592307ff168..be824672f32 100644 --- a/test/moves/guard_swap.test.ts +++ b/test/moves/guard_swap.test.ts @@ -29,14 +29,12 @@ describe("Moves - Guard Swap", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.INDEEDEE) .enemyLevel(200) - .moveset([ Moves.GUARD_SWAP ]) + .moveset([Moves.GUARD_SWAP]) .ability(Abilities.NONE); }); it("should swap the user's DEF and SPDEF stat stages with the target's", async () => { - await game.classicMode.startBattle([ - Species.INDEEDEE - ]); + await game.classicMode.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/hard_press.test.ts b/test/moves/hard_press.test.ts index 32c9190e06e..1bb6adc8e90 100644 --- a/test/moves/hard_press.test.ts +++ b/test/moves/hard_press.test.ts @@ -30,12 +30,12 @@ describe("Moves - Hard Press", () => { game.override.enemySpecies(Species.MUNCHLAX); game.override.enemyAbility(Abilities.BALL_FETCH); game.override.enemyMoveset(Moves.SPLASH); - game.override.moveset([ Moves.HARD_PRESS ]); + game.override.moveset([Moves.HARD_PRESS]); vi.spyOn(moveToCheck, "calculateBattlePower"); }); it("should return 100 power if target HP ratio is at 100%", async () => { - await game.startBattle([ Species.PIKACHU ]); + await game.startBattle([Species.PIKACHU]); game.move.select(Moves.HARD_PRESS); await game.phaseInterceptor.to(MoveEffectPhase); @@ -44,8 +44,8 @@ describe("Moves - Hard Press", () => { }); it("should return 50 power if target HP ratio is at 50%", async () => { - await game.startBattle([ Species.PIKACHU ]); - const targetHpRatio = .5; + await game.startBattle([Species.PIKACHU]); + const targetHpRatio = 0.5; const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); @@ -57,8 +57,8 @@ describe("Moves - Hard Press", () => { }); it("should return 1 power if target HP ratio is at 1%", async () => { - await game.startBattle([ Species.PIKACHU ]); - const targetHpRatio = .01; + await game.startBattle([Species.PIKACHU]); + const targetHpRatio = 0.01; const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); @@ -70,8 +70,8 @@ describe("Moves - Hard Press", () => { }); it("should return 1 power if target HP ratio is less than 1%", async () => { - await game.startBattle([ Species.PIKACHU ]); - const targetHpRatio = .005; + await game.startBattle([Species.PIKACHU]); + const targetHpRatio = 0.005; const enemy = game.scene.getEnemyPokemon()!; vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); diff --git a/test/moves/haze.test.ts b/test/moves/haze.test.ts index 11071bdc07d..d890678b466 100644 --- a/test/moves/haze.test.ts +++ b/test/moves/haze.test.ts @@ -31,12 +31,12 @@ describe("Moves - Haze", () => { game.override.enemyAbility(Abilities.NONE); game.override.startingLevel(100); - game.override.moveset([ Moves.HAZE, Moves.SWORDS_DANCE, Moves.CHARM, Moves.SPLASH ]); + game.override.moveset([Moves.HAZE, Moves.SWORDS_DANCE, Moves.CHARM, Moves.SPLASH]); game.override.ability(Abilities.NONE); }); it("should reset all stat changes of all Pokemon on field", async () => { - await game.startBattle([ Species.RATTATA ]); + await game.startBattle([Species.RATTATA]); const user = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/heal_bell.test.ts b/test/moves/heal_bell.test.ts index 72957ee21e7..4c0148bfd04 100644 --- a/test/moves/heal_bell.test.ts +++ b/test/moves/heal_bell.test.ts @@ -24,7 +24,7 @@ describe("Moves - Heal Bell", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.HEAL_BELL, Moves.SPLASH ]) + .moveset([Moves.HEAL_BELL, Moves.SPLASH]) .statusEffect(StatusEffect.BURN) .battleType("double") .enemyAbility(Abilities.BALL_FETCH) @@ -32,8 +32,8 @@ describe("Moves - Heal Bell", () => { }); it("should cure status effect of the user, its ally, and all party pokemon", async () => { - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty(); vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus"); @@ -55,8 +55,8 @@ describe("Moves - Heal Bell", () => { it("should not cure status effect of the target/target's allies", async () => { game.override.enemyStatusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA ]); - const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftOpp, rightOpp] = game.scene.getEnemyField(); vi.spyOn(leftOpp, "resetStatus"); vi.spyOn(rightOpp, "resetStatus"); @@ -78,8 +78,8 @@ describe("Moves - Heal Bell", () => { it("should not cure status effect of allies ON FIELD with Soundproof, should still cure allies in party", async () => { game.override.ability(Abilities.SOUNDPROOF); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty(); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty(); vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus"); diff --git a/test/moves/heal_block.test.ts b/test/moves/heal_block.test.ts index a0e8eaf541c..4ef67214a91 100644 --- a/test/moves/heal_block.test.ts +++ b/test/moves/heal_block.test.ts @@ -28,7 +28,7 @@ describe("Moves - Heal Block", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.ABSORB, Moves.WISH, Moves.SPLASH, Moves.AQUA_RING ]) + .moveset([Moves.ABSORB, Moves.WISH, Moves.SPLASH, Moves.AQUA_RING]) .enemyMoveset(Moves.HEAL_BLOCK) .ability(Abilities.NO_GUARD) .enemyAbility(Abilities.BALL_FETCH) @@ -36,9 +36,8 @@ describe("Moves - Heal Block", () => { .disableCrits(); }); - it("shouldn't stop damage from HP-drain attacks, just HP restoration", async() => { - - await game.classicMode.startBattle([ Species.CHARIZARD ]); + it("shouldn't stop damage from HP-drain attacks, just HP restoration", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -46,31 +45,31 @@ describe("Moves - Heal Block", () => { player.damageAndUpdate(enemy.getMaxHp() - 1); game.move.select(Moves.ABSORB); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(player.hp).toBe(1); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); }); - it("shouldn't stop Liquid Ooze from dealing damage", async() => { + it("shouldn't stop Liquid Ooze from dealing damage", async () => { game.override.enemyAbility(Abilities.LIQUID_OOZE); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.ABSORB); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(player.isFullHp()).toBe(false); expect(enemy.isFullHp()).toBe(false); }); - it("should stop delayed heals, such as from Wish", async() => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + it("should stop delayed heals, such as from Wish", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; @@ -88,10 +87,10 @@ describe("Moves - Heal Block", () => { expect(player.hp).toBe(1); }); - it("should prevent Grassy Terrain from restoring HP", async() => { + it("should prevent Grassy Terrain from restoring HP", async () => { game.override.enemyAbility(Abilities.GRASSY_SURGE); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; @@ -103,8 +102,8 @@ describe("Moves - Heal Block", () => { expect(player.hp).toBe(1); }); - it("should prevent healing from heal-over-time moves", async() => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + it("should prevent healing from heal-over-time moves", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; @@ -117,12 +116,10 @@ describe("Moves - Heal Block", () => { expect(player.hp).toBe(1); }); - it("should prevent abilities from restoring HP", async() => { - game.override - .weather(WeatherType.RAIN) - .ability(Abilities.RAIN_DISH); + it("should prevent abilities from restoring HP", async () => { + game.override.weather(WeatherType.RAIN).ability(Abilities.RAIN_DISH); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; @@ -134,10 +131,10 @@ describe("Moves - Heal Block", () => { expect(player.hp).toBe(1); }); - it("should stop healing from items", async() => { + it("should stop healing from items", async () => { game.override.startingHeldItems([{ name: "LEFTOVERS" }]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); const player = game.scene.getPlayerPokemon()!; player.damageAndUpdate(player.getMaxHp() - 1); diff --git a/test/moves/heart_swap.test.ts b/test/moves/heart_swap.test.ts index 43569a32a69..a3d892cd518 100644 --- a/test/moves/heart_swap.test.ts +++ b/test/moves/heart_swap.test.ts @@ -29,14 +29,12 @@ describe("Moves - Heart Swap", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.INDEEDEE) .enemyLevel(200) - .moveset([ Moves.HEART_SWAP ]) + .moveset([Moves.HEART_SWAP]) .ability(Abilities.NONE); }); it("should swap all of the user's stat stages with the target's", async () => { - await game.classicMode.startBattle([ - Species.MANAPHY - ]); + await game.classicMode.startBattle([Species.MANAPHY]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/hyper_beam.test.ts b/test/moves/hyper_beam.test.ts index f03d54426d6..5cd54e9b46a 100644 --- a/test/moves/hyper_beam.test.ts +++ b/test/moves/hyper_beam.test.ts @@ -15,7 +15,7 @@ describe("Moves - Hyper Beam", () => { beforeAll(() => { phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS + type: Phaser.HEADLESS, }); }); @@ -30,41 +30,38 @@ describe("Moves - Hyper Beam", () => { game.override.ability(Abilities.BALL_FETCH); game.override.enemySpecies(Species.SNORLAX); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); game.override.enemyLevel(100); - game.override.moveset([ Moves.HYPER_BEAM, Moves.TACKLE ]); + game.override.moveset([Moves.HYPER_BEAM, Moves.TACKLE]); vi.spyOn(allMoves[Moves.HYPER_BEAM], "accuracy", "get").mockReturnValue(100); }); - it( - "should force the user to recharge on the next turn (and only that turn)", - async () => { - await game.startBattle([ Species.MAGIKARP ]); + it("should force the user to recharge on the next turn (and only that turn)", async () => { + await game.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.HYPER_BEAM); + game.move.select(Moves.HYPER_BEAM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined(); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined(); - const enemyPostAttackHp = enemyPokemon.hp; + const enemyPostAttackHp = enemyPokemon.hp; - /** Game should progress without a new command from the player */ - await game.phaseInterceptor.to(TurnEndPhase); + /** Game should progress without a new command from the player */ + await game.phaseInterceptor.to(TurnEndPhase); - expect(enemyPokemon.hp).toBe(enemyPostAttackHp); - expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); + expect(enemyPokemon.hp).toBe(enemyPostAttackHp); + expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.hp).toBeLessThan(enemyPostAttackHp); - } - ); + expect(enemyPokemon.hp).toBeLessThan(enemyPostAttackHp); + }); }); diff --git a/test/moves/imprison.test.ts b/test/moves/imprison.test.ts index 85d529d7a74..89ef9981040 100644 --- a/test/moves/imprison.test.ts +++ b/test/moves/imprison.test.ts @@ -25,13 +25,13 @@ describe("Moves - Imprison", () => { game.override .battleType("single") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.IMPRISON, Moves.SPLASH, Moves.GROWL ]) + .enemyMoveset([Moves.IMPRISON, Moves.SPLASH, Moves.GROWL]) .enemySpecies(Species.SHUCKLE) - .moveset([ Moves.TRANSFORM, Moves.SPLASH ]); + .moveset([Moves.TRANSFORM, Moves.SPLASH]); }); it("Pokemon under Imprison cannot use shared moves", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -39,7 +39,10 @@ describe("Moves - Imprison", () => { await game.forceEnemyMove(Moves.IMPRISON); await game.toNextTurn(); const playerMoveset = playerPokemon.getMoveset().map(x => x?.moveId); - const enemyMoveset = game.scene.getEnemyPokemon()!.getMoveset().map(x => x?.moveId); + const enemyMoveset = game.scene + .getEnemyPokemon()! + .getMoveset() + .map(x => x?.moveId); expect(enemyMoveset.includes(playerMoveset[0])).toBeTruthy(); const imprisonArenaTag = game.scene.arena.getTag(ArenaTagType.IMPRISON); const imprisonBattlerTag = playerPokemon.getTag(BattlerTagType.IMPRISON); @@ -55,7 +58,7 @@ describe("Moves - Imprison", () => { }); it("Imprison applies to Pokemon switched into Battle", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); const playerPokemon1 = game.scene.getPlayerPokemon()!; @@ -78,8 +81,8 @@ describe("Moves - Imprison", () => { }); it("The effects of Imprison only end when the source is no longer active", async () => { - game.override.moveset([ Moves.SPLASH, Moves.IMPRISON ]); - await game.classicMode.startBattle([ Species.REGIELEKI, Species.BULBASAUR ]); + game.override.moveset([Moves.SPLASH, Moves.IMPRISON]); + await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/moves/instruct.test.ts b/test/moves/instruct.test.ts index db9801932cc..079c8803ddc 100644 --- a/test/moves/instruct.test.ts +++ b/test/moves/instruct.test.ts @@ -41,17 +41,15 @@ describe("Moves - Instruct", () => { }); it("should repeat target's last used move", async () => { - game.override - .moveset(Moves.INSTRUCT) - .enemyLevel(1000); // ensures shuckle no die - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset(Moves.INSTRUCT).enemyLevel(1000); // ensures shuckle no die + await game.classicMode.startBattle([Species.AMOONGUSS]); const enemy = game.scene.getEnemyPokemon()!; game.move.changeMoveset(enemy, Moves.SONIC_BOOM); game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.SONIC_BOOM); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MovePhase"); // enemy attacks us await game.phaseInterceptor.to("MovePhase", false); // instruct @@ -70,20 +68,20 @@ describe("Moves - Instruct", () => { }); it("should repeat enemy's move through substitute", async () => { - game.override.moveset([ Moves.INSTRUCT, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset([Moves.INSTRUCT, Moves.SPLASH]); + await game.classicMode.startBattle([Species.AMOONGUSS]); const enemy = game.scene.getEnemyPokemon()!; - game.move.changeMoveset(enemy, [ Moves.SONIC_BOOM, Moves.SUBSTITUTE ]); + game.move.changeMoveset(enemy, [Moves.SONIC_BOOM, Moves.SUBSTITUTE]); game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.SUBSTITUTE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.SONIC_BOOM); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase", false); instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM); @@ -91,18 +89,16 @@ describe("Moves - Instruct", () => { }); it("should repeat ally's attack on enemy", async () => { - game.override - .battleType("double") - .enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.SHUCKLE ]); + game.override.battleType("double").enemyMoveset(Moves.SPLASH); + await game.classicMode.startBattle([Species.AMOONGUSS, Species.SHUCKLE]); - const [ amoonguss, shuckle ] = game.scene.getPlayerField(); - game.move.changeMoveset(amoonguss, [ Moves.INSTRUCT, Moves.SONIC_BOOM ]); - game.move.changeMoveset(shuckle, [ Moves.INSTRUCT, Moves.SONIC_BOOM ]); + const [amoonguss, shuckle] = game.scene.getPlayerField(); + game.move.changeMoveset(amoonguss, [Moves.INSTRUCT, Moves.SONIC_BOOM]); + game.move.changeMoveset(shuckle, [Moves.INSTRUCT, Moves.SONIC_BOOM]); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2); game.move.select(Moves.SONIC_BOOM, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); instructSuccess(shuckle, Moves.SONIC_BOOM); @@ -111,16 +107,14 @@ describe("Moves - Instruct", () => { // TODO: Enable test case once gigaton hammer (and blood moon) are reworked it.todo("should repeat enemy's Gigaton Hammer", async () => { - game.override - .moveset(Moves.INSTRUCT) - .enemyLevel(5); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset(Moves.INSTRUCT).enemyLevel(5); + await game.classicMode.startBattle([Species.AMOONGUSS]); const enemy = game.scene.getEnemyPokemon()!; - game.move.changeMoveset(enemy, [ Moves.GIGATON_HAMMER, Moves.BLOOD_MOON ]); + game.move.changeMoveset(enemy, [Moves.GIGATON_HAMMER, Moves.BLOOD_MOON]); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); instructSuccess(enemy, Moves.GIGATON_HAMMER); @@ -128,18 +122,15 @@ describe("Moves - Instruct", () => { }); it("should add moves to move queue for copycat", async () => { - game.override - .battleType("double") - .moveset(Moves.INSTRUCT) - .enemyLevel(5); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.battleType("double").moveset(Moves.INSTRUCT).enemyLevel(5); + await game.classicMode.startBattle([Species.AMOONGUSS]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField()!; + const [enemy1, enemy2] = game.scene.getEnemyField()!; game.move.changeMoveset(enemy1, Moves.WATER_GUN); game.move.changeMoveset(enemy2, Moves.COPYCAT); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); instructSuccess(enemy1, Moves.WATER_GUN); @@ -148,17 +139,15 @@ describe("Moves - Instruct", () => { }); it("should respect enemy's status condition", async () => { - game.override - .moveset([ Moves.INSTRUCT, Moves.THUNDER_WAVE ]) - .enemyMoveset(Moves.SONIC_BOOM); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset([Moves.INSTRUCT, Moves.THUNDER_WAVE]).enemyMoveset(Moves.SONIC_BOOM); + await game.classicMode.startBattle([Species.AMOONGUSS]); game.move.select(Moves.THUNDER_WAVE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MovePhase"); // force enemy's instructed move to bork and then immediately thaw out await game.move.forceStatusActivation(true); @@ -166,15 +155,13 @@ describe("Moves - Instruct", () => { await game.phaseInterceptor.to("TurnEndPhase", false); const moveHistory = game.scene.getEnemyPokemon()?.getLastXMoves(-1)!; - expect(moveHistory.map(m => m.move)).toEqual([ Moves.SONIC_BOOM, Moves.NONE, Moves.SONIC_BOOM ]); + expect(moveHistory.map(m => m.move)).toEqual([Moves.SONIC_BOOM, Moves.NONE, Moves.SONIC_BOOM]); expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40); }); it("should not repeat enemy's out of pp move", async () => { - game.override - .moveset(Moves.INSTRUCT) - .enemySpecies(Species.UNOWN); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset(Moves.INSTRUCT).enemySpecies(Species.UNOWN); + await game.classicMode.startBattle([Species.AMOONGUSS]); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.changeMoveset(enemyPokemon, Moves.HIDDEN_POWER); @@ -183,7 +170,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.HIDDEN_POWER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase", false); const playerMoves = game.scene.getPlayerPokemon()!.getLastXMoves(-1)!; @@ -192,20 +179,16 @@ describe("Moves - Instruct", () => { }); it("should redirect attacking moves if enemy faints", async () => { - game.override - .battleType("double") - .enemyMoveset(Moves.SPLASH) - .enemySpecies(Species.MAGIKARP) - .enemyLevel(1); - await game.classicMode.startBattle([ Species.HISUI_ELECTRODE, Species.KOMMO_O ]); + game.override.battleType("double").enemyMoveset(Moves.SPLASH).enemySpecies(Species.MAGIKARP).enemyLevel(1); + await game.classicMode.startBattle([Species.HISUI_ELECTRODE, Species.KOMMO_O]); - const [ electrode, kommo_o ] = game.scene.getPlayerField()!; + const [electrode, kommo_o] = game.scene.getPlayerField()!; game.move.changeMoveset(electrode, Moves.CHLOROBLAST); game.move.changeMoveset(kommo_o, Moves.INSTRUCT); game.move.select(Moves.CHLOROBLAST, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); // Chloroblast always deals 50% max HP% recoil UNLESS you whiff @@ -213,19 +196,15 @@ describe("Moves - Instruct", () => { // so all we have to do is check whether electrode fainted or not. // Naturally, both karps should also be dead as well. expect(electrode.isFainted()).toBe(true); - const [ karp1, karp2 ] = game.scene.getEnemyField()!; + const [karp1, karp2] = game.scene.getEnemyField()!; expect(karp1.isFainted()).toBe(true); expect(karp2.isFainted()).toBe(true); - }), - + }); it("should allow for dancer copying of instructed dance move", async () => { - game.override - .battleType("double") - .enemyMoveset([ Moves.INSTRUCT, Moves.SPLASH ]) - .enemyLevel(1000); - await game.classicMode.startBattle([ Species.ORICORIO, Species.VOLCARONA ]); + game.override.battleType("double").enemyMoveset([Moves.INSTRUCT, Moves.SPLASH]).enemyLevel(1000); + await game.classicMode.startBattle([Species.ORICORIO, Species.VOLCARONA]); - const [ oricorio, volcarona ] = game.scene.getPlayerField(); + const [oricorio, volcarona] = game.scene.getPlayerField(); game.move.changeMoveset(oricorio, Moves.SPLASH); game.move.changeMoveset(volcarona, Moves.FIERY_DANCE); @@ -233,7 +212,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); // fiery dance triggered dancer successfully for a total of 4 hits @@ -243,15 +222,19 @@ describe("Moves - Instruct", () => { }); it("should not repeat move when switching out", async () => { - game.override - .enemyMoveset(Moves.INSTRUCT) - .enemySpecies(Species.UNOWN); - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.TOXICROAK ]); + game.override.enemyMoveset(Moves.INSTRUCT).enemySpecies(Species.UNOWN); + await game.classicMode.startBattle([Species.AMOONGUSS, Species.TOXICROAK]); const amoonguss = game.scene.getPlayerPokemon()!; game.move.changeMoveset(amoonguss, Moves.SEED_BOMB); - amoonguss.battleSummonData.moveHistory = [{ move: Moves.SEED_BOMB, targets: [ BattlerIndex.ENEMY ], result: MoveResult.SUCCESS }]; + amoonguss.battleSummonData.moveHistory = [ + { + move: Moves.SEED_BOMB, + targets: [BattlerIndex.ENEMY], + result: MoveResult.SUCCESS, + }, + ]; game.doSwitchPokemon(1); await game.phaseInterceptor.to("TurnEndPhase", false); @@ -261,49 +244,50 @@ describe("Moves - Instruct", () => { }); it("should fail if no move has yet been used by target", async () => { - game.override - .moveset(Moves.INSTRUCT) - .enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset(Moves.INSTRUCT).enemyMoveset(Moves.SPLASH); + await game.classicMode.startBattle([Species.AMOONGUSS]); game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); }); it("should attempt to call enemy's disabled move, but move use itself should fail", async () => { - game.override - .moveset([ Moves.INSTRUCT, Moves.DISABLE ]) - .battleType("double"); - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.DROWZEE ]); + game.override.moveset([Moves.INSTRUCT, Moves.DISABLE]).battleType("double"); + await game.classicMode.startBattle([Species.AMOONGUSS, Species.DROWZEE]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); game.move.changeMoveset(enemy1, Moves.SONIC_BOOM); game.move.changeMoveset(enemy2, Moves.SPLASH); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); const enemyMove = game.scene.getEnemyField()[0]!.getLastXMoves()[0]; expect(enemyMove.result).toBe(MoveResult.FAIL); - expect(game.scene.getEnemyField()[0].getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1); + expect( + game.scene + .getEnemyField()[0] + .getMoveset() + .find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed, + ).toBe(1); }); it("should not repeat enemy's move through protect", async () => { - game.override.moveset([ Moves.INSTRUCT ]); - await game.classicMode.startBattle([ Species.AMOONGUSS ]); + game.override.moveset([Moves.INSTRUCT]); + await game.classicMode.startBattle([Species.AMOONGUSS]); const enemy = game.scene.getEnemyPokemon()!; game.move.changeMoveset(enemy, Moves.PROTECT); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(enemy.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT); @@ -312,62 +296,68 @@ describe("Moves - Instruct", () => { }); it("should not repeat enemy's charging move", async () => { - game.override - .moveset([ Moves.INSTRUCT ]) - .enemyMoveset([ Moves.SONIC_BOOM, Moves.HYPER_BEAM ]); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + game.override.moveset([Moves.INSTRUCT]).enemyMoveset([Moves.SONIC_BOOM, Moves.HYPER_BEAM]); + await game.classicMode.startBattle([Species.SHUCKLE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; - enemy.battleSummonData.moveHistory = [{ move: Moves.SONIC_BOOM, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }]; + enemy.battleSummonData.moveHistory = [ + { + move: Moves.SONIC_BOOM, + targets: [BattlerIndex.PLAYER], + result: MoveResult.SUCCESS, + virtual: false, + }, + ]; game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.HYPER_BEAM); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); // instruct fails at copying last move due to charging turn (rather than instructing sonic boom) expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL); }); it("should not repeat move since forgotten by target", async () => { - game.override - .enemyLevel(5) - .xpMultiplier(0) - .enemySpecies(Species.WURMPLE) - .enemyMoveset(Moves.INSTRUCT); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + game.override.enemyLevel(5).xpMultiplier(0).enemySpecies(Species.WURMPLE).enemyMoveset(Moves.INSTRUCT); + await game.classicMode.startBattle([Species.REGIELEKI]); const regieleki = game.scene.getPlayerPokemon()!; // fill out moveset with random moves - game.move.changeMoveset(regieleki, [ Moves.ELECTRO_DRIFT, Moves.SPLASH, Moves.ICE_BEAM, Moves.ANCIENT_POWER ]); + game.move.changeMoveset(regieleki, [Moves.ELECTRO_DRIFT, Moves.SPLASH, Moves.ICE_BEAM, Moves.ANCIENT_POWER]); game.move.select(Moves.ELECTRO_DRIFT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("FaintPhase"); await game.move.learnMove(Moves.ELECTROWEB); await game.toNextWave(); game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.getEnemyField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL); }); it("should disregard priority of instructed move on use", async () => { - game.override - .enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]) - .moveset(Moves.INSTRUCT); - await game.classicMode.startBattle([ Species.LUCARIO, Species.BANETTE ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.WHIRLWIND]).moveset(Moves.INSTRUCT); + await game.classicMode.startBattle([Species.LUCARIO, Species.BANETTE]); const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.WHIRLWIND, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }]; + enemyPokemon.battleSummonData.moveHistory = [ + { + move: Moves.WHIRLWIND, + targets: [BattlerIndex.PLAYER], + result: MoveResult.SUCCESS, + virtual: false, + }, + ]; game.move.select(Moves.INSTRUCT); await game.forceEnemyMove(Moves.SPLASH); @@ -381,11 +371,11 @@ describe("Moves - Instruct", () => { }); it("should respect moves' original priority for psychic terrain", async () => { - game.override. - battleType("double") - .moveset([ Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT ]) - .enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]); - await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]); + game.override + .battleType("double") + .moveset([Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT]) + .enemyMoveset([Moves.SPLASH, Moves.PSYCHIC_TERRAIN]); + await game.classicMode.startBattle([Species.BANETTE, Species.KLEFKI]); game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); @@ -395,7 +385,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); // quick attack failed when instructed @@ -405,14 +395,12 @@ describe("Moves - Instruct", () => { }); it("should still work w/ prankster in psychic terrain", async () => { - game.override. - battleType("double") - .enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]); - await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]); + game.override.battleType("double").enemyMoveset([Moves.SPLASH, Moves.PSYCHIC_TERRAIN]); + await game.classicMode.startBattle([Species.BANETTE, Species.KLEFKI]); - const [ banette, klefki ] = game.scene.getPlayerField()!; - game.move.changeMoveset(banette, [ Moves.VINE_WHIP, Moves.SPLASH ]); - game.move.changeMoveset(klefki, [ Moves.INSTRUCT, Moves.SPLASH ]); + const [banette, klefki] = game.scene.getPlayerField()!; + game.move.changeMoveset(banette, [Moves.VINE_WHIP, Moves.SPLASH]); + game.move.changeMoveset(klefki, [Moves.INSTRUCT, Moves.SPLASH]); game.move.select(Moves.VINE_WHIP, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); @@ -422,74 +410,78 @@ describe("Moves - Instruct", () => { game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); // copies vine whip - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(banette.getLastXMoves(-1)[1].move).toBe(Moves.VINE_WHIP); expect(banette.getLastXMoves(-1)[2].move).toBe(Moves.VINE_WHIP); - expect(banette.getMoveset().find(m => m?.moveId === Moves.VINE_WHIP )?.ppUsed).toBe(2); + expect(banette.getMoveset().find(m => m?.moveId === Moves.VINE_WHIP)?.ppUsed).toBe(2); }); it("should cause spread moves to correctly hit targets in doubles after singles", async () => { game.override .battleType("even-doubles") - .moveset([ Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH ]) + .moveset([Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH]) .enemyMoveset(Moves.SONIC_BOOM) .enemySpecies(Species.AXEW) .startingLevel(500); - await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); + await game.classicMode.startBattle([Species.KORAIDON, Species.KLEFKI]); const koraidon = game.scene.getPlayerField()[0]!; game.move.select(Moves.BREAKING_SWIPE); await game.phaseInterceptor.to("TurnEndPhase", false); expect(koraidon.getInverseHp()).toBe(0); - expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]); + expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([BattlerIndex.ENEMY]); await game.toNextWave(); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); // did not take damage since enemies died beforehand; // last move used hit both enemies expect(koraidon.getInverseHp()).toBe(0); - expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); }); it("should cause AoE moves to correctly hit everyone in doubles after singles", async () => { game.override .battleType("even-doubles") - .moveset([ Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH ]) + .moveset([Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH]) .enemySpecies(Species.AXEW) .enemyMoveset(Moves.SONIC_BOOM) .startingLevel(500); - await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); + await game.classicMode.startBattle([Species.KORAIDON, Species.KLEFKI]); const koraidon = game.scene.getPlayerField()[0]!; game.move.select(Moves.BRUTAL_SWING); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("TurnEndPhase", false); expect(koraidon.getInverseHp()).toBe(0); - expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]); + expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([BattlerIndex.ENEMY]); await game.toNextWave(); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("TurnEndPhase", false); // did not take damage since enemies died beforehand; // last move used hit everything around it expect(koraidon.getInverseHp()).toBe(0); - expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ + BattlerIndex.PLAYER_2, + BattlerIndex.ENEMY, + BattlerIndex.ENEMY_2, + ]); }); it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => { game.override .enemyAbility(Abilities.SKILL_LINK) - .moveset([ Moves.SPLASH, Moves.INSTRUCT ]) + .moveset([Moves.SPLASH, Moves.INSTRUCT]) .enemyMoveset(Moves.BULLET_SEED); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; @@ -497,14 +489,14 @@ describe("Moves - Instruct", () => { await game.toNextTurn(); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(bulbasaur.turnData.attacksReceived.length).toBe(10); await game.toNextTurn(); game.move.select(Moves.INSTRUCT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(bulbasaur.turnData.attacksReceived.length).toBe(10); @@ -514,12 +506,12 @@ describe("Moves - Instruct", () => { game.override .battleType("double") .enemyAbility(Abilities.SKILL_LINK) - .moveset([ Moves.SPLASH, Moves.INSTRUCT ]) - .enemyMoveset([ Moves.BULLET_SEED, Moves.SPLASH ]) + .moveset([Moves.SPLASH, Moves.INSTRUCT]) + .enemyMoveset([Moves.BULLET_SEED, Moves.SPLASH]) .enemyLevel(5); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.IVYSAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.IVYSAUR]); - const [ , ivysaur ] = game.scene.getPlayerField(); + const [, ivysaur] = game.scene.getPlayerField(); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); @@ -531,7 +523,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); expect(ivysaur.turnData.attacksReceived.length).toBe(15); @@ -541,7 +533,7 @@ describe("Moves - Instruct", () => { game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); await game.phaseInterceptor.to("BerryPhase"); expect(ivysaur.turnData.attacksReceived.length).toBe(15); diff --git a/test/moves/jaw_lock.test.ts b/test/moves/jaw_lock.test.ts index 4f9c6481a9a..fc71397e624 100644 --- a/test/moves/jaw_lock.test.ts +++ b/test/moves/jaw_lock.test.ts @@ -11,7 +11,6 @@ import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Jaw Lock", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -34,136 +33,121 @@ describe("Moves - Jaw Lock", () => { .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.INSOMNIA) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.JAW_LOCK, Moves.SPLASH ]) + .moveset([Moves.JAW_LOCK, Moves.SPLASH]) .startingLevel(100) .enemyLevel(100) .disableCrits(); }); - it( - "should trap the move's user and target", - async () => { - await game.startBattle([ Species.BULBASAUR ]); + it("should trap the move's user and target", async () => { + await game.startBattle([Species.BULBASAUR]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.JAW_LOCK); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to(MoveEffectPhase, false); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - } - ); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + }); - it( - "should not trap either pokemon if the target faints", - async () => { - game.override.enemyLevel(1); - await game.startBattle([ Species.BULBASAUR ]); + it("should not trap either pokemon if the target faints", async () => { + game.override.enemyLevel(1); + await game.startBattle([Species.BULBASAUR]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.JAW_LOCK); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to(MoveEffectPhase, false); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(MoveEffectPhase); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(FaintPhase); + await game.phaseInterceptor.to(FaintPhase); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - } - ); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }); - it( - "should only trap the user until the target faints", - async () => { - await game.startBattle([ Species.BULBASAUR ]); + it("should only trap the user until the target faints", async () => { + await game.startBattle([Species.BULBASAUR]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.JAW_LOCK); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + game.move.select(Moves.JAW_LOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(MoveEffectPhase); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - await game.doKillOpponents(); + await game.doKillOpponents(); - expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - } - ); + expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }); - it( - "should not trap other targets after the first target is trapped", - async () => { - game.override.battleType("double"); + it("should not trap other targets after the first target is trapped", async () => { + game.override.battleType("double"); - await game.startBattle([ Species.CHARMANDER, Species.BULBASAUR ]); + await game.startBattle([Species.CHARMANDER, Species.BULBASAUR]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(MoveEffectPhase); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); - expect(enemyPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(enemyPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); - await game.toNextTurn(); + await game.toNextTurn(); - game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.JAW_LOCK, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(MoveEffectPhase); - expect(enemyPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); - expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)?.sourceId).toBe(enemyPokemon[0].id); - } - ); + expect(enemyPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); + expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)?.sourceId).toBe(enemyPokemon[0].id); + }); - it( - "should not trap either pokemon if the target is protected", - async () => { - game.override.enemyMoveset([ Moves.PROTECT ]); + it("should not trap either pokemon if the target is protected", async () => { + game.override.enemyMoveset([Moves.PROTECT]); - await game.startBattle([ Species.BULBASAUR ]); + await game.startBattle([Species.BULBASAUR]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.JAW_LOCK); + game.move.select(Moves.JAW_LOCK); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - } - ); + expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); + }); }); diff --git a/test/moves/lash_out.test.ts b/test/moves/lash_out.test.ts index 7ba507b66b9..8395633f5c0 100644 --- a/test/moves/lash_out.test.ts +++ b/test/moves/lash_out.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Lash Out", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,13 +28,12 @@ describe("Moves - Lash Out", () => { .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.FUR_COAT) - .enemyMoveset([ Moves.GROWL ]) + .enemyMoveset([Moves.GROWL]) .startingLevel(10) .enemyLevel(10) .starterSpecies(Species.FEEBAS) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.LASH_OUT ]); - + .moveset([Moves.LASH_OUT]); }); it("should deal double damage if the user's stat stages were lowered this turn", async () => { @@ -43,7 +41,7 @@ describe("Moves - Lash Out", () => { await game.classicMode.startBattle(); game.move.select(Moves.LASH_OUT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(allMoves[Moves.LASH_OUT].calculateBattlePower).toHaveReturnedWith(150); diff --git a/test/moves/last_respects.test.ts b/test/moves/last_respects.test.ts index 272c6bc71b7..57752cea1af 100644 --- a/test/moves/last_respects.test.ts +++ b/test/moves/last_respects.test.ts @@ -30,7 +30,7 @@ describe("Moves - Last Respects", () => { game.override .battleType("single") .disableCrits() - .moveset([ Moves.LAST_RESPECTS, Moves.EXPLOSION, Moves.LUNAR_DANCE ]) + .moveset([Moves.LAST_RESPECTS, Moves.EXPLOSION, Moves.LUNAR_DANCE]) .ability(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH) .enemySpecies(Species.MAGIKARP) @@ -42,13 +42,13 @@ describe("Moves - Last Respects", () => { }); it("should have 150 power if 2 allies faint before using move", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * Bulbasur faints once */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -56,25 +56,25 @@ describe("Moves - Last Respects", () => { * Charmander faints once */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(2); await game.toNextTurn(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); - expect(move.calculateBattlePower).toHaveReturnedWith(basePower + (2 * 50)); + expect(move.calculateBattlePower).toHaveReturnedWith(basePower + 2 * 50); }); it("should have 200 power if an ally fainted twice and another one once", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * Bulbasur faints once */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -83,7 +83,7 @@ describe("Moves - Last Respects", () => { */ game.doRevivePokemon(1); game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -91,15 +91,15 @@ describe("Moves - Last Respects", () => { * Bulbasur faints twice */ game.move.select(Moves.EXPLOSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(2); await game.toNextTurn(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); - expect(move.calculateBattlePower).toHaveReturnedWith(basePower + (3 * 50)); + expect(move.calculateBattlePower).toHaveReturnedWith(basePower + 3 * 50); }); it("should maintain its power for the player during the next battle if it is within the same arena encounter", async () => { @@ -110,13 +110,13 @@ describe("Moves - Last Respects", () => { .startingLevel(100) .enemyMoveset(Moves.SPLASH); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * The first Pokemon faints and another Pokemon in the party is selected. - */ + */ game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -124,14 +124,14 @@ describe("Moves - Last Respects", () => { * Enemy Pokemon faints and new wave is entered. */ game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); expect(game.scene.arena.playerFaints).toBe(1); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); - expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower + (1 * 50)); + expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower + 1 * 50); }); it("should reset enemyFaints count on progressing to the next wave.", async () => { @@ -141,15 +141,15 @@ describe("Moves - Last Respects", () => { .enemyLevel(1) .startingLevel(100) .enemyMoveset(Moves.LAST_RESPECTS) - .moveset([ Moves.LUNAR_DANCE, Moves.LAST_RESPECTS, Moves.SPLASH ]); + .moveset([Moves.LUNAR_DANCE, Moves.LAST_RESPECTS, Moves.SPLASH]); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); /** * The first Pokemon faints and another Pokemon in the party is selected. - */ + */ game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); @@ -157,61 +157,53 @@ describe("Moves - Last Respects", () => { * Enemy Pokemon faints and new wave is entered. */ game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); expect(game.scene.currentBattle.enemyFaints).toBe(0); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase"); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); }); it("should reset playerFaints count if we enter new trainer battle", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(4) - .enemyLevel(1) - .startingLevel(100); + game.override.enemySpecies(Species.MAGIKARP).startingWave(4).enemyLevel(1).startingLevel(100); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); }); it("should reset playerFaints count if we enter new biome", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(10) - .enemyLevel(1) - .startingLevel(100); + game.override.enemySpecies(Species.MAGIKARP).startingWave(10).enemyLevel(1).startingLevel(100); - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); game.move.select(Moves.LUNAR_DANCE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); game.doSelectPartyPokemon(1); await game.toNextTurn(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.LAST_RESPECTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); diff --git a/test/moves/light_screen.test.ts b/test/moves/light_screen.test.ts index 2a4a1568136..9cc6944ed3e 100644 --- a/test/moves/light_screen.test.ts +++ b/test/moves/light_screen.test.ts @@ -36,22 +36,26 @@ describe("Moves - Light Screen", () => { globalScene = game.scene; game.override.battleType("single"); game.override.ability(Abilities.NONE); - game.override.moveset([ Moves.ABSORB, Moves.DAZZLING_GLEAM, Moves.TACKLE ]); + game.override.moveset([Moves.ABSORB, Moves.DAZZLING_GLEAM, Moves.TACKLE]); game.override.enemyLevel(100); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN ]); + game.override.enemyMoveset([Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN, Moves.LIGHT_SCREEN]); game.override.disableCrits(); }); it("reduces damage of special attacks by half in a single battle", async () => { const moveToUse = Moves.ABSORB; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); @@ -60,39 +64,51 @@ describe("Moves - Light Screen", () => { game.override.battleType("double"); const moveToUse = Moves.DAZZLING_GLEAM; - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); game.move.select(moveToUse); game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); it("does not affect physical attacks", async () => { const moveToUse = Moves.TACKLE; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); it("does not affect critical hits", async () => { - game.override.moveset([ Moves.FROST_BREATH ]); + game.override.moveset([Moves.FROST_BREATH]); const moveToUse = Moves.FROST_BREATH; vi.spyOn(allMoves[Moves.FROST_BREATH], "accuracy", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); }); @@ -112,7 +128,14 @@ const getMockedMoveDamage = (defender: Pokemon, attacker: Pokemon, move: Move) = if (globalScene.arena.getTagOnSide(ArenaTagType.LIGHT_SCREEN, side)) { if (move.getAttrs(CritOnlyAttr).length === 0) { - globalScene.arena.applyTagsForSide(ArenaTagType.LIGHT_SCREEN, side, false, attacker, move.category, multiplierHolder); + globalScene.arena.applyTagsForSide( + ArenaTagType.LIGHT_SCREEN, + side, + false, + attacker, + move.category, + multiplierHolder, + ); } } diff --git a/test/moves/lucky_chant.test.ts b/test/moves/lucky_chant.test.ts index 7f943732192..21802574e79 100644 --- a/test/moves/lucky_chant.test.ts +++ b/test/moves/lucky_chant.test.ts @@ -7,14 +7,13 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "#test/testUtils/gameManager"; - describe("Moves - Lucky Chant", () => { let phaserGame: Phaser.Game; let game: GameManager; beforeAll(() => { phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS + type: Phaser.HEADLESS, }); }); @@ -27,86 +26,77 @@ describe("Moves - Lucky Chant", () => { game.override .battleType("single") - .moveset([ Moves.LUCKY_CHANT, Moves.SPLASH, Moves.FOLLOW_ME ]) + .moveset([Moves.LUCKY_CHANT, Moves.SPLASH, Moves.FOLLOW_ME]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.INSOMNIA) - .enemyMoveset([ Moves.FLOWER_TRICK ]) + .enemyMoveset([Moves.FLOWER_TRICK]) .startingLevel(100) .enemyLevel(100); }); - it( - "should prevent critical hits from moves", - async () => { - await game.startBattle([ Species.CHARIZARD ]); + it("should prevent critical hits from moves", async () => { + await game.startBattle([Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; + const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; - game.move.select(Moves.LUCKY_CHANT); + game.move.select(Moves.LUCKY_CHANT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - const secondTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp - firstTurnDamage; - expect(secondTurnDamage).toBeLessThan(firstTurnDamage); - } - ); + const secondTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp - firstTurnDamage; + expect(secondTurnDamage).toBeLessThan(firstTurnDamage); + }); - it( - "should prevent critical hits against the user's ally", - async () => { - game.override.battleType("double"); + it("should prevent critical hits against the user's ally", async () => { + game.override.battleType("double"); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.FOLLOW_ME); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - const firstTurnDamage = playerPokemon[0].getMaxHp() - playerPokemon[0].hp; + const firstTurnDamage = playerPokemon[0].getMaxHp() - playerPokemon[0].hp; - game.move.select(Moves.FOLLOW_ME); - game.move.select(Moves.LUCKY_CHANT, 1); + game.move.select(Moves.FOLLOW_ME); + game.move.select(Moves.LUCKY_CHANT, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - const secondTurnDamage = playerPokemon[0].getMaxHp() - playerPokemon[0].hp - firstTurnDamage; - expect(secondTurnDamage).toBeLessThan(firstTurnDamage); - } - ); + const secondTurnDamage = playerPokemon[0].getMaxHp() - playerPokemon[0].hp - firstTurnDamage; + expect(secondTurnDamage).toBeLessThan(firstTurnDamage); + }); - it( - "should prevent critical hits from field effects", - async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + it("should prevent critical hits from field effects", async () => { + game.override.enemyMoveset([Moves.TACKLE]); - await game.startBattle([ Species.CHARIZARD ]); + await game.startBattle([Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 2, Moves.NONE, 0); + enemyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 2, Moves.NONE, 0); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; + const firstTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp; - game.move.select(Moves.LUCKY_CHANT); + game.move.select(Moves.LUCKY_CHANT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - const secondTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp - firstTurnDamage; - expect(secondTurnDamage).toBeLessThan(firstTurnDamage); - } - ); + const secondTurnDamage = playerPokemon.getMaxHp() - playerPokemon.hp - firstTurnDamage; + expect(secondTurnDamage).toBeLessThan(firstTurnDamage); + }); }); diff --git a/test/moves/lunar_blessing.test.ts b/test/moves/lunar_blessing.test.ts index a81e967a6d9..d97e6c978eb 100644 --- a/test/moves/lunar_blessing.test.ts +++ b/test/moves/lunar_blessing.test.ts @@ -28,13 +28,13 @@ describe("Moves - Lunar Blessing", () => { game.override.enemyMoveset(Moves.SPLASH); game.override.enemyAbility(Abilities.BALL_FETCH); - game.override.moveset([ Moves.LUNAR_BLESSING, Moves.SPLASH ]); + game.override.moveset([Moves.LUNAR_BLESSING, Moves.SPLASH]); game.override.ability(Abilities.BALL_FETCH); }); it("should restore 25% HP of the user and its ally", async () => { - await game.startBattle([ Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField(); + await game.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); vi.spyOn(leftPlayer, "getMaxHp").mockReturnValue(100); vi.spyOn(rightPlayer, "getMaxHp").mockReturnValue(100); @@ -47,7 +47,6 @@ describe("Moves - Lunar Blessing", () => { vi.spyOn(leftPlayer, "heal"); vi.spyOn(rightPlayer, "heal"); - game.move.select(Moves.LUNAR_BLESSING, 0); await game.phaseInterceptor.to(CommandPhase); game.move.select(Moves.SPLASH, 1); @@ -62,8 +61,8 @@ describe("Moves - Lunar Blessing", () => { it("should cure status effect of the user and its ally", async () => { game.override.statusEffect(StatusEffect.BURN); - await game.startBattle([ Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField(); + await game.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); vi.spyOn(leftPlayer, "resetStatus"); vi.spyOn(rightPlayer, "resetStatus"); diff --git a/test/moves/lunar_dance.test.ts b/test/moves/lunar_dance.test.ts index 37e96e0dc3e..d3dceba087c 100644 --- a/test/moves/lunar_dance.test.ts +++ b/test/moves/lunar_dance.test.ts @@ -31,12 +31,12 @@ describe("Moves - Lunar Dance", () => { }); it("should full restore HP, PP and status of switched in pokemon, then fail second use because no remaining backup pokemon in party", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.ODDISH, Species.RATTATA ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.ODDISH, Species.RATTATA]); - const [ bulbasaur, oddish, rattata ] = game.scene.getPlayerParty(); - game.move.changeMoveset(bulbasaur, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); - game.move.changeMoveset(oddish, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); - game.move.changeMoveset(rattata, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); + const [bulbasaur, oddish, rattata] = game.scene.getPlayerParty(); + game.move.changeMoveset(bulbasaur, [Moves.LUNAR_DANCE, Moves.SPLASH]); + game.move.changeMoveset(oddish, [Moves.LUNAR_DANCE, Moves.SPLASH]); + game.move.changeMoveset(rattata, [Moves.LUNAR_DANCE, Moves.SPLASH]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.SPLASH, 1); diff --git a/test/moves/magic_coat.test.ts b/test/moves/magic_coat.test.ts index c3e2e6e9f51..2cc8dea8938 100644 --- a/test/moves/magic_coat.test.ts +++ b/test/moves/magic_coat.test.ts @@ -38,8 +38,8 @@ describe("Moves - Magic Coat", () => { }); it("should fail if the user goes last in the turn", async () => { - game.override.moveset([ Moves.PROTECT ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.PROTECT]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.PROTECT); await game.phaseInterceptor.to("BerryPhase"); @@ -47,8 +47,8 @@ describe("Moves - Magic Coat", () => { }); it("should fail if called again in the same turn due to moves like instruct", async () => { - game.override.moveset([ Moves.INSTRUCT ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.INSTRUCT]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.INSTRUCT); await game.phaseInterceptor.to("BerryPhase"); @@ -56,9 +56,9 @@ describe("Moves - Magic Coat", () => { }); it("should not reflect moves used on the next turn", async () => { - game.override.moveset([ Moves.GROWL, Moves.SPLASH ]); - game.override.enemyMoveset([ Moves.MAGIC_COAT, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.SPLASH]); + game.override.enemyMoveset([Moves.MAGIC_COAT, Moves.SPLASH]); + await game.classicMode.startBattle([Species.MAGIKARP]); // turn 1 game.move.select(Moves.SPLASH); @@ -73,8 +73,8 @@ describe("Moves - Magic Coat", () => { }); it("should reflect basic status moves", async () => { - game.override.moveset([ Moves.GROWL ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -83,8 +83,8 @@ describe("Moves - Magic Coat", () => { it("should individually bounce back multi-target moves when used by both targets in doubles", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.GROWL, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.SPLASH]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.GROWL, 0); game.move.select(Moves.SPLASH, 1); @@ -96,9 +96,9 @@ describe("Moves - Magic Coat", () => { it("should bounce back a spread status move against both pokemon", async () => { game.override.battleType("double"); - game.override.moveset([ Moves.GROWL, Moves.SPLASH ]); - game.override.enemyMoveset([ Moves.SPLASH, Moves.MAGIC_COAT ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.SPLASH]); + game.override.enemyMoveset([Moves.SPLASH, Moves.MAGIC_COAT]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.GROWL, 0); game.move.select(Moves.SPLASH, 1); @@ -110,9 +110,9 @@ describe("Moves - Magic Coat", () => { }); it("should still bounce back a move that would otherwise fail", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.scene.getEnemyPokemon()?.setStatStage(Stat.ATK, -6); - game.override.moveset([ Moves.GROWL ]); + game.override.moveset([Moves.GROWL]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -123,9 +123,9 @@ describe("Moves - Magic Coat", () => { it("should not bounce back a move that was just bounced", async () => { game.override.battleType("double"); game.override.ability(Abilities.MAGIC_BOUNCE); - game.override.moveset([ Moves.GROWL, Moves.MAGIC_COAT ]); - game.override.enemyMoveset([ Moves.SPLASH, Moves.MAGIC_COAT ]); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL, Moves.MAGIC_COAT]); + game.override.enemyMoveset([Moves.SPLASH, Moves.MAGIC_COAT]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]); game.move.select(Moves.MAGIC_COAT, 0); game.move.select(Moves.GROWL, 1); @@ -138,7 +138,7 @@ describe("Moves - Magic Coat", () => { // todo while Mirror Armor is not implemented it.todo("should receive the stat change after reflecting a move back to a mirror armor user", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -148,8 +148,8 @@ describe("Moves - Magic Coat", () => { it("should still bounce back a move from a mold breaker user", async () => { game.override.ability(Abilities.MOLD_BREAKER); - game.override.moveset([ Moves.GROWL ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.GROWL]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.GROWL); await game.phaseInterceptor.to("BerryPhase"); @@ -160,8 +160,8 @@ describe("Moves - Magic Coat", () => { it("should only bounce spikes back once when both targets use magic coat in doubles", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.SPIKES ]); + await game.classicMode.startBattle([Species.MAGIKARP]); + game.override.moveset([Moves.SPIKES]); game.move.select(Moves.SPIKES); await game.phaseInterceptor.to("BerryPhase"); @@ -170,10 +170,10 @@ describe("Moves - Magic Coat", () => { expect(game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY)).toBeUndefined(); }); - it("should not bounce back curse", async() => { + it("should not bounce back curse", async () => { game.override.starterSpecies(Species.GASTLY); - await game.classicMode.startBattle([ Species.GASTLY ]); - game.override.moveset([ Moves.CURSE ]); + await game.classicMode.startBattle([Species.GASTLY]); + game.override.moveset([Moves.CURSE]); game.move.select(Moves.CURSE); await game.phaseInterceptor.to("BerryPhase"); @@ -183,11 +183,11 @@ describe("Moves - Magic Coat", () => { // TODO: encore is failing if the last move was virtual. it.todo("should not cause the bounced move to count for encore", async () => { - game.override.moveset([ Moves.GROWL, Moves.ENCORE ]); - game.override.enemyMoveset([ Moves.MAGIC_COAT, Moves.TACKLE ]); + game.override.moveset([Moves.GROWL, Moves.ENCORE]); + game.override.enemyMoveset([Moves.MAGIC_COAT, Moves.TACKLE]); game.override.enemyAbility(Abilities.MAGIC_BOUNCE); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyPokemon = game.scene.getEnemyPokemon()!; // turn 1 @@ -198,7 +198,7 @@ describe("Moves - Magic Coat", () => { // turn 2 game.move.select(Moves.ENCORE); await game.forceEnemyMove(Moves.TACKLE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase"); expect(enemyPokemon.getTag(BattlerTagType.ENCORE)!["moveId"]).toBe(Moves.TACKLE); expect(enemyPokemon.getLastXMoves()[0].move).toBe(Moves.TACKLE); @@ -207,8 +207,8 @@ describe("Moves - Magic Coat", () => { // TODO: stomping tantrum should consider moves that were bounced. it.todo("should cause stomping tantrum to double in power when the last move was bounced", async () => { game.override.battleType("single"); - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.STOMPING_TANTRUM, Moves.CHARM ]); + await game.classicMode.startBattle([Species.MAGIKARP]); + game.override.moveset([Moves.STOMPING_TANTRUM, Moves.CHARM]); const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; vi.spyOn(stomping_tantrum, "calculateBattlePower"); @@ -222,33 +222,36 @@ describe("Moves - Magic Coat", () => { }); // TODO: stomping tantrum should consider moves that were bounced. - it.todo("should properly cause the enemy's stomping tantrum to be doubled in power after bouncing and failing", async () => { - game.override.enemyMoveset([ Moves.STOMPING_TANTRUM, Moves.SPLASH, Moves.CHARM ]); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + it.todo( + "should properly cause the enemy's stomping tantrum to be doubled in power after bouncing and failing", + async () => { + game.override.enemyMoveset([Moves.STOMPING_TANTRUM, Moves.SPLASH, Moves.CHARM]); + await game.classicMode.startBattle([Species.BULBASAUR]); - const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; - const enemy = game.scene.getEnemyPokemon()!; - vi.spyOn(stomping_tantrum, "calculateBattlePower"); + const stomping_tantrum = allMoves[Moves.STOMPING_TANTRUM]; + const enemy = game.scene.getEnemyPokemon()!; + vi.spyOn(stomping_tantrum, "calculateBattlePower"); - game.move.select(Moves.SPORE); - await game.forceEnemyMove(Moves.CHARM); - await game.phaseInterceptor.to("TurnEndPhase"); - expect(enemy.getLastXMoves(1)[0].result).toBe("success"); + game.move.select(Moves.SPORE); + await game.forceEnemyMove(Moves.CHARM); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemy.getLastXMoves(1)[0].result).toBe("success"); - await game.phaseInterceptor.to("BerryPhase"); - expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); + await game.phaseInterceptor.to("BerryPhase"); + expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); - await game.toNextTurn(); - game.move.select(Moves.GROWL); - await game.phaseInterceptor.to("BerryPhase"); - expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); - }); + await game.toNextTurn(); + game.move.select(Moves.GROWL); + await game.phaseInterceptor.to("BerryPhase"); + expect(stomping_tantrum.calculateBattlePower).toHaveReturnedWith(75); + }, + ); it("should respect immunities when bouncing a move", async () => { vi.spyOn(allMoves[Moves.THUNDER_WAVE], "accuracy", "get").mockReturnValue(100); - game.override.moveset([ Moves.THUNDER_WAVE, Moves.GROWL ]); + game.override.moveset([Moves.THUNDER_WAVE, Moves.GROWL]); game.override.ability(Abilities.SOUNDPROOF); - await game.classicMode.startBattle([ Species.PHANPY ]); + await game.classicMode.startBattle([Species.PHANPY]); // Turn 1 - thunder wave immunity test game.move.select(Moves.THUNDER_WAVE); @@ -262,8 +265,8 @@ describe("Moves - Magic Coat", () => { }); it("should bounce back a move before the accuracy check", async () => { - game.override.moveset([ Moves.SPORE ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPORE]); + await game.classicMode.startBattle([Species.MAGIKARP]); const attacker = game.scene.getPlayerPokemon()!; @@ -274,8 +277,8 @@ describe("Moves - Magic Coat", () => { }); it("should take the accuracy of the magic bounce user into account", async () => { - game.override.moveset([ Moves.SPORE ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.moveset([Moves.SPORE]); + await game.classicMode.startBattle([Species.MAGIKARP]); const opponent = game.scene.getEnemyPokemon()!; vi.spyOn(opponent, "getAccuracyMultiplier").mockReturnValue(0); diff --git a/test/moves/magnet_rise.test.ts b/test/moves/magnet_rise.test.ts index e4ceeaea929..725bbb99276 100644 --- a/test/moves/magnet_rise.test.ts +++ b/test/moves/magnet_rise.test.ts @@ -26,10 +26,10 @@ describe("Moves - Magnet Rise", () => { game.override.battleType("single"); game.override.starterSpecies(Species.MAGNEZONE); game.override.enemySpecies(Species.RATTATA); - game.override.enemyMoveset([ Moves.DRILL_RUN, Moves.DRILL_RUN, Moves.DRILL_RUN, Moves.DRILL_RUN ]); + game.override.enemyMoveset([Moves.DRILL_RUN, Moves.DRILL_RUN, Moves.DRILL_RUN, Moves.DRILL_RUN]); game.override.disableCrits(); game.override.enemyLevel(1); - game.override.moveset([ moveToUse, Moves.SPLASH, Moves.GRAVITY, Moves.BATON_PASS ]); + game.override.moveset([moveToUse, Moves.SPLASH, Moves.GRAVITY, Moves.BATON_PASS]); }); it("MAGNET RISE", async () => { diff --git a/test/moves/make_it_rain.test.ts b/test/moves/make_it_rain.test.ts index 8de6777bddf..38460d99e63 100644 --- a/test/moves/make_it_rain.test.ts +++ b/test/moves/make_it_rain.test.ts @@ -8,7 +8,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { MoveEndPhase } from "#app/phases/move-end-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; - describe("Moves - Make It Rain", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -26,7 +25,7 @@ describe("Moves - Make It Rain", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([ Moves.MAKE_IT_RAIN, Moves.SPLASH ]); + game.override.moveset([Moves.MAKE_IT_RAIN, Moves.SPLASH]); game.override.enemySpecies(Species.SNORLAX); game.override.enemyAbility(Abilities.INSOMNIA); game.override.enemyMoveset(Moves.SPLASH); @@ -35,7 +34,7 @@ describe("Moves - Make It Rain", () => { }); it("should only lower SPATK stat stage by 1 once in a double battle", async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -51,7 +50,7 @@ describe("Moves - Make It Rain", () => { game.override.enemyLevel(1); // ensures the enemy will faint game.override.battleType("single"); - await game.startBattle([ Species.CHARIZARD ]); + await game.startBattle([Species.CHARIZARD]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -67,7 +66,7 @@ describe("Moves - Make It Rain", () => { it("should reduce Sp. Atk. once after KOing two enemies", async () => { game.override.enemyLevel(1); // ensures the enemy will faint - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyField(); @@ -82,7 +81,7 @@ describe("Moves - Make It Rain", () => { }); it("should lower SPATK stat stage by 1 if it only hits the second target", async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/mat_block.test.ts b/test/moves/mat_block.test.ts index b9e66253058..ddfa29a53da 100644 --- a/test/moves/mat_block.test.ts +++ b/test/moves/mat_block.test.ts @@ -9,7 +9,6 @@ import { BerryPhase } from "#app/phases/berry-phase"; import { CommandPhase } from "#app/phases/command-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; - describe("Moves - Mat Block", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,79 +28,70 @@ describe("Moves - Mat Block", () => { game.override.battleType("double"); - game.override.moveset([ Moves.MAT_BLOCK, Moves.SPLASH ]); + game.override.moveset([Moves.MAT_BLOCK, Moves.SPLASH]); game.override.enemySpecies(Species.SNORLAX); - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user and allies from attack moves", - async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + test("should protect the user and allies from attack moves", async () => { + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.MAT_BLOCK); + game.move.select(Moves.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - } - ); + leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - test( - "should not protect the user and allies from status moves", - async () => { - game.override.enemyMoveset([ Moves.GROWL ]); + test("should not protect the user and allies from status moves", async () => { + game.override.enemyMoveset([Moves.GROWL]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.MAT_BLOCK); + game.move.select(Moves.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(-2)); - } - ); + leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(-2)); + }); - test( - "should fail when used after the first turn", - async () => { - await game.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + test("should fail when used after the first turn", async () => { + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - const leadStartingHp = leadPokemon.map(p => p.hp); + const leadStartingHp = leadPokemon.map(p => p.hp); - await game.phaseInterceptor.to(CommandPhase, false); - game.move.select(Moves.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.MAT_BLOCK, 1); + await game.phaseInterceptor.to(CommandPhase, false); + game.move.select(Moves.MAT_BLOCK); + await game.phaseInterceptor.to(CommandPhase); + game.move.select(Moves.MAT_BLOCK, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.some((p, i) => p.hp < leadStartingHp[i])).toBeTruthy(); - } - ); + expect(leadPokemon.some((p, i) => p.hp < leadStartingHp[i])).toBeTruthy(); + }); }); diff --git a/test/moves/metal_burst.test.ts b/test/moves/metal_burst.test.ts index 7f7cfa841da..2cbc999436f 100644 --- a/test/moves/metal_burst.test.ts +++ b/test/moves/metal_burst.test.ts @@ -24,7 +24,7 @@ describe("Moves - Metal Burst", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.METAL_BURST, Moves.FISSURE, Moves.PRECIPICE_BLADES ]) + .moveset([Moves.METAL_BURST, Moves.FISSURE, Moves.PRECIPICE_BLADES]) .ability(Abilities.PURE_POWER) .startingLevel(10) .battleType("double") @@ -35,9 +35,9 @@ describe("Moves - Metal Burst", () => { }); it("should redirect target if intended target faints", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.FEEBAS]); - const [ , enemy2 ] = game.scene.getEnemyField(); + const [, enemy2] = game.scene.getEnemyField(); game.move.select(Moves.METAL_BURST); game.move.select(Moves.FISSURE, 1, BattlerIndex.ENEMY); @@ -45,7 +45,7 @@ describe("Moves - Metal Burst", () => { await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); await game.move.forceHit(); @@ -56,9 +56,9 @@ describe("Moves - Metal Burst", () => { }); it("should not crash if both opponents faint before the move is used", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.ARCEUS ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.ARCEUS]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); game.move.select(Moves.METAL_BURST); game.move.select(Moves.PRECIPICE_BLADES, 1); @@ -66,7 +66,7 @@ describe("Moves - Metal Burst", () => { await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); await game.move.forceHit(); diff --git a/test/moves/metronome.test.ts b/test/moves/metronome.test.ts index a1253334f0f..15790777ed3 100644 --- a/test/moves/metronome.test.ts +++ b/test/moves/metronome.test.ts @@ -28,7 +28,7 @@ describe("Moves - Metronome", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.METRONOME, Moves.SPLASH ]) + .moveset([Moves.METRONOME, Moves.SPLASH]) .battleType("single") .startingLevel(100) .starterSpecies(Species.REGIELEKI) @@ -79,9 +79,9 @@ describe("Moves - Metronome", () => { it("should only target ally for Aromatic Mist", async () => { game.override.battleType("double"); - await game.classicMode.startBattle([ Species.REGIELEKI, Species.RATTATA ]); - const [ leftPlayer, rightPlayer ] = game.scene.getPlayerField(); - const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + await game.classicMode.startBattle([Species.REGIELEKI, Species.RATTATA]); + const [leftPlayer, rightPlayer] = game.scene.getPlayerField(); + const [leftOpp, rightOpp] = game.scene.getEnemyField(); vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.AROMATIC_MIST); game.move.select(Moves.METRONOME, 0); diff --git a/test/moves/miracle_eye.test.ts b/test/moves/miracle_eye.test.ts index 068f4f70493..2dbfb962540 100644 --- a/test/moves/miracle_eye.test.ts +++ b/test/moves/miracle_eye.test.ts @@ -28,7 +28,7 @@ describe("Moves - Miracle Eye", () => { .enemyMoveset(Moves.SPLASH) .enemyLevel(5) .starterSpecies(Species.MAGIKARP) - .moveset([ Moves.MIRACLE_EYE, Moves.CONFUSION ]); + .moveset([Moves.MIRACLE_EYE, Moves.CONFUSION]); }); it("should allow Psychic moves to hit Dark types", async () => { @@ -43,7 +43,7 @@ describe("Moves - Miracle Eye", () => { game.move.select(Moves.MIRACLE_EYE); await game.toNextTurn(); game.move.select(Moves.CONFUSION); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); diff --git a/test/moves/mirror_move.test.ts b/test/moves/mirror_move.test.ts index a6fe90548be..9178410adb2 100644 --- a/test/moves/mirror_move.test.ts +++ b/test/moves/mirror_move.test.ts @@ -25,7 +25,7 @@ describe("Moves - Mirror Move", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.MIRROR_MOVE, Moves.SPLASH ]) + .moveset([Moves.MIRROR_MOVE, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -35,16 +35,14 @@ describe("Moves - Mirror Move", () => { }); it("should use the last move that the target used on the user", async () => { - game.override - .battleType("double") - .enemyMoveset([ Moves.TACKLE, Moves.GROWL ]); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + game.override.battleType("double").enemyMoveset([Moves.TACKLE, Moves.GROWL]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); game.move.select(Moves.MIRROR_MOVE, 0, BattlerIndex.ENEMY); // target's last move is Tackle, enemy should receive damage from Mirror Move copying Tackle game.move.select(Moves.SPLASH, 1); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); await game.forceEnemyMove(Moves.GROWL, BattlerIndex.PLAYER_2); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyField()[0].isFullHp()).toBeFalsy(); @@ -52,10 +50,10 @@ describe("Moves - Mirror Move", () => { it("should apply secondary effects of a move", async () => { game.override.enemyMoveset(Moves.ACID_SPRAY); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.MIRROR_MOVE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.SPDEF)).toBe(-2); @@ -63,20 +61,20 @@ describe("Moves - Mirror Move", () => { it("should be able to copy status moves", async () => { game.override.enemyMoveset(Moves.GROWL); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.MIRROR_MOVE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(game.scene.getEnemyPokemon()!.getStatStage(Stat.ATK)).toBe(-1); }); it("should fail if the target has not used any moves", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.MIRROR_MOVE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); diff --git a/test/moves/mist.test.ts b/test/moves/mist.test.ts index a9b69bccc6c..2deb6f9b90d 100644 --- a/test/moves/mist.test.ts +++ b/test/moves/mist.test.ts @@ -23,7 +23,7 @@ describe("Moves - Mist", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.MIST, Moves.SPLASH ]) + .moveset([Moves.MIST, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("double") .disableCrits() @@ -33,7 +33,7 @@ describe("Moves - Mist", () => { }); it("should prevent the user's side from having stats lowered", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); const playerPokemon = game.scene.getPlayerField(); diff --git a/test/moves/moongeist_beam.test.ts b/test/moves/moongeist_beam.test.ts index 5b36129fe2a..117fe513e17 100644 --- a/test/moves/moongeist_beam.test.ts +++ b/test/moves/moongeist_beam.test.ts @@ -23,7 +23,7 @@ describe("Moves - Moongeist Beam", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.MOONGEIST_BEAM, Moves.METRONOME ]) + .moveset([Moves.MOONGEIST_BEAM, Moves.METRONOME]) .ability(Abilities.BALL_FETCH) .startingLevel(200) .battleType("single") @@ -35,7 +35,7 @@ describe("Moves - Moongeist Beam", () => { // Also covers Photon Geyser and Sunsteel Strike it("should ignore enemy abilities", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); + await game.classicMode.startBattle([Species.MILOTIC]); const enemy = game.scene.getEnemyPokemon()!; @@ -47,8 +47,10 @@ describe("Moves - Moongeist Beam", () => { // Also covers Photon Geyser and Sunsteel Strike it("should not ignore enemy abilities when called by another move, such as metronome", async () => { - await game.classicMode.startBattle([ Species.MILOTIC ]); - vi.spyOn(allMoves[Moves.METRONOME].getAttrs(RandomMoveAttr)[0], "getMoveOverride").mockReturnValue(Moves.MOONGEIST_BEAM); + await game.classicMode.startBattle([Species.MILOTIC]); + vi.spyOn(allMoves[Moves.METRONOME].getAttrs(RandomMoveAttr)[0], "getMoveOverride").mockReturnValue( + Moves.MOONGEIST_BEAM, + ); game.move.select(Moves.METRONOME); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/multi_target.test.ts b/test/moves/multi_target.test.ts index a2379524c73..2b17929a5df 100644 --- a/test/moves/multi_target.test.ts +++ b/test/moves/multi_target.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Multi-target damage reduction", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -32,18 +31,18 @@ describe("Multi-target damage reduction", () => { .enemySpecies(Species.POLIWAG) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.TACKLE, Moves.DAZZLING_GLEAM, Moves.EARTHQUAKE, Moves.SPLASH ]) + .moveset([Moves.TACKLE, Moves.DAZZLING_GLEAM, Moves.EARTHQUAKE, Moves.SPLASH]) .ability(Abilities.BALL_FETCH); }); it("should reduce d.gleam damage when multiple enemies but not tackle", async () => { - await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.startBattle([Species.MAGIKARP, Species.FEEBAS]); - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); game.move.select(Moves.DAZZLING_GLEAM); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); const gleam1 = enemy1.getMaxHp() - enemy1.hp; @@ -59,7 +58,7 @@ describe("Multi-target damage reduction", () => { game.move.select(Moves.DAZZLING_GLEAM); game.move.select(Moves.TACKLE, 1, BattlerIndex.ENEMY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); @@ -77,14 +76,14 @@ describe("Multi-target damage reduction", () => { }); it("should reduce earthquake when more than one pokemon other than user is not fainted", async () => { - await game.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.startBattle([Species.MAGIKARP, Species.FEEBAS]); const player2 = game.scene.getPlayerParty()[1]; - const [ enemy1, enemy2 ] = game.scene.getEnemyField(); + const [enemy1, enemy2] = game.scene.getEnemyField(); game.move.select(Moves.EARTHQUAKE); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("MoveEndPhase"); @@ -99,7 +98,7 @@ describe("Multi-target damage reduction", () => { game.move.select(Moves.EARTHQUAKE); game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); @@ -117,7 +116,7 @@ describe("Multi-target damage reduction", () => { await game.toNextTurn(); game.move.select(Moves.EARTHQUAKE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); diff --git a/test/moves/nightmare.test.ts b/test/moves/nightmare.test.ts index 0a2392fe833..e1cef0084ee 100644 --- a/test/moves/nightmare.test.ts +++ b/test/moves/nightmare.test.ts @@ -23,17 +23,18 @@ describe("Moves - Nightmare", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.battleType("single") + game.override + .battleType("single") .enemySpecies(Species.RATTATA) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) .enemyStatusEffect(StatusEffect.SLEEP) .startingLevel(5) - .moveset([ Moves.NIGHTMARE, Moves.SPLASH ]); + .moveset([Moves.NIGHTMARE, Moves.SPLASH]); }); it("lowers enemy hp by 1/4 each turn while asleep", async () => { - await game.classicMode.startBattle([ Species.HYPNO ]); + await game.classicMode.startBattle([Species.HYPNO]); const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyMaxHP = enemyPokemon.hp; diff --git a/test/moves/obstruct.test.ts b/test/moves/obstruct.test.ts index e2c469e21f0..d8e3a949f08 100644 --- a/test/moves/obstruct.test.ts +++ b/test/moves/obstruct.test.ts @@ -27,7 +27,7 @@ describe("Moves - Obstruct", () => { .enemyMoveset(Moves.TACKLE) .enemyAbility(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.OBSTRUCT ]) + .moveset([Moves.OBSTRUCT]) .starterSpecies(Species.FEEBAS); }); @@ -57,8 +57,7 @@ describe("Moves - Obstruct", () => { await game.phaseInterceptor.to("TurnEndPhase"); expect(player.isFullHp()).toBe(true); expect(enemy.getStatStage(Stat.DEF)).toBe(-2); - } - ); + }); it("protects from non-contact damaging moves and doesn't lower the opponent's defense by 2 stages", async () => { game.override.enemyMoveset(Moves.WATER_GUN); diff --git a/test/moves/octolock.test.ts b/test/moves/octolock.test.ts index 882a2357e1a..c9c5fd42f7e 100644 --- a/test/moves/octolock.test.ts +++ b/test/moves/octolock.test.ts @@ -30,12 +30,12 @@ describe("Moves - Octolock", () => { .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) .startingLevel(2000) - .moveset([ Moves.OCTOLOCK, Moves.SPLASH, Moves.TRICK_OR_TREAT ]) + .moveset([Moves.OCTOLOCK, Moves.SPLASH, Moves.TRICK_OR_TREAT]) .ability(Abilities.BALL_FETCH); }); it("lowers DEF and SPDEF stat stages of the target Pokemon by 1 each turn", async () => { - await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + await game.classicMode.startBattle([Species.GRAPPLOCT]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -56,7 +56,7 @@ describe("Moves - Octolock", () => { it("if target pokemon has BIG_PECKS, should only lower SPDEF stat stage by 1", async () => { game.override.enemyAbility(Abilities.BIG_PECKS); - await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + await game.classicMode.startBattle([Species.GRAPPLOCT]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -70,7 +70,7 @@ describe("Moves - Octolock", () => { it("if target pokemon has WHITE_SMOKE, should not reduce any stat stages", async () => { game.override.enemyAbility(Abilities.WHITE_SMOKE); - await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + await game.classicMode.startBattle([Species.GRAPPLOCT]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -84,7 +84,7 @@ describe("Moves - Octolock", () => { it("if target pokemon has CLEAR_BODY, should not reduce any stat stages", async () => { game.override.enemyAbility(Abilities.CLEAR_BODY); - await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + await game.classicMode.startBattle([Species.GRAPPLOCT]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -97,7 +97,7 @@ describe("Moves - Octolock", () => { }); it("traps the target pokemon", async () => { - await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + await game.classicMode.startBattle([Species.GRAPPLOCT]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -113,7 +113,7 @@ describe("Moves - Octolock", () => { it("does not work on ghost type pokemon", async () => { game.override.enemyMoveset(Moves.OCTOLOCK); - await game.classicMode.startBattle([ Species.GASTLY ]); + await game.classicMode.startBattle([Species.GASTLY]); const playerPokemon = game.scene.getPlayerPokemon()!; @@ -130,7 +130,7 @@ describe("Moves - Octolock", () => { }); it("does not work on pokemon with added ghost type via Trick-or-Treat", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/order_up.test.ts b/test/moves/order_up.test.ts index 339f3f31584..516f7f625a3 100644 --- a/test/moves/order_up.test.ts +++ b/test/moves/order_up.test.ts @@ -43,34 +43,35 @@ describe("Moves - Order Up", () => { it.each([ { formIndex: 0, formName: "Curly", stat: Stat.ATK, statName: "Attack" }, { formIndex: 1, formName: "Droopy", stat: Stat.DEF, statName: "Defense" }, - { formIndex: 2, formName: "Stretchy", stat: Stat.SPD, statName: "Speed" } - ])("should raise the user's $statName when the user is commanded by a $formName Tatsugiri", async ({ formIndex, stat }) => { - game.override.starterForms({ [Species.TATSUGIRI]: formIndex }); + { formIndex: 2, formName: "Stretchy", stat: Stat.SPD, statName: "Speed" }, + ])( + "should raise the user's $statName when the user is commanded by a $formName Tatsugiri", + async ({ formIndex, stat }) => { + game.override.starterForms({ [Species.TATSUGIRI]: formIndex }); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); - expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); - expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); + expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); + expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); - game.move.select(Moves.ORDER_UP, 1, BattlerIndex.ENEMY); - expect(game.scene.currentBattle.turnCommands[0]?.skip).toBeTruthy(); + game.move.select(Moves.ORDER_UP, 1, BattlerIndex.ENEMY); + expect(game.scene.currentBattle.turnCommands[0]?.skip).toBeTruthy(); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - const affectedStats: EffectiveStat[] = [ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]; - affectedStats.forEach(st => expect(dondozo.getStatStage(st)).toBe(st === stat ? 3 : 2)); - }); + const affectedStats: EffectiveStat[] = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]; + affectedStats.forEach(st => expect(dondozo.getStatStage(st)).toBe(st === stat ? 3 : 2)); + }, + ); it("should be boosted by Sheer Force while still applying a stat boost", async () => { - game.override - .passiveAbility(Abilities.SHEER_FORCE) - .starterForms({ [Species.TATSUGIRI]: 0 }); + game.override.passiveAbility(Abilities.SHEER_FORCE).starterForms({ [Species.TATSUGIRI]: 0 }); - await game.classicMode.startBattle([ Species.TATSUGIRI, Species.DONDOZO ]); + await game.classicMode.startBattle([Species.TATSUGIRI, Species.DONDOZO]); - const [ tatsugiri, dondozo ] = game.scene.getPlayerField(); + const [tatsugiri, dondozo] = game.scene.getPlayerField(); expect(game.scene.triggerPokemonBattleAnim).toHaveBeenLastCalledWith(tatsugiri, PokemonAnimType.COMMANDER_APPLY); expect(dondozo.getTag(BattlerTagType.COMMANDED)).toBeDefined(); diff --git a/test/moves/parting_shot.test.ts b/test/moves/parting_shot.test.ts index 43a6d833949..699d960f882 100644 --- a/test/moves/parting_shot.test.ts +++ b/test/moves/parting_shot.test.ts @@ -10,7 +10,6 @@ import { FaintPhase } from "#app/phases/faint-phase"; import { MessagePhase } from "#app/phases/message-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; - describe("Moves - Parting Shot", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,58 +27,48 @@ describe("Moves - Parting Shot", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.moveset([ Moves.PARTING_SHOT, Moves.SPLASH ]); + game.override.moveset([Moves.PARTING_SHOT, Moves.SPLASH]); game.override.enemyMoveset(Moves.SPLASH); game.override.startingLevel(5); game.override.enemyLevel(5); - }); - test( - "Parting Shot when buffed by prankster should fail against dark types", - async () => { - game.override - .enemySpecies(Species.POOCHYENA) - .ability(Abilities.PRANKSTER); - await game.startBattle([ Species.MURKROW, Species.MEOWTH ]); + test("Parting Shot when buffed by prankster should fail against dark types", async () => { + game.override.enemySpecies(Species.POOCHYENA).ability(Abilities.PRANKSTER); + await game.startBattle([Species.MURKROW, Species.MEOWTH]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon).toBeDefined(); - game.move.select(Moves.PARTING_SHOT); + game.move.select(Moves.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); - expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); + expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); + }); - test( - "Parting shot should fail against good as gold ability", - async () => { - game.override - .enemySpecies(Species.GHOLDENGO) - .enemyAbility(Abilities.GOOD_AS_GOLD); - await game.startBattle([ Species.MURKROW, Species.MEOWTH ]); + test("Parting shot should fail against good as gold ability", async () => { + game.override.enemySpecies(Species.GHOLDENGO).enemyAbility(Abilities.GOOD_AS_GOLD); + await game.startBattle([Species.MURKROW, Species.MEOWTH]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); + const enemyPokemon = game.scene.getEnemyPokemon()!; + expect(enemyPokemon).toBeDefined(); - game.move.select(Moves.PARTING_SHOT); + game.move.select(Moves.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); - expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); + expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); + }); - it.todo( // TODO: fix this bug to pass the test! + it.todo( + // TODO: fix this bug to pass the test! "Parting shot should fail if target is -6/-6 de-buffed", async () => { - game.override.moveset([ Moves.PARTING_SHOT, Moves.MEMENTO, Moves.SPLASH ]); - await game.startBattle([ Species.MEOWTH, Species.MEOWTH, Species.MEOWTH, Species.MURKROW, Species.ABRA ]); + game.override.moveset([Moves.PARTING_SHOT, Moves.MEMENTO, Moves.SPLASH]); + await game.startBattle([Species.MEOWTH, Species.MEOWTH, Species.MEOWTH, Species.MURKROW, Species.ABRA]); // use Memento 3 times to debuff enemy game.move.select(Moves.MEMENTO); @@ -114,17 +103,15 @@ describe("Moves - Parting Shot", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } + }, ); - it.todo( // TODO: fix this bug to pass the test! + it.todo( + // TODO: fix this bug to pass the test! "Parting shot shouldn't allow switch out when mist is active", async () => { - game.override - .enemySpecies(Species.ALTARIA) - .enemyAbility(Abilities.NONE) - .enemyMoveset([ Moves.MIST ]); - await game.startBattle([ Species.SNORLAX, Species.MEOWTH ]); + game.override.enemySpecies(Species.ALTARIA).enemyAbility(Abilities.NONE).enemyMoveset([Moves.MIST]); + await game.startBattle([Species.SNORLAX, Species.MEOWTH]); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); @@ -135,16 +122,15 @@ describe("Moves - Parting Shot", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } + }, ); - it.todo( // TODO: fix this bug to pass the test! + it.todo( + // TODO: fix this bug to pass the test! "Parting shot shouldn't allow switch out against clear body ability", async () => { - game.override - .enemySpecies(Species.TENTACOOL) - .enemyAbility(Abilities.CLEAR_BODY); - await game.startBattle([ Species.SNORLAX, Species.MEOWTH ]); + game.override.enemySpecies(Species.TENTACOOL).enemyAbility(Abilities.CLEAR_BODY); + await game.startBattle([Species.SNORLAX, Species.MEOWTH]); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); @@ -155,13 +141,14 @@ describe("Moves - Parting Shot", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } + }, ); - it.todo( // TODO: fix this bug to pass the test! + it.todo( + // TODO: fix this bug to pass the test! "Parting shot should de-buff and not fail if no party available to switch - party size 1", async () => { - await game.startBattle([ Species.MURKROW ]); + await game.startBattle([Species.MURKROW]); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); @@ -172,13 +159,14 @@ describe("Moves - Parting Shot", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MURKROW); - } + }, ); - it.todo( // TODO: fix this bug to pass the test! + it.todo( + // TODO: fix this bug to pass the test! "Parting shot regularly not fail if no party available to switch - party fainted", async () => { - await game.startBattle([ Species.MURKROW, Species.MEOWTH ]); + await game.startBattle([Species.MURKROW, Species.MEOWTH]); game.move.select(Moves.SPLASH); // intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted) @@ -195,6 +183,6 @@ describe("Moves - Parting Shot", () => { expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(Species.MEOWTH); - } + }, ); }); diff --git a/test/moves/plasma_fists.test.ts b/test/moves/plasma_fists.test.ts index 276b5fd999a..fe19ab4a460 100644 --- a/test/moves/plasma_fists.test.ts +++ b/test/moves/plasma_fists.test.ts @@ -24,7 +24,7 @@ describe("Moves - Plasma Fists", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.PLASMA_FISTS, Moves.TACKLE ]) + .moveset([Moves.PLASMA_FISTS, Moves.TACKLE]) .battleType("double") .startingLevel(100) .enemySpecies(Species.DUSCLOPS) @@ -34,7 +34,7 @@ describe("Moves - Plasma Fists", () => { }); it("should convert all subsequent Normal-type attacks to Electric-type", async () => { - await game.classicMode.startBattle([ Species.DUSCLOPS, Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.DUSCLOPS, Species.BLASTOISE]); const field = game.scene.getField(true); field.forEach(p => vi.spyOn(p, "getMoveType")); @@ -45,7 +45,7 @@ describe("Moves - Plasma Fists", () => { await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER_2); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase", false); @@ -56,11 +56,9 @@ describe("Moves - Plasma Fists", () => { }); it("should not affect Normal-type attacks boosted by Pixilate", async () => { - game.override - .battleType("single") - .enemyAbility(Abilities.PIXILATE); + game.override.battleType("single").enemyAbility(Abilities.PIXILATE); - await game.classicMode.startBattle([ Species.ONIX ]); + await game.classicMode.startBattle([Species.ONIX]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -68,7 +66,7 @@ describe("Moves - Plasma Fists", () => { game.move.select(Moves.PLASMA_FISTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getMoveType).toHaveLastReturnedWith(PokemonType.FAIRY); @@ -76,12 +74,9 @@ describe("Moves - Plasma Fists", () => { }); it("should affect moves that become Normal type due to Normalize", async () => { - game.override - .battleType("single") - .enemyAbility(Abilities.NORMALIZE) - .enemyMoveset(Moves.WATER_GUN); + game.override.battleType("single").enemyAbility(Abilities.NORMALIZE).enemyMoveset(Moves.WATER_GUN); - await game.classicMode.startBattle([ Species.DUSCLOPS ]); + await game.classicMode.startBattle([Species.DUSCLOPS]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -89,7 +84,7 @@ describe("Moves - Plasma Fists", () => { game.move.select(Moves.PLASMA_FISTS); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getMoveType).toHaveLastReturnedWith(PokemonType.ELECTRIC); diff --git a/test/moves/pledge_moves.test.ts b/test/moves/pledge_moves.test.ts index 62606489d0b..c866d15357c 100644 --- a/test/moves/pledge_moves.test.ts +++ b/test/moves/pledge_moves.test.ts @@ -19,7 +19,7 @@ describe("Moves - Pledge Moves", () => { beforeAll(() => { phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS + type: Phaser.HEADLESS, }); }); @@ -32,306 +32,270 @@ describe("Moves - Pledge Moves", () => { game.override .battleType("double") .startingLevel(100) - .moveset([ Moves.FIRE_PLEDGE, Moves.GRASS_PLEDGE, Moves.WATER_PLEDGE, Moves.SPLASH ]) + .moveset([Moves.FIRE_PLEDGE, Moves.GRASS_PLEDGE, Moves.WATER_PLEDGE, Moves.SPLASH]) .enemySpecies(Species.SNORLAX) .enemyLevel(100) .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH); }); - it( - "Fire Pledge - should be an 80-power Fire-type attack outside of combination", - async () => { - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + it("Fire Pledge - should be an 80-power Fire-type attack outside of combination", async () => { + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const firePledge = allMoves[Moves.FIRE_PLEDGE]; - vi.spyOn(firePledge, "calculateBattlePower"); + const firePledge = allMoves[Moves.FIRE_PLEDGE]; + vi.spyOn(firePledge, "calculateBattlePower"); - const playerPokemon = game.scene.getPlayerField(); - vi.spyOn(playerPokemon[0], "getMoveType"); + const playerPokemon = game.scene.getPlayerField(); + vi.spyOn(playerPokemon[0], "getMoveType"); - game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); - expect(playerPokemon[0].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); - } - ); + expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); + expect(playerPokemon[0].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); + }); - it( - "Fire Pledge - should not combine with an ally using Fire Pledge", - async () => { - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + it("Fire Pledge - should not combine with an ally using Fire Pledge", async () => { + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const firePledge = allMoves[Moves.FIRE_PLEDGE]; - vi.spyOn(firePledge, "calculateBattlePower"); + const firePledge = allMoves[Moves.FIRE_PLEDGE]; + vi.spyOn(firePledge, "calculateBattlePower"); - const playerPokemon = game.scene.getPlayerField(); - playerPokemon.forEach(p => vi.spyOn(p, "getMoveType")); + const playerPokemon = game.scene.getPlayerField(); + playerPokemon.forEach(p => vi.spyOn(p, "getMoveType")); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY_2); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + await game.phaseInterceptor.to("MoveEndPhase"); + expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); + expect(playerPokemon[0].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); + + await game.phaseInterceptor.to("BerryPhase", false); + expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); + expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); + + enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); + }); + + it("Fire Pledge - should not combine with an enemy's Pledge move", async () => { + game.override.battleType("single").enemyMoveset(Moves.GRASS_PLEDGE); + + await game.classicMode.startBattle([Species.CHARIZARD]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.FIRE_PLEDGE); + + await game.toNextTurn(); + + // Neither Pokemon should defer their move's effects as they would + // if they combined moves, so both should be damaged. + expect(playerPokemon.hp).toBeLessThan(playerPokemon.getMaxHp()); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + expect(game.scene.arena.getTag(ArenaTagType.FIRE_GRASS_PLEDGE)).toBeUndefined(); + }); + + it("Grass Pledge - should combine with Fire Pledge to form a 150-power Fire-type attack that creates a 'sea of fire'", async () => { + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); + + const grassPledge = allMoves[Moves.GRASS_PLEDGE]; + vi.spyOn(grassPledge, "calculateBattlePower"); + + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); + + vi.spyOn(playerPokemon[1], "getMoveType"); + const baseDmgMock = vi.spyOn(enemyPokemon[0], "getBaseDamage"); + + game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.GRASS_PLEDGE, 1, BattlerIndex.ENEMY); + + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + // advance to the end of PLAYER_2's move this turn + for (let i = 0; i < 2; i++) { await game.phaseInterceptor.to("MoveEndPhase"); - expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); - expect(playerPokemon[0].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); - - await game.phaseInterceptor.to("BerryPhase", false); - expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(80); - expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); - - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); } - ); + expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); + expect(grassPledge.calculateBattlePower).toHaveLastReturnedWith(150); - it( - "Fire Pledge - should not combine with an enemy's Pledge move", - async () => { - game.override - .battleType("single") - .enemyMoveset(Moves.GRASS_PLEDGE); + const baseDmg = baseDmgMock.mock.results[baseDmgMock.mock.results.length - 1].value; + expect(enemyPokemon[0].getMaxHp() - enemyPokemon[0].hp).toBe(toDmgValue(baseDmg * 1.5)); + expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); // PLAYER should not have attacked + expect(game.scene.arena.getTagOnSide(ArenaTagType.FIRE_GRASS_PLEDGE, ArenaTagSide.ENEMY)).toBeDefined(); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + const enemyStartingHp = enemyPokemon.map(p => p.hp); + await game.toNextTurn(); + enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(toDmgValue(p.getMaxHp() / 8))); + }); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + it("Fire Pledge - should combine with Water Pledge to form a 150-power Water-type attack that creates a 'rainbow'", async () => { + game.override.moveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.FIERY_DANCE, Moves.SPLASH]); - game.move.select(Moves.FIRE_PLEDGE); + await game.classicMode.startBattle([Species.BLASTOISE, Species.VENUSAUR]); - await game.toNextTurn(); + const firePledge = allMoves[Moves.FIRE_PLEDGE]; + vi.spyOn(firePledge, "calculateBattlePower"); - // Neither Pokemon should defer their move's effects as they would - // if they combined moves, so both should be damaged. - expect(playerPokemon.hp).toBeLessThan(playerPokemon.getMaxHp()); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - expect(game.scene.arena.getTag(ArenaTagType.FIRE_GRASS_PLEDGE)).toBeUndefined(); - } - ); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - it( - "Grass Pledge - should combine with Fire Pledge to form a 150-power Fire-type attack that creates a 'sea of fire'", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + vi.spyOn(playerPokemon[1], "getMoveType"); - const grassPledge = allMoves[Moves.GRASS_PLEDGE]; - vi.spyOn(grassPledge, "calculateBattlePower"); + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); - - vi.spyOn(playerPokemon[1], "getMoveType"); - const baseDmgMock = vi.spyOn(enemyPokemon[0], "getBaseDamage"); - - game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.GRASS_PLEDGE, 1, BattlerIndex.ENEMY); - - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); - // advance to the end of PLAYER_2's move this turn - for (let i = 0; i < 2; i++) { - await game.phaseInterceptor.to("MoveEndPhase"); - } - expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.FIRE); - expect(grassPledge.calculateBattlePower).toHaveLastReturnedWith(150); - - const baseDmg = baseDmgMock.mock.results[baseDmgMock.mock.results.length - 1].value; - expect(enemyPokemon[0].getMaxHp() - enemyPokemon[0].hp).toBe(toDmgValue(baseDmg * 1.5)); - expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); // PLAYER should not have attacked - expect(game.scene.arena.getTagOnSide(ArenaTagType.FIRE_GRASS_PLEDGE, ArenaTagSide.ENEMY)).toBeDefined(); - - const enemyStartingHp = enemyPokemon.map(p => p.hp); - await game.toNextTurn(); - enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(toDmgValue(p.getMaxHp() / 8))); - } - ); - - it( - "Fire Pledge - should combine with Water Pledge to form a 150-power Water-type attack that creates a 'rainbow'", - async () => { - game.override.moveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.FIERY_DANCE, Moves.SPLASH ]); - - await game.classicMode.startBattle([ Species.BLASTOISE, Species.VENUSAUR ]); - - const firePledge = allMoves[Moves.FIRE_PLEDGE]; - vi.spyOn(firePledge, "calculateBattlePower"); - - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); - - vi.spyOn(playerPokemon[1], "getMoveType"); - - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY); - - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); - // advance to the end of PLAYER_2's move this turn - for (let i = 0; i < 2; i++) { - await game.phaseInterceptor.to("MoveEndPhase"); - } - expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.WATER); - expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(150); - expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); // PLAYER should not have attacked - expect(game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); - - await game.toNextTurn(); - - game.move.select(Moves.FIERY_DANCE, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + // advance to the end of PLAYER_2's move this turn + for (let i = 0; i < 2; i++) { await game.phaseInterceptor.to("MoveEndPhase"); - - // Rainbow effect should increase Fiery Dance's chance of raising Sp. Atk to 100% - expect(playerPokemon[0].getStatStage(Stat.SPATK)).toBe(1); } - ); + expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.WATER); + expect(firePledge.calculateBattlePower).toHaveLastReturnedWith(150); + expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); // PLAYER should not have attacked + expect(game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); - it( - "Water Pledge - should combine with Grass Pledge to form a 150-power Grass-type attack that creates a 'swamp'", - async () => { - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + await game.toNextTurn(); - const waterPledge = allMoves[Moves.WATER_PLEDGE]; - vi.spyOn(waterPledge, "calculateBattlePower"); + game.move.select(Moves.FIERY_DANCE, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPLASH, 1); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + await game.phaseInterceptor.to("MoveEndPhase"); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); - const enemyStartingSpd = enemyPokemon.map(p => p.getEffectiveStat(Stat.SPD)); + // Rainbow effect should increase Fiery Dance's chance of raising Sp. Atk to 100% + expect(playerPokemon[0].getStatStage(Stat.SPATK)).toBe(1); + }); - vi.spyOn(playerPokemon[1], "getMoveType"); + it("Water Pledge - should combine with Grass Pledge to form a 150-power Grass-type attack that creates a 'swamp'", async () => { + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - game.move.select(Moves.GRASS_PLEDGE, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.WATER_PLEDGE, 1, BattlerIndex.ENEMY); + const waterPledge = allMoves[Moves.WATER_PLEDGE]; + vi.spyOn(waterPledge, "calculateBattlePower"); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); - // advance to the end of PLAYER_2's move this turn - for (let i = 0; i < 2; i++) { - await game.phaseInterceptor.to("MoveEndPhase"); - } + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); + const enemyStartingSpd = enemyPokemon.map(p => p.getEffectiveStat(Stat.SPD)); - expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.GRASS); - expect(waterPledge.calculateBattlePower).toHaveLastReturnedWith(150); - expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); + vi.spyOn(playerPokemon[1], "getMoveType"); - expect(game.scene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, ArenaTagSide.ENEMY)).toBeDefined(); - enemyPokemon.forEach((p, i) => expect(p.getEffectiveStat(Stat.SPD)).toBe(Math.floor(enemyStartingSpd[i] / 4))); + game.move.select(Moves.GRASS_PLEDGE, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.WATER_PLEDGE, 1, BattlerIndex.ENEMY); + + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + // advance to the end of PLAYER_2's move this turn + for (let i = 0; i < 2; i++) { + await game.phaseInterceptor.to("MoveEndPhase"); } - ); - it( - "Pledge Moves - should alter turn order when used in combination", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + expect(playerPokemon[1].getMoveType).toHaveLastReturnedWith(PokemonType.GRASS); + expect(waterPledge.calculateBattlePower).toHaveLastReturnedWith(150); + expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); - const enemyPokemon = game.scene.getEnemyField(); + expect(game.scene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, ArenaTagSide.ENEMY)).toBeDefined(); + enemyPokemon.forEach((p, i) => expect(p.getEffectiveStat(Stat.SPD)).toBe(Math.floor(enemyStartingSpd[i] / 4))); + }); - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); + it("Pledge Moves - should alter turn order when used in combination", async () => { + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]); - // PLAYER_2 should act with a combined move immediately after PLAYER as the second move in the turn - for (let i = 0; i < 2; i++) { - await game.phaseInterceptor.to("MoveEndPhase"); - } - expect(enemyPokemon[0].hp).toBe(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); + const enemyPokemon = game.scene.getEnemyField(); + + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); + + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2]); + // PLAYER_2 should act with a combined move immediately after PLAYER as the second move in the turn + for (let i = 0; i < 2; i++) { + await game.phaseInterceptor.to("MoveEndPhase"); } - ); + expect(enemyPokemon[0].hp).toBe(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); + }); - it( - "Pledge Moves - 'rainbow' effect should not stack with Serene Grace when applied to flinching moves", - async () => { - game.override - .ability(Abilities.SERENE_GRACE) - .moveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.IRON_HEAD, Moves.SPLASH ]); + it("Pledge Moves - 'rainbow' effect should not stack with Serene Grace when applied to flinching moves", async () => { + game.override + .ability(Abilities.SERENE_GRACE) + .moveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.IRON_HEAD, Moves.SPLASH]); - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const ironHeadFlinchAttr = allMoves[Moves.IRON_HEAD].getAttrs(FlinchAttr)[0]; - vi.spyOn(ironHeadFlinchAttr, "getMoveChance"); + const ironHeadFlinchAttr = allMoves[Moves.IRON_HEAD].getAttrs(FlinchAttr)[0]; + vi.spyOn(ironHeadFlinchAttr, "getMoveChance"); - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("TurnEndPhase"); - expect(game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); + expect(game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); - game.move.select(Moves.IRON_HEAD, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.IRON_HEAD, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(ironHeadFlinchAttr.getMoveChance).toHaveLastReturnedWith(60); - } - ); + expect(ironHeadFlinchAttr.getMoveChance).toHaveLastReturnedWith(60); + }); - it( - "Pledge Moves - should have no effect when the second ally's move is cancelled", - async () => { - game.override - .enemyMoveset([ Moves.SPLASH, Moves.SPORE ]); + it("Pledge Moves - should have no effect when the second ally's move is cancelled", async () => { + game.override.enemyMoveset([Moves.SPLASH, Moves.SPORE]); - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.GRASS_PLEDGE, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.FIRE_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.GRASS_PLEDGE, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.SPORE, BattlerIndex.PLAYER_2); - await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.SPORE, BattlerIndex.PLAYER_2); + await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - enemyPokemon.forEach((p) => expect(p.hp).toBe(p.getMaxHp())); - } - ); + enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - it( - "Pledge Moves - should ignore redirection from another Pokemon's Storm Drain", - async () => { - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + it("Pledge Moves - should ignore redirection from another Pokemon's Storm Drain", async () => { + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); - vi.spyOn(enemyPokemon[1], "getAbility").mockReturnValue(allAbilities[Abilities.STORM_DRAIN]); + const enemyPokemon = game.scene.getEnemyField(); + vi.spyOn(enemyPokemon[1], "getAbility").mockReturnValue(allAbilities[Abilities.STORM_DRAIN]); - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].getStatStage(Stat.SPATK)).toBe(0); - } - ); + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].getStatStage(Stat.SPATK)).toBe(0); + }); - it( - "Pledge Moves - should not ignore redirection from another Pokemon's Follow Me", - async () => { - game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + it("Pledge Moves - should not ignore redirection from another Pokemon's Follow Me", async () => { + game.override.enemyMoveset([Moves.FOLLOW_ME, Moves.SPLASH]); + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); - await game.forceEnemyMove(Moves.SPLASH); - await game.forceEnemyMove(Moves.FOLLOW_ME); + await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.FOLLOW_ME); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - const enemyPokemon = game.scene.getEnemyField(); - expect(enemyPokemon[0].hp).toBe(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); - } - ); + const enemyPokemon = game.scene.getEnemyField(); + expect(enemyPokemon[0].hp).toBe(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[1].getMaxHp()); + }); }); diff --git a/test/moves/powder.test.ts b/test/moves/powder.test.ts index b43772bd703..522b0b74ca7 100644 --- a/test/moves/powder.test.ts +++ b/test/moves/powder.test.ts @@ -35,284 +35,245 @@ describe("Moves - Powder", () => { .enemyMoveset(Moves.EMBER) .enemyAbility(Abilities.INSOMNIA) .startingLevel(100) - .moveset([ Moves.POWDER, Moves.SPLASH, Moves.FIERY_DANCE, Moves.ROAR ]); + .moveset([Moves.POWDER, Moves.SPLASH, Moves.FIERY_DANCE, Moves.ROAR]); }); - it( - "should cancel the target's Fire-type move, damage the target, and still consume the target's PP", - async () => { - // Cannot use enemy moveset override for this test, since it interferes with checking PP - game.override.enemyMoveset([]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + it("should cancel the target's Fire-type move, damage the target, and still consume the target's PP", async () => { + // Cannot use enemy moveset override for this test, since it interferes with checking PP + game.override.enemyMoveset([]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.moveset = [ new PokemonMove(Moves.EMBER) ]; + const enemyPokemon = game.scene.getEnemyPokemon()!; + enemyPokemon.moveset = [new PokemonMove(Moves.EMBER)]; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - expect(enemyPokemon.moveset[0]!.ppUsed).toBe(1); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + expect(enemyPokemon.moveset[0]!.ppUsed).toBe(1); - await game.toNextTurn(); + await game.toNextTurn(); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - expect(enemyPokemon.moveset[0]!.ppUsed).toBe(2); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + expect(enemyPokemon.moveset[0]!.ppUsed).toBe(2); + }); - it( - "should have no effect against Grass-type Pokemon", - async () => { - game.override.enemySpecies(Species.AMOONGUSS); + it("should have no effect against Grass-type Pokemon", async () => { + game.override.enemySpecies(Species.AMOONGUSS); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should have no effect against Pokemon with Overcoat", - async () => { - game.override.enemyAbility(Abilities.OVERCOAT); + it("should have no effect against Pokemon with Overcoat", async () => { + game.override.enemyAbility(Abilities.OVERCOAT); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should not damage the target if the target has Magic Guard", - async () => { - game.override.enemyAbility(Abilities.MAGIC_GUARD); + it("should not damage the target if the target has Magic Guard", async () => { + game.override.enemyAbility(Abilities.MAGIC_GUARD); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should not damage the target if Primordial Sea is active", - async () => { - game.override.enemyAbility(Abilities.PRIMORDIAL_SEA); + it("should not damage the target if Primordial Sea is active", async () => { + game.override.enemyAbility(Abilities.PRIMORDIAL_SEA); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should not prevent the target from thawing out with Flame Wheel", - async () => { - game.override - .enemyMoveset(Array(4).fill(Moves.FLAME_WHEEL)) - .enemyStatusEffect(StatusEffect.FREEZE); + it("should not prevent the target from thawing out with Flame Wheel", async () => { + game.override.enemyMoveset(Array(4).fill(Moves.FLAME_WHEEL)).enemyStatusEffect(StatusEffect.FREEZE); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.FREEZE); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.FREEZE); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + }); - it( - "should not allow a target with Protean to change to Fire type", - async () => { - game.override.enemyAbility(Abilities.PROTEAN); + it("should not allow a target with Protean to change to Fire type", async () => { + game.override.enemyAbility(Abilities.PROTEAN); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - expect(enemyPokemon.summonData?.types).not.toBe(PokemonType.FIRE); - }); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + expect(enemyPokemon.summonData?.types).not.toBe(PokemonType.FIRE); + }); - it( - "should cancel Fire-type moves generated by the target's Dancer ability", - async () => { - game.override - .battleType("double") - .enemySpecies(Species.BLASTOISE) - .enemyAbility(Abilities.DANCER); + it("should cancel Fire-type moves generated by the target's Dancer ability", async () => { + game.override.battleType("double").enemySpecies(Species.BLASTOISE).enemyAbility(Abilities.DANCER); - await game.classicMode.startBattle([ Species.CHARIZARD, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD, Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - // Turn 1: Roar away 1 opponent - game.move.select(Moves.ROAR, 0, BattlerIndex.ENEMY_2); - game.move.select(Moves.SPLASH, 1); - await game.toNextTurn(); - await game.toNextTurn(); // Requires game.toNextTurn() twice due to double battle + // Turn 1: Roar away 1 opponent + game.move.select(Moves.ROAR, 0, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPLASH, 1); + await game.toNextTurn(); + await game.toNextTurn(); // Requires game.toNextTurn() twice due to double battle - // Turn 2: Enemy should activate Powder twice: From using Ember, and from copying Fiery Dance via Dancer - playerPokemon.hp = playerPokemon.getMaxHp(); - game.move.select(Moves.FIERY_DANCE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.POWDER, 1, BattlerIndex.ENEMY); + // Turn 2: Enemy should activate Powder twice: From using Ember, and from copying Fiery Dance via Dancer + playerPokemon.hp = playerPokemon.getMaxHp(); + game.move.select(Moves.FIERY_DANCE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.POWDER, 1, BattlerIndex.ENEMY); - await game.phaseInterceptor.to(MoveEffectPhase); - const enemyStartingHp = enemyPokemon.hp; + await game.phaseInterceptor.to(MoveEffectPhase); + const enemyStartingHp = enemyPokemon.hp; - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); + // player should not take damage + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); + // enemy should have taken damage from player's Fiery Dance + 2 Powder procs + expect(enemyPokemon.hp).toBe( + enemyStartingHp - playerPokemon.turnData.totalDamageDealt - 2 * Math.floor(enemyPokemon.getMaxHp() / 4), + ); + }); - // player should not take damage - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(playerPokemon.hp).toBe(playerPokemon.getMaxHp()); - // enemy should have taken damage from player's Fiery Dance + 2 Powder procs - expect(enemyPokemon.hp).toBe(enemyStartingHp - playerPokemon.turnData.totalDamageDealt - 2 * Math.floor(enemyPokemon.getMaxHp() / 4)); - }); + it("should cancel Fiery Dance, then prevent it from triggering Dancer", async () => { + game.override.ability(Abilities.DANCER).enemyMoveset(Moves.FIERY_DANCE); - it( - "should cancel Fiery Dance, then prevent it from triggering Dancer", - async () => { - game.override.ability(Abilities.DANCER) - .enemyMoveset(Moves.FIERY_DANCE); + await game.classicMode.startBattle([Species.CHARIZARD]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + game.move.select(Moves.POWDER); - game.move.select(Moves.POWDER); + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + expect(playerPokemon.getLastXMoves()[0].move).toBe(Moves.POWDER); + }); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - expect(playerPokemon.getLastXMoves()[0].move).toBe(Moves.POWDER); - }); + it("should cancel Revelation Dance if it becomes a Fire-type move", async () => { + game.override.enemySpecies(Species.CHARIZARD).enemyMoveset(Array(4).fill(Moves.REVELATION_DANCE)); - it( - "should cancel Revelation Dance if it becomes a Fire-type move", - async () => { - game.override - .enemySpecies(Species.CHARIZARD) - .enemyMoveset(Array(4).fill(Moves.REVELATION_DANCE)); + await game.classicMode.startBattle([Species.CHARIZARD]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); - - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.POWDER); + game.move.select(Moves.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - }); - - it( - "should cancel Shell Trap and damage the target, even if the move would fail", - async () => { - game.override.enemyMoveset(Array(4).fill(Moves.SHELL_TRAP)); - - await game.classicMode.startBattle([ Species.CHARIZARD ]); - - const enemyPokemon = game.scene.getEnemyPokemon()!; + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + }); - game.move.select(Moves.POWDER); - - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - }); - - it( - "should cancel Grass Pledge if used after ally's Fire Pledge", - async () => { - game.override.enemyMoveset([ Moves.FIRE_PLEDGE, Moves.GRASS_PLEDGE ]) - .battleType("double"); - - await game.classicMode.startBattle([ Species.CHARIZARD, Species.CHARIZARD ]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - - game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); - await game.forceEnemyMove(Moves.GRASS_PLEDGE, BattlerIndex.PLAYER); - await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY ]); - - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - }); - - it( - "should cancel Fire Pledge if used before ally's Water Pledge", - async () => { - game.override.enemyMoveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE ]) - .battleType("double"); - - await game.classicMode.startBattle([ Species.CHARIZARD, Species.CHARIZARD ]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + it("should cancel Shell Trap and damage the target, even if the move would fail", async () => { + game.override.enemyMoveset(Array(4).fill(Moves.SHELL_TRAP)); - game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); - await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); - await game.forceEnemyMove(Moves.WATER_PLEDGE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); - - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(Math.ceil(3 * enemyPokemon.getMaxHp() / 4)); - }); - - it( - "should NOT cancel Fire Pledge if used after ally's Water Pledge", - async () => { - game.override.enemyMoveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE ]) - .battleType("double"); - - await game.classicMode.startBattle([ Species.CHARIZARD, Species.CHARIZARD ]); - const enemyPokemon = game.scene.getEnemyPokemon()!; - - game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); - await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); - await game.forceEnemyMove(Moves.WATER_PLEDGE, BattlerIndex.PLAYER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY ]); - - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - }); + await game.classicMode.startBattle([Species.CHARIZARD]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.POWDER); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + }); + + it("should cancel Grass Pledge if used after ally's Fire Pledge", async () => { + game.override.enemyMoveset([Moves.FIRE_PLEDGE, Moves.GRASS_PLEDGE]).battleType("double"); + + await game.classicMode.startBattle([Species.CHARIZARD, Species.CHARIZARD]); + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.GRASS_PLEDGE, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + }); + + it("should cancel Fire Pledge if used before ally's Water Pledge", async () => { + game.override.enemyMoveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE]).battleType("double"); + + await game.classicMode.startBattle([Species.CHARIZARD, Species.CHARIZARD]); + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.WATER_PLEDGE, BattlerIndex.PLAYER); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); + }); + + it("should NOT cancel Fire Pledge if used after ally's Water Pledge", async () => { + game.override.enemyMoveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE]).battleType("double"); + + await game.classicMode.startBattle([Species.CHARIZARD, Species.CHARIZARD]); + const enemyPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.POWDER, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.FIRE_PLEDGE, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.WATER_PLEDGE, BattlerIndex.PLAYER); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]); + + await game.phaseInterceptor.to(BerryPhase, false); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); }); diff --git a/test/moves/power_shift.test.ts b/test/moves/power_shift.test.ts index bb98d8cf3ed..fbc6d732d30 100644 --- a/test/moves/power_shift.test.ts +++ b/test/moves/power_shift.test.ts @@ -22,7 +22,7 @@ describe("Moves - Power Shift", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.POWER_SHIFT, Moves.BULK_UP ]) + .moveset([Moves.POWER_SHIFT, Moves.BULK_UP]) .battleType("single") .ability(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH) @@ -30,7 +30,7 @@ describe("Moves - Power Shift", () => { }); it("switches the user's raw Attack stat with its raw Defense stat", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/power_split.test.ts b/test/moves/power_split.test.ts index 69ea92c69ef..9150a707ad5 100644 --- a/test/moves/power_split.test.ts +++ b/test/moves/power_split.test.ts @@ -28,15 +28,13 @@ describe("Moves - Power Split", () => { .enemyAbility(Abilities.NONE) .enemySpecies(Species.MEW) .enemyLevel(200) - .moveset([ Moves.POWER_SPLIT ]) + .moveset([Moves.POWER_SPLIT]) .ability(Abilities.NONE); }); it("should average the user's ATK and SPATK stats with those of the target", async () => { game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ - Species.INDEEDEE - ]); + await game.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -55,10 +53,8 @@ describe("Moves - Power Split", () => { }, 20000); it("should be idempotent", async () => { - game.override.enemyMoveset([ Moves.POWER_SPLIT ]); - await game.startBattle([ - Species.INDEEDEE - ]); + game.override.enemyMoveset([Moves.POWER_SPLIT]); + await game.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/power_swap.test.ts b/test/moves/power_swap.test.ts index 637714f1277..d6f5e782e66 100644 --- a/test/moves/power_swap.test.ts +++ b/test/moves/power_swap.test.ts @@ -29,14 +29,12 @@ describe("Moves - Power Swap", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.INDEEDEE) .enemyLevel(200) - .moveset([ Moves.POWER_SWAP ]) + .moveset([Moves.POWER_SWAP]) .ability(Abilities.NONE); }); it("should swap the user's ATK and SPATK stat stages with the target's", async () => { - await game.classicMode.startBattle([ - Species.INDEEDEE - ]); + await game.classicMode.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/power_trick.test.ts b/test/moves/power_trick.test.ts index e60172b5304..0cd849bbcc5 100644 --- a/test/moves/power_trick.test.ts +++ b/test/moves/power_trick.test.ts @@ -30,12 +30,12 @@ describe("Moves - Power Trick", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.MEW) .enemyLevel(200) - .moveset([ Moves.POWER_TRICK ]) + .moveset([Moves.POWER_TRICK]) .ability(Abilities.BALL_FETCH); }); it("swaps the user's ATK and DEF stats", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); const player = game.scene.getPlayerPokemon()!; const baseATK = player.getStat(Stat.ATK, false); @@ -51,7 +51,7 @@ describe("Moves - Power Trick", () => { }); it("resets initial ATK and DEF stat swap when used consecutively", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); const player = game.scene.getPlayerPokemon()!; const baseATK = player.getStat(Stat.ATK, false); @@ -71,8 +71,8 @@ describe("Moves - Power Trick", () => { }); it("should pass effect when using BATON_PASS", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); - await game.override.moveset([ Moves.POWER_TRICK, Moves.BATON_PASS ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); + await game.override.moveset([Moves.POWER_TRICK, Moves.BATON_PASS]); const player = game.scene.getPlayerPokemon()!; player.addTag(BattlerTagType.POWER_TRICK); @@ -92,8 +92,8 @@ describe("Moves - Power Trick", () => { }); it("should remove effect after using Transform", async () => { - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); - await game.override.moveset([ Moves.POWER_TRICK, Moves.TRANSFORM ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); + await game.override.moveset([Moves.POWER_TRICK, Moves.TRANSFORM]); const player = game.scene.getPlayerPokemon()!; player.addTag(BattlerTagType.POWER_TRICK); diff --git a/test/moves/protect.test.ts b/test/moves/protect.test.ts index 7f5484ab7c9..d50c490f7d3 100644 --- a/test/moves/protect.test.ts +++ b/test/moves/protect.test.ts @@ -10,7 +10,6 @@ import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag"; import { BattlerIndex } from "#app/battle"; import { MoveResult } from "#app/field/pokemon"; - describe("Moves - Protect", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,104 +29,89 @@ describe("Moves - Protect", () => { game.override.battleType("single"); - game.override.moveset([ Moves.PROTECT ]); + game.override.moveset([Moves.PROTECT]); game.override.enemySpecies(Species.SNORLAX); game.override.enemyAbility(Abilities.INSOMNIA); - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user from attacks", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD ]); + test("should protect the user from attacks", async () => { + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.PROTECT); + game.move.select(Moves.PROTECT); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + }); - test( - "should prevent secondary effects from the opponent's attack", - async () => { - game.override.enemyMoveset([ Moves.CEASELESS_EDGE ]); - vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); + test("should prevent secondary effects from the opponent's attack", async () => { + game.override.enemyMoveset([Moves.CEASELESS_EDGE]); + vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.PROTECT); + game.move.select(Moves.PROTECT); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(game.scene.arena.getTagOnSide(ArenaTrapTag, ArenaTagSide.ENEMY)).toBeUndefined(); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(game.scene.arena.getTagOnSide(ArenaTrapTag, ArenaTagSide.ENEMY)).toBeUndefined(); + }); - test( - "should protect the user from status moves", - async () => { - game.override.enemyMoveset([ Moves.CHARM ]); + test("should protect the user from status moves", async () => { + game.override.enemyMoveset([Moves.CHARM]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.PROTECT); + game.move.select(Moves.PROTECT); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); - } - ); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); + }); - test( - "should stop subsequent hits of a multi-hit move", - async () => { - game.override.enemyMoveset([ Moves.TACHYON_CUTTER ]); + test("should stop subsequent hits of a multi-hit move", async () => { + game.override.enemyMoveset([Moves.TACHYON_CUTTER]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.PROTECT); + game.move.select(Moves.PROTECT); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); - expect(enemyPokemon.turnData.hitCount).toBe(1); - } - ); + expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); + expect(enemyPokemon.turnData.hitCount).toBe(1); + }); - test( - "should fail if the user is the last to move in the turn", - async () => { - game.override.enemyMoveset([ Moves.PROTECT ]); + test("should fail if the user is the last to move in the turn", async () => { + game.override.enemyMoveset([Moves.PROTECT]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.PROTECT); + game.move.select(Moves.PROTECT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(leadPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - } - ); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(leadPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); }); diff --git a/test/moves/psycho_shift.test.ts b/test/moves/psycho_shift.test.ts index d5890a3af0b..0a82189d201 100644 --- a/test/moves/psycho_shift.test.ts +++ b/test/moves/psycho_shift.test.ts @@ -23,7 +23,7 @@ describe("Moves - Psycho Shift", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.PSYCHO_SHIFT ]) + .moveset([Moves.PSYCHO_SHIFT]) .ability(Abilities.BALL_FETCH) .statusEffect(StatusEffect.POISON) .battleType("single") @@ -35,7 +35,7 @@ describe("Moves - Psycho Shift", () => { }); it("If Psycho Shift is used on a Pokémon with Synchronize, the user of Psycho Shift will already be afflicted with a status condition when Synchronize activates", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); const enemyPokemon = game.scene.getEnemyPokemon(); diff --git a/test/moves/purify.test.ts b/test/moves/purify.test.ts index eba8e9d851f..30d9df8ff67 100644 --- a/test/moves/purify.test.ts +++ b/test/moves/purify.test.ts @@ -9,7 +9,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Moves - Purify", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -30,49 +29,42 @@ describe("Moves - Purify", () => { game.override.starterSpecies(Species.PYUKUMUKU); game.override.startingLevel(10); - game.override.moveset([ Moves.PURIFY, Moves.SIZZLY_SLIDE ]); + game.override.moveset([Moves.PURIFY, Moves.SIZZLY_SLIDE]); game.override.enemySpecies(Species.MAGIKARP); game.override.enemyLevel(10); - game.override.enemyMoveset([ Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE]); }); - test( - "Purify heals opponent status effect and restores user hp", - async () => { - await game.startBattle(); + test("Purify heals opponent status effect and restores user hp", async () => { + await game.startBattle(); - const enemyPokemon: EnemyPokemon = game.scene.getEnemyPokemon()!; - const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon: EnemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.hp = playerPokemon.getMaxHp() - 1; - enemyPokemon.status = new Status(StatusEffect.BURN); + playerPokemon.hp = playerPokemon.getMaxHp() - 1; + enemyPokemon.status = new Status(StatusEffect.BURN); - game.move.select(Moves.PURIFY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEndPhase); + game.move.select(Moves.PURIFY); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEndPhase); - expect(enemyPokemon.status).toBeNull(); - expect(playerPokemon.isFullHp()).toBe(true); - }, - ); + expect(enemyPokemon.status).toBeNull(); + expect(playerPokemon.isFullHp()).toBe(true); + }); - test( - "Purify does not heal if opponent doesnt have any status effect", - async () => { - await game.startBattle(); + test("Purify does not heal if opponent doesnt have any status effect", async () => { + await game.startBattle(); - const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon: PlayerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.hp = playerPokemon.getMaxHp() - 1; - const playerInitialHp = playerPokemon.hp; + playerPokemon.hp = playerPokemon.getMaxHp() - 1; + const playerInitialHp = playerPokemon.hp; - game.move.select(Moves.PURIFY); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEndPhase); - - expect(playerPokemon.hp).toBe(playerInitialHp); - }, - ); + game.move.select(Moves.PURIFY); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEndPhase); + expect(playerPokemon.hp).toBe(playerInitialHp); + }); }); diff --git a/test/moves/quash.test.ts b/test/moves/quash.test.ts index dd91820a8db..f85dbd89517 100644 --- a/test/moves/quash.test.ts +++ b/test/moves/quash.test.ts @@ -29,13 +29,13 @@ describe("Moves - Quash", () => { .enemyLevel(1) .enemySpecies(Species.SLOWPOKE) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.RAIN_DANCE, Moves.SPLASH ]) + .enemyMoveset([Moves.RAIN_DANCE, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) - .moveset([ Moves.QUASH, Moves.SUNNY_DAY, Moves.RAIN_DANCE, Moves.SPLASH ]); + .moveset([Moves.QUASH, Moves.SUNNY_DAY, Moves.RAIN_DANCE, Moves.SPLASH]); }); it("makes the target move last in a turn, ignoring priority", async () => { - await game.classicMode.startBattle([ Species.ACCELGOR, Species.RATTATA ]); + await game.classicMode.startBattle([Species.ACCELGOR, Species.RATTATA]); game.move.select(Moves.QUASH, 0, BattlerIndex.PLAYER_2); game.move.select(Moves.SUNNY_DAY, 1); @@ -48,7 +48,7 @@ describe("Moves - Quash", () => { }); it("fails if the target has already moved", async () => { - await game.classicMode.startBattle([ Species.ACCELGOR, Species.RATTATA ]); + await game.classicMode.startBattle([Species.ACCELGOR, Species.RATTATA]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.QUASH, 1, BattlerIndex.PLAYER); @@ -59,10 +59,9 @@ describe("Moves - Quash", () => { }); it("makes multiple quashed targets move in speed order at the end of the turn", async () => { - game.override.enemySpecies(Species.NINJASK) - .enemyLevel(100); + game.override.enemySpecies(Species.NINJASK).enemyLevel(100); - await game.classicMode.startBattle([ Species.ACCELGOR, Species.RATTATA ]); + await game.classicMode.startBattle([Species.ACCELGOR, Species.RATTATA]); // both users are quashed - rattata is slower so sun should be up at end of turn game.move.select(Moves.RAIN_DANCE, 0); @@ -76,9 +75,9 @@ describe("Moves - Quash", () => { }); it("respects trick room", async () => { - game.override.enemyMoveset([ Moves.RAIN_DANCE, Moves.SPLASH, Moves.TRICK_ROOM ]); + game.override.enemyMoveset([Moves.RAIN_DANCE, Moves.SPLASH, Moves.TRICK_ROOM]); - await game.classicMode.startBattle([ Species.ACCELGOR, Species.RATTATA ]); + await game.classicMode.startBattle([Species.ACCELGOR, Species.RATTATA]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.SPLASH, 1); @@ -95,5 +94,4 @@ describe("Moves - Quash", () => { await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.RAIN); }); - }); diff --git a/test/moves/quick_guard.test.ts b/test/moves/quick_guard.test.ts index c326e77d057..22d4a5078ac 100644 --- a/test/moves/quick_guard.test.ts +++ b/test/moves/quick_guard.test.ts @@ -8,7 +8,6 @@ import { Stat } from "#enums/stat"; import { BattlerIndex } from "#app/battle"; import { MoveResult } from "#app/field/pokemon"; - describe("Moves - Quick Guard", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,90 +27,78 @@ describe("Moves - Quick Guard", () => { game.override.battleType("double"); - game.override.moveset([ Moves.QUICK_GUARD, Moves.SPLASH, Moves.FOLLOW_ME ]); + game.override.moveset([Moves.QUICK_GUARD, Moves.SPLASH, Moves.FOLLOW_ME]); game.override.enemySpecies(Species.SNORLAX); - game.override.enemyMoveset([ Moves.QUICK_ATTACK ]); + game.override.enemyMoveset([Moves.QUICK_ATTACK]); game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user and allies from priority moves", - async () => { - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + test("should protect the user and allies from priority moves", async () => { + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.QUICK_GUARD); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.QUICK_GUARD); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - } - ); + playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - test( - "should protect the user and allies from Prankster-boosted moves", - async () => { - game.override.enemyAbility(Abilities.PRANKSTER); - game.override.enemyMoveset([ Moves.GROWL ]); + test("should protect the user and allies from Prankster-boosted moves", async () => { + game.override.enemyAbility(Abilities.PRANKSTER); + game.override.enemyMoveset([Moves.GROWL]); - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerField(); + const playerPokemon = game.scene.getPlayerField(); - game.move.select(Moves.QUICK_GUARD); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.QUICK_GUARD); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); - } - ); + playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); + }); - test( - "should stop subsequent hits of a multi-hit priority move", - async () => { - game.override.enemyMoveset([ Moves.WATER_SHURIKEN ]); + test("should stop subsequent hits of a multi-hit priority move", async () => { + game.override.enemyMoveset([Moves.WATER_SHURIKEN]); - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.QUICK_GUARD); - game.move.select(Moves.FOLLOW_ME, 1); + game.move.select(Moves.QUICK_GUARD); + game.move.select(Moves.FOLLOW_ME, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); - } - ); + playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); + }); - test( - "should fail if the user is the last to move in the turn", - async () => { - game.override.battleType("single"); - game.override.enemyMoveset([ Moves.QUICK_GUARD ]); + test("should fail if the user is the last to move in the turn", async () => { + game.override.battleType("single"); + game.override.enemyMoveset([Moves.QUICK_GUARD]); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.QUICK_GUARD); + game.move.select(Moves.QUICK_GUARD); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - } - ); + expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); }); diff --git a/test/moves/rage_fist.test.ts b/test/moves/rage_fist.test.ts index 15c8794a469..8bcb212d60e 100644 --- a/test/moves/rage_fist.test.ts +++ b/test/moves/rage_fist.test.ts @@ -26,7 +26,7 @@ describe("Moves - Rage Fist", () => { game = new GameManager(phaserGame); game.override .battleType("single") - .moveset([ Moves.RAGE_FIST, Moves.SPLASH, Moves.SUBSTITUTE ]) + .moveset([Moves.RAGE_FIST, Moves.SPLASH, Moves.SUBSTITUTE]) .startingLevel(100) .enemyLevel(1) .enemyAbility(Abilities.BALL_FETCH) @@ -36,96 +36,84 @@ describe("Moves - Rage Fist", () => { }); it("should have 100 more power if hit twice before calling Rage Fist", async () => { - game.override - .enemySpecies(Species.MAGIKARP); + game.override.enemySpecies(Species.MAGIKARP); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(move.calculateBattlePower).toHaveLastReturnedWith(150); }); it("should maintain its power during next battle if it is within the same arena encounter", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(1); + game.override.enemySpecies(Species.MAGIKARP).startingWave(1); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(250); }); it("should reset the hitRecCounter if we enter new trainer battle", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(4); + game.override.enemySpecies(Species.MAGIKARP).startingWave(4); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextWave(); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(150); }); it("should not increase the hitCounter if Substitute is hit", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(4); + game.override.enemySpecies(Species.MAGIKARP).startingWave(4); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SUBSTITUTE); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); expect(game.scene.getPlayerPokemon()?.customPokemonData.hitsRecCount).toBe(0); }); it("should reset the hitRecCounter if we enter new biome", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(10); + game.override.enemySpecies(Species.MAGIKARP).startingWave(10); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); game.move.select(Moves.RAGE_FIST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(move.calculateBattlePower).toHaveLastReturnedWith(150); }); it("should not reset the hitRecCounter if switched out", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .startingWave(1) - .enemyMoveset(Moves.TACKLE); + game.override.enemySpecies(Species.MAGIKARP).startingWave(1).enemyMoveset(Moves.TACKLE); - await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.CHARIZARD, Species.BLASTOISE]); game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); game.doSwitchPokemon(1); diff --git a/test/moves/rage_powder.test.ts b/test/moves/rage_powder.test.ts index 15a9bfd951c..ab05ae2e0bc 100644 --- a/test/moves/rage_powder.test.ts +++ b/test/moves/rage_powder.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Moves - Rage Powder", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,54 +26,48 @@ describe("Moves - Rage Powder", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([ Moves.RAGE_POWDER, Moves.TACKLE, Moves.SPLASH ]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.RAGE_POWDER, Moves.TACKLE, Moves.SPLASH]); }); - test( - "move effect should be bypassed by Grass type", - async () => { - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.VENUSAUR ]); + test("move effect should be bypassed by Grass type", async () => { + await game.classicMode.startBattle([Species.AMOONGUSS, Species.VENUSAUR]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.RAGE_POWDER); - await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.RAGE_POWDER); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - // If redirection was bypassed, both enemies should be damaged - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - } - ); + // If redirection was bypassed, both enemies should be damaged + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + }); - test( - "move effect should be bypassed by Overcoat", - async () => { - game.override.ability(Abilities.OVERCOAT); + test("move effect should be bypassed by Overcoat", async () => { + game.override.ability(Abilities.OVERCOAT); - // Test with two non-Grass type player Pokemon - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + // Test with two non-Grass type player Pokemon + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - const enemyStartingHp = enemyPokemon.map(p => p.hp); + const enemyStartingHp = enemyPokemon.map(p => p.hp); - game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.QUICK_ATTACK, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.RAGE_POWDER); - await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.RAGE_POWDER); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - // If redirection was bypassed, both enemies should be damaged - expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); - expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); - } - ); + // If redirection was bypassed, both enemies should be damaged + expect(enemyPokemon[0].hp).toBeLessThan(enemyStartingHp[0]); + expect(enemyPokemon[1].hp).toBeLessThan(enemyStartingHp[1]); + }); }); diff --git a/test/moves/reflect.test.ts b/test/moves/reflect.test.ts index 4f818afb071..ac879a7cc2b 100644 --- a/test/moves/reflect.test.ts +++ b/test/moves/reflect.test.ts @@ -36,21 +36,25 @@ describe("Moves - Reflect", () => { globalScene = game.scene; game.override.battleType("single"); game.override.ability(Abilities.NONE); - game.override.moveset([ Moves.ABSORB, Moves.ROCK_SLIDE, Moves.TACKLE ]); + game.override.moveset([Moves.ABSORB, Moves.ROCK_SLIDE, Moves.TACKLE]); game.override.enemyLevel(100); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.REFLECT, Moves.REFLECT, Moves.REFLECT, Moves.REFLECT ]); + game.override.enemyMoveset([Moves.REFLECT, Moves.REFLECT, Moves.REFLECT, Moves.REFLECT]); game.override.disableCrits(); }); it("reduces damage of physical attacks by half in a single battle", async () => { const moveToUse = Moves.TACKLE; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); }); @@ -59,39 +63,68 @@ describe("Moves - Reflect", () => { game.override.battleType("double"); const moveToUse = Moves.ROCK_SLIDE; - await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE, Species.SHUCKLE]); game.move.select(moveToUse); game.move.select(moveToUse, 1); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); }); it("does not affect special attacks", async () => { const moveToUse = Moves.ABSORB; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); it("does not affect critical hits", async () => { - game.override.moveset([ Moves.WICKED_BLOW ]); + game.override.moveset([Moves.WICKED_BLOW]); const moveToUse = Moves.WICKED_BLOW; - await game.classicMode.startBattle([ Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.SHUCKLE]); game.move.select(moveToUse); await game.phaseInterceptor.to(TurnEndPhase); - const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); + + expect(mockedDmg).toBe(allMoves[moveToUse].power); + }); + + it("does not affect critical hits", async () => { + game.override.moveset([Moves.WICKED_BLOW]); + const moveToUse = Moves.WICKED_BLOW; + await game.classicMode.startBattle([Species.SHUCKLE]); + + game.move.select(moveToUse); + await game.phaseInterceptor.to(TurnEndPhase); + + const mockedDmg = getMockedMoveDamage( + game.scene.getEnemyPokemon()!, + game.scene.getPlayerPokemon()!, + allMoves[moveToUse], + ); expect(mockedDmg).toBe(allMoves[moveToUse].power); }); }); diff --git a/test/moves/reflect_type.test.ts b/test/moves/reflect_type.test.ts index aa61f00a083..78371d35475 100644 --- a/test/moves/reflect_type.test.ts +++ b/test/moves/reflect_type.test.ts @@ -22,20 +22,16 @@ describe("Moves - Reflect Type", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override - .ability(Abilities.BALL_FETCH) - .battleType("single") - .disableCrits() - .enemyAbility(Abilities.BALL_FETCH); + game.override.ability(Abilities.BALL_FETCH).battleType("single").disableCrits().enemyAbility(Abilities.BALL_FETCH); }); it("will make the user Normal/Grass if targetting a typeless Pokemon affected by Forest's Curse", async () => { game.override - .moveset([ Moves.FORESTS_CURSE, Moves.REFLECT_TYPE ]) + .moveset([Moves.FORESTS_CURSE, Moves.REFLECT_TYPE]) .startingLevel(60) .enemySpecies(Species.CHARMANDER) - .enemyMoveset([ Moves.BURN_UP, Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.FEEBAS ]); + .enemyMoveset([Moves.BURN_UP, Moves.SPLASH]); + await game.classicMode.startBattle([Species.FEEBAS]); const playerPokemon = game.scene.getPlayerPokemon(); const enemyPokemon = game.scene.getEnemyPokemon(); diff --git a/test/moves/relic_song.test.ts b/test/moves/relic_song.test.ts index 48e945f596a..d8f1373b4c0 100644 --- a/test/moves/relic_song.test.ts +++ b/test/moves/relic_song.test.ts @@ -23,7 +23,7 @@ describe("Moves - Relic Song", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.RELIC_SONG, Moves.SPLASH ]) + .moveset([Moves.RELIC_SONG, Moves.SPLASH]) .battleType("single") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) @@ -32,7 +32,7 @@ describe("Moves - Relic Song", () => { }); it("swaps Meloetta's form between Aria and Pirouette", async () => { - await game.classicMode.startBattle([ Species.MELOETTA ]); + await game.classicMode.startBattle([Species.MELOETTA]); const meloetta = game.scene.getPlayerPokemon()!; @@ -49,7 +49,7 @@ describe("Moves - Relic Song", () => { it("doesn't swap Meloetta's form during a mono-type challenge", async () => { game.challengeMode.addChallenge(Challenges.SINGLE_TYPE, PokemonType.PSYCHIC + 1, 0); - await game.challengeMode.startBattle([ Species.MELOETTA ]); + await game.challengeMode.startBattle([Species.MELOETTA]); const meloetta = game.scene.getPlayerPokemon()!; @@ -63,10 +63,8 @@ describe("Moves - Relic Song", () => { }); it("doesn't swap Meloetta's form during biome change (arena reset)", async () => { - game.override - .starterForms({ [Species.MELOETTA]: 1 }) - .startingWave(10); - await game.classicMode.startBattle([ Species.MELOETTA ]); + game.override.starterForms({ [Species.MELOETTA]: 1 }).startingWave(10); + await game.classicMode.startBattle([Species.MELOETTA]); const meloetta = game.scene.getPlayerPokemon()!; diff --git a/test/moves/retaliate.test.ts b/test/moves/retaliate.test.ts index 33bba2af211..5cc0b08ccc6 100644 --- a/test/moves/retaliate.test.ts +++ b/test/moves/retaliate.test.ts @@ -26,16 +26,16 @@ describe("Moves - Retaliate", () => { game.override .battleType("single") .enemySpecies(Species.SNORLAX) - .enemyMoveset([ Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE ]) + .enemyMoveset([Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE, Moves.RETALIATE]) .enemyLevel(100) - .moveset([ Moves.RETALIATE, Moves.SPLASH ]) + .moveset([Moves.RETALIATE, Moves.SPLASH]) .startingLevel(80) .disableCrits(); }); it("increases power if ally died previous turn", async () => { vi.spyOn(retaliate, "calculateBattlePower"); - await game.startBattle([ Species.ABRA, Species.COBALION ]); + await game.startBattle([Species.ABRA, Species.COBALION]); game.move.select(Moves.RETALIATE); await game.phaseInterceptor.to("TurnEndPhase"); expect(retaliate.calculateBattlePower).toHaveLastReturnedWith(70); diff --git a/test/moves/revival_blessing.test.ts b/test/moves/revival_blessing.test.ts index 647771fa23b..187b5e62e76 100644 --- a/test/moves/revival_blessing.test.ts +++ b/test/moves/revival_blessing.test.ts @@ -25,7 +25,7 @@ describe("Moves - Revival Blessing", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.REVIVAL_BLESSING, Moves.MEMENTO ]) + .moveset([Moves.SPLASH, Moves.REVIVAL_BLESSING, Moves.MEMENTO]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -35,7 +35,7 @@ describe("Moves - Revival Blessing", () => { }); it("should revive a selected fainted Pokemon when used by the player", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); game.move.select(Moves.MEMENTO); game.doSelectPartyPokemon(1, "SwitchPhase"); @@ -46,7 +46,7 @@ describe("Moves - Revival Blessing", () => { expect(player.species.speciesId).toBe(Species.MAGIKARP); game.move.select(Moves.REVIVAL_BLESSING); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); game.doSelectPartyPokemon(1, "RevivalBlessingPhase"); await game.phaseInterceptor.to("MoveEndPhase", false); @@ -59,14 +59,14 @@ describe("Moves - Revival Blessing", () => { it("should revive a random fainted enemy when used by an enemy Trainer", async () => { game.override.enemyMoveset(Moves.REVIVAL_BLESSING).startingWave(8); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.toNextTurn(); game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase", false); @@ -76,10 +76,10 @@ describe("Moves - Revival Blessing", () => { }); it("should fail when there are no fainted Pokemon to target", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MAGIKARP]); game.move.select(Moves.REVIVAL_BLESSING); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase", false); const player = game.scene.getPlayerPokemon()!; @@ -89,10 +89,10 @@ describe("Moves - Revival Blessing", () => { it("should revive a player pokemon and immediately send it back out if used in the same turn it fainted in doubles", async () => { game.override .battleType("double") - .enemyMoveset([ Moves.SPLASH, Moves.FISSURE ]) + .enemyMoveset([Moves.SPLASH, Moves.FISSURE]) .enemyAbility(Abilities.NO_GUARD) .enemyLevel(100); - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC, Species.GYARADOS ]); + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC, Species.GYARADOS]); const feebas = game.scene.getPlayerField()[0]; @@ -100,7 +100,7 @@ describe("Moves - Revival Blessing", () => { game.move.select(Moves.REVIVAL_BLESSING, 1); await game.forceEnemyMove(Moves.FISSURE, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2]); await game.phaseInterceptor.to("MoveEndPhase"); await game.phaseInterceptor.to("MoveEndPhase"); diff --git a/test/moves/role_play.test.ts b/test/moves/role_play.test.ts index edc41de5c68..2a899b6e987 100644 --- a/test/moves/role_play.test.ts +++ b/test/moves/role_play.test.ts @@ -23,7 +23,7 @@ describe("Moves - Role Play", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.ROLE_PLAY ]) + .moveset([Moves.SPLASH, Moves.ROLE_PLAY]) .ability(Abilities.ADAPTABILITY) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Moves - Role Play", () => { }); it("should set the user's ability to the target's ability", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.ROLE_PLAY); await game.phaseInterceptor.to("BerryPhase"); @@ -43,7 +43,7 @@ describe("Moves - Role Play", () => { it("should activate post-summon abilities", async () => { game.override.enemyAbility(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.ROLE_PLAY); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/rollout.test.ts b/test/moves/rollout.test.ts index 08c18267a75..89270c2dfc7 100644 --- a/test/moves/rollout.test.ts +++ b/test/moves/rollout.test.ts @@ -35,7 +35,7 @@ describe("Moves - Rollout", () => { }); it("should double it's dmg on sequential uses but reset after 5", async () => { - game.override.moveset([ Moves.ROLLOUT ]); + game.override.moveset([Moves.ROLLOUT]); vi.spyOn(allMoves[Moves.ROLLOUT], "accuracy", "get").mockReturnValue(100); //always hit const variance = 5; @@ -45,10 +45,10 @@ describe("Moves - Rollout", () => { await game.startBattle(); const playerPkm = game.scene.getPlayerParty()[0]; - vi.spyOn(playerPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD + vi.spyOn(playerPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD const enemyPkm = game.scene.getEnemyParty()[0]; - vi.spyOn(enemyPkm, "stats", "get").mockReturnValue([ 500000, 1, 1, 1, 1, 1 ]); // HP, ATK, DEF, SPATK, SPDEF, SPD + vi.spyOn(enemyPkm, "stats", "get").mockReturnValue([500000, 1, 1, 1, 1, 1]); // HP, ATK, DEF, SPATK, SPDEF, SPD vi.spyOn(enemyPkm, "getHeldItems").mockReturnValue([]); //no berries enemyPkm.hp = enemyPkm.getMaxHp(); @@ -62,7 +62,7 @@ describe("Moves - Rollout", () => { previousHp = enemyPkm.hp; } - const [ turn1Dmg, turn2Dmg, turn3Dmg, turn4Dmg, turn5Dmg, turn6Dmg ] = dmgHistory; + const [turn1Dmg, turn2Dmg, turn3Dmg, turn4Dmg, turn5Dmg, turn6Dmg] = dmgHistory; expect(turn2Dmg).toBeGreaterThanOrEqual(turn1Dmg * 2 - variance); expect(turn2Dmg).toBeLessThanOrEqual(turn1Dmg * 2 + variance); diff --git a/test/moves/roost.test.ts b/test/moves/roost.test.ts index 470313a27fb..a52b81085c8 100644 --- a/test/moves/roost.test.ts +++ b/test/moves/roost.test.ts @@ -9,7 +9,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Moves - Roost", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,7 +30,7 @@ describe("Moves - Roost", () => { game.override.startingLevel(100); game.override.enemyLevel(100); game.override.enemyMoveset(Moves.EARTHQUAKE); - game.override.moveset([ Moves.ROOST, Moves.BURN_UP, Moves.DOUBLE_SHOCK ]); + game.override.moveset([Moves.ROOST, Moves.BURN_UP, Moves.DOUBLE_SHOCK]); }); /** @@ -47,222 +46,199 @@ describe("Moves - Roost", () => { * 6. Non flying types using roost (such as dunsparce) are already grounded, so this move will only heal and have no other effects. */ - test( - "Non flying type uses roost -> no type change, took damage", - async () => { - await game.classicMode.startBattle([ Species.DUNSPARCE ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + test("Non flying type uses roost -> no type change, took damage", async () => { + await game.classicMode.startBattle([Species.DUNSPARCE]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - // Should only be normal type, and NOT flying type - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); + // Should only be normal type, and NOT flying type + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - // Lose HP, still normal type - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); - } - ); + // Lose HP, still normal type + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); + }); - test( - "Pure flying type -> becomes normal after roost and takes damage from ground moves -> regains flying", - async () => { - await game.classicMode.startBattle([ Species.TORNADUS ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + test("Pure flying type -> becomes normal after roost and takes damage from ground moves -> regains flying", async () => { + await game.classicMode.startBattle([Species.TORNADUS]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - // Should only be normal type, and NOT flying type - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeFalsy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); + // Should only be normal type, and NOT flying type + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeTruthy(); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeFalsy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to(TurnEndPhase); - // Should have lost HP and is now back to being pure flying - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeFalsy(); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); + // Should have lost HP and is now back to being pure flying + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.NORMAL).toBeFalsy(); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); - } - ); + test("Dual X/flying type -> becomes type X after roost and takes damage from ground moves -> regains flying", async () => { + await game.classicMode.startBattle([Species.HAWLUCHA]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - test( - "Dual X/flying type -> becomes type X after roost and takes damage from ground moves -> regains flying", - async () => { - await game.classicMode.startBattle([ Species.HAWLUCHA ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + // Should only be pure fighting type and grounded + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.FIGHTING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - // Should only be pure fighting type and grounded - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.FIGHTING).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); + await game.phaseInterceptor.to(TurnEndPhase); - await game.phaseInterceptor.to(TurnEndPhase); + // Should have lost HP and is now back to being fighting/flying + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.FIGHTING).toBeTruthy(); + expect(playerPokemonTypes[1] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); - // Should have lost HP and is now back to being fighting/flying - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.FIGHTING).toBeTruthy(); - expect(playerPokemonTypes[1] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); + test("Pokemon with levitate after using roost should lose flying type but still be unaffected by ground moves", async () => { + game.override.starterForms({ [Species.ROTOM]: 4 }); + await game.classicMode.startBattle([Species.ROTOM]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - } - ); + // Should only be pure eletric type and grounded + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.ELECTRIC).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); - test( - "Pokemon with levitate after using roost should lose flying type but still be unaffected by ground moves", - async () => { - game.override.starterForms({ [Species.ROTOM]: 4 }); - await game.classicMode.startBattle([ Species.ROTOM ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(TurnEndPhase); - // Should only be pure eletric type and grounded - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.ELECTRIC).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); + // Should have lost HP and is now back to being electric/flying + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBe(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.ELECTRIC).toBeTruthy(); + expect(playerPokemonTypes[1] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); - await game.phaseInterceptor.to(TurnEndPhase); + test("A fire/flying type that uses burn up, then roost should be typeless until end of turn", async () => { + await game.classicMode.startBattle([Species.MOLTRES]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.BURN_UP); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - // Should have lost HP and is now back to being electric/flying - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBe(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.ELECTRIC).toBeTruthy(); - expect(playerPokemonTypes[1] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); + // Should only be pure flying type after burn up + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - test( - "A fire/flying type that uses burn up, then roost should be typeless until end of turn", - async () => { - await game.classicMode.startBattle([ Species.MOLTRES ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.BURN_UP); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + // Should only be typeless type after roost and is grounded + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + expect(playerPokemonTypes[0] === PokemonType.UNKNOWN).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - // Should only be pure flying type after burn up - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); + await game.phaseInterceptor.to(TurnEndPhase); - await game.phaseInterceptor.to(TurnEndPhase); - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); - // Should only be typeless type after roost and is grounded - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); - expect(playerPokemonTypes[0] === PokemonType.UNKNOWN).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); + test("An electric/flying type that uses double shock, then roost should be typeless until end of turn", async () => { + game.override.enemySpecies(Species.ZEKROM); + await game.classicMode.startBattle([Species.ZAPDOS]); + const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemonStartingHP = playerPokemon.hp; + game.move.select(Moves.DOUBLE_SHOCK); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - await game.phaseInterceptor.to(TurnEndPhase); + // Should only be pure flying type after burn up + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); - // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); + await game.phaseInterceptor.to(TurnEndPhase); + game.move.select(Moves.ROOST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to(MoveEffectPhase); - } - ); + // Should only be typeless type after roost and is grounded + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + expect(playerPokemonTypes[0] === PokemonType.UNKNOWN).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - test( - "An electric/flying type that uses double shock, then roost should be typeless until end of turn", - async () => { - game.override.enemySpecies(Species.ZEKROM); - await game.classicMode.startBattle([ Species.ZAPDOS ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const playerPokemonStartingHP = playerPokemon.hp; - game.move.select(Moves.DOUBLE_SHOCK); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to(TurnEndPhase); - // Should only be pure flying type after burn up - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); + // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); - await game.phaseInterceptor.to(TurnEndPhase); - game.move.select(Moves.ROOST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to(MoveEffectPhase); + test("Dual Type Pokemon afflicted with Forests Curse/Trick or Treat and post roost will become dual type and then become 3 type at end of turn", async () => { + game.override.enemyMoveset([ + Moves.TRICK_OR_TREAT, + Moves.TRICK_OR_TREAT, + Moves.TRICK_OR_TREAT, + Moves.TRICK_OR_TREAT, + ]); + await game.classicMode.startBattle([Species.MOLTRES]); + const playerPokemon = game.scene.getPlayerPokemon()!; + game.move.select(Moves.ROOST); + await game.phaseInterceptor.to(MoveEffectPhase); - // Should only be typeless type after roost and is grounded - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); - expect(playerPokemonTypes[0] === PokemonType.UNKNOWN).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); + let playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes[0] === PokemonType.FIRE).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); - - // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); - expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); - - } - ); - - test( - "Dual Type Pokemon afflicted with Forests Curse/Trick or Treat and post roost will become dual type and then become 3 type at end of turn", - async () => { - game.override.enemyMoveset([ Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT, Moves.TRICK_OR_TREAT ]); - await game.classicMode.startBattle([ Species.MOLTRES ]); - const playerPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.ROOST); - await game.phaseInterceptor.to(MoveEffectPhase); - - let playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes[0] === PokemonType.FIRE).toBeTruthy(); - expect(playerPokemonTypes.length === 1).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeTruthy(); - - await game.phaseInterceptor.to(TurnEndPhase); - - // Should be fire/flying/ghost - playerPokemonTypes = playerPokemon.getTypes(); - expect(playerPokemonTypes.filter(type => type === PokemonType.FLYING)).toHaveLength(1); - expect(playerPokemonTypes.filter(type => type === PokemonType.FIRE)).toHaveLength(1); - expect(playerPokemonTypes.filter(type => type === PokemonType.GHOST)).toHaveLength(1); - expect(playerPokemonTypes.length === 3).toBeTruthy(); - expect(playerPokemon.isGrounded()).toBeFalsy(); - - } - ); + await game.phaseInterceptor.to(TurnEndPhase); + // Should be fire/flying/ghost + playerPokemonTypes = playerPokemon.getTypes(); + expect(playerPokemonTypes.filter(type => type === PokemonType.FLYING)).toHaveLength(1); + expect(playerPokemonTypes.filter(type => type === PokemonType.FIRE)).toHaveLength(1); + expect(playerPokemonTypes.filter(type => type === PokemonType.GHOST)).toHaveLength(1); + expect(playerPokemonTypes.length === 3).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }); }); diff --git a/test/moves/round.test.ts b/test/moves/round.test.ts index 01efa098f5a..82f080a25ea 100644 --- a/test/moves/round.test.ts +++ b/test/moves/round.test.ts @@ -25,19 +25,19 @@ describe("Moves - Round", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.ROUND ]) + .moveset([Moves.SPLASH, Moves.ROUND]) .ability(Abilities.BALL_FETCH) .battleType("double") .disableCrits() .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.ROUND ]) + .enemyMoveset([Moves.SPLASH, Moves.ROUND]) .startingLevel(100) .enemyLevel(100); }); it("should cue other instances of Round together in Speed order", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); const round = allMoves[Moves.ROUND]; const spy = vi.spyOn(round, "calculateBattlePower"); @@ -48,7 +48,7 @@ describe("Moves - Round", () => { await game.forceEnemyMove(Moves.ROUND, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); const actualTurnOrder: BattlerIndex[] = []; @@ -58,8 +58,13 @@ describe("Moves - Round", () => { await game.phaseInterceptor.to("MoveEndPhase"); } - expect(actualTurnOrder).toEqual([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + expect(actualTurnOrder).toEqual([ + BattlerIndex.PLAYER, + BattlerIndex.PLAYER_2, + BattlerIndex.ENEMY, + BattlerIndex.ENEMY_2, + ]); const powerResults = spy.mock.results.map(result => result.value); - expect(powerResults).toEqual( [ 60, 120, 120 ]); + expect(powerResults).toEqual([60, 120, 120]); }); }); diff --git a/test/moves/safeguard.test.ts b/test/moves/safeguard.test.ts index 9768b24f170..2235b59e1af 100644 --- a/test/moves/safeguard.test.ts +++ b/test/moves/safeguard.test.ts @@ -8,7 +8,6 @@ import { Species } from "#enums/species"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Safeguard", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,11 +27,11 @@ describe("Moves - Safeguard", () => { game.override .battleType("single") .enemySpecies(Species.DRATINI) - .enemyMoveset([ Moves.SAFEGUARD ]) + .enemyMoveset([Moves.SAFEGUARD]) .enemyAbility(Abilities.BALL_FETCH) .enemyLevel(5) .starterSpecies(Species.DRATINI) - .moveset([ Moves.NUZZLE, Moves.SPORE, Moves.YAWN, Moves.SPLASH ]) + .moveset([Moves.NUZZLE, Moves.SPORE, Moves.YAWN, Moves.SPLASH]) .ability(Abilities.UNNERVE); // Stop wild Pokemon from potentially eating Lum Berry }); @@ -41,7 +40,7 @@ describe("Moves - Safeguard", () => { const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.NUZZLE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemy.status).toBeUndefined(); @@ -52,19 +51,19 @@ describe("Moves - Safeguard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPORE); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyPokemon.status).toBeUndefined(); }); it("protects from confusion", async () => { - game.override.moveset([ Moves.CONFUSE_RAY ]); + game.override.moveset([Moves.CONFUSE_RAY]); await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.CONFUSE_RAY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyPokemon.summonData.tags).toEqual([]); @@ -78,7 +77,7 @@ describe("Moves - Safeguard", () => { game.move.select(Moves.SPORE, 0, BattlerIndex.ENEMY_2); game.move.select(Moves.NUZZLE, 1, BattlerIndex.ENEMY_2); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2]); await game.phaseInterceptor.to("BerryPhase"); @@ -93,7 +92,7 @@ describe("Moves - Safeguard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.YAWN); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); expect(enemyPokemon.summonData.tags).toEqual([]); @@ -104,7 +103,7 @@ describe("Moves - Safeguard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.YAWN); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); game.move.select(Moves.SPLASH); @@ -119,13 +118,13 @@ describe("Moves - Safeguard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); enemyPokemon.damageAndUpdate(1); expect(enemyPokemon.status?.effect).toEqual(StatusEffect.BURN); - game.override.enemyMoveset([ Moves.REST ]); + game.override.enemyMoveset([Moves.REST]); // Force the moveset to update mid-battle // TODO: Remove after enemy AI rework is in enemyPokemon.getMoveset(); @@ -138,14 +137,18 @@ describe("Moves - Safeguard", () => { it("protects from ability-inflicted status", async () => { game.override.ability(Abilities.STATIC); - vi.spyOn(allAbilities[Abilities.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0], "chance", "get").mockReturnValue(100); + vi.spyOn( + allAbilities[Abilities.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0], + "chance", + "get", + ).mockReturnValue(100); await game.classicMode.startBattle(); const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.toNextTurn(); - game.override.enemyMoveset([ Moves.TACKLE ]); + game.override.enemyMoveset([Moves.TACKLE]); game.move.select(Moves.SPLASH); await game.toNextTurn(); diff --git a/test/moves/scale_shot.test.ts b/test/moves/scale_shot.test.ts index 118b37795a1..2be632adb54 100644 --- a/test/moves/scale_shot.test.ts +++ b/test/moves/scale_shot.test.ts @@ -29,7 +29,7 @@ describe("Moves - Scale Shot", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SCALE_SHOT ]) + .moveset([Moves.SCALE_SHOT]) .battleType("single") .disableCrits() .ability(Abilities.NO_GUARD) @@ -41,11 +41,11 @@ describe("Moves - Scale Shot", () => { it("applies stat changes after last hit", async () => { game.override.enemySpecies(Species.FORRETRESS); - await game.classicMode.startBattle([ Species.MINCCINO ]); + await game.classicMode.startBattle([Species.MINCCINO]); const minccino = game.scene.getPlayerPokemon()!; game.move.select(Moves.SCALE_SHOT); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(DamageAnimPhase); @@ -69,7 +69,7 @@ describe("Moves - Scale Shot", () => { vi.spyOn(moveToCheck, "calculateBattlePower"); - await game.classicMode.startBattle([ Species.MINCCINO ]); + await game.classicMode.startBattle([Species.MINCCINO]); const minccino = game.scene.getPlayerPokemon()!; game.move.select(Moves.SCALE_SHOT); diff --git a/test/moves/secret_power.test.ts b/test/moves/secret_power.test.ts index 26fec5fabc3..28dc7efc434 100644 --- a/test/moves/secret_power.test.ts +++ b/test/moves/secret_power.test.ts @@ -30,7 +30,7 @@ describe("Moves - Secret Power", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SECRET_POWER ]) + .moveset([Moves.SECRET_POWER]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -40,13 +40,11 @@ describe("Moves - Secret Power", () => { }); it("Secret Power checks for an active terrain first then looks at the biome for its secondary effect", async () => { - game.override - .startingBiome(Biome.VOLCANO) - .enemyMoveset([ Moves.SPLASH, Moves.MISTY_TERRAIN ]); + game.override.startingBiome(Biome.VOLCANO).enemyMoveset([Moves.SPLASH, Moves.MISTY_TERRAIN]); vi.spyOn(allMoves[Moves.SECRET_POWER], "chance", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; // No Terrain + Biome.VOLCANO --> Burn game.move.select(Moves.SECRET_POWER); @@ -61,38 +59,36 @@ describe("Moves - Secret Power", () => { expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1); }); - it("Secret Power's effect chance is doubled by Serene Grace, but not by the 'rainbow' effect from Fire/Water Pledge", - async () => { - game.override - .moveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.SECRET_POWER, Moves.SPLASH ]) - .ability(Abilities.SERENE_GRACE) - .enemyMoveset([ Moves.SPLASH ]) - .battleType("double"); - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + it("Secret Power's effect chance is doubled by Serene Grace, but not by the 'rainbow' effect from Fire/Water Pledge", async () => { + game.override + .moveset([Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.SECRET_POWER, Moves.SPLASH]) + .ability(Abilities.SERENE_GRACE) + .enemyMoveset([Moves.SPLASH]) + .battleType("double"); + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const sereneGraceAttr = allAbilities[Abilities.SERENE_GRACE].getAttrs(MoveEffectChanceMultiplierAbAttr)[0]; - vi.spyOn(sereneGraceAttr, "apply"); + const sereneGraceAttr = allAbilities[Abilities.SERENE_GRACE].getAttrs(MoveEffectChanceMultiplierAbAttr)[0]; + vi.spyOn(sereneGraceAttr, "apply"); - game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); - game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("TurnEndPhase"); - let rainbowEffect = game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER); - expect(rainbowEffect).toBeDefined(); + let rainbowEffect = game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER); + expect(rainbowEffect).toBeDefined(); - rainbowEffect = rainbowEffect!; - vi.spyOn(rainbowEffect, "apply"); + rainbowEffect = rainbowEffect!; + vi.spyOn(rainbowEffect, "apply"); - game.move.select(Moves.SECRET_POWER, 0, BattlerIndex.ENEMY); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SECRET_POWER, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(sereneGraceAttr.apply).toHaveBeenCalledOnce(); - expect(sereneGraceAttr.apply).toHaveLastReturnedWith(true); + expect(sereneGraceAttr.apply).toHaveBeenCalledOnce(); + expect(sereneGraceAttr.apply).toHaveLastReturnedWith(true); - expect(rainbowEffect.apply).toHaveBeenCalledTimes(0); - } - ); + expect(rainbowEffect.apply).toHaveBeenCalledTimes(0); + }); }); diff --git a/test/moves/shed_tail.test.ts b/test/moves/shed_tail.test.ts index be746aacd78..6744c4e9ed8 100644 --- a/test/moves/shed_tail.test.ts +++ b/test/moves/shed_tail.test.ts @@ -24,7 +24,7 @@ describe("Moves - Shed Tail", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SHED_TAIL ]) + .moveset([Moves.SHED_TAIL]) .battleType("single") .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.BALL_FETCH) @@ -32,7 +32,7 @@ describe("Moves - Shed Tail", () => { }); it("transfers a Substitute doll to the switched in Pokemon", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.FEEBAS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.FEEBAS]); const magikarp = game.scene.getPlayerPokemon()!; @@ -53,7 +53,7 @@ describe("Moves - Shed Tail", () => { }); it("should fail if no ally is available to switch in", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const magikarp = game.scene.getPlayerPokemon()!; expect(game.scene.getPlayerParty().length).toBe(1); diff --git a/test/moves/shell_side_arm.test.ts b/test/moves/shell_side_arm.test.ts index c23bb316ba0..47da5e1c2f7 100644 --- a/test/moves/shell_side_arm.test.ts +++ b/test/moves/shell_side_arm.test.ts @@ -26,7 +26,7 @@ describe("Moves - Shell Side Arm", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SHELL_SIDE_ARM, Moves.SPLASH ]) + .moveset([Moves.SHELL_SIDE_ARM, Moves.SPLASH]) .battleType("single") .startingLevel(100) .enemyLevel(100) @@ -37,7 +37,7 @@ describe("Moves - Shell Side Arm", () => { it("becomes a physical attack if forecasted to deal more damage as physical", async () => { game.override.enemySpecies(Species.SNORLAX); - await game.classicMode.startBattle([ Species.RAMPARDOS ]); + await game.classicMode.startBattle([Species.RAMPARDOS]); vi.spyOn(shellSideArmAttr, "apply"); @@ -50,7 +50,7 @@ describe("Moves - Shell Side Arm", () => { it("remains a special attack if forecasted to deal more damage as special", async () => { game.override.enemySpecies(Species.SLOWBRO); - await game.classicMode.startBattle([ Species.XURKITREE ]); + await game.classicMode.startBattle([Species.XURKITREE]); vi.spyOn(shellSideArmAttr, "apply"); @@ -61,11 +61,9 @@ describe("Moves - Shell Side Arm", () => { }); it("respects stat stage changes when forecasting base damage", async () => { - game.override - .enemySpecies(Species.SNORLAX) - .enemyMoveset(Moves.COTTON_GUARD); + game.override.enemySpecies(Species.SNORLAX).enemyMoveset(Moves.COTTON_GUARD); - await game.classicMode.startBattle([ Species.MANAPHY ]); + await game.classicMode.startBattle([Species.MANAPHY]); vi.spyOn(shellSideArmAttr, "apply"); @@ -73,7 +71,7 @@ describe("Moves - Shell Side Arm", () => { await game.toNextTurn(); game.move.select(Moves.SHELL_SIDE_ARM); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(shellSideArmAttr.apply).toHaveLastReturnedWith(false); diff --git a/test/moves/shell_trap.test.ts b/test/moves/shell_trap.test.ts index 2e9d9ed69d6..2df94cdb828 100644 --- a/test/moves/shell_trap.test.ts +++ b/test/moves/shell_trap.test.ts @@ -10,7 +10,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Shell Trap", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,134 +28,119 @@ describe("Moves - Shell Trap", () => { game = new GameManager(phaserGame); game.override .battleType("double") - .moveset([ Moves.SHELL_TRAP, Moves.SPLASH, Moves.BULLDOZE ]) + .moveset([Moves.SHELL_TRAP, Moves.SPLASH, Moves.BULLDOZE]) .enemySpecies(Species.SNORLAX) - .enemyMoveset([ Moves.RAZOR_LEAF ]) + .enemyMoveset([Moves.RAZOR_LEAF]) .startingLevel(100) .enemyLevel(100); vi.spyOn(allMoves[Moves.RAZOR_LEAF], "accuracy", "get").mockReturnValue(100); }); - it( - "should activate after the user is hit by a physical attack", - async () => { - await game.startBattle([ Species.CHARIZARD, Species.TURTONATOR ]); + it("should activate after the user is hit by a physical attack", async () => { + await game.startBattle([Species.CHARIZARD, Species.TURTONATOR]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SPLASH); - game.move.select(Moves.SHELL_TRAP, 1); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); - const movePhase = game.scene.getCurrentPhase(); - expect(movePhase instanceof MovePhase).toBeTruthy(); - expect((movePhase as MovePhase).pokemon).toBe(playerPokemon[1]); + const movePhase = game.scene.getCurrentPhase(); + expect(movePhase instanceof MovePhase).toBeTruthy(); + expect((movePhase as MovePhase).pokemon).toBe(playerPokemon[1]); - await game.phaseInterceptor.to(MoveEndPhase); - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); - } - ); + await game.phaseInterceptor.to(MoveEndPhase); + enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); + }); - it( - "should fail if the user is only hit by special attacks", - async () => { - game.override.enemyMoveset([ Moves.SWIFT ]); + it("should fail if the user is only hit by special attacks", async () => { + game.override.enemyMoveset([Moves.SWIFT]); - await game.startBattle([ Species.CHARIZARD, Species.TURTONATOR ]); + await game.startBattle([Species.CHARIZARD, Species.TURTONATOR]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SPLASH); - game.move.select(Moves.SHELL_TRAP, 1); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); - const movePhase = game.scene.getCurrentPhase(); - expect(movePhase instanceof MovePhase).toBeTruthy(); - expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); + const movePhase = game.scene.getCurrentPhase(); + expect(movePhase instanceof MovePhase).toBeTruthy(); + expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); - await game.phaseInterceptor.to(BerryPhase, false); - enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - it( - "should fail if the user isn't hit with any attack", - async () => { - game.override.enemyMoveset(Moves.SPLASH); + it("should fail if the user isn't hit with any attack", async () => { + game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.CHARIZARD, Species.TURTONATOR ]); + await game.startBattle([Species.CHARIZARD, Species.TURTONATOR]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SPLASH); - game.move.select(Moves.SHELL_TRAP, 1); + game.move.select(Moves.SPLASH); + game.move.select(Moves.SHELL_TRAP, 1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); - const movePhase = game.scene.getCurrentPhase(); - expect(movePhase instanceof MovePhase).toBeTruthy(); - expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); + const movePhase = game.scene.getCurrentPhase(); + expect(movePhase instanceof MovePhase).toBeTruthy(); + expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); - await game.phaseInterceptor.to(BerryPhase, false); - enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - it( - "should not activate from an ally's attack", - async () => { - game.override.enemyMoveset(Moves.SPLASH); + it("should not activate from an ally's attack", async () => { + game.override.enemyMoveset(Moves.SPLASH); - await game.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const playerPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SHELL_TRAP); - game.move.select(Moves.BULLDOZE, 1); + game.move.select(Moves.SHELL_TRAP); + game.move.select(Moves.BULLDOZE, 1); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to(MoveEndPhase); - const movePhase = game.scene.getCurrentPhase(); - expect(movePhase instanceof MovePhase).toBeTruthy(); - expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); + const movePhase = game.scene.getCurrentPhase(); + expect(movePhase instanceof MovePhase).toBeTruthy(); + expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); - const enemyStartingHp = enemyPokemon.map(p => p.hp); + const enemyStartingHp = enemyPokemon.map(p => p.hp); - await game.phaseInterceptor.to(BerryPhase, false); - enemyPokemon.forEach((p, i) => expect(p.hp).toBe(enemyStartingHp[i])); - } - ); + await game.phaseInterceptor.to(BerryPhase, false); + enemyPokemon.forEach((p, i) => expect(p.hp).toBe(enemyStartingHp[i])); + }); - it( - "should not activate from a subsequent physical attack", - async () => { - game.override.battleType("single"); - vi.spyOn(allMoves[Moves.RAZOR_LEAF], "priority", "get").mockReturnValue(-4); + it("should not activate from a subsequent physical attack", async () => { + game.override.battleType("single"); + vi.spyOn(allMoves[Moves.RAZOR_LEAF], "priority", "get").mockReturnValue(-4); - await game.startBattle([ Species.CHARIZARD ]); + await game.startBattle([Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.SHELL_TRAP); + game.move.select(Moves.SHELL_TRAP); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); }); diff --git a/test/moves/simple_beam.test.ts b/test/moves/simple_beam.test.ts index 1fb8b54e8aa..ce86f42671e 100644 --- a/test/moves/simple_beam.test.ts +++ b/test/moves/simple_beam.test.ts @@ -22,7 +22,7 @@ describe("Moves - Simple Beam", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.SIMPLE_BEAM ]) + .moveset([Moves.SPLASH, Moves.SIMPLE_BEAM]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -32,7 +32,7 @@ describe("Moves - Simple Beam", () => { }); it("sets the target's ability to simple", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SIMPLE_BEAM); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/sketch.test.ts b/test/moves/sketch.test.ts index 0b63598ba9b..dfbf2eca713 100644 --- a/test/moves/sketch.test.ts +++ b/test/moves/sketch.test.ts @@ -35,10 +35,10 @@ describe("Moves - Sketch", () => { }); it("Sketch should not fail even if a previous Sketch failed to retrieve a valid move and ran out of PP", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon()!; // can't use normal moveset override because we need to check moveset changes - playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH) ]; + playerPokemon.moveset = [new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH)]; game.move.select(Moves.SKETCH); await game.phaseInterceptor.to("TurnEndPhase"); @@ -57,20 +57,20 @@ describe("Moves - Sketch", () => { it("Sketch should retrieve the most recent valid move from its target history", async () => { game.override.enemyStatusEffect(StatusEffect.PARALYSIS); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.GROWL) ]; + playerPokemon.moveset = [new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.GROWL)]; game.move.select(Moves.GROWL); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.move.forceStatusActivation(false); await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); await game.toNextTurn(); game.move.select(Moves.SKETCH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.move.forceStatusActivation(true); await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); @@ -82,14 +82,14 @@ describe("Moves - Sketch", () => { const randomMoveAttr = allMoves[Moves.METRONOME].findAttr(attr => attr instanceof RandomMoveAttr) as RandomMoveAttr; vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.FALSE_SWIPE); - game.override.enemyMoveset([ Moves.METRONOME ]); - await game.classicMode.startBattle([ Species.REGIELEKI ]); + game.override.enemyMoveset([Moves.METRONOME]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH) ]; + playerPokemon.moveset = [new PokemonMove(Moves.SKETCH)]; // Opponent uses Metronome -> False Swipe, then player uses Sketch, which should sketch Metronome game.move.select(Moves.SKETCH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(playerPokemon.moveset[0]?.moveId).toBe(Moves.METRONOME); diff --git a/test/moves/skill_swap.test.ts b/test/moves/skill_swap.test.ts index e39dac8bb01..f807a85eaf6 100644 --- a/test/moves/skill_swap.test.ts +++ b/test/moves/skill_swap.test.ts @@ -23,7 +23,7 @@ describe("Moves - Skill Swap", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.SKILL_SWAP ]) + .moveset([Moves.SPLASH, Moves.SKILL_SWAP]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -34,7 +34,7 @@ describe("Moves - Skill Swap", () => { it("should swap the two abilities", async () => { game.override.ability(Abilities.ADAPTABILITY); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SKILL_SWAP); await game.phaseInterceptor.to("BerryPhase"); @@ -45,7 +45,7 @@ describe("Moves - Skill Swap", () => { it("should activate post-summon abilities", async () => { game.override.ability(Abilities.INTIMIDATE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SKILL_SWAP); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/sleep_talk.test.ts b/test/moves/sleep_talk.test.ts index b9c98f4fb65..d31eff34a7a 100644 --- a/test/moves/sleep_talk.test.ts +++ b/test/moves/sleep_talk.test.ts @@ -25,7 +25,7 @@ describe("Moves - Sleep Talk", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH, Moves.SLEEP_TALK ]) + .moveset([Moves.SPLASH, Moves.SLEEP_TALK]) .statusEffect(StatusEffect.SLEEP) .ability(Abilities.BALL_FETCH) .battleType("single") @@ -38,7 +38,7 @@ describe("Moves - Sleep Talk", () => { it("should fail when the user is not asleep", async () => { game.override.statusEffect(StatusEffect.NONE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SLEEP_TALK); await game.toNextTurn(); @@ -46,8 +46,8 @@ describe("Moves - Sleep Talk", () => { }); it("should fail if the user has no valid moves", async () => { - game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.METRONOME, Moves.SOLAR_BEAM ]); - await game.classicMode.startBattle([ Species.FEEBAS ]); + game.override.moveset([Moves.SLEEP_TALK, Moves.DIG, Moves.METRONOME, Moves.SOLAR_BEAM]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SLEEP_TALK); await game.toNextTurn(); @@ -55,8 +55,8 @@ describe("Moves - Sleep Talk", () => { }); it("should call a random valid move if the user is asleep", async () => { - game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.SWORDS_DANCE ]); // Dig and Fly are invalid moves, Swords Dance should always be called - await game.classicMode.startBattle([ Species.FEEBAS ]); + game.override.moveset([Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.SWORDS_DANCE]); // Dig and Fly are invalid moves, Swords Dance should always be called + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.SLEEP_TALK); await game.toNextTurn(); @@ -64,7 +64,7 @@ describe("Moves - Sleep Talk", () => { }); it("should apply secondary effects of a move", async () => { - game.override.moveset([ Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.WOOD_HAMMER ]); // Dig and Fly are invalid moves, Wood Hammer should always be called + game.override.moveset([Moves.SLEEP_TALK, Moves.DIG, Moves.FLY, Moves.WOOD_HAMMER]); // Dig and Fly are invalid moves, Wood Hammer should always be called await game.classicMode.startBattle(); game.move.select(Moves.SLEEP_TALK); diff --git a/test/moves/solar_beam.test.ts b/test/moves/solar_beam.test.ts index c3025db57d0..dffd4f210e5 100644 --- a/test/moves/solar_beam.test.ts +++ b/test/moves/solar_beam.test.ts @@ -36,7 +36,7 @@ describe("Moves - Solar Beam", () => { }); it("should deal damage in two turns if no weather is active", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -60,11 +60,11 @@ describe("Moves - Solar Beam", () => { it.each([ { weatherType: WeatherType.SUNNY, name: "Sun" }, - { weatherType: WeatherType.HARSH_SUN, name: "Harsh Sun" } + { weatherType: WeatherType.HARSH_SUN, name: "Harsh Sun" }, ])("should deal damage in one turn if $name is active", async ({ weatherType }) => { game.override.weather(weatherType); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -83,11 +83,11 @@ describe("Moves - Solar Beam", () => { it.each([ { weatherType: WeatherType.RAIN, name: "Rain" }, - { weatherType: WeatherType.HEAVY_RAIN, name: "Heavy Rain" } + { weatherType: WeatherType.HEAVY_RAIN, name: "Heavy Rain" }, ])("should have its power halved in $name", async ({ weatherType }) => { game.override.weather(weatherType); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const solarBeam = allMoves[Moves.SOLAR_BEAM]; diff --git a/test/moves/sparkly_swirl.test.ts b/test/moves/sparkly_swirl.test.ts index f865c00271f..6cd357c7e0e 100644 --- a/test/moves/sparkly_swirl.test.ts +++ b/test/moves/sparkly_swirl.test.ts @@ -27,18 +27,16 @@ describe("Moves - Sparkly Swirl", () => { .enemyLevel(100) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.SPARKLY_SWIRL, Moves.SPLASH ]) + .moveset([Moves.SPARKLY_SWIRL, Moves.SPLASH]) .ability(Abilities.BALL_FETCH); vi.spyOn(allMoves[Moves.SPARKLY_SWIRL], "accuracy", "get").mockReturnValue(100); }); it("should cure status effect of the user, its ally, and all party pokemon", async () => { - game.override - .battleType("double") - .statusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA, Species.RATTATA ]); - const [ leftPlayer, rightPlayer, partyPokemon ] = game.scene.getPlayerParty(); + game.override.battleType("double").statusEffect(StatusEffect.BURN); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA, Species.RATTATA]); + const [leftPlayer, rightPlayer, partyPokemon] = game.scene.getPlayerParty(); const leftOpp = game.scene.getEnemyPokemon()!; vi.spyOn(leftPlayer, "resetStatus"); @@ -60,11 +58,9 @@ describe("Moves - Sparkly Swirl", () => { }); it("should not cure status effect of the target/target's allies", async () => { - game.override - .battleType("double") - .enemyStatusEffect(StatusEffect.BURN); - await game.classicMode.startBattle([ Species.RATTATA, Species.RATTATA ]); - const [ leftOpp, rightOpp ] = game.scene.getEnemyField(); + game.override.battleType("double").enemyStatusEffect(StatusEffect.BURN); + await game.classicMode.startBattle([Species.RATTATA, Species.RATTATA]); + const [leftOpp, rightOpp] = game.scene.getEnemyField(); vi.spyOn(leftOpp, "resetStatus"); vi.spyOn(rightOpp, "resetStatus"); diff --git a/test/moves/spectral_thief.test.ts b/test/moves/spectral_thief.test.ts index d7524586d66..2e52b118a74 100644 --- a/test/moves/spectral_thief.test.ts +++ b/test/moves/spectral_thief.test.ts @@ -28,9 +28,8 @@ describe("Moves - Spectral Thief", () => { .enemyLevel(100) .enemyMoveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .moveset([ Moves.SPECTRAL_THIEF, Moves.SPLASH ]) - .ability(Abilities.BALL_FETCH) - .disableCrits; + .moveset([Moves.SPECTRAL_THIEF, Moves.SPLASH]) + .ability(Abilities.BALL_FETCH).disableCrits; }); it("should steal max possible positive stat changes and ignore negative ones.", async () => { @@ -61,14 +60,12 @@ describe("Moves - Spectral Thief", () => { * enemy has -6 SPDEF and player 0 => player should not steal * enemy has +3 SPD and player -2 => player only steals +3 */ - expect(player.getStatStages()).toEqual([ 6, 1, 6, 0, 1, 0, 0 ]); - expect(enemy.getStatStages()).toEqual([ 4, -6, 0, -6, 0, 0, 0 ]); + expect(player.getStatStages()).toEqual([6, 1, 6, 0, 1, 0, 0]); + expect(enemy.getStatStages()).toEqual([4, -6, 0, -6, 0, 0, 0]); }); it("should steal stat stages before dmg calculation", async () => { - game.override - .enemySpecies(Species.MAGIKARP) - .enemyLevel(50); + game.override.enemySpecies(Species.MAGIKARP).enemyLevel(50); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -87,8 +84,7 @@ describe("Moves - Spectral Thief", () => { }); it("should steal stat stages as a negative value with Contrary.", async () => { - game.override - .ability(Abilities.CONTRARY); + game.override.ability(Abilities.CONTRARY); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -106,8 +102,7 @@ describe("Moves - Spectral Thief", () => { }); it("should steal double the stat stages with Simple.", async () => { - game.override - .ability(Abilities.SIMPLE); + game.override.ability(Abilities.SIMPLE); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -125,8 +120,7 @@ describe("Moves - Spectral Thief", () => { }); it("should steal the stat stages through Clear Body.", async () => { - game.override - .enemyAbility(Abilities.CLEAR_BODY); + game.override.enemyAbility(Abilities.CLEAR_BODY); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -144,8 +138,7 @@ describe("Moves - Spectral Thief", () => { }); it("should steal the stat stages through White Smoke.", async () => { - game.override - .enemyAbility(Abilities.WHITE_SMOKE); + game.override.enemyAbility(Abilities.WHITE_SMOKE); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -163,8 +156,7 @@ describe("Moves - Spectral Thief", () => { }); it("should steal the stat stages through Hyper Cutter.", async () => { - game.override - .enemyAbility(Abilities.HYPER_CUTTER); + game.override.enemyAbility(Abilities.HYPER_CUTTER); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -182,8 +174,7 @@ describe("Moves - Spectral Thief", () => { }); it("should bypass Substitute.", async () => { - game.override - .enemyMoveset(Moves.SUBSTITUTE); + game.override.enemyMoveset(Moves.SUBSTITUTE); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; @@ -194,7 +185,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(Moves.SPECTRAL_THIEF); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to(TurnEndPhase); expect(player.getStatStage(Stat.ATK)).toEqual(3); @@ -203,8 +194,7 @@ describe("Moves - Spectral Thief", () => { }); it("should get blocked by protect.", async () => { - game.override - .enemyMoveset(Moves.PROTECT); + game.override.enemyMoveset(Moves.PROTECT); await game.classicMode.startBattle(); const player = game.scene.getPlayerPokemon()!; diff --git a/test/moves/speed_swap.test.ts b/test/moves/speed_swap.test.ts index 5cdea223296..a1385ce5386 100644 --- a/test/moves/speed_swap.test.ts +++ b/test/moves/speed_swap.test.ts @@ -29,14 +29,12 @@ describe("Moves - Speed Swap", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.MEW) .enemyLevel(200) - .moveset([ Moves.SPEED_SWAP ]) + .moveset([Moves.SPEED_SWAP]) .ability(Abilities.NONE); }); it("should swap the user's SPD and the target's SPD stats", async () => { - await game.startBattle([ - Species.INDEEDEE - ]); + await game.startBattle([Species.INDEEDEE]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; diff --git a/test/moves/spikes.test.ts b/test/moves/spikes.test.ts index 11ef295a62f..9bf0e5e1437 100644 --- a/test/moves/spikes.test.ts +++ b/test/moves/spikes.test.ts @@ -5,7 +5,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Spikes", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,11 +27,11 @@ describe("Moves - Spikes", () => { .enemyAbility(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.SPIKES, Moves.SPLASH, Moves.ROAR ]); + .moveset([Moves.SPIKES, Moves.SPLASH, Moves.ROAR]); }); it("should not damage the team that set them", async () => { - await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); game.move.select(Moves.SPIKES); await game.toNextTurn(); @@ -52,7 +51,7 @@ describe("Moves - Spikes", () => { it("should damage opposing pokemon that are forced to switch in", async () => { game.override.startingWave(5); - await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); game.move.select(Moves.SPIKES); await game.toNextTurn(); @@ -66,7 +65,7 @@ describe("Moves - Spikes", () => { it("should damage opposing pokemon that choose to switch in", async () => { game.override.startingWave(5); - await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.startBattle([Species.MIGHTYENA, Species.POOCHYENA]); game.move.select(Moves.SPIKES); await game.toNextTurn(); @@ -78,5 +77,4 @@ describe("Moves - Spikes", () => { const enemy = game.scene.getEnemyParty()[0]; expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); }, 20000); - }); diff --git a/test/moves/spit_up.test.ts b/test/moves/spit_up.test.ts index 59dca04fe26..d986ae4d141 100644 --- a/test/moves/spit_up.test.ts +++ b/test/moves/spit_up.test.ts @@ -48,7 +48,7 @@ describe("Moves - Spit Up", () => { const stacksToSetup = 1; const expectedPower = 100; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -70,7 +70,7 @@ describe("Moves - Spit Up", () => { const stacksToSetup = 2; const expectedPower = 200; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -93,7 +93,7 @@ describe("Moves - Spit Up", () => { const stacksToSetup = 3; const expectedPower = 300; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -115,7 +115,7 @@ describe("Moves - Spit Up", () => { }); it("fails without stacks", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; @@ -125,14 +125,18 @@ describe("Moves - Spit Up", () => { game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.FAIL, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SPIT_UP, + result: MoveResult.FAIL, + targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()], + }); expect(spitUp.calculateBattlePower).not.toHaveBeenCalled(); }); describe("restores stat boosts granted by stacks", () => { it("decreases stats based on stored values (both boosts equal)", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -148,7 +152,11 @@ describe("Moves - Spit Up", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SPIT_UP, + result: MoveResult.SUCCESS, + targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()], + }); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); @@ -159,7 +167,7 @@ describe("Moves - Spit Up", () => { }); it("decreases stats based on stored values (different boosts)", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -176,7 +184,11 @@ describe("Moves - Spit Up", () => { game.move.select(Moves.SPIT_UP); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SPIT_UP, result: MoveResult.SUCCESS, targets: [ game.scene.getEnemyPokemon()!.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SPIT_UP, + result: MoveResult.SUCCESS, + targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()], + }); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); diff --git a/test/moves/spotlight.test.ts b/test/moves/spotlight.test.ts index 2a883d403a7..91705dbb2fa 100644 --- a/test/moves/spotlight.test.ts +++ b/test/moves/spotlight.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; - describe("Moves - Spotlight", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,47 +27,41 @@ describe("Moves - Spotlight", () => { game.override.enemySpecies(Species.SNORLAX); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]); - game.override.enemyMoveset([ Moves.FOLLOW_ME, Moves.SPLASH ]); + game.override.moveset([Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK]); + game.override.enemyMoveset([Moves.FOLLOW_ME, Moves.SPLASH]); }); - test( - "move should redirect attacks to the target", - async () => { - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + test("move should redirect attacks to the target", async () => { + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.SPLASH); - await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to(TurnEndPhase, false); - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); - } - ); + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); + }); - test( - "move should cause other redirection moves to fail", - async () => { - await game.classicMode.startBattle([ Species.AMOONGUSS, Species.CHARIZARD ]); + test("move should cause other redirection moves to fail", async () => { + await game.classicMode.startBattle([Species.AMOONGUSS, Species.CHARIZARD]); - const enemyPokemon = game.scene.getEnemyField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY); - game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); + game.move.select(Moves.SPOTLIGHT, 0, BattlerIndex.ENEMY); + game.move.select(Moves.QUICK_ATTACK, 1, BattlerIndex.ENEMY_2); - await game.forceEnemyMove(Moves.SPLASH); - await game.forceEnemyMove(Moves.FOLLOW_ME); + await game.forceEnemyMove(Moves.SPLASH); + await game.forceEnemyMove(Moves.FOLLOW_ME); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); - expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); - } - ); + expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); + expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); + }); }); diff --git a/test/moves/steamroller.test.ts b/test/moves/steamroller.test.ts index e83b67e9d9c..ba96928e01d 100644 --- a/test/moves/steamroller.test.ts +++ b/test/moves/steamroller.test.ts @@ -25,12 +25,12 @@ describe("Moves - Steamroller", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override.moveset([ Moves.STEAMROLLER ]).battleType("single").enemyAbility(Abilities.BALL_FETCH); + game.override.moveset([Moves.STEAMROLLER]).battleType("single").enemyAbility(Abilities.BALL_FETCH); }); it("should always hit a minimzed target with double damage", async () => { game.override.enemySpecies(Species.DITTO).enemyMoveset(Moves.MINIMIZE); - await game.classicMode.startBattle([ Species.IRON_BOULDER ]); + await game.classicMode.startBattle([Species.IRON_BOULDER]); const ditto = game.scene.getEnemyPokemon()!; vi.spyOn(ditto, "getAttackDamage"); @@ -41,15 +41,15 @@ describe("Moves - Steamroller", () => { vi.spyOn(ironBoulder, "getAccuracyMultiplier"); // Turn 1 game.move.select(Moves.STEAMROLLER); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.toNextTurn(); // Turn 2 game.move.select(Moves.STEAMROLLER); await game.toNextTurn(); - const [ dmgCalcTurn1, dmgCalcTurn2 ]: DamageCalculationResult[] = vi + const [dmgCalcTurn1, dmgCalcTurn2]: DamageCalculationResult[] = vi .mocked(ditto.getAttackDamage) - .mock.results.map((r) => r.value); + .mock.results.map(r => r.value); expect(dmgCalcTurn2.damage).toBeGreaterThanOrEqual(dmgCalcTurn1.damage * 2); expect(ditto.getTag(BattlerTagType.MINIMIZED)).toBeDefined(); diff --git a/test/moves/stockpile.test.ts b/test/moves/stockpile.test.ts index 0d0a1de4840..033f24d5229 100644 --- a/test/moves/stockpile.test.ts +++ b/test/moves/stockpile.test.ts @@ -34,12 +34,12 @@ describe("Moves - Stockpile", () => { game.override.enemyAbility(Abilities.NONE); game.override.startingLevel(2000); - game.override.moveset([ Moves.STOCKPILE, Moves.SPLASH ]); + game.override.moveset([Moves.STOCKPILE, Moves.SPLASH]); game.override.ability(Abilities.NONE); }); it("gains a stockpile stack and raises user's DEF and SPDEF stat stages by 1 on each use, fails at max stacks (3)", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const user = game.scene.getPlayerPokemon()!; @@ -61,24 +61,29 @@ describe("Moves - Stockpile", () => { const stockpilingTag = user.getTag(StockpilingTag)!; - if (i < 3) { // first three uses should behave normally + if (i < 3) { + // first three uses should behave normally expect(user.getStatStage(Stat.DEF)).toBe(i + 1); expect(user.getStatStage(Stat.SPDEF)).toBe(i + 1); expect(stockpilingTag).toBeDefined(); expect(stockpilingTag.stockpiledCount).toBe(i + 1); - - } else { // fourth should have failed + } else { + // fourth should have failed expect(user.getStatStage(Stat.DEF)).toBe(3); expect(user.getStatStage(Stat.SPDEF)).toBe(3); expect(stockpilingTag).toBeDefined(); expect(stockpilingTag.stockpiledCount).toBe(3); - expect(user.getMoveHistory().at(-1)).toMatchObject({ result: MoveResult.FAIL, move: Moves.STOCKPILE, targets: [ user.getBattlerIndex() ]}); + expect(user.getMoveHistory().at(-1)).toMatchObject({ + result: MoveResult.FAIL, + move: Moves.STOCKPILE, + targets: [user.getBattlerIndex()], + }); } } }); it("gains a stockpile stack even if user's DEF and SPDEF stat stages are at +6", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const user = game.scene.getPlayerPokemon()!; diff --git a/test/moves/substitute.test.ts b/test/moves/substitute.test.ts index ce5fbdd99d8..23f7f4af4b9 100644 --- a/test/moves/substitute.test.ts +++ b/test/moves/substitute.test.ts @@ -18,7 +18,6 @@ import { StatusEffect } from "#enums/status-effect"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - describe("Moves - Substitute", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -38,7 +37,7 @@ describe("Moves - Substitute", () => { game.override .battleType("single") - .moveset([ Moves.SUBSTITUTE, Moves.SWORDS_DANCE, Moves.TACKLE, Moves.SPLASH ]) + .moveset([Moves.SUBSTITUTE, Moves.SWORDS_DANCE, Moves.TACKLE, Moves.SPLASH]) .enemySpecies(Species.SNORLAX) .enemyAbility(Abilities.INSOMNIA) .enemyMoveset(Moves.SPLASH) @@ -46,557 +45,477 @@ describe("Moves - Substitute", () => { .enemyLevel(100); }); - it( - "should cause the user to take damage", - async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + it("should cause the user to take damage", async () => { + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(leadPokemon.hp).toBe(Math.ceil(leadPokemon.getMaxHp() * 3 / 4)); - } - ); + expect(leadPokemon.hp).toBe(Math.ceil((leadPokemon.getMaxHp() * 3) / 4)); + }); - it( - "should redirect enemy attack damage to the Substitute doll", - async () => { - game.override.enemyMoveset(Moves.TACKLE); + it("should redirect enemy attack damage to the Substitute doll", async () => { + game.override.enemyMoveset(Moves.TACKLE); - await game.classicMode.startBattle([ Species.SKARMORY ]); + await game.classicMode.startBattle([Species.SKARMORY]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(leadPokemon.hp).toBe(Math.ceil(leadPokemon.getMaxHp() * 3 / 4)); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - const postSubHp = leadPokemon.hp; + expect(leadPokemon.hp).toBe(Math.ceil((leadPokemon.getMaxHp() * 3) / 4)); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + const postSubHp = leadPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(postSubHp); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - } - ); + expect(leadPokemon.hp).toBe(postSubHp); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + }); - it( - "should fade after redirecting more damage than its remaining HP", - async () => { - // Giga Impact OHKOs Magikarp if substitute isn't up - game.override.enemyMoveset(Moves.GIGA_IMPACT); - vi.spyOn(allMoves[Moves.GIGA_IMPACT], "accuracy", "get").mockReturnValue(100); + it("should fade after redirecting more damage than its remaining HP", async () => { + // Giga Impact OHKOs Magikarp if substitute isn't up + game.override.enemyMoveset(Moves.GIGA_IMPACT); + vi.spyOn(allMoves[Moves.GIGA_IMPACT], "accuracy", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(leadPokemon.hp).toBe(Math.ceil(leadPokemon.getMaxHp() * 3 / 4)); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - const postSubHp = leadPokemon.hp; + expect(leadPokemon.hp).toBe(Math.ceil((leadPokemon.getMaxHp() * 3) / 4)); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + const postSubHp = leadPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.hp).toBe(postSubHp); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined(); - } - ); + expect(leadPokemon.hp).toBe(postSubHp); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined(); + }); - it( - "should block stat changes from status moves", - async () => { - game.override.enemyMoveset(Moves.CHARM); + it("should block stat changes from status moves", async () => { + game.override.enemyMoveset(Moves.CHARM); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - } - ); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + }); - it( - "should be bypassed by sound-based moves", - async () => { - game.override.enemyMoveset(Moves.ECHOED_VOICE); + it("should be bypassed by sound-based moves", async () => { + game.override.enemyMoveset(Moves.ECHOED_VOICE); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase"); + await game.phaseInterceptor.to("MoveEndPhase"); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - const postSubHp = leadPokemon.hp; + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + const postSubHp = leadPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - expect(leadPokemon.hp).toBeLessThan(postSubHp); - } - ); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + expect(leadPokemon.hp).toBeLessThan(postSubHp); + }); - it( - "should be bypassed by attackers with Infiltrator", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.enemyAbility(Abilities.INFILTRATOR); + it("should be bypassed by attackers with Infiltrator", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.enemyAbility(Abilities.INFILTRATOR); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase"); + await game.phaseInterceptor.to("MoveEndPhase"); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - const postSubHp = leadPokemon.hp; + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + const postSubHp = leadPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); - expect(leadPokemon.hp).toBeLessThan(postSubHp); - } - ); + expect(leadPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeDefined(); + expect(leadPokemon.hp).toBeLessThan(postSubHp); + }); - it( - "shouldn't block the user's own status moves", - async () => { - await game.classicMode.startBattle([ Species.BLASTOISE ]); + it("shouldn't block the user's own status moves", async () => { + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("MoveEndPhase"); - await game.toNextTurn(); + await game.phaseInterceptor.to("MoveEndPhase"); + await game.toNextTurn(); - game.move.select(Moves.SWORDS_DANCE); + game.move.select(Moves.SWORDS_DANCE); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); - } - ); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); + }); - it( - "shouldn't block moves that target the user's side of the field", - async () => { - game.override.moveset(Moves.LIGHT_SCREEN); + it("shouldn't block moves that target the user's side of the field", async () => { + game.override.moveset(Moves.LIGHT_SCREEN); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(leadPokemon, "getMoveEffectiveness"); + const leadPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(leadPokemon, "getMoveEffectiveness"); - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.LIGHT_SCREEN); + game.move.select(Moves.LIGHT_SCREEN); - await game.toNextTurn(); + await game.toNextTurn(); - expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0); - expect(game.scene.arena.getTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER)).toBeDefined(); - } - ); + expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0); + expect(game.scene.arena.getTagOnSide(ArenaTagType.LIGHT_SCREEN, ArenaTagSide.PLAYER)).toBeDefined(); + }); - it( - "shouldn't block the opponent from setting hazards", - async () => { - game.override.enemyMoveset(Moves.STEALTH_ROCK); + it("shouldn't block the opponent from setting hazards", async () => { + game.override.enemyMoveset(Moves.STEALTH_ROCK); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - vi.spyOn(leadPokemon, "getMoveEffectiveness"); + const leadPokemon = game.scene.getPlayerPokemon()!; + vi.spyOn(leadPokemon, "getMoveEffectiveness"); - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.toNextTurn(); + await game.toNextTurn(); - expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0); - expect(game.scene.arena.getTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER)).toBeDefined(); - } - ); + expect(leadPokemon.getMoveEffectiveness).not.toHaveReturnedWith(0); + expect(game.scene.arena.getTagOnSide(ArenaTagType.STEALTH_ROCK, ArenaTagSide.PLAYER)).toBeDefined(); + }); - it( - "shouldn't block moves that target both sides of the field", - async () => { - game.override - .moveset(Moves.TRICK_ROOM) - .enemyMoveset(Moves.GRAVITY); + it("shouldn't block moves that target both sides of the field", async () => { + game.override.moveset(Moves.TRICK_ROOM).enemyMoveset(Moves.GRAVITY); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const pokemon = game.scene.getField(true); - pokemon.forEach(p => { - vi.spyOn(p, "getMoveEffectiveness"); - p.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, p.id); - }); + const pokemon = game.scene.getField(true); + pokemon.forEach(p => { + vi.spyOn(p, "getMoveEffectiveness"); + p.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, p.id); + }); - game.move.select(Moves.TRICK_ROOM); + game.move.select(Moves.TRICK_ROOM); - await game.toNextTurn(); + await game.toNextTurn(); - pokemon.forEach(p => expect(p.getMoveEffectiveness).not.toHaveReturnedWith(0)); - expect(game.scene.arena.getTag(ArenaTagType.TRICK_ROOM)).toBeDefined(); - expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); - } - ); + pokemon.forEach(p => expect(p.getMoveEffectiveness).not.toHaveReturnedWith(0)); + expect(game.scene.arena.getTag(ArenaTagType.TRICK_ROOM)).toBeDefined(); + expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); + }); - it( - "should protect the user from flinching", - async () => { - game.override.enemyMoveset(Moves.FAKE_OUT); - game.override.startingLevel(1); // Ensures the Substitute will break + it("should protect the user from flinching", async () => { + game.override.enemyMoveset(Moves.FAKE_OUT); + game.override.startingLevel(1); // Ensures the Substitute will break - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); - it( - "should protect the user from being trapped", - async () => { - vi.spyOn(allMoves[Moves.SAND_TOMB], "accuracy", "get").mockReturnValue(100); - game.override.enemyMoveset(Moves.SAND_TOMB); + it("should protect the user from being trapped", async () => { + vi.spyOn(allMoves[Moves.SAND_TOMB], "accuracy", "get").mockReturnValue(100); + game.override.enemyMoveset(Moves.SAND_TOMB); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getTag(TrappedTag)).toBeUndefined(); - } - ); + expect(leadPokemon.getTag(TrappedTag)).toBeUndefined(); + }); - it( - "should prevent the user's stats from being lowered", - async () => { - vi.spyOn(allMoves[Moves.LIQUIDATION], "chance", "get").mockReturnValue(100); - game.override.enemyMoveset(Moves.LIQUIDATION); + it("should prevent the user's stats from being lowered", async () => { + vi.spyOn(allMoves[Moves.LIQUIDATION], "chance", "get").mockReturnValue(100); + game.override.enemyMoveset(Moves.LIQUIDATION); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getStatStage(Stat.DEF)).toBe(0); - } - ); + expect(leadPokemon.getStatStage(Stat.DEF)).toBe(0); + }); - it( - "should protect the user from being afflicted with status effects", - async () => { - game.override.enemyMoveset(Moves.NUZZLE); + it("should protect the user from being afflicted with status effects", async () => { + game.override.enemyMoveset(Moves.NUZZLE); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.status?.effect).not.toBe(StatusEffect.PARALYSIS); - } - ); + expect(leadPokemon.status?.effect).not.toBe(StatusEffect.PARALYSIS); + }); - it( - "should prevent the user's items from being stolen", - async () => { - game.override.enemyMoveset(Moves.THIEF); - vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([ new StealHeldItemChanceAttr(1.0) ]); // give Thief 100% steal rate - game.override.startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); + it("should prevent the user's items from being stolen", async () => { + game.override.enemyMoveset(Moves.THIEF); + vi.spyOn(allMoves[Moves.THIEF], "attrs", "get").mockReturnValue([new StealHeldItemChanceAttr(1.0)]); // give Thief 100% steal rate + game.override.startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getHeldItems().length).toBe(1); - } - ); + expect(leadPokemon.getHeldItems().length).toBe(1); + }); - it( - "should prevent the user's items from being removed", - async () => { - game.override.moveset([ Moves.KNOCK_OFF ]); - game.override.enemyHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); + it("should prevent the user's items from being removed", async () => { + game.override.moveset([Moves.KNOCK_OFF]); + game.override.enemyHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id); - const enemyNumItems = enemyPokemon.getHeldItems().length; + enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id); + const enemyNumItems = enemyPokemon.getHeldItems().length; - game.move.select(Moves.KNOCK_OFF); + game.move.select(Moves.KNOCK_OFF); - await game.phaseInterceptor.to("MoveEndPhase", false); + await game.phaseInterceptor.to("MoveEndPhase", false); - expect(enemyPokemon.getHeldItems().length).toBe(enemyNumItems); - } - ); + expect(enemyPokemon.getHeldItems().length).toBe(enemyNumItems); + }); - it( - "move effect should prevent the user's berries from being stolen and eaten", - async () => { - game.override.enemyMoveset(Moves.BUG_BITE); - game.override.startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); + it("move effect should prevent the user's berries from being stolen and eaten", async () => { + game.override.enemyMoveset(Moves.BUG_BITE); + game.override.startingHeldItems([{ name: "BERRY", type: BerryType.SITRUS }]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.TACKLE); + game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("MoveEndPhase", false); - const enemyPostAttackHp = enemyPokemon.hp; + await game.phaseInterceptor.to("MoveEndPhase", false); + const enemyPostAttackHp = enemyPokemon.hp; - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getHeldItems().length).toBe(1); - expect(enemyPokemon.hp).toBe(enemyPostAttackHp); - } - ); + expect(leadPokemon.getHeldItems().length).toBe(1); + expect(enemyPokemon.hp).toBe(enemyPostAttackHp); + }); - it( - "should prevent the user's stats from being reset by Clear Smog", - async () => { - game.override.enemyMoveset(Moves.CLEAR_SMOG); + it("should prevent the user's stats from being reset by Clear Smog", async () => { + game.override.enemyMoveset(Moves.CLEAR_SMOG); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SWORDS_DANCE); + game.move.select(Moves.SWORDS_DANCE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); - } - ); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); + }); - it( - "should prevent the user from becoming confused", - async () => { - game.override.enemyMoveset(Moves.MAGICAL_TORQUE); - vi.spyOn(allMoves[Moves.MAGICAL_TORQUE], "chance", "get").mockReturnValue(100); + it("should prevent the user from becoming confused", async () => { + game.override.enemyMoveset(Moves.MAGICAL_TORQUE); + vi.spyOn(allMoves[Moves.MAGICAL_TORQUE], "chance", "get").mockReturnValue(100); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.move.select(Moves.SWORDS_DANCE); + game.move.select(Moves.SWORDS_DANCE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(leadPokemon.getTag(BattlerTagType.CONFUSED)).toBeUndefined(); - expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); - } - ); + expect(leadPokemon.getTag(BattlerTagType.CONFUSED)).toBeUndefined(); + expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); + }); - it( - "should transfer to the switched in Pokemon when the source uses Baton Pass", - async () => { - game.override.moveset([ Moves.SUBSTITUTE, Moves.BATON_PASS ]); + it("should transfer to the switched in Pokemon when the source uses Baton Pass", async () => { + game.override.moveset([Moves.SUBSTITUTE, Moves.BATON_PASS]); - await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.BLASTOISE, Species.CHARIZARD]); - const leadPokemon = game.scene.getPlayerPokemon()!; + const leadPokemon = game.scene.getPlayerPokemon()!; - leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); + leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - // Simulate a Baton switch for the player this turn - game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { - (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, 1, true); - }); + // Simulate a Baton switch for the player this turn + game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, 1, true); + }); - await game.phaseInterceptor.to("MovePhase", false); + await game.phaseInterceptor.to("MovePhase", false); - const switchedPokemon = game.scene.getPlayerPokemon()!; - const subTag = switchedPokemon.getTag(SubstituteTag)!; - expect(subTag).toBeDefined(); - expect(subTag.hp).toBe(Math.floor(leadPokemon.getMaxHp() * 1 / 4)); - } - ); + const switchedPokemon = game.scene.getPlayerPokemon()!; + const subTag = switchedPokemon.getTag(SubstituteTag)!; + expect(subTag).toBeDefined(); + expect(subTag.hp).toBe(Math.floor((leadPokemon.getMaxHp() * 1) / 4)); + }); - it( - "should prevent the source's Rough Skin from activating when hit", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.ability(Abilities.ROUGH_SKIN); + it("should prevent the source's Rough Skin from activating when hit", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.ability(Abilities.ROUGH_SKIN); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.SUBSTITUTE); + game.move.select(Moves.SUBSTITUTE); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should prevent the source's Focus Punch from failing when hit", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.moveset([ Moves.FOCUS_PUNCH ]); + it("should prevent the source's Focus Punch from failing when hit", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.moveset([Moves.FOCUS_PUNCH]); - // Make Focus Punch 40 power to avoid a KO - vi.spyOn(allMoves[Moves.FOCUS_PUNCH], "calculateBattlePower").mockReturnValue(40); + // Make Focus Punch 40 power to avoid a KO + vi.spyOn(allMoves[Moves.FOCUS_PUNCH], "calculateBattlePower").mockReturnValue(40); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); + playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); - game.move.select(Moves.FOCUS_PUNCH); + game.move.select(Moves.FOCUS_PUNCH); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); - it( - "should not allow Shell Trap to activate when attacked", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.moveset([ Moves.SHELL_TRAP ]); + it("should not allow Shell Trap to activate when attacked", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.moveset([Moves.SHELL_TRAP]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); + playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); - game.move.select(Moves.SHELL_TRAP); + game.move.select(Moves.SHELL_TRAP); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - } - ); + expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + }); - it( - "should not allow Beak Blast to burn opponents when hit", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.moveset([ Moves.BEAK_BLAST ]); + it("should not allow Beak Blast to burn opponents when hit", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.moveset([Moves.BEAK_BLAST]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); + playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); - game.move.select(Moves.BEAK_BLAST); + game.move.select(Moves.BEAK_BLAST); - await game.phaseInterceptor.to("MoveEndPhase"); + await game.phaseInterceptor.to("MoveEndPhase"); - expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.BURN); - } - ); + expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.BURN); + }); - it( - "should cause incoming attacks to not activate Counter", - async () => { - game.override.enemyMoveset(Moves.TACKLE); - game.override.moveset([ Moves.COUNTER ]); + it("should cause incoming attacks to not activate Counter", async () => { + game.override.enemyMoveset(Moves.TACKLE); + game.override.moveset([Moves.COUNTER]); - await game.classicMode.startBattle([ Species.BLASTOISE ]); + await game.classicMode.startBattle([Species.BLASTOISE]); - const playerPokemon = game.scene.getPlayerPokemon()!; - const enemyPokemon = game.scene.getEnemyPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); + playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); - game.move.select(Moves.COUNTER); + game.move.select(Moves.COUNTER); - await game.phaseInterceptor.to("BerryPhase", false); + await game.phaseInterceptor.to("BerryPhase", false); - expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); - expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); - } - ); + expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); + }); - it( - "should prevent Sappy Seed from applying its Leech Seed effect to the user", - async () => { - game.override.enemyMoveset(Moves.SAPPY_SEED); + it("should prevent Sappy Seed from applying its Leech Seed effect to the user", async () => { + game.override.enemyMoveset(Moves.SAPPY_SEED); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); - const playerPokemon = game.scene.getPlayerPokemon()!; + const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); + playerPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, playerPokemon.id); - game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); // enemy uses Sappy Seed first - await game.move.forceHit(); // forces Sappy Seed to hit - await game.phaseInterceptor.to("MoveEndPhase"); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); // enemy uses Sappy Seed first + await game.move.forceHit(); // forces Sappy Seed to hit + await game.phaseInterceptor.to("MoveEndPhase"); - expect(playerPokemon.getTag(BattlerTagType.SEEDED)).toBeUndefined(); - } - ); + expect(playerPokemon.getTag(BattlerTagType.SEEDED)).toBeUndefined(); + }); }); diff --git a/test/moves/swallow.test.ts b/test/moves/swallow.test.ts index 1ede5808d82..baa03801079 100644 --- a/test/moves/swallow.test.ts +++ b/test/moves/swallow.test.ts @@ -34,7 +34,7 @@ describe("Moves - Swallow", () => { game.override.enemyAbility(Abilities.NONE); game.override.enemyLevel(2000); - game.override.moveset([ Moves.SWALLOW, Moves.SWALLOW, Moves.SWALLOW, Moves.SWALLOW ]); + game.override.moveset([Moves.SWALLOW, Moves.SWALLOW, Moves.SWALLOW, Moves.SWALLOW]); game.override.ability(Abilities.NONE); }); @@ -43,7 +43,7 @@ describe("Moves - Swallow", () => { const stacksToSetup = 1; const expectedHeal = 25; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100); @@ -70,7 +70,7 @@ describe("Moves - Swallow", () => { const stacksToSetup = 2; const expectedHeal = 50; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100); @@ -98,7 +98,7 @@ describe("Moves - Swallow", () => { const stacksToSetup = 3; const expectedHeal = 100; - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100); @@ -125,7 +125,7 @@ describe("Moves - Swallow", () => { }); it("fails without stacks", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; @@ -135,12 +135,16 @@ describe("Moves - Swallow", () => { game.move.select(Moves.SWALLOW); await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.FAIL, targets: [ pokemon.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SWALLOW, + result: MoveResult.FAIL, + targets: [pokemon.getBattlerIndex()], + }); }); describe("restores stat stage boosts granted by stacks", () => { it("decreases stats based on stored values (both boosts equal)", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -156,7 +160,11 @@ describe("Moves - Swallow", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS, targets: [ pokemon.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SWALLOW, + result: MoveResult.SUCCESS, + targets: [pokemon.getBattlerIndex()], + }); expect(pokemon.getStatStage(Stat.DEF)).toBe(0); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(0); @@ -165,7 +173,7 @@ describe("Moves - Swallow", () => { }); it("lower stat stages based on stored values (different boosts)", async () => { - await game.startBattle([ Species.ABOMASNOW ]); + await game.startBattle([Species.ABOMASNOW]); const pokemon = game.scene.getPlayerPokemon()!; pokemon.addTag(BattlerTagType.STOCKPILING); @@ -183,7 +191,11 @@ describe("Moves - Swallow", () => { await game.phaseInterceptor.to(TurnInitPhase); - expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: Moves.SWALLOW, result: MoveResult.SUCCESS, targets: [ pokemon.getBattlerIndex() ]}); + expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ + move: Moves.SWALLOW, + result: MoveResult.SUCCESS, + targets: [pokemon.getBattlerIndex()], + }); expect(pokemon.getStatStage(Stat.DEF)).toBe(1); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(-2); diff --git a/test/moves/syrup_bomb.test.ts b/test/moves/syrup_bomb.test.ts index a284e6fa669..1e193793d82 100644 --- a/test/moves/syrup_bomb.test.ts +++ b/test/moves/syrup_bomb.test.ts @@ -31,60 +31,56 @@ describe("Moves - SYRUP BOMB", () => { .ability(Abilities.BALL_FETCH) .startingLevel(30) .enemyLevel(100) - .moveset([ Moves.SYRUP_BOMB, Moves.SPLASH ]) + .moveset([Moves.SYRUP_BOMB, Moves.SPLASH]) .enemyMoveset(Moves.SPLASH); }); //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/syrup_bomb_(move) - it("decreases the target Pokemon's speed stat once per turn for 3 turns", - async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + it("decreases the target Pokemon's speed stat once per turn for 3 turns", async () => { + await game.classicMode.startBattle([Species.MAGIKARP]); - const targetPokemon = game.scene.getEnemyPokemon()!; - expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0); - - game.move.select(Moves.SYRUP_BOMB); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.move.forceHit(); - await game.toNextTurn(); - expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined(); - expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-1); - - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined(); - expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-2); - - game.move.select(Moves.SPLASH); - await game.toNextTurn(); - expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined(); - expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-3); - } - ); - - it("does not affect Pokemon with the ability Bulletproof", - async () => { - game.override.enemyAbility(Abilities.BULLETPROOF); - await game.classicMode.startBattle([ Species.MAGIKARP ]); - - const targetPokemon = game.scene.getEnemyPokemon()!; - - game.move.select(Moves.SYRUP_BOMB); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.move.forceHit(); - await game.toNextTurn(); - expect(targetPokemon.isFullHp()).toBe(true); - expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined(); - expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0); - } - ); - - it("stops lowering the target's speed if the user leaves the field", async () => { - await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]); + const targetPokemon = game.scene.getEnemyPokemon()!; + expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0); game.move.select(Moves.SYRUP_BOMB); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.move.forceHit(); + await game.toNextTurn(); + expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined(); + expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-1); + + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeDefined(); + expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-2); + + game.move.select(Moves.SPLASH); + await game.toNextTurn(); + expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined(); + expect(targetPokemon.getStatStage(Stat.SPD)).toBe(-3); + }); + + it("does not affect Pokemon with the ability Bulletproof", async () => { + game.override.enemyAbility(Abilities.BULLETPROOF); + await game.classicMode.startBattle([Species.MAGIKARP]); + + const targetPokemon = game.scene.getEnemyPokemon()!; + + game.move.select(Moves.SYRUP_BOMB); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.move.forceHit(); + await game.toNextTurn(); + expect(targetPokemon.isFullHp()).toBe(true); + expect(targetPokemon.getTag(BattlerTagType.SYRUP_BOMB)).toBeUndefined(); + expect(targetPokemon.getStatStage(Stat.SPD)).toBe(0); + }); + + it("stops lowering the target's speed if the user leaves the field", async () => { + await game.classicMode.startBattle([Species.FEEBAS, Species.MILOTIC]); + + game.move.select(Moves.SYRUP_BOMB); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.toNextTurn(); diff --git a/test/moves/tackle.test.ts b/test/moves/tackle.test.ts index 2ee811d3137..44fc698ec62 100644 --- a/test/moves/tackle.test.ts +++ b/test/moves/tackle.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Tackle", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,17 +28,15 @@ describe("Moves - Tackle", () => { game.override.enemySpecies(Species.MAGIKARP); game.override.startingLevel(1); game.override.startingWave(97); - game.override.moveset([ moveToUse ]); - game.override.enemyMoveset([ Moves.GROWTH, Moves.GROWTH, Moves.GROWTH, Moves.GROWTH ]); + game.override.moveset([moveToUse]); + game.override.enemyMoveset([Moves.GROWTH, Moves.GROWTH, Moves.GROWTH, Moves.GROWTH]); game.override.disableCrits(); }); it("TACKLE against ghost", async () => { const moveToUse = Moves.TACKLE; game.override.enemySpecies(Species.GENGAR); - await game.startBattle([ - Species.MIGHTYENA, - ]); + await game.startBattle([Species.MIGHTYENA]); const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; game.move.select(moveToUse); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); @@ -49,13 +46,10 @@ describe("Moves - Tackle", () => { it("TACKLE against not resistant", async () => { const moveToUse = Moves.TACKLE; - await game.startBattle([ - Species.MIGHTYENA, - ]); + await game.startBattle([Species.MIGHTYENA]); game.scene.currentBattle.enemyParty[0].stats[Stat.DEF] = 50; game.scene.getPlayerParty()[0].stats[Stat.ATK] = 50; - const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; game.move.select(moveToUse); diff --git a/test/moves/tail_whip.test.ts b/test/moves/tail_whip.test.ts index fea334e4708..41c39ab22ca 100644 --- a/test/moves/tail_whip.test.ts +++ b/test/moves/tail_whip.test.ts @@ -8,7 +8,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; - describe("Moves - Tail whip", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -31,16 +30,13 @@ describe("Moves - Tail whip", () => { game.override.enemyAbility(Abilities.INSOMNIA); game.override.ability(Abilities.INSOMNIA); game.override.startingLevel(2000); - game.override.moveset([ moveToUse ]); + game.override.moveset([moveToUse]); game.override.enemyMoveset(Moves.SPLASH); }); - it("should lower DEF stat stage by 1", async() => { + it("should lower DEF stat stage by 1", async () => { const moveToUse = Moves.TAIL_WHIP; - await game.startBattle([ - Species.MIGHTYENA, - Species.MIGHTYENA, - ]); + await game.startBattle([Species.MIGHTYENA, Species.MIGHTYENA]); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); diff --git a/test/moves/tailwind.test.ts b/test/moves/tailwind.test.ts index 56cf85749cd..24a7fa25061 100644 --- a/test/moves/tailwind.test.ts +++ b/test/moves/tailwind.test.ts @@ -25,12 +25,12 @@ describe("Moves - Tailwind", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("double"); - game.override.moveset([ Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM ]); + game.override.moveset([Moves.TAILWIND, Moves.SPLASH, Moves.PETAL_BLIZZARD, Moves.SANDSTORM]); game.override.enemyMoveset(Moves.SPLASH); }); it("doubles the Speed stat of the Pokemons on its side", async () => { - await game.startBattle([ Species.MAGIKARP, Species.MEOWTH ]); + await game.startBattle([Species.MAGIKARP, Species.MEOWTH]); const magikarp = game.scene.getPlayerField()[0]; const meowth = game.scene.getPlayerField()[1]; @@ -53,7 +53,7 @@ describe("Moves - Tailwind", () => { it("lasts for 4 turns", async () => { game.override.battleType("single"); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); game.move.select(Moves.TAILWIND); await game.toNextTurn(); @@ -76,7 +76,7 @@ describe("Moves - Tailwind", () => { it("does not affect the opposing side", async () => { game.override.battleType("single"); - await game.startBattle([ Species.MAGIKARP ]); + await game.startBattle([Species.MAGIKARP]); const ally = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -84,7 +84,6 @@ describe("Moves - Tailwind", () => { const allySpd = ally.getStat(Stat.SPD); const enemySpd = enemy.getStat(Stat.SPD); - expect(ally.getEffectiveStat(Stat.SPD)).equal(allySpd); expect(enemy.getEffectiveStat(Stat.SPD)).equal(enemySpd); expect(game.scene.arena.getTagOnSide(ArenaTagType.TAILWIND, ArenaTagSide.PLAYER)).toBeUndefined(); diff --git a/test/moves/tar_shot.test.ts b/test/moves/tar_shot.test.ts index e5adfe6112d..ac3ba534446 100644 --- a/test/moves/tar_shot.test.ts +++ b/test/moves/tar_shot.test.ts @@ -29,12 +29,12 @@ describe("Moves - Tar Shot", () => { .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.TANGELA) .enemyLevel(1000) - .moveset([ Moves.TAR_SHOT, Moves.FIRE_PUNCH ]) + .moveset([Moves.TAR_SHOT, Moves.FIRE_PUNCH]) .disableCrits(); }); it("lowers the target's Speed stat by one stage and doubles the effectiveness of Fire-type moves used on the target", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const enemy = game.scene.getEnemyPokemon()!; @@ -48,14 +48,14 @@ describe("Moves - Tar Shot", () => { await game.toNextTurn(); game.move.select(Moves.FIRE_PUNCH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4); }); it("will not double the effectiveness of Fire-type moves used on a target that is already under the effect of Tar Shot (but may still lower its Speed)", async () => { - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const enemy = game.scene.getEnemyPokemon()!; @@ -76,7 +76,7 @@ describe("Moves - Tar Shot", () => { await game.toNextTurn(); game.move.select(Moves.FIRE_PUNCH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4); @@ -84,7 +84,7 @@ describe("Moves - Tar Shot", () => { it("does not double the effectiveness of Fire-type moves against a Pokémon that is Terastallized", async () => { game.override.enemySpecies(Species.SPRIGATITO); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const enemy = game.scene.getEnemyPokemon()!; enemy.teraType = PokemonType.GRASS; @@ -100,7 +100,7 @@ describe("Moves - Tar Shot", () => { await game.toNextTurn(); game.move.select(Moves.FIRE_PUNCH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(2); @@ -108,7 +108,7 @@ describe("Moves - Tar Shot", () => { it("doubles the effectiveness of Fire-type moves against a Pokémon that is already under the effects of Tar Shot before it Terastallized", async () => { game.override.enemySpecies(Species.SPRIGATITO); - await game.classicMode.startBattle([ Species.PIKACHU ]); + await game.classicMode.startBattle([Species.PIKACHU]); const enemy = game.scene.getEnemyPokemon()!; @@ -125,7 +125,7 @@ describe("Moves - Tar Shot", () => { enemy.isTerastallized = true; game.move.select(Moves.FIRE_PUNCH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.getMoveEffectiveness).toHaveReturnedWith(4); diff --git a/test/moves/taunt.test.ts b/test/moves/taunt.test.ts index c5cdd512704..adc1434c7dd 100644 --- a/test/moves/taunt.test.ts +++ b/test/moves/taunt.test.ts @@ -25,13 +25,13 @@ describe("Moves - Taunt", () => { game.override .battleType("single") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.TAUNT, Moves.SPLASH ]) + .enemyMoveset([Moves.TAUNT, Moves.SPLASH]) .enemySpecies(Species.SHUCKLE) - .moveset([ Moves.GROWL ]); + .moveset([Moves.GROWL]); }); it("Pokemon should not be able to use Status Moves", async () => { - await game.classicMode.startBattle([ Species.REGIELEKI ]); + await game.classicMode.startBattle([Species.REGIELEKI]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/telekinesis.test.ts b/test/moves/telekinesis.test.ts index f24f972b44c..1355cb975f3 100644 --- a/test/moves/telekinesis.test.ts +++ b/test/moves/telekinesis.test.ts @@ -26,16 +26,16 @@ describe("Moves - Telekinesis", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.TELEKINESIS, Moves.TACKLE, Moves.MUD_SHOT, Moves.SMACK_DOWN ]) + .moveset([Moves.TELEKINESIS, Moves.TACKLE, Moves.MUD_SHOT, Moves.SMACK_DOWN]) .battleType("single") .enemySpecies(Species.SNORLAX) .enemyLevel(60) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH ]); + .enemyMoveset([Moves.SPLASH]); }); it("Telekinesis makes the affected vulnerable to most attacking moves regardless of accuracy", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyOpponent = game.scene.getEnemyPokemon()!; @@ -52,7 +52,7 @@ describe("Moves - Telekinesis", () => { }); it("Telekinesis makes the affected airborne and immune to most Ground-moves", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyOpponent = game.scene.getEnemyPokemon()!; @@ -70,7 +70,7 @@ describe("Moves - Telekinesis", () => { it("Telekinesis can still affect Pokemon that have been transformed into invalid Pokemon", async () => { game.override.enemyMoveset(Moves.TRANSFORM); - await game.classicMode.startBattle([ Species.DIGLETT ]); + await game.classicMode.startBattle([Species.DIGLETT]); const enemyOpponent = game.scene.getEnemyPokemon()!; @@ -82,7 +82,7 @@ describe("Moves - Telekinesis", () => { }); it("Moves like Smack Down and 1000 Arrows remove all effects of Telekinesis from the target Pokemon", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemyOpponent = game.scene.getEnemyPokemon()!; @@ -99,8 +99,8 @@ describe("Moves - Telekinesis", () => { }); it("Ingrain will remove the floating effect of Telekinesis, but not the 100% hit", async () => { - game.override.enemyMoveset([ Moves.SPLASH, Moves.INGRAIN ]); - await game.classicMode.startBattle([ Species.MAGIKARP ]); + game.override.enemyMoveset([Moves.SPLASH, Moves.INGRAIN]); + await game.classicMode.startBattle([Species.MAGIKARP]); const playerPokemon = game.scene.getPlayerPokemon()!; const enemyOpponent = game.scene.getEnemyPokemon()!; @@ -124,14 +124,15 @@ describe("Moves - Telekinesis", () => { }); it("should not be baton passed onto a mega gengar", async () => { - game.override.moveset([ Moves.BATON_PASS ]) - .enemyMoveset([ Moves.TELEKINESIS ]) + game.override + .moveset([Moves.BATON_PASS]) + .enemyMoveset([Moves.TELEKINESIS]) .starterForms({ [Species.GENGAR]: 1 }); - await game.classicMode.startBattle([ Species.MAGIKARP, Species.GENGAR ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.GENGAR]); game.move.select(Moves.BATON_PASS); game.doSelectPartyPokemon(1); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.getPlayerPokemon()!.getTag(BattlerTagType.TELEKINESIS)).toBeUndefined(); }); diff --git a/test/moves/tera_blast.test.ts b/test/moves/tera_blast.test.ts index 772b14d9f36..dffe39f4d87 100644 --- a/test/moves/tera_blast.test.ts +++ b/test/moves/tera_blast.test.ts @@ -1,191 +1,190 @@ -import { BattlerIndex } from "#app/battle"; -import { Stat } from "#enums/stat"; -import { allMoves, TeraMoveCategoryAttr } from "#app/data/moves/move"; -import { PokemonType } from "#enums/pokemon-type"; -import { Abilities } from "#app/enums/abilities"; -import { HitResult } from "#app/field/pokemon"; -import { Moves } from "#enums/moves"; -import { Species } from "#enums/species"; -import GameManager from "#test/testUtils/gameManager"; -import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - -describe("Moves - Tera Blast", () => { - let phaserGame: Phaser.Game; - let game: GameManager; - const moveToCheck = allMoves[Moves.TERA_BLAST]; - const teraBlastAttr = moveToCheck.getAttrs(TeraMoveCategoryAttr)[0]; - - beforeAll(() => { - phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS, - }); - }); - - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - - game.override - .battleType("single") - .disableCrits() - .starterSpecies(Species.FEEBAS) - .moveset([ Moves.TERA_BLAST ]) - .ability(Abilities.BALL_FETCH) - .enemySpecies(Species.MAGIKARP) - .enemyMoveset(Moves.SPLASH) - .enemyAbility(Abilities.STURDY) - .enemyLevel(50); - - vi.spyOn(moveToCheck, "calculateBattlePower"); - }); - - it("changes type to match user's tera type", async () => { - game.override.enemySpecies(Species.FURRET); - await game.startBattle(); - const enemyPokemon = game.scene.getEnemyPokemon()!; - vi.spyOn(enemyPokemon, "apply"); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.teraType = PokemonType.FIGHTING; - playerPokemon.isTerastallized = true; - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to("MoveEffectPhase"); - - expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE); - }, 20000); - - it("increases power if user is Stellar tera type", async () => { - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.teraType = PokemonType.STELLAR; - playerPokemon.isTerastallized = true; - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to("MoveEffectPhase"); - - expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(100); - }, 20000); - - it("is super effective against terastallized targets if user is Stellar tera type", async () => { - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.teraType = PokemonType.STELLAR; - playerPokemon.isTerastallized = true; - - const enemyPokemon = game.scene.getEnemyPokemon()!; - vi.spyOn(enemyPokemon, "apply"); - enemyPokemon.isTerastallized = true; - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to("MoveEffectPhase"); - - expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE); - }); - - it("uses the higher ATK for damage calculation", async () => { - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.stats[Stat.ATK] = 100; - playerPokemon.stats[Stat.SPATK] = 1; - playerPokemon.isTerastallized = true; - - vi.spyOn(teraBlastAttr, "apply"); - - game.move.select(Moves.TERA_BLAST); - await game.toNextTurn(); - expect(teraBlastAttr.apply).toHaveLastReturnedWith(true); - }); - - it("uses the higher SPATK for damage calculation", async () => { - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.stats[Stat.ATK] = 1; - playerPokemon.stats[Stat.SPATK] = 100; - - vi.spyOn(teraBlastAttr, "apply"); - - game.move.select(Moves.TERA_BLAST); - await game.toNextTurn(); - expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); - }); - - it("should stay as a special move if ATK turns lower than SPATK mid-turn", async () => { - game.override.enemyMoveset([ Moves.CHARM ]); - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.stats[Stat.ATK] = 51; - playerPokemon.stats[Stat.SPATK] = 50; - - vi.spyOn(teraBlastAttr, "apply"); - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.toNextTurn(); - expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); - }); - - it("does not change its move category from stat changes due to held items", async () => { - game.override - .startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]) - .starterSpecies(Species.CUBONE); - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - - playerPokemon.stats[Stat.ATK] = 50; - playerPokemon.stats[Stat.SPATK] = 51; - - vi.spyOn(teraBlastAttr, "apply"); - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.toNextTurn(); - - expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); - }); - - it("does not change its move category from stat changes due to abilities", async () => { - game.override.ability(Abilities.HUGE_POWER); - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.stats[Stat.ATK] = 50; - playerPokemon.stats[Stat.SPATK] = 51; - - vi.spyOn(teraBlastAttr, "apply"); - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.toNextTurn(); - expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); - }); - - - it("causes stat drops if user is Stellar tera type", async () => { - await game.startBattle(); - - const playerPokemon = game.scene.getPlayerPokemon()!; - playerPokemon.teraType = PokemonType.STELLAR; - playerPokemon.isTerastallized = true; - - game.move.select(Moves.TERA_BLAST); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); - await game.phaseInterceptor.to("MoveEndPhase"); - - expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); - expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1); - }, 20000); -}); +import { BattlerIndex } from "#app/battle"; +import { Stat } from "#enums/stat"; +import { allMoves, TeraMoveCategoryAttr } from "#app/data/moves/move"; +import { PokemonType } from "#enums/pokemon-type"; +import { Abilities } from "#app/enums/abilities"; +import { HitResult } from "#app/field/pokemon"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; +import GameManager from "#test/testUtils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; + +describe("Moves - Tera Blast", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + const moveToCheck = allMoves[Moves.TERA_BLAST]; + const teraBlastAttr = moveToCheck.getAttrs(TeraMoveCategoryAttr)[0]; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + + game.override + .battleType("single") + .disableCrits() + .starterSpecies(Species.FEEBAS) + .moveset([Moves.TERA_BLAST]) + .ability(Abilities.BALL_FETCH) + .enemySpecies(Species.MAGIKARP) + .enemyMoveset(Moves.SPLASH) + .enemyAbility(Abilities.STURDY) + .enemyLevel(50); + + vi.spyOn(moveToCheck, "calculateBattlePower"); + }); + + it("changes type to match user's tera type", async () => { + game.override.enemySpecies(Species.FURRET); + await game.startBattle(); + const enemyPokemon = game.scene.getEnemyPokemon()!; + vi.spyOn(enemyPokemon, "apply"); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.teraType = PokemonType.FIGHTING; + playerPokemon.isTerastallized = true; + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEffectPhase"); + + expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE); + }, 20000); + + it("increases power if user is Stellar tera type", async () => { + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.teraType = PokemonType.STELLAR; + playerPokemon.isTerastallized = true; + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEffectPhase"); + + expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(100); + }, 20000); + + it("is super effective against terastallized targets if user is Stellar tera type", async () => { + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.teraType = PokemonType.STELLAR; + playerPokemon.isTerastallized = true; + + const enemyPokemon = game.scene.getEnemyPokemon()!; + vi.spyOn(enemyPokemon, "apply"); + enemyPokemon.isTerastallized = true; + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEffectPhase"); + + expect(enemyPokemon.apply).toHaveReturnedWith(HitResult.SUPER_EFFECTIVE); + }); + + it("uses the higher ATK for damage calculation", async () => { + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.stats[Stat.ATK] = 100; + playerPokemon.stats[Stat.SPATK] = 1; + playerPokemon.isTerastallized = true; + + vi.spyOn(teraBlastAttr, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.toNextTurn(); + expect(teraBlastAttr.apply).toHaveLastReturnedWith(true); + }); + + it("uses the higher SPATK for damage calculation", async () => { + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.stats[Stat.ATK] = 1; + playerPokemon.stats[Stat.SPATK] = 100; + + vi.spyOn(teraBlastAttr, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.toNextTurn(); + expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); + }); + + it("should stay as a special move if ATK turns lower than SPATK mid-turn", async () => { + game.override.enemyMoveset([Moves.CHARM]); + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.stats[Stat.ATK] = 51; + playerPokemon.stats[Stat.SPATK] = 50; + + vi.spyOn(teraBlastAttr, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.toNextTurn(); + expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); + }); + + it("does not change its move category from stat changes due to held items", async () => { + game.override + .startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]) + .starterSpecies(Species.CUBONE); + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + + playerPokemon.stats[Stat.ATK] = 50; + playerPokemon.stats[Stat.SPATK] = 51; + + vi.spyOn(teraBlastAttr, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.toNextTurn(); + + expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); + }); + + it("does not change its move category from stat changes due to abilities", async () => { + game.override.ability(Abilities.HUGE_POWER); + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.stats[Stat.ATK] = 50; + playerPokemon.stats[Stat.SPATK] = 51; + + vi.spyOn(teraBlastAttr, "apply"); + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); + await game.toNextTurn(); + expect(teraBlastAttr.apply).toHaveLastReturnedWith(false); + }); + + it("causes stat drops if user is Stellar tera type", async () => { + await game.startBattle(); + + const playerPokemon = game.scene.getPlayerPokemon()!; + playerPokemon.teraType = PokemonType.STELLAR; + playerPokemon.isTerastallized = true; + + game.move.select(Moves.TERA_BLAST); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); + await game.phaseInterceptor.to("MoveEndPhase"); + + expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); + expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1); + }, 20000); +}); diff --git a/test/moves/tera_starstorm.test.ts b/test/moves/tera_starstorm.test.ts index 9e2a06c7f0f..19fe58f4057 100644 --- a/test/moves/tera_starstorm.test.ts +++ b/test/moves/tera_starstorm.test.ts @@ -24,7 +24,7 @@ describe("Moves - Tera Starstorm", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.TERA_STARSTORM, Moves.SPLASH ]) + .moveset([Moves.TERA_STARSTORM, Moves.SPLASH]) .battleType("double") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) @@ -34,7 +34,7 @@ describe("Moves - Tera Starstorm", () => { it("changes type to Stellar when used by Terapagos in its Stellar Form", async () => { game.override.battleType("single"); - await game.classicMode.startBattle([ Species.TERAPAGOS ]); + await game.classicMode.startBattle([Species.TERAPAGOS]); const terapagos = game.scene.getPlayerPokemon()!; terapagos.isTerastallized = true; @@ -48,7 +48,7 @@ describe("Moves - Tera Starstorm", () => { }); it("targets both opponents in a double battle when used by Terapagos in its Stellar Form", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP, Species.TERAPAGOS ]); + await game.classicMode.startBattle([Species.MAGIKARP, Species.TERAPAGOS]); const terapagos = game.scene.getPlayerParty()[1]; terapagos.isTerastallized = true; @@ -56,7 +56,7 @@ describe("Moves - Tera Starstorm", () => { game.move.select(Moves.TERA_STARSTORM, 0, BattlerIndex.ENEMY); game.move.select(Moves.TERA_STARSTORM, 1); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); const enemyField = game.scene.getEnemyField(); @@ -70,7 +70,7 @@ describe("Moves - Tera Starstorm", () => { }); it("applies the effects when Terapagos in Stellar Form is fused with another Pokemon", async () => { - await game.classicMode.startBattle([ Species.TERAPAGOS, Species.CHARMANDER, Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.TERAPAGOS, Species.CHARMANDER, Species.MAGIKARP]); const fusionedMon = game.scene.getPlayerParty()[0]; const magikarp = game.scene.getPlayerParty()[2]; diff --git a/test/moves/thousand_arrows.test.ts b/test/moves/thousand_arrows.test.ts index 563f99c030d..109fc2c6936 100644 --- a/test/moves/thousand_arrows.test.ts +++ b/test/moves/thousand_arrows.test.ts @@ -8,7 +8,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Thousand Arrows", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -29,71 +28,62 @@ describe("Moves - Thousand Arrows", () => { game.override.enemySpecies(Species.TOGETIC); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([ Moves.THOUSAND_ARROWS ]); - game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); + game.override.moveset([Moves.THOUSAND_ARROWS]); + game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]); }); - it( - "move should hit and ground Flying-type targets", - async () => { - await game.startBattle([ Species.ILLUMISE ]); + it("move should hit and ground Flying-type targets", async () => { + await game.startBattle([Species.ILLUMISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.THOUSAND_ARROWS); + game.move.select(Moves.THOUSAND_ARROWS); - await game.phaseInterceptor.to(MoveEffectPhase, false); - // Enemy should not be grounded before move effect is applied - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); + await game.phaseInterceptor.to(MoveEffectPhase, false); + // Enemy should not be grounded before move effect is applied + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); - it( - "move should hit and ground targets with Levitate", - async () => { - game.override.enemySpecies(Species.SNORLAX); - game.override.enemyAbility(Abilities.LEVITATE); + it("move should hit and ground targets with Levitate", async () => { + game.override.enemySpecies(Species.SNORLAX); + game.override.enemyAbility(Abilities.LEVITATE); - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - game.move.select(Moves.THOUSAND_ARROWS); + game.move.select(Moves.THOUSAND_ARROWS); - await game.phaseInterceptor.to(MoveEffectPhase, false); - // Enemy should not be grounded before move effect is applied - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); + await game.phaseInterceptor.to(MoveEffectPhase, false); + // Enemy should not be grounded before move effect is applied + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); - it( - "move should hit and ground targets under the effects of Magnet Rise", - async () => { - game.override.enemySpecies(Species.SNORLAX); + it("move should hit and ground targets under the effects of Magnet Rise", async () => { + game.override.enemySpecies(Species.SNORLAX); - await game.startBattle([ Species.ILLUMISE ]); + await game.startBattle([Species.ILLUMISE]); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; - enemyPokemon.addTag(BattlerTagType.FLOATING, undefined, Moves.MAGNET_RISE); + enemyPokemon.addTag(BattlerTagType.FLOATING, undefined, Moves.MAGNET_RISE); - game.move.select(Moves.THOUSAND_ARROWS); + game.move.select(Moves.THOUSAND_ARROWS); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getTag(BattlerTagType.FLOATING)).toBeUndefined(); - expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); - expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); - } - ); + expect(enemyPokemon.getTag(BattlerTagType.FLOATING)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); + expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); + }); }); diff --git a/test/moves/throat_chop.test.ts b/test/moves/throat_chop.test.ts index d69205aadf3..755e60fe425 100644 --- a/test/moves/throat_chop.test.ts +++ b/test/moves/throat_chop.test.ts @@ -32,12 +32,12 @@ describe("Moves - Throat Chop", () => { }); it("prevents the target from using sound-based moves for two turns", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); + await game.classicMode.startBattle([Species.MAGIKARP]); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.GROWL); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); // First turn, move is interrupted await game.phaseInterceptor.to("TurnEndPhase"); @@ -47,7 +47,7 @@ describe("Moves - Throat Chop", () => { await game.toNextTurn(); game.move.select(Moves.GROWL); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEndPhase"); expect(enemy.isFullHp()).toBe(false); diff --git a/test/moves/thunder_wave.test.ts b/test/moves/thunder_wave.test.ts index 34ab64e081a..9f907e38b62 100644 --- a/test/moves/thunder_wave.test.ts +++ b/test/moves/thunder_wave.test.ts @@ -7,7 +7,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("Moves - Thunder Wave", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -27,7 +26,7 @@ describe("Moves - Thunder Wave", () => { game.override .battleType("single") .starterSpecies(Species.PIKACHU) - .moveset([ Moves.THUNDER_WAVE ]) + .moveset([Moves.THUNDER_WAVE]) .enemyMoveset(Moves.SPLASH); }); diff --git a/test/moves/tidy_up.test.ts b/test/moves/tidy_up.test.ts index 5b5b67847ce..9d98feb13f5 100644 --- a/test/moves/tidy_up.test.ts +++ b/test/moves/tidy_up.test.ts @@ -10,7 +10,6 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { SubstituteTag } from "#app/data/battler-tags"; - describe("Moves - Tidy Up", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -33,13 +32,13 @@ describe("Moves - Tidy Up", () => { game.override.enemyMoveset(Moves.SPLASH); game.override.starterSpecies(Species.FEEBAS); game.override.ability(Abilities.BALL_FETCH); - game.override.moveset([ Moves.TIDY_UP ]); + game.override.moveset([Moves.TIDY_UP]); game.override.startingLevel(50); }); it("spikes are cleared", async () => { - game.override.moveset([ Moves.SPIKES, Moves.TIDY_UP ]); - game.override.enemyMoveset([ Moves.SPIKES, Moves.SPIKES, Moves.SPIKES, Moves.SPIKES ]); + game.override.moveset([Moves.SPIKES, Moves.TIDY_UP]); + game.override.enemyMoveset([Moves.SPIKES, Moves.SPIKES, Moves.SPIKES, Moves.SPIKES]); await game.classicMode.startBattle(); game.move.select(Moves.SPIKES); @@ -47,12 +46,11 @@ describe("Moves - Tidy Up", () => { game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); expect(game.scene.arena.getTag(ArenaTagType.SPIKES)).toBeUndefined(); - }, 20000); it("stealth rocks are cleared", async () => { - game.override.moveset([ Moves.STEALTH_ROCK, Moves.TIDY_UP ]); - game.override.enemyMoveset([ Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK ]); + game.override.moveset([Moves.STEALTH_ROCK, Moves.TIDY_UP]); + game.override.enemyMoveset([Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK, Moves.STEALTH_ROCK]); await game.classicMode.startBattle(); game.move.select(Moves.STEALTH_ROCK); @@ -63,8 +61,8 @@ describe("Moves - Tidy Up", () => { }, 20000); it("toxic spikes are cleared", async () => { - game.override.moveset([ Moves.TOXIC_SPIKES, Moves.TIDY_UP ]); - game.override.enemyMoveset([ Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES ]); + game.override.moveset([Moves.TOXIC_SPIKES, Moves.TIDY_UP]); + game.override.enemyMoveset([Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES, Moves.TOXIC_SPIKES]); await game.classicMode.startBattle(); game.move.select(Moves.TOXIC_SPIKES); @@ -75,8 +73,8 @@ describe("Moves - Tidy Up", () => { }, 20000); it("sticky webs are cleared", async () => { - game.override.moveset([ Moves.STICKY_WEB, Moves.TIDY_UP ]); - game.override.enemyMoveset([ Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB ]); + game.override.moveset([Moves.STICKY_WEB, Moves.TIDY_UP]); + game.override.enemyMoveset([Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB, Moves.STICKY_WEB]); await game.classicMode.startBattle(); @@ -88,8 +86,8 @@ describe("Moves - Tidy Up", () => { }, 20000); it("substitutes are cleared", async () => { - game.override.moveset([ Moves.SUBSTITUTE, Moves.TIDY_UP ]); - game.override.enemyMoveset([ Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE ]); + game.override.moveset([Moves.SUBSTITUTE, Moves.TIDY_UP]); + game.override.enemyMoveset([Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE, Moves.SUBSTITUTE]); await game.classicMode.startBattle(); @@ -98,7 +96,7 @@ describe("Moves - Tidy Up", () => { game.move.select(Moves.TIDY_UP); await game.phaseInterceptor.to(MoveEndPhase); - const pokemon = [ game.scene.getPlayerPokemon()!, game.scene.getEnemyPokemon()! ]; + const pokemon = [game.scene.getPlayerPokemon()!, game.scene.getEnemyPokemon()!]; pokemon.forEach(p => { expect(p).toBeDefined(); expect(p!.getTag(SubstituteTag)).toBeUndefined(); diff --git a/test/moves/torment.test.ts b/test/moves/torment.test.ts index 8cc835aad48..75143053321 100644 --- a/test/moves/torment.test.ts +++ b/test/moves/torment.test.ts @@ -26,15 +26,15 @@ describe("Moves - Torment", () => { game.override .battleType("single") .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.TORMENT, Moves.SPLASH ]) + .enemyMoveset([Moves.TORMENT, Moves.SPLASH]) .enemySpecies(Species.SHUCKLE) .enemyLevel(30) - .moveset([ Moves.TACKLE ]) + .moveset([Moves.TACKLE]) .ability(Abilities.BALL_FETCH); }); it("Pokemon should not be able to use the same move consecutively", async () => { - await game.classicMode.startBattle([ Species.CHANSEY ]); + await game.classicMode.startBattle([Species.CHANSEY]); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/moves/toxic.test.ts b/test/moves/toxic.test.ts index 4fea079638a..f2b1f82fe02 100644 --- a/test/moves/toxic.test.ts +++ b/test/moves/toxic.test.ts @@ -23,16 +23,12 @@ describe("Moves - Toxic", () => { beforeEach(() => { game = new GameManager(phaserGame); - game.override - .battleType("single") - .moveset(Moves.TOXIC) - .enemySpecies(Species.MAGIKARP) - .enemyMoveset(Moves.SPLASH); + game.override.battleType("single").moveset(Moves.TOXIC).enemySpecies(Species.MAGIKARP).enemyMoveset(Moves.SPLASH); }); it("should be guaranteed to hit if user is Poison-type", async () => { vi.spyOn(allMoves[Moves.TOXIC], "accuracy", "get").mockReturnValue(0); - await game.classicMode.startBattle([ Species.TOXAPEX ]); + await game.classicMode.startBattle([Species.TOXAPEX]); game.move.select(Moves.TOXIC); await game.phaseInterceptor.to("BerryPhase", false); @@ -42,7 +38,7 @@ describe("Moves - Toxic", () => { it("may miss if user is not Poison-type", async () => { vi.spyOn(allMoves[Moves.TOXIC], "accuracy", "get").mockReturnValue(0); - await game.classicMode.startBattle([ Species.UMBREON ]); + await game.classicMode.startBattle([Species.UMBREON]); game.move.select(Moves.TOXIC); await game.phaseInterceptor.to("BerryPhase", false); @@ -53,10 +49,10 @@ describe("Moves - Toxic", () => { it("should hit semi-invulnerable targets if user is Poison-type", async () => { vi.spyOn(allMoves[Moves.TOXIC], "accuracy", "get").mockReturnValue(0); game.override.enemyMoveset(Moves.FLY); - await game.classicMode.startBattle([ Species.TOXAPEX ]); + await game.classicMode.startBattle([Species.TOXAPEX]); game.move.select(Moves.TOXIC); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.TOXIC); @@ -65,10 +61,10 @@ describe("Moves - Toxic", () => { it("should miss semi-invulnerable targets if user is not Poison-type", async () => { vi.spyOn(allMoves[Moves.TOXIC], "accuracy", "get").mockReturnValue(-1); game.override.enemyMoveset(Moves.FLY); - await game.classicMode.startBattle([ Species.UMBREON ]); + await game.classicMode.startBattle([Species.UMBREON]); game.move.select(Moves.TOXIC); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); expect(game.scene.getEnemyPokemon()!.status).toBeUndefined(); @@ -77,10 +73,10 @@ describe("Moves - Toxic", () => { it("moves other than Toxic should not hit semi-invulnerable targets even if user is Poison-type", async () => { game.override.moveset(Moves.SWIFT); game.override.enemyMoveset(Moves.FLY); - await game.classicMode.startBattle([ Species.TOXAPEX ]); + await game.classicMode.startBattle([Species.TOXAPEX]); game.move.select(Moves.SWIFT); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase", false); const enemyPokemon = game.scene.getEnemyPokemon()!; diff --git a/test/moves/toxic_spikes.test.ts b/test/moves/toxic_spikes.test.ts index 2bddbc2eccb..d457ec5cb56 100644 --- a/test/moves/toxic_spikes.test.ts +++ b/test/moves/toxic_spikes.test.ts @@ -34,11 +34,11 @@ describe("Moves - Toxic Spikes", () => { .enemyAbility(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.TOXIC_SPIKES, Moves.SPLASH, Moves.ROAR, Moves.COURT_CHANGE ]); + .moveset([Moves.TOXIC_SPIKES, Moves.SPLASH, Moves.ROAR, Moves.COURT_CHANGE]); }); it("should not affect the opponent if they do not switch", async () => { - await game.classicMode.runToSummon([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); const enemy = game.scene.getEnemyField()[0]; @@ -54,7 +54,7 @@ describe("Moves - Toxic Spikes", () => { }); it("should poison the opponent if they switch into 1 layer", async () => { - await game.classicMode.runToSummon([ Species.MIGHTYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA]); game.move.select(Moves.TOXIC_SPIKES); await game.phaseInterceptor.to("TurnEndPhase"); @@ -68,7 +68,7 @@ describe("Moves - Toxic Spikes", () => { }); it("should badly poison the opponent if they switch into 2 layers", async () => { - await game.classicMode.runToSummon([ Species.MIGHTYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA]); game.move.select(Moves.TOXIC_SPIKES); await game.phaseInterceptor.to("TurnEndPhase"); @@ -83,7 +83,7 @@ describe("Moves - Toxic Spikes", () => { }); it("should be removed if a grounded poison pokemon switches in", async () => { - await game.classicMode.runToSummon([ Species.MUK, Species.PIDGEY ]); + await game.classicMode.runToSummon([Species.MUK, Species.PIDGEY]); const muk = game.scene.getPlayerPokemon()!; @@ -106,12 +106,12 @@ describe("Moves - Toxic Spikes", () => { }); it("shouldn't create multiple layers per use in doubles", async () => { - await game.classicMode.runToSummon([ Species.MIGHTYENA, Species.POOCHYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA, Species.POOCHYENA]); game.move.select(Moves.TOXIC_SPIKES); await game.phaseInterceptor.to("TurnEndPhase"); - const arenaTags = (game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag); + const arenaTags = game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(arenaTags.tagType).toBe(ArenaTagType.TOXIC_SPIKES); expect(arenaTags.layers).toBe(1); }); @@ -120,7 +120,7 @@ describe("Moves - Toxic Spikes", () => { game.override.startingWave(1); const gameData = new GameData(); - await game.classicMode.runToSummon([ Species.MIGHTYENA ]); + await game.classicMode.runToSummon([Species.MIGHTYENA]); game.move.select(Moves.TOXIC_SPIKES); await game.phaseInterceptor.to("TurnEndPhase"); @@ -129,9 +129,11 @@ describe("Moves - Toxic Spikes", () => { await game.phaseInterceptor.to("BattleEndPhase"); await game.toNextWave(); - const sessionData : SessionSaveData = gameData["getSessionSaveData"](); + const sessionData: SessionSaveData = gameData["getSessionSaveData"](); localStorage.setItem("sessionTestData", encrypt(JSON.stringify(sessionData), true)); - const recoveredData : SessionSaveData = gameData.parseSessionData(decrypt(localStorage.getItem("sessionTestData")!, true)); + const recoveredData: SessionSaveData = gameData.parseSessionData( + decrypt(localStorage.getItem("sessionTestData")!, true), + ); await gameData.loadSession(0, recoveredData); expect(sessionData.arena.tags).toEqual(recoveredData.arena.tags); diff --git a/test/moves/transform.test.ts b/test/moves/transform.test.ts index 781e83b7e89..5140202a383 100644 --- a/test/moves/transform.test.ts +++ b/test/moves/transform.test.ts @@ -32,11 +32,11 @@ describe("Moves - Transform", () => { .enemyPassiveAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) .ability(Abilities.INTIMIDATE) - .moveset([ Moves.TRANSFORM ]); + .moveset([Moves.TRANSFORM]); }); it("should copy species, ability, gender, all stats except HP, all stat stages, moveset, and types of target", async () => { - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); game.move.select(Moves.TRANSFORM); await game.phaseInterceptor.to(TurnEndPhase); @@ -75,9 +75,9 @@ describe("Moves - Transform", () => { }); it("should copy in-battle overridden stats", async () => { - game.override.enemyMoveset([ Moves.POWER_SPLIT ]); + game.override.enemyMoveset([Moves.POWER_SPLIT]); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -96,9 +96,9 @@ describe("Moves - Transform", () => { }); it("should set each move's pp to a maximum of 5", async () => { - game.override.enemyMoveset([ Moves.SWORDS_DANCE, Moves.GROWL, Moves.SKETCH, Moves.RECOVER ]); + game.override.enemyMoveset([Moves.SWORDS_DANCE, Moves.GROWL, Moves.SKETCH, Moves.RECOVER]); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); const player = game.scene.getPlayerPokemon()!; game.move.select(Moves.TRANSFORM); @@ -118,10 +118,9 @@ describe("Moves - Transform", () => { }); it("should activate its ability if it copies one that activates on summon", async () => { - game.override.enemyAbility(Abilities.INTIMIDATE) - .ability(Abilities.BALL_FETCH); + game.override.enemyAbility(Abilities.INTIMIDATE).ability(Abilities.BALL_FETCH); - await game.classicMode.startBattle([ Species.DITTO ]); + await game.classicMode.startBattle([Species.DITTO]); game.move.select(Moves.TRANSFORM); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/trick_or_treat.test.ts b/test/moves/trick_or_treat.test.ts index 927d625fbb8..108028f3008 100644 --- a/test/moves/trick_or_treat.test.ts +++ b/test/moves/trick_or_treat.test.ts @@ -23,7 +23,7 @@ describe("Moves - Trick Or Treat", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.FORESTS_CURSE, Moves.TRICK_OR_TREAT ]) + .moveset([Moves.FORESTS_CURSE, Moves.TRICK_OR_TREAT]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -33,7 +33,7 @@ describe("Moves - Trick Or Treat", () => { }); it("will replace added type from Forest's Curse", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemyPokemon = game.scene.getEnemyPokemon(); game.move.select(Moves.FORESTS_CURSE); diff --git a/test/moves/triple_arrows.test.ts b/test/moves/triple_arrows.test.ts index 11926b4066d..c1114b69b99 100644 --- a/test/moves/triple_arrows.test.ts +++ b/test/moves/triple_arrows.test.ts @@ -27,7 +27,7 @@ describe("Moves - Triple Arrows", () => { game = new GameManager(phaserGame); game.override .ability(Abilities.BALL_FETCH) - .moveset([ Moves.TRIPLE_ARROWS ]) + .moveset([Moves.TRIPLE_ARROWS]) .battleType("single") .enemySpecies(Species.MAGIKARP) .enemyAbility(Abilities.STURDY) @@ -38,7 +38,7 @@ describe("Moves - Triple Arrows", () => { }); it("has a 30% flinch chance and 50% defense drop chance", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.TRIPLE_ARROWS); await game.phaseInterceptor.to("BerryPhase"); @@ -49,7 +49,7 @@ describe("Moves - Triple Arrows", () => { it("is affected normally by Serene Grace", async () => { game.override.ability(Abilities.SERENE_GRACE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); game.move.select(Moves.TRIPLE_ARROWS); await game.phaseInterceptor.to("BerryPhase"); diff --git a/test/moves/u_turn.test.ts b/test/moves/u_turn.test.ts index f57dec2e39f..f1d212f3f47 100644 --- a/test/moves/u_turn.test.ts +++ b/test/moves/u_turn.test.ts @@ -27,7 +27,7 @@ describe("Moves - U-turn", () => { .enemySpecies(Species.GENGAR) .startingLevel(90) .startingWave(97) - .moveset([ Moves.U_TURN ]) + .moveset([Moves.U_TURN]) .enemyMoveset(Moves.SPLASH) .disableCrits(); }); @@ -36,7 +36,7 @@ describe("Moves - U-turn", () => { // arrange const playerHp = 1; game.override.ability(Abilities.REGENERATOR); - await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); game.scene.getPlayerPokemon()!.hp = playerHp; // act @@ -45,7 +45,9 @@ describe("Moves - U-turn", () => { await game.phaseInterceptor.to("TurnEndPhase"); // assert - expect(game.scene.getPlayerParty()[1].hp).toEqual(Math.floor(game.scene.getPlayerParty()[1].getMaxHp() * 0.33 + playerHp)); + expect(game.scene.getPlayerParty()[1].hp).toEqual( + Math.floor(game.scene.getPlayerParty()[1].getMaxHp() * 0.33 + playerHp), + ); expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase"); expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(Species.SHUCKLE); }, 20000); @@ -53,7 +55,7 @@ describe("Moves - U-turn", () => { it("triggers rough skin on the u-turn user before a new pokemon is switched in", async () => { // arrange game.override.enemyAbility(Abilities.ROUGH_SKIN); - await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); // act game.move.select(Moves.U_TURN); @@ -71,7 +73,7 @@ describe("Moves - U-turn", () => { it("triggers contact abilities on the u-turn user (eg poison point) before a new pokemon is switched in", async () => { // arrange game.override.enemyAbility(Abilities.POISON_POINT); - await game.classicMode.startBattle([ Species.RAICHU, Species.SHUCKLE ]); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); vi.spyOn(game.scene.getEnemyPokemon()!, "randSeedInt").mockReturnValue(0); // act @@ -88,10 +90,7 @@ describe("Moves - U-turn", () => { it("still forces a switch if u-turn KO's the opponent", async () => { game.override.startingLevel(1000); // Ensure that U-Turn KO's the opponent - await game.classicMode.startBattle([ - Species.RAICHU, - Species.SHUCKLE - ]); + await game.classicMode.startBattle([Species.RAICHU, Species.SHUCKLE]); const enemy = game.scene.getEnemyPokemon()!; // KO the opponent with U-Turn diff --git a/test/moves/upper_hand.test.ts b/test/moves/upper_hand.test.ts index c7556c1fa91..ecfd9f0735c 100644 --- a/test/moves/upper_hand.test.ts +++ b/test/moves/upper_hand.test.ts @@ -36,7 +36,7 @@ describe("Moves - Upper Hand", () => { }); it("should flinch the opponent before they use a priority attack", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const feebas = game.scene.getPlayerPokemon()!; const magikarp = game.scene.getEnemyPokemon()!; @@ -51,11 +51,11 @@ describe("Moves - Upper Hand", () => { it.each([ { descriptor: "non-priority attack", move: Moves.TACKLE }, - { descriptor: "status move", move: Moves.BABY_DOLL_EYES } + { descriptor: "status move", move: Moves.BABY_DOLL_EYES }, ])("should fail when the opponent selects a $descriptor", async ({ move }) => { game.override.enemyMoveset(move); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const feebas = game.scene.getPlayerPokemon()!; @@ -66,11 +66,9 @@ describe("Moves - Upper Hand", () => { }); it("should flinch the opponent before they use an attack boosted by Gale Wings", async () => { - game.override - .enemyAbility(Abilities.GALE_WINGS) - .enemyMoveset(Moves.GUST); + game.override.enemyAbility(Abilities.GALE_WINGS).enemyMoveset(Moves.GUST); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const feebas = game.scene.getPlayerPokemon()!; const magikarp = game.scene.getEnemyPokemon()!; @@ -84,17 +82,15 @@ describe("Moves - Upper Hand", () => { }); it("should fail if the target has already moved", async () => { - game.override - .enemyMoveset(Moves.FAKE_OUT) - .enemyAbility(Abilities.SHEER_FORCE); + game.override.enemyMoveset(Moves.FAKE_OUT).enemyAbility(Abilities.SHEER_FORCE); - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const feebas = game.scene.getPlayerPokemon()!; game.move.select(Moves.UPPER_HAND); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("BerryPhase"); expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.FAIL); diff --git a/test/moves/whirlwind.test.ts b/test/moves/whirlwind.test.ts index 7bf99f0ff21..d6124b6c766 100644 --- a/test/moves/whirlwind.test.ts +++ b/test/moves/whirlwind.test.ts @@ -31,7 +31,7 @@ describe("Moves - Whirlwind", () => { .battleType("single") .moveset(Moves.SPLASH) .enemyAbility(Abilities.BALL_FETCH) - .enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]) + .enemyMoveset([Moves.SPLASH, Moves.WHIRLWIND]) .enemySpecies(Species.PIDGEY); }); @@ -40,8 +40,8 @@ describe("Moves - Whirlwind", () => { { move: Moves.BOUNCE, name: "Bounce" }, { move: Moves.SKY_DROP, name: "Sky Drop" }, ])("should not hit a flying target: $name (=$move)", async ({ move }) => { - game.override.moveset([ move ]); - await game.classicMode.startBattle([ Species.STARAPTOR ]); + game.override.moveset([move]); + await game.classicMode.startBattle([Species.STARAPTOR]); const staraptor = game.scene.getPlayerPokemon()!; @@ -50,17 +50,17 @@ describe("Moves - Whirlwind", () => { await game.phaseInterceptor.to("BerryPhase", false); - expect(staraptor.findTag((t) => t.tagType === BattlerTagType.FLYING)).toBeDefined(); + expect(staraptor.findTag(t => t.tagType === BattlerTagType.FLYING)).toBeDefined(); expect(game.scene.getEnemyPokemon()!.getLastXMoves(1)[0].result).toBe(MoveResult.MISS); }); it("should force switches randomly", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE]); - const [ bulbasaur, charmander, squirtle ] = game.scene.getPlayerParty(); + const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty(); // Turn 1: Mock an RNG call that calls for switching to 1st backup Pokemon (Charmander) - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -72,7 +72,7 @@ describe("Moves - Whirlwind", () => { expect(squirtle.isOnField()).toBe(false); // Turn 2: Mock an RNG call that calls for switching to 2nd backup Pokemon (Squirtle) - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min + 1; }); game.move.select(Moves.SPLASH); @@ -87,12 +87,12 @@ describe("Moves - Whirlwind", () => { it("should not force a switch to a challenge-ineligible Pokemon", async () => { // Mono-Water challenge, Eevee is ineligible game.challengeMode.addChallenge(Challenges.SINGLE_TYPE, PokemonType.WATER + 1, 0); - await game.challengeMode.startBattle([ Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA ]); + await game.challengeMode.startBattle([Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA]); - const [ lapras, eevee, toxapex, primarina ] = game.scene.getPlayerParty(); + const [lapras, eevee, toxapex, primarina] = game.scene.getPlayerParty(); // Turn 1: Mock an RNG call that would normally call for switching to Eevee, but it is ineligible - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -106,9 +106,9 @@ describe("Moves - Whirlwind", () => { }); it("should not force a switch to a fainted Pokemon", async () => { - await game.classicMode.startBattle([ Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA ]); + await game.classicMode.startBattle([Species.LAPRAS, Species.EEVEE, Species.TOXAPEX, Species.PRIMARINA]); - const [ lapras, eevee, toxapex, primarina ] = game.scene.getPlayerParty(); + const [lapras, eevee, toxapex, primarina] = game.scene.getPlayerParty(); // Turn 1: Eevee faints eevee.hp = 0; @@ -119,7 +119,7 @@ describe("Moves - Whirlwind", () => { await game.toNextTurn(); // Turn 2: Mock an RNG call that would normally call for switching to Eevee, but it is fainted - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); @@ -133,9 +133,9 @@ describe("Moves - Whirlwind", () => { }); it("should not force a switch if there are no available Pokemon to switch into", async () => { - await game.classicMode.startBattle([ Species.LAPRAS, Species.EEVEE ]); + await game.classicMode.startBattle([Species.LAPRAS, Species.EEVEE]); - const [ lapras, eevee ] = game.scene.getPlayerParty(); + const [lapras, eevee] = game.scene.getPlayerParty(); // Turn 1: Eevee faints eevee.hp = 0; @@ -146,7 +146,7 @@ describe("Moves - Whirlwind", () => { await game.toNextTurn(); // Turn 2: Mock an RNG call that would normally call for switching to Eevee, but it is fainted - vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((range, min: number = 0) => { + vi.spyOn(game.scene, "randBattleSeedInt").mockImplementation((_range, min = 0) => { return min; }); game.move.select(Moves.SPLASH); diff --git a/test/moves/wide_guard.test.ts b/test/moves/wide_guard.test.ts index 1f0579e24ee..c466f104f67 100644 --- a/test/moves/wide_guard.test.ts +++ b/test/moves/wide_guard.test.ts @@ -8,7 +8,6 @@ import { Stat } from "#enums/stat"; import { BerryPhase } from "#app/phases/berry-phase"; import { CommandPhase } from "#app/phases/command-phase"; - describe("Moves - Wide Guard", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,97 +27,85 @@ describe("Moves - Wide Guard", () => { game.override.battleType("double"); - game.override.moveset([ Moves.WIDE_GUARD, Moves.SPLASH, Moves.SURF ]); + game.override.moveset([Moves.WIDE_GUARD, Moves.SPLASH, Moves.SURF]); game.override.enemySpecies(Species.SNORLAX); - game.override.enemyMoveset([ Moves.SWIFT ]); + game.override.enemyMoveset([Moves.SWIFT]); game.override.enemyAbility(Abilities.INSOMNIA); game.override.startingLevel(100); game.override.enemyLevel(100); }); - test( - "should protect the user and allies from multi-target attack moves", - async () => { - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + test("should protect the user and allies from multi-target attack moves", async () => { + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.WIDE_GUARD); + game.move.select(Moves.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); - } - ); + leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); + }); - test( - "should protect the user and allies from multi-target status moves", - async () => { - game.override.enemyMoveset([ Moves.GROWL ]); + test("should protect the user and allies from multi-target status moves", async () => { + game.override.enemyMoveset([Moves.GROWL]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.WIDE_GUARD); + game.move.select(Moves.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); - } - ); + leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); + }); - test( - "should not protect the user and allies from single-target moves", - async () => { - game.override.enemyMoveset([ Moves.TACKLE ]); + test("should not protect the user and allies from single-target moves", async () => { + game.override.enemyMoveset([Moves.TACKLE]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); + const leadPokemon = game.scene.getPlayerField(); - game.move.select(Moves.WIDE_GUARD); + game.move.select(Moves.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SPLASH, 1); + game.move.select(Moves.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); - } - ); + expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); + }); - test( - "should protect the user from its ally's multi-target move", - async () => { - game.override.enemyMoveset([ Moves.SPLASH ]); + test("should protect the user from its ally's multi-target move", async () => { + game.override.enemyMoveset([Moves.SPLASH]); - await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]); + await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]); - const leadPokemon = game.scene.getPlayerField(); - const enemyPokemon = game.scene.getEnemyField(); + const leadPokemon = game.scene.getPlayerField(); + const enemyPokemon = game.scene.getEnemyField(); - game.move.select(Moves.WIDE_GUARD); + game.move.select(Moves.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to(CommandPhase); - game.move.select(Moves.SURF, 1); + game.move.select(Moves.SURF, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to(BerryPhase, false); - expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp()); - enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); - } - ); + expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp()); + enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); + }); }); diff --git a/test/moves/will_o_wisp.test.ts b/test/moves/will_o_wisp.test.ts index 473f0d4d0a8..0d19fec954c 100644 --- a/test/moves/will_o_wisp.test.ts +++ b/test/moves/will_o_wisp.test.ts @@ -24,7 +24,7 @@ describe("Moves - Will-O-Wisp", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.WILL_O_WISP, Moves.SPLASH ]) + .moveset([Moves.WILL_O_WISP, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -34,12 +34,12 @@ describe("Moves - Will-O-Wisp", () => { }); it("should burn the opponent", async () => { - await game.classicMode.startBattle([ Species.FEEBAS ]); + await game.classicMode.startBattle([Species.FEEBAS]); const enemy = game.scene.getEnemyPokemon()!; game.move.select(Moves.WILL_O_WISP); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceHit(); await game.toNextTurn(); diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 97f292ef6b1..19ec364618e 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -2,7 +2,12 @@ import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encount import { Status } from "#app/data/status-effect"; import { CommandPhase } from "#app/phases/command-phase"; import { MessagePhase } from "#app/phases/message-phase"; -import { MysteryEncounterBattlePhase, MysteryEncounterOptionSelectedPhase, MysteryEncounterPhase, MysteryEncounterRewardsPhase } from "#app/phases/mystery-encounter-phases"; +import { + MysteryEncounterBattlePhase, + MysteryEncounterOptionSelectedPhase, + MysteryEncounterPhase, + MysteryEncounterRewardsPhase, +} from "#app/phases/mystery-encounter-phases"; import { VictoryPhase } from "#app/phases/victory-phase"; import type MessageUiHandler from "#app/ui/message-ui-handler"; import type MysteryEncounterUiHandler from "#app/ui/mystery-encounter-ui-handler"; @@ -22,31 +27,56 @@ import { expect, vi } from "vitest"; * @param secondaryOptionSelect * @param isBattle If selecting option should lead to battle, set to `true` */ -export async function runMysteryEncounterToEnd(game: GameManager, optionNo: number, secondaryOptionSelect?: { pokemonNo: number, optionNo?: number }, isBattle: boolean = false) { +export async function runMysteryEncounterToEnd( + game: GameManager, + optionNo: number, + secondaryOptionSelect?: { pokemonNo: number; optionNo?: number }, + isBattle = false, +) { vi.spyOn(EncounterPhaseUtils, "selectPokemonForOption"); await runSelectMysteryEncounterOption(game, optionNo, secondaryOptionSelect); // run the selected options phase - game.onNextPrompt("MysteryEncounterOptionSelectedPhase", Mode.MESSAGE, () => { - const uiHandler = game.scene.ui.getHandler(); - uiHandler.processInput(Button.ACTION); - }, () => game.isCurrentPhase(MysteryEncounterBattlePhase) || game.isCurrentPhase(MysteryEncounterRewardsPhase)); + game.onNextPrompt( + "MysteryEncounterOptionSelectedPhase", + Mode.MESSAGE, + () => { + const uiHandler = game.scene.ui.getHandler(); + uiHandler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase(MysteryEncounterBattlePhase) || game.isCurrentPhase(MysteryEncounterRewardsPhase), + ); if (isBattle) { - game.onNextPrompt("DamageAnimPhase", Mode.MESSAGE, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase)); + game.onNextPrompt( + "DamageAnimPhase", + Mode.MESSAGE, + () => { + game.setMode(Mode.MESSAGE); + game.endPhase(); + }, + () => game.isCurrentPhase(CommandPhase), + ); - game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase)); + game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + game.setMode(Mode.MESSAGE); + game.endPhase(); + }, + () => game.isCurrentPhase(CommandPhase), + ); - game.onNextPrompt("CheckSwitchPhase", Mode.MESSAGE, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase)); + game.onNextPrompt( + "CheckSwitchPhase", + Mode.MESSAGE, + () => { + game.setMode(Mode.MESSAGE); + game.endPhase(); + }, + () => game.isCurrentPhase(CommandPhase), + ); // If a battle is started, fast forward to end of the battle game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { @@ -74,22 +104,36 @@ export async function runMysteryEncounterToEnd(game: GameManager, optionNo: numb } } -export async function runSelectMysteryEncounterOption(game: GameManager, optionNo: number, secondaryOptionSelect?: { pokemonNo: number, optionNo?: number }) { +export async function runSelectMysteryEncounterOption( + game: GameManager, + optionNo: number, + secondaryOptionSelect?: { pokemonNo: number; optionNo?: number }, +) { // Handle any eventual queued messages (e.g. weather phase, etc.) - game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { - const uiHandler = game.scene.ui.getHandler(); - uiHandler.processInput(Button.ACTION); - }, () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase)); + game.onNextPrompt( + "MessagePhase", + Mode.MESSAGE, + () => { + const uiHandler = game.scene.ui.getHandler(); + uiHandler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase), + ); if (game.isCurrentPhase(MessagePhase)) { await game.phaseInterceptor.run(MessagePhase); } // dispose of intro messages - game.onNextPrompt("MysteryEncounterPhase", Mode.MESSAGE, () => { - const uiHandler = game.scene.ui.getHandler(); - uiHandler.processInput(Button.ACTION); - }, () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase)); + game.onNextPrompt( + "MysteryEncounterPhase", + Mode.MESSAGE, + () => { + const uiHandler = game.scene.ui.getHandler(); + uiHandler.processInput(Button.ACTION); + }, + () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase), + ); await game.phaseInterceptor.to(MysteryEncounterPhase, true); @@ -98,10 +142,6 @@ export async function runSelectMysteryEncounterOption(game: GameManager, optionN uiHandler.unblockInput(); // input are blocked by 1s to prevent accidental input. Tests need to handle that switch (optionNo) { - default: - case 1: - // no movement needed. Default cursor position - break; case 2: uiHandler.processInput(Button.RIGHT); break; @@ -112,6 +152,9 @@ export async function runSelectMysteryEncounterOption(game: GameManager, optionN uiHandler.processInput(Button.RIGHT); uiHandler.processInput(Button.DOWN); break; + default: + // no movement needed. Default cursor position + break; } if (!isNullOrUndefined(secondaryOptionSelect?.pokemonNo)) { @@ -162,7 +205,7 @@ async function handleSecondaryOptionSelect(game: GameManager, pokemonNo: number, * @param game * @param runRewardsPhase */ -export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManager, runRewardsPhase: boolean = true) { +export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManager, runRewardsPhase = true) { game.scene.clearPhaseQueue(); game.scene.clearPhaseQueueSplice(); game.scene.getEnemyParty().forEach(p => { 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 d7f0ed6e20e..43d582c5b70 100644 --- a/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts +++ b/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts @@ -6,7 +6,10 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -19,7 +22,7 @@ import { PartyHealPhase } from "#app/phases/party-heal-phase"; import i18next from "i18next"; const namespace = "mysteryEncounters/aTrainersTest"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -41,10 +44,10 @@ describe("A Trainer's Test - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.A_TRAINERS_TEST ]); + biomeMap.set(biome, [MysteryEncounterType.A_TRAINERS_TEST]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -107,8 +110,17 @@ describe("A Trainer's Test - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(enemyField.length).toBe(1); expect(scene.currentBattle.trainer).toBeDefined(); - expect([ i18next.t("trainerNames:buck"), i18next.t("trainerNames:cheryl"), i18next.t("trainerNames:marley"), i18next.t("trainerNames:mira"), i18next.t("trainerNames:riley") ] - .map(name => name.toLowerCase()).includes(scene.currentBattle.trainer!.config.name)).toBeTruthy(); + expect( + [ + i18next.t("trainerNames:buck"), + i18next.t("trainerNames:cheryl"), + i18next.t("trainerNames:marley"), + i18next.t("trainerNames:mira"), + i18next.t("trainerNames:riley"), + ] + .map(name => name.toLowerCase()) + .includes(scene.currentBattle.trainer!.config.name), + ).toBeTruthy(); expect(enemyField[0]).toBeDefined(); }); @@ -138,7 +150,7 @@ describe("A Trainer's Test - Mystery Encounter", () => { vi.spyOn(scene, "playSoundWithoutBgm").mockImplementation(() => { return { totalDuration: 1, - destroy: () => null + destroy: () => null, } as any; }); }); diff --git a/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts b/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts index 0503a60cf1b..3e1588f3a72 100644 --- a/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts +++ b/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts @@ -4,7 +4,10 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -19,7 +22,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import i18next from "i18next"; const namespace = "mysteryEncounters/absoluteAvarice"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.PLAINS; const defaultWave = 45; @@ -42,9 +45,9 @@ describe("Absolute Avarice - Mystery Encounter", () => { vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ - [ Biome.PLAINS, [ MysteryEncounterType.ABSOLUTE_AVARICE ]], - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], - ]) + [Biome.PLAINS, [MysteryEncounterType.ABSOLUTE_AVARICE]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], + ]), ); }); @@ -85,7 +88,10 @@ describe("Absolute Avarice - Mystery Encounter", () => { it("should spawn if player has enough berries", async () => { game.override.mysteryEncounterTier(MysteryEncounterTier.GREAT); - game.override.startingHeldItems([{ name: "BERRY", count: 2, type: BerryType.SITRUS }, { name: "BERRY", count: 3, type: BerryType.GANLON }]); + game.override.startingHeldItems([ + { name: "BERRY", count: 2, type: BerryType.SITRUS }, + { name: "BERRY", count: 3, type: BerryType.GANLON }, + ]); await game.runToMysteryEncounter(); @@ -93,7 +99,10 @@ describe("Absolute Avarice - Mystery Encounter", () => { }); it("should remove all player's berries at the start of the encounter", async () => { - game.override.startingHeldItems([{ name: "BERRY", count: 2, type: BerryType.SITRUS }, { name: "BERRY", count: 3, type: BerryType.GANLON }]); + game.override.startingHeldItems([ + { name: "BERRY", count: 2, type: BerryType.SITRUS }, + { name: "BERRY", count: 3, type: BerryType.GANLON }, + ]); await game.runToMysteryEncounter(MysteryEncounterType.ABSOLUTE_AVARICE, defaultParty); @@ -129,7 +138,7 @@ describe("Absolute Avarice - Mystery Encounter", () => { expect(enemyField[0].species.speciesId).toBe(Species.GREEDENT); const moveset = enemyField[0].moveset.map(m => m?.moveId); expect(moveset?.length).toBe(4); - expect(moveset).toEqual([ Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH ]); + expect(moveset).toEqual([Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.CRUNCH]); const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); expect(movePhases.length).toBe(1); @@ -145,9 +154,13 @@ describe("Absolute Avarice - Mystery Encounter", () => { for (const partyPokemon of scene.getPlayerParty()) { const pokemonId = partyPokemon.id; - const pokemonItems = scene.findModifiers(m => m instanceof PokemonHeldItemModifier - && (m as PokemonHeldItemModifier).pokemonId === pokemonId, true) as PokemonHeldItemModifier[]; - const revSeed = pokemonItems.find(i => i.type.name === i18next.t("modifierType:ModifierType.REVIVER_SEED.name")); + const pokemonItems = scene.findModifiers( + m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === pokemonId, + true, + ) as PokemonHeldItemModifier[]; + const revSeed = pokemonItems.find( + i => i.type.name === i18next.t("modifierType:ModifierType.REVIVER_SEED.name"), + ); expect(revSeed).toBeDefined; expect(revSeed?.stackCount).toBe(1); } @@ -171,7 +184,11 @@ describe("Absolute Avarice - Mystery Encounter", () => { }); it("Should return 3 (2/5ths floored) berries if 8 were stolen", { retry: 5 }, async () => { - game.override.startingHeldItems([{ name: "BERRY", count: 2, type: BerryType.SITRUS }, { name: "BERRY", count: 3, type: BerryType.GANLON }, { name: "BERRY", count: 3, type: BerryType.APICOT }]); + game.override.startingHeldItems([ + { name: "BERRY", count: 2, type: BerryType.SITRUS }, + { name: "BERRY", count: 3, type: BerryType.GANLON }, + { name: "BERRY", count: 3, type: BerryType.APICOT }, + ]); await game.runToMysteryEncounter(MysteryEncounterType.ABSOLUTE_AVARICE, defaultParty); @@ -187,7 +204,11 @@ describe("Absolute Avarice - Mystery Encounter", () => { }); it("Should return 2 (2/5ths floored) berries if 7 were stolen", { retry: 5 }, async () => { - game.override.startingHeldItems([{ name: "BERRY", count: 2, type: BerryType.SITRUS }, { name: "BERRY", count: 3, type: BerryType.GANLON }, { name: "BERRY", count: 2, type: BerryType.APICOT }]); + game.override.startingHeldItems([ + { name: "BERRY", count: 2, type: BerryType.SITRUS }, + { name: "BERRY", count: 3, type: BerryType.GANLON }, + { name: "BERRY", count: 2, type: BerryType.APICOT }, + ]); await game.runToMysteryEncounter(MysteryEncounterType.ABSOLUTE_AVARICE, defaultParty); @@ -240,7 +261,7 @@ describe("Absolute Avarice - Mystery Encounter", () => { expect(greedent.species.speciesId).toBe(Species.GREEDENT); const moveset = greedent.moveset.map(m => m?.moveId); expect(moveset?.length).toBe(4); - expect(moveset).toEqual([ Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.SLACK_OFF ]); + expect(moveset).toEqual([Moves.THRASH, Moves.BODY_PRESS, Moves.STUFF_CHEEKS, Moves.SLACK_OFF]); }); it("should leave encounter without battle", async () => { diff --git a/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts b/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts index b88e02be6ab..3c7bda8febd 100644 --- a/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts +++ b/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts @@ -22,7 +22,7 @@ import { Abilities } from "#enums/abilities"; const namespace = "mysteryEncounters/anOfferYouCantRefuse"; /** Gyarados for Indimidate */ -const defaultParty = [ Species.GYARADOS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.GYARADOS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -38,17 +38,18 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { beforeEach(async () => { game = new GameManager(phaserGame); scene = game.scene; - game.override.mysteryEncounterChance(100) + game.override + .mysteryEncounterChance(100) .startingWave(defaultWave) .startingBiome(defaultBiome) .disableTrainerWaves() .ability(Abilities.INTIMIDATE); // Extortion ability const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE ]); + biomeMap.set(biome, [MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -67,10 +68,12 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { expect(AnOfferYouCantRefuseEncounter.dialogue).toBeDefined(); expect(AnOfferYouCantRefuseEncounter.dialogue.intro).toStrictEqual([ { text: `${namespace}:intro` }, - { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue` } + { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue` }, ]); expect(AnOfferYouCantRefuseEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); - expect(AnOfferYouCantRefuseEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); + expect(AnOfferYouCantRefuseEncounter.dialogue.encounterOptionsDialogue?.description).toBe( + `${namespace}:description`, + ); expect(AnOfferYouCantRefuseEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); expect(AnOfferYouCantRefuseEncounter.options.length).toBe(3); }); @@ -80,7 +83,9 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { game.override.startingBiome(Biome.VOLCANO); await game.runToMysteryEncounter(); - expect(scene.currentBattle?.mysteryEncounter?.encounterType).not.toBe(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE); + expect(scene.currentBattle?.mysteryEncounter?.encounterType).not.toBe( + MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, + ); }); it("should initialize fully ", async () => { @@ -96,10 +101,14 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { expect(AnOfferYouCantRefuseEncounter.dialogueTokens?.strongestPokemon).toBeDefined(); expect(AnOfferYouCantRefuseEncounter.dialogueTokens?.price).toBeDefined(); - expect(AnOfferYouCantRefuseEncounter.dialogueTokens?.option2PrimaryAbility).toBe(i18next.t("ability:intimidate.name")); + expect(AnOfferYouCantRefuseEncounter.dialogueTokens?.option2PrimaryAbility).toBe( + i18next.t("ability:intimidate.name"), + ); expect(AnOfferYouCantRefuseEncounter.dialogueTokens?.moveOrAbility).toBe(i18next.t("ability:intimidate.name")); expect(AnOfferYouCantRefuseEncounter.misc.pokemon instanceof PlayerPokemon).toBeTruthy(); - expect(AnOfferYouCantRefuseEncounter.misc?.price?.toString()).toBe(AnOfferYouCantRefuseEncounter.dialogueTokens?.price); + expect(AnOfferYouCantRefuseEncounter.misc?.price?.toString()).toBe( + AnOfferYouCantRefuseEncounter.dialogueTokens?.price, + ); expect(onInitResult).toBe(true); }); @@ -187,27 +196,29 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { it("should award EXP to a pokemon with an ability in EXTORTION_ABILITIES", async () => { await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, defaultParty); const party = scene.getPlayerParty(); - const gyarados = party.find((pkm) => pkm.species.speciesId === Species.GYARADOS)!; + const gyarados = party.find(pkm => pkm.species.speciesId === Species.GYARADOS)!; const expBefore = gyarados.exp; await runMysteryEncounterToEnd(game, 2); await game.phaseInterceptor.to(SelectModifierPhase, false); - expect(gyarados.exp).toBe(expBefore + Math.floor(getPokemonSpecies(Species.LIEPARD).baseExp * defaultWave / 5 + 1)); + expect(gyarados.exp).toBe( + expBefore + Math.floor((getPokemonSpecies(Species.LIEPARD).baseExp * defaultWave) / 5 + 1), + ); }); it("should award EXP to a pokemon with a move in EXTORTION_MOVES", async () => { game.override.ability(Abilities.SYNCHRONIZE); // Not an extortion ability, so we can test extortion move - await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, [ Species.ABRA ]); + await game.runToMysteryEncounter(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE, [Species.ABRA]); const party = scene.getPlayerParty(); - const abra = party.find((pkm) => pkm.species.speciesId === Species.ABRA)!; - abra.moveset = [ new PokemonMove(Moves.BEAT_UP) ]; + const abra = party.find(pkm => pkm.species.speciesId === Species.ABRA)!; + abra.moveset = [new PokemonMove(Moves.BEAT_UP)]; const expBefore = abra.exp; await runMysteryEncounterToEnd(game, 2); await game.phaseInterceptor.to(SelectModifierPhase, false); - expect(abra.exp).toBe(expBefore + Math.floor(getPokemonSpecies(Species.LIEPARD).baseExp * defaultWave / 5 + 1)); + expect(abra.exp).toBe(expBefore + Math.floor((getPokemonSpecies(Species.LIEPARD).baseExp * defaultWave) / 5 + 1)); }); it("Should update the player's money properly", async () => { diff --git a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts index d623d1ce7a8..e19726f49fd 100644 --- a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts +++ b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts @@ -4,7 +4,10 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { Mode } from "#app/ui/ui"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; @@ -20,7 +23,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { Abilities } from "#enums/abilities"; const namespace = "mysteryEncounters/berriesAbound"; -const defaultParty = [ Species.PYUKUMUKU, Species.MAGIKARP, Species.PIKACHU ]; +const defaultParty = [Species.PYUKUMUKU, Species.MAGIKARP, Species.PIKACHU]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -36,7 +39,8 @@ describe("Berries Abound - Mystery Encounter", () => { beforeEach(async () => { game = new GameManager(phaserGame); scene = game.scene; - game.override.mysteryEncounterChance(100) + game.override + .mysteryEncounterChance(100) .mysteryEncounterTier(MysteryEncounterTier.COMMON) .startingWave(defaultWave) .startingBiome(defaultBiome) @@ -47,9 +51,7 @@ describe("Berries Abound - Mystery Encounter", () => { .enemyPassiveAbility(Abilities.BALL_FETCH); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.BERRIES_ABOUND ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.BERRIES_ABOUND]]]), ); }); @@ -152,7 +154,9 @@ describe("Berries Abound - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); for (const option of modifierSelectHandler.options) { expect(option.modifierTypeOption.type.id).toContain("BERRY"); @@ -191,7 +195,7 @@ describe("Berries Abound - Mystery Encounter", () => { expect(enemyField[0].species.speciesId).toBe(speciesToSpawn); // Should be enraged - expect(enemyField[0].summonData.statStages).toEqual([ 0, 1, 0, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([0, 1, 0, 1, 1, 0, 0]); expect(encounterTextSpy).toHaveBeenCalledWith(`${namespace}:option.2.selected_bad`); }); @@ -215,7 +219,7 @@ describe("Berries Abound - Mystery Encounter", () => { expect(enemyField[0].species.speciesId).toBe(speciesToSpawn); // Should be enraged - expect(enemyField[0].summonData.statStages).toEqual([ 1, 1, 1, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 1, 0, 0]); expect(encounterTextSpy).toHaveBeenCalledWith(`${namespace}:option.2.selected_bad`); }); @@ -235,7 +239,9 @@ describe("Berries Abound - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); for (const option of modifierSelectHandler.options) { expect(option.modifierTypeOption.type.id).toContain("BERRY"); 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 6827ea5a463..9befe77e688 100644 --- a/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts +++ b/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts @@ -4,7 +4,11 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; @@ -22,7 +26,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; const namespace = "mysteryEncounters/bugTypeSuperfan"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.WEEDLE ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.WEEDLE]; const defaultBiome = Biome.CAVE; const defaultWave = 24; @@ -49,7 +53,7 @@ const POOL_1_POKEMON = [ Species.CHARJABUG, Species.RIBOMBEE, Species.SPIDOPS, - Species.LOKIX + Species.LOKIX, ]; const POOL_2_POKEMON = [ @@ -78,26 +82,26 @@ const POOL_2_POKEMON = [ Species.KLEAVOR, ]; -const POOL_3_POKEMON: { species: Species, formIndex?: number }[] = [ +const POOL_3_POKEMON: { species: Species; formIndex?: number }[] = [ { species: Species.PINSIR, - formIndex: 1 + formIndex: 1, }, { species: Species.SCIZOR, - formIndex: 1 + formIndex: 1, }, { species: Species.HERACROSS, - formIndex: 1 + formIndex: 1, }, { species: Species.ORBEETLE, - formIndex: 1 + formIndex: 1, }, { species: Species.CENTISKORCH, - formIndex: 1 + formIndex: 1, }, { species: Species.DURANT, @@ -110,35 +114,19 @@ const POOL_3_POKEMON: { species: Species, formIndex?: number }[] = [ }, ]; -const POOL_4_POKEMON = [ - Species.GENESECT, - Species.SLITHER_WING, - Species.BUZZWOLE, - Species.PHEROMOSA -]; +const POOL_4_POKEMON = [Species.GENESECT, Species.SLITHER_WING, Species.BUZZWOLE, Species.PHEROMOSA]; const PHYSICAL_TUTOR_MOVES = [ Moves.MEGAHORN, Moves.X_SCISSOR, Moves.ATTACK_ORDER, Moves.PIN_MISSILE, - Moves.FIRST_IMPRESSION + Moves.FIRST_IMPRESSION, ]; -const SPECIAL_TUTOR_MOVES = [ - Moves.SILVER_WIND, - Moves.BUG_BUZZ, - Moves.SIGNAL_BEAM, - Moves.POLLEN_PUFF -]; +const SPECIAL_TUTOR_MOVES = [Moves.SILVER_WIND, Moves.BUG_BUZZ, Moves.SIGNAL_BEAM, Moves.POLLEN_PUFF]; -const STATUS_TUTOR_MOVES = [ - Moves.STRING_SHOT, - Moves.STICKY_WEB, - Moves.SILK_TRAP, - Moves.RAGE_POWDER, - Moves.HEAL_ORDER -]; +const STATUS_TUTOR_MOVES = [Moves.STRING_SHOT, Moves.STICKY_WEB, Moves.SILK_TRAP, Moves.RAGE_POWDER, Moves.HEAL_ORDER]; const MISC_TUTOR_MOVES = [ Moves.BUG_BITE, @@ -147,7 +135,7 @@ const MISC_TUTOR_MOVES = [ Moves.QUIVER_DANCE, Moves.TAIL_GLOW, Moves.INFESTATION, - Moves.U_TURN + Moves.U_TURN, ]; describe("Bug-Type Superfan - Mystery Encounter", () => { @@ -168,9 +156,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { game.override.disableTrainerWaves(); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.BUG_TYPE_SUPERFAN ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.BUG_TYPE_SUPERFAN]]]), ); }); @@ -400,12 +386,12 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(option.dialogue).toStrictEqual({ buttonLabel: `${namespace}:option.2.label`, buttonTooltip: `${namespace}:option.2.tooltip`, - disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip` + disabledButtonTooltip: `${namespace}:option.2.disabled_tooltip`, }); }); it("should NOT be selectable if the player doesn't have any Bug types", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.ABRA ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [Species.ABRA]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -431,21 +417,25 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(2); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("SUPER_LURE"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("GREAT_BALL"); }); it("should proceed to rewards screen with 2-3 Bug Types reward options", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.BUTTERFREE, Species.BEEDRILL ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [Species.BUTTERFREE, Species.BEEDRILL]); await runMysteryEncounterToEnd(game, 2); expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("QUICK_CLAW"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("MAX_LURE"); @@ -453,14 +443,21 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { }); it("should proceed to rewards screen with 4-5 Bug Types reward options", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.BUTTERFREE, Species.BEEDRILL, Species.GALVANTULA, Species.VOLCARONA ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ + Species.BUTTERFREE, + Species.BEEDRILL, + Species.GALVANTULA, + Species.VOLCARONA, + ]); await runMysteryEncounterToEnd(game, 2); expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("GRIP_CLAW"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("MAX_LURE"); @@ -468,14 +465,23 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { }); it("should proceed to rewards screen with 6 Bug Types reward options (including form change item)", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.BUTTERFREE, Species.BEEDRILL, Species.GALVANTULA, Species.VOLCARONA, Species.ANORITH, Species.GENESECT ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ + Species.BUTTERFREE, + Species.BEEDRILL, + Species.GALVANTULA, + Species.VOLCARONA, + Species.ANORITH, + Species.GENESECT, + ]); await runMysteryEncounterToEnd(game, 2); expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("MASTER_BALL"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("MEGA_BRACELET"); @@ -538,9 +544,10 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { it("should remove the gifted item and proceed to rewards screen", async () => { game.override.startingHeldItems([{ name: "GRIP_CLAW", count: 1 }]); - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.BUTTERFREE ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [Species.BUTTERFREE]); - const gripClawCountBefore = scene.findModifier(m => m instanceof ContactHeldItemTransferChanceModifier)?.stackCount ?? 0; + const gripClawCountBefore = + scene.findModifier(m => m instanceof ContactHeldItemTransferChanceModifier)?.stackCount ?? 0; await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); @@ -548,12 +555,15 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(2); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("MYSTERY_ENCOUNTER_GOLDEN_BUG_NET"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toBe("REVIVER_SEED"); - const gripClawCountAfter = scene.findModifier(m => m instanceof ContactHeldItemTransferChanceModifier)?.stackCount ?? 0; + const gripClawCountAfter = + scene.findModifier(m => m instanceof ContactHeldItemTransferChanceModifier)?.stackCount ?? 0; expect(gripClawCountBefore - 1).toBe(gripClawCountAfter); }); @@ -561,7 +571,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { game.override.startingHeldItems([{ name: "GRIP_CLAW", count: 1 }]); const leaveEncounterWithoutBattleSpy = vi.spyOn(encounterPhaseUtils, "leaveEncounterWithoutBattle"); - await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [ Species.BUTTERFREE ]); + await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [Species.BUTTERFREE]); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); expect(leaveEncounterWithoutBattleSpy).toBeCalled(); diff --git a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts index 2f690a1d990..4bbe76e5c72 100644 --- a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -8,7 +8,10 @@ import { getPokemonSpecies } from "#app/data/pokemon-species"; import * as BattleAnims from "#app/data/battle-anims"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import type Pokemon from "#app/field/pokemon"; @@ -36,7 +39,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { NewBattlePhase } from "#app/phases/new-battle-phase"; const namespace = "mysteryEncounters/clowningAround"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -58,9 +61,7 @@ describe("Clowning Around - Mystery Encounter", () => { game.override.disableTrainerWaves(); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.CLOWNING_AROUND ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.CLOWNING_AROUND]]]), ); }); @@ -116,13 +117,13 @@ describe("Clowning Around - Mystery Encounter", () => { expect(config.pokemonConfigs?.[0]).toEqual({ species: getPokemonSpecies(Species.MR_MIME), isBoss: true, - moveSet: [ Moves.TEETER_DANCE, Moves.ALLY_SWITCH, Moves.DAZZLING_GLEAM, Moves.PSYCHIC ] + moveSet: [Moves.TEETER_DANCE, Moves.ALLY_SWITCH, Moves.DAZZLING_GLEAM, Moves.PSYCHIC], }); expect(config.pokemonConfigs?.[1]).toEqual({ species: getPokemonSpecies(Species.BLACEPHALON), customPokemonData: expect.anything(), isBoss: true, - moveSet: [ Moves.TRICK, Moves.HYPNOSIS, Moves.SHADOW_BALL, Moves.MIND_BLOWN ] + moveSet: [Moves.TRICK, Moves.HYPNOSIS, Moves.SHADOW_BALL, Moves.MIND_BLOWN], }); expect(config.pokemonConfigs?.[1].customPokemonData?.types.length).toBe(2); expect([ @@ -140,7 +141,7 @@ describe("Clowning Around - Mystery Encounter", () => { Abilities.MISTY_SURGE, Abilities.MAGICIAN, Abilities.SHEER_FORCE, - Abilities.PRANKSTER + Abilities.PRANKSTER, ]).toContain(config.pokemonConfigs?.[1].customPokemonData?.ability); expect(ClowningAroundEncounter.misc.ability).toBe(config.pokemonConfigs?.[1].customPokemonData?.ability); await vi.waitFor(() => expect(moveInitSpy).toHaveBeenCalled()); @@ -175,9 +176,19 @@ describe("Clowning Around - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(enemyField.length).toBe(2); expect(enemyField[0].species.speciesId).toBe(Species.MR_MIME); - expect(enemyField[0].moveset).toEqual([ new PokemonMove(Moves.TEETER_DANCE), new PokemonMove(Moves.ALLY_SWITCH), new PokemonMove(Moves.DAZZLING_GLEAM), new PokemonMove(Moves.PSYCHIC) ]); + expect(enemyField[0].moveset).toEqual([ + new PokemonMove(Moves.TEETER_DANCE), + new PokemonMove(Moves.ALLY_SWITCH), + new PokemonMove(Moves.DAZZLING_GLEAM), + new PokemonMove(Moves.PSYCHIC), + ]); expect(enemyField[1].species.speciesId).toBe(Species.BLACEPHALON); - expect(enemyField[1].moveset).toEqual([ new PokemonMove(Moves.TRICK), new PokemonMove(Moves.HYPNOSIS), new PokemonMove(Moves.SHADOW_BALL), new PokemonMove(Moves.MIND_BLOWN) ]); + expect(enemyField[1].moveset).toEqual([ + new PokemonMove(Moves.TRICK), + new PokemonMove(Moves.HYPNOSIS), + new PokemonMove(Moves.SHADOW_BALL), + new PokemonMove(Moves.MIND_BLOWN), + ]); // Should have used moves pre-battle const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); @@ -253,14 +264,14 @@ describe("Clowning Around - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); // Set some moves on party for attack type booster generation - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.TACKLE), new PokemonMove(Moves.THIEF) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.TACKLE), new PokemonMove(Moves.THIEF)]; // 2 Sitrus Berries on lead scene.modifiers = []; - let itemType = generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ]) as PokemonHeldItemModifierType; + let itemType = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS]) as PokemonHeldItemModifierType; await addItemToPokemon(scene, scene.getPlayerParty()[0], 2, itemType); // 2 Ganlon Berries on lead - itemType = generateModifierType(modifierTypes.BERRY, [ BerryType.GANLON ]) as PokemonHeldItemModifierType; + itemType = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON]) as PokemonHeldItemModifierType; await addItemToPokemon(scene, scene.getPlayerParty()[0], 2, itemType); // 5 Golden Punch on lead (ultra) itemType = generateModifierType(modifierTypes.GOLDEN_PUNCH) as PokemonHeldItemModifierType; @@ -338,9 +349,9 @@ describe("Clowning Around - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); // Same type moves on lead - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.ICE_BEAM), new PokemonMove(Moves.SURF) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.ICE_BEAM), new PokemonMove(Moves.SURF)]; // Different type moves on second - scene.getPlayerParty()[1].moveset = [ new PokemonMove(Moves.GRASS_KNOT), new PokemonMove(Moves.ELECTRO_BALL) ]; + scene.getPlayerParty()[1].moveset = [new PokemonMove(Moves.GRASS_KNOT), new PokemonMove(Moves.ELECTRO_BALL)]; // No moves on third scene.getPlayerParty()[2].moveset = []; await runMysteryEncounterToEnd(game, 3); @@ -351,11 +362,11 @@ describe("Clowning Around - Mystery Encounter", () => { expect(leadTypesAfter.length).toBe(2); expect(leadTypesAfter[0]).toBe(PokemonType.WATER); - expect([ PokemonType.WATER, PokemonType.ICE ].includes(leadTypesAfter[1])).toBeFalsy(); + expect([PokemonType.WATER, PokemonType.ICE].includes(leadTypesAfter[1])).toBeFalsy(); expect(secondaryTypesAfter.length).toBe(2); expect(secondaryTypesAfter[0]).toBe(PokemonType.GHOST); - expect([ PokemonType.GHOST, PokemonType.POISON ].includes(secondaryTypesAfter[1])).toBeFalsy(); - expect([ PokemonType.GRASS, PokemonType.ELECTRIC ].includes(secondaryTypesAfter[1])).toBeTruthy(); + expect([PokemonType.GHOST, PokemonType.POISON].includes(secondaryTypesAfter[1])).toBeFalsy(); + expect([PokemonType.GRASS, PokemonType.ELECTRIC].includes(secondaryTypesAfter[1])).toBeTruthy(); expect(thirdTypesAfter.length).toBe(2); expect(thirdTypesAfter[0]).toBe(PokemonType.PSYCHIC); expect(secondaryTypesAfter[1]).not.toBe(PokemonType.PSYCHIC); @@ -372,7 +383,12 @@ describe("Clowning Around - Mystery Encounter", () => { }); }); -async function addItemToPokemon(scene: BattleScene, pokemon: Pokemon, stackCount: number, itemType: PokemonHeldItemModifierType) { +async function addItemToPokemon( + scene: BattleScene, + pokemon: Pokemon, + stackCount: number, + itemType: PokemonHeldItemModifierType, +) { const itemMod = itemType.newModifier(pokemon) as PokemonHeldItemModifier; itemMod.stackCount = stackCount; scene.addModifier(itemMod, true, false, false, true); diff --git a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts index 46217cca5e2..a4c1052463c 100644 --- a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts +++ b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts @@ -4,7 +4,11 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -21,7 +25,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { LearnMovePhase } from "#app/phases/learn-move-phase"; const namespace = "mysteryEncounters/dancingLessons"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.PLAINS; const defaultWave = 45; @@ -44,9 +48,9 @@ describe("Dancing Lessons - Mystery Encounter", () => { vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ - [ Biome.PLAINS, [ MysteryEncounterType.DANCING_LESSONS ]], - [ Biome.SPACE, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], - ]) + [Biome.PLAINS, [MysteryEncounterType.DANCING_LESSONS]], + [Biome.SPACE, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], + ]), ); }); @@ -107,7 +111,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(enemyField.length).toBe(1); expect(enemyField[0].species.speciesId).toBe(Species.ORICORIO); - expect(enemyField[0].summonData.statStages).toEqual([ 1, 1, 1, 1, 0, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 0, 0, 0]); const moveset = enemyField[0].moveset.map(m => m?.moveId); expect(moveset.some(m => m === Moves.REVELATION_DANCE)).toBeTruthy(); @@ -129,7 +133,9 @@ describe("Dancing Lessons - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); // Should fill remaining expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toContain("BATON"); }); @@ -195,7 +201,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { it("should add Oricorio to the party", async () => { await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); const partyCountBefore = scene.getPlayerParty().length; - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.DRAGON_DANCE) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.DRAGON_DANCE)]; await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); const partyCountAfter = scene.getPlayerParty().length; @@ -210,7 +216,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have a Dance type move", async () => { await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); const partyCountBefore = scene.getPlayerParty().length; - scene.getPlayerParty().forEach(p => p.moveset = []); + scene.getPlayerParty().forEach(p => (p.moveset = [])); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -234,7 +240,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.DRAGON_DANCE) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.DRAGON_DANCE)]; await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); expect(leaveEncounterWithoutBattleSpy).toBeCalled(); diff --git a/test/mystery-encounter/encounters/delibirdy-encounter.test.ts b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts index baea430fdaf..94faf070a39 100644 --- a/test/mystery-encounter/encounters/delibirdy-encounter.test.ts +++ b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts @@ -4,21 +4,33 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { DelibirdyEncounter } from "#app/data/mystery-encounters/encounters/delibirdy-encounter"; import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters"; import type { MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; -import { BerryModifier, HealingBoosterModifier, HitHealModifier, LevelIncrementBoosterModifier, MoneyMultiplierModifier, PokemonInstantReviveModifier, PokemonNatureWeightModifier, PreserveBerryModifier } from "#app/modifier/modifier"; +import { + BerryModifier, + HealingBoosterModifier, + HitHealModifier, + LevelIncrementBoosterModifier, + MoneyMultiplierModifier, + PokemonInstantReviveModifier, + PokemonNatureWeightModifier, + PreserveBerryModifier, +} from "#app/modifier/modifier"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { modifierTypes } from "#app/modifier/modifier-type"; import { BerryType } from "#enums/berry-type"; const namespace = "mysteryEncounters/delibirdy"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -40,9 +52,7 @@ describe("Delibird-y - Mystery Encounter", () => { game.override.disableTrainerWaves(); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.DELIBIRDY ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.DELIBIRDY]]]), ); }); @@ -98,7 +108,8 @@ describe("Delibird-y - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DELIBIRDY, defaultParty); await runMysteryEncounterToEnd(game, 1); - const price = (scene.currentBattle.mysteryEncounter?.options[0].requirements[0] as MoneyRequirement).requiredMoney; + const price = (scene.currentBattle.mysteryEncounter?.options[0].requirements[0] as MoneyRequirement) + .requiredMoney; expect(updateMoneySpy).toHaveBeenCalledWith(-price, true, false); expect(scene.money).toBe(initialMoney - price); @@ -190,7 +201,7 @@ describe("Delibird-y - Mystery Encounter", () => { // Set 2 Sitrus berries on party lead scene.modifiers = []; - const sitrus = generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ])!; + const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; sitrusMod.stackCount = 2; scene.addModifier(sitrusMod, true, false, false, true); @@ -235,7 +246,7 @@ describe("Delibird-y - Mystery Encounter", () => { const candyJar = generateModifierType(modifierTypes.CANDY_JAR)!.newModifier() as LevelIncrementBoosterModifier; candyJar.stackCount = 99; scene.addModifier(candyJar, true, false, false, true); - const sitrus = generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ])!; + const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; // Sitrus berries on party const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; 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 224a4403942..d4b0de30535 100644 --- a/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts +++ b/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts @@ -16,7 +16,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; const namespace = "mysteryEncounters/departmentStoreSale"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.PLAINS; const defaultWave = 37; @@ -38,10 +38,10 @@ describe("Department Store Sale - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); CIVILIZATION_ENCOUNTER_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.DEPARTMENT_STORE_SALE ]); + biomeMap.set(biome, [MysteryEncounterType.DEPARTMENT_STORE_SALE]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -63,10 +63,12 @@ describe("Department Store Sale - Mystery Encounter", () => { { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue`, - } + }, ]); expect(DepartmentStoreSaleEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); - expect(DepartmentStoreSaleEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); + expect(DepartmentStoreSaleEncounter.dialogue.encounterOptionsDialogue?.description).toBe( + `${namespace}:description`, + ); expect(DepartmentStoreSaleEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); expect(DepartmentStoreSaleEncounter.options.length).toBe(4); }); @@ -97,7 +99,9 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); for (const option of modifierSelectHandler.options) { expect(option.modifierTypeOption.type.id).toContain("TM_"); @@ -132,11 +136,15 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); for (const option of modifierSelectHandler.options) { - expect(option.modifierTypeOption.type.id.includes("PP_UP") || - option.modifierTypeOption.type.id.includes("BASE_STAT_BOOSTER")).toBeTruthy(); + expect( + option.modifierTypeOption.type.id.includes("PP_UP") || + option.modifierTypeOption.type.id.includes("BASE_STAT_BOOSTER"), + ).toBeTruthy(); } }); @@ -168,11 +176,15 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); for (const option of modifierSelectHandler.options) { - expect(option.modifierTypeOption.type.id.includes("DIRE_HIT") || - option.modifierTypeOption.type.id.includes("TEMP_STAT_STAGE_BOOSTER")).toBeTruthy(); + expect( + option.modifierTypeOption.type.id.includes("DIRE_HIT") || + option.modifierTypeOption.type.id.includes("TEMP_STAT_STAGE_BOOSTER"), + ).toBeTruthy(); } }); @@ -204,7 +216,9 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); for (const option of modifierSelectHandler.options) { expect(option.modifierTypeOption.type.id).toContain("BALL"); diff --git a/test/mystery-encounter/encounters/field-trip-encounter.test.ts b/test/mystery-encounter/encounters/field-trip-encounter.test.ts index b831a52f116..8bd35d6013f 100644 --- a/test/mystery-encounter/encounters/field-trip-encounter.test.ts +++ b/test/mystery-encounter/encounters/field-trip-encounter.test.ts @@ -17,7 +17,7 @@ import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import i18next from "i18next"; const namespace = "mysteryEncounters/fieldTrip"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -37,12 +37,10 @@ describe("Field Trip - Mystery Encounter", () => { game.override.startingWave(defaultWave); game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - game.override.moveset([ Moves.TACKLE, Moves.UPROAR, Moves.SWORDS_DANCE ]); + game.override.moveset([Moves.TACKLE, Moves.UPROAR, Moves.SWORDS_DANCE]); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.FIELD_TRIP ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.FIELD_TRIP]]]), ); }); @@ -60,12 +58,12 @@ describe("Field Trip - Mystery Encounter", () => { expect(FieldTripEncounter.dialogue).toBeDefined(); expect(FieldTripEncounter.dialogue.intro).toStrictEqual([ { - text: `${namespace}:intro` + text: `${namespace}:intro`, }, { speaker: `${namespace}:speaker`, - text: `${namespace}:intro_dialogue` - } + text: `${namespace}:intro_dialogue`, + }, ]); expect(FieldTripEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); expect(FieldTripEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); @@ -91,7 +89,9 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(0); }); @@ -101,13 +101,25 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_attack")); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_defense")); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_speed")); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.DIRE_HIT.name")); - expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.RARER_CANDY.name")); + expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_attack"), + ); + expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_defense"), + ); + expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_speed"), + ); + expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.DIRE_HIT.name"), + ); + expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.RARER_CANDY.name"), + ); }); it("should leave encounter without battle", async () => { @@ -138,7 +150,9 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(0); }); @@ -148,13 +162,25 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_sp_atk")); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_sp_def")); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_speed")); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.DIRE_HIT.name")); - expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.RARER_CANDY.name")); + expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_sp_atk"), + ); + expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_sp_def"), + ); + expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_speed"), + ); + expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.DIRE_HIT.name"), + ); + expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.RARER_CANDY.name"), + ); }); it("should leave encounter without battle", async () => { @@ -185,7 +211,9 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(0); }); @@ -196,14 +224,32 @@ describe("Field Trip - Mystery Encounter", () => { await game.phaseInterceptor.to(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_accuracy")); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe(i18next.t("modifierType:TempStatStageBoosterItem.x_speed")); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", { modifierCount: 5, pokeballName: i18next.t("pokeball:greatBall") })); - expect(i18next.t).toHaveBeenCalledWith(("modifierType:ModifierType.AddPokeballModifierType.name"), expect.objectContaining({ modifierCount: 5 })); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.IV_SCANNER.name")); - expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe(i18next.t("modifierType:ModifierType.RARER_CANDY.name")); + expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_accuracy"), + ); + expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:TempStatStageBoosterItem.x_speed"), + ); + expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", { + modifierCount: 5, + pokeballName: i18next.t("pokeball:greatBall"), + }), + ); + expect(i18next.t).toHaveBeenCalledWith( + "modifierType:ModifierType.AddPokeballModifierType.name", + expect.objectContaining({ modifierCount: 5 }), + ); + expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.IV_SCANNER.name"), + ); + expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe( + i18next.t("modifierType:ModifierType.RARER_CANDY.name"), + ); }); it("should leave encounter without battle", async () => { diff --git a/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts b/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts index a49cadb5549..3d311134d4e 100644 --- a/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts +++ b/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts @@ -9,7 +9,11 @@ import { Gender } from "#app/data/gender"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import * as BattleAnims from "#app/data/battle-anims"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { AttackTypeBoosterModifier, PokemonHeldItemModifier } from "#app/modifier/modifier"; @@ -29,7 +33,7 @@ import { StatusEffect } from "#enums/status-effect"; const namespace = "mysteryEncounters/fieryFallout"; /** Arcanine and Ninetails for 2 Fire types. Lapras, Gengar, Abra for burnable mon. */ -const defaultParty = [ Species.ARCANINE, Species.NINETALES, Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.ARCANINE, Species.NINETALES, Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.VOLCANO; const defaultWave = 56; @@ -45,17 +49,18 @@ describe("Fiery Fallout - Mystery Encounter", () => { beforeEach(async () => { game = new GameManager(phaserGame); scene = game.scene; - game.override.mysteryEncounterChance(100) + game.override + .mysteryEncounterChance(100) .startingWave(defaultWave) .startingBiome(defaultBiome) .disableTrainerWaves() - .moveset([ Moves.PAYBACK, Moves.THUNDERBOLT ]); // Required for attack type booster item generation + .moveset([Moves.PAYBACK, Moves.THUNDERBOLT]); // Required for attack type booster item generation vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIERY_FALLOUT ]], - [ Biome.MOUNTAIN, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], - ]) + [Biome.VOLCANO, [MysteryEncounterType.FIERY_FALLOUT]], + [Biome.MOUNTAIN, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], + ]), ); }); @@ -114,20 +119,20 @@ describe("Fiery Fallout - Mystery Encounter", () => { species: getPokemonSpecies(Species.VOLCARONA), isBoss: false, gender: Gender.MALE, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: expect.any(Function) + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: expect.any(Function), }, { species: getPokemonSpecies(Species.VOLCARONA), isBoss: false, gender: Gender.FEMALE, - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: expect.any(Function) - } + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: expect.any(Function), + }, ], doubleBattle: true, - disableSwitch: true - } + disableSwitch: true, + }, ]); expect(weatherSpy).toHaveBeenCalledTimes(1); await vi.waitFor(() => expect(moveInitSpy).toHaveBeenCalled()); @@ -177,8 +182,10 @@ describe("Fiery Fallout - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const leadPokemonId = scene.getPlayerParty()?.[0].id; - const leadPokemonItems = scene.findModifiers(m => m instanceof PokemonHeldItemModifier - && (m as PokemonHeldItemModifier).pokemonId === leadPokemonId, true) as PokemonHeldItemModifier[]; + const leadPokemonItems = scene.findModifiers( + m => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === leadPokemonId, + true, + ) as PokemonHeldItemModifier[]; const item = leadPokemonItems.find(i => i instanceof AttackTypeBoosterModifier); expect(item).toBeDefined; }); @@ -204,22 +211,30 @@ describe("Fiery Fallout - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, defaultParty); const party = scene.getPlayerParty(); - const lapras = party.find((pkm) => pkm.species.speciesId === Species.LAPRAS)!; + const lapras = party.find(pkm => pkm.species.speciesId === Species.LAPRAS)!; lapras.status = new Status(StatusEffect.POISON); - const abra = party.find((pkm) => pkm.species.speciesId === Species.ABRA)!; + const abra = party.find(pkm => pkm.species.speciesId === Species.ABRA)!; vi.spyOn(abra, "isAllowedInBattle").mockReturnValue(false); await runMysteryEncounterToEnd(game, 2); - const burnablePokemon = party.filter((pkm) => pkm.isAllowedInBattle() && !pkm.getTypes().includes(PokemonType.FIRE)); - const notBurnablePokemon = party.filter((pkm) => !pkm.isAllowedInBattle() || pkm.getTypes().includes(PokemonType.FIRE)); + const burnablePokemon = party.filter( + pkm => pkm.isAllowedInBattle() && !pkm.getTypes().includes(PokemonType.FIRE), + ); + const notBurnablePokemon = party.filter( + pkm => !pkm.isAllowedInBattle() || pkm.getTypes().includes(PokemonType.FIRE), + ); expect(scene.currentBattle.mysteryEncounter?.dialogueTokens["burnedPokemon"]).toBe(i18next.t("pokemon:gengar")); - burnablePokemon.forEach((pkm) => { - expect(pkm.hp, `${pkm.name} should have received 20% damage: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp() - Math.floor(pkm.getMaxHp() * 0.2)); + burnablePokemon.forEach(pkm => { + expect(pkm.hp, `${pkm.name} should have received 20% damage: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe( + pkm.getMaxHp() - Math.floor(pkm.getMaxHp() * 0.2), + ); }); expect(burnablePokemon.some(pkm => pkm.status?.effect === StatusEffect.BURN)).toBeTruthy(); expect(burnablePokemon.some(pkm => pkm.customPokemonData.ability === Abilities.HEATPROOF)); - notBurnablePokemon.forEach((pkm) => expect(pkm.hp, `${pkm.name} should be full hp: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp())); + notBurnablePokemon.forEach(pkm => + expect(pkm.hp, `${pkm.name} should be full hp: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp()), + ); }); it("should leave encounter without battle", async () => { @@ -270,12 +285,12 @@ describe("Fiery Fallout - Mystery Encounter", () => { }); it("should be disabled if not enough FIRE types are in party", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, [ Species.MAGIKARP ]); + await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, [Species.MAGIKARP]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); - const continueEncounterSpy = vi.spyOn((encounterPhase as MysteryEncounterPhase), "continueEncounter"); + const continueEncounterSpy = vi.spyOn(encounterPhase as MysteryEncounterPhase, "continueEncounter"); await runSelectMysteryEncounterOption(game, 3); 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 116c45c1faf..d233e72932a 100644 --- a/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts +++ b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts @@ -4,7 +4,11 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; @@ -20,7 +24,7 @@ import { CommandPhase } from "#app/phases/command-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; const namespace = "mysteryEncounters/fightOrFlight"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -42,9 +46,7 @@ describe("Fight or Flight - Mystery Encounter", () => { game.override.disableTrainerWaves(); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.FIGHT_OR_FLIGHT]]]), ); }); @@ -126,7 +128,9 @@ describe("Fight or Flight - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(item.type.name).toBe(modifierSelectHandler.options[0].modifierTypeOption.type.name); }); @@ -144,14 +148,14 @@ describe("Fight or Flight - Mystery Encounter", () => { selected: [ { text: `${namespace}:option.2.selected`, - } + }, ], }); }); it("should NOT be selectable if the player doesn't have a Stealing move", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty); - scene.getPlayerParty().forEach(p => p.moveset = []); + scene.getPlayerParty().forEach(p => (p.moveset = [])); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -175,7 +179,7 @@ describe("Fight or Flight - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty); // Mock moveset - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.KNOCK_OFF) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.KNOCK_OFF)]; const item = game.scene.currentBattle.mysteryEncounter!.misc; await runMysteryEncounterToEnd(game, 2); @@ -184,7 +188,9 @@ describe("Fight or Flight - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(item.type.name).toBe(modifierSelectHandler.options[0].modifierTypeOption.type.name); 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 de351e48c76..4bb44c4d19e 100644 --- a/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts +++ b/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts @@ -5,7 +5,10 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { Mode } from "#app/ui/ui"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -23,7 +26,7 @@ import { Command } from "#app/ui/command-ui-handler"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; const namespace = "mysteryEncounters/funAndGames"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -44,11 +47,9 @@ describe("Fun And Games! - Mystery Encounter", () => { game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - ]); + const biomeMap = new Map([[Biome.VOLCANO, [MysteryEncounterType.FIGHT_OR_FLIGHT]]]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.FUN_AND_GAMES ]); + biomeMap.set(biome, [MysteryEncounterType.FUN_AND_GAMES]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -69,7 +70,7 @@ describe("Fun And Games! - Mystery Encounter", () => { { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue`, - } + }, ]); expect(FunAndGamesEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); expect(FunAndGamesEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); @@ -137,13 +138,13 @@ describe("Fun And Games! - Mystery Encounter", () => { it("should get 3 turns to attack the Wobbuffet for a reward", async () => { scene.money = 20000; - game.override.moveset([ Moves.TACKLE ]); + game.override.moveset([Moves.TACKLE]); await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(scene.getEnemyPokemon()?.species.speciesId).toBe(Species.WOBBUFFET); - expect(scene.getEnemyPokemon()?.ivs).toEqual([ 0, 0, 0, 0, 0, 0 ]); + expect(scene.getEnemyPokemon()?.ivs).toEqual([0, 0, 0, 0, 0, 0]); expect(scene.getEnemyPokemon()?.nature).toBe(Nature.MILD); game.onNextPrompt("MessagePhase", Mode.MESSAGE, () => { @@ -186,13 +187,15 @@ describe("Fun And Games! - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(0); }); it("should have Wide Lens item in rewards if Wubboffet is at 15-33% HP remaining", async () => { scene.money = 20000; - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); @@ -213,14 +216,16 @@ describe("Fun And Games! - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("WIDE_LENS"); }); it("should have Scope Lens item in rewards if Wubboffet is at 3-15% HP remaining", async () => { scene.money = 20000; - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); @@ -241,14 +246,16 @@ describe("Fun And Games! - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("SCOPE_LENS"); }); it("should have Multi Lens item in rewards if Wubboffet is at <3% HP remaining", async () => { scene.money = 20000; - game.override.moveset([ Moves.SPLASH ]); + game.override.moveset([Moves.SPLASH]); await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1 }, true); @@ -269,7 +276,9 @@ describe("Fun And Games! - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("MULTI_LENS"); }); 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 f898b1f574f..f68561c2286 100644 --- a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts +++ b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts @@ -21,7 +21,7 @@ import { ModifierTier } from "#app/modifier/modifier-tier"; import * as Utils from "#app/utils"; const namespace = "mysteryEncounters/globalTradeSystem"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -43,10 +43,10 @@ describe("Global Trade System - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); CIVILIZATION_ENCOUNTER_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.GLOBAL_TRADE_SYSTEM ]); + biomeMap.set(biome, [MysteryEncounterType.GLOBAL_TRADE_SYSTEM]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -71,7 +71,7 @@ describe("Global Trade System - Mystery Encounter", () => { }); it("should not loop infinitely when generating trade options for extreme BST non-legendaries", async () => { - const extremeBstTeam = [ Species.SLAKING, Species.WISHIWASHI, Species.SUNKERN ]; + const extremeBstTeam = [Species.SLAKING, Species.WISHIWASHI, Species.SUNKERN]; await game.runToMysteryEncounter(MysteryEncounterType.GLOBAL_TRADE_SYSTEM, extremeBstTeam); expect(GlobalTradeSystemEncounter.encounterType).toBe(MysteryEncounterType.GLOBAL_TRADE_SYSTEM); @@ -160,7 +160,7 @@ describe("Global Trade System - Mystery Encounter", () => { expect(option.dialogue).toBeDefined(); expect(option.dialogue).toStrictEqual({ buttonLabel: `${namespace}:option.2.label`, - buttonTooltip: `${namespace}:option.2.tooltip` + buttonTooltip: `${namespace}:option.2.tooltip`, }); }); @@ -232,7 +232,9 @@ describe("Global Trade System - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier).toBe(ModifierTier.MASTER); const soulDewAfter = scene.findModifier(m => m instanceof PokemonNatureWeightModifier); diff --git a/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts b/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts index 09ecbc6c31a..f23bc8738f2 100644 --- a/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts +++ b/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts @@ -16,10 +16,9 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { PartyExpPhase } from "#app/phases/party-exp-phase"; import i18next from "i18next"; - const namespace = "mysteryEncounters/lostAtSea"; /** Blastoise for surf. Pidgeot for fly. Abra for none. */ -const defaultParty = [ Species.BLASTOISE, Species.PIDGEOT, Species.ABRA ]; +const defaultParty = [Species.BLASTOISE, Species.PIDGEOT, Species.ABRA]; const defaultBiome = Biome.SEA; const defaultWave = 33; @@ -42,9 +41,9 @@ describe("Lost at Sea - Mystery Encounter", () => { vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ - [ Biome.SEA, [ MysteryEncounterType.LOST_AT_SEA ]], - [ Biome.MOUNTAIN, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], - ]) + [Biome.SEA, [MysteryEncounterType.LOST_AT_SEA]], + [Biome.MOUNTAIN, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], + ]), ); }); @@ -115,13 +114,13 @@ describe("Lost at Sea - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, defaultParty); const party = game.scene.getPlayerParty(); - const blastoise = party.find((pkm) => pkm.species.speciesId === Species.BLASTOISE); + const blastoise = party.find(pkm => pkm.species.speciesId === Species.BLASTOISE); const expBefore = blastoise!.exp; await runMysteryEncounterToEnd(game, 1); await game.phaseInterceptor.to(PartyExpPhase); - expect(blastoise?.exp).toBe(expBefore + Math.floor(laprasSpecies.baseExp * defaultWave / 5 + 1)); + expect(blastoise?.exp).toBe(expBefore + Math.floor((laprasSpecies.baseExp * defaultWave) / 5 + 1)); }); it("should leave encounter without battle", async () => { @@ -135,7 +134,7 @@ describe("Lost at Sea - Mystery Encounter", () => { }); it("should be disabled if no surfable PKM is in party", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [ Species.ARCANINE ]); + await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [Species.ARCANINE]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -180,13 +179,13 @@ describe("Lost at Sea - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, defaultParty); const party = game.scene.getPlayerParty(); - const pidgeot = party.find((pkm) => pkm.species.speciesId === Species.PIDGEOT); + const pidgeot = party.find(pkm => pkm.species.speciesId === Species.PIDGEOT); const expBefore = pidgeot!.exp; await runMysteryEncounterToEnd(game, 2); await game.phaseInterceptor.to(PartyExpPhase); - expect(pidgeot!.exp).toBe(expBefore + Math.floor(laprasBaseExp * defaultWave / 5 + 1)); + expect(pidgeot!.exp).toBe(expBefore + Math.floor((laprasBaseExp * defaultWave) / 5 + 1)); }); it("should leave encounter without battle", async () => { @@ -200,7 +199,7 @@ describe("Lost at Sea - Mystery Encounter", () => { }); it("should be disabled if no flyable PKM is in party", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [ Species.ARCANINE ]); + await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [Species.ARCANINE]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -242,18 +241,22 @@ describe("Lost at Sea - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, defaultParty); const party = game.scene.getPlayerParty(); - const abra = party.find((pkm) => pkm.species.speciesId === Species.ABRA)!; + const abra = party.find(pkm => pkm.species.speciesId === Species.ABRA)!; vi.spyOn(abra, "isAllowedInBattle").mockReturnValue(false); await runMysteryEncounterToEnd(game, 3); - const allowedPkm = party.filter((pkm) => pkm.isAllowedInBattle()); - const notAllowedPkm = party.filter((pkm) => !pkm.isAllowedInBattle()); - allowedPkm.forEach((pkm) => - expect(pkm.hp, `${pkm.name} should have receivd 25% damage: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp() - Math.floor(pkm.getMaxHp() * 0.25)) + const allowedPkm = party.filter(pkm => pkm.isAllowedInBattle()); + const notAllowedPkm = party.filter(pkm => !pkm.isAllowedInBattle()); + allowedPkm.forEach(pkm => + expect(pkm.hp, `${pkm.name} should have receivd 25% damage: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe( + pkm.getMaxHp() - Math.floor(pkm.getMaxHp() * 0.25), + ), ); - notAllowedPkm.forEach((pkm) => expect(pkm.hp, `${pkm.name} should be full hp: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp())); + notAllowedPkm.forEach(pkm => + expect(pkm.hp, `${pkm.name} should be full hp: ${pkm.hp} / ${pkm.getMaxHp()} HP`).toBe(pkm.getMaxHp()), + ); }); it("should leave encounter without battle", async () => { diff --git a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts index e42cd321cde..8e825dc2c9b 100644 --- a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts +++ b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts @@ -5,7 +5,10 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { Mode } from "#app/ui/ui"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -22,7 +25,7 @@ import { CommandPhase } from "#app/phases/command-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; const namespace = "mysteryEncounters/mysteriousChallengers"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -43,11 +46,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - ]); + const biomeMap = new Map([[Biome.VOLCANO, [MysteryEncounterType.FIGHT_OR_FLIGHT]]]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]); + biomeMap.set(biome, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -66,7 +67,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { expect(MysteriousChallengersEncounter.dialogue).toBeDefined(); expect(MysteriousChallengersEncounter.dialogue.intro).toStrictEqual([{ text: `${namespace}:intro` }]); expect(MysteriousChallengersEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); - expect(MysteriousChallengersEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); + expect(MysteriousChallengersEncounter.dialogue.encounterOptionsDialogue?.description).toBe( + `${namespace}:description`, + ); expect(MysteriousChallengersEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); expect(MysteriousChallengersEncounter.options.length).toBe(3); }); @@ -108,16 +111,20 @@ describe("Mysterious Challengers - Mystery Encounter", () => { trainerConfig: expect.any(TrainerConfig), levelAdditiveModifier: 1.5, female: expect.any(Boolean), - } + }, ]); - expect(encounter.enemyPartyConfigs[1].trainerConfig?.partyTemplates[0]).toEqual(new TrainerPartyCompoundTemplate( - new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER, false, true), - new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true) - )); - expect(encounter.enemyPartyConfigs[2].trainerConfig?.partyTemplates[0]).toEqual(new TrainerPartyCompoundTemplate( - new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), - new TrainerPartyTemplate(3, PartyMemberStrength.STRONG), - new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER)) + expect(encounter.enemyPartyConfigs[1].trainerConfig?.partyTemplates[0]).toEqual( + new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER, false, true), + new TrainerPartyTemplate(3, PartyMemberStrength.AVERAGE, false, true), + ), + ); + expect(encounter.enemyPartyConfigs[2].trainerConfig?.partyTemplates[0]).toEqual( + new TrainerPartyCompoundTemplate( + new TrainerPartyTemplate(2, PartyMemberStrength.AVERAGE), + new TrainerPartyTemplate(3, PartyMemberStrength.STRONG), + new TrainerPartyTemplate(1, PartyMemberStrength.STRONGER), + ), ); expect(encounter.spriteConfigs).toBeDefined(); expect(encounter.spriteConfigs.length).toBe(3); @@ -158,7 +165,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toContain("TM_COMMON"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toContain("TM_GREAT"); @@ -200,12 +209,26 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toBe(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toBe(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toBe(ModifierTier.GREAT); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.tier - modifierSelectHandler.options[3].modifierTypeOption.upgradeCount).toBe(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[3].modifierTypeOption.type.tier - + modifierSelectHandler.options[3].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.GREAT); }); }); @@ -243,12 +266,26 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toBe(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toBe(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toBe(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.tier - modifierSelectHandler.options[3].modifierTypeOption.upgradeCount).toBe(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[3].modifierTypeOption.type.tier - + modifierSelectHandler.options[3].modifierTypeOption.upgradeCount, + ).toBe(ModifierTier.GREAT); }); }); }); diff --git a/test/mystery-encounter/encounters/part-timer-encounter.test.ts b/test/mystery-encounter/encounters/part-timer-encounter.test.ts index 0cd7bc9bc76..639a2e140ff 100644 --- a/test/mystery-encounter/encounters/part-timer-encounter.test.ts +++ b/test/mystery-encounter/encounters/part-timer-encounter.test.ts @@ -5,7 +5,10 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { CIVILIZATION_ENCOUNTER_BIOMES } from "#app/data/mystery-encounters/mystery-encounters"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; @@ -17,7 +20,7 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; const namespace = "mysteryEncounters/partTimer"; // Pyukumuku for lowest speed, Regieleki for highest speed, Feebas for lowest "bulk", Melmetal for highest "bulk" -const defaultParty = [ Species.PYUKUMUKU, Species.REGIELEKI, Species.FEEBAS, Species.MELMETAL ]; +const defaultParty = [Species.PYUKUMUKU, Species.REGIELEKI, Species.FEEBAS, Species.MELMETAL]; const defaultBiome = Biome.PLAINS; const defaultWave = 37; @@ -39,10 +42,10 @@ describe("Part-Timer - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); CIVILIZATION_ENCOUNTER_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.PART_TIMER ]); + biomeMap.set(biome, [MysteryEncounterType.PART_TIMER]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -64,7 +67,7 @@ describe("Part-Timer - Mystery Encounter", () => { { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue`, - } + }, ]); expect(PartTimerEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); expect(PartTimerEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); @@ -90,9 +93,9 @@ describe("Part-Timer - Mystery Encounter", () => { buttonTooltip: `${namespace}:option.1.tooltip`, selected: [ { - text: `${namespace}:option.1.selected` - } - ] + text: `${namespace}:option.1.selected`, + }, + ], }); }); @@ -122,7 +125,7 @@ describe("Part-Timer - Mystery Encounter", () => { // Override party levels to 50 so stats can be fully reflective scene.getPlayerParty().forEach(p => { p.level = 50; - p.ivs = [ 20, 20, 20, 20, 20, 20 ]; + p.ivs = [20, 20, 20, 20, 20, 20]; p.calculateStats(); }); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 2 }); @@ -155,9 +158,9 @@ describe("Part-Timer - Mystery Encounter", () => { buttonTooltip: `${namespace}:option.2.tooltip`, selected: [ { - text: `${namespace}:option.2.selected` - } - ] + text: `${namespace}:option.2.selected`, + }, + ], }); }); @@ -187,7 +190,7 @@ describe("Part-Timer - Mystery Encounter", () => { // Override party levels to 50 so stats can be fully reflective scene.getPlayerParty().forEach(p => { p.level = 50; - p.ivs = [ 20, 20, 20, 20, 20, 20 ]; + p.ivs = [20, 20, 20, 20, 20, 20]; p.calculateStats(); }); await runMysteryEncounterToEnd(game, 2, { pokemonNo: 4 }); @@ -221,9 +224,9 @@ describe("Part-Timer - Mystery Encounter", () => { disabledButtonTooltip: `${namespace}:option.3.disabled_tooltip`, selected: [ { - text: `${namespace}:option.3.selected` - } - ] + text: `${namespace}:option.3.selected`, + }, + ], }); }); @@ -232,7 +235,7 @@ describe("Part-Timer - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty); // Mock movesets - scene.getPlayerParty().forEach(p => p.moveset = []); + scene.getPlayerParty().forEach(p => (p.moveset = [])); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -256,7 +259,7 @@ describe("Part-Timer - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty); // Mock moveset - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.ATTRACT) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.ATTRACT)]; await runMysteryEncounterToEnd(game, 3); expect(EncounterPhaseUtils.updatePlayerMoney).toHaveBeenCalledWith(scene.getWaveMoneyAmount(2.5), true, false); diff --git a/test/mystery-encounter/encounters/safari-zone.test.ts b/test/mystery-encounter/encounters/safari-zone.test.ts index 068e28547f4..3506020aae4 100644 --- a/test/mystery-encounter/encounters/safari-zone.test.ts +++ b/test/mystery-encounter/encounters/safari-zone.test.ts @@ -4,19 +4,25 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { Species } from "#enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; -import { getSafariSpeciesSpawn, SafariZoneEncounter } from "#app/data/mystery-encounters/encounters/safari-zone-encounter"; +import { + getSafariSpeciesSpawn, + SafariZoneEncounter, +} from "#app/data/mystery-encounters/encounters/safari-zone-encounter"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { NON_LEGEND_PARADOX_POKEMON } from "#app/data/balance/special-species-groups"; const namespace = "mysteryEncounters/safariZone"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.SWAMP; const defaultWave = 45; @@ -38,10 +44,10 @@ describe("Safari Zone - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - [ Biome.FOREST, [ MysteryEncounterType.SAFARI_ZONE ]], - [ Biome.SWAMP, [ MysteryEncounterType.SAFARI_ZONE ]], - [ Biome.JUNGLE, [ MysteryEncounterType.SAFARI_ZONE ]], + [Biome.VOLCANO, [MysteryEncounterType.FIGHT_OR_FLIGHT]], + [Biome.FOREST, [MysteryEncounterType.SAFARI_ZONE]], + [Biome.SWAMP, [MysteryEncounterType.SAFARI_ZONE]], + [Biome.JUNGLE, [MysteryEncounterType.SAFARI_ZONE]], ]); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -58,9 +64,7 @@ describe("Safari Zone - Mystery Encounter", () => { expect(SafariZoneEncounter.encounterType).toBe(MysteryEncounterType.SAFARI_ZONE); expect(SafariZoneEncounter.encounterTier).toBe(MysteryEncounterTier.GREAT); expect(SafariZoneEncounter.dialogue).toBeDefined(); - expect(SafariZoneEncounter.dialogue.intro).toStrictEqual([ - { text: `${namespace}:intro` }, - ]); + expect(SafariZoneEncounter.dialogue.intro).toStrictEqual([{ text: `${namespace}:intro` }]); expect(SafariZoneEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); expect(SafariZoneEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); expect(SafariZoneEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); diff --git a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts index c7fcc1e967f..85c823038e8 100644 --- a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts +++ b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts @@ -13,17 +13,21 @@ import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { Mode } from "#app/ui/ui"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; import i18next from "i18next"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; const namespace = "mysteryEncounters/teleportingHijinks"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; -const TRANSPORT_BIOMES = [ Biome.SPACE, Biome.ISLAND, Biome.LABORATORY, Biome.FAIRY_CAVE, Biome.WASTELAND, Biome.DOJO ]; +const TRANSPORT_BIOMES = [Biome.SPACE, Biome.ISLAND, Biome.LABORATORY, Biome.FAIRY_CAVE, Biome.WASTELAND, Biome.DOJO]; describe("Teleporting Hijinks - Mystery Encounter", () => { let phaserGame: Phaser.Game; @@ -47,9 +51,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { .enemyPassiveAbility(Abilities.BALL_FETCH); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.TELEPORTING_HIJINKS ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.TELEPORTING_HIJINKS]]]), ); }); @@ -181,7 +183,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await runMysteryEncounterToEnd(game, 1, undefined, true); const enemyField = scene.getEnemyField(); - expect(enemyField[0].summonData.statStages).toEqual([ 0, 1, 0, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([0, 1, 0, 1, 1, 0, 0]); expect(enemyField[0].isBoss()).toBe(true); }); @@ -190,7 +192,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await runMysteryEncounterToEnd(game, 1, undefined, true); const enemyField = scene.getEnemyField(); - expect(enemyField[0].summonData.statStages).toEqual([ 1, 1, 1, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 1, 0, 0]); expect(enemyField[0].isBoss()).toBe(true); }); }); @@ -207,13 +209,13 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { selected: [ { text: `${namespace}:option.2.selected`, - } + }, ], }); }); it("should NOT be selectable if the player doesn't the right type pokemon", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [ Species.BLASTOISE ]); + await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [Species.BLASTOISE]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -232,14 +234,14 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { }); it("should be selectable if the player has the right type pokemon", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [ Species.METAGROSS ]); + await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [Species.METAGROSS]); await runMysteryEncounterToEnd(game, 2, undefined, true); expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); }); it("should transport to a new area", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [ Species.PIKACHU ]); + await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [Species.PIKACHU]); const previousBiome = scene.arena.biomeType; @@ -250,19 +252,19 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { }); it("should start a battle against an enraged boss below wave 50", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [ Species.PIKACHU ]); + await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [Species.PIKACHU]); await runMysteryEncounterToEnd(game, 2, undefined, true); const enemyField = scene.getEnemyField(); - expect(enemyField[0].summonData.statStages).toEqual([ 0, 1, 0, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([0, 1, 0, 1, 1, 0, 0]); expect(enemyField[0].isBoss()).toBe(true); }); it("should start a battle against an extra enraged boss above wave 50", { retry: 5 }, async () => { game.override.startingWave(56); - await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [ Species.PIKACHU ]); + await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [Species.PIKACHU]); await runMysteryEncounterToEnd(game, 2, undefined, true); const enemyField = scene.getEnemyField(); - expect(enemyField[0].summonData.statStages).toEqual([ 1, 1, 1, 1, 1, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([1, 1, 1, 1, 1, 0, 0]); expect(enemyField[0].isBoss()).toBe(true); }); }); @@ -287,7 +289,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await runMysteryEncounterToEnd(game, 3, undefined, true); const enemyField = scene.getEnemyField(); - expect(enemyField[0].summonData.statStages).toEqual([ 0, 0, 0, 0, 0, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([0, 0, 0, 0, 0, 0, 0]); expect(enemyField[0].isBoss()).toBe(true); }); @@ -300,9 +302,19 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; - expect(modifierSelectHandler.options.some(opt => opt.modifierTypeOption.type.name === i18next.t("modifierType:AttackTypeBoosterItem.metal_coat"))).toBe(true); - expect(modifierSelectHandler.options.some(opt => opt.modifierTypeOption.type.name === i18next.t("modifierType:AttackTypeBoosterItem.magnet"))).toBe(true); + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; + expect( + modifierSelectHandler.options.some( + opt => opt.modifierTypeOption.type.name === i18next.t("modifierType:AttackTypeBoosterItem.metal_coat"), + ), + ).toBe(true); + expect( + modifierSelectHandler.options.some( + opt => opt.modifierTypeOption.type.name === i18next.t("modifierType:AttackTypeBoosterItem.magnet"), + ), + ).toBe(true); }); }); }); diff --git a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts index 7b10adc9680..9160126ffc3 100644 --- a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts @@ -5,7 +5,10 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -21,7 +24,7 @@ import { PostMysteryEncounterPhase } from "#app/phases/mystery-encounter-phases" import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters"; const namespace = "mysteryEncounters/theExpertPokemonBreeder"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -42,11 +45,9 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - ]); + const biomeMap = new Map([[Biome.VOLCANO, [MysteryEncounterType.FIGHT_OR_FLIGHT]]]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER ]); + biomeMap.set(biome, [MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -65,15 +66,17 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(TheExpertPokemonBreederEncounter.dialogue).toBeDefined(); expect(TheExpertPokemonBreederEncounter.dialogue.intro).toStrictEqual([ { - text: `${namespace}:intro` + text: `${namespace}:intro`, }, { speaker: "trainerNames:expert_pokemon_breeder", - text: `${namespace}:intro_dialogue` + text: `${namespace}:intro_dialogue`, }, ]); expect(TheExpertPokemonBreederEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); - expect(TheExpertPokemonBreederEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); + expect(TheExpertPokemonBreederEncounter.dialogue.encounterOptionsDialogue?.description).toBe( + `${namespace}:description`, + ); expect(TheExpertPokemonBreederEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); expect(TheExpertPokemonBreederEncounter.options.length).toBe(3); }); @@ -83,7 +86,9 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { game.override.startingBiome(Biome.VOLCANO); await game.runToMysteryEncounter(); - expect(scene.currentBattle?.mysteryEncounter?.encounterType).not.toBe(MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER); + expect(scene.currentBattle?.mysteryEncounter?.encounterType).not.toBe( + MysteryEncounterType.THE_EXPERT_POKEMON_BREEDER, + ); }); it("should initialize fully", async () => { @@ -133,12 +138,15 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { const ace = scene.currentBattle?.enemyParty[0]; if (ace) { // Pretend that loading assets takes an extra 500ms - vi.spyOn(ace, "loadAssets").mockImplementation(() => new Promise(resolve => { - setTimeout(() => { - successfullyLoaded = true; - resolve(); - }, 500); - })); + vi.spyOn(ace, "loadAssets").mockImplementation( + () => + new Promise(resolve => { + setTimeout(() => { + successfullyLoaded = true; + resolve(); + }, 500); + }), + ); } return scene.currentBattle?.enemyParty ?? []; @@ -215,12 +223,15 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { const ace = scene.currentBattle?.enemyParty[0]; if (ace) { // Pretend that loading assets takes an extra 500ms - vi.spyOn(ace, "loadAssets").mockImplementation(() => new Promise(resolve => { - setTimeout(() => { - successfullyLoaded = true; - resolve(); - }, 500); - })); + vi.spyOn(ace, "loadAssets").mockImplementation( + () => + new Promise(resolve => { + setTimeout(() => { + successfullyLoaded = true; + resolve(); + }, 500); + }), + ); } return scene.currentBattle?.enemyParty ?? []; @@ -294,12 +305,15 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { const ace = scene.currentBattle?.enemyParty[0]; if (ace) { // Pretend that loading assets takes an extra 500ms - vi.spyOn(ace, "loadAssets").mockImplementation(() => new Promise(resolve => { - setTimeout(() => { - successfullyLoaded = true; - resolve(); - }, 500); - })); + vi.spyOn(ace, "loadAssets").mockImplementation( + () => + new Promise(resolve => { + setTimeout(() => { + successfullyLoaded = true; + resolve(); + }, 500); + }), + ); } return scene.currentBattle?.enemyParty ?? []; diff --git a/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts b/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts index 3a3d94dbc44..4adb8c6b076 100644 --- a/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts @@ -5,11 +5,17 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { PlayerPokemon } from "#app/field/pokemon"; import { HUMAN_TRANSITABLE_BIOMES } from "#app/data/mystery-encounters/mystery-encounters"; -import { getSalesmanSpeciesOffer, ThePokemonSalesmanEncounter } from "#app/data/mystery-encounters/encounters/the-pokemon-salesman-encounter"; +import { + getSalesmanSpeciesOffer, + ThePokemonSalesmanEncounter, +} from "#app/data/mystery-encounters/encounters/the-pokemon-salesman-encounter"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; @@ -17,7 +23,7 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { NON_LEGEND_PARADOX_POKEMON } from "#app/data/balance/special-species-groups"; const namespace = "mysteryEncounters/thePokemonSalesman"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -39,10 +45,10 @@ describe("The Pokemon Salesman - Mystery Encounter", () => { game.override.disableTrainerWaves(); const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], + [Biome.VOLCANO, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], ]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.THE_POKEMON_SALESMAN ]); + biomeMap.set(biome, [MysteryEncounterType.THE_POKEMON_SALESMAN]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -63,7 +69,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => { expect(dialogue).toBeDefined(); expect(dialogue.intro).toStrictEqual([ { text: `${namespace}:intro` }, - { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue` } + { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue` }, ]); const { title, description, query } = dialogue.encounterOptionsDialogue!; expect(title).toBe(`${namespace}:title`); 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 1a075ffaff2..57d55af5dac 100644 --- a/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts @@ -7,7 +7,10 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import { getPokemonSpecies } from "#app/data/pokemon-species"; import * as BattleAnims from "#app/data/battle-anims"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { TheStrongStuffEncounter } from "#app/data/mystery-encounters/encounters/the-strong-stuff-encounter"; @@ -28,7 +31,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { Abilities } from "#enums/abilities"; const namespace = "mysteryEncounters/theStrongStuff"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -54,9 +57,9 @@ describe("The Strong Stuff - Mystery Encounter", () => { vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( new Map([ - [ Biome.CAVE, [ MysteryEncounterType.THE_STRONG_STUFF ]], - [ Biome.MOUNTAIN, [ MysteryEncounterType.MYSTERIOUS_CHALLENGERS ]], - ]) + [Biome.CAVE, [MysteryEncounterType.THE_STRONG_STUFF]], + [Biome.MOUNTAIN, [MysteryEncounterType.MYSTERIOUS_CHALLENGERS]], + ]), ); }); @@ -112,13 +115,13 @@ describe("The Strong Stuff - Mystery Encounter", () => { shiny: false, customPokemonData: new CustomPokemonData({ spriteScale: 1.25 }), nature: Nature.BOLD, - moveSet: [ Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER ], + moveSet: [Moves.INFESTATION, Moves.SALT_CURE, Moves.GASTRO_ACID, Moves.HEAL_ORDER], modifierConfigs: expect.any(Array), - tags: [ BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON ], - mysteryEncounterBattleEffects: expect.any(Function) - } + tags: [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON], + mysteryEncounterBattleEffects: expect.any(Function), + }, ], - } + }, ]); await vi.waitFor(() => expect(moveInitSpy).toHaveBeenCalled()); await vi.waitFor(() => expect(moveLoadSpy).toHaveBeenCalled()); @@ -195,15 +198,28 @@ describe("The Strong Stuff - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(enemyField.length).toBe(1); expect(enemyField[0].species.speciesId).toBe(Species.SHUCKLE); - expect(enemyField[0].summonData.statStages).toEqual([ 0, 2, 0, 2, 0, 0, 0 ]); + expect(enemyField[0].summonData.statStages).toEqual([0, 2, 0, 2, 0, 0, 0]); const shuckleItems = enemyField[0].getHeldItems(); expect(shuckleItems.length).toBe(5); - expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.SITRUS)?.stackCount).toBe(1); - expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.ENIGMA)?.stackCount).toBe(1); - expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.GANLON)?.stackCount).toBe(1); - expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.APICOT)?.stackCount).toBe(1); + expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.SITRUS)?.stackCount).toBe( + 1, + ); + expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.ENIGMA)?.stackCount).toBe( + 1, + ); + expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.GANLON)?.stackCount).toBe( + 1, + ); + expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.APICOT)?.stackCount).toBe( + 1, + ); expect(shuckleItems.find(m => m instanceof BerryModifier && m.berryType === BerryType.LUM)?.stackCount).toBe(2); - expect(enemyField[0].moveset).toEqual([ new PokemonMove(Moves.INFESTATION), new PokemonMove(Moves.SALT_CURE), new PokemonMove(Moves.GASTRO_ACID), new PokemonMove(Moves.HEAL_ORDER) ]); + expect(enemyField[0].moveset).toEqual([ + new PokemonMove(Moves.INFESTATION), + new PokemonMove(Moves.SALT_CURE), + new PokemonMove(Moves.GASTRO_ACID), + new PokemonMove(Moves.HEAL_ORDER), + ]); // Should have used moves pre-battle const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); @@ -221,7 +237,9 @@ describe("The Strong Stuff - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("SOUL_DEW"); }); 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 85dbb4e23ff..94c8141aa1e 100644 --- a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts @@ -28,7 +28,7 @@ import { VictoryPhase } from "#app/phases/victory-phase"; import { StatusEffect } from "#enums/status-effect"; const namespace = "mysteryEncounters/theWinstrateChallenge"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -49,11 +49,9 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - const biomeMap = new Map([ - [ Biome.VOLCANO, [ MysteryEncounterType.FIGHT_OR_FLIGHT ]], - ]); + const biomeMap = new Map([[Biome.VOLCANO, [MysteryEncounterType.FIGHT_OR_FLIGHT]]]); HUMAN_TRANSITABLE_BIOMES.forEach(biome => { - biomeMap.set(biome, [ MysteryEncounterType.THE_WINSTRATE_CHALLENGE ]); + biomeMap.set(biome, [MysteryEncounterType.THE_WINSTRATE_CHALLENGE]); }); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue(biomeMap); }); @@ -75,10 +73,12 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { { speaker: `${namespace}:speaker`, text: `${namespace}:intro_dialogue`, - } + }, ]); expect(TheWinstrateChallengeEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}:title`); - expect(TheWinstrateChallengeEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}:description`); + expect(TheWinstrateChallengeEncounter.dialogue.encounterOptionsDialogue?.description).toBe( + `${namespace}:description`, + ); expect(TheWinstrateChallengeEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}:query`); expect(TheWinstrateChallengeEncounter.options.length).toBe(2); }); @@ -115,42 +115,42 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { isBoss: false, abilityIndex: 0, // Soundproof nature: Nature.MODEST, - moveSet: [ Moves.THUNDERBOLT, Moves.GIGA_DRAIN, Moves.FOUL_PLAY, Moves.THUNDER_WAVE ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.THUNDERBOLT, Moves.GIGA_DRAIN, Moves.FOUL_PLAY, Moves.THUNDER_WAVE], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.SWALOT), isBoss: false, abilityIndex: 2, // Gluttony nature: Nature.QUIET, - moveSet: [ Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.ICE_BEAM, Moves.EARTHQUAKE ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.ICE_BEAM, Moves.EARTHQUAKE], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.DODRIO), isBoss: false, abilityIndex: 2, // Tangled Feet nature: Nature.JOLLY, - moveSet: [ Moves.DRILL_PECK, Moves.QUICK_ATTACK, Moves.THRASH, Moves.KNOCK_OFF ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.DRILL_PECK, Moves.QUICK_ATTACK, Moves.THRASH, Moves.KNOCK_OFF], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.ALAKAZAM), isBoss: false, formIndex: 1, nature: Nature.BOLD, - moveSet: [ Moves.PSYCHIC, Moves.SHADOW_BALL, Moves.FOCUS_BLAST, Moves.THUNDERBOLT ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.PSYCHIC, Moves.SHADOW_BALL, Moves.FOCUS_BLAST, Moves.THUNDERBOLT], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.DARMANITAN), isBoss: false, abilityIndex: 0, // Sheer Force nature: Nature.IMPISH, - moveSet: [ Moves.EARTHQUAKE, Moves.U_TURN, Moves.FLARE_BLITZ, Moves.ROCK_SLIDE ], - modifierConfigs: expect.any(Array) - } - ] + moveSet: [Moves.EARTHQUAKE, Moves.U_TURN, Moves.FLARE_BLITZ, Moves.ROCK_SLIDE], + modifierConfigs: expect.any(Array), + }, + ], }, { trainerType: TrainerType.VICKY, @@ -160,10 +160,10 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { isBoss: false, formIndex: 1, nature: Nature.IMPISH, - moveSet: [ Moves.AXE_KICK, Moves.ICE_PUNCH, Moves.ZEN_HEADBUTT, Moves.BULLET_PUNCH ], - modifierConfigs: expect.any(Array) - } - ] + moveSet: [Moves.AXE_KICK, Moves.ICE_PUNCH, Moves.ZEN_HEADBUTT, Moves.BULLET_PUNCH], + modifierConfigs: expect.any(Array), + }, + ], }, { trainerType: TrainerType.VIVI, @@ -173,26 +173,26 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { isBoss: false, abilityIndex: 3, // Lightning Rod nature: Nature.ADAMANT, - moveSet: [ Moves.WATERFALL, Moves.MEGAHORN, Moves.KNOCK_OFF, Moves.REST ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.WATERFALL, Moves.MEGAHORN, Moves.KNOCK_OFF, Moves.REST], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.BRELOOM), isBoss: false, abilityIndex: 1, // Poison Heal nature: Nature.JOLLY, - moveSet: [ Moves.SPORE, Moves.SWORDS_DANCE, Moves.SEED_BOMB, Moves.DRAIN_PUNCH ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.SPORE, Moves.SWORDS_DANCE, Moves.SEED_BOMB, Moves.DRAIN_PUNCH], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.CAMERUPT), isBoss: false, formIndex: 1, nature: Nature.CALM, - moveSet: [ Moves.EARTH_POWER, Moves.FIRE_BLAST, Moves.YAWN, Moves.PROTECT ], - modifierConfigs: expect.any(Array) - } - ] + moveSet: [Moves.EARTH_POWER, Moves.FIRE_BLAST, Moves.YAWN, Moves.PROTECT], + modifierConfigs: expect.any(Array), + }, + ], }, { trainerType: TrainerType.VICTORIA, @@ -202,18 +202,18 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { isBoss: false, abilityIndex: 0, // Natural Cure nature: Nature.CALM, - moveSet: [ Moves.SYNTHESIS, Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.SLEEP_POWDER ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.SYNTHESIS, Moves.SLUDGE_BOMB, Moves.GIGA_DRAIN, Moves.SLEEP_POWDER], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.GARDEVOIR), isBoss: false, formIndex: 1, nature: Nature.TIMID, - moveSet: [ Moves.PSYSHOCK, Moves.MOONBLAST, Moves.SHADOW_BALL, Moves.WILL_O_WISP ], - modifierConfigs: expect.any(Array) - } - ] + moveSet: [Moves.PSYSHOCK, Moves.MOONBLAST, Moves.SHADOW_BALL, Moves.WILL_O_WISP], + modifierConfigs: expect.any(Array), + }, + ], }, { trainerType: TrainerType.VICTOR, @@ -223,19 +223,19 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { isBoss: false, abilityIndex: 0, // Guts nature: Nature.ADAMANT, - moveSet: [ Moves.FACADE, Moves.BRAVE_BIRD, Moves.PROTECT, Moves.QUICK_ATTACK ], - modifierConfigs: expect.any(Array) + moveSet: [Moves.FACADE, Moves.BRAVE_BIRD, Moves.PROTECT, Moves.QUICK_ATTACK], + modifierConfigs: expect.any(Array), }, { species: getPokemonSpecies(Species.OBSTAGOON), isBoss: false, abilityIndex: 1, // Guts nature: Nature.ADAMANT, - moveSet: [ Moves.FACADE, Moves.OBSTRUCT, Moves.NIGHT_SLASH, Moves.FIRE_PUNCH ], - modifierConfigs: expect.any(Array) - } - ] - } + moveSet: [Moves.FACADE, Moves.OBSTRUCT, Moves.NIGHT_SLASH, Moves.FIRE_PUNCH], + modifierConfigs: expect.any(Array), + }, + ], + }, ]); expect(encounter.spriteConfigs).toBeDefined(); expect(encounter.spriteConfigs.length).toBe(5); @@ -300,7 +300,9 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("MYSTERY_ENCOUNTER_MACHO_BRACE"); }, 15000); @@ -340,7 +342,9 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(1); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toBe("RARER_CANDY"); }); @@ -352,7 +356,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { * @param game * @param isFinalBattle */ -async function skipBattleToNextBattle(game: GameManager, isFinalBattle: boolean = false) { +async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false) { game.scene.clearPhaseQueue(); game.scene.clearPhaseQueueSplice(); const commandUiHandler = game.scene.ui.handlers[Mode.COMMAND]; 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 90a13c75dc3..90e2312e624 100644 --- a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts +++ b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts @@ -7,7 +7,10 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import { getPokemonSpecies } from "#app/data/pokemon-species"; import * as BattleAnims from "#app/data/battle-anims"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; @@ -24,7 +27,7 @@ import { CommandPhase } from "#app/phases/command-phase"; import { MovePhase } from "#app/phases/move-phase"; const namespace = "mysteryEncounters/trashToTreasure"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -46,9 +49,7 @@ describe("Trash to Treasure - Mystery Encounter", () => { game.override.disableTrainerWaves(); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.TRASH_TO_TREASURE ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.TRASH_TO_TREASURE]]]), ); }); @@ -95,10 +96,10 @@ describe("Trash to Treasure - Mystery Encounter", () => { shiny: false, formIndex: 1, bossSegmentModifier: 1, - moveSet: [ Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH ], - } + moveSet: [Moves.PAYBACK, Moves.GUNK_SHOT, Moves.STOMPING_TANTRUM, Moves.DRAIN_PUNCH], + }, ], - } + }, ]); await vi.waitFor(() => expect(moveInitSpy).toHaveBeenCalled()); await vi.waitFor(() => expect(moveLoadSpy).toHaveBeenCalled()); @@ -176,7 +177,12 @@ describe("Trash to Treasure - Mystery Encounter", () => { expect(scene.getCurrentPhase()?.constructor.name).toBe(CommandPhase.name); expect(enemyField.length).toBe(1); expect(enemyField[0].species.speciesId).toBe(Species.GARBODOR); - expect(enemyField[0].moveset).toEqual([ new PokemonMove(Moves.PAYBACK), new PokemonMove(Moves.GUNK_SHOT), new PokemonMove(Moves.STOMPING_TANTRUM), new PokemonMove(Moves.DRAIN_PUNCH) ]); + expect(enemyField[0].moveset).toEqual([ + new PokemonMove(Moves.PAYBACK), + new PokemonMove(Moves.GUNK_SHOT), + new PokemonMove(Moves.STOMPING_TANTRUM), + new PokemonMove(Moves.DRAIN_PUNCH), + ]); // Should have used moves pre-battle const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); @@ -194,12 +200,26 @@ describe("Trash to Treasure - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.tier - modifierSelectHandler.options[3].modifierTypeOption.upgradeCount).toEqual(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[3].modifierTypeOption.type.tier - + modifierSelectHandler.options[3].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.GREAT); }); }); }); diff --git a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts index 1bdc45348d6..452dfcf3784 100644 --- a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts +++ b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts @@ -4,7 +4,10 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { runMysteryEncounterToEnd, runSelectMysteryEncounterOption } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + runSelectMysteryEncounterOption, +} from "#test/mystery-encounter/encounter-test-utils"; import { Moves } from "#enums/moves"; import type BattleScene from "#app/battle-scene"; import { PokemonMove } from "#app/field/pokemon"; @@ -27,7 +30,7 @@ import { modifierTypes } from "#app/modifier/modifier-type"; import { Abilities } from "#enums/abilities"; const namespace = "mysteryEncounters/uncommonBreed"; -const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ]; +const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -43,7 +46,8 @@ describe("Uncommon Breed - Mystery Encounter", () => { beforeEach(async () => { game = new GameManager(phaserGame); scene = game.scene; - game.override.mysteryEncounterChance(100) + game.override + .mysteryEncounterChance(100) .mysteryEncounterTier(MysteryEncounterTier.COMMON) .startingWave(defaultWave) .startingBiome(defaultBiome) @@ -52,9 +56,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { .enemyPassiveAbility(Abilities.BALL_FETCH); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.UNCOMMON_BREED ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.UNCOMMON_BREED]]]), ); }); @@ -126,7 +128,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { expect(enemyField[0].species.speciesId).toBe(speciesToSpawn); const statStagePhases = unshiftPhaseSpy.mock.calls.filter(p => p[0] instanceof StatStageChangePhase)[0][0] as any; - expect(statStagePhases.stats).toEqual([ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]); + expect(statStagePhases.stats).toEqual([Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]); // Should have used its egg move pre-battle const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); @@ -153,7 +155,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { expect(enemyField[0].species.speciesId).toBe(speciesToSpawn); const statStagePhases = unshiftPhaseSpy.mock.calls.filter(p => p[0] instanceof StatStageChangePhase)[0][0] as any; - expect(statStagePhases.stats).toEqual([ Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD ]); + expect(statStagePhases.stats).toEqual([Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.SPD]); // Should have used its egg move pre-battle const movePhases = phaseSpy.mock.calls.filter(p => p[0] instanceof MovePhase).map(p => p[0]); @@ -176,7 +178,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { selected: [ { text: `${namespace}:option.2.selected`, - } + }, ], }); }); @@ -213,11 +215,11 @@ describe("Uncommon Breed - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); // Berries on party lead - const sitrus = generateModifierType(modifierTypes.BERRY, [ BerryType.SITRUS ])!; + const sitrus = generateModifierType(modifierTypes.BERRY, [BerryType.SITRUS])!; const sitrusMod = sitrus.newModifier(scene.getPlayerParty()[0]) as BerryModifier; sitrusMod.stackCount = 2; scene.addModifier(sitrusMod, true, false, false, true); - const ganlon = generateModifierType(modifierTypes.BERRY, [ BerryType.GANLON ])!; + const ganlon = generateModifierType(modifierTypes.BERRY, [BerryType.GANLON])!; const ganlonMod = ganlon.newModifier(scene.getPlayerParty()[0]) as BerryModifier; ganlonMod.stackCount = 3; scene.addModifier(ganlonMod, true, false, false, true); @@ -241,14 +243,14 @@ describe("Uncommon Breed - Mystery Encounter", () => { selected: [ { text: `${namespace}:option.3.selected`, - } + }, ], }); }); it("should NOT be selectable if the player doesn't have an Attracting move", async () => { await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); - scene.getPlayerParty().forEach(p => p.moveset = []); + scene.getPlayerParty().forEach(p => (p.moveset = [])); await game.phaseInterceptor.to(MysteryEncounterPhase, false); const encounterPhase = scene.getCurrentPhase(); @@ -270,7 +272,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle"); await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty); // Mock moveset - scene.getPlayerParty()[0].moveset = [ new PokemonMove(Moves.CHARM) ]; + scene.getPlayerParty()[0].moveset = [new PokemonMove(Moves.CHARM)]; await runMysteryEncounterToEnd(game, 3); expect(leaveEncounterWithoutBattleSpy).toBeCalled(); diff --git a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts index 073893f340d..fbb88e346a8 100644 --- a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts +++ b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts @@ -5,7 +5,10 @@ import { Species } from "#app/enums/species"; import GameManager from "#test/testUtils/gameManager"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { runMysteryEncounterToEnd, skipBattleRunMysteryEncounterRewardsPhase } from "#test/mystery-encounter/encounter-test-utils"; +import { + runMysteryEncounterToEnd, + skipBattleRunMysteryEncounterRewardsPhase, +} from "#test/mystery-encounter/encounter-test-utils"; import type BattleScene from "#app/battle-scene"; import { Mode } from "#app/ui/ui"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; @@ -19,7 +22,7 @@ import { CommandPhase } from "#app/phases/command-phase"; import { ModifierTier } from "#app/modifier/modifier-tier"; const namespace = "mysteryEncounters/weirdDream"; -const defaultParty = [ Species.MAGBY, Species.HAUNTER, Species.ABRA ]; +const defaultParty = [Species.MAGBY, Species.HAUNTER, Species.ABRA]; const defaultBiome = Biome.CAVE; const defaultWave = 45; @@ -39,12 +42,12 @@ describe("Weird Dream - Mystery Encounter", () => { game.override.startingWave(defaultWave); game.override.startingBiome(defaultBiome); game.override.disableTrainerWaves(); - vi.spyOn(EncounterTransformationSequence, "doPokemonTransformationSequence").mockImplementation(() => new Promise(resolve => resolve())); + vi.spyOn(EncounterTransformationSequence, "doPokemonTransformationSequence").mockImplementation( + () => new Promise(resolve => resolve()), + ); vi.spyOn(MysteryEncounters, "mysteryEncountersByBiome", "get").mockReturnValue( - new Map([ - [ Biome.CAVE, [ MysteryEncounterType.WEIRD_DREAM ]], - ]) + new Map([[Biome.CAVE, [MysteryEncounterType.WEIRD_DREAM]]]), ); }); @@ -62,7 +65,7 @@ describe("Weird Dream - Mystery Encounter", () => { expect(WeirdDreamEncounter.dialogue).toBeDefined(); expect(WeirdDreamEncounter.dialogue.intro).toStrictEqual([ { - text: `${namespace}:intro` + text: `${namespace}:intro`, }, { speaker: `${namespace}:speaker`, @@ -142,7 +145,9 @@ describe("Weird Dream - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("MEMORY_MUSHROOM"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toEqual("ROGUE_BALL"); @@ -196,14 +201,34 @@ describe("Weird Dream - Mystery Encounter", () => { await game.phaseInterceptor.run(SelectModifierPhase); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(6); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.tier - modifierSelectHandler.options[3].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[4].modifierTypeOption.type.tier - modifierSelectHandler.options[4].modifierTypeOption.upgradeCount).toEqual(ModifierTier.GREAT); - expect(modifierSelectHandler.options[5].modifierTypeOption.type.tier - modifierSelectHandler.options[5].modifierTypeOption.upgradeCount).toEqual(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[3].modifierTypeOption.type.tier - + modifierSelectHandler.options[3].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[4].modifierTypeOption.type.tier - + modifierSelectHandler.options[4].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[5].modifierTypeOption.type.tier - + modifierSelectHandler.options[5].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.GREAT); }); }); diff --git a/test/mystery-encounter/mystery-encounter-utils.test.ts b/test/mystery-encounter/mystery-encounter-utils.test.ts index 25981b444a4..1c4a2cf89bd 100644 --- a/test/mystery-encounter/mystery-encounter-utils.test.ts +++ b/test/mystery-encounter/mystery-encounter-utils.test.ts @@ -1,8 +1,19 @@ import type BattleScene from "#app/battle-scene"; import { speciesStarterCosts } from "#app/data/balance/starters"; import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; -import { getEncounterText, queueEncounterMessage, showEncounterDialogue, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; -import { getHighestLevelPlayerPokemon, getLowestLevelPlayerPokemon, getRandomPlayerPokemon, getRandomSpeciesByStarterCost, koPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; +import { + getEncounterText, + queueEncounterMessage, + showEncounterDialogue, + showEncounterText, +} from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; +import { + getHighestLevelPlayerPokemon, + getLowestLevelPlayerPokemon, + getRandomPlayerPokemon, + getRandomSpeciesByStarterCost, + koPlayerPokemon, +} from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { PokemonType } from "#enums/pokemon-type"; import { MessagePhase } from "#app/phases/message-phase"; @@ -31,7 +42,7 @@ describe("Mystery Encounter Utils", () => { beforeEach(() => { game = new GameManager(phaserGame); scene = game.scene; - initSceneWithoutEncounterPhase(game.scene, [ Species.ARCEUS, Species.MANAPHY ]); + initSceneWithoutEncounterPhase(game.scene, [Species.ARCEUS, Species.MANAPHY]); }); describe("getRandomPlayerPokemon", () => { @@ -214,7 +225,7 @@ describe("Mystery Encounter Utils", () => { }); it("gets species for a starter tier range", () => { - const result = getRandomSpeciesByStarterCost([ 5, 8 ]); + const result = getRandomSpeciesByStarterCost([5, 8]); const pokeSpecies = getPokemonSpecies(result); expect(pokeSpecies.speciesId).toBe(result); @@ -224,14 +235,22 @@ describe("Mystery Encounter Utils", () => { it("excludes species from search", () => { // Only 9 tiers are: Kyogre, Groudon, Rayquaza, Arceus, Zacian, Koraidon, Miraidon, Terapagos - const result = getRandomSpeciesByStarterCost(9, [ Species.KYOGRE, Species.GROUDON, Species.RAYQUAZA, Species.ARCEUS, Species.KORAIDON, Species.MIRAIDON, Species.TERAPAGOS ]); + const result = getRandomSpeciesByStarterCost(9, [ + Species.KYOGRE, + Species.GROUDON, + Species.RAYQUAZA, + Species.ARCEUS, + Species.KORAIDON, + Species.MIRAIDON, + Species.TERAPAGOS, + ]); const pokeSpecies = getPokemonSpecies(result); expect(pokeSpecies.speciesId).toBe(Species.ZACIAN); }); it("gets species of specified types", () => { // Only 9 tiers are: Kyogre, Groudon, Rayquaza, Arceus, Zacian, Koraidon, Miraidon, Terapagos - const result = getRandomSpeciesByStarterCost(9, undefined, [ PokemonType.GROUND ]); + const result = getRandomSpeciesByStarterCost(9, undefined, [PokemonType.GROUND]); const pokeSpecies = getPokemonSpecies(result); expect(pokeSpecies.speciesId).toBe(Species.GROUDON); }); @@ -288,7 +307,14 @@ describe("Mystery Encounter Utils", () => { const spy = vi.spyOn(game.scene.ui, "showText"); await showEncounterText("mysteryEncounter:unit_test_dialogue"); - expect(spy).toHaveBeenCalledWith("mysteryEncounter:unit_test_dialogue", null, expect.any(Function), 0, true, null); + expect(spy).toHaveBeenCalledWith( + "mysteryEncounter:unit_test_dialogue", + null, + expect.any(Function), + 0, + true, + null, + ); }); }); @@ -299,8 +325,13 @@ describe("Mystery Encounter Utils", () => { const spy = vi.spyOn(game.scene.ui, "showDialogue"); await showEncounterDialogue("mysteryEncounter:unit_test_dialogue", "mysteryEncounter:unit_test_dialogue"); - expect(spy).toHaveBeenCalledWith("mysteryEncounter:unit_test_dialogue", "mysteryEncounter:unit_test_dialogue", null, expect.any(Function), 0); + expect(spy).toHaveBeenCalledWith( + "mysteryEncounter:unit_test_dialogue", + "mysteryEncounter:unit_test_dialogue", + null, + expect.any(Function), + 0, + ); }); }); }); - diff --git a/test/mystery-encounter/mystery-encounter.test.ts b/test/mystery-encounter/mystery-encounter.test.ts index c70193a5d56..c9d31f28717 100644 --- a/test/mystery-encounter/mystery-encounter.test.ts +++ b/test/mystery-encounter/mystery-encounter.test.ts @@ -29,7 +29,10 @@ describe("Mystery Encounters", () => { }); it("Spawns a mystery encounter", async () => { - await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]); + await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ + Species.CHARIZARD, + Species.VOLCARONA, + ]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(MysteryEncounterPhase.name); @@ -51,4 +54,3 @@ describe("Mystery Encounters", () => { expect(scene.currentBattle.mysteryEncounter).toBeUndefined(); }); }); - diff --git a/test/phases/form-change-phase.test.ts b/test/phases/form-change-phase.test.ts index 92b956d6531..deac21ed0dd 100644 --- a/test/phases/form-change-phase.test.ts +++ b/test/phases/form-change-phase.test.ts @@ -25,7 +25,7 @@ describe("Form Change Phase", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -35,16 +35,16 @@ describe("Form Change Phase", () => { }); it("Zacian should successfully change into Crowned form", async () => { - await game.classicMode.startBattle([ Species.ZACIAN ]); + await game.classicMode.startBattle([Species.ZACIAN]); // Before the form change: Should be Hero form const zacian = game.scene.getPlayerParty()[0]; expect(zacian.getFormKey()).toBe("hero-of-many-battles"); - expect(zacian.getTypes()).toStrictEqual([ PokemonType.FAIRY ]); - expect(zacian.calculateBaseStats()).toStrictEqual([ 92, 120, 115, 80, 115, 138 ]); + expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY]); + expect(zacian.calculateBaseStats()).toStrictEqual([92, 120, 115, 80, 115, 138]); // Give Zacian a Rusted Sword - const rustedSwordType = generateModifierType( modifierTypes.RARE_FORM_CHANGE_ITEM)!; + const rustedSwordType = generateModifierType(modifierTypes.RARE_FORM_CHANGE_ITEM)!; const rustedSword = rustedSwordType.newModifier(zacian); await game.scene.addModifier(rustedSword); @@ -54,7 +54,7 @@ describe("Form Change Phase", () => { // After the form change: Should be Crowned form expect(game.phaseInterceptor.log.includes("FormChangePhase")).toBe(true); expect(zacian.getFormKey()).toBe("crowned"); - expect(zacian.getTypes()).toStrictEqual([ PokemonType.FAIRY, PokemonType.STEEL ]); - expect(zacian.calculateBaseStats()).toStrictEqual([ 92, 150, 115, 80, 115, 148 ]); + expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY, PokemonType.STEEL]); + expect(zacian.calculateBaseStats()).toStrictEqual([92, 150, 115, 80, 115, 148]); }); }); diff --git a/test/phases/frenzy-move-reset.test.ts b/test/phases/frenzy-move-reset.test.ts index 0bea8e87f47..2f628f8a8c4 100644 --- a/test/phases/frenzy-move-reset.test.ts +++ b/test/phases/frenzy-move-reset.test.ts @@ -37,32 +37,32 @@ describe("Frenzy Move Reset", () => { }); /* - * Thrash (or frenzy moves in general) should not continue to run if attack fails due to paralysis - * - * This is a 3-turn Thrash test: - * 1. Thrash is selected and succeeds to hit the enemy -> Enemy Faints - * - * 2. Thrash is automatically selected but misses due to paralysis - * Note: After missing the Pokemon should stop automatically attacking - * - * 3. At the start of the 3rd turn the Player should be able to select a move/switch Pokemon/etc. - * Note: This means that BattlerTag.FRENZY is not anymore in pokemon.summonData.tags and pokemon.summonData.moveQueue is empty - * - */ + * Thrash (or frenzy moves in general) should not continue to run if attack fails due to paralysis + * + * This is a 3-turn Thrash test: + * 1. Thrash is selected and succeeds to hit the enemy -> Enemy Faints + * + * 2. Thrash is automatically selected but misses due to paralysis + * Note: After missing the Pokemon should stop automatically attacking + * + * 3. At the start of the 3rd turn the Player should be able to select a move/switch Pokemon/etc. + * Note: This means that BattlerTag.FRENZY is not anymore in pokemon.summonData.tags and pokemon.summonData.moveQueue is empty + * + */ it("should cancel frenzy move if move fails turn 2", async () => { await game.classicMode.startBattle(); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.THRASH); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceStatusActivation(false); await game.toNextTurn(); expect(playerPokemon.summonData.moveQueue.length).toBe(2); expect(playerPokemon.summonData.tags.some(tag => tag.tagType === BattlerTagType.FRENZY)).toBe(true); - await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); + await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.move.forceStatusActivation(true); await game.toNextTurn(); diff --git a/test/phases/game-over-phase.test.ts b/test/phases/game-over-phase.test.ts index 4f5e215959a..438efc85167 100644 --- a/test/phases/game-over-phase.test.ts +++ b/test/phases/game-over-phase.test.ts @@ -25,7 +25,7 @@ describe("Game Over Phase", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.MEMENTO, Moves.ICE_BEAM, Moves.SPLASH ]) + .moveset([Moves.MEMENTO, Moves.ICE_BEAM, Moves.SPLASH]) .ability(Abilities.BALL_FETCH) .battleType("single") .disableCrits() @@ -37,7 +37,7 @@ describe("Game Over Phase", () => { }); it("winning a run should give rewards", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); vi.spyOn(game.scene, "validateAchv"); // Note: `game.doKillOpponents()` does not properly handle final boss @@ -60,7 +60,7 @@ describe("Game Over Phase", () => { }); it("losing a run should not give rewards", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); vi.spyOn(game.scene, "validateAchv"); game.move.select(Moves.MEMENTO); diff --git a/test/phases/learn-move-phase.test.ts b/test/phases/learn-move-phase.test.ts index 6eb86620877..55b9d8b79d4 100644 --- a/test/phases/learn-move-phase.test.ts +++ b/test/phases/learn-move-phase.test.ts @@ -27,8 +27,8 @@ describe("Learn Move Phase", () => { }); it("If Pokemon has less than 4 moves, its newest move will be added to the lowest empty index", async () => { - game.override.moveset([ Moves.SPLASH ]); - await game.classicMode.startBattle([ Species.BULBASAUR ]); + game.override.moveset([Moves.SPLASH]); + await game.classicMode.startBattle([Species.BULBASAUR]); const pokemon = game.scene.getPlayerPokemon()!; const newMovePos = pokemon?.getMoveset().length; game.move.select(Moves.SPLASH); @@ -42,9 +42,9 @@ describe("Learn Move Phase", () => { }); it("If a pokemon has 4 move slots filled, the chosen move will be deleted and replaced", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; - const prevMoveset = [ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]; + const prevMoveset = [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]; const moveSlotNum = 3; game.move.changeMoveset(bulbasaur, prevMoveset); @@ -69,17 +69,17 @@ describe("Learn Move Phase", () => { expect(bulbasaur.level).toBeGreaterThanOrEqual(levelReq); // Check each of mr mime's moveslots to make sure the changed move (and ONLY the changed move) is different bulbasaur.getMoveset().forEach((move, index) => { - const expectedMove: Moves = (index === moveSlotNum ? levelMoveId : prevMoveset[index]); + const expectedMove: Moves = index === moveSlotNum ? levelMoveId : prevMoveset[index]; expect(move?.moveId).toBe(expectedMove); }); }); it("selecting the newly deleted move will reject it and keep old moveset", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; - const prevMoveset = [ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]; + const prevMoveset = [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]; - game.move.changeMoveset(bulbasaur, [ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]); + game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]); game.move.select(Moves.SPLASH); await game.doKillOpponents(); @@ -104,47 +104,62 @@ describe("Learn Move Phase", () => { }); it("macro should add moves in free slots normally", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; - game.move.changeMoveset(bulbasaur, [ Moves.SPLASH, Moves.ABSORB, Moves.ACID ]); + game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID]); game.move.select(Moves.SPLASH); await game.move.learnMove(Moves.SACRED_FIRE, 0, 1); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.SACRED_FIRE ]); - + expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ + Moves.SPLASH, + Moves.ABSORB, + Moves.ACID, + Moves.SACRED_FIRE, + ]); }); it("macro should replace moves", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; - game.move.changeMoveset(bulbasaur, [ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]); + game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]); game.move.select(Moves.SPLASH); await game.move.learnMove(Moves.SACRED_FIRE, 0, 1); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ Moves.SPLASH, Moves.SACRED_FIRE, Moves.ACID, Moves.VINE_WHIP ]); - + expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ + Moves.SPLASH, + Moves.SACRED_FIRE, + Moves.ACID, + Moves.VINE_WHIP, + ]); }); it("macro should allow for cancelling move learning", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR ]); + await game.classicMode.startBattle([Species.BULBASAUR]); const bulbasaur = game.scene.getPlayerPokemon()!; - game.move.changeMoveset(bulbasaur, [ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]); + game.move.changeMoveset(bulbasaur, [Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP]); game.move.select(Moves.SPLASH); await game.move.learnMove(Moves.SACRED_FIRE, 0, 4); - expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ Moves.SPLASH, Moves.ABSORB, Moves.ACID, Moves.VINE_WHIP ]); - + expect(bulbasaur.getMoveset().map(m => m?.moveId)).toEqual([ + Moves.SPLASH, + Moves.ABSORB, + Moves.ACID, + Moves.VINE_WHIP, + ]); }); it("macro works on off-field party members", async () => { - await game.classicMode.startBattle([ Species.BULBASAUR, Species.SQUIRTLE ]); + await game.classicMode.startBattle([Species.BULBASAUR, Species.SQUIRTLE]); const squirtle = game.scene.getPlayerParty()[1]!; - game.move.changeMoveset(squirtle, [ Moves.SPLASH, Moves.WATER_GUN, Moves.FREEZE_DRY, Moves.GROWL ]); + game.move.changeMoveset(squirtle, [Moves.SPLASH, Moves.WATER_GUN, Moves.FREEZE_DRY, Moves.GROWL]); game.move.select(Moves.TACKLE); await game.move.learnMove(Moves.SHELL_SMASH, 1, 0); - expect(squirtle.getMoveset().map(m => m?.moveId)).toEqual([ Moves.SHELL_SMASH, Moves.WATER_GUN, Moves.FREEZE_DRY, Moves.GROWL ]); - + expect(squirtle.getMoveset().map(m => m?.moveId)).toEqual([ + Moves.SHELL_SMASH, + Moves.WATER_GUN, + Moves.FREEZE_DRY, + Moves.GROWL, + ]); }); - }); diff --git a/test/phases/mystery-encounter-phase.test.ts b/test/phases/mystery-encounter-phase.test.ts index aa4e1683aae..f903932d2cb 100644 --- a/test/phases/mystery-encounter-phase.test.ts +++ b/test/phases/mystery-encounter-phase.test.ts @@ -34,15 +34,21 @@ describe("Mystery Encounter Phases", () => { }); describe("MysteryEncounterPhase", () => { - it("Runs to MysteryEncounterPhase", async() => { - await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]); + it("Runs to MysteryEncounterPhase", async () => { + await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ + Species.CHARIZARD, + Species.VOLCARONA, + ]); await game.phaseInterceptor.to(MysteryEncounterPhase, false); expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name); }); - it("Runs MysteryEncounterPhase", async() => { - await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]); + it("Runs MysteryEncounterPhase", async () => { + await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ + Species.CHARIZARD, + Species.VOLCARONA, + ]); game.onNextPrompt("MysteryEncounterPhase", Mode.MYSTERY_ENCOUNTER, () => { // End phase early for test @@ -51,16 +57,21 @@ describe("Mystery Encounter Phases", () => { await game.phaseInterceptor.run(MysteryEncounterPhase); expect(game.scene.mysteryEncounterSaveData.encounteredEvents.length).toBeGreaterThan(0); - expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual(MysteryEncounterType.MYSTERIOUS_CHALLENGERS); + expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual( + MysteryEncounterType.MYSTERIOUS_CHALLENGERS, + ); expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].tier).toEqual(MysteryEncounterTier.GREAT); expect(game.scene.ui.getMode()).toBe(Mode.MYSTERY_ENCOUNTER); }); - it("Selects an option for MysteryEncounterPhase", async() => { + it("Selects an option for MysteryEncounterPhase", async () => { const { ui } = game.scene; vi.spyOn(ui, "showDialogue"); vi.spyOn(ui, "showText"); - await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]); + await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ + Species.CHARIZARD, + Species.VOLCARONA, + ]); game.onNextPrompt("MysteryEncounterPhase", Mode.MESSAGE, () => { const handler = game.scene.ui.getHandler() as MessageUiHandler; @@ -75,82 +86,70 @@ describe("Mystery Encounter Phases", () => { handler.processInput(Button.ACTION); // Waitfor required so that option select messages and preOptionPhase logic are handled - await vi.waitFor(() => expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterOptionSelectedPhase.name)); + await vi.waitFor(() => + expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterOptionSelectedPhase.name), + ); expect(ui.getMode()).toBe(Mode.MESSAGE); expect(ui.showDialogue).toHaveBeenCalledTimes(1); expect(ui.showText).toHaveBeenCalledTimes(2); - expect(ui.showDialogue).toHaveBeenCalledWith(i18next.t("battle:mysteryEncounterAppeared"), "???", null, expect.any(Function)); - expect(ui.showText).toHaveBeenCalledWith(i18next.t("mysteryEncounters/mysteriousChallengers:intro"), null, expect.any(Function), 750, true); - expect(ui.showText).toHaveBeenCalledWith(i18next.t("mysteryEncounters/mysteriousChallengers:option.selected"), null, expect.any(Function), 300, true); + expect(ui.showDialogue).toHaveBeenCalledWith( + i18next.t("battle:mysteryEncounterAppeared"), + "???", + null, + expect.any(Function), + ); + expect(ui.showText).toHaveBeenCalledWith( + i18next.t("mysteryEncounters/mysteriousChallengers:intro"), + null, + expect.any(Function), + 750, + true, + ); + expect(ui.showText).toHaveBeenCalledWith( + i18next.t("mysteryEncounters/mysteriousChallengers:option.selected"), + null, + expect.any(Function), + 300, + true, + ); }); }); describe("MysteryEncounterOptionSelectedPhase", () => { - it("runs phase", () => { + it("runs phase", () => {}); - }); + it("handles onOptionSelect execution", () => {}); - it("handles onOptionSelect execution", () => { + it("hides intro visuals", () => {}); - }); - - it("hides intro visuals", () => { - - }); - - it("does not hide intro visuals if option disabled", () => { - - }); + it("does not hide intro visuals if option disabled", () => {}); }); describe("MysteryEncounterBattlePhase", () => { - it("runs phase", () => { + it("runs phase", () => {}); - }); + it("handles TRAINER_BATTLE variant", () => {}); - it("handles TRAINER_BATTLE variant", () => { + it("handles BOSS_BATTLE variant", () => {}); - }); + it("handles WILD_BATTLE variant", () => {}); - it("handles BOSS_BATTLE variant", () => { - - }); - - it("handles WILD_BATTLE variant", () => { - - }); - - it("handles double battle", () => { - - }); + it("handles double battle", () => {}); }); describe("MysteryEncounterRewardsPhase", () => { - it("runs phase", () => { + it("runs phase", () => {}); - }); + it("handles doEncounterRewards", () => {}); - it("handles doEncounterRewards", () => { - - }); - - it("handles heal phase if enabled", () => { - - }); + it("handles heal phase if enabled", () => {}); }); describe("PostMysteryEncounterPhase", () => { - it("runs phase", () => { + it("runs phase", () => {}); - }); + it("handles onPostOptionSelect execution", () => {}); - it("handles onPostOptionSelect execution", () => { - - }); - - it("runs to next EncounterPhase", () => { - - }); + it("runs to next EncounterPhase", () => {}); }); }); - diff --git a/test/phases/select-modifier-phase.test.ts b/test/phases/select-modifier-phase.test.ts index 0949eeec955..bb3d5debc7c 100644 --- a/test/phases/select-modifier-phase.test.ts +++ b/test/phases/select-modifier-phase.test.ts @@ -33,7 +33,7 @@ describe("SelectModifierPhase", () => { scene = game.scene; game.override - .moveset([ Moves.FISSURE, Moves.SPLASH ]) + .moveset([Moves.FISSURE, Moves.SPLASH]) .ability(Abilities.NO_GUARD) .startingLevel(200) .enemySpecies(Species.MAGIKARP); @@ -46,7 +46,7 @@ describe("SelectModifierPhase", () => { }); it("should start a select modifier phase", async () => { - initSceneWithoutEncounterPhase(scene, [ Species.ABRA, Species.VOLCARONA ]); + initSceneWithoutEncounterPhase(scene, [Species.ABRA, Species.VOLCARONA]); const selectModifierPhase = new SelectModifierPhase(); scene.pushPhase(selectModifierPhase); await game.phaseInterceptor.run(SelectModifierPhase); @@ -55,25 +55,32 @@ describe("SelectModifierPhase", () => { }); it("should generate random modifiers", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); game.move.select(Moves.FISSURE); await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); }); it("should modify reroll cost", async () => { - initSceneWithoutEncounterPhase(scene, [ Species.ABRA, Species.VOLCARONA ]); + initSceneWithoutEncounterPhase(scene, [Species.ABRA, Species.VOLCARONA]); const options = [ new ModifierTypeOption(modifierTypes.POTION(), 0, 100), new ModifierTypeOption(modifierTypes.ETHER(), 0, 400), - new ModifierTypeOption(modifierTypes.REVIVE(), 0, 1000) + new ModifierTypeOption(modifierTypes.REVIVE(), 0, 1000), ]; - const selectModifierPhase1 = new SelectModifierPhase(0, undefined, { guaranteedModifierTypeOptions: options }); - const selectModifierPhase2 = new SelectModifierPhase(0, undefined, { guaranteedModifierTypeOptions: options, rerollMultiplier: 2 }); + const selectModifierPhase1 = new SelectModifierPhase(0, undefined, { + guaranteedModifierTypeOptions: options, + }); + const selectModifierPhase2 = new SelectModifierPhase(0, undefined, { + guaranteedModifierTypeOptions: options, + rerollMultiplier: 2, + }); const cost1 = selectModifierPhase1.getRerollCost(false); const cost2 = selectModifierPhase2.getRerollCost(false); @@ -81,7 +88,7 @@ describe("SelectModifierPhase", () => { }); it.todo("should generate random modifiers from reroll", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; scene.shopCursorTarget = 0; @@ -91,7 +98,9 @@ describe("SelectModifierPhase", () => { // TODO: nagivate the ui to reroll somehow //const smphase = scene.getCurrentPhase() as SelectModifierPhase; expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); modifierSelectHandler.processInput(Button.ACTION); @@ -103,12 +112,12 @@ describe("SelectModifierPhase", () => { it.todo("should generate random modifiers of same tier for reroll with reroll lock", async () => { game.override.startingModifier([{ name: "LOCK_CAPSULE" }]); - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; // Just use fully random seed for this test vi.spyOn(scene, "resetSeed").mockImplementation(() => { scene.waveSeed = shiftCharCodes(scene.seed, 5); - Phaser.Math.RND.sow([ scene.waveSeed ]); + Phaser.Math.RND.sow([scene.waveSeed]); console.log("Wave Seed:", scene.waveSeed, 5); scene.rngCounter = 0; }); @@ -117,7 +126,9 @@ describe("SelectModifierPhase", () => { await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); const firstRollTiers: ModifierTier[] = modifierSelectHandler.options.map(o => o.modifierTypeOption.type.tier); @@ -126,16 +137,31 @@ describe("SelectModifierPhase", () => { expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); expect(modifierSelectHandler.options.length).toEqual(3); // Reroll with lock can still upgrade - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toEqual(firstRollTiers[0]); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toEqual(firstRollTiers[1]); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toEqual(firstRollTiers[2]); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toEqual(firstRollTiers[0]); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toEqual(firstRollTiers[1]); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toEqual(firstRollTiers[2]); }); it("should generate custom modifiers", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; const customModifiers: CustomModifierSettings = { - guaranteedModifierTypeFuncs: [ modifierTypes.MEMORY_MUSHROOM, modifierTypes.TM_ULTRA, modifierTypes.LEFTOVERS, modifierTypes.AMULET_COIN, modifierTypes.GOLDEN_PUNCH ] + guaranteedModifierTypeFuncs: [ + modifierTypes.MEMORY_MUSHROOM, + modifierTypes.TM_ULTRA, + modifierTypes.LEFTOVERS, + modifierTypes.AMULET_COIN, + modifierTypes.GOLDEN_PUNCH, + ], }; const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); scene.unshiftPhase(selectModifierPhase); @@ -143,7 +169,9 @@ describe("SelectModifierPhase", () => { await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("MEMORY_MUSHROOM"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toEqual("TM_ULTRA"); @@ -153,10 +181,16 @@ describe("SelectModifierPhase", () => { }); it("should generate custom modifier tiers that can upgrade from luck", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; const customModifiers: CustomModifierSettings = { - guaranteedModifierTiers: [ ModifierTier.COMMON, ModifierTier.GREAT, ModifierTier.ULTRA, ModifierTier.ROGUE, ModifierTier.MASTER ] + guaranteedModifierTiers: [ + ModifierTier.COMMON, + ModifierTier.GREAT, + ModifierTier.ULTRA, + ModifierTier.ROGUE, + ModifierTier.MASTER, + ], }; const pokemon = new PlayerPokemon(getPokemonSpecies(Species.BULBASAUR), 10, undefined, 0, undefined, true, 2); @@ -172,30 +206,48 @@ describe("SelectModifierPhase", () => { await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(5); - expect(modifierSelectHandler.options[0].modifierTypeOption.type.tier - modifierSelectHandler.options[0].modifierTypeOption.upgradeCount).toEqual(ModifierTier.COMMON); - expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier - modifierSelectHandler.options[1].modifierTypeOption.upgradeCount).toEqual(ModifierTier.GREAT); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.tier - modifierSelectHandler.options[2].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ULTRA); - expect(modifierSelectHandler.options[3].modifierTypeOption.type.tier - modifierSelectHandler.options[3].modifierTypeOption.upgradeCount).toEqual(ModifierTier.ROGUE); - expect(modifierSelectHandler.options[4].modifierTypeOption.type.tier - modifierSelectHandler.options[4].modifierTypeOption.upgradeCount).toEqual(ModifierTier.MASTER); + expect( + modifierSelectHandler.options[0].modifierTypeOption.type.tier - + modifierSelectHandler.options[0].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.COMMON); + expect( + modifierSelectHandler.options[1].modifierTypeOption.type.tier - + modifierSelectHandler.options[1].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.GREAT); + expect( + modifierSelectHandler.options[2].modifierTypeOption.type.tier - + modifierSelectHandler.options[2].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ULTRA); + expect( + modifierSelectHandler.options[3].modifierTypeOption.type.tier - + modifierSelectHandler.options[3].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.ROGUE); + expect( + modifierSelectHandler.options[4].modifierTypeOption.type.tier - + modifierSelectHandler.options[4].modifierTypeOption.upgradeCount, + ).toEqual(ModifierTier.MASTER); }); it("should generate custom modifiers and modifier tiers together", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; const customModifiers: CustomModifierSettings = { - guaranteedModifierTypeFuncs: [ modifierTypes.MEMORY_MUSHROOM, modifierTypes.TM_COMMON ], - guaranteedModifierTiers: [ ModifierTier.MASTER, ModifierTier.MASTER ] + guaranteedModifierTypeFuncs: [modifierTypes.MEMORY_MUSHROOM, modifierTypes.TM_COMMON], + guaranteedModifierTiers: [ModifierTier.MASTER, ModifierTier.MASTER], }; const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); scene.unshiftPhase(selectModifierPhase); game.move.select(Moves.SPLASH); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(4); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("MEMORY_MUSHROOM"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.id).toEqual("TM_COMMON"); @@ -204,21 +256,22 @@ describe("SelectModifierPhase", () => { }); it("should fill remaining modifiers if fillRemaining is true with custom modifiers", async () => { - await game.classicMode.startBattle([ Species.ABRA, Species.VOLCARONA ]); + await game.classicMode.startBattle([Species.ABRA, Species.VOLCARONA]); scene.money = 1000000; const customModifiers: CustomModifierSettings = { - guaranteedModifierTypeFuncs: [ modifierTypes.MEMORY_MUSHROOM ], - guaranteedModifierTiers: [ ModifierTier.MASTER ], - fillRemaining: true + guaranteedModifierTypeFuncs: [modifierTypes.MEMORY_MUSHROOM], + guaranteedModifierTiers: [ModifierTier.MASTER], + fillRemaining: true, }; const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); scene.unshiftPhase(selectModifierPhase); game.move.select(Moves.SPLASH); await game.phaseInterceptor.run(SelectModifierPhase); - expect(scene.ui.getMode()).to.equal(Mode.MODIFIER_SELECT); - const modifierSelectHandler = scene.ui.handlers.find(h => h instanceof ModifierSelectUiHandler) as ModifierSelectUiHandler; + const modifierSelectHandler = scene.ui.handlers.find( + h => h instanceof ModifierSelectUiHandler, + ) as ModifierSelectUiHandler; expect(modifierSelectHandler.options.length).toEqual(3); expect(modifierSelectHandler.options[0].modifierTypeOption.type.id).toEqual("MEMORY_MUSHROOM"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.tier).toEqual(ModifierTier.MASTER); diff --git a/test/plugins/api/pokerogue-account-api.test.ts b/test/plugins/api/pokerogue-account-api.test.ts index e9033c859de..9ec98b6a59f 100644 --- a/test/plugins/api/pokerogue-account-api.test.ts +++ b/test/plugins/api/pokerogue-account-api.test.ts @@ -30,7 +30,7 @@ describe("Pokerogue Account API", () => { }; server.use(http.get(`${apiBase}/account/info`, () => HttpResponse.json(expectedAccountInfo))); - const [ accountInfo, status ] = await accountApi.getInfo(); + const [accountInfo, status] = await accountApi.getInfo(); expect(accountInfo).toEqual(expectedAccountInfo); expect(status).toBe(200); @@ -39,7 +39,7 @@ describe("Pokerogue Account API", () => { it("should return null + status-code anad report a warning on FAILURE", async () => { server.use(http.get(`${apiBase}/account/info`, () => new HttpResponse("", { status: 401 }))); - const [ accountInfo, status ] = await accountApi.getInfo(); + const [accountInfo, status] = await accountApi.getInfo(); expect(accountInfo).toBeNull(); expect(status).toBe(401); @@ -49,7 +49,7 @@ describe("Pokerogue Account API", () => { it("should return null + 500 anad report a warning on ERROR", async () => { server.use(http.get(`${apiBase}/account/info`, () => HttpResponse.error())); - const [ accountInfo, status ] = await accountApi.getInfo(); + const [accountInfo, status] = await accountApi.getInfo(); expect(accountInfo).toBeNull(); expect(status).toBe(500); @@ -70,7 +70,7 @@ describe("Pokerogue Account API", () => { it("should return error message on FAILURE", async () => { server.use( - http.post(`${apiBase}/account/register`, () => new HttpResponse("Username is already taken", { status: 400 })) + http.post(`${apiBase}/account/register`, () => new HttpResponse("Username is already taken", { status: 400 })), ); const error = await accountApi.register(registerParams); @@ -78,7 +78,7 @@ describe("Pokerogue Account API", () => { expect(error).toBe("Username is already taken"); }); - it("should return \"Unknown error\" and report a warning on ERROR", async () => { + it('should return "Unknown error" and report a warning on ERROR', async () => { server.use(http.post(`${apiBase}/account/register`, () => HttpResponse.error())); const error = await accountApi.register(registerParams); @@ -103,7 +103,7 @@ describe("Pokerogue Account API", () => { it("should return error message and report a warning on FAILURE", async () => { server.use( - http.post(`${apiBase}/account/login`, () => new HttpResponse("Password is incorrect", { status: 401 })) + http.post(`${apiBase}/account/login`, () => new HttpResponse("Password is incorrect", { status: 401 })), ); const error = await accountApi.login(loginParams); @@ -112,7 +112,7 @@ describe("Pokerogue Account API", () => { expect(console.warn).toHaveBeenCalledWith("Login failed!", 401, "Unauthorized"); }); - it("should return \"Unknown error\" and report a warning on ERROR", async () => { + it('should return "Unknown error" and report a warning on ERROR', async () => { server.use(http.post(`${apiBase}/account/login`, () => HttpResponse.error())); const error = await accountApi.login(loginParams); diff --git a/test/plugins/api/pokerogue-admin-api.test.ts b/test/plugins/api/pokerogue-admin-api.test.ts index 5af55967ae2..0ce727b88da 100644 --- a/test/plugins/api/pokerogue-admin-api.test.ts +++ b/test/plugins/api/pokerogue-admin-api.test.ts @@ -25,7 +25,10 @@ describe("Pokerogue Admin API", () => { }); describe("Link Account to Discord", () => { - const params: LinkAccountToDiscordIdRequest = { username: "test", discordId: "test-12575756" }; + const params: LinkAccountToDiscordIdRequest = { + username: "test", + discordId: "test-12575756", + }; it("should return null on SUCCESS", async () => { server.use(http.post(`${apiBase}/admin/account/discordLink`, () => HttpResponse.json(true))); @@ -64,7 +67,10 @@ describe("Pokerogue Admin API", () => { }); describe("Unlink Account from Discord", () => { - const params: UnlinkAccountFromDiscordIdRequest = { username: "test", discordId: "test-12575756" }; + const params: UnlinkAccountFromDiscordIdRequest = { + username: "test", + discordId: "test-12575756", + }; it("should return null on SUCCESS", async () => { server.use(http.post(`${apiBase}/admin/account/discordUnlink`, () => HttpResponse.json(true))); @@ -103,7 +109,10 @@ describe("Pokerogue Admin API", () => { }); describe("Link Account to Google", () => { - const params: LinkAccountToGoogledIdRequest = { username: "test", googleId: "test-12575756" }; + const params: LinkAccountToGoogledIdRequest = { + username: "test", + googleId: "test-12575756", + }; it("should return null on SUCCESS", async () => { server.use(http.post(`${apiBase}/admin/account/googleLink`, () => HttpResponse.json(true))); @@ -142,7 +151,10 @@ describe("Pokerogue Admin API", () => { }); describe("Unlink Account from Google", () => { - const params: UnlinkAccountFromGoogledIdRequest = { username: "test", googleId: "test-12575756" }; + const params: UnlinkAccountFromGoogledIdRequest = { + username: "test", + googleId: "test-12575756", + }; it("should return null on SUCCESS", async () => { server.use(http.post(`${apiBase}/admin/account/googleUnlink`, () => HttpResponse.json(true))); @@ -193,7 +205,7 @@ describe("Pokerogue Admin API", () => { }; server.use(http.get(`${apiBase}/admin/account/adminSearch`, () => HttpResponse.json(responseData))); - const [ data, err ] = await adminApi.searchAccount(params); + const [data, err] = await adminApi.searchAccount(params); expect(data).toStrictEqual(responseData); expect(err).toBeUndefined(); @@ -202,7 +214,7 @@ describe("Pokerogue Admin API", () => { it("should return [undefined, ERR_GENERIC] and report a warning on on FAILURE", async () => { server.use(http.get(`${apiBase}/admin/account/adminSearch`, () => new HttpResponse("", { status: 400 }))); - const [ data, err ] = await adminApi.searchAccount(params); + const [data, err] = await adminApi.searchAccount(params); expect(data).toBeUndefined(); expect(err).toBe(adminApi.ERR_GENERIC); @@ -212,7 +224,7 @@ describe("Pokerogue Admin API", () => { it("should return [undefined, ERR_USERNAME_NOT_FOUND] and report a warning on on 404", async () => { server.use(http.get(`${apiBase}/admin/account/adminSearch`, () => new HttpResponse("", { status: 404 }))); - const [ data, err ] = await adminApi.searchAccount(params); + const [data, err] = await adminApi.searchAccount(params); expect(data).toBeUndefined(); expect(err).toBe(adminApi.ERR_USERNAME_NOT_FOUND); @@ -222,7 +234,7 @@ describe("Pokerogue Admin API", () => { it("should return [undefined, ERR_GENERIC] and report a warning on on ERROR", async () => { server.use(http.get(`${apiBase}/admin/account/adminSearch`, () => HttpResponse.error())); - const [ data, err ] = await adminApi.searchAccount(params); + const [data, err] = await adminApi.searchAccount(params); expect(data).toBeUndefined(); expect(err).toBe(adminApi.ERR_GENERIC); diff --git a/test/plugins/api/pokerogue-session-savedata-api.test.ts b/test/plugins/api/pokerogue-session-savedata-api.test.ts index d8103428d59..67abc9c9336 100644 --- a/test/plugins/api/pokerogue-session-savedata-api.test.ts +++ b/test/plugins/api/pokerogue-session-savedata-api.test.ts @@ -29,7 +29,7 @@ describe("Pokerogue Session Savedata API", () => { const params: NewClearSessionSavedataRequest = { clientSessionId: "test-session-id", isVictory: true, - slot: 3 + slot: 3, }; it("should return true on SUCCESS", async () => { @@ -132,7 +132,7 @@ describe("Pokerogue Session Savedata API", () => { it("should return an error string on FAILURE", async () => { server.use( - http.get(`${apiBase}/savedata/session/delete`, () => new HttpResponse("Failed to delete!", { status: 400 })) + http.get(`${apiBase}/savedata/session/delete`, () => new HttpResponse("Failed to delete!", { status: 400 })), ); const error = await sessionSavedataApi.delete(params); @@ -162,8 +162,8 @@ describe("Pokerogue Session Savedata API", () => { http.post(`${apiBase}/savedata/session/clear`, () => HttpResponse.json({ success: true, - }) - ) + }), + ), ); const { success, error } = await sessionSavedataApi.clear(params, {} as SessionSaveData); @@ -178,8 +178,8 @@ describe("Pokerogue Session Savedata API", () => { HttpResponse.json({ success: false, error: "Failed to clear!", - }) - ) + }), + ), ); const { success, error } = await sessionSavedataApi.clear(params, {} as SessionSaveData); diff --git a/test/plugins/api/pokerogue-system-savedata-api.test.ts b/test/plugins/api/pokerogue-system-savedata-api.test.ts index f108e22ee2c..81d863049f0 100644 --- a/test/plugins/api/pokerogue-system-savedata-api.test.ts +++ b/test/plugins/api/pokerogue-system-savedata-api.test.ts @@ -59,8 +59,8 @@ describe("Pokerogue System Savedata API", () => { trainerId: 123456789, } as SystemSaveData, valid: true, - }) - ) + }), + ), ); const savedata = await systemSavedataApi.verify(params); @@ -76,8 +76,8 @@ describe("Pokerogue System Savedata API", () => { trainerId: 123456789, } as SystemSaveData, valid: false, - }) - ) + }), + ), ); const savedata = await systemSavedataApi.verify(params); diff --git a/test/reload.test.ts b/test/reload.test.ts index 019da0a4c2a..f54885eccfb 100644 --- a/test/reload.test.ts +++ b/test/reload.test.ts @@ -26,7 +26,10 @@ describe("Reload", () => { beforeEach(() => { game = new GameManager(phaserGame); - vi.spyOn(pokerogueApi, "getGameTitleStats").mockResolvedValue({ battleCount: -1, playerCount: -1 }); + vi.spyOn(pokerogueApi, "getGameTitleStats").mockResolvedValue({ + battleCount: -1, + playerCount: -1, + }); vi.spyOn(pokerogueApi.daily, "getSeed").mockResolvedValue("test-seed"); }); @@ -48,7 +51,7 @@ describe("Reload", () => { .battleType("single") .startingLevel(100) // Avoid levelling up .disableTrainerWaves() - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .enemyMoveset(Moves.SPLASH); await game.dailyMode.startBattle(); @@ -81,7 +84,7 @@ describe("Reload", () => { .battleType("single") .startingLevel(100) // Avoid levelling up .disableTrainerWaves() - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .enemyMoveset(Moves.SPLASH); await game.classicMode.startBattle(); // Apparently daily mode would override the biome @@ -153,7 +156,7 @@ describe("Reload", () => { it("should not have RNG inconsistencies at a Daily run wave 50 Boss fight", async () => { game.override.battleType("single").startingWave(50); - await game.runToFinalBossEncounter([ Species.BULBASAUR ], GameModes.DAILY); + await game.runToFinalBossEncounter([Species.BULBASAUR], GameModes.DAILY); const preReloadRngState = Phaser.Math.RND.state(); diff --git a/test/settingMenu/helpers/inGameManip.ts b/test/settingMenu/helpers/inGameManip.ts index b81e577f5b9..ca1fac3bc65 100644 --- a/test/settingMenu/helpers/inGameManip.ts +++ b/test/settingMenu/helpers/inGameManip.ts @@ -45,7 +45,9 @@ export class InGameManip { icon = "KEY_" + icon; } this.icon = this.config.icons[icon]; - expect(getIconForLatestInput(this.configs, this.latestSource, this.selectedDevice, this.settingName)).toEqual(this.icon); + expect(getIconForLatestInput(this.configs, this.latestSource, this.selectedDevice, this.settingName)).toEqual( + this.icon, + ); return this; } diff --git a/test/settingMenu/helpers/menuManip.ts b/test/settingMenu/helpers/menuManip.ts index 1d53b845047..1ddd842c864 100644 --- a/test/settingMenu/helpers/menuManip.ts +++ b/test/settingMenu/helpers/menuManip.ts @@ -40,7 +40,10 @@ export class MenuManip { const parts = input.split("_"); // Skip the first part and join the rest with an underscore - const result = parts.slice(1).map(part => part.toUpperCase()).join("_"); + const result = parts + .slice(1) + .map(part => part.toUpperCase()) + .join("_"); return result; } @@ -54,7 +57,7 @@ export class MenuManip { } iconDisplayedIs(icon) { - if (!(icon.toUpperCase().includes("KEY_"))) { + if (!icon.toUpperCase().includes("KEY_")) { icon = "KEY_" + icon.toUpperCase(); } this.iconDisplayed = this.config.icons[icon]; @@ -110,7 +113,6 @@ export class MenuManip { this.confirm(); } - confirm() { assign(this.config, this.settingName, this.keycode); } diff --git a/test/settingMenu/rebinding_setting.test.ts b/test/settingMenu/rebinding_setting.test.ts index 46a37f4e137..28b5d73d7cc 100644 --- a/test/settingMenu/rebinding_setting.test.ts +++ b/test/settingMenu/rebinding_setting.test.ts @@ -9,10 +9,12 @@ import { InGameManip } from "#test/settingMenu/helpers/inGameManip"; import { MenuManip } from "#test/settingMenu/helpers/menuManip"; import { beforeEach, describe, expect, it } from "vitest"; - describe("Test Rebinding", () => { + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let config; + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let inGame; + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let inTheSettingMenu; const configs: Map = new Map(); const selectedDevice = { @@ -100,7 +102,12 @@ describe("Test Rebinding", () => { it("Check prevent rebind indirectly the d-pad buttons", () => { inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("A"); inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").iconDisplayedIs("D"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("A").weWantThisBindInstead("LEFT").weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("A") + .weWantThisBindInstead("LEFT") + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Left"); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); @@ -109,7 +116,12 @@ describe("Test Rebinding", () => { it("Swap alt with a d-pad main", () => { inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("W").weCantOverrideThisBind().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Up") + .iconDisplayedIs("KEY_ARROW_UP") + .weWantThisBindInstead("W") + .weCantOverrideThisBind() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); }); @@ -118,19 +130,37 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .weWantThisBindInstead("RIGHT") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("UP").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .weWantThisBindInstead("UP") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .weWantThisBindInstead("RIGHT") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); @@ -142,19 +172,31 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_A").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_A") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_D").weWantThisBindInstead("W").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_D") + .weWantThisBindInstead("W") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Left"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_W").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_W") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left"); @@ -162,18 +204,36 @@ describe("Test Rebinding", () => { }); it("Check if triple swap d-pad is prevented", () => { - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("RIGHT").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .weWantThisBindInstead("RIGHT") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_RIGHT").weWantThisBindInstead("UP").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Right") + .iconDisplayedIs("KEY_ARROW_RIGHT") + .weWantThisBindInstead("UP") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").weWantThisBindInstead("LEFT").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .weWantThisBindInstead("LEFT") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("LEFT").weShouldTriggerTheButton("Button_Left"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); @@ -184,19 +244,31 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_A").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_A") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").thereShouldBeNoIcon().weWantThisBindInstead("W").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Right") + .thereShouldBeNoIcon() + .weWantThisBindInstead("W") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Right"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_D").weWantThisBindInstead("A").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_D") + .weWantThisBindInstead("A") + .confirm(); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); @@ -216,12 +288,20 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Button_Cycle_Shiny"); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Shiny").iconDisplayedIs("KEY_R").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Cycle_Shiny") + .iconDisplayedIs("KEY_R") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny"); inGame.whenWePressOnKeyboard("R").nothingShouldHappen(); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Form").iconDisplayedIs("KEY_F").weWantThisBindInstead("R").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Cycle_Form") + .iconDisplayedIs("KEY_F") + .weWantThisBindInstead("R") + .confirm(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny"); inGame.whenWePressOnKeyboard("R").weShouldTriggerTheButton("Button_Cycle_Form"); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); @@ -231,7 +311,11 @@ describe("Test Rebinding", () => { it("Swap alt with a key not binded yet", () => { inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_W").weWantThisBindInstead("B").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .iconDisplayedIs("KEY_W") + .weWantThisBindInstead("B") + .confirm(); inGame.whenWePressOnKeyboard("W").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Up"); }); @@ -252,7 +336,11 @@ describe("Test Rebinding", () => { inTheSettingMenu.whenWeDelete("Alt_Button_Left").thereShouldBeNoIconAnymore(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("B").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .thereShouldBeNoIcon() + .weWantThisBindInstead("B") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left"); }); @@ -261,13 +349,21 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Shiny").iconDisplayedIs("KEY_R").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Cycle_Shiny") + .iconDisplayedIs("KEY_R") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("R").nothingShouldHappen(); inGame.whenWePressOnKeyboard("F").weShouldTriggerTheButton("Button_Cycle_Form"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Button_Cycle_Shiny"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Form").iconDisplayedIs("KEY_F").weWantThisBindInstead("W").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Cycle_Form") + .iconDisplayedIs("KEY_F") + .weWantThisBindInstead("W") + .confirm(); inGame.whenWePressOnKeyboard("R").nothingShouldHappen(); inGame.whenWePressOnKeyboard("F").nothingShouldHappen(); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Button_Cycle_Form"); @@ -283,7 +379,11 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Down").iconDisplayedIs("KEY_S").weWantThisBindInstead("B").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Down") + .iconDisplayedIs("KEY_S") + .weWantThisBindInstead("B") + .confirm(); inGame.whenWePressOnKeyboard("R").nothingShouldHappen(); inGame.whenWePressOnKeyboard("F").nothingShouldHappen(); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Button_Cycle_Form"); @@ -293,9 +393,7 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Down"); }); - it("Delete bind then assign not already existing button", () => { - inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); @@ -303,23 +401,34 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("B").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .thereShouldBeNoIcon() + .weWantThisBindInstead("B") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left"); }); - it("change alt bind to not already existing button, than another one alt bind with another not already existing button", () => { inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); inGame.whenWePressOnKeyboard("B").nothingShouldHappen(); inGame.whenWePressOnKeyboard("U").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").iconDisplayedIs("KEY_A").weWantThisBindInstead("B").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .iconDisplayedIs("KEY_A") + .weWantThisBindInstead("B") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("U").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Right").iconDisplayedIs("KEY_D").weWantThisBindInstead("U").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Right") + .iconDisplayedIs("KEY_D") + .weWantThisBindInstead("U") + .confirm(); inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); inGame.whenWePressOnKeyboard("B").weShouldTriggerTheButton("Alt_Button_Left"); @@ -331,26 +440,38 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").weWantThisBindInstead("RIGHT").weCantOverrideThisBind().weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Up") + .iconDisplayedIs("KEY_ARROW_UP") + .weWantThisBindInstead("RIGHT") + .weCantOverrideThisBind() + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_W").weWantThisBindInstead("D").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .iconDisplayedIs("KEY_W") + .weWantThisBindInstead("D") + .confirm(); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("W").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Up"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_D").weWantThisBindInstead("W").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .iconDisplayedIs("KEY_D") + .weWantThisBindInstead("W") + .confirm(); inGame.whenWePressOnKeyboard("UP").weShouldTriggerTheButton("Button_Up"); inGame.whenWePressOnKeyboard("RIGHT").weShouldTriggerTheButton("Button_Right"); inGame.whenWePressOnKeyboard("W").weShouldTriggerTheButton("Alt_Button_Up"); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); }); - it("Delete 2 bind then reassign one of them", () => { - inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("D").weShouldTriggerTheButton("Alt_Button_Right"); @@ -362,7 +483,11 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("A").nothingShouldHappen(); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Left").thereShouldBeNoIcon().weWantThisBindInstead("A").confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Left") + .thereShouldBeNoIcon() + .weWantThisBindInstead("A") + .confirm(); inGame.whenWePressOnKeyboard("A").weShouldTriggerTheButton("Alt_Button_Left"); inGame.whenWePressOnKeyboard("D").nothingShouldHappen(); }); @@ -391,15 +516,53 @@ describe("Test Rebinding", () => { inGame.whenWePressOnKeyboard("ESC").weShouldTriggerTheButton("Button_Menu"); inGame.whenWePressOnKeyboard("HOME").nothingShouldHappen(); inGame.whenWePressOnKeyboard("DELETE").nothingShouldHappen(); - inTheSettingMenu.whenCursorIsOnSetting("Button_Submit").iconDisplayedIs("KEY_ENTER").whenWeDelete().iconDisplayedIs("KEY_ENTER"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Up").iconDisplayedIs("KEY_ARROW_UP").whenWeDelete().iconDisplayedIs("KEY_ARROW_UP"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Down").iconDisplayedIs("KEY_ARROW_DOWN").whenWeDelete().iconDisplayedIs("KEY_ARROW_DOWN"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Left").iconDisplayedIs("KEY_ARROW_LEFT").whenWeDelete().iconDisplayedIs("KEY_ARROW_LEFT"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Right").iconDisplayedIs("KEY_ARROW_RIGHT").whenWeDelete().iconDisplayedIs("KEY_ARROW_RIGHT"); - inTheSettingMenu.whenCursorIsOnSetting("Button_Menu").iconDisplayedIs("KEY_ESC").whenWeDelete().iconDisplayedIs("KEY_ESC"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").iconDisplayedIs("KEY_W").whenWeDelete().thereShouldBeNoIconAnymore(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").thereShouldBeNoIcon().weWantThisBindInstead("DELETE").weCantAssignThisKey().butLetsForceIt(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Up").thereShouldBeNoIcon().weWantThisBindInstead("HOME").weCantAssignThisKey().butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Submit") + .iconDisplayedIs("KEY_ENTER") + .whenWeDelete() + .iconDisplayedIs("KEY_ENTER"); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Up") + .iconDisplayedIs("KEY_ARROW_UP") + .whenWeDelete() + .iconDisplayedIs("KEY_ARROW_UP"); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Down") + .iconDisplayedIs("KEY_ARROW_DOWN") + .whenWeDelete() + .iconDisplayedIs("KEY_ARROW_DOWN"); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Left") + .iconDisplayedIs("KEY_ARROW_LEFT") + .whenWeDelete() + .iconDisplayedIs("KEY_ARROW_LEFT"); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Right") + .iconDisplayedIs("KEY_ARROW_RIGHT") + .whenWeDelete() + .iconDisplayedIs("KEY_ARROW_RIGHT"); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Menu") + .iconDisplayedIs("KEY_ESC") + .whenWeDelete() + .iconDisplayedIs("KEY_ESC"); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .iconDisplayedIs("KEY_W") + .whenWeDelete() + .thereShouldBeNoIconAnymore(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .thereShouldBeNoIcon() + .weWantThisBindInstead("DELETE") + .weCantAssignThisKey() + .butLetsForceIt(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Up") + .thereShouldBeNoIcon() + .weWantThisBindInstead("HOME") + .weCantAssignThisKey() + .butLetsForceIt(); inGame.whenWePressOnKeyboard("DELETE").nothingShouldHappen(); inGame.whenWePressOnKeyboard("HOME").nothingShouldHappen(); inGame.whenWePressOnKeyboard("W").nothingShouldHappen(); @@ -407,8 +570,20 @@ describe("Test Rebinding", () => { it("check to delete all the binds of an action", () => { inGame.whenWePressOnKeyboard("V").weShouldTriggerTheButton("Button_Cycle_Tera"); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Cycle_Tera").thereShouldBeNoIcon().weWantThisBindInstead("K").confirm(); - inTheSettingMenu.whenCursorIsOnSetting("Alt_Button_Cycle_Tera").iconDisplayedIs("KEY_K").whenWeDelete().thereShouldBeNoIconAnymore(); - inTheSettingMenu.whenCursorIsOnSetting("Button_Cycle_Tera").iconDisplayedIs("KEY_V").whenWeDelete().thereShouldBeNoIconAnymore(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Cycle_Tera") + .thereShouldBeNoIcon() + .weWantThisBindInstead("K") + .confirm(); + inTheSettingMenu + .whenCursorIsOnSetting("Alt_Button_Cycle_Tera") + .iconDisplayedIs("KEY_K") + .whenWeDelete() + .thereShouldBeNoIconAnymore(); + inTheSettingMenu + .whenCursorIsOnSetting("Button_Cycle_Tera") + .iconDisplayedIs("KEY_V") + .whenWeDelete() + .thereShouldBeNoIconAnymore(); }); }); diff --git a/test/sprites/pokemonSprite.test.ts b/test/sprites/pokemonSprite.test.ts index 43749015e1c..5bd08a58cda 100644 --- a/test/sprites/pokemonSprite.test.ts +++ b/test/sprites/pokemonSprite.test.ts @@ -42,7 +42,7 @@ describe("check if every variant's sprite are correctly set", () => { const errors: string[] = []; const trimmedDirpath = `variant${path.sep}${dirpath.split(rootDir)[1]}`; if (fs.existsSync(dirpath)) { - const files = fs.readdirSync(dirpath).filter((filename) => !/^\..*/.test(filename)); + const files = fs.readdirSync(dirpath).filter(filename => !/^\..*/.test(filename)); for (const filename of files) { const filePath = `${dirpath}${filename}`; const trimmedFilePath = `${trimmedDirpath}${filename}`; @@ -54,7 +54,7 @@ describe("check if every variant's sprite are correctly set", () => { if (name.includes("_")) { const id = name.split("_")[0]; const variant = name.split("_")[1]; - const index = parseInt(variant, 10) - 1; + const index = Number.parseInt(variant, 10) - 1; if (ext !== "json") { const urlJsonFile = `${dirpath}${id}.json`; if (mlist.hasOwnProperty(id)) { @@ -78,7 +78,9 @@ describe("check if every variant's sprite are correctly set", () => { const trimmedUrlSpriteFilepath = `${trimmedDirpath}${id}_${variant}.json`; const spriteFileExists = fs.existsSync(urlSpriteJsonFile); if (spriteFileExists) { - errors.push(`[${id}] [${mlist[id]}] - the value should be 2 for the index ${index} - ${trimmedUrlSpriteFilepath}`); + errors.push( + `[${id}] [${mlist[id]}] - the value should be 2 for the index ${index} - ${trimmedUrlSpriteFilepath}`, + ); } } } @@ -92,10 +94,12 @@ describe("check if every variant's sprite are correctly set", () => { for (const key of Object.keys(data)) { if (mlist[name][key] !== 1) { // if 2, check if json there - const urlSpriteJsonFile = `${dirpath}${name}_${parseInt(key, 10) + 1}.json`; + const urlSpriteJsonFile = `${dirpath}${name}_${Number.parseInt(key, 10) + 1}.json`; const spriteFileExists = fs.existsSync(urlSpriteJsonFile); if (!spriteFileExists) { - errors.push(`[${name}] [${mlist[name]}] - the value should be 1 for the index ${key} - ${trimmedFilePath}`); + errors.push( + `[${name}] [${mlist[name]}] - the value should be 1 for the index ${key} - ${trimmedFilePath}`, + ); } } } @@ -109,10 +113,9 @@ describe("check if every variant's sprite are correctly set", () => { const errors: string[] = []; for (const key of Object.keys(keys)) { const row = keys[key]; - for (const [ index, elm ] of row.entries()) { + for (const [index, elm] of row.entries()) { let url: string; if (elm === 0) { - continue; } else if (elm === 1) { url = `${key}.json`; const filePath = `${dirPath}${url}`; @@ -122,13 +125,13 @@ describe("check if every variant's sprite are correctly set", () => { errors.push(`index: ${index} - ${filePath}`); } } else if (elm === 2) { - url = `${key}_${parseInt(index, 10) + 1}.png`; + url = `${key}_${Number.parseInt(index, 10) + 1}.png`; let filePath = `${dirPath}${url}`; if (!fs.existsSync(filePath)) { errors.push(filePath); } - url = `${key}_${parseInt(index, 10) + 1}.json`; + url = `${key}_${Number.parseInt(index, 10) + 1}.json`; filePath = `${dirPath}${url}`; if (!fs.existsSync(filePath)) { errors.push(filePath); @@ -243,7 +246,7 @@ describe("check if every variant's sprite are correctly set", () => { it("look over every file in variant back male and check if present in masterlist", () => { const dirPath = `${rootDir}back${path.sep}`; const backMaleVariant = deepCopy(backVariant); - const errors = getMissingMasterlist(backMaleVariant, dirPath, [ "female" ]); + const errors = getMissingMasterlist(backMaleVariant, dirPath, ["female"]); if (errors.length) { console.log("errors for ", dirPath, errors); } @@ -261,7 +264,7 @@ describe("check if every variant's sprite are correctly set", () => { it("look over every file in variant exp back male and check if present in masterlist", () => { const dirPath = `${rootDir}exp${path.sep}back${path.sep}`; - const errors = getMissingMasterlist(expVariant.back, dirPath, [ "female" ]); + const errors = getMissingMasterlist(expVariant.back, dirPath, ["female"]); if (errors.length) { console.log("errors for ", dirPath, errors); } @@ -279,7 +282,7 @@ describe("check if every variant's sprite are correctly set", () => { it("look over every file in variant exp male and check if present in masterlist", () => { const dirPath = `${rootDir}exp${path.sep}`; - const errors = getMissingMasterlist(expVariant, dirPath, [ "back", "female" ]); + const errors = getMissingMasterlist(expVariant, dirPath, ["back", "female"]); if (errors.length) { console.log("errors for ", dirPath, errors); } @@ -288,7 +291,7 @@ describe("check if every variant's sprite are correctly set", () => { it("look over every file in variant root and check if present in masterlist", () => { const dirPath = `${rootDir}`; - const errors = getMissingMasterlist(masterlist, dirPath, [ "back", "female", "exp", "icons" ]); + const errors = getMissingMasterlist(masterlist, dirPath, ["back", "female", "exp", "icons"]); if (errors.length) { console.log("errors for ", dirPath, errors); } diff --git a/test/sprites/spritesUtils.ts b/test/sprites/spritesUtils.ts index f3ee634cd76..0c4bcd875fb 100644 --- a/test/sprites/spritesUtils.ts +++ b/test/sprites/spritesUtils.ts @@ -1,7 +1,7 @@ -const fs = require("fs"); -const path = require("path"); +const fs = require("node:fs"); +const path = require("node:path"); -export function getAppRootDir () { +export function getAppRootDir() { let currentDir = __dirname; while (!fs.existsSync(path.join(currentDir, "package.json"))) { currentDir = path.join(currentDir, ".."); diff --git a/test/system/game_data.test.ts b/test/system/game_data.test.ts index f7940567746..93e615711c4 100644 --- a/test/system/game_data.test.ts +++ b/test/system/game_data.test.ts @@ -21,7 +21,7 @@ describe("System - Game Data", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.SPLASH ]) + .moveset([Moves.SPLASH]) .battleType("single") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH); @@ -35,7 +35,7 @@ describe("System - Game Data", () => { beforeEach(() => { vi.spyOn(BattleScene, "bypassLogin", "get").mockReturnValue(false); vi.spyOn(game.scene.gameData, "getSessionSaveData").mockReturnValue({} as SessionSaveData); - vi.spyOn(account, "updateUserInfo").mockImplementation(async () => [ true, 1 ]); + vi.spyOn(account, "updateUserInfo").mockImplementation(async () => [true, 1]); }); it("should return [true, true] if bypassLogin is true", async () => { @@ -43,33 +43,39 @@ describe("System - Game Data", () => { const result = await game.scene.gameData.tryClearSession(0); - expect(result).toEqual([ true, true ]); + expect(result).toEqual([true, true]); }); it("should return [true, true] if successful", async () => { - vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ success: true }); + vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ + success: true, + }); const result = await game.scene.gameData.tryClearSession(0); - expect(result).toEqual([ true, true ]); + expect(result).toEqual([true, true]); expect(account.updateUserInfo).toHaveBeenCalled(); }); it("should return [true, false] if not successful", async () => { - vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ success: false }); + vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ + success: false, + }); const result = await game.scene.gameData.tryClearSession(0); - expect(result).toEqual([ true, false ]); + expect(result).toEqual([true, false]); expect(account.updateUserInfo).toHaveBeenCalled(); }); it("should return [false, false] session is out of date", async () => { - vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ error: "session out of date" }); + vi.spyOn(pokerogueApi.savedata.session, "clear").mockResolvedValue({ + error: "session out of date", + }); const result = await game.scene.gameData.tryClearSession(0); - expect(result).toEqual([ false, false ]); + expect(result).toEqual([false, false]); expect(account.updateUserInfo).toHaveBeenCalled(); }); }); diff --git a/test/testUtils/TextInterceptor.ts b/test/testUtils/TextInterceptor.ts index 089d8967c61..4aaed458e44 100644 --- a/test/testUtils/TextInterceptor.ts +++ b/test/testUtils/TextInterceptor.ts @@ -9,12 +9,26 @@ export default class TextInterceptor { scene.messageWrapper = this; } - showText(text: string, delay?: number, callback?: Function, callbackDelay?: number, prompt?: boolean, promptDelay?: number): void { + showText( + text: string, + _delay?: number, + _callback?: Function, + _callbackDelay?: number, + _prompt?: boolean, + _promptDelay?: number, + ): void { console.log(text); this.logs.push(text); } - showDialogue(text: string, name: string, delay?: number, callback?: Function, callbackDelay?: number, promptDelay?: number): void { + showDialogue( + text: string, + name: string, + _delay?: number, + _callback?: Function, + _callbackDelay?: number, + _promptDelay?: number, + ): void { console.log(name, text); this.logs.push(name, text); } diff --git a/test/testUtils/errorInterceptor.ts b/test/testUtils/errorInterceptor.ts index 7f06c47fd39..a8fb3284b78 100644 --- a/test/testUtils/errorInterceptor.ts +++ b/test/testUtils/errorInterceptor.ts @@ -29,8 +29,7 @@ export default class ErrorInterceptor { } } - -process.on("uncaughtException", (error) => { +process.on("uncaughtException", error => { console.log(error); const toStop = ErrorInterceptor.getInstance().running; for (const elm of toStop) { @@ -40,7 +39,7 @@ process.on("uncaughtException", (error) => { }); // Global error handler for unhandled promise rejections -process.on("unhandledRejection", (reason, promise) => { +process.on("unhandledRejection", (reason, _promise) => { console.log(reason); const toStop = ErrorInterceptor.getInstance().running; for (const elm of toStop) { diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index d245a74d11e..0ebc83cae31 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -53,7 +53,7 @@ import { SettingsHelper } from "#test/testUtils/helpers/settingsHelper"; import PhaseInterceptor from "#test/testUtils/phaseInterceptor"; import TextInterceptor from "#test/testUtils/TextInterceptor"; import { AES, enc } from "crypto-js"; -import fs from "fs"; +import fs from "node:fs"; import { expect, vi } from "vitest"; /** @@ -79,10 +79,10 @@ export default class GameManager { * @param phaserGame - The Phaser game instance. * @param bypassLogin - Whether to bypass the login phase. */ - constructor(phaserGame: Phaser.Game, bypassLogin: boolean = true) { + constructor(phaserGame: Phaser.Game, bypassLogin = true) { localStorage.clear(); ErrorInterceptor.getInstance().clear(); - BattleScene.prototype.randBattleSeedInt = (range, min: number = 0) => min + range - 1; // This simulates a max roll + BattleScene.prototype.randBattleSeedInt = (range, min = 0) => min + range - 1; // This simulates a max roll this.gameWrapper = new GameWrapper(phaserGame, bypassLogin); this.scene = new BattleScene(); this.phaseInterceptor = new PhaseInterceptor(this.scene); @@ -115,7 +115,7 @@ export default class GameManager { * @returns A promise that resolves when the mode is set. */ waitMode(mode: Mode): Promise { - return new Promise(async (resolve) => { + return new Promise(async resolve => { await waitUntil(() => this.scene.ui?.getMode() === mode); return resolve(); }); @@ -136,7 +136,13 @@ export default class GameManager { * @param callback - The callback function to execute on next prompt. * @param expireFn - Optional function to determine if the prompt has expired. */ - onNextPrompt(phaseTarget: string, mode: Mode, callback: () => void, expireFn?: () => void, awaitingActionInput: boolean = false) { + onNextPrompt( + phaseTarget: string, + mode: Mode, + callback: () => void, + expireFn?: () => void, + awaitingActionInput = false, + ) { this.phaseInterceptor.addToNextPrompt(phaseTarget, mode, callback, expireFn, awaitingActionInput); } @@ -205,18 +211,29 @@ export default class GameManager { await this.runToTitle(); - this.onNextPrompt("TitlePhase", Mode.TITLE, () => { - this.scene.gameMode = getGameMode(GameModes.CLASSIC); - const starters = generateStarter(this.scene, species); - const selectStarterPhase = new SelectStarterPhase(); - this.scene.pushPhase(new EncounterPhase(false)); - selectStarterPhase.initBattle(starters); - }, () => this.isCurrentPhase(EncounterPhase)); + this.onNextPrompt( + "TitlePhase", + Mode.TITLE, + () => { + this.scene.gameMode = getGameMode(GameModes.CLASSIC); + const starters = generateStarter(this.scene, species); + const selectStarterPhase = new SelectStarterPhase(); + this.scene.pushPhase(new EncounterPhase(false)); + selectStarterPhase.initBattle(starters); + }, + () => this.isCurrentPhase(EncounterPhase), + ); - this.onNextPrompt("EncounterPhase", Mode.MESSAGE, () => { - const handler = this.scene.ui.getHandler() as BattleMessageUiHandler; - handler.processInput(Button.ACTION); - }, () => this.isCurrentPhase(MysteryEncounterPhase), true); + this.onNextPrompt( + "EncounterPhase", + Mode.MESSAGE, + () => { + const handler = this.scene.ui.getHandler() as BattleMessageUiHandler; + handler.processInput(Button.ACTION); + }, + () => this.isCurrentPhase(MysteryEncounterPhase), + true, + ); await this.phaseInterceptor.run(EncounterPhase); if (!isNullOrUndefined(encounterType)) { @@ -235,15 +252,25 @@ export default class GameManager { await this.classicMode.runToSummon(species); if (this.scene.battleStyle === BattleStyle.SWITCH) { - this.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); - this.endPhase(); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase)); + this.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.setMode(Mode.MESSAGE); + this.endPhase(); + }, + () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase), + ); - this.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); - this.endPhase(); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase)); + this.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.setMode(Mode.MESSAGE); + this.endPhase(); + }, + () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(TurnInitPhase), + ); } await this.phaseInterceptor.to(CommandPhase); @@ -257,17 +284,29 @@ export default class GameManager { * @param movePosition The index of the move in the pokemon's moveset array */ selectTarget(movePosition: number, targetIndex?: BattlerIndex) { - this.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => { - const handler = this.scene.ui.getHandler() as TargetSelectUiHandler; - const move = (this.scene.getCurrentPhase() as SelectTargetPhase).getPokemon().getMoveset()[movePosition]!.getMove(); // TODO: is the bang correct? - if (!move.isMultiTarget()) { - handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY); - } - if (move.isMultiTarget() && targetIndex !== undefined) { - throw new Error(`targetIndex was passed to selectMove() but move ("${move.name}") is not targetted`); - } - handler.processInput(Button.ACTION); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(MovePhase) || this.isCurrentPhase(TurnStartPhase) || this.isCurrentPhase(TurnEndPhase)); + this.onNextPrompt( + "SelectTargetPhase", + Mode.TARGET_SELECT, + () => { + const handler = this.scene.ui.getHandler() as TargetSelectUiHandler; + const move = (this.scene.getCurrentPhase() as SelectTargetPhase) + .getPokemon() + .getMoveset() + [movePosition]!.getMove(); // TODO: is the bang correct? + if (!move.isMultiTarget()) { + handler.setCursor(targetIndex !== undefined ? targetIndex : BattlerIndex.ENEMY); + } + if (move.isMultiTarget() && targetIndex !== undefined) { + throw new Error(`targetIndex was passed to selectMove() but move ("${move.name}") is not targetted`); + } + handler.processInput(Button.ACTION); + }, + () => + this.isCurrentPhase(CommandPhase) || + this.isCurrentPhase(MovePhase) || + this.isCurrentPhase(TurnStartPhase) || + this.isCurrentPhase(TurnEndPhase), + ); } /** Faint all opponents currently on the field */ @@ -280,15 +319,32 @@ export default class GameManager { /** Emulate selecting a modifier (item) */ doSelectModifier() { - this.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { - const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; - handler.processInput(Button.CANCEL); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(NewBattlePhase) || this.isCurrentPhase(CheckSwitchPhase), true); + this.onNextPrompt( + "SelectModifierPhase", + Mode.MODIFIER_SELECT, + () => { + const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; + handler.processInput(Button.CANCEL); + }, + () => + this.isCurrentPhase(CommandPhase) || + this.isCurrentPhase(NewBattlePhase) || + this.isCurrentPhase(CheckSwitchPhase), + true, + ); - this.onNextPrompt("SelectModifierPhase", Mode.CONFIRM, () => { - const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; - handler.processInput(Button.ACTION); - }, () => this.isCurrentPhase(CommandPhase) || this.isCurrentPhase(NewBattlePhase) || this.isCurrentPhase(CheckSwitchPhase)); + this.onNextPrompt( + "SelectModifierPhase", + Mode.CONFIRM, + () => { + const handler = this.scene.ui.getHandler() as ModifierSelectUiHandler; + handler.processInput(Button.ACTION); + }, + () => + this.isCurrentPhase(CommandPhase) || + this.isCurrentPhase(NewBattlePhase) || + this.isCurrentPhase(CheckSwitchPhase), + ); } /** @@ -305,9 +361,10 @@ export default class GameManager { vi.spyOn(enemy, "getNextMove").mockReturnValueOnce({ move: moveId, - targets: (target !== undefined && !legalTargets.multiple && legalTargets.targets.includes(target)) - ? [ target ] - : enemy.getNextTargets(moveId) + targets: + target !== undefined && !legalTargets.multiple && legalTargets.targets.includes(target) + ? [target] + : enemy.getNextTargets(moveId), }); /** @@ -322,7 +379,10 @@ export default class GameManager { const originalMatchupScore = Trainer.prototype.getPartyMemberMatchupScores; Trainer.prototype.getPartyMemberMatchupScores = () => { Trainer.prototype.getPartyMemberMatchupScores = originalMatchupScore; - return [[ 1, 100 ], [ 1, 100 ]]; + return [ + [1, 100], + [1, 100], + ]; }; } @@ -335,10 +395,15 @@ export default class GameManager { async toNextWave() { this.doSelectModifier(); - this.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.setMode(Mode.MESSAGE); - this.endPhase(); - }, () => this.isCurrentPhase(TurnInitPhase)); + this.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.setMode(Mode.MESSAGE); + this.endPhase(); + }, + () => this.isCurrentPhase(TurnInitPhase), + ); await this.toNextTurn(); } @@ -376,7 +441,7 @@ export default class GameManager { */ exportSaveToTest(): Promise { const saveKey = "x0i2O7WRiANTqPmZ"; - return new Promise(async (resolve) => { + return new Promise(async resolve => { const sessionSaveData = this.scene.gameData.getSessionSaveData(); const encryptedSaveData = AES.encrypt(JSON.stringify(sessionSaveData), saveKey).toString(); resolve(encryptedSaveData); @@ -411,7 +476,7 @@ export default class GameManager { return new Promise(async (resolve, reject) => { pokemon.hp = 0; this.scene.pushPhase(new FaintPhase(pokemon.getBattlerIndex(), true)); - await this.phaseInterceptor.to(FaintPhase).catch((e) => reject(e)); + await this.phaseInterceptor.to(FaintPhase).catch(e => reject(e)); resolve(); }); } diff --git a/test/testUtils/gameManagerUtils.ts b/test/testUtils/gameManagerUtils.ts index 757874f0c17..ae6c11f5efa 100644 --- a/test/testUtils/gameManagerUtils.ts +++ b/test/testUtils/gameManagerUtils.ts @@ -27,7 +27,6 @@ export function blobToString(blob) { }); } - export function holdOn(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } @@ -39,12 +38,21 @@ export function generateStarter(scene: BattleScene, species?: Species[]): Starte for (const starter of starters) { const starterProps = scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr); const starterFormIndex = Math.min(starterProps.formIndex, Math.max(starter.species.forms.length - 1, 0)); - const starterGender = starter.species.malePercent !== null - ? !starterProps.female ? Gender.MALE : Gender.FEMALE - : Gender.GENDERLESS; - const starterPokemon = scene.addPlayerPokemon(starter.species, startingLevel, starter.abilityIndex, starterFormIndex, starterGender, starterProps.shiny, starterProps.variant, undefined, starter.nature); + const starterGender = + starter.species.malePercent !== null ? (!starterProps.female ? Gender.MALE : Gender.FEMALE) : Gender.GENDERLESS; + const starterPokemon = scene.addPlayerPokemon( + starter.species, + startingLevel, + starter.abilityIndex, + starterFormIndex, + starterGender, + starterProps.shiny, + starterProps.variant, + undefined, + starter.nature, + ); const moveset: Moves[] = []; - starterPokemon.moveset.forEach((move) => { + starterPokemon.moveset.forEach(move => { moveset.push(move!.getMove().id); }); starter.moveset = moveset as StarterMoveset; @@ -69,7 +77,7 @@ function getTestRunStarters(seed: string, species?: Species[]): Starter[] { abilityIndex: pokemon.abilityIndex, passive: false, nature: pokemon.getNature(), - pokerus: pokemon.pokerus + pokerus: pokemon.pokerus, }; starters.push(starter); } @@ -91,7 +99,7 @@ export function waitUntil(truth): Promise { export function getMovePosition(scene: BattleScene, pokemonIndex: 0 | 1, move: Moves): number { const playerPokemon = scene.getPlayerField()[pokemonIndex]; const moveSet = playerPokemon.getMoveset(); - const index = moveSet.findIndex((m) => m?.moveId === move && m?.ppUsed < m?.getMovePp()); + const index = moveSet.findIndex(m => m?.moveId === move && m?.ppUsed < m?.getMovePp()); console.log(`Move position for ${Moves[move]} (=${move}):`, index); return index; } @@ -101,12 +109,22 @@ export function getMovePosition(scene: BattleScene, pokemonIndex: 0 | 1, move: M */ export function initSceneWithoutEncounterPhase(scene: BattleScene, species?: Species[]): void { const starters = generateStarter(scene, species); - starters.forEach((starter) => { + starters.forEach(starter => { const starterProps = scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr); const starterFormIndex = Math.min(starterProps.formIndex, Math.max(starter.species.forms.length - 1, 0)); const starterGender = Gender.MALE; const starterIvs = scene.gameData.dexData[starter.species.speciesId].ivs.slice(0); - const starterPokemon = scene.addPlayerPokemon(starter.species, scene.gameMode.getStartingLevel(), starter.abilityIndex, starterFormIndex, starterGender, starterProps.shiny, starterProps.variant, starterIvs, starter.nature); + const starterPokemon = scene.addPlayerPokemon( + starter.species, + scene.gameMode.getStartingLevel(), + starter.abilityIndex, + starterFormIndex, + starterGender, + starterProps.shiny, + starterProps.variant, + starterIvs, + starter.nature, + ); starter.moveset && starterPokemon.tryPopulateMoveset(starter.moveset); scene.getPlayerParty().push(starterPokemon); }); diff --git a/test/testUtils/gameWrapper.ts b/test/testUtils/gameWrapper.ts index c2614b2b61d..6af36f22d24 100644 --- a/test/testUtils/gameWrapper.ts +++ b/test/testUtils/gameWrapper.ts @@ -12,7 +12,7 @@ import MockLoader from "#test/testUtils/mocks/mockLoader"; import mockLocalStorage from "#test/testUtils/mocks/mockLocalStorage"; import MockImage from "#test/testUtils/mocks/mocksContainer/mockImage"; import MockTextureManager from "#test/testUtils/mocks/mockTextureManager"; -import fs from "fs"; +import fs from "node:fs"; import Phaser from "phaser"; import InputText from "phaser3-rex-plugins/plugins/inputtext"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; @@ -47,14 +47,12 @@ window.URL.createObjectURL = (blob: Blob) => { }; navigator.getGamepads = () => []; global.fetch = vi.fn(MockFetch); -Utils.setCookie(Utils.sessionIdKey, 'fake_token'); - +Utils.setCookie(Utils.sessionIdKey, "fake_token"); window.matchMedia = () => ({ matches: false, }); - /** * Sets this object's position relative to another object with a given offset * @param guideObject {@linkcode Phaser.GameObjects.GameObject} to base the position off of @@ -74,13 +72,12 @@ Phaser.GameObjects.NineSlice.prototype.setPositionRelative = setPositionRelative Phaser.GameObjects.Text.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative; - export default class GameWrapper { public game: Phaser.Game; public scene: BattleScene; constructor(phaserGame: Phaser.Game, bypassLogin: boolean) { - Phaser.Math.RND.sow([ 'test' ]); + Phaser.Math.RND.sow(["test"]); // vi.spyOn(Utils, "apiFetch", "get").mockReturnValue(fetch); if (bypassLogin) { vi.spyOn(battleScene, "bypassLogin", "get").mockReturnValue(true); @@ -92,21 +89,25 @@ export default class GameWrapper { Pokemon.prototype.enableMask = () => null; Pokemon.prototype.updateFusionPalette = () => null; Pokemon.prototype.cry = () => null; - Pokemon.prototype.faintCry = (cb) => { if (cb) cb(); }; + Pokemon.prototype.faintCry = cb => { + if (cb) { + cb(); + } + }; BattleScene.prototype.addPokemonIcon = () => new Phaser.GameObjects.Container(this.scene); } setScene(scene: BattleScene) { this.scene = scene; this.injectMandatory(); - this.scene.preload && this.scene.preload(); + this.scene.preload?.(); this.scene.create(); } injectMandatory() { this.game.config = { seed: ["test"], - gameVersion: version + gameVersion: version, }; this.scene.game = this.game; this.game.renderer = { @@ -129,7 +130,7 @@ export default class GameWrapper { pause: () => null, setRate: () => null, add: () => this.scene.sound, - get: () => ({...this.scene.sound, totalDuration: 0}), + get: () => ({ ...this.scene.sound, totalDuration: 0 }), getAllPlaying: () => [], manager: { game: this.game, @@ -138,7 +139,7 @@ export default class GameWrapper { setVolume: () => null, stop: () => null, stopByKey: () => null, - on: (evt, callback) => callback(), + on: (_evt, callback) => callback(), key: "", }; @@ -150,15 +151,15 @@ export default class GameWrapper { }; this.scene.tweens = { - add: (data) => { + add: data => { if (data.onComplete) { data.onComplete(); } }, - getTweensOf: () => ([]), - killTweensOf: () => ([]), + getTweensOf: () => [], + killTweensOf: () => [], chain: () => null, - addCounter: (data) => { + addCounter: data => { if (data.onComplete) { data.onComplete(); } @@ -185,14 +186,15 @@ export default class GameWrapper { game: this.game, textures: { addCanvas: () => ({ - get: () => ({ // this.frame in Text.js + get: () => ({ + // this.frame in Text.js source: {}, setSize: () => null, glTexture: () => ({ spectorMetadata: {}, }), }), - }) + }), }, cache: this.scene.load.cacheManager, scale: this.game.scale, @@ -203,29 +205,30 @@ export default class GameWrapper { events: new EventEmitter(), settings: { loader: { - key: 'battle', - } + key: "battle", + }, }, input: this.game.input, }; const mockTextureManager = new MockTextureManager(this.scene); this.scene.add = mockTextureManager.add; this.scene.textures = mockTextureManager; - this.scene.sys.displayList = this.scene.add.displayList; + this.scene.sys.displayList = this.scene.add.displayList; this.scene.sys.updateList = new UpdateList(this.scene); this.scene.systems = this.scene.sys; this.scene.input = this.game.input; this.scene.scene = this.scene; this.scene.input.keyboard = new KeyboardPlugin(this.scene); this.scene.input.gamepad = new GamepadPlugin(this.scene); - this.scene.cachedFetch = (url, init) => { - return new Promise((resolve) => { + this.scene.cachedFetch = (url, _init) => { + return new Promise(resolve => { // need to remove that if later we want to test battle-anims - const newUrl = url.includes('./battle-anims/') ? prependPath('./battle-anims/tackle.json') : prependPath(url); + const newUrl = url.includes("./battle-anims/") ? prependPath("./battle-anims/tackle.json") : prependPath(url); + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let raw; try { - raw = fs.readFileSync(newUrl, {encoding: "utf8", flag: "r"}); - } catch(e) { + raw = fs.readFileSync(newUrl, { encoding: "utf8", flag: "r" }); + } catch (_e) { return resolve(createFetchBadResponse({})); } const data = JSON.parse(raw); diff --git a/test/testUtils/helpers/challengeModeHelper.ts b/test/testUtils/helpers/challengeModeHelper.ts index 4b5a38e72dc..0b7826eda7e 100644 --- a/test/testUtils/helpers/challengeModeHelper.ts +++ b/test/testUtils/helpers/challengeModeHelper.ts @@ -16,7 +16,6 @@ import { copyChallenge } from "data/challenge"; * Helper to handle Challenge mode specifics */ export class ChallengeModeHelper extends GameManagerHelper { - challenges: Challenge[] = []; /** @@ -65,15 +64,25 @@ export class ChallengeModeHelper extends GameManagerHelper { await this.runToSummon(species); if (this.game.scene.battleStyle === BattleStyle.SWITCH) { - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); } await this.game.phaseInterceptor.to(CommandPhase); diff --git a/test/testUtils/helpers/classicModeHelper.ts b/test/testUtils/helpers/classicModeHelper.ts index 40c3d518f1c..5b6a38f5747 100644 --- a/test/testUtils/helpers/classicModeHelper.ts +++ b/test/testUtils/helpers/classicModeHelper.ts @@ -14,7 +14,6 @@ import { GameManagerHelper } from "./gameManagerHelper"; * Helper to handle classic mode specifics */ export class ClassicModeHelper extends GameManagerHelper { - /** * Runs the classic game to the summon phase. * @param species - Optional array of species to summon. @@ -50,15 +49,25 @@ export class ClassicModeHelper extends GameManagerHelper { await this.runToSummon(species); if (this.game.scene.battleStyle === BattleStyle.SWITCH) { - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); } await this.game.phaseInterceptor.to(CommandPhase); diff --git a/test/testUtils/helpers/dailyModeHelper.ts b/test/testUtils/helpers/dailyModeHelper.ts index bd8c6ebb920..0f5bc84df68 100644 --- a/test/testUtils/helpers/dailyModeHelper.ts +++ b/test/testUtils/helpers/dailyModeHelper.ts @@ -13,7 +13,6 @@ import { GameManagerHelper } from "./gameManagerHelper"; * Helper to handle daily mode specifics */ export class DailyModeHelper extends GameManagerHelper { - /** * Runs the daily game to the summon phase. * @returns A promise that resolves when the summon phase is reached. @@ -50,15 +49,25 @@ export class DailyModeHelper extends GameManagerHelper { await this.runToSummon(); if (this.game.scene.battleStyle === BattleStyle.SWITCH) { - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); } await this.game.phaseInterceptor.to(CommandPhase); diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index 535537b34a2..543f46b2026 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -33,7 +33,7 @@ export class MoveHelper extends GameManagerHelper { * Used to force a move to miss. * @param firstTargetOnly - Whether the move should force miss on the first target only, in the case of multi-target moves. */ - public async forceMiss(firstTargetOnly: boolean = false): Promise { + public async forceMiss(firstTargetOnly = false): Promise { await this.game.phaseInterceptor.to(MoveEffectPhase, false); const hitCheck = vi.spyOn(this.game.scene.getCurrentPhase() as MoveEffectPhase, "hitCheck"); @@ -84,25 +84,25 @@ export class MoveHelper extends GameManagerHelper { */ public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void { if (!Array.isArray(moveset)) { - moveset = [ moveset ]; + moveset = [moveset]; } pokemon.moveset = []; - moveset.forEach((move) => { + moveset.forEach(move => { pokemon.moveset.push(new PokemonMove(move)); }); - const movesetStr = moveset.map((moveId) => Moves[moveId]).join(", "); + const movesetStr = moveset.map(moveId => Moves[moveId]).join(", "); console.log(`Pokemon ${pokemon.species.name}'s moveset manually set to ${movesetStr} (=[${moveset.join(", ")}])!`); } /** - * Simulates learning a move for a player pokemon. - * @param move The {@linkcode Moves} being learnt - * @param partyIndex The party position of the {@linkcode PlayerPokemon} learning the move (defaults to 0) - * @param moveSlotIndex The INDEX (0-4) of the move slot to replace if existent move slots are full; - * defaults to 0 (first slot) and 4 aborts the procedure - * @returns a promise that resolves once the move has been successfully learnt - */ - public async learnMove(move: Moves | number, partyIndex: number = 0, moveSlotIndex: number = 0) { + * Simulates learning a move for a player pokemon. + * @param move The {@linkcode Moves} being learnt + * @param partyIndex The party position of the {@linkcode PlayerPokemon} learning the move (defaults to 0) + * @param moveSlotIndex The INDEX (0-4) of the move slot to replace if existent move slots are full; + * defaults to 0 (first slot) and 4 aborts the procedure + * @returns a promise that resolves once the move has been successfully learnt + */ + public async learnMove(move: Moves | number, partyIndex = 0, moveSlotIndex = 0) { return new Promise(async (resolve, reject) => { this.game.scene.pushPhase(new LearnMovePhase(partyIndex, move)); @@ -128,5 +128,4 @@ export class MoveHelper extends GameManagerHelper { resolve(); }); } - } diff --git a/test/testUtils/helpers/overridesHelper.ts b/test/testUtils/helpers/overridesHelper.ts index 47358738048..e69e05bce45 100644 --- a/test/testUtils/helpers/overridesHelper.ts +++ b/test/testUtils/helpers/overridesHelper.ts @@ -23,9 +23,9 @@ import { GameManagerHelper } from "./gameManagerHelper"; */ export class OverridesHelper extends GameManagerHelper { /** If `true`, removes the starting items from enemies at the start of each test; default `true` */ - public removeEnemyStartingItems: boolean = true; + public removeEnemyStartingItems = true; /** If `true`, sets the shiny overrides to disable shinies at the start of each test; default `true` */ - public disableShinies: boolean = true; + public disableShinies = true; /** * Override the starting biome @@ -142,7 +142,7 @@ export class OverridesHelper extends GameManagerHelper { public starterForms(forms: Partial>): this { vi.spyOn(Overrides, "STARTER_FORM_OVERRIDES", "get").mockReturnValue(forms); const formsStr = Object.entries(forms) - .map(([ speciesId, formIndex ]) => `${Species[speciesId]}=${formIndex}`) + .map(([speciesId, formIndex]) => `${Species[speciesId]}=${formIndex}`) .join(", "); this.log(`Player Pokemon form set to: ${formsStr}!`); return this; @@ -203,9 +203,9 @@ export class OverridesHelper extends GameManagerHelper { public moveset(moveset: Moves | Moves[]): this { vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue(moveset); if (!Array.isArray(moveset)) { - moveset = [ moveset ]; + moveset = [moveset]; } - const movesetStr = moveset.map((moveId) => Moves[moveId]).join(", "); + const movesetStr = moveset.map(moveId => Moves[moveId]).join(", "); this.log(`Player Pokemon moveset set to ${movesetStr} (=[${moveset.join(", ")}])!`); return this; } @@ -265,7 +265,7 @@ export class OverridesHelper extends GameManagerHelper { public seed(seed: string): this { vi.spyOn(this.game.scene, "resetSeed").mockImplementation(() => { this.game.scene.waveSeed = seed; - Phaser.Math.RND.sow([ seed ]); + Phaser.Math.RND.sow([seed]); this.game.scene.rngCounter = 0; }); this.game.scene.resetSeed(); @@ -362,9 +362,9 @@ export class OverridesHelper extends GameManagerHelper { public enemyMoveset(moveset: Moves | Moves[]): this { vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(moveset); if (!Array.isArray(moveset)) { - moveset = [ moveset ]; + moveset = [moveset]; } - const movesetStr = moveset.map((moveId) => Moves[moveId]).join(", "); + const movesetStr = moveset.map(moveId => Moves[moveId]).join(", "); this.log(`Enemy Pokemon moveset set to ${movesetStr} (=[${moveset.join(", ")}])!`); return this; } diff --git a/test/testUtils/helpers/reloadHelper.ts b/test/testUtils/helpers/reloadHelper.ts index 5f516584873..842cd88b95c 100644 --- a/test/testUtils/helpers/reloadHelper.ts +++ b/test/testUtils/helpers/reloadHelper.ts @@ -19,7 +19,7 @@ export class ReloadHelper extends GameManagerHelper { // Whenever the game saves the session, save it to the reloadHelper instead vi.spyOn(game.scene.gameData, "saveAll").mockImplementation(() => { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { this.sessionData = game.scene.gameData.getSessionSaveData(); resolve(true); }); @@ -31,7 +31,7 @@ export class ReloadHelper extends GameManagerHelper { * beginning of the first turn (equivalent to running `startBattle()`) for * the reloaded session. */ - async reloadSession() : Promise { + async reloadSession(): Promise { const scene = this.game.scene; const titlePhase = new TitlePhase(); @@ -39,9 +39,9 @@ export class ReloadHelper extends GameManagerHelper { // Set the last saved session to the desired session data vi.spyOn(scene.gameData, "getSession").mockReturnValue( - new Promise((resolve, reject) => { + new Promise((resolve, _reject) => { resolve(this.sessionData); - }) + }), ); scene.unshiftPhase(titlePhase); this.game.endPhase(); // End the currently ongoing battle @@ -51,15 +51,25 @@ export class ReloadHelper extends GameManagerHelper { // Run through prompts for switching Pokemon, copied from classicModeHelper.ts if (this.game.scene.battleStyle === BattleStyle.SWITCH) { - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); - this.game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - this.game.setMode(Mode.MESSAGE); - this.game.endPhase(); - }, () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase)); + this.game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + this.game.setMode(Mode.MESSAGE); + this.game.endPhase(); + }, + () => this.game.isCurrentPhase(CommandPhase) || this.game.isCurrentPhase(TurnInitPhase), + ); } await this.game.phaseInterceptor.to(CommandPhase); diff --git a/test/testUtils/helpers/settingsHelper.ts b/test/testUtils/helpers/settingsHelper.ts index 83baa329cec..d5a60e6496a 100644 --- a/test/testUtils/helpers/settingsHelper.ts +++ b/test/testUtils/helpers/settingsHelper.ts @@ -27,7 +27,7 @@ export class SettingsHelper extends GameManagerHelper { */ typeHints(enable: boolean): void { this.game.scene.typeHints = enable; - this.log(`Type Hints ${enable ? "enabled" : "disabled"}` ); + this.log(`Type Hints ${enable ? "enabled" : "disabled"}`); } /** @@ -36,7 +36,7 @@ export class SettingsHelper extends GameManagerHelper { */ playerGender(gender: PlayerGender) { this.game.scene.gameData.gender = gender; - this.log(`Gender set to: ${PlayerGender[gender]} (=${gender})` ); + this.log(`Gender set to: ${PlayerGender[gender]} (=${gender})`); } /** @@ -45,7 +45,7 @@ export class SettingsHelper extends GameManagerHelper { */ expGainsSpeed(speed: ExpGainsSpeed) { this.game.scene.expGainsSpeed = speed; - this.log(`Exp Gains Speed set to: ${ExpGainsSpeed[speed]} (=${speed})` ); + this.log(`Exp Gains Speed set to: ${ExpGainsSpeed[speed]} (=${speed})`); } private log(...params: any[]) { diff --git a/test/testUtils/inputsHandler.ts b/test/testUtils/inputsHandler.ts index c526300a75a..6e9dd453541 100644 --- a/test/testUtils/inputsHandler.ts +++ b/test/testUtils/inputsHandler.ts @@ -3,7 +3,7 @@ import pad_xbox360 from "#app/configs/inputs/pad_xbox360"; import type { InputsController } from "#app/inputs-controller"; import TouchControl from "#app/touch-controls"; import { holdOn } from "#test/testUtils/gameManagerUtils"; -import fs from "fs"; +import fs from "node:fs"; import { JSDOM } from "jsdom"; import Phaser from "phaser"; @@ -31,7 +31,7 @@ export default class InputsHandler { } pressTouch(button: string, duration: number): Promise { - return new Promise(async (resolve) => { + return new Promise(async resolve => { this.fakeMobile.touchDown(button); await holdOn(duration); this.fakeMobile.touchUp(button); @@ -40,7 +40,7 @@ export default class InputsHandler { } pressGamepadButton(button: number, duration: number): Promise { - return new Promise(async (resolve) => { + return new Promise(async resolve => { this.scene.input.gamepad?.emit("down", this.fakePad, { index: button }); await holdOn(duration); this.scene.input.gamepad?.emit("up", this.fakePad, { index: button }); @@ -49,7 +49,7 @@ export default class InputsHandler { } pressKeyboardKey(key: number, duration: number): Promise { - return new Promise(async (resolve) => { + return new Promise(async resolve => { this.scene.input.keyboard?.emit("keydown", { keyCode: key }); await holdOn(duration); this.scene.input.keyboard?.emit("keyup", { keyCode: key }); @@ -66,13 +66,21 @@ export default class InputsHandler { } listenInputs(): void { - this.events.on("input_down", (event) => { - this.log.push({ type: "input_down", button: event.button }); - }, this); + this.events.on( + "input_down", + event => { + this.log.push({ type: "input_down", button: event.button }); + }, + this, + ); - this.events.on("input_up", (event) => { - this.logUp.push({ type: "input_up", button: event.button }); - }, this); + this.events.on( + "input_up", + event => { + this.logUp.push({ type: "input_up", button: event.button }); + }, + this, + ); } } @@ -82,7 +90,7 @@ class Fakepad extends Phaser.Input.Gamepad.Gamepad { constructor(pad) { //@ts-ignore - super(undefined, { ...pad, buttons: pad.deviceMapping, axes: []}); //TODO: resolve ts-ignore + super(undefined, { ...pad, buttons: pad.deviceMapping, axes: [] }); //TODO: resolve ts-ignore this.id = "xbox_360_fakepad"; this.index = 0; } diff --git a/test/testUtils/mocks/mockClock.ts b/test/testUtils/mocks/mockClock.ts index 7fad3651010..67f399ae41d 100644 --- a/test/testUtils/mocks/mockClock.ts +++ b/test/testUtils/mocks/mockClock.ts @@ -1,6 +1,5 @@ import Clock = Phaser.Time.Clock; - export class MockClock extends Clock { public overrideDelay: number | null = 1; constructor(scene) { diff --git a/test/testUtils/mocks/mockConsoleLog.ts b/test/testUtils/mocks/mockConsoleLog.ts index 9c3cbca6bb6..808b6ea4d4d 100644 --- a/test/testUtils/mocks/mockConsoleLog.ts +++ b/test/testUtils/mocks/mockConsoleLog.ts @@ -8,17 +8,17 @@ const MockConsoleLog = (_logDisabled = false, _phaseText = false) => { const originalWarn = console.warn; const notified: any[] = []; - const blacklist = [ "Phaser", "variant icon does not exist", "Texture \"%s\" not found" ]; - const whitelist = [ "Phase" ]; + const blacklist = ["Phaser", "variant icon does not exist", 'Texture "%s" not found']; + const whitelist = ["Phase"]; - return ({ + return { log(...args) { const argsStr = this.getStr(args); logs.push(argsStr); - if (logDisabled && (!phaseText)) { + if (logDisabled && !phaseText) { return; } - if ((phaseText && !whitelist.some((b) => argsStr.includes(b))) || blacklist.some((b) => argsStr.includes(b))) { + if ((phaseText && !whitelist.some(b => argsStr.includes(b))) || blacklist.some(b => argsStr.includes(b))) { return; } originalLog(args); @@ -31,10 +31,10 @@ const MockConsoleLog = (_logDisabled = false, _phaseText = false) => { debug(...args) { const argsStr = this.getStr(args); logs.push(argsStr); - if (logDisabled && (!phaseText)) { + if (logDisabled && !phaseText) { return; } - if (!whitelist.some((b) => argsStr.includes(b)) || blacklist.some((b) => argsStr.includes(b))) { + if (!whitelist.some(b => argsStr.includes(b)) || blacklist.some(b => argsStr.includes(b))) { return; } originalDebug(args); @@ -42,10 +42,10 @@ const MockConsoleLog = (_logDisabled = false, _phaseText = false) => { warn(...args) { const argsStr = this.getStr(args); logs.push(args); - if (logDisabled && (!phaseText)) { + if (logDisabled && !phaseText) { return; } - if (!whitelist.some((b) => argsStr.includes(b)) || blacklist.some((b) => argsStr.includes(b))) { + if (!whitelist.some(b => argsStr.includes(b)) || blacklist.some(b => argsStr.includes(b))) { return; } originalWarn(args); @@ -61,22 +61,22 @@ const MockConsoleLog = (_logDisabled = false, _phaseText = false) => { logs = []; }, getStr(...args) { - return args.map(arg => { - if (typeof arg === "object" && arg !== null) { - // Handle objects including arrays - return JSON.stringify(arg, (key, value) => - typeof value === "bigint" ? value.toString() : value - ); - } else if (typeof arg === "bigint") { - // Handle BigInt values - return arg.toString(); - } else { + return args + .map(arg => { + if (typeof arg === "object" && arg !== null) { + // Handle objects including arrays + return JSON.stringify(arg, (_key, value) => (typeof value === "bigint" ? value.toString() : value)); + } + if (typeof arg === "bigint") { + // Handle BigInt values + return arg.toString(); + } // Handle all other types return arg.toString(); - } - }).join(";"); + }) + .join(";"); }, - }); + }; }; export default MockConsoleLog; diff --git a/test/testUtils/mocks/mockFetch.ts b/test/testUtils/mocks/mockFetch.ts index 2fa7cd198ce..195d4f65752 100644 --- a/test/testUtils/mocks/mockFetch.ts +++ b/test/testUtils/mocks/mockFetch.ts @@ -1,24 +1,25 @@ -export const MockFetch = (input, init) => { +export const MockFetch = (input, _init) => { const url = typeof input === "string" ? input : input.url; + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let responseHandler; + // biome-ignore lint/suspicious/noImplicitAnyLet: TODO let responseText; const handlers = { - "account/info": { "username":"greenlamp", "lastSessionSlot":0 }, + "account/info": { username: "greenlamp", lastSessionSlot: 0 }, "savedata/session": {}, "savedata/system": {}, "savedata/updateall": "", "daily/rankingpagecount": { data: 0 }, - "game/titlestats": { "playerCount":0, "battleCount":5 }, + "game/titlestats": { playerCount: 0, battleCount: 5 }, "daily/rankings": [], }; - for (const key of Object.keys(handlers)) { if (url.includes(key)) { - responseHandler = async() => handlers[key]; - responseText = async() => handlers[key] ? JSON.stringify(handlers[key]) : handlers[key]; + responseHandler = async () => handlers[key]; + responseText = async () => (handlers[key] ? JSON.stringify(handlers[key]) : handlers[key]); break; } } diff --git a/test/testUtils/mocks/mockLoader.ts b/test/testUtils/mocks/mockLoader.ts index 661eb72f2c2..7452f85a317 100644 --- a/test/testUtils/mocks/mockLoader.ts +++ b/test/testUtils/mocks/mockLoader.ts @@ -1,17 +1,16 @@ import CacheManager = Phaser.Cache.CacheManager; - export default class MockLoader { public cacheManager; constructor(scene) { this.cacheManager = new CacheManager(scene); } - once(event, callback) { + once(_event, callback) { callback(); } - setBaseURL(url) { + setBaseURL(_url) { return null; } @@ -19,24 +18,17 @@ export default class MockLoader { return null; } - spritesheet(key, url, frameConfig) { - } + spritesheet(_key, _url, _frameConfig) {} - audio(key, url) { - - } + audio(_key, _url) {} isLoading() { return false; } - start() { - } + start() {} - image() { + image() {} - } - - atlas(key, textureUrl, atlasUrl) { - } + atlas(_key, _textureUrl, _atlasUrl) {} } diff --git a/test/testUtils/mocks/mockLocalStorage.ts b/test/testUtils/mocks/mockLocalStorage.ts index bb4ea4e890d..235aa76f664 100644 --- a/test/testUtils/mocks/mockLocalStorage.ts +++ b/test/testUtils/mocks/mockLocalStorage.ts @@ -1,4 +1,4 @@ -const mockLocalStorage = (() => { +const mockLocalStorage = () => { let store = {} as Storage; return { @@ -22,6 +22,6 @@ const mockLocalStorage = (() => { store = {} as Storage; }, }; -}); +}; export default mockLocalStorage; diff --git a/test/testUtils/mocks/mockTextureManager.ts b/test/testUtils/mocks/mockTextureManager.ts index 44d33cf8910..fe249c5a5f7 100644 --- a/test/testUtils/mocks/mockTextureManager.ts +++ b/test/testUtils/mocks/mockTextureManager.ts @@ -51,7 +51,7 @@ export default class MockTextureManager { return sprite; } - existing(obj) { + existing(_obj) { // const whitelist = ["ArenaBase", "PlayerPokemon", "EnemyPokemon"]; // const key = obj.constructor.name; // if (whitelist.includes(key) || obj.texture?.key?.includes("trainer_")) { @@ -74,7 +74,19 @@ export default class MockTextureManager { } nineslice(x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight) { - const nineSlice = new MockNineslice(this, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight); + const nineSlice = new MockNineslice( + this, + x, + y, + texture, + frame, + width, + height, + leftWidth, + rightWidth, + topHeight, + bottomHeight, + ); this.list.push(nineSlice); return nineSlice; } diff --git a/test/testUtils/mocks/mockVideoGameObject.ts b/test/testUtils/mocks/mockVideoGameObject.ts index 74b05626616..65a5c37b244 100644 --- a/test/testUtils/mocks/mockVideoGameObject.ts +++ b/test/testUtils/mocks/mockVideoGameObject.ts @@ -4,8 +4,6 @@ import type { MockGameObject } from "./mockGameObject"; export class MockVideoGameObject implements MockGameObject { public name: string; - constructor() {} - public play = () => null; public stop = () => this; public setOrigin = () => null; diff --git a/test/testUtils/mocks/mocksContainer/mockContainer.ts b/test/testUtils/mocks/mocksContainer/mockContainer.ts index 6c03ff7460d..0a792c6fc79 100644 --- a/test/testUtils/mocks/mocksContainer/mockContainer.ts +++ b/test/testUtils/mocks/mocksContainer/mockContainer.ts @@ -25,17 +25,15 @@ export default class MockContainer implements MockGameObject { this.visible = visible; } - once(event, callback, source) { - } + once(_event, _callback, _source) {} - off(event, callback, source) { - } + off(_event, _callback, _source) {} removeFromDisplayList() { // same as remove or destroy } - removeBetween(startIndex, endIndex, destroyChild) { + removeBetween(_startIndex, _endIndex, _destroyChild) { // Removes multiple children across an index range } @@ -43,7 +41,7 @@ export default class MockContainer implements MockGameObject { // This callback is invoked when this Game Object is added to a Scene. } - setSize(width, height) { + setSize(_width, _height) { // Sets the size of this Game Object. } @@ -51,7 +49,7 @@ export default class MockContainer implements MockGameObject { /// Sets the mask that this Game Object will use to render with. } - setPositionRelative(source, x, y) { + setPositionRelative(_source, _x, _y) { /// Sets the position of this Game Object to be a relative position from the source Game Object. } @@ -66,11 +64,11 @@ export default class MockContainer implements MockGameObject { this.alpha = alpha; } - setFrame(frame, updateSize?: boolean, updateOrigin?: boolean) { + setFrame(_frame, _updateSize?: boolean, _updateOrigin?: boolean) { // Sets the frame this Game Object will use to render with. } - setScale(scale) { + setScale(_scale) { // Sets the scale of this Game Object. } @@ -91,59 +89,59 @@ export default class MockContainer implements MockGameObject { this.list = []; } - setShadow(shadowXpos, shadowYpos, shadowColor) { + setShadow(_shadowXpos, _shadowYpos, _shadowColor) { // Sets the shadow settings for this Game Object. } - setLineSpacing(lineSpacing) { + setLineSpacing(_lineSpacing) { // Sets the line spacing value of this Game Object. } - setText(text) { + setText(_text) { // Sets the text this Game Object will display. } - setAngle(angle) { + setAngle(_angle) { // Sets the angle of this Game Object. } - setShadowOffset(offsetX, offsetY) { + setShadowOffset(_offsetX, _offsetY) { // Sets the shadow offset values. } - setWordWrapWidth(width) { + setWordWrapWidth(_width) { // Sets the width (in pixels) to use for wrapping lines. } - setFontSize(fontSize) { + setFontSize(_fontSize) { // Sets the font size of this Game Object. } getBounds() { return { width: this.width, height: this.height }; } - setColor(color) { + setColor(_color) { // Sets the tint of this Game Object. } - setShadowColor(color) { + setShadowColor(_color) { // Sets the shadow color. } - setTint(color) { + setTint(_color) { // Sets the tint of this Game Object. } - setStrokeStyle(thickness, color) { + setStrokeStyle(_thickness, _color) { // Sets the stroke style for the graphics. return this; } - setDepth(depth) { + setDepth(_depth) { // Sets the depth of this Game Object. } - setTexture(texture) { + setTexture(_texture) { // Sets the texture this Game Object will use to render with. } @@ -155,15 +153,15 @@ export default class MockContainer implements MockGameObject { // Sends this Game Object to the back of its parent's display list. } - moveTo(obj) { + moveTo(_obj) { // Moves this Game Object to the given index in the list. } - moveAbove(obj) { + moveAbove(_obj) { // Moves this Game Object to be above the given Game Object in the display list. } - moveBelow(obj) { + moveBelow(_obj) { // Moves this Game Object to be below the given Game Object in the display list. } @@ -171,12 +169,11 @@ export default class MockContainer implements MockGameObject { this.name = name; } - bringToTop(obj) { + bringToTop(_obj) { // Brings this Game Object to the top of its parents display list. } - on(event, callback, source) { - } + on(_event, _callback, _source) {} add(obj) { // Adds a child to this Game Object. diff --git a/test/testUtils/mocks/mocksContainer/mockGraphics.ts b/test/testUtils/mocks/mocksContainer/mockGraphics.ts index 2b4a33b5e4c..ebf84e935e3 100644 --- a/test/testUtils/mocks/mocksContainer/mockGraphics.ts +++ b/test/testUtils/mocks/mocksContainer/mockGraphics.ts @@ -4,11 +4,11 @@ export default class MockGraphics implements MockGameObject { private scene; public list: MockGameObject[] = []; public name: string; - constructor(textureManager, config) { + constructor(textureManager, _config) { this.scene = textureManager.scene; } - fillStyle(color) { + fillStyle(_color) { // Sets the fill style to be used by the fill methods. } @@ -16,7 +16,7 @@ export default class MockGraphics implements MockGameObject { // Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path. } - fillRect(x, y, width, height) { + fillRect(_x, _y, _width, _height) { // Adds a rectangle shape to the path which is filled when you call fill(). } @@ -24,20 +24,15 @@ export default class MockGraphics implements MockGameObject { // Creates a geometry mask. } - setOrigin(x, y) { - } + setOrigin(_x, _y) {} - setAlpha(alpha) { - } + setAlpha(_alpha) {} - setVisible(visible) { - } + setVisible(_visible) {} - setName(name) { - } + setName(_name) {} - once(event, callback, source) { - } + once(_event, _callback, _source) {} removeFromDisplayList() { // same as remove or destroy @@ -47,7 +42,7 @@ export default class MockGraphics implements MockGameObject { // This callback is invoked when this Game Object is added to a Scene. } - setPositionRelative(source, x, y) { + setPositionRelative(_source, _x, _y) { /// Sets the position of this Game Object to be a relative position from the source Game Object. } @@ -55,12 +50,11 @@ export default class MockGraphics implements MockGameObject { this.list = []; } - setScale(scale) { + setScale(_scale) { // Sets the scale of this Game Object. } - off(event, callback, source) { - } + off(_event, _callback, _source) {} add(obj) { // Adds a child to this Game Object. diff --git a/test/testUtils/mocks/mocksContainer/mockImage.ts b/test/testUtils/mocks/mocksContainer/mockImage.ts index 3badde4f8ab..768fcfeb765 100644 --- a/test/testUtils/mocks/mocksContainer/mockImage.ts +++ b/test/testUtils/mocks/mocksContainer/mockImage.ts @@ -1,6 +1,5 @@ import MockContainer from "#test/testUtils/mocks/mocksContainer/mockContainer"; - export default class MockImage extends MockContainer { private texture; diff --git a/test/testUtils/mocks/mocksContainer/mockNineslice.ts b/test/testUtils/mocks/mocksContainer/mockNineslice.ts index 4f6b8a5d21d..90c0e13e725 100644 --- a/test/testUtils/mocks/mocksContainer/mockNineslice.ts +++ b/test/testUtils/mocks/mocksContainer/mockNineslice.ts @@ -1,6 +1,5 @@ import MockContainer from "#test/testUtils/mocks/mocksContainer/mockContainer"; - export default class MockNineslice extends MockContainer { private texture; private leftWidth; @@ -8,7 +7,7 @@ export default class MockNineslice extends MockContainer { private topHeight; private bottomHeight; - constructor(textureManager, x, y, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight) { + constructor(textureManager, x, y, texture, frame, _width, _height, leftWidth, rightWidth, topHeight, bottomHeight) { super(textureManager, x, y); this.texture = texture; this.frame = frame; diff --git a/test/testUtils/mocks/mocksContainer/mockPolygon.ts b/test/testUtils/mocks/mocksContainer/mockPolygon.ts index 43e9c5460d0..4a7f3baec78 100644 --- a/test/testUtils/mocks/mocksContainer/mockPolygon.ts +++ b/test/testUtils/mocks/mocksContainer/mockPolygon.ts @@ -1,9 +1,7 @@ import MockContainer from "#test/testUtils/mocks/mocksContainer/mockContainer"; - export default class MockPolygon extends MockContainer { - constructor(textureManager, x, y, content, fillColor, fillAlpha) { + constructor(textureManager, x, y, _content, _fillColor, _fillAlpha) { super(textureManager, x, y); } } - diff --git a/test/testUtils/mocks/mocksContainer/mockRectangle.ts b/test/testUtils/mocks/mocksContainer/mockRectangle.ts index e4bca76b8fc..eec431d8ada 100644 --- a/test/testUtils/mocks/mocksContainer/mockRectangle.ts +++ b/test/testUtils/mocks/mocksContainer/mockRectangle.ts @@ -6,23 +6,18 @@ export default class MockRectangle implements MockGameObject { public list: MockGameObject[] = []; public name: string; - constructor(textureManager, x, y, width, height, fillColor) { + constructor(textureManager, _x, _y, _width, _height, fillColor) { this.fillColor = fillColor; this.scene = textureManager.scene; } - setOrigin(x, y) { - } + setOrigin(_x, _y) {} - setAlpha(alpha) { - } - setVisible(visible) { - } + setAlpha(_alpha) {} + setVisible(_visible) {} - setName(name) { - } + setName(_name) {} - once(event, callback, source) { - } + once(_event, _callback, _source) {} removeFromDisplayList() { // same as remove or destroy @@ -32,7 +27,7 @@ export default class MockRectangle implements MockGameObject { // This callback is invoked when this Game Object is added to a Scene. } - setPositionRelative(source, x, y) { + setPositionRelative(_source, _x, _y) { /// Sets the position of this Game Object to be a relative position from the source Game Object. } @@ -74,7 +69,7 @@ export default class MockRectangle implements MockGameObject { getAll() { return this.list; } - setScale(scale) { + setScale(_scale) { // return this.phaserText.setScale(scale); } } diff --git a/test/testUtils/mocks/mocksContainer/mockSprite.ts b/test/testUtils/mocks/mocksContainer/mockSprite.ts index 6d851330a5e..dcc3588f127 100644 --- a/test/testUtils/mocks/mocksContainer/mockSprite.ts +++ b/test/testUtils/mocks/mocksContainer/mockSprite.ts @@ -3,7 +3,6 @@ import type { MockGameObject } from "../mockGameObject"; import Sprite = Phaser.GameObjects.Sprite; import Frame = Phaser.Textures.Frame; - export default class MockSprite implements MockGameObject { private phaserSprite; public pipelineData; @@ -38,11 +37,11 @@ export default class MockSprite implements MockGameObject { }; } - setTexture(key: string, frame?: string | number) { + setTexture(_key: string, _frame?: string | number) { return this; } - setSizeToFrame(frame?: boolean | Frame): Sprite { + setSizeToFrame(_frame?: boolean | Frame): Sprite { return {} as Sprite; } @@ -51,8 +50,7 @@ export default class MockSprite implements MockGameObject { return this.phaserSprite.setPipeline(obj); } - off(event, callback, source) { - } + off(_event, _callback, _source) {} setTintFill(color) { // Sets the tint fill color. @@ -117,7 +115,7 @@ export default class MockSprite implements MockGameObject { return this.phaserSprite.setTint(color); } - setFrame(frame, updateSize?: boolean, updateOrigin?: boolean) { + setFrame(frame, _updateSize?: boolean, _updateOrigin?: boolean) { // Sets the frame this Game Object will use to render with. this.frame = frame; return frame; @@ -172,9 +170,7 @@ export default class MockSprite implements MockGameObject { return this.phaserSprite.setAngle(angle); } - setMask() { - - } + setMask() {} add(obj) { // Adds a child to this Game Object. @@ -210,6 +206,4 @@ export default class MockSprite implements MockGameObject { getAll() { return this.list; } - - } diff --git a/test/testUtils/mocks/mocksContainer/mockText.ts b/test/testUtils/mocks/mocksContainer/mockText.ts index 5550e801386..552f8ff3ff8 100644 --- a/test/testUtils/mocks/mocksContainer/mockText.ts +++ b/test/testUtils/mocks/mocksContainer/mockText.ts @@ -13,7 +13,7 @@ export default class MockText implements MockGameObject { public name: string; public color?: string; - constructor(textureManager, x, y, content, styleOptions) { + constructor(textureManager, _x, _y, _content, _styleOptions) { this.scene = textureManager.scene; this.textureManager = textureManager; this.style = {}; @@ -85,7 +85,7 @@ export default class MockText implements MockGameObject { callback?: Function | null, callbackDelay?: number | null, prompt?: boolean | null, - promptDelay?: number | null + promptDelay?: number | null, ) { this.scene.messageWrapper.showText(text, delay, callback, callbackDelay, prompt, promptDelay); if (callback) { @@ -93,42 +93,49 @@ export default class MockText implements MockGameObject { } } - showDialogue(keyOrText: string, name: string | undefined, delay: number | null = 0, callback: Function, callbackDelay?: number, promptDelay?: number) { + showDialogue( + keyOrText: string, + name: string | undefined, + delay: number | null = 0, + callback: Function, + callbackDelay?: number, + promptDelay?: number, + ) { this.scene.messageWrapper.showDialogue(keyOrText, name, delay, callback, callbackDelay, promptDelay); if (callback) { callback(); } } - setScale(scale) { + setScale(_scale) { // return this.phaserText.setScale(scale); } - setShadow(shadowXpos, shadowYpos, shadowColor) { + setShadow(_shadowXpos, _shadowYpos, _shadowColor) { // Sets the shadow settings for this Game Object. // return this.phaserText.setShadow(shadowXpos, shadowYpos, shadowColor); } - setLineSpacing(lineSpacing) { + setLineSpacing(_lineSpacing) { // Sets the line spacing value of this Game Object. // return this.phaserText.setLineSpacing(lineSpacing); } - setOrigin(x, y) { + setOrigin(_x, _y) { // return this.phaserText.setOrigin(x, y); } - once(event, callback, source) { + once(_event, _callback, _source) { // return this.phaserText.once(event, callback, source); } - off(event, callback, obj) {} + off(_event, _callback, _obj) {} removedFromScene() {} addToDisplayList() {} - setStroke(color, thickness) { + setStroke(_color, _thickness) { // Sets the stroke color and thickness. // return this.phaserText.setStroke(color, thickness); } @@ -143,15 +150,15 @@ export default class MockText implements MockGameObject { // return this.phaserText.addedToScene(); } - setVisible(visible) { + setVisible(_visible) { // return this.phaserText.setVisible(visible); } - setY(y) { + setY(_y) { // return this.phaserText.setY(y); } - setX(x) { + setX(_x) { // return this.phaserText.setX(x); } @@ -162,7 +169,7 @@ export default class MockText implements MockGameObject { * @param z The z position of this Game Object. Default 0. * @param w The w position of this Game Object. Default 0. */ - setPosition(x?: number, y?: number, z?: number, w?: number) {} + setPosition(_x?: number, _y?: number, _z?: number, _w?: number) {} setText(text) { // Sets the text this Game Object will display. @@ -170,17 +177,17 @@ export default class MockText implements MockGameObject { this.text = text; } - setAngle(angle) { + setAngle(_angle) { // Sets the angle of this Game Object. // return this.phaserText.setAngle(angle); } - setPositionRelative(source, x, y) { + setPositionRelative(_source, _x, _y) { /// Sets the position of this Game Object to be a relative position from the source Game Object. // return this.phaserText.setPositionRelative(source, x, y); } - setShadowOffset(offsetX, offsetY) { + setShadowOffset(_offsetX, _offsetY) { // Sets the shadow offset values. // return this.phaserText.setShadowOffset(offsetX, offsetY); } @@ -190,7 +197,7 @@ export default class MockText implements MockGameObject { this.wordWrapWidth = width; } - setFontSize(fontSize) { + setFontSize(_fontSize) { // Sets the font size of this Game Object. // return this.phaserText.setFontSize(fontSize); } @@ -208,17 +215,17 @@ export default class MockText implements MockGameObject { setInteractive = () => null; - setShadowColor(color) { + setShadowColor(_color) { // Sets the shadow color. // return this.phaserText.setShadowColor(color); } - setTint(color) { + setTint(_color) { // Sets the tint of this Game Object. // return this.phaserText.setTint(color); } - setStrokeStyle(thickness, color) { + setStrokeStyle(_thickness, _color) { // Sets the stroke style for the graphics. // return this.phaserText.setStrokeStyle(thickness, color); } @@ -228,7 +235,7 @@ export default class MockText implements MockGameObject { this.list = []; } - setAlpha(alpha) { + setAlpha(_alpha) { // return this.phaserText.setAlpha(alpha); } @@ -236,7 +243,7 @@ export default class MockText implements MockGameObject { this.name = name; } - setAlign(align) { + setAlign(_align) { // return this.phaserText.setAlign(align); } diff --git a/test/testUtils/mocks/mocksContainer/mockTexture.ts b/test/testUtils/mocks/mocksContainer/mockTexture.ts index a9186783d46..eb8b70902fa 100644 --- a/test/testUtils/mocks/mocksContainer/mockTexture.ts +++ b/test/testUtils/mocks/mocksContainer/mockTexture.ts @@ -1,7 +1,6 @@ import type MockTextureManager from "#test/testUtils/mocks/mockTextureManager"; import type { MockGameObject } from "../mockGameObject"; - /** * Stub for Phaser.Textures.Texture object * Just mocks the function calls and data required for use in tests @@ -23,7 +22,7 @@ export default class MockTexture implements MockGameObject { width: 100, height: 100, cutX: 0, - cutY: 0 + cutY: 0, }; this.frames = { firstFrame: mockFrame, @@ -31,7 +30,7 @@ export default class MockTexture implements MockGameObject { 1: mockFrame, 2: mockFrame, 3: mockFrame, - 4: mockFrame + 4: mockFrame, }; this.firstFrame = "firstFrame"; } diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index fe0fbf82e29..742a6bc8441 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -50,7 +50,7 @@ import { MysteryEncounterOptionSelectedPhase, MysteryEncounterPhase, MysteryEncounterRewardsPhase, - PostMysteryEncounterPhase + PostMysteryEncounterPhase, } from "#app/phases/mystery-encounter-phases"; import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; import { PartyExpPhase } from "#app/phases/party-exp-phase"; @@ -215,68 +215,73 @@ export default class PhaseInterceptor { * `initPhases()` so that its subclasses can use `super.start()` properly. */ private PHASES = [ - [ LoginPhase, this.startPhase ], - [ TitlePhase, this.startPhase ], - [ SelectGenderPhase, this.startPhase ], - [ NewBiomeEncounterPhase, this.startPhase ], - [ SelectStarterPhase, this.startPhase ], - [ PostSummonPhase, this.startPhase ], - [ SummonPhase, this.startPhase ], - [ ToggleDoublePositionPhase, this.startPhase ], - [ CheckSwitchPhase, this.startPhase ], - [ ShowAbilityPhase, this.startPhase ], - [ MessagePhase, this.startPhase ], - [ TurnInitPhase, this.startPhase ], - [ CommandPhase, this.startPhase ], - [ EnemyCommandPhase, this.startPhase ], - [ TurnStartPhase, this.startPhase ], - [ MovePhase, this.startPhase ], - [ MoveEffectPhase, this.startPhase ], - [ DamageAnimPhase, this.startPhase ], - [ FaintPhase, this.startPhase ], - [ BerryPhase, this.startPhase ], - [ TurnEndPhase, this.startPhase ], - [ BattleEndPhase, this.startPhase ], - [ EggLapsePhase, this.startPhase ], - [ SelectModifierPhase, this.startPhase ], - [ NextEncounterPhase, this.startPhase ], - [ NewBattlePhase, this.startPhase ], - [ VictoryPhase, this.startPhase ], - [ LearnMovePhase, this.startPhase ], - [ MoveEndPhase, this.startPhase ], - [ StatStageChangePhase, this.startPhase ], - [ ShinySparklePhase, this.startPhase ], - [ SelectTargetPhase, this.startPhase ], - [ UnavailablePhase, this.startPhase ], - [ QuietFormChangePhase, this.startPhase ], - [ SwitchPhase, this.startPhase ], - [ SwitchSummonPhase, this.startPhase ], - [ PartyHealPhase, this.startPhase ], - [ FormChangePhase, this.startPhase ], - [ EvolutionPhase, this.startPhase ], - [ EndEvolutionPhase, this.startPhase ], - [ LevelCapPhase, this.startPhase ], - [ AttemptRunPhase, this.startPhase ], - [ SelectBiomePhase, this.startPhase ], - [ MysteryEncounterPhase, this.startPhase ], - [ MysteryEncounterOptionSelectedPhase, this.startPhase ], - [ MysteryEncounterBattlePhase, this.startPhase ], - [ MysteryEncounterRewardsPhase, this.startPhase ], - [ PostMysteryEncounterPhase, this.startPhase ], - [ RibbonModifierRewardPhase, this.startPhase ], - [ GameOverModifierRewardPhase, this.startPhase ], - [ ModifierRewardPhase, this.startPhase ], - [ PartyExpPhase, this.startPhase ], - [ ExpPhase, this.startPhase ], - [ EncounterPhase, this.startPhase ], - [ GameOverPhase, this.startPhase ], - [ UnlockPhase, this.startPhase ], - [ PostGameOverPhase, this.startPhase ], - [ RevivalBlessingPhase, this.startPhase ], + [LoginPhase, this.startPhase], + [TitlePhase, this.startPhase], + [SelectGenderPhase, this.startPhase], + [NewBiomeEncounterPhase, this.startPhase], + [SelectStarterPhase, this.startPhase], + [PostSummonPhase, this.startPhase], + [SummonPhase, this.startPhase], + [ToggleDoublePositionPhase, this.startPhase], + [CheckSwitchPhase, this.startPhase], + [ShowAbilityPhase, this.startPhase], + [MessagePhase, this.startPhase], + [TurnInitPhase, this.startPhase], + [CommandPhase, this.startPhase], + [EnemyCommandPhase, this.startPhase], + [TurnStartPhase, this.startPhase], + [MovePhase, this.startPhase], + [MoveEffectPhase, this.startPhase], + [DamageAnimPhase, this.startPhase], + [FaintPhase, this.startPhase], + [BerryPhase, this.startPhase], + [TurnEndPhase, this.startPhase], + [BattleEndPhase, this.startPhase], + [EggLapsePhase, this.startPhase], + [SelectModifierPhase, this.startPhase], + [NextEncounterPhase, this.startPhase], + [NewBattlePhase, this.startPhase], + [VictoryPhase, this.startPhase], + [LearnMovePhase, this.startPhase], + [MoveEndPhase, this.startPhase], + [StatStageChangePhase, this.startPhase], + [ShinySparklePhase, this.startPhase], + [SelectTargetPhase, this.startPhase], + [UnavailablePhase, this.startPhase], + [QuietFormChangePhase, this.startPhase], + [SwitchPhase, this.startPhase], + [SwitchSummonPhase, this.startPhase], + [PartyHealPhase, this.startPhase], + [FormChangePhase, this.startPhase], + [EvolutionPhase, this.startPhase], + [EndEvolutionPhase, this.startPhase], + [LevelCapPhase, this.startPhase], + [AttemptRunPhase, this.startPhase], + [SelectBiomePhase, this.startPhase], + [MysteryEncounterPhase, this.startPhase], + [MysteryEncounterOptionSelectedPhase, this.startPhase], + [MysteryEncounterBattlePhase, this.startPhase], + [MysteryEncounterRewardsPhase, this.startPhase], + [PostMysteryEncounterPhase, this.startPhase], + [RibbonModifierRewardPhase, this.startPhase], + [GameOverModifierRewardPhase, this.startPhase], + [ModifierRewardPhase, this.startPhase], + [PartyExpPhase, this.startPhase], + [ExpPhase, this.startPhase], + [EncounterPhase, this.startPhase], + [GameOverPhase, this.startPhase], + [UnlockPhase, this.startPhase], + [PostGameOverPhase, this.startPhase], + [RevivalBlessingPhase, this.startPhase], ]; private endBySetMode = [ - TitlePhase, SelectGenderPhase, CommandPhase, SelectModifierPhase, MysteryEncounterPhase, PostMysteryEncounterPhase + TitlePhase, + SelectGenderPhase, + CommandPhase, + SelectModifierPhase, + MysteryEncounterPhase, + PostMysteryEncounterPhase, ]; /** @@ -324,29 +329,29 @@ export default class PhaseInterceptor { * @param runTarget - Whether or not to run the target phase. * @returns A promise that resolves when the transition is complete. */ - async to(phaseTo: PhaseInterceptorPhase, runTarget: boolean = true): Promise { + async to(phaseTo: PhaseInterceptorPhase, runTarget = true): Promise { return new Promise(async (resolve, reject) => { ErrorInterceptor.getInstance().add(this); if (this.phaseFrom) { - await this.run(this.phaseFrom).catch((e) => reject(e)); + await this.run(this.phaseFrom).catch(e => reject(e)); this.phaseFrom = null; } const targetName = typeof phaseTo === "string" ? phaseTo : phaseTo.name; - this.intervalRun = setInterval(async() => { + this.intervalRun = setInterval(async () => { const currentPhase = this.onHold?.length && this.onHold[0]; if (currentPhase && currentPhase.name === targetName) { clearInterval(this.intervalRun); if (!runTarget) { return resolve(); } - await this.run(currentPhase).catch((e) => { + await this.run(currentPhase).catch(e => { clearInterval(this.intervalRun); return reject(e); }); return resolve(); } if (currentPhase && currentPhase.name !== targetName) { - await this.run(currentPhase).catch((e) => { + await this.run(currentPhase).catch(e => { clearInterval(this.intervalRun); return reject(e); }); @@ -371,7 +376,7 @@ export default class PhaseInterceptor { if (currentPhase) { if (currentPhase.name !== targetName) { clearInterval(interval); - const skip = skipFn && skipFn(currentPhase.name); + const skip = skipFn?.(currentPhase.name); if (skip) { this.onHold.unshift(currentPhase); ErrorInterceptor.getInstance().remove(this); @@ -387,7 +392,7 @@ export default class PhaseInterceptor { ErrorInterceptor.getInstance().remove(this); resolve(); }, - onError: (error) => reject(error), + onError: error => reject(error), }; currentPhase.call(); } @@ -395,10 +400,10 @@ export default class PhaseInterceptor { }); } - whenAboutToRun(phaseTarget: PhaseInterceptorPhase, skipFn?: (className: PhaseClass) => boolean): Promise { + whenAboutToRun(phaseTarget: PhaseInterceptorPhase, _skipFn?: (className: PhaseClass) => boolean): Promise { const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; this.scene.moveAnimations = null; // Mandatory to avoid crash - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve, _reject) => { ErrorInterceptor.getInstance().add(this); const interval = setInterval(async () => { const currentPhase = this.onHold[0]; @@ -424,7 +429,7 @@ export default class PhaseInterceptor { * * @param shouldRun Whether or not the current scene should also be run. */ - shift(shouldRun: boolean = false) : void { + shift(shouldRun = false): void { this.onHold.shift(); if (shouldRun) { this.scene.shiftPhase(); @@ -439,11 +444,11 @@ export default class PhaseInterceptor { this.originalSuperEnd = Phase.prototype.end; UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args); Phase.prototype.end = () => this.superEndPhase.call(this); - for (const [ phase, methodStart ] of this.PHASES) { + for (const [phase, methodStart] of this.PHASES) { const originalStart = phase.prototype.start; this.phases[phase.name] = { start: originalStart, - endBySetMode: this.endBySetMode.some((elm) => elm.name === phase.name), + endBySetMode: this.endBySetMode.some(elm => elm.name === phase.name), }; phase.prototype.start = () => methodStart.call(this, phase); } @@ -460,7 +465,7 @@ export default class PhaseInterceptor { name: phase.name, call: () => { this.phases[phase.name].start.apply(instance); - } + }, }); } @@ -489,10 +494,11 @@ export default class PhaseInterceptor { const currentPhase = this.scene.getCurrentPhase(); const instance = this.scene.ui; console.log("setMode", `${Mode[mode]} (=${mode})`, args); - const ret = this.originalSetMode.apply(instance, [ mode, ...args ]); + const ret = this.originalSetMode.apply(instance, [mode, ...args]); if (!this.phases[currentPhase.constructor.name]) { - throw new Error(`missing ${currentPhase.constructor.name} in phaseInterceptor PHASES list --- Add it to PHASES inside of /test/utils/phaseInterceptor.ts`); - + throw new Error( + `missing ${currentPhase.constructor.name} in phaseInterceptor PHASES list --- Add it to PHASES inside of /test/utils/phaseInterceptor.ts`, + ); } if (this.phases[currentPhase.constructor.name].endBySetMode) { this.inProgress?.callback(); @@ -508,7 +514,7 @@ export default class PhaseInterceptor { this.promptInterval = setInterval(() => { if (this.prompts.length) { const actionForNextPrompt = this.prompts[0]; - const expireFn = actionForNextPrompt.expireFn && actionForNextPrompt.expireFn(); + const expireFn = actionForNextPrompt.expireFn?.(); const currentMode = this.scene.ui.getMode(); const currentPhase = this.scene.getCurrentPhase()?.constructor.name; const currentHandler = this.scene.ui.getHandler(); @@ -538,13 +544,19 @@ export default class PhaseInterceptor { * @param expireFn - The function to determine if the prompt has expired. * @param awaitingActionInput */ - addToNextPrompt(phaseTarget: string, mode: Mode, callback: () => void, expireFn?: () => void, awaitingActionInput: boolean = false) { + addToNextPrompt( + phaseTarget: string, + mode: Mode, + callback: () => void, + expireFn?: () => void, + awaitingActionInput = false, + ) { this.prompts.push({ phaseTarget, mode, callback, expireFn, - awaitingActionInput + awaitingActionInput, }); } @@ -555,7 +567,7 @@ export default class PhaseInterceptor { * function stored in `this.phases`. Additionally, it clears the `promptInterval` and `interval`. */ restoreOg() { - for (const [ phase ] of this.PHASES) { + for (const [phase] of this.PHASES) { phase.prototype.start = this.phases[phase.name].start; } UI.prototype.setMode = this.originalSetMode; diff --git a/test/ui/battle_info.test.ts b/test/ui/battle_info.test.ts index 6209312c451..4c6274d5efb 100644 --- a/test/ui/battle_info.test.ts +++ b/test/ui/battle_info.test.ts @@ -7,6 +7,7 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +// biome-ignore lint/correctness/noEmptyPattern: TODO: Examine why this is here vi.mock("../data/exp", ({}) => { return { getLevelRelExp: vi.fn(() => 1), //consistent levelRelExp @@ -30,26 +31,26 @@ describe("UI - Battle Info", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.GUILLOTINE, Moves.SPLASH ]) + .moveset([Moves.GUILLOTINE, Moves.SPLASH]) .battleType("single") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH) .enemySpecies(Species.CATERPIE); }); - it.each([ ExpGainsSpeed.FAST, ExpGainsSpeed.FASTER, ExpGainsSpeed.SKIP ])( + it.each([ExpGainsSpeed.FAST, ExpGainsSpeed.FASTER, ExpGainsSpeed.SKIP])( "should increase exp gains animation by 2^%i", - async (expGainsSpeed) => { + async expGainsSpeed => { game.settings.expGainsSpeed(expGainsSpeed); vi.spyOn(Math, "pow"); - await game.classicMode.startBattle([ Species.CHARIZARD ]); + await game.classicMode.startBattle([Species.CHARIZARD]); game.move.select(Moves.SPLASH); await game.doKillOpponents(); await game.phaseInterceptor.to(ExpPhase, true); expect(Math.pow).not.toHaveBeenCalledWith(2, expGainsSpeed); - } + }, ); }); diff --git a/test/ui/starter-select.test.ts b/test/ui/starter-select.test.ts index 685debf098d..1d523c3bbd5 100644 --- a/test/ui/starter-select.test.ts +++ b/test/ui/starter-select.test.ts @@ -18,7 +18,6 @@ import i18next from "i18next"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; - describe("UI - Starter select", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -37,9 +36,9 @@ describe("UI - Starter select", () => { game = new GameManager(phaserGame); }); - it("Bulbasaur - shiny - variant 2 male", async() => { + it("Bulbasaur - shiny - variant 2 male", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -60,7 +59,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -74,7 +73,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -97,9 +96,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].gender).toBe(Gender.MALE); }, 20000); - it("Bulbasaur - shiny - variant 2 female hardy overgrow", async() => { + it("Bulbasaur - shiny - variant 2 female hardy overgrow", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -121,7 +120,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -135,7 +134,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -159,9 +158,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].getAbility().id).toBe(Abilities.OVERGROW); }, 20000); - it("Bulbasaur - shiny - variant 2 female lonely chlorophyl", async() => { + it("Bulbasaur - shiny - variant 2 female lonely chlorophyl", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -185,7 +184,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -199,7 +198,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -224,9 +223,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].getAbility().id).toBe(Abilities.CHLOROPHYLL); }, 20000); - it("Bulbasaur - shiny - variant 2 female", async() => { + it("Bulbasaur - shiny - variant 2 female", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -248,7 +247,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -262,7 +261,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -285,9 +284,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].gender).toBe(Gender.FEMALE); }, 20000); - it("Bulbasaur - not shiny", async() => { + it("Bulbasaur - not shiny", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -309,7 +308,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -323,7 +322,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -345,9 +344,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].variant).toBe(0); }, 20000); - it("Bulbasaur - shiny - variant 1", async() => { + it("Bulbasaur - shiny - variant 1", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -371,7 +370,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -385,7 +384,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -407,9 +406,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].variant).toBe(1); }, 20000); - it("Bulbasaur - shiny - variant 0", async() => { + it("Bulbasaur - shiny - variant 0", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -432,7 +431,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -446,7 +445,7 @@ describe("UI - Starter select", () => { expect(options.some(option => option.label === i18next.t("menu:cancel"))).toBe(true); optionSelectUiHandler?.processInput(Button.ACTION); - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { const handler = game.scene.ui.getHandler() as StarterSelectUiHandler; handler.processInput(Button.SUBMIT); @@ -468,9 +467,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].variant).toBe(0); }, 20000); - it("Check if first pokemon in party is caterpie from gen 1 and 1rd row, 3rd column", async() => { + it("Check if first pokemon in party is caterpie from gen 1 and 1rd row, 3rd column", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -492,7 +491,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -507,7 +506,7 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); let starterSelectUiHandler: StarterSelectUiHandler; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { starterSelectUiHandler = game.scene.ui.getHandler() as StarterSelectUiHandler; starterSelectUiHandler.processInput(Button.SUBMIT); @@ -532,9 +531,9 @@ describe("UI - Starter select", () => { expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(Species.CATERPIE); }, 20000); - it("Check if first pokemon in party is nidoran_m from gen 1 and 2nd row, 4th column (cursor (9+4)-1)", async() => { + it("Check if first pokemon in party is nidoran_m from gen 1 and 2nd row, 4th column (cursor (9+4)-1)", async () => { await game.importData("./test/testUtils/saves/everything.prsv"); - const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { + const caughtCount = Object.keys(game.scene.gameData.dexData).filter(key => { const species = game.scene.gameData.dexData[key]; return species.caughtAttr !== 0n; }).length; @@ -557,7 +556,7 @@ describe("UI - Starter select", () => { await game.phaseInterceptor.run(SelectStarterPhase); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.OPTION_SELECT, () => { optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler; options = optionSelectUiHandler.getOptionsWithScroll(); @@ -572,7 +571,7 @@ describe("UI - Starter select", () => { optionSelectUiHandler?.processInput(Button.ACTION); let starterSelectUiHandler: StarterSelectUiHandler | undefined; - await new Promise((resolve) => { + await new Promise(resolve => { game.onNextPrompt("SelectStarterPhase", Mode.STARTER_SELECT, () => { starterSelectUiHandler = game.scene.ui.getHandler() as StarterSelectUiHandler; starterSelectUiHandler.processInput(Button.SUBMIT); diff --git a/test/ui/transfer-item.test.ts b/test/ui/transfer-item.test.ts index 83c2eb2ef79..476f0744436 100644 --- a/test/ui/transfer-item.test.ts +++ b/test/ui/transfer-item.test.ts @@ -34,11 +34,11 @@ describe("UI - Transfer Items", () => { { name: "BERRY", count: 2, type: BerryType.APICOT }, { name: "BERRY", count: 2, type: BerryType.LUM }, ]); - game.override.moveset([ Moves.DRAGON_CLAW ]); + game.override.moveset([Moves.DRAGON_CLAW]); game.override.enemySpecies(Species.MAGIKARP); - game.override.enemyMoveset([ Moves.SPLASH ]); + game.override.enemyMoveset([Moves.SPLASH]); - await game.classicMode.startBattle([ Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA ]); + await game.classicMode.startBattle([Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA]); game.move.select(Moves.DRAGON_CLAW); @@ -62,9 +62,15 @@ describe("UI - Transfer Items", () => { const handler = game.scene.ui.getHandler() as PartyUiHandler; handler.processInput(Button.ACTION); - expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Sitrus Berry"))).toBe(true); - expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Apicot Berry (2)"))).toBe(true); - expect(handler.optionsContainer.list.some((option) => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text))).toBe(true); + expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Sitrus Berry"))).toBe( + true, + ); + expect( + handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Apicot Berry (2)")), + ).toBe(true); + expect( + handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)), + ).toBe(true); game.phaseInterceptor.unlock(); }); @@ -83,7 +89,9 @@ describe("UI - Transfer Items", () => { handler.setCursor(1); // move to other Pokemon handler.processInput(Button.ACTION); // select Pokemon - expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Transfer"))).toBe(true); + expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe( + true, + ); game.phaseInterceptor.unlock(); }); diff --git a/test/ui/type-hints.test.ts b/test/ui/type-hints.test.ts index 0838ab01f51..fa7532fb674 100644 --- a/test/ui/type-hints.test.ts +++ b/test/ui/type-hints.test.ts @@ -37,10 +37,10 @@ describe("UI - Type Hints", () => { .startingWave(1) .enemySpecies(Species.FLORGES) .enemyMoveset(Moves.SPLASH) - .moveset([ Moves.DRAGON_CLAW ]); + .moveset([Moves.DRAGON_CLAW]); game.settings.typeHints(true); //activate type hints - await game.startBattle([ Species.RAYQUAZA ]); + await game.startBattle([Species.RAYQUAZA]); game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { const { ui } = game.scene; @@ -54,7 +54,7 @@ describe("UI - Type Hints", () => { const movesContainer = ui.getByName(FightUiHandler.MOVES_CONTAINER_NAME); const dragonClawText = movesContainer .getAll() - .find((text) => text.text === i18next.t("move:dragonClaw.name"))! as unknown as MockText; + .find(text => text.text === i18next.t("move:dragonClaw.name"))! as unknown as MockText; expect.soft(dragonClawText.color).toBe("#929292"); ui.getHandler().processInput(Button.ACTION); @@ -63,9 +63,9 @@ describe("UI - Type Hints", () => { }); it("check status move color", async () => { - game.override.enemySpecies(Species.FLORGES).moveset([ Moves.GROWL ]); + game.override.enemySpecies(Species.FLORGES).moveset([Moves.GROWL]); - await game.startBattle([ Species.RAYQUAZA ]); + await game.startBattle([Species.RAYQUAZA]); game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { const { ui } = game.scene; @@ -79,7 +79,7 @@ describe("UI - Type Hints", () => { const movesContainer = ui.getByName(FightUiHandler.MOVES_CONTAINER_NAME); const growlText = movesContainer .getAll() - .find((text) => text.text === i18next.t("move:growl.name"))! as unknown as MockText; + .find(text => text.text === i18next.t("move:growl.name"))! as unknown as MockText; expect.soft(growlText.color).toBe(undefined); ui.getHandler().processInput(Button.ACTION); diff --git a/test/vitest.setup.ts b/test/vitest.setup.ts index 5dc5a69ce73..44175049042 100644 --- a/test/vitest.setup.ts +++ b/test/vitest.setup.ts @@ -18,14 +18,14 @@ import { afterAll, beforeAll, vi } from "vitest"; process.env.TZ = "UTC"; /** Mock the override import to always return default values, ignoring any custom overrides. */ -vi.mock("#app/overrides", async (importOriginal) => { +vi.mock("#app/overrides", async importOriginal => { // eslint-disable-next-line @typescript-eslint/consistent-type-imports const { defaultOverrides } = await importOriginal(); return { default: defaultOverrides, defaultOverrides, - // eslint-disable-next-line @typescript-eslint/consistent-type-imports + // eslint-disable-next-line @typescript-eslint/consistent-type-imports } satisfies typeof import("#app/overrides"); }); @@ -35,13 +35,13 @@ vi.mock("#app/overrides", async (importOriginal) => { * This is necessary because how our code is structured. * Do NOT try to put any of this code into external functions, it won't work as it's elevated during runtime. */ -vi.mock("i18next", async (importOriginal) => { +vi.mock("i18next", async importOriginal => { console.log("Mocking i18next"); const { setupServer } = await import("msw/node"); const { http, HttpResponse } = await import("msw"); global.server = setupServer( - http.get("/locales/en/*", async (req) => { + http.get("/locales/en/*", async req => { const filename = req.params[0]; try { diff --git a/tsconfig.json b/tsconfig.json index 6bb0ae51c1b..30e208745b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,34 +1,28 @@ { - "compilerOptions": { - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "esModuleInterop": true, - "strictNullChecks": true, - "sourceMap": false, - "strict": false, - "rootDir": ".", - "baseUrl": "./src", - "paths": { - "#enums/*": ["./enums/*.ts"], - "#app/*": ["*.ts"], - "#test/*": ["../test/*.ts"] - }, - "outDir": "./build", - "noEmit": true - }, - "typedocOptions": { - "entryPoints": ["./src"], - "entryPointStrategy": "expand", - "exclude": "**/*+.test.ts", - "out": "typedoc" - }, - "exclude": [ - "node_modules", - "dist", - "vite.config.ts", - "vitest.config.ts", - "vitest.workspace.ts", - ] + "compilerOptions": { + "target": "ES2020", + "module": "ES2020", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "esModuleInterop": true, + "strictNullChecks": true, + "sourceMap": false, + "strict": false, + "rootDir": ".", + "baseUrl": "./src", + "paths": { + "#enums/*": ["./enums/*.ts"], + "#app/*": ["*.ts"], + "#test/*": ["../test/*.ts"] + }, + "outDir": "./build", + "noEmit": true + }, + "typedocOptions": { + "entryPoints": ["./src"], + "entryPointStrategy": "expand", + "exclude": "**/*+.test.ts", + "out": "typedoc" + }, + "exclude": ["node_modules", "dist", "vite.config.ts", "vitest.config.ts", "vitest.workspace.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 946315c4b7b..4b6ad687a0a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,43 +1,39 @@ -import { defineConfig, loadEnv, Rollup, UserConfig } from 'vite'; -import tsconfigPaths from 'vite-tsconfig-paths'; +import { defineConfig, loadEnv, type Rollup, type UserConfig } from "vite"; +import tsconfigPaths from "vite-tsconfig-paths"; import { minifyJsonPlugin } from "./src/plugins/vite/vite-minify-json-plugin"; -export const defaultConfig: UserConfig = { - plugins: [ - tsconfigPaths(), - minifyJsonPlugin(["images", "battle-anims"], true) - ], - clearScreen: false, - appType: "mpa", - build: { - chunkSizeWarningLimit: 10000, - minify: 'esbuild', - sourcemap: false, - rollupOptions: { - onwarn(warning: Rollup.RollupLog, defaultHandler: (warning: string | Rollup.RollupLog) => void) { - // Suppress "Module level directives cause errors when bundled" warnings - if (warning.code === "MODULE_LEVEL_DIRECTIVE") { - return; - } - defaultHandler(warning); - }, - }, - }, +export const defaultConfig: UserConfig = { + plugins: [tsconfigPaths(), minifyJsonPlugin(["images", "battle-anims"], true)], + clearScreen: false, + appType: "mpa", + build: { + chunkSizeWarningLimit: 10000, + minify: "esbuild", + sourcemap: false, + rollupOptions: { + onwarn(warning: Rollup.RollupLog, defaultHandler: (warning: string | Rollup.RollupLog) => void) { + // Suppress "Module level directives cause errors when bundled" warnings + if (warning.code === "MODULE_LEVEL_DIRECTIVE") { + return; + } + defaultHandler(warning); + }, + }, + }, }; +export default defineConfig(({ mode }) => { + const envPort = Number(loadEnv(mode, process.cwd()).VITE_PORT); -export default defineConfig(({mode}) => { - const envPort = Number(loadEnv(mode, process.cwd()).VITE_PORT); - - return ({ - ...defaultConfig, - base: '', - esbuild: { - pure: mode === 'production' ? ['console.log'] : [], - keepNames: true, - }, - server: { - port: !isNaN(envPort) ? envPort : 8000, - } - }); + return { + ...defaultConfig, + base: "", + esbuild: { + pure: mode === "production" ? ["console.log"] : [], + keepNames: true, + }, + server: { + port: !Number.isNaN(envPort) ? envPort : 8000, + }, + }; }); From 7f226df8d6d7aecf85605392164bad52e384166d Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 9 Mar 2025 17:15:24 -0500 Subject: [PATCH 3/3] [GitHub] Automatically add issue-type in issue templates (#5499) --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .github/ISSUE_TEMPLATE/feature_request.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index eb270dc8f80..81d8427b5db 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,7 @@ name: Bug Report description: Create a report to help us improve title: "[Bug] " +type: bug labels: ["Bug", "Triage"] body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 29a79b38158..08d720aea7b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,6 +1,7 @@ name: Feature Request description: Suggest an idea for this project title: "[Feature] " +type: 'feature' labels: ["Enhancement", "Triage"] body: - type: markdown