Skip to content

Commit

Permalink
Merge pull request #61 from kaelad02/fix60
Browse files Browse the repository at this point in the history
Adapt to some skill and tool changes the system made, fixing #60
  • Loading branch information
kaelad02 authored Feb 24, 2024
2 parents fc712c2 + e57fbb5 commit ab7fe34
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 173 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 3.3.2

- bug fix: [#60](https://github.com/kaelad02/adv-reminder/issues/60) Fix tool checks to show advantage and messages again after the check was moved from the item to the actor
- bug fix: Honor the ability you can pass into the `rollSkill` function, overriding the normal ability used for a skill. Examples would be a macro or using the new enricher to make a Strength (Intimidation) check.

# 3.3.1

- bug fix: [#56](https://github.com/kaelad02/adv-reminder/issues/56) Fully support messages on damage rolls other than attacks
Expand Down
4 changes: 2 additions & 2 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export class AbilitySaveMessage extends AbilityBaseMessage {
}

export class SkillMessage extends AbilityCheckMessage {
constructor(actor, skillId) {
super(actor, actor.system.skills[skillId].ability);
constructor(actor, abilityId, skillId) {
super(actor, abilityId);

/** @type {string} */
this.skillId = skillId;
Expand Down
4 changes: 2 additions & 2 deletions src/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export class AbilitySaveReminder extends AbilityBaseReminder {
}

export class SkillReminder extends AbilityCheckReminder {
constructor(actor, skillId, checkArmorStealth = true) {
super(actor, actor.system.skills[skillId].ability);
constructor(actor, abilityId, skillId, checkArmorStealth = true) {
super(actor, abilityId);

/** @type {string} */
this.skillId = skillId;
Expand Down
16 changes: 9 additions & 7 deletions src/rollers/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,21 @@ export default class CoreRollerHooks {

if (this.isFastForwarding(config)) return;

new SkillMessage(actor, skillId).addMessage(config);
if (showSources) new SkillSource(actor, skillId, true).updateOptions(config);
new SkillReminder(actor, skillId, this.checkArmorStealth).updateOptions(config);
const ability = config.data.defaultAbility;
new SkillMessage(actor, ability, skillId).addMessage(config);
if (showSources) new SkillSource(actor, ability, skillId, true).updateOptions(config);
new SkillReminder(actor, ability, skillId, this.checkArmorStealth).updateOptions(config);
}

preRollToolCheck(item, config) {
preRollToolCheck(actor, config, toolId) {
debug("preRollToolCheck hook called");

if (this.isFastForwarding(config)) return;

new AbilityCheckMessage(item.actor, item.system.ability).addMessage(config);
if (showSources) new AbilityCheckSource(item.actor, item.system.ability).updateOptions(config);
new AbilityCheckReminder(item.actor, item.system.ability).updateOptions(config);
const ability = config.data.defaultAbility;
new AbilityCheckMessage(actor, ability).addMessage(config);
if (showSources) new AbilityCheckSource(actor, ability).updateOptions(config);
new AbilityCheckReminder(actor, ability).updateOptions(config);
}

preRollDeathSave(actor, config) {
Expand Down
12 changes: 7 additions & 5 deletions src/rollers/midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ export default class MidiRollerHooks extends CoreRollerHooks {

if (this.isFastForwarding(config)) return;

new SkillMessage(actor, skillId).addMessage(config);
if (showSources) new SkillSource(actor, skillId, true).updateOptions(config);
const ability = config.data.defaultAbility;
new SkillMessage(actor, ability, skillId).addMessage(config);
if (showSources) new SkillSource(actor, ability, skillId, true).updateOptions(config);
}

preRollToolCheck(item, config) {
preRollToolCheck(actor, config, toolId) {
debug("preRollToolCheck hook called");

if (this.isFastForwarding(config)) return;

new AbilityCheckMessage(item.actor, item.system.ability).addMessage(config);
if (showSources) new AbilityCheckSource(item.actor, item.system.ability).updateOptions(config);
const ability = config.data.defaultAbility;
new AbilityCheckMessage(actor, ability).addMessage(config);
if (showSources) new AbilityCheckSource(actor, ability).updateOptions(config);
}

preRollDeathSave(actor, config) {
Expand Down
16 changes: 9 additions & 7 deletions src/rollers/rsr.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,28 @@ export default class ReadySetRollHooks extends CoreRollerHooks {
preRollSkill(actor, config, skillId) {
debug("preRollSkill hook called");

const ability = config.data.defaultAbility;
if (this._doMessages(config)) {
new SkillMessage(actor, skillId).addMessage(config);
if (showSources) new SkillSource(actor, skillId, true).updateOptions(config);
new SkillMessage(actor, ability, skillId).addMessage(config);
if (showSources) new SkillSource(actor, ability, skillId, true).updateOptions(config);
}

if (this._doReminder(config))
new SkillReminder(actor, skillId, this.checkArmorStealth).updateOptions(config);
new SkillReminder(actor, ability, skillId, this.checkArmorStealth).updateOptions(config);
}

preRollToolCheck(item, config) {
preRollToolCheck(actor, config, toolId) {
debug("preRollToolCheck hook called");

const ability = config.data.defaultAbility;
if (this._doMessages(config)) {
new AbilityCheckMessage(item.actor, item.system.ability).addMessage(config);
new AbilityCheckMessage(actor, ability).addMessage(config);
if (showSources)
new AbilityCheckSource(item.actor, item.system.ability).updateOptions(config);
new AbilityCheckSource(actor, ability).updateOptions(config);
}

if (this._doReminder(config))
new AbilityCheckReminder(item.actor, item.system.ability).updateOptions(config);
new AbilityCheckReminder(actor, ability).updateOptions(config);
}

preRollDeathSave(actor, config) {
Expand Down
58 changes: 0 additions & 58 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,6 @@ export default function commonTestInit() {

globalThis.createActorWithFlags = (...keys) => {
const actor = {
system: {
skills: {
acr: {
ability: "dex",
},
ani: {
ability: "wis",
},
arc: {
ability: "int",
},
ath: {
ability: "str",
},
dec: {
ability: "cha",
},
his: {
ability: "int",
},
ins: {
ability: "wis",
},
itm: {
ability: "cha",
},
inv: {
ability: "int",
},
med: {
ability: "wis",
},
nat: {
ability: "int",
},
prc: {
ability: "wis",
},
prf: {
ability: "cha",
},
per: {
ability: "cha",
},
rel: {
ability: "int",
},
slt: {
ability: "dex",
},
ste: {
ability: "dex",
},
sur: {
ability: "wis",
},
},
},
flags: {},
};
keys.forEach((k) => setProperty(actor, k, true));
Expand Down
78 changes: 10 additions & 68 deletions test/messages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,6 @@ globalThis.setProperty = (object, key, value) => {
function createActorWithEffects(...keyValuePairs) {
const appliedEffects = keyValuePairs.map(createEffect);
return {
system: {
skills: {
acr: {
ability: "dex",
},
ani: {
ability: "wis",
},
arc: {
ability: "int",
},
ath: {
ability: "str",
},
dec: {
ability: "cha",
},
his: {
ability: "int",
},
ins: {
ability: "wis",
},
itm: {
ability: "cha",
},
inv: {
ability: "int",
},
med: {
ability: "wis",
},
nat: {
ability: "int",
},
prc: {
ability: "wis",
},
prf: {
ability: "cha",
},
per: {
ability: "cha",
},
rel: {
ability: "int",
},
slt: {
ability: "dex",
},
ste: {
ability: "dex",
},
sur: {
ability: "wis",
},
},
},
appliedEffects,
getRollData: () => ({}),
};
Expand Down Expand Up @@ -491,7 +433,7 @@ describe("SkillMessage no legit active effects", () => {
const actor = createActorWithEffects();
const options = {};

new SkillMessage(actor, "ath").addMessage(options);
new SkillMessage(actor, "str", "ath").addMessage(options);

expect(options.dialogOptions).toBeUndefined();
});
Expand All @@ -502,7 +444,7 @@ describe("SkillMessage message flags", () => {
const actor = createActorWithEffects(["flags.adv-reminder.message.all", "message.all message"]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual(["message.all message"]);
});
Expand All @@ -514,7 +456,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual([
"message.ability.all message",
Expand All @@ -528,7 +470,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual([
"message.ability.check.all message",
Expand All @@ -542,7 +484,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual([
"message.ability.check.int message",
Expand All @@ -556,7 +498,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "acr").addMessage(options);
new SkillMessage(actor, "dex", "acr").addMessage(options);

expect(options.dialogOptions).toBeUndefined();
});
Expand All @@ -568,7 +510,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual([
"message.skill.all message",
Expand All @@ -582,7 +524,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "prc").addMessage(options);
new SkillMessage(actor, "wis", "prc").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual([
"message.skill.prc message",
Expand All @@ -596,7 +538,7 @@ describe("SkillMessage message flags", () => {
]);
const options = {};

new SkillMessage(actor, "nat").addMessage(options);
new SkillMessage(actor, "int", "nat").addMessage(options);

expect(options.dialogOptions).toBeUndefined();
});
Expand All @@ -608,7 +550,7 @@ describe("SkillMessage message flags", () => {
);
const options = {};

new SkillMessage(actor, "ste").addMessage(options);
new SkillMessage(actor, "dex", "ste").addMessage(options);

expect(options.dialogOptions["adv-reminder"].messages).toStrictEqual(["first", "second"]);
});
Expand Down
Loading

0 comments on commit ab7fe34

Please sign in to comment.