/** * 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>} 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; }