adapt learn-move-phase to async-await

This commit is contained in:
flx-sta 2024-09-05 11:50:11 -07:00
parent e5fb9d63aa
commit 4148c84f30

View File

@ -55,19 +55,20 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
* @param move The Move to be learned * @param move The Move to be learned
* @param Pokemon The Pokemon learning the move * @param Pokemon The Pokemon learning the move
*/ */
replaceMoveCheck(move: Move, pokemon: Pokemon) { async replaceMoveCheck(move: Move, pokemon: Pokemon) {
const learnMovePrompt = i18next.t("battle:learnMovePrompt", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name }); const learnMovePrompt = i18next.t("battle:learnMovePrompt", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: move.name });
const moveLimitReached = i18next.t("battle:learnMoveLimitReached", { pokemonName: getPokemonNameWithAffix(pokemon) }); const moveLimitReached = i18next.t("battle:learnMoveLimitReached", { pokemonName: getPokemonNameWithAffix(pokemon) });
const shouldReplaceQ = i18next.t("battle:learnMoveReplaceQuestion", { moveName: move.name }); const shouldReplaceQ = i18next.t("battle:learnMoveReplaceQuestion", { moveName: move.name });
const preQText = [learnMovePrompt, moveLimitReached].join("$"); const preQText = [learnMovePrompt, moveLimitReached].join("$");
this.scene.ui.showTextPromise(preQText) await this.scene.ui.showTextPromise(preQText);
.then(() => this.scene.ui.showTextPromise(shouldReplaceQ, undefined, false)) await this.scene.ui.showTextPromise(shouldReplaceQ, undefined, false);
.then(() => this.scene.ui.setModeWithoutClear(Mode.CONFIRM, await this.scene.ui.setModeWithoutClear(Mode.CONFIRM,
() => this.forgetMoveProcess(move, pokemon), // Yes () => this.forgetMoveProcess(move, pokemon), // Yes
() => { // No () => { // No
this.scene.ui.setMode(this.messageMode); this.scene.ui.setMode(this.messageMode);
this.rejectMoveAndEnd(move, pokemon); this.rejectMoveAndEnd(move, pokemon);
})); }
);
} }
/** /**
@ -81,11 +82,10 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
* @param move The Move to be learned * @param move The Move to be learned
* @param Pokemon The Pokemon learning the move * @param Pokemon The Pokemon learning the move
*/ */
forgetMoveProcess(move: Move, pokemon: Pokemon) { async forgetMoveProcess(move: Move, pokemon: Pokemon) {
this.scene.ui.setMode(this.messageMode); this.scene.ui.setMode(this.messageMode);
this.scene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true) await this.scene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true);
.then(() => { await this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => {
this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => {
if (moveIndex === 4) { if (moveIndex === 4) {
this.scene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon)); this.scene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon));
return; return;
@ -94,7 +94,6 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
const fullText = [i18next.t("battle:countdownPoof"), forgetSuccessText, i18next.t("battle:learnMoveAnd")].join("$"); const fullText = [i18next.t("battle:countdownPoof"), forgetSuccessText, i18next.t("battle:learnMoveAnd")].join("$");
this.scene.ui.setMode(this.messageMode).then(() => this.learnMove(moveIndex, move, pokemon, fullText)); this.scene.ui.setMode(this.messageMode).then(() => this.learnMove(moveIndex, move, pokemon, fullText));
}); });
});
} }
/** /**
@ -107,8 +106,8 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
* @param move The Move to be learned * @param move The Move to be learned
* @param Pokemon The Pokemon learning the move * @param Pokemon The Pokemon learning the move
*/ */
rejectMoveAndEnd(move: Move, pokemon: Pokemon) { async rejectMoveAndEnd(move: Move, pokemon: Pokemon) {
this.scene.ui.showTextPromise(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), undefined, false).then(()=> { await this.scene.ui.showTextPromise(i18next.t("battle:learnMoveStopTeaching", { moveName: move.name }), undefined, false);
this.scene.ui.setModeWithoutClear(Mode.CONFIRM, this.scene.ui.setModeWithoutClear(Mode.CONFIRM,
() => { () => {
this.scene.ui.setMode(this.messageMode); this.scene.ui.setMode(this.messageMode);
@ -119,7 +118,6 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
this.replaceMoveCheck(move, pokemon); this.replaceMoveCheck(move, pokemon);
} }
); );
});
} }
/** /**