mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-14 13:55:20 +01:00
[Misc] Rename Pokemon.isMoveRestricted to hasRestrictingTag (#6628)
This commit is contained in:
parent
11d6753257
commit
a13ea90e46
@ -4264,19 +4264,16 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the given move is currently disabled for this Pokémon
|
* Get whether the given move is currently disabled for this Pokémon by a move restriction tag.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* ⚠️ Only checks for restrictions due to a battler tag, not due to the move's own attributes.
|
* ⚠️ Only checks for restrictions due to a battler tag, not due to the move's own attributes.
|
||||||
* (for that behavior, see {@linkcode isMoveSelectable}).
|
|
||||||
*
|
|
||||||
* @param moveId - The ID of the move to check
|
* @param moveId - The ID of the move to check
|
||||||
* @returns `true` if the move is disabled for this Pokemon, otherwise `false`
|
* @returns `true` if the move is disabled for this Pokemon, otherwise `false`
|
||||||
*
|
|
||||||
* @see {@linkcode MoveRestrictionBattlerTag}
|
* @see {@linkcode MoveRestrictionBattlerTag}
|
||||||
*/
|
*/
|
||||||
// TODO: rename this method as it can be easily confused with a move being restricted
|
// TODO: Move this behavior into a matcher and expunge it from the codebase - we only use it for tests
|
||||||
public isMoveRestricted(moveId: MoveId): boolean {
|
public hasRestrictingTag(moveId: MoveId): boolean {
|
||||||
return this.getRestrictingTag(moveId, this) !== null;
|
return this.getRestrictingTag(moveId, this) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,8 +48,8 @@ describe("Abilities - Gorilla Tactics", () => {
|
|||||||
|
|
||||||
expect(darmanitan.getStat(Stat.ATK, false)).toBeCloseTo(initialAtkStat * 1.5);
|
expect(darmanitan.getStat(Stat.ATK, false)).toBeCloseTo(initialAtkStat * 1.5);
|
||||||
// Other moves should be restricted
|
// Other moves should be restricted
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.TACKLE)).toBe(true);
|
expect(darmanitan.hasRestrictingTag(MoveId.TACKLE)).toBe(true);
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.SPLASH)).toBe(false);
|
expect(darmanitan.hasRestrictingTag(MoveId.SPLASH)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should struggle if the only usable move is disabled", async () => {
|
it("should struggle if the only usable move is disabled", async () => {
|
||||||
@ -92,8 +92,8 @@ describe("Abilities - Gorilla Tactics", () => {
|
|||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
// Gorilla Tactics should lock into Metronome, not tackle
|
// Gorilla Tactics should lock into Metronome, not tackle
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.TACKLE)).toBe(true);
|
expect(darmanitan.hasRestrictingTag(MoveId.TACKLE)).toBe(true);
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.METRONOME)).toBe(false);
|
expect(darmanitan.hasRestrictingTag(MoveId.METRONOME)).toBe(false);
|
||||||
expect(darmanitan.getLastXMoves(-1)).toEqual([
|
expect(darmanitan.getLastXMoves(-1)).toEqual([
|
||||||
expect.objectContaining({ move: MoveId.TACKLE, result: MoveResult.SUCCESS, useMode: MoveUseMode.FOLLOW_UP }),
|
expect.objectContaining({ move: MoveId.TACKLE, result: MoveResult.SUCCESS, useMode: MoveUseMode.FOLLOW_UP }),
|
||||||
expect.objectContaining({ move: MoveId.METRONOME, result: MoveResult.SUCCESS, useMode: MoveUseMode.NORMAL }),
|
expect.objectContaining({ move: MoveId.METRONOME, result: MoveResult.SUCCESS, useMode: MoveUseMode.NORMAL }),
|
||||||
@ -109,8 +109,8 @@ describe("Abilities - Gorilla Tactics", () => {
|
|||||||
await game.move.forceEnemyMove(MoveId.PROTECT);
|
await game.move.forceEnemyMove(MoveId.PROTECT);
|
||||||
|
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.SPLASH)).toBe(true);
|
expect(darmanitan.hasRestrictingTag(MoveId.SPLASH)).toBe(true);
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.TACKLE)).toBe(false);
|
expect(darmanitan.hasRestrictingTag(MoveId.TACKLE)).toBe(false);
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const enemy = game.field.getEnemyPokemon();
|
||||||
expect(enemy.hp).toBe(enemy.getMaxHp());
|
expect(enemy.hp).toBe(enemy.getMaxHp());
|
||||||
});
|
});
|
||||||
@ -125,7 +125,7 @@ describe("Abilities - Gorilla Tactics", () => {
|
|||||||
await game.move.forceMiss();
|
await game.move.forceMiss();
|
||||||
await game.toEndOfTurn();
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.SPLASH)).toBe(true);
|
expect(darmanitan.hasRestrictingTag(MoveId.SPLASH)).toBe(true);
|
||||||
expect(darmanitan.isMoveRestricted(MoveId.TACKLE)).toBe(false);
|
expect(darmanitan.hasRestrictingTag(MoveId.TACKLE)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -49,8 +49,8 @@ describe("Moves - Disable", () => {
|
|||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyMon.getLastXMoves(-1)).toHaveLength(2);
|
expect(enemyMon.getLastXMoves(-1)).toHaveLength(2);
|
||||||
expect(enemyMon.isMoveRestricted(MoveId.SPLASH)).toBe(true);
|
expect(enemyMon.hasRestrictingTag(MoveId.SPLASH)).toBe(true);
|
||||||
expect(enemyMon.isMoveRestricted(MoveId.GROWL)).toBe(false);
|
expect(enemyMon.hasRestrictingTag(MoveId.GROWL)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail if enemy has no move history", async () => {
|
it("should fail if enemy has no move history", async () => {
|
||||||
@ -67,7 +67,7 @@ describe("Moves - Disable", () => {
|
|||||||
move: MoveId.DISABLE,
|
move: MoveId.DISABLE,
|
||||||
result: MoveResult.FAIL,
|
result: MoveResult.FAIL,
|
||||||
});
|
});
|
||||||
expect(enemyMon.isMoveRestricted(MoveId.SPLASH)).toBe(false);
|
expect(enemyMon.hasRestrictingTag(MoveId.SPLASH)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("causes STRUGGLE if all usable moves are disabled", async () => {
|
it("causes STRUGGLE if all usable moves are disabled", async () => {
|
||||||
@ -100,7 +100,7 @@ describe("Moves - Disable", () => {
|
|||||||
|
|
||||||
expect(playerMon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
expect(playerMon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
expect(enemyMon.getLastXMoves()[0].move).toBe(MoveId.STRUGGLE);
|
expect(enemyMon.getLastXMoves()[0].move).toBe(MoveId.STRUGGLE);
|
||||||
expect(enemyMon.isMoveRestricted(MoveId.STRUGGLE)).toBe(false);
|
expect(enemyMon.hasRestrictingTag(MoveId.STRUGGLE)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should interrupt target's move if used first", async () => {
|
it("should interrupt target's move if used first", async () => {
|
||||||
@ -142,11 +142,11 @@ describe("Moves - Disable", () => {
|
|||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
const enemyMon = game.field.getEnemyPokemon();
|
const enemyMon = game.field.getEnemyPokemon();
|
||||||
expect(enemyMon.isMoveRestricted(moveId), `calling move ${MoveId[moveId]} was not disabled`).toBe(true);
|
expect(enemyMon.hasRestrictingTag(moveId), `calling move ${MoveId[moveId]} was not disabled`).toBe(true);
|
||||||
expect(enemyMon.getLastXMoves(-1)).toHaveLength(2);
|
expect(enemyMon.getLastXMoves(-1)).toHaveLength(2);
|
||||||
const calledMove = enemyMon.getLastXMoves()[0].move;
|
const calledMove = enemyMon.getLastXMoves()[0].move;
|
||||||
expect(
|
expect(
|
||||||
enemyMon.isMoveRestricted(calledMove),
|
enemyMon.hasRestrictingTag(calledMove),
|
||||||
`called move ${MoveId[calledMove]} (from ${MoveId[moveId]}) was incorrectly disabled`,
|
`called move ${MoveId[calledMove]} (from ${MoveId[moveId]}) was incorrectly disabled`,
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
});
|
});
|
||||||
@ -171,8 +171,8 @@ describe("Moves - Disable", () => {
|
|||||||
// Dancer-induced Swords Dance was ignored in favor of splash,
|
// Dancer-induced Swords Dance was ignored in favor of splash,
|
||||||
// leaving the subsequent _normal_ swords dance free to work as normal
|
// leaving the subsequent _normal_ swords dance free to work as normal
|
||||||
const shuckle = game.field.getEnemyPokemon();
|
const shuckle = game.field.getEnemyPokemon();
|
||||||
expect.soft(shuckle.isMoveRestricted(MoveId.SPLASH)).toBe(true);
|
expect.soft(shuckle.hasRestrictingTag(MoveId.SPLASH)).toBe(true);
|
||||||
expect.soft(shuckle.isMoveRestricted(MoveId.SWORDS_DANCE)).toBe(false);
|
expect.soft(shuckle.hasRestrictingTag(MoveId.SWORDS_DANCE)).toBe(false);
|
||||||
expect(shuckle.getLastXMoves()[0]).toMatchObject({ move: MoveId.SWORDS_DANCE, result: MoveResult.SUCCESS });
|
expect(shuckle.getLastXMoves()[0]).toMatchObject({ move: MoveId.SWORDS_DANCE, result: MoveResult.SUCCESS });
|
||||||
expect(shuckle.getStatStage(Stat.ATK)).toBe(4);
|
expect(shuckle.getStatStage(Stat.ATK)).toBe(4);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user