mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-21 12:35:59 +02:00
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { ExpBoosterModifier } from "#app/modifier/modifier";
|
|
import i18next from "i18next";
|
|
import * as Utils from "#app/utils";
|
|
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
|
|
import { LevelUpPhase } from "./level-up-phase";
|
|
|
|
export class ExpPhase extends PlayerPartyMemberPokemonPhase {
|
|
private expValue: number;
|
|
|
|
constructor(partyMemberIndex: number, expValue: number) {
|
|
super(partyMemberIndex);
|
|
|
|
this.expValue = expValue;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
const pokemon = this.getPokemon();
|
|
const exp = new Utils.NumberHolder(this.expValue);
|
|
globalScene.applyModifiers(ExpBoosterModifier, true, exp);
|
|
exp.value = Math.floor(exp.value);
|
|
globalScene.ui.showText(
|
|
i18next.t("battle:expGain", {
|
|
pokemonName: getPokemonNameWithAffix(pokemon),
|
|
exp: exp.value,
|
|
}),
|
|
null,
|
|
() => {
|
|
const lastLevel = pokemon.level;
|
|
pokemon.addExp(exp.value);
|
|
const newLevel = pokemon.level;
|
|
if (newLevel > lastLevel) {
|
|
globalScene.unshiftPhase(new LevelUpPhase(this.partyMemberIndex, lastLevel, newLevel));
|
|
}
|
|
pokemon.updateInfo().then(() => this.end());
|
|
},
|
|
null,
|
|
true,
|
|
);
|
|
}
|
|
}
|