pokerogue/src/phases/egg-summary-phase.ts
Sirz Benjie 5854b21da0
[Refactor] Remove circular imports part 1 (#5663)
* Extract Mode enum out of UI and into its own file

Reduces circular imports from 909 to 773

* Move around utility files

Reduces cyclical dependencies from 773 to 765

* Remove starterColors and bypassLogin from battle-scene

Reduces cyclical dependencies from 765 to 623

* Fix test runner error

* Update import for bypassLogin in test

* Update mocks for utils in tests

* Fix broken tests

* Update selectWithTera override

* Update path for utils in ab-attr.ts

* Update path for utils in ability-class.ts

* Fix utils import path in healer.test.ts
2025-04-19 11:57:03 +00:00

47 lines
1.3 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { Phase } from "#app/phase";
import { UiMode } from "#enums/ui-mode";
import type { EggHatchData } from "#app/data/egg-hatch-data";
/**
* 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 {
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() {
globalScene.time.delayedCall(250, () => globalScene.setModifiersVisible(true));
globalScene.ui.setModeForceTransition(UiMode.MESSAGE).then(() => {
super.end();
});
}
}