diff --git a/Axolotl-with-a-Gun/guns/AK-47.mjs b/Axolotl-with-a-Gun/guns/AK-47.mjs new file mode 100644 index 0000000..8accf6e --- /dev/null +++ b/Axolotl-with-a-Gun/guns/AK-47.mjs @@ -0,0 +1,109 @@ +const notifStyle = ` + font-size: 1.5rem; + margin-bottom: 0.5rem; + 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: `ak47-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, + }, + { + key: `bonusThreshold`, + defaultValue: 2, + label: `Bonus Threshold (when stat base <= bonus threshold, gain 3 dice)`, + } + ], + }); + const { statBase, bonusThreshold, extraDice, } = answers; + let rollMode = game.settings.get(`core`, `rollMode`); + + let diceCount = statBase; + if (statBase <= bonusThreshold) { + diceCount += 3; + }; + 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(`
  • ${total}
  • `); + } + + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + + if (successes >= 8) { + content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + } + else if (successes === 0) { + content += `

    Pinned Down
    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: AK-47)`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +rollDice(); \ No newline at end of file diff --git a/Axolotl-with-a-Gun/guns/glock.mjs b/Axolotl-with-a-Gun/guns/glock.mjs new file mode 100644 index 0000000..2c1f167 --- /dev/null +++ b/Axolotl-with-a-Gun/guns/glock.mjs @@ -0,0 +1,105 @@ +const notifStyle = ` + font-size: 1.5rem; + margin-bottom: 0.5rem; + 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);`; + +const blueText = `color: ; filter: sepia(0.5) hue-rotate()`; + +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(`
  • ${total}
  • `); + } + + successes = Math.max(successes, 1); + + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + + if (successes >= 8) { + content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + } + else if (successes === 0) { + content += `

    Pinned Down
    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(); \ No newline at end of file diff --git a/Axolotl-with-a-Gun/guns/rocket-launcher.mjs b/Axolotl-with-a-Gun/guns/rocket-launcher.mjs new file mode 100644 index 0000000..958e81f --- /dev/null +++ b/Axolotl-with-a-Gun/guns/rocket-launcher.mjs @@ -0,0 +1,96 @@ +const notifStyle = ` + font-size: 1.5rem; + margin-bottom: 0.5rem; + 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: `rocket-launcher-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 + 1 || total === statBase - 1) { + successes += 2; + critsOnly += 1; + classes += ` success`; + } else { + classes += ` discarded`; + } + + // Save dice stats if present + WorldAPI?.saveRollValue?.(sidesOnDice, total); + + results.push(`
  • ${total}
  • `); + } + + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + + if (successes >= 8) { + content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + } + else if (successes === 0) { + content += `

    Pinned Down
    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: Rocket Launcher)`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +rollDice(); diff --git a/Axolotl-with-a-Gun/hobby.mjs b/Axolotl-with-a-Gun/hobby.mjs new file mode 100644 index 0000000..cdae639 --- /dev/null +++ b/Axolotl-with-a-Gun/hobby.mjs @@ -0,0 +1,100 @@ +const notifStyle = ` + font-size: 1.5rem; + margin-bottom: 0.5rem; + 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: `hobby-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(`
  • ${total}
  • `); + } + + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + + if (successes >= 8) { + content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + } + else if (successes === 0) { + content += `

    Pinned Down
    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: `Hobby Roll`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +rollDice();