@@ -18,6 +18,11 @@ class LMRTFYRoller extends Application {
18
18
this . pf2Roll = '' ;
19
19
}
20
20
21
+ if ( game . system . id === 'demonlord' ) {
22
+ this . BBDice = data . BBDice ;
23
+ this . AddMod = data . AddMod ;
24
+ }
25
+
21
26
if ( data . title ) {
22
27
this . options . title = data . title ;
23
28
}
@@ -123,9 +128,9 @@ class LMRTFYRoller extends Application {
123
128
async getData ( ) {
124
129
let note = ""
125
130
if ( this . advantage == 1 )
126
- note = game . i18n . localize ( "LMRTFY.AdvantageNote" ) ;
131
+ note = ( game . system . id === 'demonlord' ) ? game . i18n . localize ( "LMRTFY.DemonLordBoonsNote" ) : game . i18n . localize ( "LMRTFY.AdvantageNote" ) ;
127
132
else if ( this . advantage == - 1 )
128
- note = game . i18n . localize ( "LMRTFY.DisadvantageNote" ) ;
133
+ note = ( game . system . id === 'demonlord' ) ? game . i18n . localize ( "LMRTFY.DemonLordBanesNote" ) : game . i18n . localize ( "LMRTFY.DisadvantageNote" ) ;
129
134
130
135
let abilities = { }
131
136
let saves = { }
@@ -324,6 +329,25 @@ class LMRTFYRoller extends Application {
324
329
break ;
325
330
}
326
331
332
+ case "demonlord" : {
333
+ const key = args [ 0 ] ;
334
+ switch ( this . advantage ) {
335
+ case 0 :
336
+ await actor . rollAttribute ( actor . getAttribute ( key ) , 0 , 0 )
337
+ break ;
338
+ case 1 :
339
+ await actor . rollAttribute ( actor . getAttribute ( key ) , this . BBDice , this . AddMod )
340
+ break ;
341
+ case - 1 :
342
+ await actor . rollAttribute ( actor . getAttribute ( key ) , ( this . BBDice ) * - 1 , this . AddMod )
343
+ break ;
344
+ case 2 :
345
+ await actor [ rollMethod ] . call ( actor , ...args , options ) ;
346
+ break ;
347
+ }
348
+ break ;
349
+ }
350
+
327
351
default : {
328
352
await actor [ rollMethod ] . call ( actor , ...args , options ) ;
329
353
}
@@ -366,6 +390,36 @@ class LMRTFYRoller extends Application {
366
390
candidate . updateSource ( { "flags.lmrtfy" : { "message" : this . data . message , "data" : this . data . attach , "blind" : candidate . blind } } ) ;
367
391
}
368
392
393
+ _makeDemonLordInitiativeRoll ( event ) {
394
+ // save the current roll mode to reset it after this roll
395
+ const rollMode = game . settings . get ( "core" , "rollMode" ) ;
396
+ game . settings . set ( "core" , "rollMode" , this . mode || CONST . DICE_ROLL_MODES ) ;
397
+
398
+ if ( game . combat ?. combatants !== undefined ) {
399
+ let combatantFound
400
+ for ( let actor of this . actors ) {
401
+ combatantFound = null
402
+ for ( const combatant of game . combat . combatants ) {
403
+ if ( combatant . actor ?. _id === actor . _id ) {
404
+ combatantFound = combatant
405
+ }
406
+ }
407
+ if ( combatantFound ) {
408
+ game . combat . rollInitiative ( combatantFound . _id )
409
+ } else {
410
+ ui . notifications . warn ( game . i18n . localize ( "LMRTFY.DemonLordNoCombat" ) ) ;
411
+ }
412
+ }
413
+ } else {
414
+ ui . notifications . warn ( game . i18n . localize ( "LMRTFY.DemonLordNoCombat" ) ) ;
415
+ }
416
+
417
+ game . settings . set ( "core" , "rollMode" , rollMode ) ;
418
+
419
+ event . currentTarget . disabled = true ;
420
+ this . _checkClose ( ) ;
421
+ }
422
+
369
423
async _makeDiceRoll ( event , formula , defaultMessage = null ) {
370
424
if ( formula . startsWith ( "1d20" ) ) {
371
425
if ( this . advantage === 1 )
@@ -565,19 +619,25 @@ class LMRTFYRoller extends Application {
565
619
_onInitiative ( event ) {
566
620
event . preventDefault ( ) ;
567
621
568
- if ( game . system . id === 'pf2e' ) {
569
- this . _makePF2EInitiativeRoll ( event ) ;
570
- } else {
571
- if ( this . data . initiative ) {
572
- for ( let actor of this . actors ) {
573
- actor . rollInitiative ( ) ;
622
+ switch ( game . system . id ) {
623
+ case 'pf2e' :
624
+ this . _makePF2EInitiativeRoll ( event ) ;
625
+ break ;
626
+ case 'demonlord' :
627
+ this . _makeDemonLordInitiativeRoll ( event ) ;
628
+ break ;
629
+ default :
630
+ if ( this . data . initiative ) {
631
+ for ( let actor of this . actors ) {
632
+ actor . rollInitiative ( ) ;
633
+ }
634
+ event . currentTarget . disabled = true ;
635
+ this . _checkClose ( ) ;
636
+ } else {
637
+ const initiative = CONFIG . Combat . initiative . formula || game . system . data . initiative ;
638
+ this . _makeDiceRoll ( event , initiative , game . i18n . localize ( "LMRTFY.InitiativeRollMessage" ) ) ;
574
639
}
575
- event . currentTarget . disabled = true ;
576
- this . _checkClose ( ) ;
577
- } else {
578
- const initiative = CONFIG . Combat . initiative . formula || game . system . data . initiative ;
579
- this . _makeDiceRoll ( event , initiative , game . i18n . localize ( "LMRTFY.InitiativeRollMessage" ) ) ;
580
- }
640
+ break ;
581
641
}
582
642
}
583
643
0 commit comments