diff --git a/modules/WFRP3eRoll.js b/modules/WFRP3eRoll.js index d7a6548..9fde976 100644 --- a/modules/WFRP3eRoll.js +++ b/modules/WFRP3eRoll.js @@ -17,7 +17,7 @@ export default class WFRP3eRoll extends Roll this.symbols = { ...Object.values(CONFIG.WFRP3e.symbols).reduce((object, symbol) => { - object[symbol.plural] = +dicePool[symbol.plural] ?? 0; + object[symbol.plural] = isNaN(dicePool[symbol.plural]) ? 0 : +dicePool[symbol.plural]; return object; }, {}) }; @@ -57,7 +57,8 @@ export default class WFRP3eRoll extends Roll /** @inheritDoc */ evaluate({minimize = false, maximize = false} = {}) { - if(this._evaluated) throw new Error("This Roll object has already been rolled."); + if(this._evaluated) + throw new Error("This Roll object has already been rolled."); // Step 1 - evaluate any inner Rolls and recompile the formula let hasInner = false; @@ -79,9 +80,17 @@ export default class WFRP3eRoll extends Roll this.terms = this._identifyTerms(formula); } - // Step 3 - evaluate any remaining terms and return any non-FFG dialogs to the total. + // Step 3 - evaluate any remaining terms and return any non-special dialogs to the total. this.results = this.terms.map((term) => { - if(!game.symbols.diceterms.includes(term.constructor)) { + if(game.symbols.diceterms.includes(term.constructor)) { + if(term.evaluate) + term.evaluate({minimize, maximize}); + + this.hasSpecialDice = true; + + return 0; + } + else { if(term.evaluate) { if(!(term instanceof OperatorTerm)) this.hasStandardDice = true; @@ -91,14 +100,6 @@ export default class WFRP3eRoll extends Roll else return term; } - else { - if(term.evaluate) - term.evaluate({minimize, maximize}); - - this.hasSpecialDice = true; - - return 0; - } }); // Step 4 - safely evaluate the final total @@ -239,7 +240,7 @@ export default class WFRP3eRoll extends Roll }; }), hasSpecialDice: this.hasSpecialDice, - hasStandard: this.hasStandardDice, + hasStandardDice: this.hasStandardDice, hasSuccess: this.dice.length > 0, data: this.data, addedResults: this.addedResults, @@ -262,7 +263,6 @@ export default class WFRP3eRoll extends Roll if(["gmroll", "blindroll"].includes(rMode)) messageData.whisper = ChatMessage.getWhisperRecipients("GM"); - if(rMode === "blindroll") messageData.blind = true; if(rMode === "selfroll") @@ -295,7 +295,7 @@ export default class WFRP3eRoll extends Roll json.symbols = this.symbols; json.hasSpecialDice = this.hasSpecialDice; - json.hasStandard = this.hasStandardDice; + json.hasStandardDice = this.hasStandardDice; json.data = this.data; json.addedResults = this.addedResults; json.flavor = this.flavor; diff --git a/styles/less/components/roll_message.less b/styles/less/components/roll_message.less index f5fe116..e5ffda0 100644 --- a/styles/less/components/roll_message.less +++ b/styles/less/components/roll_message.less @@ -42,6 +42,10 @@ } } +.dice-total:not(:last-child) { + margin-bottom: 0.25rem; +} + .roll-effects { & > h5 { margin: 0; diff --git a/styles/wfrp3e.css b/styles/wfrp3e.css index 89b299e..0b4ee2d 100644 --- a/styles/wfrp3e.css +++ b/styles/wfrp3e.css @@ -1450,6 +1450,9 @@ .dice-tooltip .dice-rolls .roll > .special-die { width: 44px; } +.dice-total:not(:last-child) { + margin-bottom: 0.25rem; +} .roll-effects > h5 { margin: 0; } diff --git a/templates/chatmessages/roll.hbs b/templates/chatmessages/roll.hbs index 7b539c1..14ccb5a 100644 --- a/templates/chatmessages/roll.hbs +++ b/templates/chatmessages/roll.hbs @@ -3,12 +3,16 @@
{{data.additionalFlavourText}}
{{/if}} - {{#if publicRoll }} + {{#if publicRoll}}
- {{#if hasStandard}} + {{#if hasStandardDice}}
{{formula}}
{{/if}} + {{#if hasStandardDice}} +

{{total}}

+ {{/if}} + {{#if hasSpecialDice}}
    @@ -33,10 +37,6 @@ {{{tooltip}}} - {{#if hasStandard}} -

    {{total}}

    - {{/if}} - {{#if hasSpecialDice}}
      {{#if hasSuccess}}