Suggested changes to getLastXMoves()

This commit is contained in:
Michael Li 2024-11-08 23:26:34 -05:00
parent 32f9f3ed74
commit 8581f9739f
2 changed files with 5 additions and 5 deletions

View File

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

View File

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