From 5214cdfbf26bc0bdee5d669a237fb8aefffb78d5 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 30 Aug 2023 21:35:28 +0200 Subject: story! --- resources/js/db.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'resources/js/db.js') diff --git a/resources/js/db.js b/resources/js/db.js index 54fc751..3c8be05 100644 --- a/resources/js/db.js +++ b/resources/js/db.js @@ -68,6 +68,8 @@ const DB = { */ items: {}, + npcs: {}, + areas: {}, translations: {}, @@ -162,6 +164,19 @@ async function fetchItem (slug) { return new Item(slug); } +/** + * @param {string} slug + * + * @returns {Promise} + */ +async function fetchNpc (slug) { + if (! DB.npcs[slug]) { + DB.npcs[slug] = await fetchDBData(`/modules/tuxemon/mods/tuxemon/db/npc/${slug}.json`).then((response) => response.json()); + } + + return DB.npcs[slug]; +} + /** * @param {string} locale * -- cgit v1.2.3