Skip to content

Commit

Permalink
Improved DEADLYBLOW so it does not apply to adjustment powers, sense-…
Browse files Browse the repository at this point in the history
…affecting powers, or ENTANGLES. dmdorman#1493
  • Loading branch information
aeauseth committed Nov 24, 2024
1 parent fe7fc90 commit dffc4a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Releases

## Version 4.0.7 [Hero System 6e (Unofficial) v2](https://github.com/dmdorman/hero6e-foundryvtt)
## Version 4.0.8 [Hero System 6e (Unofficial) v2](https://github.com/dmdorman/hero6e-foundryvtt)

- Improved DEADLYBLOW so it does not apply to adjustment powers, sense-affecting powers, or ENTANGLES. GM still has to confirm DEADLYBLOW with applicable powers. [#1493](https://github.com/dmdorman/hero6e-foundryvtt/issues/1493)

## Version 4.0.7

- Fixed Flash, which now has a unique icon per sense group. [#1486](https://github.com/dmdorman/hero6e-foundryvtt/issues/1486)
- Conditional DAMAGEREDUCTION and DAMAGENEGATION defenses now prompt for applicability. [#1478](https://github.com/dmdorman/hero6e-foundryvtt/issues/1478)
Expand Down
10 changes: 5 additions & 5 deletions module/item/item-attack-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class ItemAttackFormApplication extends FormApplication {
if (DEADLYBLOW) {
item.system.conditionalAttacks ??= {};
item.system.conditionalAttacks[DEADLYBLOW.id] = DEADLYBLOW;
item.system.conditionalAttacks[DEADLYBLOW.id].checked ??= true;
item.system.conditionalAttacks[DEADLYBLOW.id].system.checked ??= true;
}

data.action = Attack.getActionInfo(
Expand Down Expand Up @@ -399,10 +399,10 @@ export class ItemAttackFormApplication extends FormApplication {
// Save conditionalAttack check
const expandedData = foundry.utils.expandObject(formData);
for (const ca in expandedData?.system?.conditionalAttacks) {
console.log(ca);
this.data.item.system.conditionalAttacks[ca].checked = expandedData.system.conditionalAttacks[ca].checked;
await this.data.item.update({
[`system.conditionalAttacks`]: this.data.item.system.conditionalAttacks,
// this.data.item.system.conditionalAttacks[ca].system.checked =
// expandedData.system.conditionalAttacks[ca].system.checked;
await this.data.item.system.conditionalAttacks[ca].update({
[`system.checked`]: expandedData.system.conditionalAttacks[ca].system.checked,
});
}

Expand Down
15 changes: 9 additions & 6 deletions module/utility/damage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,8 @@ export function convertToDcFromItem(item, options) {
const DEADLYBLOW = item.actor?.items.find((o) => o.system.XMLID === "DEADLYBLOW");
if (DEADLYBLOW) {
item.system.conditionalAttacks ??= {};
item.system.conditionalAttacks[DEADLYBLOW.id] ??= {
...DEADLYBLOW,
id: DEADLYBLOW.id,
};
item.system.conditionalAttacks[DEADLYBLOW.id].checked ??= true;
item.system.conditionalAttacks[DEADLYBLOW.id] = DEADLYBLOW;
item.system.conditionalAttacks[DEADLYBLOW.id].system.checked ??= true;
}

if (item.actor) {
Expand All @@ -421,7 +418,12 @@ export function convertToDcFromItem(item, options) {
}

// If unchecked or missing then assume it is enabled
if (!item.system.conditionalAttacks[key].checked) continue;
if (!conditionalAttack.system.checked) continue;

// Make sure conditionalAttack applies (only for DEADLYBLOW at the moment)
if (typeof conditionalAttack.baseInfo?.appliesTo === "function") {
if (!conditionalAttack.baseInfo.appliesTo(item)) continue;
}

switch (conditionalAttack.system.XMLID) {
case "DEADLYBLOW": {
Expand All @@ -442,6 +444,7 @@ export function convertToDcFromItem(item, options) {
: ""
}`,
});

break;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion templates/attack/item-attack-application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
{{#if (appliesTo this @root/item)}}
<tr>
<td>
<input name="system.conditionalAttacks.{{this.id}}.checked" type="checkbox" _id="{{this.id}}" {{checked this.checked}} data-dtype="Boolean" />
<input name="system.conditionalAttacks.{{this.id}}.system.checked" type="checkbox" _id="{{this.id}}" {{checked this.system.checked}} data-dtype="Boolean" />
</td>
<td class="left">
<b>{{this.name}}{{#if @root/item.system.SFX}} ({{@root/item.system.SFX}}){{/if}}</b>: {{this.system.description}}
Expand Down

0 comments on commit dffc4a3

Please sign in to comment.