class Trainer { #monsters = []; #inventory = []; /** * @type {('trainer' | 'monster')} */ type = 'trainer'; /** * @type {Monster[]} */ monsters = []; /** * @type {InventoryItem[]} */ inventory = []; /** * @type {Monster} */ activeMonster = []; constructor (monsters, inventory = []) { this.#monsters = monsters; this.#inventory = inventory; } async initialize () { for (const monsterData of this.#monsters) { const monster = await fetchMonster(monsterData.slug); monster.level = monsterData.level || monster.level; this.monsters.push(monster); } this.activeMonster = this.monsters[0]; for (const itemData of this.#inventory) { const item = new InventoryItem(await fetchItem(itemData.slug)); item.amount = itemData.amount || 1; this.inventory.push(item); } } }