From 1a830d3823373efb17b4a478543ea916e03212c6 Mon Sep 17 00:00:00 2001 From: Justin Ross Date: Fri, 1 Jul 2022 12:31:19 -0700 Subject: [PATCH] Added simple notes field to rolls. Allows users to add a note to each roll that will display in the results. "Attacking the Devourer of Souls" or whatever. --- module/blades-actor.js | 15 ++++++++++----- module/blades-roll.js | 10 +++++----- templates/chat/action-roll.html | 4 +++- templates/chat/resistance-roll.html | 3 +++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/module/blades-actor.js b/module/blades-actor.js index fdd881d..5efdee9 100644 --- a/module/blades-actor.js +++ b/module/blades-actor.js @@ -91,12 +91,16 @@ export class BladesActor extends Actor { `; - } else { + } else { content += ` `; - } + } content += ` +
+ + +

`; @@ -111,7 +115,8 @@ export class BladesActor extends Actor { let modifier = parseInt(html.find('[name="mod"]')[0].value); let position = html.find('[name="pos"]')[0].value; let effect = html.find('[name="fx"]')[0].value; - await this.rollAttribute(attribute_name, modifier, position, effect); + let note = html.find('[name="note"]')[0].value; + await this.rollAttribute(attribute_name, modifier, position, effect, note); } }, no: { @@ -126,7 +131,7 @@ export class BladesActor extends Actor { /* -------------------------------------------- */ - async rollAttribute(attribute_name = "", additional_dice_amount = 0, position, effect) { + async rollAttribute(attribute_name = "", additional_dice_amount = 0, position, effect, note) { let dice_amount = 0; if (attribute_name !== "") { @@ -138,7 +143,7 @@ export class BladesActor extends Actor { } dice_amount += additional_dice_amount; - await bladesRoll(dice_amount, attribute_name, position, effect); + await bladesRoll(dice_amount, attribute_name, position, effect, note); } /* -------------------------------------------- */ diff --git a/module/blades-roll.js b/module/blades-roll.js index 50c0727..bcd91a6 100644 --- a/module/blades-roll.js +++ b/module/blades-roll.js @@ -5,7 +5,7 @@ * @param {string} position * @param {string} effect */ -export async function bladesRoll(dice_amount, attribute_name = "", position = "risky", effect = "standard") { +export async function bladesRoll(dice_amount, attribute_name = "", position = "risky", effect = "standard", note = "") { // ChatMessage.getSpeaker(controlledToken) let zeromode = false; @@ -17,7 +17,7 @@ export async function bladesRoll(dice_amount, attribute_name = "", position = "r // show 3d Dice so Nice if enabled r.evaluate({async:true}); - await showChatRollMessage(r, zeromode, attribute_name, position, effect); + await showChatRollMessage(r, zeromode, attribute_name, position, effect, note); } /** @@ -29,7 +29,7 @@ export async function bladesRoll(dice_amount, attribute_name = "", position = "r * @param {string} position * @param {string} effect */ -async function showChatRollMessage(r, zeromode, attribute_name = "", position = "", effect = "") { +async function showChatRollMessage(r, zeromode, attribute_name = "", position = "", effect = "", note = "") { let speaker = ChatMessage.getSpeaker(); let rolls = (r.terms)[0].results; @@ -66,11 +66,11 @@ async function showChatRollMessage(r, zeromode, attribute_name = "", position = effect_localize = 'BITD.EffectStandard' } - result = await renderTemplate("systems/blades-in-the-dark/templates/chat/action-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, position: position, position_localize: position_localize, effect: effect, effect_localize: effect_localize}); + result = await renderTemplate("systems/blades-in-the-dark/templates/chat/action-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, position: position, position_localize: position_localize, effect: effect, effect_localize: effect_localize, note: note}); } else { let stress = getBladesRollStress(rolls, zeromode); - result = await renderTemplate("systems/blades-in-the-dark/templates/chat/resistance-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, stress: stress}); + result = await renderTemplate("systems/blades-in-the-dark/templates/chat/resistance-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, stress: stress, note: note}); } let messageData = { diff --git a/templates/chat/action-roll.html b/templates/chat/action-roll.html index ca6699d..fac21ed 100644 --- a/templates/chat/action-roll.html +++ b/templates/chat/action-roll.html @@ -47,7 +47,9 @@

{{/if}} - + {{#if note}} + {{note}} + {{/if}}
    {{#each this.rolls}} {{#if this.result}} diff --git a/templates/chat/resistance-roll.html b/templates/chat/resistance-roll.html index a779552..733c89e 100644 --- a/templates/chat/resistance-roll.html +++ b/templates/chat/resistance-roll.html @@ -10,6 +10,9 @@
    {{localize "BITD.RollSuccess"}}

    {{{localize "BITD.RollResistance" stress=stress}}}

    {{/if}} + {{#if note}} + {{note}} + {{/if}}
      {{#each this.rolls}}