summaryrefslogtreecommitdiff
path: root/resources/js/story.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/story.js')
-rw-r--r--resources/js/story.js90
1 files changed, 50 insertions, 40 deletions
diff --git a/resources/js/story.js b/resources/js/story.js
index 1901829..0ceb224 100644
--- a/resources/js/story.js
+++ b/resources/js/story.js
@@ -14,20 +14,20 @@ const Story = {
},
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 story = await fetchStory('introduction');
+ const characterCeo = story.characters.ceo;
+ const characterShopKeeper = story.characters.shopKeeper;
+ const npcCeo = await fetchNpc(characterCeo.slug);
+ const npcShopKeeper = await fetchNpc(characterShopKeeper.slug);
+
+ await UI.buildAndShowStoryPopup({ speaker: npcCeo, text: translate(characterCeo.text[0], true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcCeo, text: translate(characterCeo.text[1], true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcShopKeeper, text: translate(characterShopKeeper.text[0], true) });
const possibleStarterMonsters = await Promise.all(
- [
- 'budaye',
- 'dollfin',
- 'grintot',
- 'ignibus',
- 'memnomnom',
- ].map(async (monsterSlug) => {
- const monster = await fetchMonster(monsterSlug);
- monster.level = 5;
+ story.monsters.map(async (monsterData) => {
+ const monster = await fetchMonster(monsterData.slug);
+ monster.level = monsterData.level;
return monster;
})
);
@@ -41,16 +41,16 @@ const Story = {
event.detail.popup.remove();
- await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('tuxemart-keeper'), text: translate('spyder_intro_shopkeeper4', true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcShopKeeper, text: translate(characterShopKeeper.text[1], true) });
// set rival monster
Memory.state.rivalMonster = event.detail.monster.slug;
// set initial values
- Memory.state.money = 250;
+ Memory.state.money = story.money;
// go to starting area
- await Game.goToArea('paper-town');
+ await Game.goToArea(story.area);
resolve();
}));
@@ -58,20 +58,18 @@ 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 story = await fetchStory('select-starter-monster');
+ const characterDante = story.characters.dante;
+ const npcDante = await fetchNpc(characterDante.slug);
+
+ await UI.buildAndShowStoryPopup({ speaker: npcDante, text: translate(characterDante.text[0], true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcDante, text: translate(characterDante.text[1], true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcDante, text: translate(characterDante.text[2], true) });
const possibleStarterMonsters = await Promise.all(
- [
- 'tweesher',
- 'lambert',
- 'nut',
- 'agnite',
- 'rockitten',
- ].map(async (monsterSlug) => {
- const monster = await fetchMonster(monsterSlug);
- monster.level = 5;
+ story.monsters.map(async (monsterData) => {
+ const monster = await fetchMonster(monsterData.slug);
+ monster.level = monsterData.level;
return monster;
})
);
@@ -86,9 +84,6 @@ const Story = {
Memory.state.player.monsters.push(event.detail.monster);
Game.setActivePlayerMonster(event.detail.monster);
- // go to starting area
- await Game.goToArea('paper-town');
-
UI.drawActiveMonster();
UI.drawActiveTechniques();
@@ -102,22 +97,37 @@ const Story = {
},
async battleRivalOne () {
- const rivalMonster = await fetchMonster(Memory.state.rivalMonster);
- rivalMonster.level = 5;
- Memory.state.opponent = new Trainer({ monsters: [ rivalMonster ] });
+ const story = await fetchStory('battle-rival-one');
+ const characterRival = story.characters.rival;
+ const npcRival = await fetchNpc(story.characters.rival.slug);
+
+ Memory.state.opponent = new Trainer({
+ monsters: await Promise.all(
+ characterRival.monsters.map(async (monsterData) => {
+ if (monsterData.slug === 'RIVAL') {
+ monsterData.slug = Memory.state.rivalMonster;
+ }
+
+ const monster = await fetchMonster(monsterData.slug);
+ monster.level = monsterData.level;
+
+ return monster;
+ })
+ )
+ });
await Memory.state.opponent.initialize();
- await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight', true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcRival, text: translate(characterRival.text[0], true) });
await Story.battle();
if (Game.didWinStoryBattle) {
- await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_win', true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcRival, text: translate(characterRival.text[1], true) });
} else {
- await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_lose', true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcRival, text: translate(characterRival.text[2], true) });
}
- await UI.buildAndShowStoryPopup({ speaker: await fetchNpc('spyder_billie'), text: translate('spyder_papertown_firstfight_after', true) });
+ await UI.buildAndShowStoryPopup({ speaker: npcRival, text: translate(characterRival.text[3], true) });
Game.healParty();
},
@@ -125,7 +135,7 @@ const Story = {
// Helper
/**
- * @param {string} slug
+ * @param {StorySlug} slug
*/
async progress (slug) {
if (!Story[slug]) {
@@ -143,8 +153,8 @@ const Story = {
},
/**
- * @param {string} fromSlug
- * @param {string} toSlug
+ * @param {StorySlug} fromSlug
+ * @param {StorySlug} toSlug
*/
async immediateProgress (fromSlug, toSlug) {
Memory.state.storyProgress[fromSlug] = true;