Skip to content

Commit

Permalink
Fix modifier adjustments for top level selectors (foundryvtt#4419)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez authored Oct 10, 2022
1 parent 22d0ec4 commit 768c249
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/module/actor/modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class CheckModifier extends StatisticModifier {
slug: string,
statistic: { modifiers: readonly ModifierPF2e[] },
modifiers: ModifierPF2e[] = [],
rollOptions: string[] = []
rollOptions: string[] | Set<string> = new Set()
) {
super(slug, statistic.modifiers.map((modifier) => modifier.clone()).concat(modifiers), rollOptions);
}
Expand Down
17 changes: 10 additions & 7 deletions src/module/system/statistic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,15 @@ class StatisticCheck {
this.type = data.check?.type ?? "check";
this.label = this.#calculateLabel(data);
this.domains = (data.domains ?? []).concat(data.check?.domains ?? []);
this.modifiers = parent.modifiers.concat(data.check?.modifiers ?? []);
if (data.check?.domains) {
this.modifiers.push(...extractModifiers(parent.actor.synthetics, data.check.domains));
}

const rollOptions = parent.createRollOptions(this.domains, options);
const allCheckModifiers = [
parent.modifiers,
data.check?.modifiers ?? [],
data.check?.domains ? extractModifiers(parent.actor.synthetics, data.check.domains) : [],
].flat();
this.modifiers = allCheckModifiers.map((modifier) => modifier.clone({ test: rollOptions }));

this.#stat = new StatisticModifier(this.label, this.modifiers, rollOptions);
this.mod = this.#stat.totalModifier;
}
Expand Down Expand Up @@ -385,7 +388,7 @@ class StatisticCheck {
};

const roll = await CheckPF2e.roll(
new CheckModifier(this.label, this.#stat, extraModifiers),
new CheckModifier(this.label, this.#stat, extraModifiers, options),
context,
null,
args.callback
Expand Down Expand Up @@ -417,13 +420,13 @@ class StatisticDifficultyClass {

// Add all modifiers from all sources together, then test them
const allDCModifiers = [
parent.modifiers ?? [],
parent.modifiers,
data.dc?.modifiers ?? [],
data.dc?.domains ? extractModifiers(parent.actor.synthetics, data.dc.domains) : [],
].flat();
this.modifiers = allDCModifiers.map((modifier) => modifier.clone({ test: rollOptions }));

this.value = (data.dc?.base ?? 10) + new StatisticModifier("", this.modifiers).totalModifier;
this.value = (data.dc?.base ?? 10) + new StatisticModifier("", this.modifiers, rollOptions).totalModifier;
}

createRollOptions(args: RollOptionParameters = {}): Set<string> {
Expand Down

0 comments on commit 768c249

Please sign in to comment.