[Bug] Move Restriction Battler Tag bugs (#4536)
* Added fixes
* Revert "Added fixes"
This reverts commit 3feccd792d
.
* Added loadTag functions
* Fixes
* typeodcs
* Torment
* yawn
* hsldklahdlhalhdlahldhlah
* Imprison Fixes
* Fixed imprison not interrupting PRE_MOVE
* just kidding
* Apply suggestions from code review
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Fixing what broke
* added scp[es
* missed a scope
* Update src/data/battler-tags.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* good tp go
* merge
* battler tags
* Apply suggestions from code review
* Changed function names
* publics
---------
Co-authored-by: frutescens <info@laptop>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
470f9e4e19
commit
8a355d500a
|
@ -4,7 +4,7 @@ import { Type } from "#app/data/type";
|
||||||
import * as Utils from "#app/utils";
|
import * as Utils from "#app/utils";
|
||||||
import { MoveCategory, allMoves, MoveTarget, IncrementMovePriorityAttr, applyMoveAttrs } from "#app/data/move";
|
import { MoveCategory, allMoves, MoveTarget, IncrementMovePriorityAttr, applyMoveAttrs } from "#app/data/move";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import Pokemon, { HitResult, PlayerPokemon, PokemonMove, EnemyPokemon } from "#app/field/pokemon";
|
import Pokemon, { HitResult, PokemonMove } from "#app/field/pokemon";
|
||||||
import { StatusEffect } from "#app/data/status-effect";
|
import { StatusEffect } from "#app/data/status-effect";
|
||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { BlockNonDirectDamageAbAttr, ChangeMovePriorityAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
|
import { BlockNonDirectDamageAbAttr, ChangeMovePriorityAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
|
||||||
|
@ -71,6 +71,32 @@ export abstract class ArenaTag {
|
||||||
this.sourceId = source.sourceId;
|
this.sourceId = source.sourceId;
|
||||||
this.side = source.side;
|
this.side = source.side;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that retrieves the source Pokemon
|
||||||
|
* @param scene medium to retrieve the source Pokemon
|
||||||
|
* @returns The source {@linkcode Pokemon} or `null` if none is found
|
||||||
|
*/
|
||||||
|
public getSourcePokemon(scene: BattleScene): Pokemon | null {
|
||||||
|
return this.sourceId ? scene.getPokemonById(this.sourceId) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that retrieves the Pokemon affected
|
||||||
|
* @param scene - medium to retrieve the involved Pokemon
|
||||||
|
* @returns list of PlayerPokemon or EnemyPokemon on the field
|
||||||
|
*/
|
||||||
|
public getAffectedPokemon(scene: BattleScene): Pokemon[] {
|
||||||
|
switch (this.side) {
|
||||||
|
case ArenaTagSide.PLAYER:
|
||||||
|
return scene.getPlayerField() ?? [];
|
||||||
|
case ArenaTagSide.ENEMY:
|
||||||
|
return scene.getEnemyField() ?? [];
|
||||||
|
case ArenaTagSide.BOTH:
|
||||||
|
default:
|
||||||
|
return scene.getField(true) ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -978,36 +1004,24 @@ class NoneTag extends ArenaTag {
|
||||||
* Imprison will apply to any opposing Pokemon that switch onto the field as well.
|
* Imprison will apply to any opposing Pokemon that switch onto the field as well.
|
||||||
*/
|
*/
|
||||||
class ImprisonTag extends ArenaTrapTag {
|
class ImprisonTag extends ArenaTrapTag {
|
||||||
private source: Pokemon;
|
|
||||||
|
|
||||||
constructor(sourceId: number, side: ArenaTagSide) {
|
constructor(sourceId: number, side: ArenaTagSide) {
|
||||||
super(ArenaTagType.IMPRISON, Moves.IMPRISON, sourceId, side, 1);
|
super(ArenaTagType.IMPRISON, Moves.IMPRISON, sourceId, side, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function that retrieves the Pokemon affected
|
|
||||||
* @param {BattleScene} scene medium to retrieve the involved Pokemon
|
|
||||||
* @returns list of PlayerPokemon or EnemyPokemon on the field
|
|
||||||
*/
|
|
||||||
private retrieveField(scene: BattleScene): PlayerPokemon[] | EnemyPokemon[] {
|
|
||||||
if (!this.source.isPlayer()) {
|
|
||||||
return scene.getPlayerField() ?? [];
|
|
||||||
}
|
|
||||||
return scene.getEnemyField() ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function applies the effects of Imprison to the opposing Pokemon already present on the field.
|
* This function applies the effects of Imprison to the opposing Pokemon already present on the field.
|
||||||
* @param arena
|
* @param arena
|
||||||
*/
|
*/
|
||||||
override onAdd({ scene }: Arena) {
|
override onAdd({ scene }: Arena) {
|
||||||
this.source = scene.getPokemonById(this.sourceId!)!;
|
const source = this.getSourcePokemon(scene);
|
||||||
if (this.source) {
|
if (source) {
|
||||||
const party = this.retrieveField(scene);
|
const party = this.getAffectedPokemon(scene);
|
||||||
party?.forEach((p: PlayerPokemon | EnemyPokemon ) => {
|
party?.forEach((p: Pokemon ) => {
|
||||||
p.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId);
|
if (p.isAllowedInBattle()) {
|
||||||
|
p.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
scene.queueMessage(i18next.t("battlerTags:imprisonOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(this.source) }));
|
scene.queueMessage(i18next.t("battlerTags:imprisonOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(source) }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,8 +1030,9 @@ class ImprisonTag extends ArenaTrapTag {
|
||||||
* @param _arena
|
* @param _arena
|
||||||
* @returns `true` if the source of the tag is still active on the field | `false` if not
|
* @returns `true` if the source of the tag is still active on the field | `false` if not
|
||||||
*/
|
*/
|
||||||
override lapse(_arena: Arena): boolean {
|
override lapse({ scene }: Arena): boolean {
|
||||||
return this.source.isActive(true);
|
const source = this.getSourcePokemon(scene);
|
||||||
|
return source ? source.isActive(true) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1026,7 +1041,8 @@ class ImprisonTag extends ArenaTrapTag {
|
||||||
* @returns `true`
|
* @returns `true`
|
||||||
*/
|
*/
|
||||||
override activateTrap(pokemon: Pokemon): boolean {
|
override activateTrap(pokemon: Pokemon): boolean {
|
||||||
if (this.source.isActive(true)) {
|
const source = this.getSourcePokemon(pokemon.scene);
|
||||||
|
if (source && source.isActive(true) && pokemon.isAllowedInBattle()) {
|
||||||
pokemon.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId);
|
pokemon.addTag(BattlerTagType.IMPRISON, 1, Moves.IMPRISON, this.sourceId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1037,8 +1053,8 @@ class ImprisonTag extends ArenaTrapTag {
|
||||||
* @param arena
|
* @param arena
|
||||||
*/
|
*/
|
||||||
override onRemove({ scene }: Arena): void {
|
override onRemove({ scene }: Arena): void {
|
||||||
const party = this.retrieveField(scene);
|
const party = this.getAffectedPokemon(scene);
|
||||||
party?.forEach((p: PlayerPokemon | EnemyPokemon) => {
|
party?.forEach((p: Pokemon) => {
|
||||||
p.removeTag(BattlerTagType.IMPRISON);
|
p.removeTag(BattlerTagType.IMPRISON);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
||||||
import { ShowAbilityPhase } from "#app/phases/show-ability-phase";
|
import { ShowAbilityPhase } from "#app/phases/show-ability-phase";
|
||||||
import { StatStageChangePhase, StatStageChangeCallback } from "#app/phases/stat-stage-change-phase";
|
import { StatStageChangePhase, StatStageChangeCallback } from "#app/phases/stat-stage-change-phase";
|
||||||
import { PokemonAnimType } from "#app/enums/pokemon-anim-type";
|
import { PokemonAnimType } from "#app/enums/pokemon-anim-type";
|
||||||
|
import BattleScene from "#app/battle-scene";
|
||||||
|
|
||||||
export enum BattlerTagLapseType {
|
export enum BattlerTagLapseType {
|
||||||
FAINT,
|
FAINT,
|
||||||
|
@ -90,6 +91,15 @@ export class BattlerTag {
|
||||||
this.sourceMove = source.sourceMove;
|
this.sourceMove = source.sourceMove;
|
||||||
this.sourceId = source.sourceId;
|
this.sourceId = source.sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that retrieves the source Pokemon object
|
||||||
|
* @param scene medium to retrieve the source Pokemon
|
||||||
|
* @returns The source {@linkcode Pokemon} or `null` if none is found
|
||||||
|
*/
|
||||||
|
public getSourcePokemon(scene: BattleScene): Pokemon | null {
|
||||||
|
return this.sourceId ? scene.getPokemonById(this.sourceId) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WeatherBattlerTag {
|
export interface WeatherBattlerTag {
|
||||||
|
@ -120,7 +130,7 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag {
|
||||||
const phase = pokemon.scene.getCurrentPhase() as MovePhase;
|
const phase = pokemon.scene.getCurrentPhase() as MovePhase;
|
||||||
const move = phase.move;
|
const move = phase.move;
|
||||||
|
|
||||||
if (this.isMoveRestricted(move.moveId)) {
|
if (this.isMoveRestricted(move.moveId, pokemon)) {
|
||||||
if (this.interruptedText(pokemon, move.moveId)) {
|
if (this.interruptedText(pokemon, move.moveId)) {
|
||||||
pokemon.scene.queueMessage(this.interruptedText(pokemon, move.moveId));
|
pokemon.scene.queueMessage(this.interruptedText(pokemon, move.moveId));
|
||||||
}
|
}
|
||||||
|
@ -136,10 +146,11 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag {
|
||||||
/**
|
/**
|
||||||
* Gets whether this tag is restricting a move.
|
* Gets whether this tag is restricting a move.
|
||||||
*
|
*
|
||||||
* @param {Moves} move {@linkcode Moves} ID to check restriction for.
|
* @param move - {@linkcode Moves} ID to check restriction for.
|
||||||
* @returns {boolean} `true` if the move is restricted by this tag, otherwise `false`.
|
* @param user - The {@linkcode Pokemon} involved
|
||||||
|
* @returns `true` if the move is restricted by this tag, otherwise `false`.
|
||||||
*/
|
*/
|
||||||
abstract isMoveRestricted(move: Moves): boolean;
|
public abstract isMoveRestricted(move: Moves, user?: Pokemon): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this tag is restricting a move based on a user's decisions during the target selection phase
|
* Checks if this tag is restricting a move based on a user's decisions during the target selection phase
|
||||||
|
@ -327,6 +338,16 @@ export class GorillaTacticsTag extends MoveRestrictionBattlerTag {
|
||||||
pokemon.setStat(Stat.ATK, pokemon.getStat(Stat.ATK, false) * 1.5, false);
|
pokemon.setStat(Stat.ATK, pokemon.getStat(Stat.ATK, false) * 1.5, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the Gorilla Tactics Battler Tag along with its unique class variable moveId
|
||||||
|
* @override
|
||||||
|
* @param source Gorilla Tactics' {@linkcode BattlerTag} information
|
||||||
|
*/
|
||||||
|
public override loadTag(source: BattlerTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.moveId = source.moveId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @override
|
* @override
|
||||||
|
@ -2510,8 +2531,6 @@ export class MysteryEncounterPostSummonTag extends BattlerTag {
|
||||||
* Torment does not interrupt the move if the move is performed consecutively in the same turn and right after Torment is applied
|
* Torment does not interrupt the move if the move is performed consecutively in the same turn and right after Torment is applied
|
||||||
*/
|
*/
|
||||||
export class TormentTag extends MoveRestrictionBattlerTag {
|
export class TormentTag extends MoveRestrictionBattlerTag {
|
||||||
private target: Pokemon;
|
|
||||||
|
|
||||||
constructor(sourceId: number) {
|
constructor(sourceId: number) {
|
||||||
super(BattlerTagType.TORMENT, BattlerTagLapseType.AFTER_MOVE, 1, Moves.TORMENT, sourceId);
|
super(BattlerTagType.TORMENT, BattlerTagLapseType.AFTER_MOVE, 1, Moves.TORMENT, sourceId);
|
||||||
}
|
}
|
||||||
|
@ -2523,7 +2542,6 @@ export class TormentTag extends MoveRestrictionBattlerTag {
|
||||||
*/
|
*/
|
||||||
override onAdd(pokemon: Pokemon) {
|
override onAdd(pokemon: Pokemon) {
|
||||||
super.onAdd(pokemon);
|
super.onAdd(pokemon);
|
||||||
this.target = pokemon;
|
|
||||||
pokemon.scene.queueMessage(i18next.t("battlerTags:tormentOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500);
|
pokemon.scene.queueMessage(i18next.t("battlerTags:tormentOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }), 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2542,15 +2560,18 @@ export class TormentTag extends MoveRestrictionBattlerTag {
|
||||||
* @param {Moves} move the move under investigation
|
* @param {Moves} move the move under investigation
|
||||||
* @returns `true` if there is valid consecutive usage | `false` if the moves are different from each other
|
* @returns `true` if there is valid consecutive usage | `false` if the moves are different from each other
|
||||||
*/
|
*/
|
||||||
override isMoveRestricted(move: Moves): boolean {
|
public override isMoveRestricted(move: Moves, user: Pokemon): boolean {
|
||||||
const lastMove = this.target.getLastXMoves(1)[0];
|
if (!user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const lastMove = user.getLastXMoves(1)[0];
|
||||||
if ( !lastMove ) {
|
if ( !lastMove ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// This checks for locking / momentum moves like Rollout and Hydro Cannon + if the user is under the influence of BattlerTagType.FRENZY
|
// 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
|
// 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 moveObj = allMoves[lastMove.move];
|
||||||
const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || this.target.getTag(BattlerTagType.FRENZY) || moveObj.hasAttr(ChargeAttr);
|
const isUnaffected = moveObj.hasAttr(ConsecutiveUseDoublePowerAttr) || user.getTag(BattlerTagType.FRENZY) || moveObj.hasAttr(ChargeAttr);
|
||||||
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) {
|
if (lastMove.move === move && validLastMoveResult && lastMove.move !== Moves.STRUGGLE && !isUnaffected) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2602,37 +2623,39 @@ export class TauntTag extends MoveRestrictionBattlerTag {
|
||||||
* The tag is only removed when the source-user is removed from the field.
|
* The tag is only removed when the source-user is removed from the field.
|
||||||
*/
|
*/
|
||||||
export class ImprisonTag extends MoveRestrictionBattlerTag {
|
export class ImprisonTag extends MoveRestrictionBattlerTag {
|
||||||
private source: Pokemon | null;
|
|
||||||
|
|
||||||
constructor(sourceId: number) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
override onAdd(pokemon: Pokemon) {
|
|
||||||
if (this.sourceId) {
|
|
||||||
this.source = pokemon.scene.getPokemonById(this.sourceId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the source of Imprison is still active
|
* Checks if the source of Imprison is still active
|
||||||
* @param _pokemon
|
* @override
|
||||||
* @param _lapseType
|
* @param pokemon The pokemon this tag is attached to
|
||||||
* @returns `true` if the source is still active
|
* @returns `true` if the source is still active
|
||||||
*/
|
*/
|
||||||
override lapse(_pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
|
public override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||||
return this.source?.isActive(true) ?? false;
|
const source = this.getSourcePokemon(pokemon.scene);
|
||||||
|
if (source) {
|
||||||
|
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||||
|
return super.lapse(pokemon, lapseType) && source.isActive(true);
|
||||||
|
} else {
|
||||||
|
return source.isActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the source of the tag has the parameter move in its moveset and that the source is still active
|
* Checks if the source of the tag has the parameter move in its moveset and that the source is still active
|
||||||
|
* @override
|
||||||
* @param {Moves} move the move under investigation
|
* @param {Moves} move the move under investigation
|
||||||
* @returns `false` if either condition is not met
|
* @returns `false` if either condition is not met
|
||||||
*/
|
*/
|
||||||
override isMoveRestricted(move: Moves): boolean {
|
public override isMoveRestricted(move: Moves, user: Pokemon): boolean {
|
||||||
if (this.source) {
|
const source = this.getSourcePokemon(user.scene);
|
||||||
const sourceMoveset = this.source.getMoveset().map(m => m!.moveId);
|
if (source) {
|
||||||
return sourceMoveset?.includes(move) && this.source.isActive(true);
|
const sourceMoveset = source.getMoveset().map(m => m!.moveId);
|
||||||
|
return sourceMoveset?.includes(move) && source.isActive(true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7883,7 +7883,8 @@ export function initMoves() {
|
||||||
.attr(SwitchAbilitiesAttr),
|
.attr(SwitchAbilitiesAttr),
|
||||||
new StatusMove(Moves.IMPRISON, Type.PSYCHIC, 100, 10, -1, 0, 3)
|
new StatusMove(Moves.IMPRISON, Type.PSYCHIC, 100, 10, -1, 0, 3)
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false),
|
.attr(AddArenaTagAttr, ArenaTagType.IMPRISON, 1, true, false)
|
||||||
|
.target(MoveTarget.ENEMY_SIDE),
|
||||||
new SelfStatusMove(Moves.REFRESH, Type.NORMAL, -1, 20, -1, 0, 3)
|
new SelfStatusMove(Moves.REFRESH, Type.NORMAL, -1, 20, -1, 0, 3)
|
||||||
.attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN)
|
.attr(HealStatusEffectAttr, true, StatusEffect.PARALYSIS, StatusEffect.POISON, StatusEffect.TOXIC, StatusEffect.BURN)
|
||||||
.condition((user, target, move) => !!user.status && (user.status.effect === StatusEffect.PARALYSIS || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.BURN)),
|
.condition((user, target, move) => !!user.status && (user.status.effect === StatusEffect.PARALYSIS || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.BURN)),
|
||||||
|
|
|
@ -3062,8 +3062,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
*
|
*
|
||||||
* @see {@linkcode MoveRestrictionBattlerTag}
|
* @see {@linkcode MoveRestrictionBattlerTag}
|
||||||
*/
|
*/
|
||||||
isMoveRestricted(moveId: Moves): boolean {
|
public isMoveRestricted(moveId: Moves, pokemon?: Pokemon): boolean {
|
||||||
return this.getRestrictingTag(moveId) !== null;
|
return this.getRestrictingTag(moveId, pokemon) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3096,7 +3096,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
*/
|
*/
|
||||||
getRestrictingTag(moveId: Moves, user?: Pokemon, target?: Pokemon): MoveRestrictionBattlerTag | null {
|
getRestrictingTag(moveId: Moves, user?: Pokemon, target?: Pokemon): MoveRestrictionBattlerTag | null {
|
||||||
for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) {
|
for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) {
|
||||||
if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId)) {
|
if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId, user)) {
|
||||||
return tag as MoveRestrictionBattlerTag;
|
return tag as MoveRestrictionBattlerTag;
|
||||||
} else if (user && target && (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted(moveId, user, target)) {
|
} else if (user && target && (tag as MoveRestrictionBattlerTag).isMoveTargetRestricted(moveId, user, target)) {
|
||||||
return tag as MoveRestrictionBattlerTag;
|
return tag as MoveRestrictionBattlerTag;
|
||||||
|
@ -5139,7 +5139,7 @@ export class PokemonMove {
|
||||||
* @returns `true` if the move can be selected and used by the Pokemon, otherwise `false`.
|
* @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 {
|
isUsable(pokemon: Pokemon, ignorePp: boolean = false, ignoreRestrictionTags: boolean = false): boolean {
|
||||||
if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId)) {
|
if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,8 @@ export class CommandPhase extends FieldPhase {
|
||||||
|
|
||||||
// Decides between a Disabled, Not Implemented, or No PP translation message
|
// Decides between a Disabled, Not Implemented, or No PP translation message
|
||||||
const errorMessage =
|
const errorMessage =
|
||||||
playerPokemon.isMoveRestricted(move.moveId)
|
playerPokemon.isMoveRestricted(move.moveId, playerPokemon)
|
||||||
? playerPokemon.getRestrictingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId)
|
? playerPokemon.getRestrictingTag(move.moveId, playerPokemon)!.selectionDeniedText(playerPokemon, move.moveId)
|
||||||
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
|
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
|
||||||
const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator
|
const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue