From 2030caa0c85102b1cf6131dd9eefef4a347cda42 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 2 Sep 2023 14:59:09 +0200 Subject: translations and story --- resources/js/game.js | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'resources/js/game.js') diff --git a/resources/js/game.js b/resources/js/game.js index 6c3a393..309d013 100644 --- a/resources/js/game.js +++ b/resources/js/game.js @@ -761,14 +761,6 @@ const Game = { } const nextTrainer = Memory.state.currentArea.trainers[nextTrainerIdx]; - if (nextTrainer.name.startsWith('Rival')) { - for (const idx in nextTrainer.monsters) { - if (nextTrainer.monsters[idx].slug === 'STARTER') { - nextTrainer.monsters[idx].slug = Memory.state.rivalMonster; - } - } - } - const trainer = new Trainer(nextTrainer); await trainer.initialize() Memory.state.opponent = trainer; @@ -797,11 +789,37 @@ const Game = { Memory.state.currentArea = await fetchArea(areaSlug); + + // on enter + let storyIsDone = true; + if (Memory.state.currentArea.events?.onEnter.length > 0) { + Game.isLoadingArea = false; + + for (const event of Memory.state.currentArea.events.onEnter) { + if (event.type === 'story') { + UI.showMap(); + UI.drawTown(); + + storyIsDone = await Story.progress(event.story); + } + } + } + + if (!storyIsDone) { + return; + } + + Game.isLoadingArea = true; + + + // after events resolved + if (Game.isTown(Memory.state.currentArea)) { if (Object.values(Memory.state.currentArea.locations).some((location) => location.type === 'healingCenter')) { Memory.state.lastVisitedTown = areaSlug; } - } else { + } + else { if (Memory.state.currentArea.encounters.length > 0) { await Game.encounterWildMonster(); } else if (Memory.state.currentArea.trainers.length > 0) { -- cgit v1.2.3