Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
  • Loading branch information
frutescens and DayKev authored Sep 25, 2024
1 parent 789416e commit 3d0603d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 47 deletions.
17 changes: 6 additions & 11 deletions src/data/battler-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/enums/arena-tag-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export enum ArenaTagType {
HAPPY_HOUR = "HAPPY_HOUR",
SAFEGUARD = "SAFEGUARD",
NO_CRIT = "NO_CRIT",
IMPRISON = "IMPRISON"
IMPRISON = "IMPRISON",
}
2 changes: 1 addition & 1 deletion src/locales/en/battler-tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
}
10 changes: 5 additions & 5 deletions src/test/abilities/aroma_veil.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down Expand Up @@ -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();
Expand Down
34 changes: 17 additions & 17 deletions src/test/moves/imprison.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -33,46 +33,46 @@ 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();

// Second turn, Imprison forces Struggle to occur
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();

// Second turn, Imprison forces Struggle to occur
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();
});
Expand All @@ -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();
});
});
12 changes: 6 additions & 6 deletions src/test/moves/taunt.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
});
});
12 changes: 6 additions & 6 deletions src/test/moves/torment.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
});
});

0 comments on commit 3d0603d

Please sign in to comment.