Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow Of The Demon Lord fixes #198

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/lmrtfy.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ form .form-group .lmrtfy-skill-checks {
.lmrtfy-skill-checks > div ,
.lmrtfy-extras > div {
flex: 3;
padding: 4px;
padding: 2px;
display: flex;
}

Expand Down
9 changes: 5 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@
"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.DemonLordNrOfboonsBanes": "Boons/Banes:",
"LMRTFY.DemonLordBoonsNote": "These rolls will be made with {boonsBanes} boon(s).",
"LMRTFY.DemonLordBanesNote": "These rolls will be made with {boonsBanes} bane(s).",
"LMRTFY.DemonLordAdditionalModifier": "Additional modifier:",
"LMRTFY.DemonLordFateRoll": "Fate Roll",
"LMRTFY.DemonLordNoCombat": "You are not in combat!",
"LMRTFY.DemonLordNoBoonsBanes": "No Boons/Banes"
}
2 changes: 1 addition & 1 deletion src/lmrtfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class LMRTFY {
LMRTFY.normalRollEvent = {};
LMRTFY.advantageRollEvent = {};
LMRTFY.disadvantageRollEvent = {};
LMRTFY.specialRolls = { 'initiative': true };
LMRTFY.specialRolls = { 'initiative': true, 'deathsave': true, 'perception': true };
LMRTFY.abilityAbbreviations = abilities;
LMRTFY.modIdentifier = 'modifier';
LMRTFY.abilityModifiers = {};
Expand Down
24 changes: 12 additions & 12 deletions src/requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ class LMRTFYRequestor extends FormApplication {

clearDemonLordSettings() {
if (($("#advantage").val() === "-1") || ($("#advantage").val() === "1")) {
$("#BBDice").prop('disabled', false);
$("#AddMod").prop('disabled', false);
$("#boonsBanes").prop('disabled', false);
$("#additionalModifier").prop('disabled', false);
} else {
$("#AddMod").val("0");
$("#BBDice").val("0");
$("#BBDice").prop('disabled', true);
$("#AddMod").prop('disabled', true);
$("#additionalModifier").val("0");
$("#boonsBanes").val("0");
$("#boonsBanes").prop('disabled', true);
$("#additionalModifier").prop('disabled', true);
}
}

Expand Down Expand Up @@ -366,11 +366,11 @@ class LMRTFYRequestor extends FormApplication {
}
}

let BBDice = undefined;
let AddMod = undefined;
let boonsBanes = undefined;
let additionalModifier = undefined;
if (game.system.id === 'demonlord') {
BBDice = formData.BBDice;
AddMod = formData.AddMod;
boonsBanes = formData.boonsBanes;
additionalModifier = formData.additionalModifier;
}

const socketData = {
Expand All @@ -395,8 +395,8 @@ class LMRTFYRequestor extends FormApplication {
socketData['dc'] = dc;
}
if (game.system.id === 'demonlord') {
socketData['BBDice'] = BBDice;
socketData['AddMod'] = AddMod;
socketData['boonsBanes'] = boonsBanes;
socketData['additionalModifier'] = additionalModifier;
}

if (saveAsMacro) {
Expand Down
66 changes: 45 additions & 21 deletions src/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class LMRTFYRoller extends Application {
}

if (game.system.id === 'demonlord') {
this.BBDice = data.BBDice;
this.AddMod = data.AddMod;
this.boonsBanes = data.boonsBanes;
this.additionalModifier = data.additionalModifier;
}

if (data.title) {
Expand Down Expand Up @@ -128,9 +128,9 @@ class LMRTFYRoller extends Application {
async getData() {
let note = ""
if (this.advantage == 1)
note = (game.system.id === 'demonlord') ? game.i18n.localize("LMRTFY.DemonLordBoonsNote") : game.i18n.localize("LMRTFY.AdvantageNote");
note = (game.system.id === 'demonlord') ? game.i18n.format("LMRTFY.DemonLordBoonsNote", { boonsBanes :this.boonsBanes}) : game.i18n.localize("LMRTFY.AdvantageNote");
else if (this.advantage == -1)
note = (game.system.id === 'demonlord') ? game.i18n.localize("LMRTFY.DemonLordBanesNote") : game.i18n.localize("LMRTFY.DisadvantageNote");
note = (game.system.id === 'demonlord') ? game.i18n.format("LMRTFY.DemonLordBanesNote", { boonsBanes :this.boonsBanes}) : game.i18n.localize("LMRTFY.DisadvantageNote");

let abilities = {}
let saves = {}
Expand Down Expand Up @@ -336,10 +336,10 @@ class LMRTFYRoller extends Application {
await actor.rollAttribute(actor.getAttribute(key), 0, 0)
break;
case 1:
await actor.rollAttribute(actor.getAttribute(key), this.BBDice, this.AddMod)
await actor.rollAttribute(actor.getAttribute(key), this.boonsBanes, this.additionalModifier)
break;
case -1:
await actor.rollAttribute(actor.getAttribute(key), (this.BBDice)*-1, this.AddMod)
await actor.rollAttribute(actor.getAttribute(key), (this.boonsBanes)*-1, this.additionalModifier)
break;
case 2:
await actor[rollMethod].call(actor, ...args, options);
Expand Down Expand Up @@ -420,6 +420,21 @@ class LMRTFYRoller extends Application {
this._checkClose();
}

_makeDemonLordCorruptionRoll() {
const rollMode = game.settings.get("core", "rollMode");
game.settings.set("core", "rollMode", this.mode || CONST.DICE_ROLL_MODES);

for (let actor of this.actors) {
Hooks.once("preCreateChatMessage", this._tagMessage.bind(this));
actor.rollCorruption();
}

game.settings.set("core", "rollMode", rollMode);

this._disableButtons(event);
this._checkClose();
}

async _makeDiceRoll(event, formula, defaultMessage = null) {
if (formula.startsWith("1d20")) {
if (this.advantage === 1)
Expand Down Expand Up @@ -643,26 +658,35 @@ class LMRTFYRoller extends Application {

_onDeathSave(event) {
event.preventDefault();
if (game.system.id == "dnd5e") {
for (let actor of this.actors) {
actor.rollDeathSave(event);
}
event.currentTarget.disabled = true;
this._checkClose();
} else if (game.system.id == "pf2e") {
for (let actor of this.actors) {
actor.rollRecovery();
}
event.currentTarget.disabled = true;
this._checkClose();
} else {
this._makeDiceRoll(event, "1d20", game.i18n.localize("LMRTFY.DeathSaveRollMessage"));
switch (game.system.id) {
case "dnd5e":
for (let actor of this.actors) {
actor.rollDeathSave(event);
}
break
case "pf2e":
for (let actor of this.actors) {
actor.rollRecovery();
}
break;
case "demonlord":
for (let actor of this.actors) {
this._makeDiceRoll(event, "1d6", game.i18n.localize("LMRTFY.DemonLordFateRoll"));
}
break;
default:
this._makeDiceRoll(event, "1d20", game.i18n.localize("LMRTFY.DeathSaveRollMessage"));
}
event.currentTarget.disabled = true;
this._checkClose();
}

_onPerception(event) {
event.preventDefault();
this._makeDiceRoll(event, `1d20 + @attributes.perception.totalModifier`, game.i18n.localize("LMRTFY.PerceptionRollMessage"));
if (game.system.id === 'demonlord')
this._makeDemonLordCorruptionRoll()
else
this._makeDiceRoll(event, `1d20 + @attributes.perception.totalModifier`, game.i18n.localize("LMRTFY.PerceptionRollMessage"));
}

_onRollTable(event) {
Expand Down
12 changes: 6 additions & 6 deletions templates/demonlord-request-rolls.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
</div>

<div class="form-group">
<label>{{localize "LMRTFY.DemonLordNrOfBBDice"}}</label>
<select name="BBDice" data-dtype="Number" id="BBDice" disabled>
<label>{{localize "LMRTFY.DemonLordNrOfboonsBanes"}}</label>
<select name="boonsBanes" data-dtype="Number" id="boonsBanes" disabled>
<option value="0">{{localize "LMRTFY.DemonLordNoBoonsBanes"}}</option>
<option value="1">1d6</option>
<option value="2">2d6</option>
Expand All @@ -73,8 +73,8 @@
</div>

<div class="form-group">
<label>{{localize "LMRTFY.DemonLordAddMod"}}</label>
<select name="AddMod" data-dtype="Number" id="AddMod" disabled>
<label>{{localize "LMRTFY.DemonLordAdditionalModifier"}}</label>
<select name="additionalModifier" data-dtype="Number" id="additionalModifier" disabled>
<option value="-5">-5</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
Expand Down Expand Up @@ -113,13 +113,13 @@
{{#if specialRolls.deathsave}}
<div class="lmrtfy-extra-death-save">
<input type="checkbox" name="extra-death-save" id="lmrtf-extra-death-save" data-dtype="Boolean" />
<label for="lmrtf-extra-death-save">{{localize "LMRTFY.DeathSave"}}</label>
<label for="lmrtf-extra-death-save">{{localize "LMRTFY.DemonLordFateRoll"}}</label>
</div>
{{/if}}
{{#if specialRolls.perception}}
<div class="lmrtfy-extra-perception">
<input type="checkbox" name="extra-perception" id="lmrtf-extra-perception" data-dtype="Boolean" />
<label for="lmrtf-extra-perception">{{localize "LMRTFY.Perception"}}</label>
<label for="lmrtf-extra-perception">{{localize "DL.CharRolCorruption"}}</label>
</div>
{{/if}}
</div>
Expand Down
6 changes: 3 additions & 3 deletions templates/roller.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

{{#each abilities as |name ability|}}
<div>
{{#if (lmrtfy-isdemonlord this)}}<button type="button" class="lmrtfy-ability-check" data-ability={{ability}}>{{localize "LMRTFY.DemonLordChallengeRoll"}} {{localize name}}</button> />{{else}} <button type="button" class="lmrtfy-ability-check" data-ability={{ability}}>{{localize "LMRTFY.AbilityCheck"}} {{localize name}}</button>/>{{/if}}
{{#if (lmrtfy-isdemonlord this)}}<button type="button" class="lmrtfy-ability-check" data-ability={{ability}}>{{localize "LMRTFY.DemonLordChallengeRoll"}} {{localize name}}</button>{{else}} <button type="button" class="lmrtfy-ability-check" data-ability={{ability}}>{{localize "LMRTFY.AbilityCheck"}} {{localize name}}</button>{{/if}}
</div>
{{#canFailAbilityChecks name ability}}
{{/canFailAbilityChecks}}
Expand Down Expand Up @@ -57,12 +57,12 @@
{{/if}}
{{#if deathsave}}
<div>
<button type="button" class="lmrtfy-death-save">{{localize "LMRTFY.DeathSave"}}</button>
{{#if (lmrtfy-isdemonlord this)}}<button type="button" class="lmrtfy-death-save">{{localize "LMRTFY.DemonLordFateRoll"}}</button>{{else}}<button type="button" class="lmrtfy-death-save">{{localize "LMRTFY.DeathSave"}}</button>{{/if}}
</div>
{{/if}}
{{#if perception}}
<div>
<button type="button" class="lmrtfy-perception">{{localize "LMRTFY.Perception"}}</button>
{{#if (lmrtfy-isdemonlord this)}}<button type="button" class="lmrtfy-perception">{{localize "DL.CharRolCorruption"}}{{else}}<button type="button" class="lmrtfy-perception">{{localize "LMRTFY.Perception"}}</button>{{/if}}
</div>
{{/if}}
{{#if tables}}
Expand Down