mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-14 04:12:18 +02:00
adds daily run to offline mode
This commit is contained in:
parent
e61c63f6c8
commit
ae0adfd367
@ -13,14 +13,15 @@ export interface DailyRunConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fetchDailyRunSeed(): Promise<string> {
|
export function fetchDailyRunSeed(): Promise<string> {
|
||||||
return new Promise<string>(resolve => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
Utils.apiFetch('daily/seed').then(response => {
|
Utils.apiFetch('daily/seed').then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return response.text();
|
return response.text();
|
||||||
}).then(seed => resolve(seed));
|
}).then(seed => resolve(seed))
|
||||||
|
.catch(err => reject(err));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ export class TitlePhase extends Phase {
|
|||||||
}
|
}
|
||||||
this.scene.sessionSlotId = slotId;
|
this.scene.sessionSlotId = slotId;
|
||||||
|
|
||||||
fetchDailyRunSeed().then(seed => {
|
const generateDaily = (seed: string) => {
|
||||||
this.scene.gameMode = gameModes[GameModes.DAILY];
|
this.scene.gameMode = gameModes[GameModes.DAILY];
|
||||||
|
|
||||||
this.scene.setSeed(seed);
|
this.scene.setSeed(seed);
|
||||||
@ -332,9 +332,17 @@ export class TitlePhase extends Phase {
|
|||||||
this.scene.sessionPlayTime = 0;
|
this.scene.sessionPlayTime = 0;
|
||||||
this.end();
|
this.end();
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!Utils.isLocal){
|
||||||
|
fetchDailyRunSeed().then(seed => {
|
||||||
|
generateDaily(seed);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error("Failed to load daily run:\n", err);
|
console.error("Failed to load daily run:\n", err);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
generateDaily(btoa(new Date().toISOString().substring(0, 10)))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user