Fix success/failure computation
All checks were successful
Release Creation / build (release) Successful in 1m0s
All checks were successful
Release Creation / build (release) Successful in 1m0s
This commit is contained in:
@@ -199,7 +199,17 @@ export default class HellbornRoll extends Roll {
|
|||||||
|
|
||||||
options.nbAdvantages = Number(options.nbAdvantages)
|
options.nbAdvantages = Number(options.nbAdvantages)
|
||||||
options.nbDisadvantages = Number(options.nbDisadvantages)
|
options.nbDisadvantages = Number(options.nbDisadvantages)
|
||||||
let diceFormula = `3D6 + ${options.nbAdvantages}D6kh - ${options.nbDisadvantages}D6kh + ${options.rollItem.value}`
|
let dice = 3;
|
||||||
|
let keep = ""
|
||||||
|
if ( options.nbAdvantages > 0 || options.nbDisadvantages > 0) {
|
||||||
|
dice = 4;
|
||||||
|
if ( options.nbAdvantages > options.nbDisadvantages) {
|
||||||
|
keep = "kh3"
|
||||||
|
} else {
|
||||||
|
keep = "kl3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let diceFormula = `${dice}D6${keep} + ${options.rollItem.value}`
|
||||||
const roll = new this(diceFormula, options.data, rollData)
|
const roll = new this(diceFormula, options.data, rollData)
|
||||||
await roll.evaluate()
|
await roll.evaluate()
|
||||||
console.log("Roll", rollData, roll)
|
console.log("Roll", rollData, roll)
|
||||||
@@ -235,16 +245,14 @@ export default class HellbornRoll extends Roll {
|
|||||||
commonResult = Object.entries(commonResult).reduce((a, b) => (a[1] > b[1]) ? a : b)[0]
|
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
|
let nbEqual = workResults.filter(r => Number(r.result) === Number(commonResult)).length
|
||||||
|
|
||||||
if (commonResult >= 4 && nbEqual >= 2) {
|
if (commonResult >= 4 && nbEqual >= 3) {
|
||||||
nbEqual += (options.nbAdvantages > 0 && roll.terms[2].total === commonResult) ? 1 : 0
|
this.options.satanicSuccess = true
|
||||||
this.options.satanicSuccess = nbEqual >= 3
|
|
||||||
if (this.options.satanicSuccess) {
|
if (this.options.satanicSuccess) {
|
||||||
resultType = "success"
|
resultType = "success"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (commonResult <= 3 && nbEqual >= 2) {
|
if (commonResult <= 3 && nbEqual >= 3) {
|
||||||
nbEqual += (options.nbDisadvantages > 0 && roll.terms[4].total === commonResult) ? 1 : 0
|
this.options.fiendishFailure = true
|
||||||
this.options.fiendishFailure = nbEqual >= 3
|
|
||||||
if (this.options.fiendishFailure) {
|
if (this.options.fiendishFailure) {
|
||||||
resultType = "failure"
|
resultType = "failure"
|
||||||
}
|
}
|
||||||
@@ -253,8 +261,6 @@ export default class HellbornRoll extends Roll {
|
|||||||
this.options.isSuccess = resultType === "success"
|
this.options.isSuccess = resultType === "success"
|
||||||
this.options.isFailure = resultType === "failure"
|
this.options.isFailure = resultType === "failure"
|
||||||
this.options.results = roll.terms[0].results
|
this.options.results = roll.terms[0].results
|
||||||
this.options.advantageResult = roll.terms[2].total
|
|
||||||
this.options.disadvantageResult = roll.terms[4].total
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,20 +21,19 @@
|
|||||||
|
|
||||||
<li>{{localize "HELLBORN.Label.difficulty"}} : {{difficulty}}</li>
|
<li>{{localize "HELLBORN.Label.difficulty"}} : {{difficulty}}</li>
|
||||||
|
|
||||||
|
{{#if (gt nbAdvantages 0)}}
|
||||||
|
<li>With Advantage !</li>
|
||||||
|
{{/if}}
|
||||||
|
{{#if (gt nbDisadvantages 0)}}
|
||||||
|
<li>With Disadvantages ! </li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<li>Results :
|
<li>Results :
|
||||||
{{#each results as |result|}}
|
{{#each results as |result|}}
|
||||||
{{result.result}}
|
{{result.result}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{{#if (gt nbAdvantages 0)}}
|
|
||||||
<li>Advantages : {{nbAdvantages}}, result {{advantageResult}}</li>
|
|
||||||
{{/if}}
|
|
||||||
{{#if (gt nbDisadvantages 0)}}
|
|
||||||
<li>Disadvantages : {{nbDisadvantages}}, result {{disadvantageResult}}</li>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
|
|
||||||
{{#if isSuccess}}
|
{{#if isSuccess}}
|
||||||
{{#if satanicSuccess}}
|
{{#if satanicSuccess}}
|
||||||
<li class="result-satanic-success">
|
<li class="result-satanic-success">
|
||||||
|
|||||||
Reference in New Issue
Block a user