From 2a0d38e8f92e22846aba834718492d77cde12b15 Mon Sep 17 00:00:00 2001 From: aeauseth Date: Sun, 10 Nov 2024 17:54:37 -0800 Subject: [PATCH] Modify characteristics as appropriate when OIHID changed #232 --- module/actor/actor-sheet.mjs | 39 ------------------------------------ module/actor/actor.mjs | 24 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/module/actor/actor-sheet.mjs b/module/actor/actor-sheet.mjs index e04edf04..9b0a8406 100644 --- a/module/actor/actor-sheet.mjs +++ b/module/actor/actor-sheet.mjs @@ -268,14 +268,6 @@ export class HeroSystemActorSheet extends ActorSheet { ); await pdAttack._postUpload(); - let { - defenseValue: _defenseValuePD, - resistantValue: _resistantValuePD /*impenetrableValue*/, - //damageReductionValue: _damageReductionValuePD, - //damageNegationValue: _damageNegationValuePD /*knockbackResistance*/, - // defenseTags: defenseTagsP, - } = determineDefense(this.actor, pdAttack, { suppressDeprecationWarn: true }); - // New PD const { defenseValue: defenseValuePD, @@ -284,12 +276,6 @@ export class HeroSystemActorSheet extends ActorSheet { damageNegationValue: damageNegationValuePD, defenseTags: defenseTagsPD, } = getActorDefensesVsAttack(this.actor, pdAttack); - if (_defenseValuePD != defenseValuePD) { - console.warn("PD Defense mismatch", _defenseValuePD, defenseValuePD); - } - if (_resistantValuePD != resistantValuePD) { - console.warn("rPD Defense mismatch", _resistantValuePD, resistantValuePD); - } defense.PD = defenseValuePD; for (const tag of defenseTagsPD.filter((o) => o.operation === "add" && !o.options?.resistant)) { defense.PDtags = `${defense.PDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`; @@ -318,14 +304,6 @@ export class HeroSystemActorSheet extends ActorSheet { ); await edAttack._postUpload(); - let { - defenseValue: _defenseValueED, - resistantValue: _resistantValueED /* impenetrableValueE */, - //damageReductionValue: _damageReductionValueED, - //damageNegationValue: _damageNegationValueED /* knockbackResistanceE */, - // defenseTags: _defenseTagsE, - } = determineDefense(this.actor, edAttack, { suppressDeprecationWarn: true }); - // New ED const { defenseValue: defenseValueED, @@ -334,12 +312,6 @@ export class HeroSystemActorSheet extends ActorSheet { damageNegationValue: damageNegationValueED, defenseTags: defenseTagsED, } = getActorDefensesVsAttack(this.actor, edAttack); - if (_defenseValueED != defenseValueED) { - console.warn("ED Defense mismatch", _defenseValueED, defenseValueED); - } - if (_resistantValueED != resistantValueED) { - console.warn("rED Defense mismatch", _defenseValueED, defenseValueED); - } defense.ED = defenseValueED; for (const tag of defenseTagsED.filter((o) => o.operation === "add" && !o.options?.resistant)) { defense.EDtags = `${defense.EDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`; @@ -369,14 +341,6 @@ export class HeroSystemActorSheet extends ActorSheet { ); await mdAttack._postUpload(); - let { - defenseValue: _defenseValueMD, - //resistantValue: _resistantValueMD /*impenetrableValueM*/, - //damageReductionValue: _damageReductionValueMD, - //damageNegationValue: _damageNegationValueMD /*knockbackResistanceM*/, - defenseTags: _defenseTagsMD, - } = determineDefense(this.actor, mdAttack, { suppressDeprecationWarn: true }); - // New MD const { defenseValue: defenseValueMD, @@ -385,9 +349,6 @@ export class HeroSystemActorSheet extends ActorSheet { damageNegationValue: damageNegationValueMD, defenseTags: defenseTagsMD, } = getActorDefensesVsAttack(this.actor, mdAttack); - if (_defenseValueMD != defenseValueMD) { - console.warn("MD Defense mismatch", _defenseValueMD, defenseValueMD, _defenseTagsMD); - } defense.MD = defenseValueMD; for (const tag of defenseTagsMD.filter((o) => o.operation === "add" && !o.options?.resistant)) { defense.MDtags = `${defense.MDtags || ""}${tag.value.signedString()} ${tag.name} ${tag.shortDesc}\n`; diff --git a/module/actor/actor.mjs b/module/actor/actor.mjs index d3884198..62e7a2e9 100644 --- a/module/actor/actor.mjs +++ b/module/actor/actor.mjs @@ -287,9 +287,27 @@ export class HeroSystem6eActor extends Actor { if (item.findModsByXmlid("OIHID")) { await ae.update({ disabled: !data.system.heroicIdentity }); - //TODO: Any characteristic bonuses likely remain. - //Need to simulate a toggle off, without actually toggling the power off. - //Similar when turn AE back on. + // Modify characteristics as appropriate + for (const change of ae.changes) { + if (change.key.match(/max$/) && change.mode === 2 && change.value > 0) { + const valueKey = change.key.replace(/.max$/, ".value"); + let max = this; + valueKey.split(".").forEach((subPath) => { + max = max[subPath] || null; + }); + if (parseInt(max || 0) > 0) { + if (ae.disabled) { + await this.update({ + [valueKey]: max - parseInt(change.value), + }); + } else { + await this.update({ + [valueKey]: max + parseInt(change.value), + }); + } + } + } + } } } }