mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 23:05:23 +01:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { Phase } from "#app/phase";
|
|
import type { EggHatchData } from "#data/egg-hatch-data";
|
|
import { UiMode } from "#enums/ui-mode";
|
|
|
|
/**
|
|
* Class that represents the egg summary phase
|
|
* It does some of the function for updating egg data
|
|
* Phase is handled mostly by the egg-hatch-scene-handler UI
|
|
*/
|
|
export class EggSummaryPhase extends Phase {
|
|
public readonly phaseName = "EggSummaryPhase";
|
|
private eggHatchData: EggHatchData[];
|
|
|
|
constructor(eggHatchData: EggHatchData[]) {
|
|
super();
|
|
this.eggHatchData = eggHatchData;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
// updates next pokemon once the current update has been completed
|
|
const updateNextPokemon = (i: number) => {
|
|
if (i >= this.eggHatchData.length) {
|
|
globalScene.ui.setModeForceTransition(UiMode.EGG_HATCH_SUMMARY, this.eggHatchData).then(() => {
|
|
globalScene.fadeOutBgm(undefined, false);
|
|
});
|
|
} else {
|
|
this.eggHatchData[i].setDex();
|
|
this.eggHatchData[i].updatePokemon().then(() => {
|
|
if (i < this.eggHatchData.length) {
|
|
updateNextPokemon(i + 1);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
updateNextPokemon(0);
|
|
}
|
|
|
|
end() {
|
|
this.eggHatchData.forEach(data => {
|
|
data.pokemon?.destroy();
|
|
});
|
|
this.eggHatchData = [];
|
|
globalScene.time.delayedCall(250, () => globalScene.setModifiersVisible(true));
|
|
globalScene.ui.setModeForceTransition(UiMode.MESSAGE).then(() => {
|
|
super.end();
|
|
});
|
|
}
|
|
}
|