diff options
Diffstat (limited to 'resources/js/game.js')
-rw-r--r-- | resources/js/game.js | 36 |
1 files changed, 27 insertions, 9 deletions
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) { |