Build release archive / release (push) Failing after 28s
Изменено: - Поддержка новых типов товаров: "Механические приспособления" и "Религиозные товары". - Добавлена возможность случайной генерации уровня торговца. - Улучшена производительность при загрузке предметов из компендиумов. - Обновлены тексты описаний для категорий товаров. - Исправлена ошибка при добавлении предметов к торговцу (см. `module/data.mjs`, строки 2436-2446). - Исправлена проблема с отображением характеристик торговца в интерфейсе.
31 lines
1.1 KiB
JavaScript
Executable File
31 lines
1.1 KiB
JavaScript
Executable File
/**
|
|
* 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;
|
|
} |