const DB = { allMonsters: [], allAnimations: {}, monsters: {}, shapes: {}, elements: {}, techniques: {}, statusEffects: {}, }; 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.shapes = await fetch('/modules/tuxemon/mods/tuxemon/db/shape/shapes.json').then((response) => response.json()); for (const element of Object.keys(ElementType)) { DB.elements[element] = await fetch(`/modules/tuxemon/mods/tuxemon/db/element/${element}.json`).then((response) => response.json()); } } /** * @param {MonsterSlug} slug * * @returns {Promise} */ async function fetchMonster (slug) { if (! DB.monsters[slug]) { DB.monsters[slug] = await fetch(`/modules/tuxemon/mods/tuxemon/db/monster/${slug}.json`).then((response) => response.json()); } const monster = new Monster(slug); await monster.initialize(); return monster; } /** * @param {TechniqueSlug} slug * * @returns {Promise} */ async function fetchTechnique (slug) { if (! DB.techniques[slug]) { DB.techniques[slug] = await fetch(`/modules/tuxemon/mods/tuxemon/db/technique/${slug}.json`).then((response) => response.json()); } return new Technique(slug); } /** * @param {string} slug * * @returns {Promise} */ async function fetchStatusEffect (slug) { if (! DB.statusEffects[slug]) { DB.statusEffects[slug] = await fetch(`/modules/tuxemon/mods/tuxemon/db/technique/status_${slug}.json`).then((response) => response.json()); } return new StatusEffect(slug); }