forked from public/fvtt-yggdrasill
		
	fix calculation of furor usage
This commit is contained in:
		@@ -87,12 +87,14 @@ export class YggdrasillUtility  {
 | 
			
		||||
 | 
			
		||||
  /* -------------------------------------------- */
 | 
			
		||||
  static async specificYggRoll( nbDice ) {
 | 
			
		||||
    return specificYggRoll(nbDice, false);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static async specificYggRoll( nbDice, isFurorUsage ) {
 | 
			
		||||
    let rawDices = []
 | 
			
		||||
    let rolls = []  
 | 
			
		||||
    let maxTab = []
 | 
			
		||||
 | 
			
		||||
    maxTab[0] = {idx: 0, value: 0}
 | 
			
		||||
    maxTab[1] = {idx: 0, value: 0}
 | 
			
		||||
    let maxTabMaxIndex = isFurorUsage ? nbDice : 2;
 | 
			
		||||
 | 
			
		||||
    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} );
 | 
			
		||||
@@ -102,19 +104,17 @@ export class YggdrasillUtility  {
 | 
			
		||||
        this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
 | 
			
		||||
      }
 | 
			
		||||
      rawDices.push({ 'result': rolls[i].total});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
      if ( rolls[i].total > maxTab[0].value) {
 | 
			
		||||
        if ( nbDice > 1 && maxTab[0].value > maxTab[1].value) {
 | 
			
		||||
          maxTab[1].value = maxTab[0].value
 | 
			
		||||
    rolls.sort((a,b) => a.total-b.total);
 | 
			
		||||
    rolls.reverse();
 | 
			
		||||
    
 | 
			
		||||
    for (let i=0; i<maxTabMaxIndex; i++) {
 | 
			
		||||
      maxTab[i] = {idx: 0, value: 0};
 | 
			
		||||
      if (rolls[i].total != undefined) maxTab[i].value = rolls[i].total;
 | 
			
		||||
    }
 | 
			
		||||
        maxTab[0].value = rolls[i].total
 | 
			
		||||
      } else {
 | 
			
		||||
        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)
 | 
			
		||||
 | 
			
		||||
    if ( rollData.furorUsage > 0 ) { 
 | 
			
		||||
      results = await this.specificYggRoll( rollData.furorUsage ) 
 | 
			
		||||
      results = await this.specificYggRoll( rollData.furorUsage, true ) 
 | 
			
		||||
      rollData.furorRawDices = results.rawDices
 | 
			
		||||
      rollData.furorMaxTab = results.maxTab
 | 
			
		||||
      rollData.furorRolls = results.rolls
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user