diff options
Diffstat (limited to 'resources/js/story.js')
-rw-r--r-- | resources/js/story.js | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/resources/js/story.js b/resources/js/story.js index bdec2e1..1901829 100644 --- a/resources/js/story.js +++ b/resources/js/story.js @@ -10,10 +10,14 @@ const Story = { })); }); - await Story.progress('introduction'); + await Story.immediateProgress('start', 'introduction'); }, async introduction () { + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('omnichannel-ceo'), text: translate('spyder_intro00', true) }); + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('omnichannel-ceo'), text: translate('spyder_intro01', true) }); + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('tuxemart-keeper'), text: translate('spyder_intro_shopkeeper1', true) }); + const possibleStarterMonsters = await Promise.all( [ 'budaye', @@ -37,7 +41,7 @@ const Story = { event.detail.popup.remove(); - await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_dante'), text: translate('spyder_intro_shopkeeper4', true) }); + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('tuxemart-keeper'), text: translate('spyder_intro_shopkeeper4', true) }); // set rival monster Memory.state.rivalMonster = event.detail.monster.slug; @@ -55,6 +59,7 @@ const Story = { async selectStarterMonster () { await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_dante'), text: translate('spyder_papertown_myfirstmon_notmet', true) }); + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_dante'), text: translate('spyder_papertown_myfirstmon1', true) }); await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_dante'), text: translate('spyder_papertown_myfirstmon2', true) }); const possibleStarterMonsters = await Promise.all( @@ -93,7 +98,7 @@ const Story = { })); }); - await Story.progress('battleRivalOne'); + await Story.immediateProgress('selectStarterMonster', 'battleRivalOne'); }, async battleRivalOne () { @@ -102,9 +107,18 @@ const Story = { Memory.state.opponent = new Trainer({ monsters: [ rivalMonster ] }); await Memory.state.opponent.initialize(); - await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_rivalbillie'), text: translate('spyder_papertown_firstfight', true) }); + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight', true) }); await Story.battle(); + + if (Game.didWinStoryBattle) { + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_win', true) }); + } else { + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_lose', true) }); + } + + await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_after', true) }); + Game.healParty(); }, @@ -112,8 +126,6 @@ const Story = { /** * @param {string} slug - * - * @returns {Promise<any>} */ async progress (slug) { if (!Story[slug]) { @@ -131,8 +143,16 @@ const Story = { }, /** - * @returns {Promise<any>} + * @param {string} fromSlug + * @param {string} toSlug */ + async immediateProgress (fromSlug, toSlug) { + Memory.state.storyProgress[fromSlug] = true; + Memory.saveToLocalStorage(); + + await Story.progress(toSlug); + }, + async battle () { const previousArea = Object.assign({}, Memory.state.currentArea); @@ -152,6 +172,10 @@ const Story = { }, 100); }); + // reset incremented trainer progress + if (Memory.state.areaProgress[previousArea.slug]) { + Memory.state.areaProgress[previousArea.slug].trainerProgress = previousArea.trainerProgress; + } if (previousArea.slug === Memory.state.currentArea.slug) { Memory.state.currentArea.trainerProgress = previousArea.trainerProgress; |