Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

let players = game.users.contents.filter(user => !user.isGM && user.

active);
let checkboxes = players.map(player => `
<div class="form-group">
<label for="${player.id}">${player.name}</label>
<input type="checkbox" id="${player.id}" name="${player.id}">
</div>
`).join("");

let dialogContent = `
<form>
${checkboxes}
<div class="form-group" style="display: flex; justify-content: space-between;">
<div>
<label for="attribute1">Attribute 1:</label>
<select id="attribute1" name="attribute1">
<option value="mig">Might</option>
<option value="dex">Dexterity</option>
<option value="ins">Insight</option>
<option value="wlp">Willpower</option>
</select>
</div>
<div>
<label for="attribute2">Attribute 2:</label>
<select id="attribute2" name="attribute2">
<option value="mig">Might</option>
<option value="dex">Dexterity</option>
<option value="ins">Insight</option>
<option value="wlp">Willpower</option>
</select>
</div>
</div>
</form>
`;

new Dialog({
title: "Let's Roll!",
content: dialogContent,
buttons: {
roll: {
label: "Call for Roll",
callback: (html) => {
let attribute1 = html.find('[name="attribute1"]').val();
let attribute2 = html.find('[name="attribute2"]').val();
let selectedPlayers = players.filter(player => html.find(`[name="${player.id}"]`).is(':checked'));

let attributeNames = {
"mig": "Might",
"dex": "Dexterity",
"ins": "Insight",
"wlp": "Willpower"
};

let AttributeName1 = attributeNames[attribute1];


let AttributeName2 = attributeNames[attribute2];

let chatContent = `
<p>The GM rolled ${AttributeName1} + ${AttributeName2} for you.</p>
<p>Total: [[d@attributes.${attribute1}.current + d@attributes.${attribute2}.current]]</p>
`;

selectedPlayers.forEach(player => {
ChatMessage.create({
user: player.id,
speaker: ChatMessage.getSpeaker({actor: player.character}),
content: chatContent
});
});
}
}
},
default: "roll"
}).render(true);

You might also like