Fix success/failure computation
All checks were successful
Release Creation / build (release) Successful in 58s

This commit is contained in:
2025-05-30 09:54:58 +02:00
parent 0ee42aef99
commit 10e668bc71
3 changed files with 51 additions and 43 deletions

View File

@@ -386,10 +386,10 @@
"combat": "Combat", "combat": "Combat",
"Counters": "Counters", "Counters": "Counters",
"creature": "Creature", "creature": "Creature",
"fiendishSuccess": "Fiendish Failure", "fiendishFailure": "Fiendish Failure",
"satanicSuccess": "Satanic Success", "satanicSuccess": "Satanic Success",
"bonus": "Bonus", "bonus": "Upright XP Trigger",
"penalty": "Penalty", "penalty": "Reversed XP Trigger",
"quote": "Quote", "quote": "Quote",
"current": "Curr.", "current": "Curr.",
"damage": "Damage", "damage": "Damage",

View File

@@ -219,22 +219,32 @@ export default class HellbornRoll extends Roll {
} else if (this.total >= options.difficulty) { } else if (this.total >= options.difficulty) {
resultType = "success" resultType = "success"
} }
// Compute the result quality // Compute the result quality
this.options.satanicSuccess = false this.options.satanicSuccess = false
this.options.fiendishFailure = false this.options.fiendishFailure = false
this.options.rollData = foundry.utils.duplicate(rollData) this.options.rollData = foundry.utils.duplicate(rollData)
if (resultType === "success") {
let nb6 = roll.terms[0].results.filter(r => r.result >= 4).length // Check if all results are equal
nb6 += roll.terms[2].total <= 4 ? 1 : 0 let workResults = foundry.utils.duplicate(roll.terms[0].results)
this.options.satanicSuccess = nb6 >= 3 // 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) { if (this.options.satanicSuccess) {
resultType = "success" resultType = "success"
} }
} }
if (resultType === "failure") { if (commonResult <= 3 && nbEqual >= 2) {
let nb1 = roll.terms[0].results.filter(r => r.result <= 3).length nbEqual += (options.nbDisadvantages > 0 && roll.terms[4].total === commonResult) ? 1 : 0
nb1 += roll.terms[4].total <= 3 ? 1 : 0 this.options.fiendishFailure = nbEqual >= 3
this.options.fiendishFailure = nb1 >= 3
if (this.options.fiendishFailure) { if (this.options.fiendishFailure) {
resultType = "failure" resultType = "failure"
} }

View File

@@ -35,11 +35,6 @@
{{/if}} {{/if}}
{{#if (eq resultType "unknown")}}
<li class="result-unknown">
{{localize "HELLBORN.Label.unknown"}}
</li>
{{else}}
{{#if isSuccess}} {{#if isSuccess}}
{{#if satanicSuccess}} {{#if satanicSuccess}}
<li class="result-satanic-success"> <li class="result-satanic-success">
@@ -65,9 +60,12 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if isCritical}} {{#if (eq resultType "unknown")}}
{{/if}} <li class="result-unknown">
{{localize "HELLBORN.Label.unknown"}}
</li>
{{/if}} {{/if}}
</ul> </ul>
</div> </div>
</div> </div>