summaryrefslogtreecommitdiff
path: root/resources/js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js')
-rw-r--r--resources/js/game.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/resources/js/game.js b/resources/js/game.js
index e383677..1ca9387 100644
--- a/resources/js/game.js
+++ b/resources/js/game.js
@@ -400,9 +400,28 @@ const Game = {
};
/**
+ * @param {InventoryItem} inventoryItemData
+ */
+ const loadInventoryItem = async (inventoryItemData) => {
+ const inventoryItem = new InventoryItem(await fetchItem(inventoryItemData.item.slug));
+
+ inventoryItem.quantity = inventoryItemData.quantity;
+
+ return inventoryItem;
+ };
+
+ /**
* @param {Item} itemData
*/
- const loadItem = async (itemData) => {};
+ const loadItem = async (itemData) => {
+ if (!itemData) {
+ return null;
+ }
+
+ const item = await fetchItem(itemData.slug);
+
+ return item;
+ };
/**
* @param {StatusEffect} statusEffectData
@@ -435,7 +454,7 @@ const Game = {
state.money = loadedState.money;
state.monsters = await Promise.all(loadedState.monsters.map(async (monsterData) => await loadMonster(monsterData)));
- state.inventory = await Promise.all(loadedState.inventory.map(async (itemData) => await loadItem(itemData)));
+ state.inventory = await Promise.all(loadedState.inventory.map(async (itemData) => await loadInventoryItem(itemData)));
state.partyMonsters = await Promise.all(loadedState.partyMonsters.map(async (monsterData) => await loadMonster(monsterData)));
state.activeMonster = state.partyMonsters[loadedState.activeMonsterIdx];
state.activeTechnique = await loadTechnique(loadedState.activeTechnique);