mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 22:39:31 +02:00
Converted EncoreTag into a MoveRestrictionBattlerTag
This commit is contained in:
parent
9dae28f264
commit
36eb88bac6
@ -909,7 +909,7 @@ export class FrenzyTag extends BattlerTag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EncoreTag extends BattlerTag {
|
export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||||
public moveId: Moves;
|
public moveId: Moves;
|
||||||
|
|
||||||
constructor(sourceId: number) {
|
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 {
|
onRemove(pokemon: Pokemon): void {
|
||||||
super.onRemove(pokemon);
|
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 {
|
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 });
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import BattleScene from "#app/battle-scene";
|
import BattleScene from "#app/battle-scene";
|
||||||
import { TurnCommand, BattleType } from "#app/battle";
|
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 { MoveTargetSet, getMoveTargets } from "#app/data/move";
|
||||||
import { speciesStarterCosts } from "#app/data/balance/starters";
|
import { speciesStarterCosts } from "#app/data/balance/starters";
|
||||||
import { Abilities } from "#app/enums/abilities";
|
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 {
|
getFieldIndex(): integer {
|
||||||
return this.fieldIndex;
|
return this.fieldIndex;
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,6 @@ export default class CommandUiHandler extends UiHandler {
|
|||||||
switch (cursor) {
|
switch (cursor) {
|
||||||
// Fight
|
// Fight
|
||||||
case Command.FIGHT:
|
case Command.FIGHT:
|
||||||
if ((this.scene.getCurrentPhase() as CommandPhase).checkFightOverride()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user