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",
"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",

View File

@@ -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"
}

View File

@@ -23,7 +23,7 @@
<li>Results :
{{#each results as |result|}}
{{result.result}}
{{result.result}}
{{/each}}
</li>
@@ -35,39 +35,37 @@
{{/if}}
{{#if (eq resultType "unknown")}}
<li class="result-unknown">
{{localize "HELLBORN.Label.unknown"}}
</li>
{{else}}
{{#if isSuccess}}
{{#if satanicSuccess}}
<li class="result-satanic-success">
{{localize "HELLBORN.Label.satanicSuccess"}}
</li>
{{else}}
<li class="result-success">
{{localize "HELLBORN.Label.success"}}
</li>
{{/if}}
{{/if}}
{{#if isFailure}}
{{#if fiendishFailure}}
<li class="result-fiendish-failure">
{{localize "HELLBORN.Label.fiendishFailure"}}
</li>
{{else}}
<li class="result-failure">
{{localize "HELLBORN.Label.failure"}}
</li>
{{/if}}
{{/if}}
{{#if isCritical}}
{{#if isSuccess}}
{{#if satanicSuccess}}
<li class="result-satanic-success">
{{localize "HELLBORN.Label.satanicSuccess"}}
</li>
{{else}}
<li class="result-success">
{{localize "HELLBORN.Label.success"}}
</li>
{{/if}}
{{/if}}
{{#if isFailure}}
{{#if fiendishFailure}}
<li class="result-fiendish-failure">
{{localize "HELLBORN.Label.fiendishFailure"}}
</li>
{{else}}
<li class="result-failure">
{{localize "HELLBORN.Label.failure"}}
</li>
{{/if}}
{{/if}}
{{#if (eq resultType "unknown")}}
<li class="result-unknown">
{{localize "HELLBORN.Label.unknown"}}
</li>
{{/if}}
</ul>
</div>
</div>