Apply suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Mumble 2024-09-24 20:45:08 -07:00 committed by GitHub
parent 789416e006
commit 3d0603ddf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 42 additions and 47 deletions

View File

@ -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);
}

View File

@ -24,5 +24,5 @@ export enum ArenaTagType {
HAPPY_HOUR = "HAPPY_HOUR",
SAFEGUARD = "SAFEGUARD",
NO_CRIT = "NO_CRIT",
IMPRISON = "IMPRISON"
IMPRISON = "IMPRISON",
}

View File

@ -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!"
}

View File

@ -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();

View File

@ -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();
});
});

View File

@ -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);
});
});

View File

@ -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);
});
});