Изменено: - Поддержка новых типов товаров: "Механические приспособления" и "Религиозные товары". - Добавлена возможность случайной генерации уровня торговца. - Улучшена производительность при загрузке предметов из компендиумов. - Обновлены тексты описаний для категорий товаров. - Исправлена ошибка при добавлении предметов к торговцу (см. `module/data.mjs`, строки 2436-2446). - Исправлена проблема с отображением характеристик торговца в интерфейсе.
This commit is contained in:
Executable
+77
@@ -0,0 +1,77 @@
|
||||
import { ViewData, MerchantData } from './data.mjs';
|
||||
|
||||
export class MerchantForm extends FormApplication {
|
||||
viewData = new ViewData();
|
||||
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
object: {},
|
||||
template: "./modules/test_tube_merchant/templates/merchant.hbs",
|
||||
popOut: true,
|
||||
resizable: true,
|
||||
title: game.i18n.localize("TTM.name"),
|
||||
});
|
||||
}
|
||||
|
||||
getData(options) {
|
||||
const data = super.getData(options);
|
||||
|
||||
data.footer = `${game.i18n.localize("TTM.footer")} <a href="${game.i18n.localize("TTM.boostSite")}">${game.i18n.localize("TTM.boostSite")}</a>`;
|
||||
data.itemsTypes = this.viewData.itemsTypes;
|
||||
data.categories = this.viewData.categories;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async _render(force, options) {
|
||||
await super._render(force, options);
|
||||
this._bindEvents();
|
||||
}
|
||||
|
||||
_bindEvents() {
|
||||
const html = this.element;
|
||||
|
||||
html.find('#setNewMerchant').on('click', async () => {
|
||||
const tokens = canvas.tokens.controlled;
|
||||
merchantData.newMerchant(tokens, this.merchantItemsTypes, this.categoriesTypes);
|
||||
});
|
||||
|
||||
html.find('#editMerchant').on('click', async () => {
|
||||
const tokens = canvas.tokens.controlled;
|
||||
merchantData.editMerchant(tokens, this.merchantItemsTypes, this.categoriesTypes);
|
||||
});
|
||||
|
||||
html.find('#randomCategories').on('click', async () => {
|
||||
const categories = await merchantData.randomLevelWithDice();
|
||||
this.categoriesTypes.value = categories;
|
||||
});
|
||||
|
||||
html.find('#randomTypes').on('click', async () => {
|
||||
const types = await merchantData.randomTypesWithDice(this.viewData.itemsTypes);
|
||||
this.merchantItemsTypes.value = types;
|
||||
});
|
||||
|
||||
html.find('#randomMerchant').on('click', async () => {
|
||||
const tokens = canvas.tokens.controlled;
|
||||
const itemsTypes = this.viewData.itemsTypes;
|
||||
await merchantData.randomMerchant(tokens, this.merchantItemsTypes, this.categoriesTypes, itemsTypes);
|
||||
});
|
||||
}
|
||||
|
||||
async formLoading(html) {
|
||||
this.merchantItemsTypes = html.find('[id="MerchantItemsTypes"]')[0];
|
||||
this.categoriesTypes = html.find('[id="CategoriesTypes"]')[0];
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
this.formLoading(html);
|
||||
}
|
||||
}
|
||||
|
||||
export const merchantData = new MerchantData();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user