Update all of the macros to account for the new module to track stats with

This commit is contained in:
Oliver-Akins 2025-06-01 21:46:19 -06:00
parent 9cee87b81e
commit 992201262f
11 changed files with 315 additions and 244 deletions

View file

@ -46,11 +46,11 @@ async function main() {
diceCount += 6;
};
let statGain = 0;
let gunLoss = 0;
let successes = 0;
let critsOnly = 0;
let results = [];
const results = [];
const resultValues = [];
for (let i = 0; i < diceCount; i++) {
let succeeded = false;
@ -123,9 +123,7 @@ async function main() {
} catch {};
}
// Save dice stats if present
WorldAPI?.saveRollValue?.(6, total);
resultValues.push(total);
results.push(`<li class="${classes}">${total}</li>`);
};
@ -137,21 +135,50 @@ async function main() {
if (gunLoss > 0) {
content += `<div style="${notifStyle} ${redNotif}">Lose ${gunLoss} GUN</div>`;
}
};
let successType = `Normal`;
if (successes >= 8) {
content += `<div style="${notifStyle} ${greenNotif}">POP OFF</div> Add one to your hobby stat and gain 1 additional Momentum!`;
content += `<div style="${notifStyle} ${greenNotif}">POP OFF</div> Add one to your gun stat and gain 1 additional Momentum!`;
successType = `Popped Off`;
}
else if (successes === 0) {
content += `<div style="${notifStyle} ${redNotif}">Pinned Down</div> Roll a d6, rescuing you becomes a new objective`;
}
successType = `Downed`;
};
if (rollMode === CONST.DICE_ROLL_MODES.BLIND) {
ui.notifications.info(`Cannot make a blind roll from the macro, rolling with mode "Private GM Roll" instead`);
rollMode = CONST.DICE_ROLL_MODES.PRIVATE;
};
const privacy = stats.utils.determinePrivacyFromRollMode(rollMode);
await CONFIG.stats.db.createRows(
`Dice/d6`,
game.user.id,
resultValues.map(value => ({ value, privacy })),
{ rerender: false },
);
await CONFIG.stats.db.createRow(
`AwaG/Type of Success`,
game.user.id,
{ value: successType, privacy },
{ rerender: false },
);
await CONFIG.stats.db.createRow(
`AwaG/Count of Successes`,
game.user.id,
{ value: successes, privacy },
{ rerender: false },
);
await CONFIG.stats.db.createRow(
`AwaG/Amount of Dice Rolled`,
game.user.id,
{ value: diceCount, privacy },
{ rerender: false },
);
CONFIG.stats.db.render();
const chatData = ChatMessage.applyRollMode(
{
flavor: `(Gun: Mini-Gun)`,