Apply Matthew's Suggestions

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
This commit is contained in:
Amani H. 2025-08-06 17:15:57 -04:00 committed by GitHub
parent 74e32ebb24
commit b17d682350
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 41 additions and 47 deletions

View File

@ -52,7 +52,8 @@ export class PokemonMove {
const usability = new BooleanHolder( const usability = new BooleanHolder(
!move.name.endsWith(" (N)") && !move.name.endsWith(" (N)") &&
(ignorePp || this.ppUsed < this.getMovePp() || move.pp === -1) && (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()) { if (pokemon.isPlayer()) {
applyChallenges(ChallengeType.POKEMON_MOVE, move.id, usability); applyChallenges(ChallengeType.POKEMON_MOVE, move.id, usability);

View File

@ -312,10 +312,10 @@ export class GameMode implements GameModeConfig {
} }
/** /**
* Checks if the game mode has the shop enabled or not * Check if the current game mode has the shop enabled or not
* @returns Whether the shop is available or not * @returns Whether the shop is available in the current mode
*/ */
getShopStatus(): boolean { public getShopStatus(): boolean {
const status = new BooleanHolder(!this.hasNoShop); const status = new BooleanHolder(!this.hasNoShop);
applyChallenges(ChallengeType.SHOP, status); applyChallenges(ChallengeType.SHOP, status);
return status.value; return status.value;

View File

@ -31,26 +31,25 @@ describe("Challenges - Limited Catch", () => {
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH) .enemyMoveset(MoveId.SPLASH)
.startingModifier([{ name: "MASTER_BALL", count: 1 }]) .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); game.override.startingWave(31);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
game.doThrowPokeball(PokeballType.MASTER_BALL); 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); game.override.startingWave(53);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
game.doThrowPokeball(PokeballType.MASTER_BALL); 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);
}); });
}); });

View File

@ -30,70 +30,61 @@ describe("Challenges - No Support", () => {
.enemySpecies(SpeciesId.VOLTORB) .enemySpecies(SpeciesId.VOLTORB)
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH) .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.override.startingWave(181);
game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 2, 1); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 2, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
game.move.select(MoveId.RAZOR_LEAF); game.move.use(MoveId.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to("SelectModifierPhase"); 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( const modifierSelectHandler = game.scene.ui.handlers.find(
h => h instanceof ModifierSelectUiHandler, h => h instanceof ModifierSelectUiHandler,
) as 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.override.startingWave(10);
game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 1, 1); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 1, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
const playerPokemon = game.scene.getPlayerPokemon(); const playerPokemon = game.field.getPlayerPokemon();
playerPokemon!.damageAndUpdate(playerPokemon!.hp / 2); playerPokemon.hp /= 2;
game.move.select(MoveId.RAZOR_LEAF); game.move.use(MoveId.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.toNextWave();
await game.phaseInterceptor.to("SelectModifierPhase"); expect(playerPokemon).not.toHaveFullHp();
game.doSelectModifier();
// Next wave
await game.phaseInterceptor.to("TurnInitPhase");
expect(playerPokemon!.isFullHp()).toBe(false);
}); });
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.override.startingWave(10);
game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 3, 1); game.challengeMode.addChallenge(Challenges.NO_SUPPORT, 3, 1);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); await game.challengeMode.startBattle([SpeciesId.NUZLEAF]);
const playerPokemon = game.scene.getPlayerPokemon(); const playerPokemon = game.field.getPlayerPokemon();
playerPokemon!.damageAndUpdate(playerPokemon!.hp / 2); playerPokemon.hp /= 2;
game.move.select(MoveId.RAZOR_LEAF); game.move.use(MoveId.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.toNextWave();
expect(playerPokemon).not.toHaveFullHp();
await game.phaseInterceptor.to("SelectModifierPhase"); game.move.use(MoveId.SPLASH);
game.doSelectModifier();
// Next wave
await game.phaseInterceptor.to("TurnInitPhase");
expect(playerPokemon!.isFullHp()).toBe(false);
game.move.select(MoveId.RAZOR_LEAF);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to("SelectModifierPhase"); 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( const modifierSelectHandler = game.scene.ui.handlers.find(
h => h instanceof ModifierSelectUiHandler, h => h instanceof ModifierSelectUiHandler,
) as ModifierSelectUiHandler; ) as ModifierSelectUiHandler;
expect(modifierSelectHandler.shopOptionsRows.length).toBe(0); expect(modifierSelectHandler.shopOptionsRows).toHaveLength(0);
}); });
}); });

View File

@ -35,19 +35,22 @@ describe("Challenges - Permanent Faint", () => {
.enemySpecies(SpeciesId.VOLTORB) .enemySpecies(SpeciesId.VOLTORB)
.enemyAbility(AbilityId.BALL_FETCH) .enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH) .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); game.override.enemyMoveset(MoveId.REVIVAL_BLESSING).moveset(MoveId.REVIVAL_BLESSING);
await game.challengeMode.startBattle([SpeciesId.NUZLEAF]); 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); 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.getEnemyPokemon()).toHaveUsedMove(MoveId.REVIVAL_BLESSING);
expect(game.field.getPlayerPokemon()).toHaveUsedMove(MoveId.STRUGGLE);
}); });
it("prevents REVIVE items in shop and in wave rewards", async () => { it("prevents REVIVE items in shop and in wave rewards", async () => {