forked from public/fvtt-yggdrasill
fix calculation of furor usage
This commit is contained in:
parent
63d1c5847b
commit
8d56fed614
@ -87,12 +87,14 @@ export class YggdrasillUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async specificYggRoll( nbDice ) {
|
static async specificYggRoll( nbDice ) {
|
||||||
|
return specificYggRoll(nbDice, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async specificYggRoll( nbDice, isFurorUsage ) {
|
||||||
let rawDices = []
|
let rawDices = []
|
||||||
let rolls = []
|
let rolls = []
|
||||||
let maxTab = []
|
let maxTab = []
|
||||||
|
let maxTabMaxIndex = isFurorUsage ? nbDice : 2;
|
||||||
maxTab[0] = {idx: 0, value: 0}
|
|
||||||
maxTab[1] = {idx: 0, value: 0}
|
|
||||||
|
|
||||||
for (let i=0; i<nbDice; i++) {
|
for (let i=0; i<nbDice; i++) {
|
||||||
rolls[i] = new Roll("1d10x10").roll( {async: false}) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
|
rolls[i] = new Roll("1d10x10").roll( {async: false}) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
|
||||||
@ -102,18 +104,16 @@ export class YggdrasillUtility {
|
|||||||
this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
|
this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
|
||||||
}
|
}
|
||||||
rawDices.push({ 'result': rolls[i].total});
|
rawDices.push({ 'result': rolls[i].total});
|
||||||
|
}
|
||||||
|
|
||||||
if ( rolls[i].total > maxTab[0].value) {
|
rolls.sort((a,b) => a.total-b.total);
|
||||||
if ( nbDice > 1 && maxTab[0].value > maxTab[1].value) {
|
rolls.reverse();
|
||||||
maxTab[1].value = maxTab[0].value
|
|
||||||
}
|
for (let i=0; i<maxTabMaxIndex; i++) {
|
||||||
maxTab[0].value = rolls[i].total
|
maxTab[i] = {idx: 0, value: 0};
|
||||||
} else {
|
if (rolls[i].total != undefined) maxTab[i].value = rolls[i].total;
|
||||||
if ( nbDice > 1 && rolls[i].total > maxTab[1].value) {
|
|
||||||
maxTab[1].value = rolls[i].total
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { rawDices: rawDices, maxTab: maxTab, rolls: rolls }
|
return { rawDices: rawDices, maxTab: maxTab, rolls: rolls }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ export class YggdrasillUtility {
|
|||||||
console.log("RES", results, nbDice, sumDice)
|
console.log("RES", results, nbDice, sumDice)
|
||||||
|
|
||||||
if ( rollData.furorUsage > 0 ) {
|
if ( rollData.furorUsage > 0 ) {
|
||||||
results = await this.specificYggRoll( rollData.furorUsage )
|
results = await this.specificYggRoll( rollData.furorUsage, true )
|
||||||
rollData.furorRawDices = results.rawDices
|
rollData.furorRawDices = results.rawDices
|
||||||
rollData.furorMaxTab = results.maxTab
|
rollData.furorMaxTab = results.maxTab
|
||||||
rollData.furorRolls = results.rolls
|
rollData.furorRolls = results.rolls
|
||||||
|
Loading…
Reference in New Issue
Block a user