Skip to content

Commit

Permalink
Merge pull request #48 from McGregor777/0.5.1
Browse files Browse the repository at this point in the history
0.5.1
  • Loading branch information
Grégory Soupé authored Nov 6, 2023
2 parents caa1bef + de63329 commit f7d96d8
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 26 deletions.
1 change: 1 addition & 0 deletions lang/en-EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lang/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 15 additions & 15 deletions modules/WFRP3eRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {})
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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")
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions modules/applications/CheckBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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"];

Expand Down
4 changes: 4 additions & 0 deletions modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export const WFRP3e = {
daunting: {
challengeDice: 4,
name: "ROLL.CHALLENGELEVEL.Daunting"
},
heroic: {
challengeDice: 5,
name: "ROLL.CHALLENGELEVEL.Heroic"
}
},
conditionDurations: {
Expand Down
4 changes: 4 additions & 0 deletions styles/less/components/roll_message.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
}
}

.dice-total:not(:last-child) {
margin-bottom: 0.25rem;
}

.roll-effects {
& > h5 {
margin: 0;
Expand Down
3 changes: 3 additions & 0 deletions styles/wfrp3e.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions system.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Warhammer Fantasy Roleplay - 3rd Edition",
"description": "<p>A game system for <em><strong>Warhammer Fantasy Roleplay - 3rd Edition</strong></em> in the Foundry Virtual Tabletop environment.</p>",
"version": "0.5",
"version": "0.5.1",
"compatibility": {
"minimum": "11",
"verified": "11.314",
Expand Down Expand Up @@ -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"
}
12 changes: 6 additions & 6 deletions templates/chatmessages/roll.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<div class="dice-additional-flavor">{{data.additionalFlavourText}}</div>
{{/if}}

{{#if publicRoll }}
{{#if publicRoll}}
<div class="dice-result">
{{#if hasStandard}}
{{#if hasStandardDice}}
<div class="dice-formula">{{formula}}</div>
{{/if}}

{{#if hasStandardDice}}
<h4 class="dice-total">{{total}}</h4>
{{/if}}

{{#if hasSpecialDice}}
<div class="dice-array">
<ol class="dice-rolls">
Expand All @@ -33,10 +37,6 @@

{{{tooltip}}}

{{#if hasStandard}}
<h4 class="dice-total">{{total}}</h4>
{{/if}}

{{#if hasSpecialDice}}
<ul>
{{#if hasSuccess}}
Expand Down

0 comments on commit f7d96d8

Please sign in to comment.