diff --git a/lang/en-EN.json b/lang/en-EN.json index a794468..eb99bce 100644 --- a/lang/en-EN.json +++ b/lang/en-EN.json @@ -259,6 +259,7 @@ "ROLL.CHALLENGELEVEL.Average": "Average", "ROLL.CHALLENGELEVEL.Hard": "Hard", "ROLL.CHALLENGELEVEL.Daunting": "Daunting", + "ROLL.CHALLENGELEVEL.Heroic": "Heroic", "ROLL.CHECKBUILDER.AggressionDice": "Aggression Dice", "ROLL.CHECKBUILDER.ChallengeLevel": "Challenge Level", "ROLL.CHECKBUILDER.Characteristic": "Characteristic", diff --git a/lang/fr-FR.json b/lang/fr-FR.json index 350496c..dbee69e 100644 --- a/lang/fr-FR.json +++ b/lang/fr-FR.json @@ -259,6 +259,7 @@ "ROLL.CHALLENGELEVEL.Average": "Average", "ROLL.CHALLENGELEVEL.Hard": "Hard", "ROLL.CHALLENGELEVEL.Daunting": "Daunting", + "ROLL.CHALLENGELEVEL.Heroic": "Heroic", "ROLL.CHECKBUILDER.AggressionDice": "Aggression Dice", "ROLL.CHECKBUILDER.ChallengeLevel": "Challenge Level", "ROLL.CHECKBUILDER.Characteristic": "Caractéristique", 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/modules/applications/CheckBuilder.js b/modules/applications/CheckBuilder.js index 67c5970..81913e9 100644 --- a/modules/applications/CheckBuilder.js +++ b/modules/applications/CheckBuilder.js @@ -529,7 +529,7 @@ export default class CheckBuilder extends FormApplication ChatMessage.create(chatOptions); } - else if(this.roll.data.combat) { + else if(this.roll.data?.combat) { const currentCombatantId = this.roll.data.combat.combatant?.id; const encounterType = html.find('.encounter-type input:checked').val(); const initiativeCharacteristic = encounterType === "social" ? "fellowship" : "agility"; @@ -623,7 +623,7 @@ export default class CheckBuilder extends FormApplication if(this.roll?.sound) AudioHelper.play({src: this.roll.sound}, true); - if(this.roll.data.actor.type === "creature") + if(this.roll.data?.actor.type === "creature") Object.keys(CONFIG.WFRP3e.attributes).forEach((attribute) => { const attributeDiceAmount = this.dicePool["creatures" + (attribute[0].toUpperCase() + attribute.slice(1, attribute.length)) + "Dice"]; diff --git a/modules/config.js b/modules/config.js index dbf6cf5..6abe60d 100644 --- a/modules/config.js +++ b/modules/config.js @@ -76,6 +76,10 @@ export const WFRP3e = { daunting: { challengeDice: 4, name: "ROLL.CHALLENGELEVEL.Daunting" + }, + heroic: { + challengeDice: 5, + name: "ROLL.CHALLENGELEVEL.Heroic" } }, conditionDurations: { 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/system.json b/system.json index 95949e8..881d40a 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "title": "Warhammer Fantasy Roleplay - 3rd Edition", "description": "
A game system for Warhammer Fantasy Roleplay - 3rd Edition in the Foundry Virtual Tabletop environment.
", - "version": "0.5", + "version": "0.5.1", "compatibility": { "minimum": "11", "verified": "11.314", @@ -44,8 +44,8 @@ "primaryTokenAttribute": "wounds", "secondaryTokenAttribute": "fortune", "url": "https://github.com/McGregor777/wfrp3e", - "manifest": "https://raw.githubusercontent.com/McGregor777/wfrp3e/0.5/system.json", - "download": "https://github.com/McGregor777/wfrp3e/archive/refs/tags/0.5.zip", + "manifest": "https://raw.githubusercontent.com/McGregor777/wfrp3e/0.5.1/system.json", + "download": "https://github.com/McGregor777/wfrp3e/archive/refs/tags/0.5.1.zip", "background": "systems/wfrp3e/assets/background.jpg", "id": "wfrp3e" } \ No newline at end of file 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 @@