From 8581f9739fdfc87ed67707c99091007115d1fe11 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Fri, 8 Nov 2024 23:26:34 -0500 Subject: [PATCH] Suggested changes to `getLastXMoves()` --- src/field/pokemon.ts | 6 +++--- src/modifier/modifier.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 2190fd6fd57..fe93d82efeb 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3223,13 +3223,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** * Returns a list of the most recent move entries in this Pokemon's move history. * The retrieved move entries are sorted in order from NEWEST to OLDEST. - * @param turnCount The number of move entries to retrieve. If `0`, retrieve exactly 1 move entry. If negative, retrieve the Pokemon's entire move history. Default is `1`. + * @param turnCount The number of move entries to retrieve. If negative, retrieve the Pokemon's entire move history. Default is `1`. * @returns A list of {@linkcode TurnMove}, as specified above. */ - getLastXMoves(turnCount: integer = 1): TurnMove[] { + getLastXMoves(turnCount: number = 1): TurnMove[] { const moveHistory = this.getMoveHistory(); if (turnCount >= 0) { - return moveHistory.slice(Math.max(moveHistory.length - (turnCount || 1), 0)).reverse(); + return moveHistory.slice(Math.max(moveHistory.length - turnCount, 0)).reverse(); } else { return moveHistory.slice(0).reverse(); } diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index c3b1f15fab4..c95582454d9 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -728,10 +728,10 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier { //Applies to items with chance of activating secondary effects ie Kings Rock getSecondaryChanceMultiplier(pokemon: Pokemon): number { // Temporary quickfix to stop game from freezing when the opponet uses u-turn while holding on to king's rock - if (!pokemon.getLastXMoves(0)[0]) { + if (!pokemon.getLastXMoves()[0]) { return 1; } - const sheerForceAffected = allMoves[pokemon.getLastXMoves(0)[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE); + const sheerForceAffected = allMoves[pokemon.getLastXMoves()[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE); if (sheerForceAffected) { return 0;