Update the gun macros
This commit is contained in:
parent
9d4704897f
commit
9cee87b81e
6 changed files with 403 additions and 6 deletions
106
Axolotl-with-a-Gun/guns/glock/2-not-1.mjs
Normal file
106
Axolotl-with-a-Gun/guns/glock/2-not-1.mjs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
const notifStyle = `
|
||||
font-size: 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
padding: 6px 8px;
|
||||
box-shadow: 0 0 10px var(--color-shadow-dark);
|
||||
color: var(--color-text-light-1);
|
||||
border-radius: 5px;
|
||||
text-align: center;`;
|
||||
|
||||
const greenNotif = `
|
||||
background: var(--color-level-success-bg);
|
||||
border: 1px solid var(--color-level-success-border);`;
|
||||
|
||||
const redNotif = `
|
||||
background: var(--color-level-error-bg);
|
||||
border: 1px solid var(--color-level-error);`;
|
||||
|
||||
async function rollDice() {
|
||||
const sidesOnDice = 6;
|
||||
|
||||
const answers = await DialogManager.ask({
|
||||
id: `glock-dice-pool`,
|
||||
question: `Set up your dice pool:`,
|
||||
inputs: [
|
||||
{
|
||||
key: `statBase`,
|
||||
inputType: `number`,
|
||||
label: `Stat Base`,
|
||||
autofocus: true,
|
||||
},
|
||||
{
|
||||
key: `extraDice`,
|
||||
inputType: `number`,
|
||||
label: `Extra Dice`,
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
});
|
||||
const { statBase, extraDice } = answers;
|
||||
let rollMode = game.settings.get(`core`, `rollMode`);
|
||||
|
||||
let diceCount = statBase;
|
||||
diceCount += extraDice;
|
||||
|
||||
let successes = 0;
|
||||
let critsOnly = 0;
|
||||
const results = [];
|
||||
for (let i = diceCount; i > 0; i--) {
|
||||
let r = new Roll(`1d${sidesOnDice}`);
|
||||
await r.evaluate();
|
||||
let classes = `roll die d${sidesOnDice}`;
|
||||
|
||||
const total = r.total;
|
||||
|
||||
if (total <= statBase) {
|
||||
successes += 1;
|
||||
}
|
||||
else {
|
||||
classes += ` discarded`
|
||||
}
|
||||
if (total === statBase) {
|
||||
successes += 1;
|
||||
critsOnly += 1;
|
||||
classes += ` success`;
|
||||
}
|
||||
|
||||
// Save dice stats if present
|
||||
WorldAPI?.saveRollValue?.(sidesOnDice, total);
|
||||
|
||||
results.push(`<li class="${classes}">${total}</li>`);
|
||||
};
|
||||
|
||||
if (successes === 0) {
|
||||
successes = 2;
|
||||
};
|
||||
|
||||
WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20));
|
||||
WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes);
|
||||
|
||||
let content = `Rolls:<div class="dice-tooltip"><ol class="dice-rolls">${results.join(`\n`)}</ol></div><hr>Gain 1 Momentum<br>Successes: ${successes}<br>Crits: ${critsOnly}`;
|
||||
|
||||
if (successes >= 8) {
|
||||
content += `<div style="${notifStyle} ${greenNotif}">POP OFF</div> Add one to your hobby stat and gain 1 additional Momentum!`;
|
||||
}
|
||||
else if (successes === 0) {
|
||||
content += `<div style="${notifStyle} ${redNotif}">Pinned Down</div> Roll a d6, rescuing you becomes a new objective`;
|
||||
}
|
||||
|
||||
|
||||
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 chatData = ChatMessage.applyRollMode(
|
||||
{
|
||||
flavor: `(Gun: Glock)`,
|
||||
content,
|
||||
},
|
||||
rollMode,
|
||||
);
|
||||
|
||||
await ChatMessage.implementation.create(chatData);
|
||||
}
|
||||
|
||||
rollDice();
|
||||
Loading…
Add table
Add a link
Reference in a new issue