mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-17 23:35:22 +01:00
https://github.com/pagefaultgames/pokerogue/pull/5955 * Add newPhase method to phase-manager * Update calls to append/prepend phase to use string phase * Replace instantiations of new phase with phase manager
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { Phase } from "#app/phase";
|
|
import type { EndCardPhase } from "./end-card-phase";
|
|
|
|
export class PostGameOverPhase extends Phase {
|
|
public readonly phaseName = "PostGameOverPhase";
|
|
private endCardPhase?: EndCardPhase;
|
|
|
|
constructor(endCardPhase?: EndCardPhase) {
|
|
super();
|
|
|
|
this.endCardPhase = endCardPhase;
|
|
}
|
|
|
|
start() {
|
|
super.start();
|
|
|
|
const saveAndReset = () => {
|
|
globalScene.gameData.saveAll(true, true, true).then(success => {
|
|
if (!success) {
|
|
return globalScene.reset(true);
|
|
}
|
|
globalScene.gameData
|
|
.tryClearSession(globalScene.sessionSlotId)
|
|
.then((success: boolean | [boolean, boolean]) => {
|
|
if (!success[0]) {
|
|
return globalScene.reset(true);
|
|
}
|
|
globalScene.reset();
|
|
globalScene.phaseManager.unshiftNew("TitlePhase");
|
|
this.end();
|
|
});
|
|
});
|
|
};
|
|
|
|
if (this.endCardPhase) {
|
|
globalScene.ui.fadeOut(500).then(() => {
|
|
globalScene.ui.getMessageHandler().bg.setVisible(true);
|
|
|
|
this.endCardPhase?.endCard.destroy();
|
|
this.endCardPhase?.text.destroy();
|
|
saveAndReset();
|
|
});
|
|
} else {
|
|
saveAndReset();
|
|
}
|
|
}
|
|
}
|