Add handling for some cases that weren't covered already

This commit is contained in:
Eldritch-Oliver 2025-09-15 00:40:01 -06:00
parent 708917ae99
commit 06f1225b2a

View file

@ -24,7 +24,6 @@ async function rollDice() {
{ {
type: `select`, type: `select`,
key: `stat`, key: `stat`,
inputType: `number`,
label: `Stat Base`, label: `Stat Base`,
autofocus: true, autofocus: true,
options: [ options: [
@ -34,6 +33,12 @@ async function rollDice() {
{ label: "Khaos", value: "khaos" }, { label: "Khaos", value: "khaos" },
] ]
}, },
{
type: `input`,
inputType: `number`,
key: `bonusDice`,
label: `Bonus Dice`,
},
{ type: `divider` }, { type: `divider` },
{ {
type: `details`, type: `details`,
@ -49,6 +54,11 @@ async function rollDice() {
key: `unspo`, key: `unspo`,
label: `Unspiration (-1d6)`, label: `Unspiration (-1d6)`,
}, },
{
type: `checkbox`,
key: `isCriticalRoll`,
label: `Is Critical Group Roll?`,
},
], ],
}); });
@ -63,7 +73,7 @@ async function rollDice() {
let rollMode = game.settings.get(`core`, `rollMode`); let rollMode = game.settings.get(`core`, `rollMode`);
console.log(response); console.log(response);
const { stat, inspo, unspo } = response.answers; const { stat, bonusDice, inspo, unspo, isCriticalRoll, } = response.answers;
if (game.user.isGM) { if (game.user.isGM) {
ui.notifications.info(`The macro won't work for GMs`); ui.notifications.info(`The macro won't work for GMs`);
@ -71,7 +81,7 @@ async function rollDice() {
}; };
const attr = game.user.character.system.attr[stat]; const attr = game.user.character.system.attr[stat];
let diceCount = attr.value; let diceCount = attr.value + bonusDice;
if (inspo) diceCount++; if (inspo) diceCount++;
if (unspo) diceCount--; if (unspo) diceCount--;
@ -81,11 +91,9 @@ async function rollDice() {
modifier = `kl1`; modifier = `kl1`;
}; };
console.table({modifier, diceCount});
const r = new Roll(`${diceCount}d6${modifier}`); const r = new Roll(`${diceCount}d6${modifier}`);
await r.evaluate(); await r.evaluate();
console.log(r)
const diceResults = []; const diceResults = [];
const diceHTML = []; const diceHTML = [];
let countOfOnes = 0; let countOfOnes = 0;
@ -107,22 +115,40 @@ async function rollDice() {
const total = r.total; const total = r.total;
let outcome; let outcome;
let notifType = ``; let notifType = ``;
switch (total) { if (!isCriticalRoll) {
case 1: switch (total) {
case 2: case 1:
case 3: case 2:
outcome = `Failure`; case 3:
notifType = redNotif; outcome = `Failure`;
break; notifType = redNotif;
case 4: break;
case 5: case 4:
outcome = `Partial Success`; case 5:
break; outcome = `Partial Success`;
case 6: break;
outcome = `Full Success!`; case 6:
notifType = greenNotif; outcome = `Full Success!`;
break; notifType = greenNotif;
}; break;
};
}
else {
switch (total) {
case 1:
case 2:
case 3:
outcome = `Failure`;
notifType = redNotif;
break;
case 4:
case 5:
case 6:
outcome = `Pass`;
notifType = greenNotif;
break;
};
}
let content = `Rolls:<div class="dice-tooltip"><ol class="dice-rolls">${diceHTML.join(`\n`)}</ol></div><hr><div style="${notifStyle} ${notifType}">${outcome}</div>`; let content = `Rolls:<div class="dice-tooltip"><ol class="dice-rolls">${diceHTML.join(`\n`)}</ol></div><hr><div style="${notifStyle} ${notifType}">${outcome}</div>`;
@ -139,6 +165,10 @@ async function rollDice() {
rollMode = CONST.DICE_ROLL_MODES.PRIVATE; rollMode = CONST.DICE_ROLL_MODES.PRIVATE;
}; };
/*
TODO: Add stats tracking here
*/
const chatData = ChatMessage.applyRollMode( const chatData = ChatMessage.applyRollMode(
{ {
flavor: `${attr.name} Roll`, flavor: `${attr.name} Roll`,