From d52efb73b962dbeb321bccb53f88268b7ea376df Mon Sep 17 00:00:00 2001 From: sasquach45932 Date: Mon, 6 Nov 2023 17:40:50 +0100 Subject: [PATCH 1/5] Enhancement: Shadow Of The Demon Lord --- templates/demonlord-request-rolls.html | 236 +++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 templates/demonlord-request-rolls.html diff --git a/templates/demonlord-request-rolls.html b/templates/demonlord-request-rolls.html new file mode 100644 index 0000000..2f875db --- /dev/null +++ b/templates/demonlord-request-rolls.html @@ -0,0 +1,236 @@ + +
+
+
+ + + +
+
+ + + +
+
+ {{#each actors}} +
+ + +
+ {{/each}} +
+
+ +
+
+ + + + + +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + +
+
+
+ +
+
+ + +
+ {{#if specialRolls.initiative}} +
+ + + +
+ {{/if}} + {{#if specialRolls.deathsave}} +
+ + +
+ {{/if}} + {{#if specialRolls.perception}} +
+ + +
+ {{/if}} +
+
+
+ +
+
+ + +
+
+ {{localize "LMRTFY.Selectors"}} +
+
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+
+
+
+ - +
+
+ + +
+
+
+
+ {{#each abilityModifiers as |name key|}} +
+ + +
+ {{/each}} +
+
+
+ +
+
+
+
+ +
+
+ + +
+ {{#each abilities as |name key|}} +
+ + + +
+ {{/each}} +
+
+
+ + {{#if tables}} +
+
+ + + +
+
+ {{/if}} + +
+ + +
+
From cf84f75fe77ee1440a0f98479f3a9c4761bdfde6 Mon Sep 17 00:00:00 2001 From: sasquach45932 Date: Mon, 6 Nov 2023 17:46:28 +0100 Subject: [PATCH 2/5] Enhancement: Shadow Of The Demon Lord --- README.md | 1 + lang/en.json | 11 +++++- src/lmrtfy.js | 11 +++++- src/requestor.js | 15 ++++++++ src/roller.js | 89 ++++++++++++++++++++++++++++++++++++------- templates/roller.html | 2 +- 6 files changed, 112 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c013a0f..4c747f7 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Writing this module was the idea of iotech, based on the Fantasy Grounds "[Roll - D35E - cof - coc +- demonlord Your favorite system not on this list? Adding compatibility is easy! Have a look at [CONTRIBUTING.md](/CONTRIBUTING.md) and open a PR! diff --git a/lang/en.json b/lang/en.json index 8891086..9407d95 100644 --- a/lang/en.json +++ b/lang/en.json @@ -65,5 +65,14 @@ "LMRTFY.SkillCheckFail": "FAIL Skill Check: ", "LMRTFY.EnableChooseFail": "Enable Fail Button", "LMRTFY.ShowFailButtons": "Show Fail Button", - "LMRTFY.ShowFailButtonsHint": "Show fail buttons for ability checks, ability saves and skill the requested roll form" + "LMRTFY.ShowFailButtonsHint": "Show fail buttons for ability checks, ability saves and skill the requested roll form", + "LMRTFY.DemonLordChallengeRoll": "Challenge Roll:", + "LMRTFY.DemonLordRollWithBanes": "Roll with Banes", + "LMRTFY.DemonLordRollWithBoons": "Roll with Boons", + "LMRTFY.DemonLordCustomFormulaPlaceholder": "1d20 + @attributes.strength.modifier + 1", + "LMRTFY.DemonLordNrOfBBDice": "Boons/Banes:", + "LMRTFY.DemonLordBoonsNote": "These rolls will be made with boons.", + "LMRTFY.DemonLordBanesNote": "These rolls will be made with banes.", + "LMRTFY.DemonLordAddMod": "Additional modifier:", + "LMRTFY.DemonLordNoCombat": "You are not in combat!" } diff --git a/src/lmrtfy.js b/src/lmrtfy.js index eaca5e5..178ff76 100644 --- a/src/lmrtfy.js +++ b/src/lmrtfy.js @@ -58,6 +58,15 @@ class LMRTFY { return false; } }); + + Handlebars.registerHelper('lmrtfy-isdemonlord', function (actor) { + if (game.system.id === 'demonlord') { + return true; + } else { + return false; + } + }); + } static ready() { @@ -178,7 +187,7 @@ class LMRTFY { LMRTFY.normalRollEvent = {}; LMRTFY.advantageRollEvent = {}; LMRTFY.disadvantageRollEvent = {}; - LMRTFY.specialRolls = {}; + LMRTFY.specialRolls = { 'initiative': true }; LMRTFY.abilityAbbreviations = abilities; LMRTFY.modIdentifier = 'modifier'; LMRTFY.abilityModifiers = {}; diff --git a/src/requestor.js b/src/requestor.js index 9401161..897d0a2 100644 --- a/src/requestor.js +++ b/src/requestor.js @@ -8,6 +8,7 @@ class LMRTFYRequestor extends FormApplication { this.selectedDice = []; this.selectedModifiers = []; this.dice = [ + 'd3', 'd4', 'd6', 'd8', @@ -29,6 +30,9 @@ class LMRTFYRequestor extends FormApplication { case "degenesis": template = "modules/lmrtfy/templates/degenesis-request-rolls.html"; break; + case "demonlord": + template = "modules/lmrtfy/templates/demonlord-request-rolls.html"; + break; default: template = "modules/lmrtfy/templates/request-rolls.html"; break; @@ -349,6 +353,13 @@ class LMRTFYRequestor extends FormApplication { } } + let BBDice = undefined; + let AddMod = undefined; + if (game.system.id === 'demonlord') { + BBDice = formData.BBDice; + AddMod = formData.AddMod; + } + const socketData = { user: formData.user, actors, @@ -370,6 +381,10 @@ class LMRTFYRequestor extends FormApplication { if (game.system.id === 'pf2e' && dc) { socketData['dc'] = dc; } + if (game.system.id === 'demonlord') { + socketData['BBDice'] = BBDice; + socketData['AddMod'] = AddMod; + } if (saveAsMacro) { let selectedSection = ''; diff --git a/src/roller.js b/src/roller.js index 93d9256..43b8b3b 100644 --- a/src/roller.js +++ b/src/roller.js @@ -18,6 +18,11 @@ class LMRTFYRoller extends Application { this.pf2Roll = ''; } + if (game.system.id === 'demonlord') { + this.BBDice = data.BBDice; + this.AddMod = data.AddMod; + } + if (data.title) { this.options.title = data.title; } @@ -123,9 +128,9 @@ class LMRTFYRoller extends Application { async getData() { let note = "" if (this.advantage == 1) - note = game.i18n.localize("LMRTFY.AdvantageNote"); + note = (game.system.id === 'demonlord') ? game.i18n.localize("LMRTFY.DemonLordBoonsNote") : game.i18n.localize("LMRTFY.AdvantageNote"); else if (this.advantage == -1) - note = game.i18n.localize("LMRTFY.DisadvantageNote"); + note = (game.system.id === 'demonlord') ? game.i18n.localize("LMRTFY.DemonLordBanesNote") : game.i18n.localize("LMRTFY.DisadvantageNote"); let abilities = {} let saves = {} @@ -324,6 +329,25 @@ class LMRTFYRoller extends Application { break; } + case "demonlord": { + const key = args[0]; + switch(this.advantage) { + case 0: + await actor.rollAttribute(actor.getAttribute(key), 0, 0) + break; + case 1: + await actor.rollAttribute(actor.getAttribute(key), this.BBDice, this.AddMod) + break; + case -1: + await actor.rollAttribute(actor.getAttribute(key), (this.BBDice)*-1, this.AddMod) + break; + case 2: + await actor[rollMethod].call(actor, ...args, options); + break; + } + break; + } + default: { await actor[rollMethod].call(actor, ...args, options); } @@ -366,6 +390,37 @@ class LMRTFYRoller extends Application { candidate.updateSource({"flags.lmrtfy": {"message": this.data.message, "data": this.data.attach, "blind": candidate.blind}}); } + _makeDemonLordInitiativeRoll(event) { + // save the current roll mode to reset it after this roll + const rollMode = game.settings.get("core", "rollMode"); + game.settings.set("core", "rollMode", this.mode || CONST.DICE_ROLL_MODES); + + if (game.combat?.combatants !== undefined) + { + let combatantFound + for (let actor of this.actors) { + combatantFound = null + for (const combatant of game.combat.combatants) { + if (combatant.actor?._id === actor._id) { + combatantFound = combatant + } + } + if (combatantFound) { + game.combat.rollInitiative(combatantFound._id) + } + } + } + else + { + ui.notifications.warn(game.i18n.localize("LMRTFY.DemonLordNoCombat")); + } + + game.settings.set("core", "rollMode", rollMode); + + event.currentTarget.disabled = true; + this._checkClose(); + } + async _makeDiceRoll(event, formula, defaultMessage = null) { if (formula.startsWith("1d20")) { if (this.advantage === 1) @@ -565,19 +620,25 @@ class LMRTFYRoller extends Application { _onInitiative(event) { event.preventDefault(); - if (game.system.id === 'pf2e') { - this._makePF2EInitiativeRoll(event); - } else { - if (this.data.initiative) { - for (let actor of this.actors) { - actor.rollInitiative(); + switch (game.system.id) { + case 'pf2e': + this._makePF2EInitiativeRoll(event); + break; + case 'demonlord': + this._makeDemonLordInitiativeRoll(event); + break; + default: + if (this.data.initiative) { + for (let actor of this.actors) { + actor.rollInitiative(); + } + event.currentTarget.disabled = true; + this._checkClose(); + } else { + const initiative = CONFIG.Combat.initiative.formula || game.system.data.initiative; + this._makeDiceRoll(event, initiative, game.i18n.localize("LMRTFY.InitiativeRollMessage")); } - event.currentTarget.disabled = true; - this._checkClose(); - } else { - const initiative = CONFIG.Combat.initiative.formula || game.system.data.initiative; - this._makeDiceRoll(event, initiative, game.i18n.localize("LMRTFY.InitiativeRollMessage")); - } + break; } } diff --git a/templates/roller.html b/templates/roller.html index 60a9ac0..9e10df8 100644 --- a/templates/roller.html +++ b/templates/roller.html @@ -26,7 +26,7 @@ {{#each abilities as |name ability|}}
- + {{#if (lmrtfy-isdemonlord this)}} />{{else}} />{{/if}}
{{#canFailAbilityChecks name ability}} {{/canFailAbilityChecks}} From 2bebe06ec00d71f3dd67787fd713884f6650ad9c Mon Sep 17 00:00:00 2001 From: sasquach45932 Date: Wed, 8 Nov 2023 20:40:32 +0100 Subject: [PATCH 3/5] Enhancement: Shadow Of The Demon Lord --- lang/en.json | 3 +- src/requestor.js | 13 ++++++ templates/demonlord-request-rolls.html | 62 +++++++++++++++----------- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/lang/en.json b/lang/en.json index 9407d95..ef8a8d8 100644 --- a/lang/en.json +++ b/lang/en.json @@ -74,5 +74,6 @@ "LMRTFY.DemonLordBoonsNote": "These rolls will be made with boons.", "LMRTFY.DemonLordBanesNote": "These rolls will be made with banes.", "LMRTFY.DemonLordAddMod": "Additional modifier:", - "LMRTFY.DemonLordNoCombat": "You are not in combat!" + "LMRTFY.DemonLordNoCombat": "You are not in combat!", + "LMRTFY.DemonLordNoBoonsBanes": "No Boons/Banes" } diff --git a/src/requestor.js b/src/requestor.js index 897d0a2..c2180ae 100644 --- a/src/requestor.js +++ b/src/requestor.js @@ -117,6 +117,7 @@ class LMRTFYRequestor extends FormApplication { this.element.find(".lmrtfy-bonus-button").click(this.bonusClick.bind(this)); this.element.find(".lmrtfy-formula-ability").click(this.modifierClick.bind(this)); this.element.find(".lmrtfy-clear-formula").click(this.clearCustomFormula.bind(this)); + if ((game.system.id) === "demonlord") this.element.find(".demonlord").change(this.clearDemonLordSettings.bind(this)); this._onUserChange(); } @@ -296,6 +297,18 @@ class LMRTFYRequestor extends FormApplication { this.combineFormula(); } + clearDemonLordSettings() { + if (($("#advantage").val() === "-1") || ($("#advantage").val() === "1")) { + $("#BBDice").prop('disabled', false); + $("#AddMod").prop('disabled', false); + } else { + $("#AddMod").val("0"); + $("#BBDice").val("0"); + $("#BBDice").prop('disabled', true); + $("#AddMod").prop('disabled', true); + } + } + async _updateObject(event, formData) { //console.log("LMRTFY submit: ", formData) const saveAsMacro = $(event.currentTarget).hasClass("lmrtfy-save-roll") diff --git a/templates/demonlord-request-rolls.html b/templates/demonlord-request-rolls.html index 2f875db..3d35e9f 100644 --- a/templates/demonlord-request-rolls.html +++ b/templates/demonlord-request-rolls.html @@ -38,7 +38,7 @@
- @@ -62,8 +62,8 @@
- + @@ -74,7 +74,7 @@
- @@ -136,41 +136,51 @@
-
+
- - - + + + -
+
- - - + + +
- - - + + +
From f7b184d8b6523d77dea71d96f2cda5adb6e4931a Mon Sep 17 00:00:00 2001 From: sasquach45932 Date: Wed, 8 Nov 2023 21:23:13 +0100 Subject: [PATCH 4/5] Enhancement: Shadow Of The Demon Lord --- src/roller.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/roller.js b/src/roller.js index 43b8b3b..375955e 100644 --- a/src/roller.js +++ b/src/roller.js @@ -395,8 +395,7 @@ class LMRTFYRoller extends Application { const rollMode = game.settings.get("core", "rollMode"); game.settings.set("core", "rollMode", this.mode || CONST.DICE_ROLL_MODES); - if (game.combat?.combatants !== undefined) - { + if (game.combat?.combatants !== undefined) { let combatantFound for (let actor of this.actors) { combatantFound = null @@ -404,14 +403,14 @@ class LMRTFYRoller extends Application { if (combatant.actor?._id === actor._id) { combatantFound = combatant } - } + } if (combatantFound) { game.combat.rollInitiative(combatantFound._id) - } + } else { + ui.notifications.warn(game.i18n.localize("LMRTFY.DemonLordNoCombat")); + } } - } - else - { + } else { ui.notifications.warn(game.i18n.localize("LMRTFY.DemonLordNoCombat")); } From 58e0c7cb2a37a47050ae1afe5a2f005fe49ccceb Mon Sep 17 00:00:00 2001 From: sasquach45932 Date: Thu, 9 Nov 2023 20:25:09 +0100 Subject: [PATCH 5/5] Enhancement: Shadow Of The Demon Lord --- templates/demonlord-request-rolls.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/demonlord-request-rolls.html b/templates/demonlord-request-rolls.html index 3d35e9f..f5274c9 100644 --- a/templates/demonlord-request-rolls.html +++ b/templates/demonlord-request-rolls.html @@ -35,7 +35,7 @@
-
+