blob: 64b2e9b183871ce3c0c905e9c3f1bc7e555a7576 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
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());
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<Monster>}
*/
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<Technique>}
*/
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<StatusEffect>}
*/
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);
}
/**
* @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);
}
|