pokerogue/src/phases/select-gender-phase.ts
NightKev 0107b1d47e
[Refactor] Create global scene variable (#4766)
* 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>
2025-01-12 15:33:05 -08:00

47 lines
1.3 KiB
TypeScript

import { globalScene } from "#app/global-scene";
import { PlayerGender } from "#app/enums/player-gender";
import { Phase } from "#app/phase";
import { SettingKeys } from "#app/system/settings/settings";
import { Mode } from "#app/ui/ui";
import i18next from "i18next";
export class SelectGenderPhase extends Phase {
constructor() {
super();
}
start(): void {
super.start();
globalScene.ui.showText(i18next.t("menu:boyOrGirl"), null, () => {
globalScene.ui.setMode(Mode.OPTION_SELECT, {
options: [
{
label: i18next.t("settings:boy"),
handler: () => {
globalScene.gameData.gender = PlayerGender.MALE;
globalScene.gameData.saveSetting(SettingKeys.Player_Gender, 0);
globalScene.gameData.saveSystem().then(() => this.end());
return true;
}
},
{
label: i18next.t("settings:girl"),
handler: () => {
globalScene.gameData.gender = PlayerGender.FEMALE;
globalScene.gameData.saveSetting(SettingKeys.Player_Gender, 1);
globalScene.gameData.saveSystem().then(() => this.end());
return true;
}
}
]
});
});
}
end(): void {
globalScene.ui.setMode(Mode.MESSAGE);
super.end();
}
}