diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ebbab7bfa4a..d2290fd92a3 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -909,7 +909,7 @@ export class FrenzyTag extends BattlerTag { } } -export class EncoreTag extends BattlerTag { +export class EncoreTag extends MoveRestrictionBattlerTag { public moveId: Moves; constructor(sourceId: number) { @@ -969,6 +969,17 @@ export class EncoreTag extends BattlerTag { } } + public isMoveRestricted(move: Moves, user?: Pokemon): boolean { + if (move !== this.moveId) { + return true; + } + return false; + } + + selectionDeniedText(pokemon: Pokemon, move: Moves): string { + return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name }); + } + onRemove(pokemon: Pokemon): void { super.onRemove(pokemon); @@ -2360,7 +2371,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag { } /** - * Uses DisabledTag's selectionDeniedText() message + * 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 }); diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 547805ec1d1..737a56ba48f 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -1,6 +1,6 @@ import BattleScene from "#app/battle-scene"; import { TurnCommand, BattleType } from "#app/battle"; -import { TrappedTag, EncoreTag } from "#app/data/battler-tags"; +import { TrappedTag } from "#app/data/battler-tags"; import { MoveTargetSet, getMoveTargets } from "#app/data/move"; import { speciesStarterCosts } from "#app/data/balance/starters"; import { Abilities } from "#app/enums/abilities"; @@ -291,26 +291,6 @@ export class CommandPhase extends FieldPhase { } } - checkFightOverride(): boolean { - const pokemon = this.getPokemon(); - - const encoreTag = pokemon.getTag(EncoreTag) as EncoreTag; - - if (!encoreTag) { - return false; - } - - const moveIndex = pokemon.getMoveset().findIndex(m => m?.moveId === encoreTag.moveId); - - if (moveIndex === -1 || !pokemon.getMoveset()[moveIndex]!.isUsable(pokemon)) { // TODO: is this bang correct? - return false; - } - - this.handleCommand(Command.FIGHT, moveIndex, false); - - return true; - } - getFieldIndex(): integer { return this.fieldIndex; } diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index 0f5edc28675..0dacacc7b70 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -90,9 +90,6 @@ export default class CommandUiHandler extends UiHandler { switch (cursor) { // Fight case Command.FIGHT: - if ((this.scene.getCurrentPhase() as CommandPhase).checkFightOverride()) { - return true; - } ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); success = true; break;