diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-18 16:07:39 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-18 16:07:39 +0200 |
commit | d3e65b98ca932aef1e05e33d74eaf62be520cdd4 (patch) | |
tree | 3645410b3c4c857d1a602f6b6abda71b106aae64 /resources/js/db.js | |
parent | aa44f67ab57673528e96a4a075fbd8cd0354bd68 (diff) |
inventory and items
Diffstat (limited to 'resources/js/db.js')
-rw-r--r-- | resources/js/db.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/resources/js/db.js b/resources/js/db.js index 96b971a..64b2e9b 100644 --- a/resources/js/db.js +++ b/resources/js/db.js @@ -1,16 +1,19 @@ const DB = { allMonsters: [], allAnimations: {}, + allItems: [], monsters: {}, shapes: {}, elements: {}, techniques: {}, statusEffects: {}, + items: {}, }; async function initializeDB () { DB.allMonsters = await fetch('/db/all-monsters.json').then((response) => response.json()); DB.allAnimations = await fetch('/db/animations.json').then((response) => response.json()); + DB.allItems = await fetch('/db/all-items.json').then((response) => response.json()); DB.shapes = await fetch('/modules/tuxemon/mods/tuxemon/db/shape/shapes.json').then((response) => response.json()); @@ -60,3 +63,16 @@ async function fetchStatusEffect (slug) { return new StatusEffect(slug); } + +/** + * @param {string} slug + * + * @returns {Promise<StatusEffect>} + */ +async function fetchItem (slug) { + if (! DB.items[slug]) { + DB.items[slug] = await fetch(`/modules/tuxemon/mods/tuxemon/db/item/${slug}.json`).then((response) => response.json()); + } + + return new Item(slug); +} |