Изменено: - Поддержка новых типов товаров: "Механические приспособления" и "Религиозные товары". - Добавлена возможность случайной генерации уровня торговца. - Улучшена производительность при загрузке предметов из компендиумов. - Обновлены тексты описаний для категорий товаров. - Исправлена ошибка при добавлении предметов к торговцу (см. `module/data.mjs`, строки 2436-2446). - Исправлена проблема с отображением характеристик торговца в интерфейсе.
This commit is contained in:
Executable
Executable
+43
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Class ViewData
|
||||
*
|
||||
* This class contains data used to display information about goods and categories.
|
||||
*
|
||||
* @class ViewData
|
||||
* @property {Object} itemsTypes - An object containing types of goods and their descriptions.
|
||||
* @property {Object} categories - An object containing categories and their descriptions.
|
||||
*
|
||||
* @example
|
||||
* const viewData = new ViewData();
|
||||
* console.log(viewData.itemsTypes.bars); // "Алкоголь и напитки"
|
||||
* console.log(viewData.categories.good); // "Хороший"
|
||||
*/
|
||||
|
||||
export class ViewData {
|
||||
itemsTypes = {
|
||||
"bars": "Алкоголь и напитки",
|
||||
"books": "Книги и карты",
|
||||
"flowers": "Цветы и семена",
|
||||
"food": "Еда и части животных",
|
||||
"fashion": "Высокая мода",
|
||||
"jewelry": "Ювелирные изделия",
|
||||
"trinkets": "Безделушки",
|
||||
"skin": "Изделия из кожи",
|
||||
"mechanical": "Механические приспособления",
|
||||
"armor": "Средние и тяжелые доспехи (щиты)",
|
||||
"potions": "Зелья, яды и травы",
|
||||
"religious": "Религиозные товары",
|
||||
"scrolls": "Книги заклинаний и свитки",
|
||||
"thieves": "Воровские приспособления",
|
||||
"tools": "Инструменты",
|
||||
"weapon": "Оружие"
|
||||
}
|
||||
|
||||
categories = {
|
||||
"horrible": "Ужасный",
|
||||
"bad": "Плохой",
|
||||
"medium": "Средний",
|
||||
"good": "Хороший",
|
||||
"beautiful": "Прекрасный"
|
||||
}
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Returns a random integer between 0 (inclusive) and the specified maximum (exclusive).
|
||||
*
|
||||
* @param {number} max - The maximum value (exclusive).
|
||||
* @returns {number} A random integer between 0 (inclusive) and the specified maximum (exclusive).
|
||||
*/
|
||||
export function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads items from a specified folder and returns them as an array of objects.
|
||||
*
|
||||
* @param {string} path - The path to the folder containing the items.
|
||||
* @returns {Promise<Array<Object>>} An array of objects representing the loaded items.
|
||||
**/
|
||||
export async function loadItemsFromFolder(path) {
|
||||
const items = [];
|
||||
const fileList = await FilePicker.browse('data', path);
|
||||
|
||||
for (let file of fileList.files) {
|
||||
const response = await fetch(file);
|
||||
try {
|
||||
const itemData = await response.json();
|
||||
items.push(itemData);
|
||||
} catch (e) {
|
||||
console.error(`Ошибка загрузки файла ${file}: ${e}`);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
Reference in New Issue
Block a user