summaryrefslogtreecommitdiff
path: root/resources/js/main.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-23 20:29:07 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-23 20:29:07 +0200
commit7b1c251fcb085dc37de439ea1137373f1905d82e (patch)
tree32e3f2cd4367507726af6d0172e9621a37dff576 /resources/js/main.js
parent4dd1a344c6474087a3f8782dd54f5c7b4acc67ed (diff)
areas and capture and more
Diffstat (limited to 'resources/js/main.js')
-rw-r--r--resources/js/main.js44
1 files changed, 28 insertions, 16 deletions
diff --git a/resources/js/main.js b/resources/js/main.js
index 24eafec..6ea94e2 100644
--- a/resources/js/main.js
+++ b/resources/js/main.js
@@ -4,24 +4,36 @@
// Start Game
const possibleStarterMonsters = ['budaye', 'dollfin', 'grintot', 'ignibus', 'memnomnom'];
- Memory.state.player = new Trainer({
- monsters: [
- await fetchMonster(possibleStarterMonsters[Math.round(Math.random() * (possibleStarterMonsters.length - 1))]),
- ],
- inventory: [
- new InventoryItem(await fetchItem('tuxeball'), 5),
- new InventoryItem(await fetchItem('potion')),
- ]
- });
- await Memory.state.player.initialize();
+ const monsterSelection = UI.openStarterMonsterSelection(
+ await Promise.all(possibleStarterMonsters.map(async (monsterSlug) => await fetchMonster(monsterSlug)))
+ );
+ monsterSelection.addEventListener('starter:monster:selected', async (event) => {
+ if (!confirm(`Select ${event.detail.monster.name}?`)) {
+ return;
+ }
+
+ Memory.state.player = new Trainer({
+ monsters: [
+ event.detail.monster,
+ ],
+ inventory: [
+ new InventoryItem(await fetchItem('tuxeball'), 5),
+ new InventoryItem(await fetchItem('potion')),
+ ]
+ });
+ await Memory.state.player.initialize();
- Game.setActivePlayerMonster(Memory.state.player.monsters[0]);
- Memory.state.activeBall = Memory.state.player.inventory[0]; // tuxeball
+ Game.setActivePlayerMonster(Memory.state.player.monsters[0]);
+ Memory.state.activeBall = Memory.state.player.inventory[0]; // tuxeball
- Memory.state.rivalMonster = possibleStarterMonsters[Math.round(Math.random() * (possibleStarterMonsters.length - 1))];
+ possibleStarterMonsters.splice(possibleStarterMonsters.indexOf(event.detail.monster), 1);
+ Memory.state.rivalMonster = possibleStarterMonsters[Math.round(Math.random() * (possibleStarterMonsters.length - 1))];
- await Game.goToArea('paper-town');
+ await Game.goToArea('paper-town');
- UI.drawActiveMonster();
- UI.drawActiveTechniques();
+ UI.drawActiveMonster();
+ UI.drawActiveTechniques();
+
+ event.detail.popup.remove();
+ });
})();