Skip to content

Commit 58984a5

Browse files
authored
Merge pull request #360 from sasquach45932/main
Shadow Of The Demon Lord support
2 parents 3eb0e5c + 99b796a commit 58984a5

File tree

6 files changed

+67
-2
lines changed

6 files changed

+67
-2
lines changed

lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"ACTIVEAURAS.FORM_Height": "Check Token Height",
3434
"ACTIVEAURAS.FORM_Alignment": "Check Alignment",
3535
"ACTIVEAURAS.FORM_Type": "Creature types match, split multiple with ;",
36+
"ACTIVEAURAS.FORM_TypeDemonlord": "Ancestry, Creature descriptor match, split multiple with ;",
3637
"ACTIVEAURAS.FORM_CustomCondition": "Custom Check",
3738
"ACTIVEAURAS.FORM_CustomConditionPrompt": "JavaScript",
3839
"ACTIVEAURAS.FORM_Good": "Good",

src/app/ActiveAuraSheet.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function getSchema(document) {
7878
},
7979
type: {
8080
field: new StringField({
81-
label: game.i18n.format("ACTIVEAURAS.FORM_Type"),
81+
label: (game.system.id === "demonlord") ? game.i18n.format("ACTIVEAURAS.FORM_TypeDemonlord") : game.i18n.format("ACTIVEAURAS.FORM_Type"),
8282
initial: "",
8383
}),
8484
name: `flags.${CONSTANTS.MODULE_NAME}.type`,
@@ -204,6 +204,7 @@ async function _preparePartContext(wrapped, ...args) {
204204
context.activeAuras = getSchema(this.document);
205205
context.activeAuras.applied = this.document.getFlag(CONSTANTS.MODULE_NAME, "applied") ?? false;
206206
context.activeAuras.swade = game.system.id === "swade";
207+
context.activeAuras.demonlord = game.system.id === "demonlord";
207208
}
208209
return context;
209210
};
@@ -254,6 +255,18 @@ export function extendAESheet() {
254255
"WRAPPER"
255256
);
256257
}
258+
259+
// demonlord
260+
if (CONFIG.ActiveEffect.sheetClasses.base["demonlord.DLActiveEffectConfig"]){
261+
CONFIG.ActiveEffect.sheetClasses.base["demonlord.DLActiveEffectConfig"].cls.PARTS = getExtendedParts(CONFIG.ActiveEffect.sheetClasses.base["demonlord.DLActiveEffectConfig"].cls.PARTS);
262+
263+
libWrapper.register(
264+
"ActiveAuras",
265+
"CONFIG.ActiveEffect.sheetClasses.base['demonlord.DLActiveEffectConfig'].cls.prototype._onRender",
266+
_onRender,
267+
"WRAPPER"
268+
);
269+
}
257270
});
258271

259272
}

src/lib/AAHelpers.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export class AAHelpers {
8080
return AAHelpers.typeCheckSWADE(canvasToken, type);
8181
case "dnd4e":
8282
return AAHelpers.typeCheck4e(canvasToken, type);
83+
case "demonlord":
84+
return AAHelpers.typeCheckDemonLord(canvasToken, type);
8385
}
8486
}
8587

@@ -220,6 +222,43 @@ export class AAHelpers {
220222
return false;
221223
}
222224

225+
static typeCheckDemonLord(canvasToken, type) {
226+
if (type?.trim() === "any") return true;
227+
const actorData = canvasToken?.actor;
228+
let tokenTypes;
229+
switch (canvasToken.actor.type) {
230+
case "character":
231+
{
232+
try {
233+
tokenTypes = [actorData?.items.find((i) => i.type === "ancestry")?.name?.toLocaleLowerCase()]
234+
} catch (error) {
235+
Logger.error("ActiveAuras: the token has an unreadable type", canvasToken);
236+
}
237+
}
238+
break;
239+
case "creature":
240+
{
241+
try {
242+
if (actorData.system.descriptor.toLocaleLowerCase().includes('('))
243+
{
244+
let descriptor = actorData.system.descriptor.toLocaleLowerCase()
245+
descriptor = descriptor.replace(")", "")
246+
tokenTypes = descriptor.replace("(", "").split(" ")
247+
}
248+
else
249+
tokenTypes = [actorData.system.descriptor.toLocaleLowerCase()]
250+
} catch (error) {
251+
Logger.error("ActiveAuras: the token has an unreadable type", canvasToken);
252+
}
253+
}
254+
break;
255+
case "vehicle":
256+
return;
257+
}
258+
if (tokenTypes.includes(type)) return true;
259+
return false;
260+
}
261+
223262
static Wildcard(canvasToken, wildcard, extra) {
224263
if (game.system.id !== "swade") return true;
225264
let Wild = canvasToken.actor.isWildcard;
@@ -244,6 +283,12 @@ export class AAHelpers {
244283
// dead
245284
else return false;
246285
}
286+
case "demonlord": {
287+
const { max, value } = document.system.characteristics.health
288+
if ((value) >= max) return true;
289+
// dead
290+
else return false;
291+
}
247292
}
248293
}
249294

src/lib/AAHooks.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ export function preUpdateActorHook(actor, update, _other) {
250250
&& actor.system?.attributes?.hp?.value === 0 && update.system.attributes.hp.value > 0)
251251
|| (foundry.utils.hasProperty(update, "system.wounds.value") // swade
252252
&& (update.system.wounds.value - (actor.system?.wounds?.ignored ?? 0)) < (actor.system?.wounds?.max ?? 0))
253+
|| (foundry.utils.hasProperty(update, "system.characteristics.health.injured") // demonlord
254+
&& actor.system.characteristics.health.value >= actor.system.characteristics.health.max)
253255
) {
254256
Hooks.once("updateActor", () => {
255257
addToCollateSemaphore(canvas.scene.id, true, false, "updateActor, revived");

src/lib/AATemplates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class AATemplates {
2929

3030
static getAuraShape(source, radius) {
3131
let shape = "circle";
32-
if (["dnd5e", "dnd4e"].includes(game.system.id)) {
32+
if (["dnd5e", "dnd4e","demonlord"].includes(game.system.id)) {
3333
if (game.settings.get("core", "gridDiagonals") === 0) shape = "rectangle";
3434
}
3535

templates/config.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
{{formGroup activeAuras.aura.field name=activeAuras.aura.name value=activeAuras.aura.value options=activeAuras.aura.options rootId=rootId}}
1010
{{formGroup activeAuras.nameOverride.field name=activeAuras.nameOverride.name value=activeAuras.nameOverride.value rootId=rootId}}
1111
{{formGroup activeAuras.radius.field name=activeAuras.radius.name value=activeAuras.radius.value placeholder=activeAuras.radius.placeholder rootId=rootId}}
12+
{{#unless activeAuras.demonlord}}
1213
{{formGroup activeAuras.alignment.field name=activeAuras.alignment.name value=activeAuras.alignment.value options=activeAuras.alignment.options rootId=rootId}}
14+
{{/unless}}
1315
{{formGroup activeAuras.type.field name=activeAuras.type.name value=activeAuras.type.value placeholder=activeAuras.type.placeholder rootId=rootId}}
1416
{{formGroup activeAuras.customCheck.field name=activeAuras.customCheck.name value=activeAuras.customCheck.value placeholder=activeAuras.customCheck.placeholder rootId=rootId}}
1517
{{formGroup activeAuras.ignoreSelf.field name=activeAuras.ignoreSelf.name value=activeAuras.ignoreSelf.value rootId=rootId}}
@@ -19,7 +21,9 @@
1921
{{formGroup activeAuras.hostile.field name=activeAuras.hostile.name value=activeAuras.hostile.value rootId=rootId}}
2022
{{formGroup activeAuras.onlyOnce.field name=activeAuras.onlyOnce.name value=activeAuras.onlyOnce.value rootId=rootId}}
2123
{{formGroup activeAuras.wallsBlock.field name=activeAuras.wallsBlock.name value=activeAuras.wallsBlock.value options=activeAuras.wallsBlock.options rootId=rootId}}
24+
{{#unless activeAuras.demonlord}}
2225
{{formGroup activeAuras.statuses.field name=activeAuras.statuses.name value=activeAuras.statuses.value options=activeAuras.statuses.options rootId=rootId classes="statuses"}}
26+
{{/unless}}
2327
{{#if activeAuras.swade}}
2428
{{formGroup activeAuras.wildcard.field name=activeAuras.wildcard.name value=activeAuras.wildcard.value rootId=rootId}}
2529
{{formGroup activeAuras.extra.field name=activeAuras.extra.name value=activeAuras.extra.value rootId=rootId}}

0 commit comments

Comments
 (0)