From f85d4e30b9f6d12db588d41998ffa6fc85f0f039 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 10:49:34 -0800 Subject: [PATCH 01/10] Switch to appliedEffects --- src/messages.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/messages.js b/src/messages.js index aca98af..4c143df 100644 --- a/src/messages.js +++ b/src/messages.js @@ -12,8 +12,7 @@ class BaseMessage { _getActiveEffectKeys(actor) { return actor - ? actor.effects - .filter((effect) => !effect.isSuppressed && !effect.disabled) + ? actor.appliedEffects .flatMap((effect) => effect.changes) .sort((a, b) => a.priority - b.priority) : []; From 3059d115840af8b39ab7d36d62adc306b3079bf9 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 10:50:54 -0800 Subject: [PATCH 02/10] Use appliedEffects when finding sources --- src/sources.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sources.js b/src/sources.js index 7ccfeee..8e7a47b 100644 --- a/src/sources.js +++ b/src/sources.js @@ -13,8 +13,7 @@ const SourceMixin = (superclass) => _getFlags(actor) { if (!actor) return {}; - const asArray = actor.effects - .filter((effect) => !effect.isSuppressed && !effect.disabled) + const asArray = actor.appliedEffects .flatMap((effect) => // make an object with the effect's label and change's key effect.changes.map((change) => ({ From 3ba97f31cc2707641011d2dffcda08a550afe6c2 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 10:59:46 -0800 Subject: [PATCH 03/10] change manifest to require dnd5e 3.0 --- module.json | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/module.json b/module.json index d6211aa..cc888b3 100644 --- a/module.json +++ b/module.json @@ -5,11 +5,22 @@ "authors": [{ "name": "kaelad", "discord": "kaelad#1693" }], "version": "0.1", "compatibility": { - "minimum": "10", + "minimum": "11", "verified": "11" }, "relationships": { - "systems": [{ "id": "dnd5e" }, { "id": "sw5e" }] + "systems": [ + { + "id": "dnd5e", + "compatibility": { + "minimum": "3.0.0", + "verified": "3.0.0" + } + }, + { + "id": "sw5e" + } + ] }, "esmodules": ["src/module.js", "src/settings.js"], "styles": ["css/adv-reminder.css"], From 80fced8d85c5edc292bd932375ac4dc9cdc031bb Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:03:17 -0800 Subject: [PATCH 04/10] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6440ca2..5598350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 3.3.0 + +- bug fix: 3.0.0 compatibility for Messages and Souces from effects on items +- feature: now requires dnd5e 3.0.0 and thus, Foundry 11 + # 3.2.1 - bug fix: tweak how messages are added to the dialog to remove a conflict with another module that also changes that dialog From 42385e330c6e1ccac7e64a4291459b00e2480746 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:14:38 -0800 Subject: [PATCH 05/10] Use new stealthDisadvantage property --- src/reminders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reminders.js b/src/reminders.js index 8d13ee1..c0c2f06 100644 --- a/src/reminders.js +++ b/src/reminders.js @@ -213,7 +213,7 @@ export class SkillReminder extends AbilityCheckReminder { _armorStealthDisadvantage() { if (this.skillId === "ste") { const item = this.items.find( - (item) => item.type === "equipment" && item.system?.equipped && item.system?.stealth + (item) => item.type === "equipment" && item.system.equipped && item.system.properties.has("stealthDisadvantage") ); debug("equiped item that imposes stealth disadvantage", item?.name); return item?.name; From b882a2700b5470fd385ec4a4e1dee937f4fd9932 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:15:40 -0800 Subject: [PATCH 06/10] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5598350..9718973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 3.3.0 - bug fix: 3.0.0 compatibility for Messages and Souces from effects on items +- bug fix: 3.0.0 compatibility with new stealthDisadvantage property - feature: now requires dnd5e 3.0.0 and thus, Foundry 11 # 3.2.1 From 9473f1cf52e477b8dc1d2cce80ba9f4d9bacf265 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:30:57 -0800 Subject: [PATCH 07/10] Use name instead of label on effect --- src/sources.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sources.js b/src/sources.js index 8e7a47b..9c0eca5 100644 --- a/src/sources.js +++ b/src/sources.js @@ -17,7 +17,7 @@ const SourceMixin = (superclass) => .flatMap((effect) => // make an object with the effect's label and change's key effect.changes.map((change) => ({ - label: effect.label, + name: effect.name, key: change.key, })) ) @@ -25,7 +25,7 @@ const SourceMixin = (superclass) => asArray.forEach((change) => (change.key = change.key.substring(15))); return asArray.reduce((accum, curr) => { if (!accum[curr.key]) accum[curr.key] = []; - accum[curr.key].push(curr.label); + accum[curr.key].push(curr.name); return accum; }, {}); } From a4fb4042683854959d584ebf24f836f589fcf01d Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:34:12 -0800 Subject: [PATCH 08/10] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9718973..b6cb94e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - bug fix: 3.0.0 compatibility for Messages and Souces from effects on items - bug fix: 3.0.0 compatibility with new stealthDisadvantage property +- bug fix: use `name` instead of `label` on effect to remove deprecation warning - feature: now requires dnd5e 3.0.0 and thus, Foundry 11 # 3.2.1 From 54e1aa6deff96e01fe04a2610f95e8dbfb9a68f2 Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 11:56:23 -0800 Subject: [PATCH 09/10] Fix message tests switch to appliedEffects and remove disabled/suspended tests since the code doesn't check that anymore --- test/messages.test.js | 132 +----------------------------------------- 1 file changed, 3 insertions(+), 129 deletions(-) diff --git a/test/messages.test.js b/test/messages.test.js index 700a30c..5395246 100644 --- a/test/messages.test.js +++ b/test/messages.test.js @@ -23,7 +23,7 @@ globalThis.setProperty = (object, key, value) => { }; function createActorWithEffects(...keyValuePairs) { - const effects = keyValuePairs.map(createEffect); + const appliedEffects = keyValuePairs.map(createEffect); return { system: { skills: { @@ -83,14 +83,13 @@ function createActorWithEffects(...keyValuePairs) { }, }, }, - effects, + appliedEffects, getRollData: () => ({}), }; } function createEffect([key, value]) { return { - isSuppressed: false, changes: [ { key, @@ -98,8 +97,7 @@ function createEffect([key, value]) { mode: 0, priority: "0", }, - ], - disabled: false, + ] }; } @@ -122,28 +120,6 @@ describe("AttackMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("attack with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const item = createItem("mwak", "str"); - const options = {}; - - new AttackMessage(actor, undefined, item).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("attack with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const item = createItem("mwak", "str"); - const options = {}; - - new AttackMessage(actor, undefined, item).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("AttackMessage message flags", () => { @@ -343,26 +319,6 @@ describe("AbilityCheckMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("ability check with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const options = {}; - - new AbilityCheckMessage(actor, "int").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("ability check with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const options = {}; - - new AbilityCheckMessage(actor, "int").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("AbilityCheckMessage message flags", () => { @@ -451,26 +407,6 @@ describe("AbilitySaveMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("saving throw with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const options = {}; - - new AbilitySaveMessage(actor, "int").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("saving throw with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const options = {}; - - new AbilitySaveMessage(actor, "int").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("AbilitySaveMessage message flags", () => { @@ -559,26 +495,6 @@ describe("SkillMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("skill check with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const options = {}; - - new SkillMessage(actor, "ath").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("skill check with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const options = {}; - - new SkillMessage(actor, "ath").addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("SkillMessage message flags", () => { @@ -707,26 +623,6 @@ describe("DeathSaveMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("death save with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const options = {}; - - new DeathSaveMessage(actor).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("death save with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const options = {}; - - new DeathSaveMessage(actor).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("DeathSaveMessage message flags", () => { @@ -804,28 +700,6 @@ describe("DamageMessage no legit active effects", () => { expect(options.dialogOptions).toBeUndefined(); }); - - test("damage with a suppressed active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].isSuppressed = true; - const item = createItem("mwak", "str"); - const options = {}; - - new DamageMessage(actor, undefined, item).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); - - test("damage with a disabled active effect should not add a message", () => { - const actor = createActorWithEffects(["flags.adv-reminder.message.all", "some message"]); - actor.effects[0].disabled = true; - const item = createItem("mwak", "str"); - const options = {}; - - new DamageMessage(actor, undefined, item).addMessage(options); - - expect(options.dialogOptions).toBeUndefined(); - }); }); describe("DamageMessage message flags", () => { From 458880e80dc8e933e87664d9ac92b521b80d2cba Mon Sep 17 00:00:00 2001 From: Chris Seieroe Date: Sat, 3 Feb 2024 12:06:41 -0800 Subject: [PATCH 10/10] Fix tests for stealth disadvantage from armor --- test/reminders.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/reminders.test.js b/test/reminders.test.js index 3497bbe..11b9c0c 100644 --- a/test/reminders.test.js +++ b/test/reminders.test.js @@ -669,7 +669,7 @@ describe("SkillReminder no legit active effects", () => { type: "spell", system: { equipped: true, - stealth: true, + properties: new Set(["stealthDisadvantage"]), }, }, ]; @@ -690,7 +690,7 @@ describe("SkillReminder no legit active effects", () => { type: "equipment", system: { equipped: false, - stealth: true, + properties: new Set(["stealthDisadvantage"]), }, }, ]; @@ -891,7 +891,7 @@ describe("SkillReminder disadvantage flags", () => { type: "equipment", system: { equipped: true, - stealth: true, + properties: new Set(["stealthDisadvantage"]), }, }, ]; @@ -912,7 +912,7 @@ describe("SkillReminder disadvantage flags", () => { type: "equipment", system: { equipped: true, - stealth: true, + properties: new Set(["stealthDisadvantage"]), }, }, ];