From 05bdfcf6edd23e51443ef32ed8f60a2d1f895312 Mon Sep 17 00:00:00 2001 From: Paul Maskelyne Date: Sat, 23 Sep 2023 22:22:01 +0100 Subject: [PATCH] fix hp rolls with new class items --- system/src/documents/ActorSD.mjs | 18 ++++++++---------- .../__tests__/documents-actor.test.mjs | 3 --- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/system/src/documents/ActorSD.mjs b/system/src/documents/ActorSD.mjs index f70d70ae..a578741f 100644 --- a/system/src/documents/ActorSD.mjs +++ b/system/src/documents/ActorSD.mjs @@ -355,7 +355,8 @@ export default class ActorSD extends Actor { } async getArmorClass() { - return await this.updateArmorClass(); + const ac = await this.updateArmorClass(); + return ac; } async isClaimedByUser() { @@ -896,15 +897,11 @@ export default class ActorSD extends Actor { } // Add AC from effects - this.system.attributes.ac.value = - newArmorClass + parseInt(this.system.bonuses.acBonus, 10); + newArmorClass += parseInt(this.system.bonuses.acBonus, 10); - // await Actor.updateDocuments([{ - // _id: this._id, - // "system.attributes.ac.value": newArmorClass, - // }]); + this.updateSource({"system.attributes.ac.value": newArmorClass}); - return this.system.attributes.ac.value; + return newArmorClass; } async usePotion(itemId) { @@ -1044,7 +1041,7 @@ export default class ActorSD extends Actor { } async _playerRollHP(options={}) { - if (this.system.class === "") { + if (!this.backgroundItems.class) { ui.notifications.error( game.i18n.format("SHADOWDARK.error.general.no_character_class"), {permanent: false} @@ -1063,7 +1060,8 @@ export default class ActorSD extends Actor { options.dialogTemplate = "systems/shadowdark/templates/dialog/roll-dialog.hbs"; options.chatCardTemplate = "systems/shadowdark/templates/chat/roll-hp.hbs"; - const parts = [CONFIG.SHADOWDARK.CLASS_HD[this.system.class]]; + const parts = [this.backgroundItems.class.system.hitPoints]; + await CONFIG.DiceSD.RollDialog(parts, data, options); } diff --git a/system/src/documents/__tests__/documents-actor.test.mjs b/system/src/documents/__tests__/documents-actor.test.mjs index 855ce6bd..2d17a0de 100644 --- a/system/src/documents/__tests__/documents-actor.test.mjs +++ b/system/src/documents/__tests__/documents-actor.test.mjs @@ -167,9 +167,6 @@ export default ({ describe, it, after, before, expect }) => { it("has luck", () => { expect(actor.system.luck).is.not.undefined; }); - it("has title", () => { - expect(actor.system.title).is.not.undefined; - }); after(async () => { await actor.delete();