From 3d0603ddf12740d5a246bc7aefd9724e76bb12e9 Mon Sep 17 00:00:00 2001 From: Mumble <171087428+frutescens@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:45:08 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/data/battler-tags.ts | 17 +++++--------- src/enums/arena-tag-type.ts | 2 +- src/locales/en/battler-tags.json | 2 +- src/test/abilities/aroma_veil.test.ts | 10 ++++---- src/test/moves/imprison.test.ts | 34 +++++++++++++-------------- src/test/moves/taunt.test.ts | 12 +++++----- src/test/moves/torment.test.ts | 12 +++++----- 7 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index da689c0502a..c63f532a35c 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2468,14 +2468,11 @@ export class TormentTag extends MoveRestrictionBattlerTag { * @returns `true` if still present | `false` if not */ override lapse(pokemon: Pokemon, _tagType: BattlerTagLapseType): boolean { - if (!pokemon.isActive(true)) { - return false; - } - return true; + return !pokemon.isActive(true); } /** - * This checks if the current move used is identical to the last used move with a MoveResult of SUCCESS/MISS + * This checks if the current move used is identical to the last used move with a {@linkcode MoveResult} of `SUCCESS`/`MISS` * @param move the move under investigation * @returns `true` if there is valid consecutive usage | `false` if the moves are different from each other */ @@ -2516,7 +2513,7 @@ export class TauntTag extends MoveRestrictionBattlerTag { /** * Checks if a move is a status move and determines its restriction status on that basis * @param move the move under investigation - * @returns `true` if the move is a status move | `false` if not + * @returns `true` if the move is a status move */ override isMoveRestricted(move: Moves): boolean { return allMoves[move].category === MoveCategory.STATUS; @@ -2551,7 +2548,7 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { * Checks if the source of Imprison is still active * @param _pokemon * @param _lapseType - * @returns `true` if the source is still active | `false` if not + * @returns `true` if the source is still active */ override lapse(_pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean { return this.source.isActive(true); @@ -2560,12 +2557,10 @@ export class ImprisonTag extends MoveRestrictionBattlerTag { /** * Checks if the source of the tag has the parameter move in its moveset and that the source is still active * @param move the move under investigation - * @returns `true` if both conditions are met | `false` if either conditions are not met + * @returns `false` if either condition is not met */ override isMoveRestricted(move: Moves): boolean { - const sourceMoveset = this.source.getMoveset().map(m => { - return m!.moveId; - }); + const sourceMoveset = this.source.getMoveset().map(m => m!.moveId); return sourceMoveset.includes(move) && this.source.isActive(true); } diff --git a/src/enums/arena-tag-type.ts b/src/enums/arena-tag-type.ts index f761b137fff..c6f911cb493 100644 --- a/src/enums/arena-tag-type.ts +++ b/src/enums/arena-tag-type.ts @@ -24,5 +24,5 @@ export enum ArenaTagType { HAPPY_HOUR = "HAPPY_HOUR", SAFEGUARD = "SAFEGUARD", NO_CRIT = "NO_CRIT", - IMPRISON = "IMPRISON" + IMPRISON = "IMPRISON", } diff --git a/src/locales/en/battler-tags.json b/src/locales/en/battler-tags.json index 944dc400b32..6a5eeee2577 100644 --- a/src/locales/en/battler-tags.json +++ b/src/locales/en/battler-tags.json @@ -77,5 +77,5 @@ "tormentOnAdd": "{{pokemonNameWithAffix}} was subjected to torment!", "tauntOnAdd": "{{pokemonNameWithAffix}} fell for the taunt!", "imprisonOnAdd": "{{pokemonNameWithAffix}} sealed the opponents move(s)!", - "autotomizeOnAdd": "{{pokemonNameWIthAffix}} became nimble!" + "autotomizeOnAdd": "{{pokemonNameWithAffix}} became nimble!" } diff --git a/src/test/abilities/aroma_veil.test.ts b/src/test/abilities/aroma_veil.test.ts index 7ee073b4374..7748502d81e 100644 --- a/src/test/abilities/aroma_veil.test.ts +++ b/src/test/abilities/aroma_veil.test.ts @@ -1,11 +1,11 @@ -import { Moves } from "#app/enums/moves"; -import { Species } from "#app/enums/species"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import { Abilities } from "#enums/abilities"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { BattlerTagType } from "#enums/battler-tag-type"; +import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerIndex } from "#app/battle"; describe("Moves - Aroma Veil", () => { @@ -51,7 +51,7 @@ describe("Moves - Aroma Veil", () => { const playerPokemon = game.scene.getParty()!; game.move.select(Moves.GROWL); - game.move.select(Moves.GROWL); + game.move.select(Moves.GROWL, 1); await game.forceEnemyMove(Moves.IMPRISON, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); diff --git a/src/test/moves/imprison.test.ts b/src/test/moves/imprison.test.ts index d3dc8d33f98..abb4b3cac6c 100644 --- a/src/test/moves/imprison.test.ts +++ b/src/test/moves/imprison.test.ts @@ -1,11 +1,11 @@ -import { Moves } from "#app/enums/moves"; -import { Species } from "#app/enums/species"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import { Abilities } from "#enums/abilities"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { BattlerTagType } from "#enums/battler-tag-type"; +import { ArenaTagType } from "#enums/arena-tag-type"; describe("Moves - Imprison", () => { let phaserGame: Phaser.Game; @@ -33,16 +33,16 @@ describe("Moves - Imprison", () => { it("Pokemon under Imprison cannot use shared moves", async () => { await game.classicMode.startBattle([Species.REGIELEKI]); - const playerPokemon = game.scene.getPlayerPokemon(); + const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(Moves.TRANSFORM); await game.forceEnemyMove(Moves.IMPRISON); await game.toNextTurn(); - const playerMoveset = playerPokemon!.getMoveset().map(x => x?.moveId); + const playerMoveset = playerPokemon.getMoveset().map(x => x?.moveId); const enemyMoveset = game.scene.getEnemyPokemon()!.getMoveset().map(x => x?.moveId); expect(enemyMoveset.includes(playerMoveset[0])).toBeTruthy(); const imprisonArenaTag = game.scene.arena.getTag(ArenaTagType.IMPRISON); - const imprisonBattlerTag = playerPokemon!.getTag(BattlerTagType.IMPRISON); + const imprisonBattlerTag = playerPokemon.getTag(BattlerTagType.IMPRISON); expect(imprisonArenaTag).toBeDefined(); expect(imprisonBattlerTag).toBeDefined(); @@ -50,20 +50,20 @@ describe("Moves - Imprison", () => { game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); - const move1 = playerPokemon?.getLastXMoves(1)[0]!; + const move1 = playerPokemon.getLastXMoves(1)[0]!; expect(move1.move).toBe(Moves.STRUGGLE); }); it("Imprison applies to Pokemon switched into Battle", async () => { await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); - const playerPokemon1 = game.scene.getPlayerPokemon(); + const playerPokemon1 = game.scene.getPlayerPokemon()!; game.move.select(Moves.SPLASH); await game.forceEnemyMove(Moves.IMPRISON); await game.toNextTurn(); const imprisonArenaTag = game.scene.arena.getTag(ArenaTagType.IMPRISON); - const imprisonBattlerTag1 = playerPokemon1!.getTag(BattlerTagType.IMPRISON); + const imprisonBattlerTag1 = playerPokemon1.getTag(BattlerTagType.IMPRISON); expect(imprisonArenaTag).toBeDefined(); expect(imprisonBattlerTag1).toBeDefined(); @@ -71,8 +71,8 @@ describe("Moves - Imprison", () => { game.doSwitchPokemon(1); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); - const playerPokemon2 = game.scene.getPlayerPokemon(); - const imprisonBattlerTag2 = playerPokemon2!.getTag(BattlerTagType.IMPRISON); + const playerPokemon2 = game.scene.getPlayerPokemon()!; + const imprisonBattlerTag2 = playerPokemon2.getTag(BattlerTagType.IMPRISON); expect(playerPokemon1).not.toEqual(playerPokemon2); expect(imprisonBattlerTag2).toBeDefined(); }); @@ -81,18 +81,18 @@ describe("Moves - Imprison", () => { game.override.moveset([Moves.SPLASH, Moves.IMPRISON]); await game.classicMode.startBattle([Species.REGIELEKI, Species.BULBASAUR]); - const playerPokemon = game.scene.getPlayerPokemon(); - const enemyPokemon = game.scene.getEnemyPokemon(); + const playerPokemon = game.scene.getPlayerPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(Moves.IMPRISON); await game.forceEnemyMove(Moves.GROWL); await game.toNextTurn(); expect(game.scene.arena.getTag(ArenaTagType.IMPRISON)).toBeDefined(); - expect(enemyPokemon!.getTag(BattlerTagType.IMPRISON)).toBeDefined(); + expect(enemyPokemon.getTag(BattlerTagType.IMPRISON)).toBeDefined(); game.doSwitchPokemon(1); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); - expect(playerPokemon?.isActive(true)).toBeFalsy(); + expect(playerPokemon.isActive(true)).toBeFalsy(); expect(game.scene.arena.getTag(ArenaTagType.IMPRISON)).toBeUndefined(); - expect(enemyPokemon!.getTag(BattlerTagType.IMPRISON)).toBeUndefined(); + expect(enemyPokemon.getTag(BattlerTagType.IMPRISON)).toBeUndefined(); }); }); diff --git a/src/test/moves/taunt.test.ts b/src/test/moves/taunt.test.ts index 7b63a48bc5e..50bb2fee9df 100644 --- a/src/test/moves/taunt.test.ts +++ b/src/test/moves/taunt.test.ts @@ -1,11 +1,11 @@ -import { Moves } from "#app/enums/moves"; -import { Species } from "#app/enums/species"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import { Abilities } from "#enums/abilities"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { MoveResult } from "#app/field/pokemon"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BattlerTagType } from "#enums/battler-tag-type"; describe("Moves - Taunt", () => { let phaserGame: Phaser.Game; @@ -33,13 +33,13 @@ describe("Moves - Taunt", () => { it("Pokemon should not be able to use Status Moves", async () => { await game.classicMode.startBattle([Species.REGIELEKI]); - const playerPokemon = game.scene.getPlayerPokemon(); + const playerPokemon = game.scene.getPlayerPokemon()!; // First turn, Player Pokemon succeeds using Growl without Taunt game.move.select(Moves.GROWL); await game.forceEnemyMove(Moves.TAUNT); await game.toNextTurn(); - const move1 = playerPokemon?.getLastXMoves(1)[0]!; + const move1 = playerPokemon.getLastXMoves(1)[0]!; expect(move1.move).toBe(Moves.GROWL); expect(move1.result).toBe(MoveResult.SUCCESS); expect(playerPokemon?.getTag(BattlerTagType.TAUNT)).toBeDefined(); @@ -48,7 +48,7 @@ describe("Moves - Taunt", () => { game.move.select(Moves.GROWL); await game.forceEnemyMove(Moves.SPLASH); await game.toNextTurn(); - const move2 = playerPokemon?.getLastXMoves(1)[0]!; + const move2 = playerPokemon.getLastXMoves(1)[0]!; expect(move2.move).toBe(Moves.STRUGGLE); }); }); diff --git a/src/test/moves/torment.test.ts b/src/test/moves/torment.test.ts index 479736f0621..168a90ef5a6 100644 --- a/src/test/moves/torment.test.ts +++ b/src/test/moves/torment.test.ts @@ -1,11 +1,11 @@ -import { Moves } from "#app/enums/moves"; -import { Species } from "#app/enums/species"; +import { Moves } from "#enums/moves"; +import { Species } from "#enums/species"; import { Abilities } from "#enums/abilities"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { MoveResult } from "#app/field/pokemon"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; +import { BattlerTagType } from "#enums/battler-tag-type"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; describe("Moves - Torment", () => { @@ -35,13 +35,13 @@ describe("Moves - Torment", () => { it("Pokemon should not be able to use the same move consecutively", async () => { await game.classicMode.startBattle([Species.CHANSEY]); - const playerPokemon = game.scene.getPlayerPokemon(); + const playerPokemon = game.scene.getPlayerPokemon()!; // First turn, Player Pokemon uses Tackle successfully game.move.select(Moves.TACKLE); await game.forceEnemyMove(Moves.TORMENT); await game.toNextTurn(); - const move1 = playerPokemon?.getLastXMoves(1)[0]!; + const move1 = playerPokemon.getLastXMoves(1)[0]!; expect(move1.move).toBe(Moves.TACKLE); expect(move1.result).toBe(MoveResult.SUCCESS); expect(playerPokemon?.getTag(BattlerTagType.TORMENT)).toBeDefined(); @@ -57,7 +57,7 @@ describe("Moves - Torment", () => { game.move.select(Moves.TACKLE); await game.forceEnemyMove(Moves.SPLASH); await game.phaseInterceptor.to(TurnEndPhase); - const move3 = playerPokemon?.getLastXMoves(1)[0]!; + const move3 = playerPokemon.getLastXMoves(1)[0]!; expect(move3.move).toBe(Moves.TACKLE); }); });