import { ErrorHandler } from './errorslog.mjs'; class Command { execute() {} } /** * Класс NewMerchantCommand создает нового торговца */ class NewMerchantCommand extends Command { /** * @param {Array} tokens - Токены для создания торговцев * @param {Object} itemsTypes - Типы товаров * @param {Object} categoriesTypes - Категории товаров */ constructor(tokens, itemsTypes, categoriesTypes) { super(); this.tokens = tokens; this.itemsTypes = itemsTypes; this.categoriesTypes = categoriesTypes; } /** * Основной метод выполнения команды */ async execute() { // Получаем список компендиумов const compendiumsNames = this.getCompendiumNames(); // Обрабатываем каждый токен for (const token of this.tokens) { // TODO: Добавить логику обработки токенов } } /** * Получает список имен компендиумов с типом "Item" * @returns {Array} Массив имен компендиумов */ getCompendiumNames() { return game.packs .map(pack => ({ name: pack.metadata.label, collection: pack.collection, entities: pack.index.size })) .filter(compendium => { const pack = game.packs.get(compendium.collection); return pack.metadata.type === "Item"; }) .map(compendium => compendium.collection); } }