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|}}