Changed variable name to isVictory.

This commit is contained in:
frutescens 2024-11-09 15:01:48 -08:00
parent f649295cf0
commit 09b6afbd38
3 changed files with 16 additions and 16 deletions

View File

@ -8,7 +8,7 @@ export class UpdateSessionSavedataRequest {
/** This is **NOT** similar to {@linkcode ClearSessionSavedataRequest} */ /** This is **NOT** similar to {@linkcode ClearSessionSavedataRequest} */
export interface NewClearSessionSavedataRequest { export interface NewClearSessionSavedataRequest {
slot: number; slot: number;
result: boolean; isVictory: boolean;
clientSessionId: string; clientSessionId: string;
} }

View File

@ -26,13 +26,13 @@ import i18next from "i18next";
import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
export class GameOverPhase extends BattlePhase { export class GameOverPhase extends BattlePhase {
private victory: boolean; private isVictory: boolean;
private firstRibbons: PokemonSpecies[] = []; private firstRibbons: PokemonSpecies[] = [];
constructor(scene: BattleScene, victory?: boolean) { constructor(scene: BattleScene, victory?: boolean) {
super(scene); super(scene);
this.victory = !!victory; this.isVictory = !!victory;
} }
start() { start() {
@ -40,22 +40,22 @@ export class GameOverPhase extends BattlePhase {
// Failsafe if players somehow skip floor 200 in classic mode // Failsafe if players somehow skip floor 200 in classic mode
if (this.scene.gameMode.isClassic && this.scene.currentBattle.waveIndex > 200) { if (this.scene.gameMode.isClassic && this.scene.currentBattle.waveIndex > 200) {
this.victory = true; this.isVictory = true;
} }
// Handle Mystery Encounter special Game Over cases // Handle Mystery Encounter special Game Over cases
// Situations such as when player lost a battle, but it isn't treated as full Game Over // Situations such as when player lost a battle, but it isn't treated as full Game Over
if (!this.victory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) { if (!this.isVictory && this.scene.currentBattle.mysteryEncounter?.onGameOver && !this.scene.currentBattle.mysteryEncounter.onGameOver(this.scene)) {
// Do not end the game // Do not end the game
return this.end(); return this.end();
} }
// Otherwise, continue standard Game Over logic // Otherwise, continue standard Game Over logic
if (this.victory && this.scene.gameMode.isEndless) { if (this.isVictory && this.scene.gameMode.isEndless) {
const genderIndex = this.scene.gameData.gender ?? PlayerGender.UNSET; const genderIndex = this.scene.gameData.gender ?? PlayerGender.UNSET;
const genderStr = PlayerGender[genderIndex].toLowerCase(); const genderStr = PlayerGender[genderIndex].toLowerCase();
this.scene.ui.showDialogue(i18next.t("miscDialogue:ending_endless", { context: genderStr }), i18next.t("miscDialogue:ending_name"), 0, () => this.handleGameOver()); this.scene.ui.showDialogue(i18next.t("miscDialogue:ending_endless", { context: genderStr }), i18next.t("miscDialogue:ending_name"), 0, () => this.handleGameOver());
} else if (this.victory || !this.scene.enableRetries) { } else if (this.isVictory || !this.scene.enableRetries) {
this.handleGameOver(); this.handleGameOver();
} else { } else {
this.scene.ui.showText(i18next.t("battle:retryBattle"), null, () => { this.scene.ui.showText(i18next.t("battle:retryBattle"), null, () => {
@ -93,7 +93,7 @@ export class GameOverPhase extends BattlePhase {
this.scene.disableMenu = true; this.scene.disableMenu = true;
this.scene.time.delayedCall(1000, () => { this.scene.time.delayedCall(1000, () => {
let firstClear = false; let firstClear = false;
if (this.victory && newClear) { if (this.isVictory && newClear) {
if (this.scene.gameMode.isClassic) { if (this.scene.gameMode.isClassic) {
firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY); firstClear = this.scene.validateAchv(achvs.CLASSIC_VICTORY);
this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY); this.scene.validateAchv(achvs.UNEVOLVED_CLASSIC_VICTORY);
@ -109,8 +109,8 @@ export class GameOverPhase extends BattlePhase {
this.scene.gameData.gameStats.dailyRunSessionsWon++; this.scene.gameData.gameStats.dailyRunSessionsWon++;
} }
} }
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.victory); this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.isVictory);
const fadeDuration = this.victory ? 10000 : 5000; const fadeDuration = this.isVictory ? 10000 : 5000;
this.scene.fadeOutBgm(fadeDuration, true); this.scene.fadeOutBgm(fadeDuration, true);
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true)); const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
activeBattlers.map(p => p.hideInfo()); activeBattlers.map(p => p.hideInfo());
@ -120,7 +120,7 @@ export class GameOverPhase extends BattlePhase {
this.scene.clearPhaseQueue(); this.scene.clearPhaseQueue();
this.scene.ui.clearText(); this.scene.ui.clearText();
if (this.victory && this.scene.gameMode.isChallenge) { if (this.isVictory && this.scene.gameMode.isChallenge) {
this.scene.gameMode.challenges.forEach(c => this.scene.validateAchvs(ChallengeAchv, c)); this.scene.gameMode.challenges.forEach(c => this.scene.validateAchvs(ChallengeAchv, c));
} }
@ -128,7 +128,7 @@ export class GameOverPhase extends BattlePhase {
if (newClear) { if (newClear) {
this.handleUnlocks(); this.handleUnlocks();
} }
if (this.victory && newClear) { if (this.isVictory && newClear) {
for (const species of this.firstRibbons) { for (const species of this.firstRibbons) {
this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species)); this.scene.unshiftPhase(new RibbonModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PLUS, species));
} }
@ -140,7 +140,7 @@ export class GameOverPhase extends BattlePhase {
this.end(); this.end();
}; };
if (this.victory && this.scene.gameMode.isClassic) { if (this.isVictory && this.scene.gameMode.isClassic) {
const dialogueKey = "miscDialogue:ending"; const dialogueKey = "miscDialogue:ending";
if (!this.scene.ui.shouldSkipDialogue(dialogueKey)) { if (!this.scene.ui.shouldSkipDialogue(dialogueKey)) {
@ -177,7 +177,7 @@ export class GameOverPhase extends BattlePhase {
If Online, execute apiFetch as intended If Online, execute apiFetch as intended
If Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */ If Offline, execute offlineNewClear(), a localStorage implementation of newClear daily run checks */
if (!Utils.isLocal || Utils.isLocalServerConnected) { if (!Utils.isLocal || Utils.isLocalServerConnected) {
pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, result: this.victory, clientSessionId: clientSessionId }) pokerogueApi.savedata.session.newclear({ slot: this.scene.sessionSlotId, isVictory: this.isVictory, clientSessionId: clientSessionId })
.then((success) => doGameOver(!!success)); .then((success) => doGameOver(!!success));
} else { } else {
this.scene.gameData.offlineNewClear(this.scene).then(result => { this.scene.gameData.offlineNewClear(this.scene).then(result => {
@ -187,7 +187,7 @@ export class GameOverPhase extends BattlePhase {
} }
handleUnlocks(): void { handleUnlocks(): void {
if (this.victory && this.scene.gameMode.isClassic) { if (this.isVictory && this.scene.gameMode.isClassic) {
if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) { if (!this.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]) {
this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE)); this.scene.unshiftPhase(new UnlockPhase(this.scene, Unlockables.ENDLESS_MODE));
} }

View File

@ -28,7 +28,7 @@ describe("Pokerogue Session Savedata API", () => {
describe("Newclear", () => { describe("Newclear", () => {
const params: NewClearSessionSavedataRequest = { const params: NewClearSessionSavedataRequest = {
clientSessionId: "test-session-id", clientSessionId: "test-session-id",
result: true, isVictory: true,
slot: 3 slot: 3
}; };