Skip to content

Commit

Permalink
Fix "double vs" resistance requiring all entries to be true (#17024)
Browse files Browse the repository at this point in the history
  • Loading branch information
websterguy authored Oct 28, 2024
1 parent 5091245 commit 515726a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/module/actor/data/iwr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ abstract class IWR<TType extends IWRType> {
return ["check:outcome:critical-success"];
case "custom":
return this.definition ?? [];
case "damage-from-spells":
return ["damage", "item:type:spell", "impulse"];
case "disease":
return ["item:trait:disease"];
case "emotion":
Expand Down Expand Up @@ -159,9 +157,9 @@ abstract class IWR<TType extends IWRType> {
const component = iwrType === "splash-damage" ? "splash" : "precision";
return [`damage:component:${component}`];
}
case "spells": {
return ["damage", { or: ["item:type:spell", "item:from-spell", "impulse"] }];
}
case "spells":
case "damage-from-spells":
return ["damage", { or: ["item:type:spell", "item:from-spell", "item:trait:impulse"] }];
case "unarmed-attacks":
return ["item:category:unarmed"];
case "unholy":
Expand Down Expand Up @@ -369,7 +367,15 @@ class Resistance extends IWR<ResistanceType> implements ResistanceSource {
/** Get the doubled value of this resistance if present and applicable to a given instance of damage */
getDoubledValue(damageDescription: Set<string>): number {
if (this.doubleVs.length === 0) return this.value;
const predicate = new Predicate(this.doubleVs.flatMap((d) => this.describe(d)));
const predicate =
this.doubleVs.length === 1
? new Predicate(this.describe(this.doubleVs[0]))
: new Predicate({
or: this.doubleVs.map((doubleVs) => {
const description = this.describe(doubleVs);
return description.length === 1 ? description[0] : { and: description };
}),
});
return predicate.test(damageDescription) ? this.value * 2 : this.value;
}
}
Expand Down

0 comments on commit 515726a

Please sign in to comment.