import { MerchantForm } from "./module/merchantForm.mjs"; import { MerchantFormV2 } from "./module/merchantFormV2.mjs"; import { RaceManager } from "./module/makeActor.mjs"; /** * @module testTubeMerchant * @description The module creates a merchant using the Item Piles module for Foundry VTT * * @requires module/merchantFormV2 * @requires module/merchantForm * * @example * // Initialize the merchant form * initializeMerchantForm(); * * @function registerSettings * @description Registers the settings for the module. * * @function initializeMerchantForm * @description Initializes the appropriate merchant form based on the game version. * * @function addCustomTokenButton * @param {Array} controls - The existing scene control buttons. * @description Adds a custom button to the scene control panel for the GM. */ let tube; Hooks.on('init', () => { registerSettings(); initializeMerchantForm(); }); Hooks.on('getSceneControlButtons', (controls) => { console.log(1,controls); addCustomTokenButton(controls); console.log(2,controls); }); function registerSettings() { game.settings.register("TTM", "buttonEnabled", { name: game.i18n.localize("TTM.enableButtonName") || "Enable Custom Token Button", hint: game.i18n.localize("TTM.enableButtonHint") || "Enable the custom button on tokens", scope: "world", config: true, type: Boolean, default: true }); } /** * */ function initializeMerchantForm() { const gameVersion = parseFloat(game.version); tube = gameVersion < 12 ? new MerchantForm() : new MerchantFormV2(); } /** * Adds a custom button to the scene control panel for the GM. * @param {Array} controls - The existing scene control buttons. */ function addCustomTokenButton(controls) { // const tokenControls = controls.find(c => c.name === "token"); // if (tokenControls && game.settings.get("TTM", "buttonEnabled") && game.user.isGM) { // tokenControls.tools.push({ // name: "TTM_MerchantButton", // title: game.i18n.localize("TTM.name"), // icon: 'fa-light fa-money-bill-wheat', // button: true, // onClick: () => tube.render(true) // }); // } if (controls.tokens && game.user.isGM) { controls.tokens.tools["TTM_MerchantButton"] = { name: "TTM_MerchantButton", title: game.i18n.localize("TTM.name"), icon: "fa-light fa-money-bill-wheat", visible: true, onClick: () => tube.render(true), //button: true, active: false, toggle: false, order: 7 // Порядок отображения инструмента }; } } Hooks.once('init', async () => { const raceManager = new RaceManager("dnd5e"); // Загрузка рас await raceManager.loadRaces(); // Получение списка всех рас const races = raceManager.getRaces(); console.log("Список рас:", races); // Получение случайной расы const randomRace = raceManager.getRandomRace(); console.log("Случайная раса:", randomRace); // Получение списка подрас для указанной расы const subraces = raceManager.getSubraces("human"); console.log("Подрасы человека:", subraces); // Получение случайной подрасы для указанной расы const randomSubrace = raceManager.getRandomSubrace("human"); console.log("Случайная подраса человека:", randomSubrace); // Получение списка имен для указанной расы и пола const maleNames = raceManager.getNames("human", "male"); console.log("Мужские имена человека:", maleNames); // Получение случайного имени для указанной расы и пола const randomName = raceManager.getRandomName("human", "male"); console.log("Случайное мужское имя человека:", randomName); });