improve loading process

This commit is contained in:
2023-06-20 19:37:27 +02:00
parent c2abfd6dfd
commit 3b9441b555
+14 -8
View File
@@ -248,12 +248,23 @@ export default defineComponent({
} }
}, },
async mounted() { async mounted() {
this.quests = await loadAvailableQuests(); console.debug("Loading game data")
this.adventurersDatabase = await loadAdventurersForHire(); const promises = await Promise.all([
this.loadGame(); loadAvailableQuests(),
loadAdventurersForHire(),
]);
this.quests = promises[0] as { [key: string]: { [key: string]: Quest } };
this.adventurersDatabase = promises[1] as Array<Adventurer>;
console.debug("Game data loaded!")
this.loadGame();
this.adventurersDatabase = removeAlreadyHiredAdventurers(this.adventurersDatabase, this.adventurers); this.adventurersDatabase = removeAlreadyHiredAdventurers(this.adventurersDatabase, this.adventurers);
// Wait a second to make sure at least most images load in behind the loader
setTimeout(() => {
this.loading = false;
}, 1000);
this.gameSaveTask = Number(setInterval(() => { this.gameSaveTask = Number(setInterval(() => {
saveGame(new GameData({ saveGame(new GameData({
adventurers: this.adventurers, adventurers: this.adventurers,
@@ -265,11 +276,6 @@ export default defineComponent({
})); }));
}, 10 * 1000)); }, 10 * 1000));
// Wait a second to make sure at least most images load in behind the loader
setTimeout(() => {
this.loading = false;
}, 1000);
this.gameTickTask = Number(setInterval(() => { this.gameTickTask = Number(setInterval(() => {
this.updateMissives(); this.updateMissives();