diff --git a/Axolotl-with-a-Gun/AwaG-world-script.mjs b/Axolotl-with-a-Gun/AwaG-world-script.mjs new file mode 100644 index 0000000..4178902 --- /dev/null +++ b/Axolotl-with-a-Gun/AwaG-world-script.mjs @@ -0,0 +1,3 @@ +Hooks.on(`ready`, () => { + globalThis.WorldAPI ??= {}; +}); diff --git a/Axolotl-with-a-Gun/hobby.mjs b/Axolotl-with-a-Gun/axolotl.mjs similarity index 72% rename from Axolotl-with-a-Gun/hobby.mjs rename to Axolotl-with-a-Gun/axolotl.mjs index b00f841..2b15fb9 100644 --- a/Axolotl-with-a-Gun/hobby.mjs +++ b/Axolotl-with-a-Gun/axolotl.mjs @@ -19,7 +19,7 @@ async function rollDice() { const sidesOnDice = 6; const answers = await DialogManager.ask({ - id: `hobby-dice-pool`, + id: `axolotl-dice-pool`, question: `Set up your dice pool:`, inputs: [ { @@ -45,6 +45,7 @@ async function rollDice() { 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(); @@ -61,40 +62,65 @@ async function rollDice() { successes += 1; critsOnly += 1; classes += ` success`; - } - - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); + }; + resultValues.push(total); results.push(`
  • ${total}
  • `); - } - - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + }; let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: `Hobby Roll`, + flavor: `Axoltl Roll`, content, }, rollMode, ); await ChatMessage.implementation.create(chatData); -} +}; rollDice(); diff --git a/Axolotl-with-a-Gun/guns/AK-47.mjs b/Axolotl-with-a-Gun/guns/AK-47/base.mjs similarity index 76% rename from Axolotl-with-a-Gun/guns/AK-47.mjs rename to Axolotl-with-a-Gun/guns/AK-47/base.mjs index badada8..aedbc03 100644 --- a/Axolotl-with-a-Gun/guns/AK-47.mjs +++ b/Axolotl-with-a-Gun/guns/AK-47/base.mjs @@ -53,6 +53,7 @@ async function rollDice() { 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(); @@ -72,23 +73,21 @@ async function rollDice() { classes += ` success`; } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); } - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; - } + successType = `Downed`; + }; if (rollMode === CONST.DICE_ROLL_MODES.BLIND) { @@ -96,6 +95,33 @@ async function rollDice() { 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: AK-47)`, diff --git a/Axolotl-with-a-Gun/guns/glock/2-not-1.mjs b/Axolotl-with-a-Gun/guns/glock/2-not-1.mjs index b43bbf0..0c4cb84 100644 --- a/Axolotl-with-a-Gun/guns/glock/2-not-1.mjs +++ b/Axolotl-with-a-Gun/guns/glock/2-not-1.mjs @@ -64,9 +64,7 @@ async function rollDice() { classes += ` success`; } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); }; @@ -74,24 +72,50 @@ async function rollDice() { successes = 2; }; - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: Glock)`, diff --git a/Axolotl-with-a-Gun/guns/glock/base.mjs b/Axolotl-with-a-Gun/guns/glock/base.mjs index 2aa1f97..b9675ac 100644 --- a/Axolotl-with-a-Gun/guns/glock/base.mjs +++ b/Axolotl-with-a-Gun/guns/glock/base.mjs @@ -45,6 +45,7 @@ async function rollDice() { 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(); @@ -64,32 +65,56 @@ async function rollDice() { classes += ` success`; } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); } successes = Math.max(successes, 1); - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: Glock)`, diff --git a/Axolotl-with-a-Gun/guns/gunsword/base.mjs b/Axolotl-with-a-Gun/guns/gunsword/base.mjs index 7fb6e63..9ec5c4e 100644 --- a/Axolotl-with-a-Gun/guns/gunsword/base.mjs +++ b/Axolotl-with-a-Gun/guns/gunsword/base.mjs @@ -53,6 +53,7 @@ async function rollDice() { 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(); @@ -74,30 +75,56 @@ async function rollDice() { classes += ` discarded` } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); } game.user.setFlag(`world`, `comboCount`, comboCount); - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}
    Combo Count After Roll: ${comboCount}`; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: Gunsword)`, diff --git a/Axolotl-with-a-Gun/guns/gunsword/only-empty-half.mjs b/Axolotl-with-a-Gun/guns/gunsword/only-empty-half.mjs index 3da0111..6bf13e2 100644 --- a/Axolotl-with-a-Gun/guns/gunsword/only-empty-half.mjs +++ b/Axolotl-with-a-Gun/guns/gunsword/only-empty-half.mjs @@ -53,6 +53,7 @@ async function rollDice() { 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(); @@ -74,30 +75,56 @@ async function rollDice() { classes += ` discarded` } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); } game.user.setFlag(`world`, `comboCount`, comboCount); - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}
    Combo Count After Roll: ${comboCount}`; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: Gunsword)`, diff --git a/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs b/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs index 268d6cd..2e02ac8 100644 --- a/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs +++ b/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs @@ -45,6 +45,7 @@ async function rollDice() { let successes = 0; let critsOnly = 0; const results = []; + const resultValues = []; for (let i = diceCount; i > 0; i--) { let r = new Roll(`1d${sidesOnDice}x=${statBase}`); await r.evaluate(); @@ -64,30 +65,56 @@ async function rollDice() { critsOnly += 1; classes += ` success exploded`; } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); + resultValues.push(total); results.push(`
  • ${total}
  • `); } - } - - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + }; let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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: Hand Cannon)`, diff --git a/Axolotl-with-a-Gun/guns/mini-gun/base.mjs b/Axolotl-with-a-Gun/guns/mini-gun/base.mjs index 1c1d645..3354d48 100644 --- a/Axolotl-with-a-Gun/guns/mini-gun/base.mjs +++ b/Axolotl-with-a-Gun/guns/mini-gun/base.mjs @@ -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(`
  • ${total}
  • `); }; @@ -137,21 +135,50 @@ async function main() { if (gunLoss > 0) { content += `
    Lose ${gunLoss} GUN
    `; - } + }; + let successType = `Normal`; if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { content += `
    Pinned Down
    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)`, diff --git a/Axolotl-with-a-Gun/guns/mini-gun/ventable.mjs b/Axolotl-with-a-Gun/guns/mini-gun/ventable.mjs deleted file mode 100644 index c6130a3..0000000 --- a/Axolotl-with-a-Gun/guns/mini-gun/ventable.mjs +++ /dev/null @@ -1,166 +0,0 @@ -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 main() { - let heatMeter = game.user.getFlag(`world`, `heatMeter`) ?? 0; - - const answers = await DialogManager.ask({ - id: `mini-gun-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 { extraDice } = answers; - let { statBase } = answers; - let rollMode = game.settings.get(`core`, `rollMode`); - - let diceCount = statBase; - diceCount += extraDice; - if (statBase === 6) { - diceCount += 6; - }; - - let statGain = 0; - let gunLoss = 0; - let successes = 0; - let critsOnly = 0; - let results = []; - for (let i = 0; i < diceCount; i++) { - let succeeded = false; - - let r = new Roll(`1d6`); - await r.evaluate(); - let classes = `roll die d6`; - - const total = r.total; - - if (total <= statBase) { - successes += 1; - succeeded = true; - } - else { - classes += ` discarded` - } - if (total === statBase) { - successes += 1; - critsOnly += 1; - classes += ` success`; - } - - if (statBase === 6 && i <= 6) { - if (i === 6) { - statBase -= 1; - }; - continue - } - - if (succeeded) { - try { - const { holdTheTrigger, ventHeat } = await DialogManager.ask({ - id: `mini-gun-hold-the-trigger`, - question: `Hold The Trigger?`, - inputs: [ - { - key: `_1`, - inputType: `hidden`, - label: `Success Count: ${successes}`, - }, - { - key: `_2`, - inputType: `hidden`, - label: `Total Dice Rolled: ${i + 1}/${diceCount}`, - }, - { - key: `_3`, - inputType: `hidden`, - label: `Current Heat: ${heatMeter}/6`, - }, - { - key: `holdTheTrigger`, - inputType: `checkbox`, - label: `Hold The Trigger?`, - details: `If you hold the trigger, you roll an additional dice, and gain 1 heat. If you don't hold the trigger, you lose one heat. When you reach 6 heat, you lost all heat and lose 2 GUN.`, - defaultValue: false, - autofocus: true, - } - ], - }); - heatMeter += (holdTheTrigger ? 1 : -1); - if (holdTheTrigger) { - diceCount += 1; - }; - if (heatMeter >= 6) { - heatMeter = 0; - gunLoss += 2; - statBase -= 2; - } - } catch {}; - } - - // Save dice stats if present - WorldAPI?.saveRollValue?.(6, total); - - results.push(`
  • ${total}
  • `); - }; - - game.user.setFlag(`world`, `heatMeter`, heatMeter); - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - - let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}
    Final Heat: ${heatMeter}`; - - if (gunLoss > 0) { - content += `
    Lose ${gunLoss} GUN
    `; - } - - if (successes >= 8) { - content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional 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: Mini-Gun)`, - content, - }, - rollMode, - ); - - await ChatMessage.implementation.create(chatData); -} - -main(); \ 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/base.mjs similarity index 72% rename from Axolotl-with-a-Gun/guns/rocket-launcher.mjs rename to Axolotl-with-a-Gun/guns/rocket-launcher/base.mjs index 5fc1740..74bdff3 100644 --- a/Axolotl-with-a-Gun/guns/rocket-launcher.mjs +++ b/Axolotl-with-a-Gun/guns/rocket-launcher/base.mjs @@ -45,6 +45,7 @@ async function rollDice() { 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(); @@ -59,30 +60,54 @@ async function rollDice() { classes += ` discarded`; } - // Save dice stats if present - WorldAPI?.saveRollValue?.(sidesOnDice, total); - + resultValues.push(total); results.push(`
  • ${total}
  • `); - } - - WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); - WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + }; let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + let successType = `Normal`; if (successes >= 8) { content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + successType = `Popped Off`; } else if (successes === 0) { - content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; - } - + content += `
    Pinned Down
    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: Rocket Launcher)`,