pokerogue/src/phases/command-phase.ts

334 lines
16 KiB
TypeScript
Raw Normal View History

import { globalScene } from "#app/global-scene";
import type { TurnCommand } from "#app/battle";
import { BattleType } from "#app/battle";
import type { EncoreTag } from "#app/data/battler-tags";
import { TrappedTag } from "#app/data/battler-tags";
import type { MoveTargetSet } from "#app/data/move";
import { getMoveTargets } from "#app/data/move";
import { speciesStarterCosts } from "#app/data/balance/starters";
import { Abilities } from "#app/enums/abilities";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Biome } from "#app/enums/biome";
import { Moves } from "#app/enums/moves";
import { PokeballType } from "#enums/pokeball";
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
import type { PlayerPokemon, TurnMove } from "#app/field/pokemon";
import { FieldPosition } from "#app/field/pokemon";
import { getPokemonNameWithAffix } from "#app/messages";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
2024-08-19 03:23:52 +01:00
import i18next from "i18next";
import { FieldPhase } from "./field-phase";
import { SelectTargetPhase } from "./select-target-phase";
[Feature] Add Mystery Encounters to the game (#3938) * add .github/workflows/mystery-event.yml * update mystery-event.yml * mystery encounters: resolve review comments: Lost at Sea: -fix typo in handlePokemonGuidingYouPhase function Mysterious Chest: - remove obsolete commented code mystery-encounter.ts - remove unused `onDone` field from MysteryEncounterBuilder * fix typo in CanLearnMoveRequirementOptions * remove redundance from Pokemon.isAllowedInBattle() * chore: jsdoc formatting * fix lost-at-sea tests * add fallback for biomeMysteryEncounters if empty * lost-at-sea-encounter: fix and extend tests * move "battle:fainted" into `koPlayerPokemon` * add retries to quick-draw tests * fix lost-at-sea-encounter tests * clean up battle animation logic * Update and rename mystery-event.yml to mystery-events.yml * Update mystery-events.yml * Fix typo * Update mystery-events.yml Fix debug runs * clean up unit tests and utils * attach github issues to all encounter jsdocs * start dialogue refactor * update sleeping snorlax encounter * migrate encounters dialogue to new format * cleanup and add jsdocs * finish fiery fallout encounter * fix unit test breaks * add skeleton tests to fiery fallout * commit latest test changes * finish unit tests for fiery fallout * bug fix for empty modifier shop * stash working changes * stash changes * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/battle-anims.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * nit updates and cleanup * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * add jsdocs and more cleanup * add more jsdoc * add the strong stuff encounter * add the strong stuff encounter and more unit tests * cleanup container length checks in ME ui * add retries to tests * add retries to tests * fix trainer wave disable override * add shuckle juice modifier * add dialogue bug fixes * add dialogue bug fixes * add pokemon salesman encounter and affects pokedex UI display * add unit tests for pokemon salesman * temp stash * add offer you can't refuse * add unit tests for offer you can't refuse encounter * remove unnecessary prompt handlers * add tests for disabled encounter options * add delibird-y encounter * add delibird-y encounter * add absolute avarice encounter * finish absolute avarice encounter * add unit tests and enhancements for item overrides in tests * fix unit test * cleanup absolute avarice PR * small bug fixes with latest sync from main * update visuals loading for safari and stat trainer visuals * update visuals loading for safari and stat trainer visuals * update a trainer's test encounter and add unit tests * add Trash to Treasure encounter * clean up trash to treasure encounter * clean up trash to treasure encounter * add berries abound encounter * start clowning around encounter * first implementation pass at clowning around * add unit tests for clowning around * add unit tests for clowning around * clean up ME unit tests * clean up unit tests * update unit tests * add part timer and dancing lessons encounters * add unit tests for Dancing Lessons and Part-Timer * reordered biome list and adjusted redirection for project and labels * Add Weird Dream encounter and slight reworks to Berries Abound/Fight or Flight * adjusting yml to match new labels * fix yml whoopsie * Expanded 'Weird Dream' banlist and fixed a bug with the BST bump range * adds Winstrate Challenge mystery encounter * small cleanup for winstrates * add unit tests for Winstrate Challenge * fix pokemon not returning after winstrate battle * commit latest beta merge updates * fix ME null checks and unit tests with beta update * fix ME null checks and unit tests with beta update * MEs to pokerogue beta branch * test dialogue changes * test patch fix * test patch fix * test patch fix * adds teleporting hijinks encounter * add unit tests for Teleporting Hijinks * small change to teleporting hijinks dialogue * migrate ME translations to json * add retries to berries-abound.Option1: should reward the player with X berries based on wave * add missing ME dialogue back in * revert template changes * add ME unique trainer dialogue to both dialogue jsons * fix hanging comma in json * fix broken imports * resolve lint issues * fix flaky test * balance tweaks to a few MEs, updates to bug superfan * add unit tests for Bug-Type Superfan and clean up dialogue * Adds Fun and Games mystery encounter * add unit tests for Fun and Games encounter * update jsdoc * small ME balance changes * small ME balance changes * Adds Uncommon Breed ME and misc. ME bug fixes * Update getFinalSessionData() to collect Mystery Encounter data * adds GTS encounter * various ME bug fixes and balance changes * latest ME bug fixes * clean up GTS Encounter and add unit tests * small cleanup to MEs branch * add BGM music names for ME music * bug fixes and balance changes for MEs * ME data schema updates * balance changes and bug fixes to MEs * balance changes and bug fixes to MEs * update tests for MEs * add jsdoc to party exp function * dialogue updates and test fixes for MEs * dialogue updates and test fixes for MEs * PR suggestions and fixees * stash PR feedback and bugfixes * fix all tests for MEs and cleanup * PR feedback * update flaky ME test * update tests, bug fix MEs, and sprite assets * remove unintentional console log * re-enable stubbed function for Phaser text styling * handle undefined introVisuals properly * PR feedback from NightKev * disable Uncommon Breed tests * locales updates and bug fixes for safari zone * more PR feedback and update field trip with Rarer Candy * fix unit test * Change how reroll button gets disabled in Modifier Shop Phase * update continue button text logic * Update src/ui/modifier-select-ui-handler.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * fix money formatting and some nits * more nits * more nits * update ME tsdocs with links * update ME tsdocs with links --------- Co-authored-by: Felix Staud <felix.staud@headwire.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com> Co-authored-by: InnocentGameDev <asdargmng@gmail.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com>
2024-09-13 22:05:58 -04:00
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
import { isNullOrUndefined } from "#app/utils";
import { ArenaTagSide } from "#app/data/arena-tag";
import { ArenaTagType } from "#app/enums/arena-tag-type";
2024-08-19 03:23:52 +01:00
export class CommandPhase extends FieldPhase {
protected fieldIndex: integer;
constructor(fieldIndex: integer) {
super();
2024-08-19 03:23:52 +01:00
this.fieldIndex = fieldIndex;
}
start() {
super.start();
globalScene.updateGameInfo();
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;
if (commandUiHandler) {
if ((globalScene.currentBattle.turn === 1 && (!globalScene.commandCursorMemory || cursorResetEvent)) || commandUiHandler.getCursor() === Command.POKEMON) {
commandUiHandler.setCursor(Command.FIGHT);
} else {
commandUiHandler.setCursor(commandUiHandler.getCursor());
}
}
2024-08-19 03:23:52 +01:00
if (this.fieldIndex) {
// If we somehow are attempting to check the right pokemon but there's only one pokemon out
// Switch back to the center pokemon. This can happen rarely in double battles with mid turn switching
if (globalScene.getPlayerField().filter(p => p.isActive()).length === 1) {
2024-08-19 03:23:52 +01:00
this.fieldIndex = FieldPosition.CENTER;
} else {
const allyCommand = globalScene.currentBattle.turnCommands[this.fieldIndex - 1];
2024-08-19 03:23:52 +01:00
if (allyCommand?.command === Command.BALL || allyCommand?.command === Command.RUN) {
globalScene.currentBattle.turnCommands[this.fieldIndex] = { command: allyCommand?.command, skip: true };
2024-08-19 03:23:52 +01:00
}
}
}
// 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 };
}
// Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP.
const encoreTag = this.getPokemon().getTag(BattlerTagType.ENCORE) as EncoreTag;
if (encoreTag) {
this.getPokemon().lapseTag(BattlerTagType.ENCORE);
}
if (globalScene.currentBattle.turnCommands[this.fieldIndex]?.skip) {
2024-08-19 03:23:52 +01:00
return this.end();
}
const playerPokemon = globalScene.getPlayerField()[this.fieldIndex];
2024-08-19 03:23:52 +01:00
const moveQueue = playerPokemon.getMoveQueue();
while (moveQueue.length && moveQueue[0]
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
&& moveQueue[0].move && !moveQueue[0].virtual && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move)
2024-08-19 03:23:52 +01:00
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct?
moveQueue.shift();
}
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
if (moveQueue.length > 0) {
2024-08-19 03:23:52 +01:00
const queuedMove = moveQueue[0];
if (!queuedMove.move) {
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
this.handleCommand(Command.FIGHT, -1);
2024-08-19 03:23:52 +01:00
} else {
const moveIndex = playerPokemon.getMoveset().findIndex(m => m?.moveId === queuedMove.move);
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
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);
2024-08-19 03:23:52 +01:00
} else {
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
2024-08-19 03:23:52 +01:00
}
}
} else {
if (globalScene.currentBattle.isBattleMysteryEncounter() && globalScene.currentBattle.mysteryEncounter?.skipToFightInput) {
globalScene.ui.clearText();
globalScene.ui.setMode(Mode.FIGHT, this.fieldIndex);
[Feature] Add Mystery Encounters to the game (#3938) * add .github/workflows/mystery-event.yml * update mystery-event.yml * mystery encounters: resolve review comments: Lost at Sea: -fix typo in handlePokemonGuidingYouPhase function Mysterious Chest: - remove obsolete commented code mystery-encounter.ts - remove unused `onDone` field from MysteryEncounterBuilder * fix typo in CanLearnMoveRequirementOptions * remove redundance from Pokemon.isAllowedInBattle() * chore: jsdoc formatting * fix lost-at-sea tests * add fallback for biomeMysteryEncounters if empty * lost-at-sea-encounter: fix and extend tests * move "battle:fainted" into `koPlayerPokemon` * add retries to quick-draw tests * fix lost-at-sea-encounter tests * clean up battle animation logic * Update and rename mystery-event.yml to mystery-events.yml * Update mystery-events.yml * Fix typo * Update mystery-events.yml Fix debug runs * clean up unit tests and utils * attach github issues to all encounter jsdocs * start dialogue refactor * update sleeping snorlax encounter * migrate encounters dialogue to new format * cleanup and add jsdocs * finish fiery fallout encounter * fix unit test breaks * add skeleton tests to fiery fallout * commit latest test changes * finish unit tests for fiery fallout * bug fix for empty modifier shop * stash working changes * stash changes * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/battle-anims.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * nit updates and cleanup * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * add jsdocs and more cleanup * add more jsdoc * add the strong stuff encounter * add the strong stuff encounter and more unit tests * cleanup container length checks in ME ui * add retries to tests * add retries to tests * fix trainer wave disable override * add shuckle juice modifier * add dialogue bug fixes * add dialogue bug fixes * add pokemon salesman encounter and affects pokedex UI display * add unit tests for pokemon salesman * temp stash * add offer you can't refuse * add unit tests for offer you can't refuse encounter * remove unnecessary prompt handlers * add tests for disabled encounter options * add delibird-y encounter * add delibird-y encounter * add absolute avarice encounter * finish absolute avarice encounter * add unit tests and enhancements for item overrides in tests * fix unit test * cleanup absolute avarice PR * small bug fixes with latest sync from main * update visuals loading for safari and stat trainer visuals * update visuals loading for safari and stat trainer visuals * update a trainer's test encounter and add unit tests * add Trash to Treasure encounter * clean up trash to treasure encounter * clean up trash to treasure encounter * add berries abound encounter * start clowning around encounter * first implementation pass at clowning around * add unit tests for clowning around * add unit tests for clowning around * clean up ME unit tests * clean up unit tests * update unit tests * add part timer and dancing lessons encounters * add unit tests for Dancing Lessons and Part-Timer * reordered biome list and adjusted redirection for project and labels * Add Weird Dream encounter and slight reworks to Berries Abound/Fight or Flight * adjusting yml to match new labels * fix yml whoopsie * Expanded 'Weird Dream' banlist and fixed a bug with the BST bump range * adds Winstrate Challenge mystery encounter * small cleanup for winstrates * add unit tests for Winstrate Challenge * fix pokemon not returning after winstrate battle * commit latest beta merge updates * fix ME null checks and unit tests with beta update * fix ME null checks and unit tests with beta update * MEs to pokerogue beta branch * test dialogue changes * test patch fix * test patch fix * test patch fix * adds teleporting hijinks encounter * add unit tests for Teleporting Hijinks * small change to teleporting hijinks dialogue * migrate ME translations to json * add retries to berries-abound.Option1: should reward the player with X berries based on wave * add missing ME dialogue back in * revert template changes * add ME unique trainer dialogue to both dialogue jsons * fix hanging comma in json * fix broken imports * resolve lint issues * fix flaky test * balance tweaks to a few MEs, updates to bug superfan * add unit tests for Bug-Type Superfan and clean up dialogue * Adds Fun and Games mystery encounter * add unit tests for Fun and Games encounter * update jsdoc * small ME balance changes * small ME balance changes * Adds Uncommon Breed ME and misc. ME bug fixes * Update getFinalSessionData() to collect Mystery Encounter data * adds GTS encounter * various ME bug fixes and balance changes * latest ME bug fixes * clean up GTS Encounter and add unit tests * small cleanup to MEs branch * add BGM music names for ME music * bug fixes and balance changes for MEs * ME data schema updates * balance changes and bug fixes to MEs * balance changes and bug fixes to MEs * update tests for MEs * add jsdoc to party exp function * dialogue updates and test fixes for MEs * dialogue updates and test fixes for MEs * PR suggestions and fixees * stash PR feedback and bugfixes * fix all tests for MEs and cleanup * PR feedback * update flaky ME test * update tests, bug fix MEs, and sprite assets * remove unintentional console log * re-enable stubbed function for Phaser text styling * handle undefined introVisuals properly * PR feedback from NightKev * disable Uncommon Breed tests * locales updates and bug fixes for safari zone * more PR feedback and update field trip with Rarer Candy * fix unit test * Change how reroll button gets disabled in Modifier Shop Phase * update continue button text logic * Update src/ui/modifier-select-ui-handler.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * fix money formatting and some nits * more nits * more nits * update ME tsdocs with links * update ME tsdocs with links --------- Co-authored-by: Felix Staud <felix.staud@headwire.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com> Co-authored-by: InnocentGameDev <asdargmng@gmail.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com>
2024-09-13 22:05:58 -04:00
} else {
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
[Feature] Add Mystery Encounters to the game (#3938) * add .github/workflows/mystery-event.yml * update mystery-event.yml * mystery encounters: resolve review comments: Lost at Sea: -fix typo in handlePokemonGuidingYouPhase function Mysterious Chest: - remove obsolete commented code mystery-encounter.ts - remove unused `onDone` field from MysteryEncounterBuilder * fix typo in CanLearnMoveRequirementOptions * remove redundance from Pokemon.isAllowedInBattle() * chore: jsdoc formatting * fix lost-at-sea tests * add fallback for biomeMysteryEncounters if empty * lost-at-sea-encounter: fix and extend tests * move "battle:fainted" into `koPlayerPokemon` * add retries to quick-draw tests * fix lost-at-sea-encounter tests * clean up battle animation logic * Update and rename mystery-event.yml to mystery-events.yml * Update mystery-events.yml * Fix typo * Update mystery-events.yml Fix debug runs * clean up unit tests and utils * attach github issues to all encounter jsdocs * start dialogue refactor * update sleeping snorlax encounter * migrate encounters dialogue to new format * cleanup and add jsdocs * finish fiery fallout encounter * fix unit test breaks * add skeleton tests to fiery fallout * commit latest test changes * finish unit tests for fiery fallout * bug fix for empty modifier shop * stash working changes * stash changes * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/test/utils/overridesHelper.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update src/data/battle-anims.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * nit updates and cleanup * Update src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * add jsdocs and more cleanup * add more jsdoc * add the strong stuff encounter * add the strong stuff encounter and more unit tests * cleanup container length checks in ME ui * add retries to tests * add retries to tests * fix trainer wave disable override * add shuckle juice modifier * add dialogue bug fixes * add dialogue bug fixes * add pokemon salesman encounter and affects pokedex UI display * add unit tests for pokemon salesman * temp stash * add offer you can't refuse * add unit tests for offer you can't refuse encounter * remove unnecessary prompt handlers * add tests for disabled encounter options * add delibird-y encounter * add delibird-y encounter * add absolute avarice encounter * finish absolute avarice encounter * add unit tests and enhancements for item overrides in tests * fix unit test * cleanup absolute avarice PR * small bug fixes with latest sync from main * update visuals loading for safari and stat trainer visuals * update visuals loading for safari and stat trainer visuals * update a trainer's test encounter and add unit tests * add Trash to Treasure encounter * clean up trash to treasure encounter * clean up trash to treasure encounter * add berries abound encounter * start clowning around encounter * first implementation pass at clowning around * add unit tests for clowning around * add unit tests for clowning around * clean up ME unit tests * clean up unit tests * update unit tests * add part timer and dancing lessons encounters * add unit tests for Dancing Lessons and Part-Timer * reordered biome list and adjusted redirection for project and labels * Add Weird Dream encounter and slight reworks to Berries Abound/Fight or Flight * adjusting yml to match new labels * fix yml whoopsie * Expanded 'Weird Dream' banlist and fixed a bug with the BST bump range * adds Winstrate Challenge mystery encounter * small cleanup for winstrates * add unit tests for Winstrate Challenge * fix pokemon not returning after winstrate battle * commit latest beta merge updates * fix ME null checks and unit tests with beta update * fix ME null checks and unit tests with beta update * MEs to pokerogue beta branch * test dialogue changes * test patch fix * test patch fix * test patch fix * adds teleporting hijinks encounter * add unit tests for Teleporting Hijinks * small change to teleporting hijinks dialogue * migrate ME translations to json * add retries to berries-abound.Option1: should reward the player with X berries based on wave * add missing ME dialogue back in * revert template changes * add ME unique trainer dialogue to both dialogue jsons * fix hanging comma in json * fix broken imports * resolve lint issues * fix flaky test * balance tweaks to a few MEs, updates to bug superfan * add unit tests for Bug-Type Superfan and clean up dialogue * Adds Fun and Games mystery encounter * add unit tests for Fun and Games encounter * update jsdoc * small ME balance changes * small ME balance changes * Adds Uncommon Breed ME and misc. ME bug fixes * Update getFinalSessionData() to collect Mystery Encounter data * adds GTS encounter * various ME bug fixes and balance changes * latest ME bug fixes * clean up GTS Encounter and add unit tests * small cleanup to MEs branch * add BGM music names for ME music * bug fixes and balance changes for MEs * ME data schema updates * balance changes and bug fixes to MEs * balance changes and bug fixes to MEs * update tests for MEs * add jsdoc to party exp function * dialogue updates and test fixes for MEs * dialogue updates and test fixes for MEs * PR suggestions and fixees * stash PR feedback and bugfixes * fix all tests for MEs and cleanup * PR feedback * update flaky ME test * update tests, bug fix MEs, and sprite assets * remove unintentional console log * re-enable stubbed function for Phaser text styling * handle undefined introVisuals properly * PR feedback from NightKev * disable Uncommon Breed tests * locales updates and bug fixes for safari zone * more PR feedback and update field trip with Rarer Candy * fix unit test * Change how reroll button gets disabled in Modifier Shop Phase * update continue button text logic * Update src/ui/modifier-select-ui-handler.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * fix money formatting and some nits * more nits * more nits * update ME tsdocs with links * update ME tsdocs with links --------- Co-authored-by: Felix Staud <felix.staud@headwire.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com> Co-authored-by: InnocentGameDev <asdargmng@gmail.com> Co-authored-by: Mumble <171087428+frutescens@users.noreply.github.com>
2024-09-13 22:05:58 -04:00
}
2024-08-19 03:23:52 +01:00
}
}
handleCommand(command: Command, cursor: integer, ...args: any[]): boolean {
const playerPokemon = globalScene.getPlayerField()[this.fieldIndex];
let success: boolean = false;
2024-08-19 03:23:52 +01:00
switch (command) {
case Command.FIGHT:
let useStruggle = false;
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
const turnMove: TurnMove | undefined = (args.length === 2 ? (args[1] as TurnMove) : undefined);
if (cursor === -1 ||
2024-08-19 03:23:52 +01:00
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) {
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
let moveId: Moves;
if (useStruggle) {
moveId = Moves.STRUGGLE;
} else if (turnMove !== undefined) {
moveId = turnMove.move;
} else if (cursor > -1) {
moveId = playerPokemon.getMoveset()[cursor]!.moveId;
} else {
moveId = Moves.NONE;
}
const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args };
[Bug][Move] Refactor moves that call a random move (#3380) * Combine moveset from allies and uses it to get a move * Clearer implementation of combining user and teammates' moves * Refactor assist and sleep talk to use metronome's attribute for calling a move * Refactor move filtering in RandomMovesetMoveAttr, creates arrays with invalid moves for assist/sleep talk * Refactor RandomMoveAttr to set moveId in condition, places reused code in callMove in RandomMoveAttr * Correct invalid move lists, adds Max/Z moves to metronome's list * Remove ignoresVirtual from beta merge * Remove Max/Z moves per frutescens' comment * Fix bug with metronome/copycat/assist/sleep talk targeting ally * Experimental async/await to be tested * Refactor other attributes to extend CallMoveAttr * Replace QueuedMove with TurnMove, refactor to attempt two-turn move fix for metronome * Fix Swallow test due to TurnMove refactor * Further fixes for TurnMove refactor * Fix metronome two turn moves for enemy pokemon * Replace nested ternary with if-else block per DayKev's comment * Minor fixes * Adjust command phase args handling * Create metronome test, refactor RandomMoveAttr for easier testing * Add unit test for recharge moves * Refactor Copycat and Mirror Move, adjust move targeting * Add unit test for ally targeting with Aromatic Mist * Add tests for secondary effects and recharge moves for metronome * Add test for Roar, remove test for Acupressure * Create test for Assist * Add test for assist failing * Add sleep talk unit test coverage * Adjust move-phase to better track last move for copycat, write and update unit tests for assist/copycat * Create moveHistory in Battle to track all moves used, adjust mirror move to use this, writes unit tests * Correct mirror move implementation, rewrite unit test to adjust * Add docs to attrs, update assist to only grab allies sets * Update assist unit test to match expected functionality * Update metronome unit test to use getMoveOverride * Update copycat unit test to use metronome getMoveOverride mock * Fix phase interception * Add docs from missed conversations * Update assist tests to use manual moveset overrides Minor fixes to other tests * Remove `export` from `CallMoveAttr` * Add missing `.unimplemented()` to some Max- and Z-Moves --------- Co-authored-by: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-01-14 18:26:35 -05:00
const moveTargets: MoveTargetSet = turnMove === undefined ? getMoveTargets(playerPokemon, moveId) : { targets: turnMove.targets, multiple: turnMove.targets.length > 1 };
if (!moveId) {
turnCommand.targets = [ this.fieldIndex ];
}
console.log(moveTargets, getPokemonNameWithAffix(playerPokemon));
if (moveTargets.targets.length > 1 && moveTargets.multiple) {
globalScene.unshiftPhase(new SelectTargetPhase(this.fieldIndex));
}
if (moveTargets.targets.length <= 1 || moveTargets.multiple) {
2024-08-19 03:23:52 +01:00
turnCommand.move!.targets = moveTargets.targets; //TODO: is the bang correct here?
} else if (playerPokemon.getTag(BattlerTagType.CHARGING) && playerPokemon.getMoveQueue().length >= 1) {
2024-08-19 03:23:52 +01:00
turnCommand.move!.targets = playerPokemon.getMoveQueue()[0].targets; //TODO: is the bang correct here?
} else {
globalScene.unshiftPhase(new SelectTargetPhase(this.fieldIndex));
}
globalScene.currentBattle.turnCommands[this.fieldIndex] = turnCommand;
success = true;
} else if (cursor < playerPokemon.getMoveset().length) {
const move = playerPokemon.getMoveset()[cursor]!; //TODO: is this bang correct?
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] Use BattlerTag for move-disabling effects (#2051) * Use BattlerTag for move-disabling effects * Fix RUN command causing freeze * Improve documentation * Clean up and document PokemonMove.isUsable * Fix isMoveDisabled missing return * Tags define the message shown when disabling interrupts a move * Fix -1 duration on Disable effect * Add tests for Disable * En loc and fix message functions * Fix Disable test * Fix broken imports * Fix test * All disable tests passing * Localize remaining strings * Move cancellation logic out of lapse; use use TURN_END for lapse type * Prevent disabling STRUGGLE * Inline struggle check function * Restore RechargingTag docs * Move cancellation logic back to tag Wanted to increase similarity to the existing code base to avoid that stupid hyper beam error but it's still happening here * Fix hyper beam test * Remove erroneous shit * Fill movesets with SPLASH for disable test * More robust condition for disable checking * Remove DisabledTag lapse * Simplify DisablingBattlerTag lapse * Cancel disable-interrupted moves instead of failing them * Avoid disabling virtual moves * Consistent access modifiers across Disable tags * Add abstract function for message when player tries to select the disabled move * Fix syntax mistake * Always disable last-used non-virtual move * Overhaul tests + add tests * Implement loadTag for DisabledTag * Update translations * Update translations * Reimplement phase changes * fix battlertag strings * Fix disable test not running * Update name of base class * Rename "disabling" to "restriction" * Fix sneaky string fuckup * Fix test failure * fix merge problems * fix merge problems * Update tests * rerun RNG test * Properly mock stats in test * Document everything in battlertag * More docs + typo fix * Update tests --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2024-09-05 04:44:22 -04:00
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator
2024-08-19 03:23:52 +01:00
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 )) {
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);
} 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.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);
2024-08-19 03:23:52 +01:00
}, null, true);
} else {
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);
2024-08-19 03:23:52 +01:00
}, 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]!.targets = targets;
2024-08-19 03:23:52 +01:00
if (this.fieldIndex) {
globalScene.currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true;
2024-08-19 03:23:52 +01:00
}
success = true;
}
2024-08-19 03:23:52 +01:00
}
}
break;
case Command.POKEMON:
case Command.RUN:
const isSwitch = command === Command.POKEMON;
const { currentBattle, arena } = globalScene;
const mysteryEncounterFleeAllowed = currentBattle.mysteryEncounter?.fleeAllowed;
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.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);
} else {
const batonPass = isSwitch && args[0] as boolean;
const trappedAbMessages: string[] = [];
if (batonPass || !playerPokemon.isTrapped(trappedAbMessages)) {
currentBattle.turnCommands[this.fieldIndex] = isSwitch
2024-08-19 03:23:52 +01:00
? { command: Command.POKEMON, cursor: cursor, args: args }
: { command: Command.RUN };
success = true;
if (!isSwitch && this.fieldIndex) {
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);
2024-08-19 03:23:52 +01:00
if (!isSwitch) {
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
2024-08-19 03:23:52 +01:00
}
}, null, true);
} else {
const trapTag = playerPokemon.getTag(TrappedTag);
const fairyLockTag = globalScene.arena.getTagOnSide(ArenaTagType.FAIRY_LOCK, ArenaTagSide.PLAYER);
if (!trapTag && !fairyLockTag) {
i18next.t(`battle:noEscape${isSwitch ? "Switch" : "Flee"}`);
break;
}
if (!isSwitch) {
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
globalScene.ui.setMode(Mode.MESSAGE);
}
const showNoEscapeText = (tag: any) => {
globalScene.ui.showText(
i18next.t("battle:noEscapePokemon", {
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")
}),
null,
() => {
globalScene.ui.showText("", 0);
if (!isSwitch) {
globalScene.ui.setMode(Mode.COMMAND, this.fieldIndex);
}
},
null,
true
);
};
if (trapTag) {
showNoEscapeText(trapTag);
} else if (fairyLockTag) {
showNoEscapeText(fairyLockTag);
}
}
2024-08-19 03:23:52 +01:00
}
break;
2024-08-19 03:23:52 +01:00
}
if (success) {
2024-08-19 03:23:52 +01:00
this.end();
}
return success;
2024-08-19 03:23:52 +01:00
}
cancel() {
if (this.fieldIndex) {
globalScene.unshiftPhase(new CommandPhase(0));
globalScene.unshiftPhase(new CommandPhase(1));
2024-08-19 03:23:52 +01:00
this.end();
}
}
getFieldIndex(): integer {
return this.fieldIndex;
}
getPokemon(): PlayerPokemon {
return globalScene.getPlayerField()[this.fieldIndex];
2024-08-19 03:23:52 +01:00
}
end() {
globalScene.ui.setMode(Mode.MESSAGE).then(() => super.end());
2024-08-19 03:23:52 +01:00
}
}