export async function getOpenEndedRollModifier() { return await new Roll("1d100x>95").roll(); } export function processOpenEndedSixtySixRoll(baseroll, rolltype) { // Log the Roll to Chat let chatOptions = { type: CONST.CHAT_MESSAGE_TYPES.ROLL, rolls: [baseroll], flavor: rolltype, rollMode: game.settings.get("core", "rollMode"), content: "You rolled a 66!", }; ChatMessage.create(chatOptions); } export function processOpenEndedRoll(baseroll, rolltype) { // Define the Chat Message Template let chatTemplate = "systems/fvtt-rolemaster-frp/templates/chat/chat_dice_roll.html"; // Pass the Data through to be used in the Chat Message let chatData = { baseroll: baseroll, total: baseroll.result, highopen: false, lowopen: false, }; // Render the Rolls to the Chat Window renderTemplate(chatTemplate, chatData).then((html) => { let chatOptions = { type: CONST.CHAT_MESSAGE_TYPES.ROLL, rolls: [baseroll], flavor: rolltype, rollMode: game.settings.get("core", "rollMode"), content: html, }; ChatMessage.create(chatOptions); }); } export async function processHighOpenEndedRoll(baseroll, rolltype) { // Get the Base Roll followed by the High Open Ended Roll let originalRoll = baseroll; let openendedRoll = await this.getOpenEndedRollModifier(); // Create a rolls array for Dice So Nice integration. let rolls = [originalRoll, openendedRoll]; // Create an Array to hold the High Open Ended Roll Results and set the total to base roll let openendedResults = []; let total = Number(originalRoll.result); // Each time the High Open Ended Roll is triggered add the result to an array and add it to the total. for (const rollResult of openendedRoll.dice[0].results) { openendedResults.push(rollResult.result); total = total + Number(rollResult.result); } // Define the Chat Message Template let chatTemplate = "systems/fvtt-rolemaster-frp/templates/chat/chat_dice_roll.html"; // Pass the Data through to be used in the Chat Message let chatData = { baseroll: baseroll, opeendedresults: [openendedResults], highopen: true, lowopen: false, total: total, }; // Render the Rolls to the Chat Window renderTemplate(chatTemplate, chatData).then((html) => { let chatOptions = { style: CONST.CHAT_MESSAGE_STYLES.ROLL, rolls: rolls, flavor: rolltype, rollMode: game.settings.get("core", "rollMode"), content: html, }; ChatMessage.create(chatOptions); }); } export async function processLowOpenEndedRoll(baseroll, rolltype) { // Get the Base Roll followed by the Low Open Ended Roll let originalRoll = baseroll; let openendedRoll = await this.getOpenEndedRollModifier(); // Create a rolls array for Dice So Nice integration. let rolls = [originalRoll, openendedRoll]; // Create an Array to hold the Low Open Ended Roll Results and set the total to base roll let openendedResults = []; let total = Number(originalRoll.result); // Each time the Low Open Ended Roll is triggered add the result to an array and subtract it from the total. for (const rollResult of openendedRoll.dice[0].results) { openendedResults.push(rollResult.result); total = total - Number(rollResult.result); } // Define the Chat Message Template let chatTemplate = "systems/fvtt-rolemaster-frp/templates/chat/chat_dice_roll.html"; // Pass the Data through to be used in the Chat Message let chatData = { baseroll: baseroll, rolls: rolls, opeendedresults: [openendedResults], highopen: false, lowopen: true, total: total, }; // Render the Rolls to the Chat Window renderTemplate(chatTemplate, chatData).then((html) => { let chatOptions = { style: CONST.CHAT_MESSAGE_STYLES.ROLL, rolls: rolls, flavor: rolltype, rollMode: game.settings.get("core", "rollMode"), content: html, }; ChatMessage.create(chatOptions); }); }