@@ -424,6 +424,9 @@ class DCCActor extends Actor {
424424 const roll = new Roll ( formula , { ab : attackBonus , critical : critRange } )
425425 roll . roll ( )
426426 const d20RollResult = roll . dice [ 0 ] . total
427+ roll . dice [ 0 ] . options . dcc = {
428+ upperThreshold : critRange
429+ }
427430
428431 if ( displayStandardCards ) {
429432 roll . toMessage ( {
@@ -484,12 +487,8 @@ class DCCActor extends Actor {
484487 // Display standard cards in chat?
485488 const displayStandardCards = game . settings . get ( 'dcc' , 'useStandardDiceRoller' )
486489
487- // Roll the crit
488- const roll = new Roll ( `${ this . data . data . attributes . critical . die } + ${ this . data . data . abilities . lck . mod } ` )
489- roll . roll ( )
490- const rollData = escape ( JSON . stringify ( roll ) )
491- const rollTotal = roll . total
492- const rollHTML = `<a class="inline-roll inline-result" data-roll="${ rollData } " data-damage="${ rollTotal } " title="${ Roll . cleanFormula ( roll . terms || roll . formula ) } "><i class="fas fa-dice-d20"></i> ${ rollTotal } </a>`
490+ // Roll object for the crit die
491+ let roll = new Roll ( `${ this . data . data . attributes . critical . die } + ${ this . data . data . abilities . lck . mod } ` )
493492
494493 // Lookup the crit table if available
495494 let critResult = null
@@ -507,13 +506,31 @@ class DCCActor extends Actor {
507506 }
508507 }
509508
509+ // Either roll the die or grab the roll from the table lookup
510+ if ( ! critResult ) {
511+ roll . roll ( )
512+ } else {
513+ roll = critResult . roll
514+ }
515+
510516 if ( ! displayStandardCards ) {
517+ // Create the roll emote
518+ const rollData = escape ( JSON . stringify ( roll ) )
519+ const rollTotal = roll . total
520+ const rollHTML = `<a class="inline-roll inline-result" data-roll="${ rollData } " data-damage="${ rollTotal } " title="${ Roll . cleanFormula ( roll . terms || roll . formula ) } "><i class="fas fa-dice-d20"></i> ${ rollTotal } </a>`
521+
511522 // Display crit result or just a notification of the crit
512523 if ( critResult ) {
513524 return ` <br/><br/><span style='color:#ff0000; font-weight: bolder'>${ game . i18n . localize ( 'DCC.CriticalHit' ) } !</span> ${ rollHTML } <br/>${ critResult . results [ 0 ] . text } `
514525 } else {
515526 return ` <br/><br/><span style='color:#ff0000; font-weight: bolder'>${ game . i18n . localize ( 'DCC.CriticalHit' ) } !</span> ${ rollHTML } `
516527 }
528+ } else if ( ! critResult ) {
529+ // Display the raw crit roll
530+ await roll . toMessage ( {
531+ speaker : ChatMessage . getSpeaker ( { actor : this } ) ,
532+ flavor : `${ game . i18n . localize ( 'DCC.CriticalHit' ) } !`
533+ } )
517534 }
518535 }
519536
@@ -531,12 +548,8 @@ class DCCActor extends Actor {
531548 fumbleDie = '1d4'
532549 }
533550
534- // Roll the fumble
535- const roll = new Roll ( `${ fumbleDie } - ${ this . data . data . abilities . lck . mod } ` )
536- roll . roll ( )
537- const rollData = escape ( JSON . stringify ( roll ) )
538- const rollTotal = roll . total
539- const rollHTML = `<a class="inline-roll inline-result" data-roll="${ rollData } " data-damage="${ rollTotal } " title="${ Roll . cleanFormula ( roll . terms || roll . formula ) } "><i class="fas fa-dice-d20"></i> ${ rollTotal } </a>`
551+ // Roll object for the fumble die
552+ let roll = new Roll ( `${ fumbleDie } - ${ this . data . data . abilities . lck . mod } ` )
540553
541554 // Lookup the fumble table if available
542555 let fumbleResult = null
@@ -557,13 +570,31 @@ class DCCActor extends Actor {
557570 }
558571 }
559572
573+ // Either roll the die or grab the roll from the table lookup
574+ if ( ! fumbleResult ) {
575+ roll . roll ( )
576+ } else {
577+ roll = fumbleResult . roll
578+ }
579+
560580 if ( ! displayStandardCards ) {
581+ // Create the roll emote
582+ const rollData = escape ( JSON . stringify ( roll ) )
583+ const rollTotal = roll . total
584+ const rollHTML = `<a class="inline-roll inline-result" data-roll="${ rollData } " data-damage="${ rollTotal } " title="${ Roll . cleanFormula ( roll . terms || roll . formula ) } "><i class="fas fa-dice-d20"></i> ${ rollTotal } </a>`
585+
561586 // Display fumble result or just a notification of the fumble
562587 if ( fumbleResult ) {
563- return ` <br/><br/><span style='color:red; font-weight: bolder'>Fumble!</span> ${ rollHTML } <br/>${ fumbleResult . results [ 0 ] . text } `
588+ return ` <br/><br/><span style='color:red; font-weight: bolder'>${ game . i18n . localize ( 'DCC. Fumble' ) } !</span> ${ rollHTML } <br/>${ fumbleResult . results [ 0 ] . text } `
564589 } else {
565- return ` <br/><br/><span style='color:red; font-weight: bolder'>Fumble!</span> ${ rollHTML } `
590+ return ` <br/><br/><span style='color:red; font-weight: bolder'>${ game . i18n . localize ( 'DCC. Fumble' ) } !</span> ${ rollHTML } `
566591 }
592+ } else if ( ! fumbleResult ) {
593+ // Display the raw fumble roll
594+ await roll . toMessage ( {
595+ speaker : ChatMessage . getSpeaker ( { actor : this } ) ,
596+ flavor : `${ game . i18n . localize ( 'DCC.Fumble' ) } !`
597+ } )
567598 }
568599 }
569600
0 commit comments