diff --git a/Axolotl-with-a-Gun/guns/glock/steady-aim-and-extended.mjs b/Axolotl-with-a-Gun/guns/glock/steady-aim-and-extended.mjs new file mode 100644 index 0000000..a349444 --- /dev/null +++ b/Axolotl-with-a-Gun/guns/glock/steady-aim-and-extended.mjs @@ -0,0 +1,132 @@ +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`); + + const critOn = Math.min(statBase, 6); + let diceCount = statBase ?? 1; + diceCount += extraDice ?? 0; + + let successes = 0; + let critsOnly = 0; + const results = []; + const resultValues = []; + 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 === critOn) { + successes += 1; + critsOnly += 1; + classes += ` success`; + } + + resultValues.push(total); + results.push(`