Skip to content

Commit 1f4c1e0

Browse files
authored
Merge pull request #194 from sasquach45932/master
Enhancement: Shadow Of The Demon Lord
2 parents 8d2206e + 58e0c7c commit 1f4c1e0

File tree

7 files changed

+371
-17
lines changed

7 files changed

+371
-17
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Writing this module was the idea of iotech, based on the Fantasy Grounds "[Roll
2323
- D35E
2424
- cof
2525
- coc
26+
- demonlord
2627

2728
Your favorite system not on this list? Adding compatibility is easy! Have a look at [CONTRIBUTING.md](/CONTRIBUTING.md) and open a PR!
2829

lang/en.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,15 @@
6565
"LMRTFY.SkillCheckFail": "FAIL Skill Check: ",
6666
"LMRTFY.EnableChooseFail": "Enable Fail Button",
6767
"LMRTFY.ShowFailButtons": "Show Fail Button",
68-
"LMRTFY.ShowFailButtonsHint": "Show fail buttons for ability checks, ability saves and skill the requested roll form"
68+
"LMRTFY.ShowFailButtonsHint": "Show fail buttons for ability checks, ability saves and skill the requested roll form",
69+
"LMRTFY.DemonLordChallengeRoll": "Challenge Roll:",
70+
"LMRTFY.DemonLordRollWithBanes": "Roll with Banes",
71+
"LMRTFY.DemonLordRollWithBoons": "Roll with Boons",
72+
"LMRTFY.DemonLordCustomFormulaPlaceholder": "1d20 + @attributes.strength.modifier + 1",
73+
"LMRTFY.DemonLordNrOfBBDice": "Boons/Banes:",
74+
"LMRTFY.DemonLordBoonsNote": "These rolls will be made with boons.",
75+
"LMRTFY.DemonLordBanesNote": "These rolls will be made with banes.",
76+
"LMRTFY.DemonLordAddMod": "Additional modifier:",
77+
"LMRTFY.DemonLordNoCombat": "You are not in combat!",
78+
"LMRTFY.DemonLordNoBoonsBanes": "No Boons/Banes"
6979
}

src/lmrtfy.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ class LMRTFY {
5858
return false;
5959
}
6060
});
61+
62+
Handlebars.registerHelper('lmrtfy-isdemonlord', function (actor) {
63+
if (game.system.id === 'demonlord') {
64+
return true;
65+
} else {
66+
return false;
67+
}
68+
});
69+
6170
}
6271

6372
static ready() {
@@ -178,7 +187,7 @@ class LMRTFY {
178187
LMRTFY.normalRollEvent = {};
179188
LMRTFY.advantageRollEvent = {};
180189
LMRTFY.disadvantageRollEvent = {};
181-
LMRTFY.specialRolls = {};
190+
LMRTFY.specialRolls = { 'initiative': true };
182191
LMRTFY.abilityAbbreviations = abilities;
183192
LMRTFY.modIdentifier = 'modifier';
184193
LMRTFY.abilityModifiers = {};

src/requestor.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class LMRTFYRequestor extends FormApplication {
88
this.selectedDice = [];
99
this.selectedModifiers = [];
1010
this.dice = [
11+
'd3',
1112
'd4',
1213
'd6',
1314
'd8',
@@ -29,6 +30,9 @@ class LMRTFYRequestor extends FormApplication {
2930
case "degenesis":
3031
template = "modules/lmrtfy/templates/degenesis-request-rolls.html";
3132
break;
33+
case "demonlord":
34+
template = "modules/lmrtfy/templates/demonlord-request-rolls.html";
35+
break;
3236
default:
3337
template = "modules/lmrtfy/templates/request-rolls.html";
3438
break;
@@ -113,6 +117,7 @@ class LMRTFYRequestor extends FormApplication {
113117
this.element.find(".lmrtfy-bonus-button").click(this.bonusClick.bind(this));
114118
this.element.find(".lmrtfy-formula-ability").click(this.modifierClick.bind(this));
115119
this.element.find(".lmrtfy-clear-formula").click(this.clearCustomFormula.bind(this));
120+
if ((game.system.id) === "demonlord") this.element.find(".demonlord").change(this.clearDemonLordSettings.bind(this));
116121
this._onUserChange();
117122
}
118123

@@ -292,6 +297,18 @@ class LMRTFYRequestor extends FormApplication {
292297
this.combineFormula();
293298
}
294299

300+
clearDemonLordSettings() {
301+
if (($("#advantage").val() === "-1") || ($("#advantage").val() === "1")) {
302+
$("#BBDice").prop('disabled', false);
303+
$("#AddMod").prop('disabled', false);
304+
} else {
305+
$("#AddMod").val("0");
306+
$("#BBDice").val("0");
307+
$("#BBDice").prop('disabled', true);
308+
$("#AddMod").prop('disabled', true);
309+
}
310+
}
311+
295312
async _updateObject(event, formData) {
296313
//console.log("LMRTFY submit: ", formData)
297314
const saveAsMacro = $(event.currentTarget).hasClass("lmrtfy-save-roll")
@@ -349,6 +366,13 @@ class LMRTFYRequestor extends FormApplication {
349366
}
350367
}
351368

369+
let BBDice = undefined;
370+
let AddMod = undefined;
371+
if (game.system.id === 'demonlord') {
372+
BBDice = formData.BBDice;
373+
AddMod = formData.AddMod;
374+
}
375+
352376
const socketData = {
353377
user: formData.user,
354378
actors,
@@ -370,6 +394,10 @@ class LMRTFYRequestor extends FormApplication {
370394
if (game.system.id === 'pf2e' && dc) {
371395
socketData['dc'] = dc;
372396
}
397+
if (game.system.id === 'demonlord') {
398+
socketData['BBDice'] = BBDice;
399+
socketData['AddMod'] = AddMod;
400+
}
373401

374402
if (saveAsMacro) {
375403
let selectedSection = '';

src/roller.js

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class LMRTFYRoller extends Application {
1818
this.pf2Roll = '';
1919
}
2020

21+
if (game.system.id === 'demonlord') {
22+
this.BBDice = data.BBDice;
23+
this.AddMod = data.AddMod;
24+
}
25+
2126
if (data.title) {
2227
this.options.title = data.title;
2328
}
@@ -123,9 +128,9 @@ class LMRTFYRoller extends Application {
123128
async getData() {
124129
let note = ""
125130
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");
127132
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");
129134

130135
let abilities = {}
131136
let saves = {}
@@ -324,6 +329,25 @@ class LMRTFYRoller extends Application {
324329
break;
325330
}
326331

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+
327351
default: {
328352
await actor[rollMethod].call(actor, ...args, options);
329353
}
@@ -366,6 +390,36 @@ class LMRTFYRoller extends Application {
366390
candidate.updateSource({"flags.lmrtfy": {"message": this.data.message, "data": this.data.attach, "blind": candidate.blind}});
367391
}
368392

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+
369423
async _makeDiceRoll(event, formula, defaultMessage = null) {
370424
if (formula.startsWith("1d20")) {
371425
if (this.advantage === 1)
@@ -565,19 +619,25 @@ class LMRTFYRoller extends Application {
565619
_onInitiative(event) {
566620
event.preventDefault();
567621

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"));
574639
}
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;
581641
}
582642
}
583643

0 commit comments

Comments
 (0)