From 2b4dc9a4f05a872330a4a82f4c02794b426d3ac3 Mon Sep 17 00:00:00 2001 From: Benjamin Odom Date: Sun, 5 May 2024 23:02:52 -0500 Subject: [PATCH] Fixes Struggle Softlock (#531) * Fixes Struggle Softlock Fixed an issue where moves marked as (N) would prevent you from being able to Struggle. Also fixes messaging so that a message shows when you are out of PP, Disabled, or trying to use an unimplemented move consistently. * Update phases.ts --- src/field/pokemon.ts | 2 +- src/locales/de/battle.ts | 1 + src/locales/en/battle.ts | 1 + src/locales/es/battle.ts | 1 + src/locales/fr/battle.ts | 1 + src/locales/it/battle.ts | 1 + src/phases.ts | 38 ++++++++++++++++++-------------------- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index b20096513..1237f7bb5 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3172,7 +3172,7 @@ export class PokemonMove { isUsable(pokemon: Pokemon, ignorePp?: boolean): boolean { if (this.moveId && pokemon.summonData?.disabledMove === this.moveId) return false; - return ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1; + return (ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1) && !this.getMove().name.endsWith(' (N)'); } getMove(): Move { diff --git a/src/locales/de/battle.ts b/src/locales/de/battle.ts index 61191a116..b48aa1129 100644 --- a/src/locales/de/battle.ts +++ b/src/locales/de/battle.ts @@ -33,6 +33,7 @@ export const battle: SimpleTranslationEntries = { "learnMoveForgetSuccess": "{{pokemonName}} forgot how to\nuse {{moveName}}.", "levelCapUp": "Das Levellimit\nhat sich zu {{levelCap}} erhöht!", "moveNotImplemented": "{{moveName}} ist noch nicht implementiert und kann nicht ausgewählt werden.", + "moveNoPP": "There's no PP left for\nthis move!", "moveDisabled": "{{moveName}} ist deaktiviert!", "noPokeballForce": "Eine unsichtbare Kraft\nverhindert die Nutzung von Pokébällen.", "noPokeballTrainer": "Du kannst das Pokémon\neines anderen Trainers nicht fangen!", diff --git a/src/locales/en/battle.ts b/src/locales/en/battle.ts index 599672a1b..e307a3a52 100644 --- a/src/locales/en/battle.ts +++ b/src/locales/en/battle.ts @@ -33,6 +33,7 @@ export const battle: SimpleTranslationEntries = { "learnMoveForgetSuccess": "{{pokemonName}} forgot how to\nuse {{moveName}}.", "levelCapUp": "The level cap\nhas increased to {{levelCap}}!", "moveNotImplemented": "{{moveName}} is not yet implemented and cannot be selected.", + "moveNoPP": "There's no PP left for\nthis move!", "moveDisabled": "{{moveName}} is disabled!", "noPokeballForce": "An unseen force\nprevents using Poké Balls.", "noPokeballTrainer": "You can't catch\nanother trainer's Pokémon!", diff --git a/src/locales/es/battle.ts b/src/locales/es/battle.ts index 2d7087d6c..f4bf22bb9 100644 --- a/src/locales/es/battle.ts +++ b/src/locales/es/battle.ts @@ -33,6 +33,7 @@ export const battle: SimpleTranslationEntries = { "learnMoveForgetSuccess": "{{pokemonName}} ha olvidado cómo utilizar {{moveName}}.", "levelCapUp": "¡Se ha incrementado el\nnivel máximo a {{levelCap}}!", "moveNotImplemented": "{{moveName}} aún no está implementado y no se puede seleccionar.", + "moveNoPP": "There's no PP left for\nthis move!", "moveDisabled": "!No puede usar {{moveName}} porque ha sido anulado!", "noPokeballForce": "Una fuerza misteriosa\nte impide usar Poké Balls.", "noPokeballTrainer": "¡No puedes atrapar a los\nPokémon de los demás!", diff --git a/src/locales/fr/battle.ts b/src/locales/fr/battle.ts index a4abf5239..2167ddd31 100644 --- a/src/locales/fr/battle.ts +++ b/src/locales/fr/battle.ts @@ -33,6 +33,7 @@ export const battle: SimpleTranslationEntries = { "learnMoveForgetSuccess": "{{pokemonName}} oublie comment\nutiliser {{moveName}}.", "levelCapUp": "La limite de niveau\na été augmentée à {{levelCap}} !", "moveNotImplemented": "{{moveName}} n’est pas encore implémenté et ne peut pas être sélectionné.", + "moveNoPP": "There's no PP left for\nthis move!", "moveDisabled": "{{moveName}} est sous entrave !", "noPokeballForce": "Une force mystérieuse\nempêche l’utilisation des Poké Balls.", "noPokeballTrainer": "Le Dresseur détourne la Ball\nVoler, c’est mal !", diff --git a/src/locales/it/battle.ts b/src/locales/it/battle.ts index 52a4ee66c..4b0afae12 100644 --- a/src/locales/it/battle.ts +++ b/src/locales/it/battle.ts @@ -33,6 +33,7 @@ export const battle: SimpleTranslationEntries = { "learnMoveForgetSuccess": "{{pokemonName}} ha dimenticato la mossa\n{{moveName}}.", "levelCapUp": "Il livello massimo\nè aumentato a {{levelCap}}!", "moveNotImplemented": "{{moveName}} non è ancora implementata e non può essere selezionata.", + "moveNoPP": "There's no PP left for\nthis move!", "moveDisabled": "{{moveName}} è disabilitata!", "noPokeballForce": "Una forza misteriosa\nimpedisce l'uso dell Poké Ball.", "noPokeballTrainer": "Non puoi catturare\nPokémon di altri allenatori!", diff --git a/src/phases.ts b/src/phases.ts index 751cac166..fc6af354a 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1680,21 +1680,13 @@ export class CommandPhase extends FieldPhase { switch (command) { case Command.FIGHT: let useStruggle = false; - if (cursor === -1 || playerPokemon.trySelectMove(cursor, args[0] as boolean) || (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)) { + if (cursor === -1 || + playerPokemon.trySelectMove(cursor, args[0] as boolean) || + (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)) { const moveId = !useStruggle ? cursor > -1 ? playerPokemon.getMoveset()[cursor].moveId : Moves.NONE : Moves.STRUGGLE; const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args }; const moveTargets: MoveTargetSet = args.length < 3 ? getMoveTargets(playerPokemon, moveId) : args[2]; - if (moveId) { - const move = playerPokemon.getMoveset()[cursor]; - if (move.getName().endsWith(' (N)')) { - this.scene.ui.setMode(Mode.MESSAGE); - this.scene.ui.showText(i18next.t('battle:moveNotImplemented', { moveName: move.getName().slice(0, -4) }), null, () => { - this.scene.ui.clearText(); - this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex); - }, null, true); - return; - } - } else + if (!moveId) turnCommand.targets = [ this.fieldIndex ]; console.log(moveTargets, playerPokemon.name); if (moveTargets.targets.length <= 1 || moveTargets.multiple) @@ -1705,15 +1697,21 @@ export class CommandPhase extends FieldPhase { this.scene.unshiftPhase(new SelectTargetPhase(this.scene, this.fieldIndex)); this.scene.currentBattle.turnCommands[this.fieldIndex] = turnCommand; success = true; - } else if (cursor < playerPokemon.getMoveset().length) { + } + else if (cursor < playerPokemon.getMoveset().length) { const move = playerPokemon.getMoveset()[cursor]; - if (playerPokemon.summonData.disabledMove === move.moveId) { - this.scene.ui.setMode(Mode.MESSAGE); - this.scene.ui.showText(i18next.t('battle:moveDisabled', { moveName: move.getName() }), null, () => { - this.scene.ui.clearText(); - this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex); - }, null, true); - } + this.scene.ui.setMode(Mode.MESSAGE); + + // Decides between a Disabled, Not Implemented, or No PP translation message + const errorMessage = + playerPokemon.summonData.disabledMove === move.moveId ? 'battle:moveDisabled' : + move.getName().endsWith(' (N)') ? 'battle:moveNotImplemented' : 'battle:moveNoPP'; + const moveName = move.getName().replace(' (N)', ''); // Trims off the indicator + + this.scene.ui.showText(i18next.t(errorMessage, { moveName: moveName }), null, () => { + this.scene.ui.clearText(); + this.scene.ui.setMode(Mode.FIGHT, this.fieldIndex); + }, null, true); } break; case Command.BALL: