From b17d682350828e04392f86d583b03c02f2e2f01a Mon Sep 17 00:00:00 2001 From: "Amani H." <109637146+xsn34kzx@users.noreply.github.com> Date: Wed, 6 Aug 2025 17:15:57 -0400 Subject: [PATCH] Apply Matthew's Suggestions Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> --- src/data/moves/pokemon-move.ts | 3 +- src/game-mode.ts | 6 +-- test/challenges/limited-catch.test.ts | 13 +++--- test/challenges/no-support.test.ts | 53 ++++++++++--------------- test/challenges/permanent-faint.test.ts | 13 +++--- 5 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/data/moves/pokemon-move.ts b/src/data/moves/pokemon-move.ts index f179dc360fc..b3a0612e553 100644 --- a/src/data/moves/pokemon-move.ts +++ b/src/data/moves/pokemon-move.ts @@ -52,7 +52,8 @@ export class PokemonMove { const usability = new BooleanHolder( !move.name.endsWith(" (N)") && (ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) && - !(this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)), + // TODO: Review if the `MoveId.NONE` check is even necessary anymore + !(this.moveId !== MoveId.NONE && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)), ); if (pokemon.isPlayer()) { applyChallenges(ChallengeType.POKEMON_MOVE, move.id, usability); diff --git a/src/game-mode.ts b/src/game-mode.ts index 645a6b8c449..82f7b4fa77f 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -312,10 +312,10 @@ export class GameMode implements GameModeConfig { } /** - * Checks if the game mode has the shop enabled or not - * @returns Whether the shop is available or not + * Check if the current game mode has the shop enabled or not + * @returns Whether the shop is available in the current mode */ - getShopStatus(): boolean { + public getShopStatus(): boolean { const status = new BooleanHolder(!this.hasNoShop); applyChallenges(ChallengeType.SHOP, status); return status.value; diff --git a/test/challenges/limited-catch.test.ts b/test/challenges/limited-catch.test.ts index 87ac5351e7c..26b40df00ff 100644 --- a/test/challenges/limited-catch.test.ts +++ b/test/challenges/limited-catch.test.ts @@ -31,26 +31,25 @@ describe("Challenges - Limited Catch", () => { .enemyAbility(AbilityId.BALL_FETCH) .enemyMoveset(MoveId.SPLASH) .startingModifier([{ name: "MASTER_BALL", count: 1 }]) - .moveset(MoveId.RAZOR_LEAF); }); - it("allows Pokémon to be caught on X1 waves", async () => { + it("should allow wild Pokémon to be caught on X1 waves", async () => { game.override.startingWave(31); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); game.doThrowPokeball(PokeballType.MASTER_BALL); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.toEndOfTurn(); - expect(game.scene.getPlayerParty().length).toBe(2); + expect(game.scene.getPlayerParty()).toHaveLength(2); }); - it("prevents Pokémon from being caught on waves that aren't X1 waves", async () => { + it("should prevent Pokémon from being caught on non-X1 waves", async () => { game.override.startingWave(53); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); game.doThrowPokeball(PokeballType.MASTER_BALL); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.toEndOfTurn(); - expect(game.scene.getPlayerParty().length).toBe(1); + expect(game.scene.getPlayerParty()).toHaveLength(1); }); }); diff --git a/test/challenges/no-support.test.ts b/test/challenges/no-support.test.ts index aa1254f1968..213f9645220 100644 --- a/test/challenges/no-support.test.ts +++ b/test/challenges/no-support.test.ts @@ -30,70 +30,61 @@ describe("Challenges - No Support", () => { .enemySpecies(SpeciesId.VOLTORB) .enemyAbility(AbilityId.BALL_FETCH) .enemyMoveset(MoveId.SPLASH) - .moveset(MoveId.RAZOR_LEAF); }); - it('disables the shop in "No Shop"', async () => { + it('should disable the shop in "No Shop"', async () => { game.override.startingWave(181); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 2, 1); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); - game.move.select(MoveId.RAZOR_LEAF); + game.move.use(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to("SelectModifierPhase"); - expect(game.scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); + + expect(game.scene.ui.getMode()).toBe(UiMode.MODIFIER_SELECT); const modifierSelectHandler = game.scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; - expect(modifierSelectHandler.shopOptionsRows.length).toBe(0); + expect(modifierSelectHandler.shopOptionsRows).toHaveLength(0); }); - it('disables the automatic party heal in "No Heal"', async () => { + it('should disable the automatic party heal in "No Heal"', async () => { game.override.startingWave(10); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 1, 1); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); - const playerPokemon = game.scene.getPlayerPokemon(); - playerPokemon!.damageAndUpdate(playerPokemon!.hp / 2); + const playerPokemon = game.field.getPlayerPokemon(); + playerPokemon.hp /= 2; - game.move.select(MoveId.RAZOR_LEAF); + game.move.use(MoveId.SPLASH); await game.doKillOpponents(); + await game.toNextWave(); - await game.phaseInterceptor.to("SelectModifierPhase"); - game.doSelectModifier(); - - // Next wave - await game.phaseInterceptor.to("TurnInitPhase"); - expect(playerPokemon!.isFullHp()).toBe(false); + expect(playerPokemon).not.toHaveFullHp(); }); - it('disables the automatic party heal and the shop in "Both"', async () => { + it('should disable both automatic party healing and shop in "Both"', async () => { game.override.startingWave(10); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 3, 1); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); - const playerPokemon = game.scene.getPlayerPokemon(); - playerPokemon!.damageAndUpdate(playerPokemon!.hp / 2); + const playerPokemon = game.field.getPlayerPokemon(); + playerPokemon.hp /= 2; - game.move.select(MoveId.RAZOR_LEAF); + game.move.use(MoveId.SPLASH); await game.doKillOpponents(); + await game.toNextWave(); + + expect(playerPokemon).not.toHaveFullHp(); - await game.phaseInterceptor.to("SelectModifierPhase"); - game.doSelectModifier(); - - // Next wave - await game.phaseInterceptor.to("TurnInitPhase"); - expect(playerPokemon!.isFullHp()).toBe(false); - - game.move.select(MoveId.RAZOR_LEAF); + game.move.use(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to("SelectModifierPhase"); - expect(game.scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); + + expect(game.scene.ui.getMode()).toBe(UiMode.MODIFIER_SELECT); const modifierSelectHandler = game.scene.ui.handlers.find( h => h instanceof ModifierSelectUiHandler, ) as ModifierSelectUiHandler; - expect(modifierSelectHandler.shopOptionsRows.length).toBe(0); + expect(modifierSelectHandler.shopOptionsRows).toHaveLength(0); }); }); diff --git a/test/challenges/permanent-faint.test.ts b/test/challenges/permanent-faint.test.ts index d7222097bdf..60618fd57ea 100644 --- a/test/challenges/permanent-faint.test.ts +++ b/test/challenges/permanent-faint.test.ts @@ -35,19 +35,22 @@ describe("Challenges - Permanent Faint", () => { .enemySpecies(SpeciesId.VOLTORB) .enemyAbility(AbilityId.BALL_FETCH) .enemyMoveset(MoveId.SPLASH) - .moveset(MoveId.RAZOR_LEAF); }); - it("disables REVIVAL_BLESSING for the player only", async () => { + it("should render Revival Blessing unusable by players only", async () => { game.override.enemyMoveset(MoveId.REVIVAL_BLESSING).moveset(MoveId.REVIVAL_BLESSING); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); + const player = game.field.getPlayerPokemon(); + const revBlessing = player.getMoveset()[0]; + expect(revBlessing.isUsable()).toBe(false); + game.move.select(MoveId.REVIVAL_BLESSING); + await game.toEndOfTurn(); - await game.phaseInterceptor.to("TurnEndPhase"); - + // Player struggled due to only move being the unusable Revival Blessing + expect(player).toHaveUsedMove(MoveId.STRUGGLE); expect(game.field.getEnemyPokemon()).toHaveUsedMove(MoveId.REVIVAL_BLESSING); - expect(game.field.getPlayerPokemon()).toHaveUsedMove(MoveId.STRUGGLE); }); it("prevents REVIVE items in shop and in wave rewards", async () => {