Add a simple macro for rolling Eat The Reich dice
This commit is contained in:
parent
8a94558590
commit
50ecd27c92
1 changed files with 35 additions and 0 deletions
35
scripts/macros/rollDice.mjs
Normal file
35
scripts/macros/rollDice.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
async function rollDice() {
|
||||
|
||||
const statBase = await DialogManager.ask({
|
||||
question: `How many dice to roll?`,
|
||||
initialValue: 2,
|
||||
inputType: `number`,
|
||||
});
|
||||
|
||||
if (!statBase) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sidesOnDice = 6;
|
||||
const successThreshold = 4;
|
||||
|
||||
let successes = 0;
|
||||
const results = [];
|
||||
for (let i = statBase; i > 0; i--) {
|
||||
let r = new Roll(`1d${sidesOnDice}`);
|
||||
await r.evaluate();
|
||||
results.push(r.total);
|
||||
if (r.total >= successThreshold) {
|
||||
successes++;
|
||||
}
|
||||
if (r.total === sidesOnDice) {
|
||||
successes++;
|
||||
}
|
||||
}
|
||||
|
||||
await ChatMessage.create({
|
||||
content: `Rolled: ${results.join(`, `)}<br>Successes: ${successes}`,
|
||||
});
|
||||
}
|
||||
|
||||
rollDice()
|
||||
Loading…
Add table
Add a link
Reference in a new issue