mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-28 06:56:00 +01:00
* Replace various `scene` pass-arounds with global scene variable * Modify tests * Add scene back to `fade[in|out]()` calls Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Fix Bug Superfan ME test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Re-enable fixed test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Rename `gScene` to `globalScene` * Move `globalScene` to its own file to fix import/async issues * Fix `SelectModifierPhase` tests * Fix ME tests by removing `scene` from `expect()`s * Resolve merge issues * Remove tsdocs referencing `scene` params Remove missed instances of `.scene` * Remove unnecessary `globalScene` usage in `loading-scene.ts` * Fix merge conflicts * Attempt to fix circular import issue * Found the source of the import issue * Fix merge issues --------- Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { Phase } from "#app/phase";
|
|
import type { EndCardPhase } from "./end-card-phase";
|
|
import { TitlePhase } from "./title-phase";
|
|
|
|
export class PostGameOverPhase extends Phase {
|
|
private endCardPhase: EndCardPhase | null;
|
|
|
|
constructor(endCardPhase?: EndCardPhase) {
|
|
super();
|
|
|
|
this.endCardPhase = endCardPhase!; // TODO: is this bang correct?
|
|
}
|
|
|
|
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.unshiftPhase(new 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();
|
|
}
|
|
}
|
|
}
|