summaryrefslogtreecommitdiff
path: root/resources/js/game.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-09-02 14:59:09 +0200
committerDaniel Weipert <code@drogueronin.de>2023-09-02 14:59:09 +0200
commit2030caa0c85102b1cf6131dd9eefef4a347cda42 (patch)
tree9188abac0d7b7730ded1e8e154c3f7c589f785cf /resources/js/game.js
parent1d29ee6d87d3794a9319bca5bf36afdfe176072c (diff)
translations and story
Diffstat (limited to 'resources/js/game.js')
-rw-r--r--resources/js/game.js36
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) {