diff --git a/lang/en.json b/lang/en.json index 4bf7d66..d18e2a0 100644 --- a/lang/en.json +++ b/lang/en.json @@ -386,10 +386,10 @@ "combat": "Combat", "Counters": "Counters", "creature": "Creature", - "fiendishSuccess": "Fiendish Failure", + "fiendishFailure": "Fiendish Failure", "satanicSuccess": "Satanic Success", - "bonus": "Bonus", - "penalty": "Penalty", + "bonus": "Upright XP Trigger", + "penalty": "Reversed XP Trigger", "quote": "Quote", "current": "Curr.", "damage": "Damage", diff --git a/module/documents/roll.mjs b/module/documents/roll.mjs index c4c2eec..e2ebbc0 100644 --- a/module/documents/roll.mjs +++ b/module/documents/roll.mjs @@ -219,22 +219,32 @@ export default class HellbornRoll extends Roll { } else if (this.total >= options.difficulty) { resultType = "success" } + // Compute the result quality this.options.satanicSuccess = false this.options.fiendishFailure = false this.options.rollData = foundry.utils.duplicate(rollData) - if (resultType === "success") { - let nb6 = roll.terms[0].results.filter(r => r.result >= 4).length - nb6 += roll.terms[2].total <= 4 ? 1 : 0 - this.options.satanicSuccess = nb6 >= 3 + + // Check if all results are equal + let workResults = foundry.utils.duplicate(roll.terms[0].results) + // Get the most common result of the roll + let commonResult = workResults.reduce((acc, r) => { + acc[r.result] = (acc[r.result] || 0) + 1 + return acc + }, {}) + commonResult = Object.entries(commonResult).reduce((a, b) => (a[1] > b[1]) ? a : b)[0] + let nbEqual = workResults.filter(r => Number(r.result) === Number(commonResult)).length + + if (commonResult >= 4 && nbEqual >= 2) { + nbEqual += (options.nbAdvantages > 0 && roll.terms[2].total === commonResult) ? 1 : 0 + this.options.satanicSuccess = nbEqual >= 3 if (this.options.satanicSuccess) { resultType = "success" } } - if (resultType === "failure") { - let nb1 = roll.terms[0].results.filter(r => r.result <= 3).length - nb1 += roll.terms[4].total <= 3 ? 1 : 0 - this.options.fiendishFailure = nb1 >= 3 + if (commonResult <= 3 && nbEqual >= 2) { + nbEqual += (options.nbDisadvantages > 0 && roll.terms[4].total === commonResult) ? 1 : 0 + this.options.fiendishFailure = nbEqual >= 3 if (this.options.fiendishFailure) { resultType = "failure" } diff --git a/templates/chat-message.hbs b/templates/chat-message.hbs index 7a081af..ef0d202 100644 --- a/templates/chat-message.hbs +++ b/templates/chat-message.hbs @@ -23,7 +23,7 @@