[miscellaneous] Create single variable for max pokeballs (#2698)

* Configure max pokeballs

* Rename variable
This commit is contained in:
ReneGV 2024-06-29 11:52:30 -06:00 committed by GitHub
parent fd586ecd8e
commit 2dd8aaf31a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -10,6 +10,8 @@ export enum PokeballType {
LUXURY_BALL LUXURY_BALL
} }
export const MAX_PER_TYPE_POKEBALLS: integer = 99;
export function getPokeballAtlasKey(type: PokeballType): string { export function getPokeballAtlasKey(type: PokeballType): string {
switch (type) { switch (type) {
case PokeballType.POKEBALL: case PokeballType.POKEBALL:

View File

@ -1,6 +1,6 @@
import * as Modifiers from "./modifier"; import * as Modifiers from "./modifier";
import { AttackMove, allMoves } from "../data/move"; 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 Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "../field/pokemon";
import { EvolutionItem, pokemonEvolutions } from "../data/pokemon-evolutions"; import { EvolutionItem, pokemonEvolutions } from "../data/pokemon-evolutions";
import { Stat, getStatName } from "../data/pokemon-stat"; import { Stat, getStatName } from "../data/pokemon-stat";
@ -1362,8 +1362,6 @@ interface ModifierPool {
[tier: string]: WeightedModifierType[] [tier: string]: WeightedModifierType[]
} }
const MAX_BALLS = 99;
/** /**
* Used to check if the player has max of a given ball type in Classic * 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 * @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 * @returns boolean: true if the player has the maximum of a given ball type
*/ */
function hasMaximumBalls(party: Pokemon[], ballType: PokeballType): boolean { 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 = { const modifierPool: ModifierPool = {

View File

@ -2,7 +2,7 @@ import * as ModifierTypes from "./modifier-type";
import { LearnMovePhase, LevelUpPhase, PokemonHealPhase } from "../phases"; import { LearnMovePhase, LevelUpPhase, PokemonHealPhase } from "../phases";
import BattleScene from "../battle-scene"; import BattleScene from "../battle-scene";
import { getLevelTotalExp } from "../data/exp"; 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 Pokemon, { PlayerPokemon } from "../field/pokemon";
import { Stat } from "../data/pokemon-stat"; import { Stat } from "../data/pokemon-stat";
import { addTextObject, TextStyle } from "../ui/text"; import { addTextObject, TextStyle } from "../ui/text";
@ -263,7 +263,7 @@ export class AddPokeballModifier extends ConsumableModifier {
apply(args: any[]): boolean { apply(args: any[]): boolean {
const pokeballCounts = (args[0] as BattleScene).pokeballCounts; 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; return true;
} }