Skip to content

Commit

Permalink
Merge pull request #194 from sasquach45932/master
Browse files Browse the repository at this point in the history
Enhancement: Shadow Of The Demon Lord
  • Loading branch information
Varriount authored Nov 9, 2023
2 parents 8d2206e + 58e0c7c commit 1f4c1e0
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
12 changes: 11 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,15 @@
"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!",
"LMRTFY.DemonLordNoBoonsBanes": "No Boons/Banes"
}
11 changes: 10 additions & 1 deletion src/lmrtfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 = {};
Expand Down
28 changes: 28 additions & 0 deletions src/requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LMRTFYRequestor extends FormApplication {
this.selectedDice = [];
this.selectedModifiers = [];
this.dice = [
'd3',
'd4',
'd6',
'd8',
Expand All @@ -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;
Expand Down Expand Up @@ -113,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();
}

Expand Down Expand Up @@ -292,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")
Expand Down Expand Up @@ -349,6 +366,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,
Expand All @@ -370,6 +394,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 = '';
Expand Down
88 changes: 74 additions & 14 deletions src/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -366,6 +390,36 @@ 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"));
}
}
} 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)
Expand Down Expand Up @@ -565,19 +619,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;
}
}

Expand Down
Loading

0 comments on commit 1f4c1e0

Please sign in to comment.