Fix negative EXP level cap bug

This commit is contained in:
Flashfyre 2023-10-28 18:38:22 -04:00
parent f831f3ab75
commit 989e4b37f4
4 changed files with 6 additions and 4 deletions

View File

@ -791,7 +791,9 @@ export default class BattleScene extends Phaser.Scene {
this.partyExpBar.setY(this.moneyText.y + 15); 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 lastWaveIndex = Math.ceil((this.currentBattle?.waveIndex || 1) / 10) * 10;
const baseLevel = (1 + lastWaveIndex / 2 + Math.pow(lastWaveIndex / 25, 2)) * 1.2; const baseLevel = (1 + lastWaveIndex / 2 + Math.pow(lastWaveIndex / 25, 2)) * 1.2;
return Math.min(Math.ceil(baseLevel / 2) * 2 + 2, 10000); return Math.min(Math.ceil(baseLevel / 2) * 2 + 2, 10000);

View File

@ -832,7 +832,7 @@ export class PokemonLevelIncrementModifier extends ConsumablePokemonModifier {
pokemon.scene.applyModifiers(LevelIncrementBoosterModifier, true, levelCount); pokemon.scene.applyModifiers(LevelIncrementBoosterModifier, true, levelCount);
pokemon.level += levelCount.value; 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.exp = getLevelTotalExp(pokemon.level, pokemon.species.growthRate);
pokemon.levelExp = 0; pokemon.levelExp = 0;
} }

View File

@ -264,7 +264,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
const relLevelExp = getLevelRelExp(this.lastLevel + 1, battler.species.growthRate); const relLevelExp = getLevelRelExp(this.lastLevel + 1, battler.species.growthRate);
const levelExp = levelUp ? relLevelExp : battler.levelExp; const levelExp = levelUp ? relLevelExp : battler.levelExp;
let ratio = relLevelExp ? levelExp / relLevelExp : 0; 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) if (levelUp)
ratio = 1; ratio = 1;
else else

View File

@ -538,7 +538,7 @@ export default class SummaryUiHandler extends UiHandler {
statsContainer.add(expText); statsContainer.add(expText);
const nextLvExp = this.pokemon.level < this.scene.getMaxExpLevel() 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; : 0;
const nextLvExpText = addTextObject(this.scene, 208, 128, nextLvExp.toString(), TextStyle.WINDOW); const nextLvExpText = addTextObject(this.scene, 208, 128, nextLvExp.toString(), TextStyle.WINDOW);
nextLvExpText.setOrigin(1, 0); nextLvExpText.setOrigin(1, 0);