From 4361aa089ba5af9f2ac0e3400e50937475b09c84 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:31:46 -0600 Subject: [PATCH] [Refactor] Replace integer holder with number holder (#5350) * Replace integer holder with number holder * Remove duplicate NumberHolder --------- Co-authored-by: Madmadness65 <59298170+Madmadness65@users.noreply.github.com> --- src/battle-scene.ts | 4 +- src/battle.ts | 2 +- src/data/ability.ts | 10 ++--- src/data/challenge.ts | 32 ++++++++-------- src/data/move.ts | 38 +++++++++---------- .../encounters/safari-zone-encounter.ts | 4 +- .../encounters/weird-dream-encounter.ts | 4 +- src/field/pokemon.ts | 14 +++---- src/modifier/modifier-type.ts | 4 +- src/phases/money-reward-phase.ts | 2 +- src/phases/pokemon-heal-phase.ts | 2 +- src/phases/select-modifier-phase.ts | 2 +- src/test/achievements/achievement.test.ts | 4 +- src/ui/modifier-select-ui-handler.ts | 4 +- src/utils.ts | 7 ---- 15 files changed, 64 insertions(+), 69 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 4033f44eacb..c7e3d4bc928 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1212,7 +1212,7 @@ export default class BattleScene extends SceneBase { } getDoubleBattleChance(newWaveIndex: number, playerField: PlayerPokemon[]) { - const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8); + const doubleChance = new Utils.NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance)); return Math.max(doubleChance.value, 1); @@ -2628,7 +2628,7 @@ export default class BattleScene extends SceneBase { const args: unknown[] = []; if (modifier instanceof PokemonHpRestoreModifier) { if (!(modifier as PokemonHpRestoreModifier).fainted) { - const hpRestoreMultiplier = new Utils.IntegerHolder(1); + const hpRestoreMultiplier = new Utils.NumberHolder(1); this.applyModifiers(HealingBoosterModifier, true, hpRestoreMultiplier); args.push(hpRestoreMultiplier.value); } else { diff --git a/src/battle.ts b/src/battle.ts index 807ac215ea8..242954a3729 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -203,7 +203,7 @@ export default class Battle { } pickUpScatteredMoney(): void { - const moneyAmount = new Utils.IntegerHolder(globalScene.currentBattle.moneyScattered); + const moneyAmount = new Utils.NumberHolder(globalScene.currentBattle.moneyScattered); globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); if (globalScene.arena.getTag(ArenaTagType.HAPPY_HOUR)) { diff --git a/src/data/ability.ts b/src/data/ability.ts index 6ba5f685acd..bf3b04e1f63 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3115,7 +3115,7 @@ export class ChangeMovePriorityAbAttr extends AbAttr { return false; } - (args[1] as Utils.IntegerHolder).value += this.changeAmount; + (args[1] as Utils.NumberHolder).value += this.changeAmount; return true; } } @@ -3957,7 +3957,7 @@ export class StatStageChangeMultiplierAbAttr extends AbAttr { } override apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value *= this.multiplier; + (args[0] as Utils.NumberHolder).value *= this.multiplier; return true; } @@ -4058,7 +4058,7 @@ export class HealFromBerryUseAbAttr extends AbAttr { export class RunSuccessAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = 256; + (args[0] as Utils.NumberHolder).value = 256; return true; } @@ -4128,7 +4128,7 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr { export class MaxMultiHitAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = 0; + (args[0] as Utils.NumberHolder).value = 0; return true; } @@ -4259,7 +4259,7 @@ export class PostFaintHPDamageAbAttr extends PostFaintAbAttr { export class RedirectMoveAbAttr extends AbAttr { apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { if (this.canRedirect(args[0] as Moves)) { - const target = args[1] as Utils.IntegerHolder; + const target = args[1] as Utils.NumberHolder; const newTarget = pokemon.getBattlerIndex(); if (target.value !== newTarget) { target.value = newTarget; diff --git a/src/data/challenge.ts b/src/data/challenge.ts index b6d123ce933..c6e85be2389 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -349,23 +349,23 @@ export abstract class Challenge { /** * An apply function for AI_LEVEL challenges. Derived classes should alter this. - * @param level {@link Utils.IntegerHolder} The generated level. + * @param level {@link Utils.NumberHolder} The generated level. * @param levelCap {@link Number} The current level cap. * @param isTrainer {@link Boolean} Whether this is a trainer pokemon. * @param isBoss {@link Boolean} Whether this is a non-trainer boss pokemon. * @returns {@link boolean} Whether this function did anything. */ - applyLevelChange(level: Utils.IntegerHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean { + applyLevelChange(level: Utils.NumberHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean { return false; } /** * An apply function for AI_MOVE_SLOTS challenges. Derived classes should alter this. * @param pokemon {@link Pokemon} The pokemon that is being considered. - * @param moveSlots {@link Utils.IntegerHolder} The amount of move slots. + * @param moveSlots {@link Utils.NumberHolder} The amount of move slots. * @returns {@link boolean} Whether this function did anything. */ - applyMoveSlot(pokemon: Pokemon, moveSlots: Utils.IntegerHolder): boolean { + applyMoveSlot(pokemon: Pokemon, moveSlots: Utils.NumberHolder): boolean { return false; } @@ -393,10 +393,10 @@ export abstract class Challenge { * @param pokemon {@link Pokemon} What pokemon would learn the move. * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. * @param move {@link Moves} The move in question. - * @param level {@link Utils.IntegerHolder} The level threshold for access. + * @param level {@link Utils.NumberHolder} The level threshold for access. * @returns {@link boolean} Whether this function did anything. */ - applyMoveAccessLevel(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.IntegerHolder): boolean { + applyMoveAccessLevel(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean { return false; } @@ -405,10 +405,10 @@ export abstract class Challenge { * @param pokemon {@link Pokemon} What pokemon would learn the move. * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. * @param move {@link Moves} The move in question. - * @param weight {@link Utils.IntegerHolder} The base weight of the move + * @param weight {@link Utils.NumberHolder} The base weight of the move * @returns {@link boolean} Whether this function did anything. */ - applyMoveWeight(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.IntegerHolder): boolean { + applyMoveWeight(pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean { return false; } @@ -913,22 +913,22 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * Apply all challenges that modify what level AI are. * @param gameMode {@link GameMode} The current gameMode * @param challengeType {@link ChallengeType} ChallengeType.AI_LEVEL - * @param level {@link Utils.IntegerHolder} The generated level of the pokemon. + * @param level {@link Utils.NumberHolder} The generated level of the pokemon. * @param levelCap {@link Number} The maximum level cap for the current wave. * @param isTrainer {@link Boolean} Whether this is a trainer pokemon. * @param isBoss {@link Boolean} Whether this is a non-trainer boss pokemon. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_LEVEL, level: Utils.IntegerHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean; +export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_LEVEL, level: Utils.NumberHolder, levelCap: number, isTrainer: boolean, isBoss: boolean): boolean; /** * Apply all challenges that modify how many move slots the AI has. * @param gameMode {@link GameMode} The current gameMode * @param challengeType {@link ChallengeType} ChallengeType.AI_MOVE_SLOTS * @param pokemon {@link Pokemon} The pokemon being considered. - * @param moveSlots {@link Utils.IntegerHolder} The amount of move slots. + * @param moveSlots {@link Utils.NumberHolder} The amount of move slots. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_MOVE_SLOTS, pokemon: Pokemon, moveSlots: Utils.IntegerHolder): boolean; +export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.AI_MOVE_SLOTS, pokemon: Pokemon, moveSlots: Utils.NumberHolder): boolean; /** * Apply all challenges that modify whether a pokemon has its passive. * @param gameMode {@link GameMode} The current gameMode @@ -952,10 +952,10 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param pokemon {@link Pokemon} What pokemon would learn the move. * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. * @param move {@link Moves} The move in question. - * @param level {@link Utils.IntegerHolder} The level threshold for access. + * @param level {@link Utils.NumberHolder} The level threshold for access. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_ACCESS, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.IntegerHolder): boolean; +export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_ACCESS, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, level: Utils.NumberHolder): boolean; /** * Apply all challenges that modify what weight a pokemon gives to move generation * @param gameMode {@link GameMode} The current gameMode @@ -963,10 +963,10 @@ export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType * @param pokemon {@link Pokemon} What pokemon would learn the move. * @param moveSource {@link MoveSourceType} What source the pokemon would get the move from. * @param move {@link Moves} The move in question. - * @param weight {@link Utils.IntegerHolder} The weight of the move. + * @param weight {@link Utils.NumberHolder} The weight of the move. * @returns True if any challenge was successfully applied. */ -export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_WEIGHT, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, weight: Utils.IntegerHolder): boolean; +export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.MOVE_WEIGHT, pokemon: Pokemon, moveSource: MoveSourceType, move: Moves, weight: Utils.NumberHolder): boolean; export function applyChallenges(gameMode: GameMode, challengeType: ChallengeType.FLIP_STAT, pokemon: Pokemon, baseStats: number[]): boolean; diff --git a/src/data/move.ts b/src/data/move.ts index 7e504e87667..60c5690ae44 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -908,7 +908,7 @@ export class AttackMove extends Move { attackScore = Math.pow(effectiveness - 1, 2) * effectiveness < 1 ? -2 : 2; if (attackScore) { if (this.category === MoveCategory.PHYSICAL) { - const atk = new Utils.IntegerHolder(user.getEffectiveStat(Stat.ATK, target)); + const atk = new Utils.NumberHolder(user.getEffectiveStat(Stat.ATK, target)); applyMoveAttrs(VariableAtkAttr, user, target, move, atk); if (atk.value > user.getEffectiveStat(Stat.SPATK, target)) { const statRatio = user.getEffectiveStat(Stat.SPATK, target) / atk.value; @@ -919,7 +919,7 @@ export class AttackMove extends Move { } } } else { - const spAtk = new Utils.IntegerHolder(user.getEffectiveStat(Stat.SPATK, target)); + const spAtk = new Utils.NumberHolder(user.getEffectiveStat(Stat.SPATK, target)); applyMoveAttrs(VariableAtkAttr, user, target, move, spAtk); if (spAtk.value > user.getEffectiveStat(Stat.ATK, target)) { const statRatio = user.getEffectiveStat(Stat.ATK, target) / spAtk.value; @@ -1337,7 +1337,7 @@ export class IgnoreOpponentStatStagesAttr extends MoveAttr { export class HighCritAttr extends MoveAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value++; + (args[0] as Utils.NumberHolder).value++; return true; } @@ -1369,7 +1369,7 @@ export class FixedDamageAttr extends MoveAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = this.getDamage(user, target, move); + (args[0] as Utils.NumberHolder).value = this.getDamage(user, target, move); return true; } @@ -1385,7 +1385,7 @@ export class UserHpDamageAttr extends FixedDamageAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = user.hp; + (args[0] as Utils.NumberHolder).value = user.hp; return true; } @@ -1437,7 +1437,7 @@ export class MatchHpAttr extends FixedDamageAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = target.hp - user.hp; + (args[0] as Utils.NumberHolder).value = target.hp - user.hp; return true; } @@ -1467,7 +1467,7 @@ export class CounterDamageAttr extends FixedDamageAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const damage = user.turnData.attacksReceived.filter(ar => this.moveFilter(allMoves[ar.move])).reduce((total: number, ar: AttackMoveResult) => total + ar.damage, 0); - (args[0] as Utils.IntegerHolder).value = Utils.toDmgValue(damage * this.multiplier); + (args[0] as Utils.NumberHolder).value = Utils.toDmgValue(damage * this.multiplier); return true; } @@ -1499,7 +1499,7 @@ export class RandomLevelDamageAttr extends FixedDamageAttr { export class ModifiedDamageAttr extends MoveAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const initialDamage = args[0] as Utils.IntegerHolder; + const initialDamage = args[0] as Utils.NumberHolder; initialDamage.value = this.getModifiedDamage(user, target, move, initialDamage.value); return true; @@ -2164,7 +2164,7 @@ export class IncrementMovePriorityAttr extends MoveAttr { * @param user {@linkcode Pokemon} using this move * @param target {@linkcode Pokemon} target of this move * @param move {@linkcode Move} being used - * @param args [0] {@linkcode Utils.IntegerHolder} for move priority. + * @param args [0] {@linkcode Utils.NumberHolder} for move priority. * @returns true if function succeeds */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -2172,7 +2172,7 @@ export class IncrementMovePriorityAttr extends MoveAttr { return false; } - (args[0] as Utils.IntegerHolder).value += this.increaseAmount; + (args[0] as Utils.NumberHolder).value += this.increaseAmount; return true; } } @@ -2210,7 +2210,7 @@ export class MultiHitAttr extends MoveAttr { * @param user {@linkcode Pokemon} that used the attack * @param target {@linkcode Pokemon} targeted by the attack * @param move {@linkcode Move} being used - * @param args [0] {@linkcode Utils.IntegerHolder} storing the hit count of the attack + * @param args [0] {@linkcode Utils.NumberHolder} storing the hit count of the attack * @returns True */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -2277,7 +2277,7 @@ export class ChangeMultiHitTypeAttr extends MoveAttr { export class WaterShurikenMultiHitTypeAttr extends ChangeMultiHitTypeAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { if (user.species.speciesId === Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex === 2) { - (args[0] as Utils.IntegerHolder).value = MultiHitType._3; + (args[0] as Utils.NumberHolder).value = MultiHitType._3; return true; } return false; @@ -4118,7 +4118,7 @@ export class PresentPowerAttr extends VariablePowerAttr { export class WaterShurikenPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { if (user.species.speciesId === Species.GRENINJA && user.hasAbility(Abilities.BATTLE_BOND) && user.formIndex === 2) { - (args[0] as Utils.IntegerHolder).value = 20; + (args[0] as Utils.NumberHolder).value = 20; return true; } return false; @@ -4140,7 +4140,7 @@ export class SpitUpPowerAttr extends VariablePowerAttr { const stockpilingTag = user.getTag(StockpilingTag); if (stockpilingTag && stockpilingTag.stockpiledCount > 0) { - const power = args[0] as Utils.IntegerHolder; + const power = args[0] as Utils.NumberHolder; power.value = this.multiplier * stockpilingTag.stockpiledCount; return true; } @@ -4449,7 +4449,7 @@ export class VariableAtkAttr extends MoveAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - //const atk = args[0] as Utils.IntegerHolder; + //const atk = args[0] as Utils.NumberHolder; return false; } } @@ -4459,7 +4459,7 @@ export class TargetAtkUserAtkAttr extends VariableAtkAttr { super(); } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = target.getEffectiveStat(Stat.ATK, target); + (args[0] as Utils.NumberHolder).value = target.getEffectiveStat(Stat.ATK, target); return true; } } @@ -4470,7 +4470,7 @@ export class DefAtkAttr extends VariableAtkAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = user.getEffectiveStat(Stat.DEF, target); + (args[0] as Utils.NumberHolder).value = user.getEffectiveStat(Stat.DEF, target); return true; } } @@ -4481,7 +4481,7 @@ export class VariableDefAttr extends MoveAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - //const def = args[0] as Utils.IntegerHolder; + //const def = args[0] as Utils.NumberHolder; return false; } } @@ -4492,7 +4492,7 @@ export class DefDefAttr extends VariableDefAttr { } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - (args[0] as Utils.IntegerHolder).value = target.getEffectiveStat(Stat.DEF, user); + (args[0] as Utils.NumberHolder).value = target.getEffectiveStat(Stat.DEF, user); return true; } } diff --git a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts index aa497e3c8fc..130c55c361e 100644 --- a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts +++ b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts @@ -10,7 +10,7 @@ import { HiddenAbilityRateBoosterModifier, IvScannerModifier } from "#app/modifi import type { EnemyPokemon } from "#app/field/pokemon"; import { PokeballType } from "#enums/pokeball"; import { PlayerGender } from "#enums/player-gender"; -import { IntegerHolder, randSeedInt } from "#app/utils"; +import { NumberHolder, randSeedInt } from "#app/utils"; import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { MoneyRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; @@ -279,7 +279,7 @@ async function summonSafariPokemon() { if (pokemon.species.abilityHidden) { const hiddenIndex = pokemon.species.ability2 ? 2 : 1; if (pokemon.abilityIndex < hiddenIndex) { - const hiddenAbilityChance = new IntegerHolder(256); + const hiddenAbilityChance = new NumberHolder(256); globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); diff --git a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts index e047a7a4f01..f7c70cb7052 100644 --- a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts +++ b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts @@ -12,7 +12,7 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import { PokemonMove } from "#app/field/pokemon"; -import { IntegerHolder, isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils"; +import { NumberHolder, isNullOrUndefined, randSeedInt, randSeedShuffle } from "#app/utils"; import type PokemonSpecies from "#app/data/pokemon-species"; import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species"; import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; @@ -452,7 +452,7 @@ async function postProcessTransformedPokemon(previousPokemon: PlayerPokemon, new if (newPokemon.species.abilityHidden) { const hiddenIndex = newPokemon.species.ability2 ? 2 : 1; if (newPokemon.abilityIndex < hiddenIndex) { - const hiddenAbilityChance = new IntegerHolder(256); + const hiddenAbilityChance = new NumberHolder(256); globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index dfce632ab06..1377f11187b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -204,7 +204,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { throw `Cannot create a player Pokemon for species '${species.getName(formIndex)}'`; } - const hiddenAbilityChance = new Utils.IntegerHolder(BASE_HIDDEN_ABILITY_CHANCE); + const hiddenAbilityChance = new Utils.NumberHolder(BASE_HIDDEN_ABILITY_CHANCE); if (!this.hasTrainer()) { globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance); } @@ -960,7 +960,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns the final critical-hit stage value */ getCritStage(source: Pokemon, move: Move): number { - const critStage = new Utils.IntegerHolder(0); + const critStage = new Utils.NumberHolder(0); applyMoveAttrs(HighCritAttr, source, this, move, critStage); globalScene.applyModifiers(CritBoosterModifier, source.isPlayer(), source, critStage); globalScene.applyModifiers(TempCritBoosterModifier, source.isPlayer(), critStage); @@ -1074,7 +1074,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const baseStats = this.calculateBaseStats(); // Using base stats, calculate and store stats one by one for (const s of PERMANENT_STATS) { - const statHolder = new Utils.IntegerHolder(Math.floor(((2 * baseStats[s] + this.ivs[s]) * this.level) * 0.01)); + const statHolder = new Utils.NumberHolder(Math.floor(((2 * baseStats[s] + this.ivs[s]) * this.level) * 0.01)); if (s === Stat.HP) { statHolder.value = statHolder.value + this.level + 10; globalScene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder); @@ -2567,7 +2567,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @return the stat stage multiplier to be used for effective stat calculation */ getStatStageMultiplier(stat: EffectiveStat, opponent?: Pokemon, move?: Move, ignoreOppAbility: boolean = false, isCritical: boolean = false, simulated: boolean = true, ignoreHeldItems: boolean = false): number { - const statStage = new Utils.IntegerHolder(this.getStatStage(stat)); + const statStage = new Utils.NumberHolder(this.getStatStage(stat)); const ignoreStatStage = new Utils.BooleanHolder(false); if (opponent) { @@ -2617,8 +2617,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return 1; } - const userAccStage = new Utils.IntegerHolder(this.getStatStage(Stat.ACC)); - const targetEvaStage = new Utils.IntegerHolder(target.getStatStage(Stat.EVA)); + const userAccStage = new Utils.NumberHolder(this.getStatStage(Stat.ACC)); + const targetEvaStage = new Utils.NumberHolder(target.getStatStage(Stat.EVA)); const ignoreAccStatStage = new Utils.BooleanHolder(false); const ignoreEvaStatStage = new Utils.BooleanHolder(false); @@ -2797,7 +2797,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } /** Doubles damage if this Pokemon's last move was Glaive Rush */ - const glaiveRushMultiplier = new Utils.IntegerHolder(1); + const glaiveRushMultiplier = new Utils.NumberHolder(1); if (this.getTag(BattlerTagType.RECEIVE_DOUBLE_DAMAGE)) { glaiveRushMultiplier.value = 2; } diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 35ed75d8c6e..30ad287fd98 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1186,11 +1186,11 @@ class FormChangeItemModifierTypeGenerator extends ModifierTypeGenerator { if (p.species.speciesId === Species.NECROZMA) { // technically we could use a simplified version and check for formChanges.length > 3, but in case any code changes later, this might break... - let foundULTRA_Z = false, foundN_LUNA = false, foundN_SOLAR = false; formChangeItemTriggers.forEach((fc, _i) => { + console.log("Checking ", fc.item); switch (fc.item) { case FormChangeItem.ULTRANECROZIUM_Z: foundULTRA_Z = true; @@ -1206,6 +1206,8 @@ class FormChangeItemModifierTypeGenerator extends ModifierTypeGenerator { if (foundULTRA_Z && foundN_LUNA && foundN_SOLAR) { // all three items are present -> user hasn't acquired any of the N_*ARIZERs -> block ULTRANECROZIUM_Z acquisition. formChangeItemTriggers = formChangeItemTriggers.filter(fc => fc.item !== FormChangeItem.ULTRANECROZIUM_Z); + } else { + console.log("DID NOT FIND "); } } return formChangeItemTriggers; diff --git a/src/phases/money-reward-phase.ts b/src/phases/money-reward-phase.ts index 70f0019227c..f460f89a72a 100644 --- a/src/phases/money-reward-phase.ts +++ b/src/phases/money-reward-phase.ts @@ -15,7 +15,7 @@ export class MoneyRewardPhase extends BattlePhase { } start() { - const moneyAmount = new Utils.IntegerHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier)); + const moneyAmount = new Utils.NumberHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier)); globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index a544d47df70..6d0621b8f48 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -62,7 +62,7 @@ export class PokemonHealPhase extends CommonAnimPhase { this.message = null; return super.end(); } else if (healOrDamage) { - const hpRestoreMultiplier = new Utils.IntegerHolder(1); + const hpRestoreMultiplier = new Utils.NumberHolder(1); if (!this.revive) { globalScene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier); } diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 3b9a0a0405c..a3a2fa1aa24 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -45,7 +45,7 @@ export class SelectModifierPhase extends BattlePhase { if (!this.isCopy) { regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount); } - const modifierCount = new Utils.IntegerHolder(3); + const modifierCount = new Utils.NumberHolder(3); if (this.isPlayer()) { globalScene.applyModifiers(ExtraModifierModifier, true, modifierCount); globalScene.applyModifiers(TempExtraModifierModifier, true, modifierCount); diff --git a/src/test/achievements/achievement.test.ts b/src/test/achievements/achievement.test.ts index b515c6bafa8..2d1cc50603e 100644 --- a/src/test/achievements/achievement.test.ts +++ b/src/test/achievements/achievement.test.ts @@ -1,6 +1,6 @@ import { TurnHeldItemTransferModifier } from "#app/modifier/modifier"; import { Achv, AchvTier, DamageAchv, HealAchv, LevelAchv, ModifierAchv, MoneyAchv, RibbonAchv, achvs } from "#app/system/achv"; -import { IntegerHolder, NumberHolder } from "#app/utils"; +import { NumberHolder } from "#app/utils"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -174,7 +174,7 @@ describe("LevelAchv", () => { it("should validate the achievement based on the level", () => { const levelAchv = new LevelAchv("", "Test Level Achievement", 100, "level_icon", 10); - const integerHolder = new IntegerHolder(50); + const integerHolder = new NumberHolder(50); expect(levelAchv.validate([ integerHolder ])).toBe(false); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index a3508532631..76d02c191bb 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -14,7 +14,7 @@ import * as Utils from "./../utils"; import Overrides from "#app/overrides"; import i18next from "i18next"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; -import { IntegerHolder } from "./../utils"; +import { NumberHolder } from "./../utils"; import Phaser from "phaser"; import type { PokeballType } from "#enums/pokeball"; @@ -191,7 +191,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { const typeOptions = args[1] as ModifierTypeOption[]; const removeHealShop = globalScene.gameMode.hasNoShop; - const baseShopCost = new IntegerHolder(globalScene.getWaveMoneyAmount(1)); + const baseShopCost = new NumberHolder(globalScene.getWaveMoneyAmount(1)); globalScene.applyModifier(HealShopCostModifier, true, baseShopCost); const shopTypeOptions = !removeHealShop ? getPlayerShopModifierTypeOptionsForWave(globalScene.currentBattle.waveIndex, baseShopCost.value) diff --git a/src/utils.ts b/src/utils.ts index a906ee76391..56df3f3f48e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -342,13 +342,6 @@ export class NumberHolder { } } -/** @deprecated Use {@linkcode NumberHolder} */ -export class IntegerHolder extends NumberHolder { - constructor(value: number) { - super(value); - } -} - export class FixedInt { public readonly value: number;