[QoL] Don't offer ball rewards when you have max in Classic mode (#1677)

* Don't offer ball rewards past floor 189

* Remove balls from reward pool when you have max

* Change only applies to classic

* Function to weigh the player's balls

* Documented hasMaxBalls function

* More specific comment
This commit is contained in:
AJ Fontaine 2024-06-28 12:11:52 -04:00 committed by GitHub
parent cd73c37d4b
commit 96f72eae2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 5 deletions

View File

@ -1362,9 +1362,21 @@ 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
* @param ballType The {@linkcode PokeballType} being checked
* @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);
}
const modifierPool: ModifierPool = {
[ModifierTier.COMMON]: [
new WeightedModifierType(modifierTypes.POKEBALL, 6),
new WeightedModifierType(modifierTypes.POKEBALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.POKEBALL)) ? 0 : 6, 6),
new WeightedModifierType(modifierTypes.RARE_CANDY, 2),
new WeightedModifierType(modifierTypes.POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => (p.getInverseHp() >= 10 || p.getHpRatio() <= 0.875) && !p.isFainted()).length, 3);
@ -1390,7 +1402,7 @@ const modifierPool: ModifierPool = {
m.setTier(ModifierTier.COMMON); return m;
}),
[ModifierTier.GREAT]: [
new WeightedModifierType(modifierTypes.GREAT_BALL, 6),
new WeightedModifierType(modifierTypes.GREAT_BALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.GREAT_BALL)) ? 0 : 6, 6),
new WeightedModifierType(modifierTypes.PP_UP, 2),
new WeightedModifierType(modifierTypes.FULL_HEAL, (party: Pokemon[]) => {
const statusEffectPartyMemberCount = Math.min(party.filter(p => p.hp && !!p.status && !p.getHeldItems().some(i => {
@ -1461,7 +1473,7 @@ const modifierPool: ModifierPool = {
m.setTier(ModifierTier.GREAT); return m;
}),
[ModifierTier.ULTRA]: [
new WeightedModifierType(modifierTypes.ULTRA_BALL, 15),
new WeightedModifierType(modifierTypes.ULTRA_BALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.ULTRA_BALL)) ? 0 : 15, 15),
new WeightedModifierType(modifierTypes.MAX_LURE, 4),
new WeightedModifierType(modifierTypes.BIG_NUGGET, skipInLastClassicWaveOrDefault(12)),
new WeightedModifierType(modifierTypes.PP_MAX, 3),
@ -1499,7 +1511,7 @@ const modifierPool: ModifierPool = {
m.setTier(ModifierTier.ULTRA); return m;
}),
[ModifierTier.ROGUE]: [
new WeightedModifierType(modifierTypes.ROGUE_BALL, 16),
new WeightedModifierType(modifierTypes.ROGUE_BALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.ROGUE_BALL)) ? 0 : 16, 16),
new WeightedModifierType(modifierTypes.RELIC_GOLD, skipInLastClassicWaveOrDefault(2)),
new WeightedModifierType(modifierTypes.LEFTOVERS, 3),
new WeightedModifierType(modifierTypes.SHELL_BELL, 3),
@ -1522,7 +1534,7 @@ const modifierPool: ModifierPool = {
m.setTier(ModifierTier.ROGUE); return m;
}),
[ModifierTier.MASTER]: [
new WeightedModifierType(modifierTypes.MASTER_BALL, 24),
new WeightedModifierType(modifierTypes.MASTER_BALL, (party: Pokemon[]) => (hasMaximumBalls(party, PokeballType.MASTER_BALL)) ? 0 : 24, 24),
new WeightedModifierType(modifierTypes.SHINY_CHARM, 14),
new WeightedModifierType(modifierTypes.HEALING_CHARM, 18),
new WeightedModifierType(modifierTypes.MULTI_LENS, 18),