Rename "disabling" to "restriction"

This commit is contained in:
Zach Day 2024-09-02 18:50:16 -04:00
parent 5f3183bc8a
commit e5d4b6a0a6
4 changed files with 32 additions and 29 deletions

View File

@ -98,9 +98,12 @@ export interface TerrainBattlerTag {
}
/**
* Base class for tags that disable moves. Descendants can override {@linkcode moveIsDisabled} to disable moves that
* match a condition. A disabled move gets cancelled before it is used. Players and enemies should not be allowed
* to select disabled moves.
* Base class for tags that restrict the usage of moves. This effect is generally referred to as "disabling" a move
* in-game. This is not to be confused with {@linkcode Moves.DISABLE}.
*
* Descendants can override {@linkcode isMoveRestricted} to restrict moves that
* match a condition. A restricted move gets cancelled before it is used. Players and enemies should not be allowed
* to select restricted moves.
*/
export abstract class MoveRestrictionBattlerTag extends BattlerTag {
constructor(tagType: BattlerTagType, turnCount: integer, sourceMove?: Moves, sourceId?: integer) {
@ -113,7 +116,7 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag {
const phase = pokemon.scene.getCurrentPhase() as MovePhase;
const move = phase.move;
if (this.moveIsDisabled(move.moveId)) {
if (this.isMoveRestricted(move.moveId)) {
pokemon.scene.queueMessage(this.interruptedText(pokemon, move.moveId));
phase.cancel();
}
@ -124,29 +127,29 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag {
return super.lapse(pokemon, lapseType);
}
/** Determines whether to disable a move. */
abstract moveIsDisabled(move: Moves): boolean;
/** Determines whether to restrict a move. */
abstract isMoveRestricted(move: Moves): boolean;
/** The text to display when the player attempts to select a move disabled by this tag. */
/** The text to display when the player attempts to select a move that is restricted by this tag. */
abstract selectionDeniedText(pokemon: Pokemon, move: Moves): string;
/**
* The text to display when a move's execution is prevented as a result of the disable.
* Because disabling effects also prevent selection of the move, this situation can only arise if a
* pokemon first selects a move, then gets outsped by a pokemon using a move that disables the selected move.
* The text to display when a move's execution is prevented as a result of the restriction.
* Because restriction effects also prevent selection of the move, this situation can only arise if a
* pokemon first selects a move, then gets outsped by a pokemon using a move that restricts the selected move.
*/
abstract interruptedText(pokemon: Pokemon, move: Moves): string;
}
/**
* Tag representing the "disabling" effect performed by {@linkcode Moves.DISABLE} and {@linkcode Abilities.CURSED_BODY}.
* When the tag is added, the last used move of the tag holder is set as the disabled move.
* When the tag is added, the last-used move of the tag holder is set as the disabled move.
*/
export class DisabledTag extends MoveRestrictionBattlerTag {
/** The move being disabled. Gets set when {@linkcode onAdd} is called for this tag. */
public moveId: Moves = Moves.NONE;
public override moveIsDisabled(move: Moves): boolean {
public override isMoveRestricted(move: Moves): boolean {
return move === this.moveId;
}

View File

@ -2553,16 +2553,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @param moveId {@linkcode Moves} The ID of the move to check
* @see {@linkcode MoveRestrictionBattlerTag}
*/
isMoveDisabled(moveId: Moves): boolean {
return this.getDisablingTag(moveId) !== null;
isMoveRestricted(moveId: Moves): boolean {
return this.getRestrictingTag(moveId) !== null;
}
/**
* Gets the {@link MoveRestrictionBattlerTag} that is disabling the given move, or null if that move is not disabled.
* Gets the {@link MoveRestrictionBattlerTag} that is restricting the given move, or null if that move is not restricted.
*/
getDisablingTag(moveId: Moves): MoveRestrictionBattlerTag | null {
getRestrictingTag(moveId: Moves): MoveRestrictionBattlerTag | null {
for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) {
if ((tag as MoveRestrictionBattlerTag).moveIsDisabled(moveId)) {
if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId)) {
return tag as MoveRestrictionBattlerTag;
}
}
@ -4434,7 +4434,7 @@ export type DamageResult = HitResult.EFFECTIVE | HitResult.SUPER_EFFECTIVE | Hit
* It links to {@linkcode Move} class via the move ID.
* Compared to {@linkcode Move}, this class also tracks if a move has received.
* PP Ups, amount of PP used, and things like that.
* @see {@linkcode isUsable} - checks if move is disabled, out of PP, or not implemented.
* @see {@linkcode isUsable} - checks if move is restricted, out of PP, or not implemented.
* @see {@linkcode getMove} - returns {@linkcode Move} object by looking it up via ID.
* @see {@linkcode usePp} - removes a point of PP from the move.
* @see {@linkcode getMovePp} - returns amount of PP a move currently has.
@ -4456,14 +4456,14 @@ export class PokemonMove {
/**
* Checks whether the move can be selected or performed by a Pokemon, without consideration for the move's targets.
* The move is unusable if it is out of PP, disabled by an effect, or unimplemented.
* @param {Pokemon} pokemon The Pokemon that would be using this move
* The move is unusable if it is out of PP, restricted by an effect, or unimplemented.
* @param pokemon {@linkcode Pokemon} The Pokemon that would be using this move
* @param ignorePp If true, skips the PP check
* @param ignoreDisableTags If true, skips the check for move-disabling tags
* @param ignoreRestrictionTags If true, skips the check for move restriction tags
* @returns True if the move can be selected and used by the Pokemon, otherwise false.
*/
isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreDisableTags?: boolean): boolean {
if (this.moveId && !ignoreDisableTags && pokemon.isMoveDisabled(this.moveId)) {
isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreRestrictionTags?: boolean): boolean {
if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId)) {
return false;
}

View File

@ -107,8 +107,8 @@ export class CommandPhase extends FieldPhase {
// Decides between a Disabled, Not Implemented, or No PP translation message
const errorMessage =
playerPokemon.isMoveDisabled(move.moveId)
? playerPokemon.getDisablingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId)
playerPokemon.isMoveRestricted(move.moveId)
? playerPokemon.getRestrictingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId)
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator

View File

@ -64,7 +64,7 @@ describe("Moves - Disable", () => {
expect(playerMon.getMoveHistory()).toHaveLength(1);
expect(enemyMon.getMoveHistory()).toHaveLength(1);
expect(playerMon.getMoveHistory()[0]).toMatchObject({ move: Moves.DISABLE, result: MoveResult.SUCCESS });
expect(enemyMon.isMoveDisabled(Moves.SPLASH)).toBe(true);
expect(enemyMon.isMoveRestricted(Moves.SPLASH)).toBe(true);
});
it("fails if enemy has no move history", async() => {
@ -118,7 +118,7 @@ describe("Moves - Disable", () => {
expect(playerMon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(enemyMon.getLastXMoves()[0].move).toBe(Moves.STRUGGLE);
expect(enemyMon.isMoveDisabled(Moves.STRUGGLE)).toBe(false);
expect(enemyMon.isMoveRestricted(Moves.STRUGGLE)).toBe(false);
}, 20000);
it("interrupts target's move when target moves after", async() => {
@ -157,7 +157,7 @@ describe("Moves - Disable", () => {
_useMove(Moves.DISABLE);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(CommandPhase);
expect(enemyMon.isMoveDisabled(Moves.NATURE_POWER)).toBe(true);
expect(enemyMon.isMoveDisabled(enemyMon.getLastXMoves(2)[1].move)).toBe(false);
expect(enemyMon.isMoveRestricted(Moves.NATURE_POWER)).toBe(true);
expect(enemyMon.isMoveRestricted(enemyMon.getLastXMoves(2)[1].move)).toBe(false);
}, 20000);
});