From 2dd8aaf31aa414c241153478636d04ee54ae456f Mon Sep 17 00:00:00 2001 From: ReneGV Date: Sat, 29 Jun 2024 11:52:30 -0600 Subject: [PATCH] [miscellaneous] Create single variable for max pokeballs (#2698) * Configure max pokeballs * Rename variable --- src/data/pokeball.ts | 2 ++ src/modifier/modifier-type.ts | 6 ++---- src/modifier/modifier.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/pokeball.ts b/src/data/pokeball.ts index 0399e383820..5964884d967 100644 --- a/src/data/pokeball.ts +++ b/src/data/pokeball.ts @@ -10,6 +10,8 @@ export enum PokeballType { LUXURY_BALL } +export const MAX_PER_TYPE_POKEBALLS: integer = 99; + export function getPokeballAtlasKey(type: PokeballType): string { switch (type) { case PokeballType.POKEBALL: diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index d17a12c67ee..f86a1846a61 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1,6 +1,6 @@ import * as Modifiers from "./modifier"; import { AttackMove, allMoves } from "../data/move"; -import { PokeballType, getPokeballCatchMultiplier, getPokeballName } from "../data/pokeball"; +import { MAX_PER_TYPE_POKEBALLS, PokeballType, getPokeballCatchMultiplier, getPokeballName } from "../data/pokeball"; import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "../field/pokemon"; import { EvolutionItem, pokemonEvolutions } from "../data/pokemon-evolutions"; import { Stat, getStatName } from "../data/pokemon-stat"; @@ -1362,8 +1362,6 @@ interface ModifierPool { [tier: string]: WeightedModifierType[] } -const MAX_BALLS = 99; - /** * Used to check if the player has max of a given ball type in Classic * @param party The player's party, just used to access the scene @@ -1371,7 +1369,7 @@ const MAX_BALLS = 99; * @returns boolean: true if the player has the maximum of a given ball type */ function hasMaximumBalls(party: Pokemon[], ballType: PokeballType): boolean { - return (party[0].scene.gameMode.isClassic && party[0].scene.pokeballCounts[ballType] >= MAX_BALLS); + return (party[0].scene.gameMode.isClassic && party[0].scene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS); } const modifierPool: ModifierPool = { diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 946b381b7f8..b680cdd41c4 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -2,7 +2,7 @@ import * as ModifierTypes from "./modifier-type"; import { LearnMovePhase, LevelUpPhase, PokemonHealPhase } from "../phases"; import BattleScene from "../battle-scene"; import { getLevelTotalExp } from "../data/exp"; -import { PokeballType } from "../data/pokeball"; +import { MAX_PER_TYPE_POKEBALLS, PokeballType } from "../data/pokeball"; import Pokemon, { PlayerPokemon } from "../field/pokemon"; import { Stat } from "../data/pokemon-stat"; import { addTextObject, TextStyle } from "../ui/text"; @@ -263,7 +263,7 @@ export class AddPokeballModifier extends ConsumableModifier { apply(args: any[]): boolean { const pokeballCounts = (args[0] as BattleScene).pokeballCounts; - pokeballCounts[this.pokeballType] = Math.min(pokeballCounts[this.pokeballType] + this.count, 99); + pokeballCounts[this.pokeballType] = Math.min(pokeballCounts[this.pokeballType] + this.count, MAX_PER_TYPE_POKEBALLS); return true; }