From 989e4b37f4959e132dbb88642853fbe9f564f8ed Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 28 Oct 2023 18:38:22 -0400 Subject: [PATCH] Fix negative EXP level cap bug --- src/battle-scene.ts | 4 +++- src/modifier/modifier.ts | 2 +- src/ui/battle-info.ts | 2 +- src/ui/summary-ui-handler.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 7a90445f5..a2a7b6e65 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -791,7 +791,9 @@ export default class BattleScene extends Phaser.Scene { this.partyExpBar.setY(this.moneyText.y + 15); } - getMaxExpLevel(): integer { + getMaxExpLevel(ignoreLevelCap?: boolean): integer { + if (ignoreLevelCap) + return 10000; const lastWaveIndex = Math.ceil((this.currentBattle?.waveIndex || 1) / 10) * 10; const baseLevel = (1 + lastWaveIndex / 2 + Math.pow(lastWaveIndex / 25, 2)) * 1.2; return Math.min(Math.ceil(baseLevel / 2) * 2 + 2, 10000); diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 4ac8eb57e..f39df21a4 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -832,7 +832,7 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier { pokemon.scene.applyModifiers(LevelIncrementBoosterModifier, true, levelCount); pokemon.level += levelCount.value; - if (pokemon.level <= pokemon.scene.getMaxExpLevel()) { + if (pokemon.level <= pokemon.scene.getMaxExpLevel(true)) { pokemon.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate); pokemon.levelExp = 0; } diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index c52f6c96f..9077ea948 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -264,7 +264,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const relLevelExp = getLevelRelExp(this.lastLevel + 1, battler.species.growthRate); const levelExp = levelUp ? relLevelExp : battler.levelExp; let ratio = relLevelExp ? levelExp / relLevelExp : 0; - if (this.lastLevel >= (this.scene as BattleScene).getMaxExpLevel()) { + if (this.lastLevel >= (this.scene as BattleScene).getMaxExpLevel(true)) { if (levelUp) ratio = 1; else diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 7f3ad246a..8acd54ee2 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -538,7 +538,7 @@ export default class SummaryUiHandler extends UiHandler { statsContainer.add(expText); const nextLvExp = this.pokemon.level < this.scene.getMaxExpLevel() - ? getLevelTotalExp(this.pokemon.level + 1, this.pokemon.species.growthRate) - this.pokemon.levelExp + ? getLevelTotalExp(this.pokemon.level + 1, this.pokemon.species.growthRate) - this.pokemon.exp : 0; const nextLvExpText = addTextObject(this.scene, 208, 128, nextLvExp.toString(), TextStyle.WINDOW); nextLvExpText.setOrigin(1, 0);