Skip to content

Commit

Permalink
fix slashing getting undefined armour points
Browse files Browse the repository at this point in the history
  • Loading branch information
Forien committed Jun 8, 2024
1 parent 9cbcd24 commit c7dd7cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## v2.X.X

### v2.1.2
* Fixed the AP check for the Slashing weapon quality

### v2.1.1
* `Award XP` macro now offers checkboxes to deselect characters and/or companions from getting XP
* Added support for rerolling Combat Fatigue Tests
Expand Down
15 changes: 8 additions & 7 deletions dist/modules/features/ItemProperties.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export default class ItemProperties extends ForienBaseModule {
const {
actor,
opposedTest,
AP,
modifiers,
extraMessages
} = args;

debug('[ItemProperties] onApplyDamage arguments:', args);
this.#checkForSlashing(opposedTest, AP, actor, extraMessages);
this.#checkForSlashing(opposedTest, modifiers, actor, extraMessages);
this.#checkForIncendiary(opposedTest, actor, extraMessages);
this.#checkForBlinding(opposedTest, actor, extraMessages);
this.#checkForPoisonous(opposedTest, actor, extraMessages);
Expand Down Expand Up @@ -143,21 +143,22 @@ export default class ItemProperties extends ForienBaseModule {
* Checks if weapon used by attacker has Slashing Quality
*
* @param {OpposedTest} opposedTest Opposed Test of the attack
* @param {{}} AP abstract object containing information about Armour Points
* @param {{}} modifiers abstract object containing information about damage modifiers
* @param {ActorWfrp4e} actor Actor receiving the damage
* @param {string[]} extraMessages Array containing additional messages that appear on the Chat Card
*/
#checkForSlashing(opposedTest, AP, actor, extraMessages) {
#checkForSlashing(opposedTest, modifiers, actor, extraMessages) {
const slashing = opposedTest.attackerTest.weapon?.properties.qualities.slashing?.value ?? null;
if (slashing === null) return;

debug('[ItemProperties] Slashing property used:', {opposedTest, actor, extraMessages, rating: slashing, ap: AP.used});
if (slashing < AP.used) return;
let apUsed = modifiers.ap.used;
debug('[ItemProperties] Slashing property used:', {opposedTest, actor, extraMessages, rating: slashing, ap: apUsed});
if (slashing < apUsed) return;

actor.addCondition('bleeding');
extraMessages.push(game.i18n.format("Forien.Armoury.Arrows.Properties.Slashing.Message", {
location: AP.label,
ap: AP.used,
ap: apUsed,
rating: slashing
}));
}
Expand Down

0 comments on commit c7dd7cf

Please sign in to comment.