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`,
key: `stat`,
inputType: `number`,
label: `Stat Base`,
autofocus: true,
options: [
@ -34,6 +33,12 @@ async function rollDice() {
{ label: "Khaos", value: "khaos" },
]
},
{
type: `input`,
inputType: `number`,
key: `bonusDice`,
label: `Bonus Dice`,
},
{ type: `divider` },
{
type: `details`,
@ -49,6 +54,11 @@ async function rollDice() {
key: `unspo`,
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`);
console.log(response);
const { stat, inspo, unspo } = response.answers;
const { stat, bonusDice, inspo, unspo, isCriticalRoll, } = response.answers;
if (game.user.isGM) {
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];
let diceCount = attr.value;
let diceCount = attr.value + bonusDice;
if (inspo) diceCount++;
if (unspo) diceCount--;
@ -81,11 +91,9 @@ async function rollDice() {
modifier = `kl1`;
};
console.table({modifier, diceCount});
const r = new Roll(`${diceCount}d6${modifier}`);
await r.evaluate();
console.log(r)
const diceResults = [];
const diceHTML = [];
let countOfOnes = 0;
@ -107,22 +115,40 @@ async function rollDice() {
const total = r.total;
let outcome;
let notifType = ``;
switch (total) {
case 1:
case 2:
case 3:
outcome = `Failure`;
notifType = redNotif;
break;
case 4:
case 5:
outcome = `Partial Success`;
break;
case 6:
outcome = `Full Success!`;
notifType = greenNotif;
break;
};
if (!isCriticalRoll) {
switch (total) {
case 1:
case 2:
case 3:
outcome = `Failure`;
notifType = redNotif;
break;
case 4:
case 5:
outcome = `Partial Success`;
break;
case 6:
outcome = `Full Success!`;
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>`;
@ -139,6 +165,10 @@ async function rollDice() {
rollMode = CONST.DICE_ROLL_MODES.PRIVATE;
};
/*
TODO: Add stats tracking here
*/
const chatData = ChatMessage.applyRollMode(
{
flavor: `${attr.name} Roll`,