summaryrefslogtreecommitdiff
path: root/resources/js/db.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-18 16:07:39 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-18 16:07:39 +0200
commitd3e65b98ca932aef1e05e33d74eaf62be520cdd4 (patch)
tree3645410b3c4c857d1a602f6b6abda71b106aae64 /resources/js/db.js
parentaa44f67ab57673528e96a4a075fbd8cd0354bd68 (diff)
inventory and items
Diffstat (limited to 'resources/js/db.js')
-rw-r--r--resources/js/db.js16
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);
+}