Skip to content

Commit

Permalink
Merge pull request dmdorman#1511 from aeauseth/main
Browse files Browse the repository at this point in the history
Improved DEADLYBLOW so it does not apply to adjustment powers, sense-affecting powers, or ENTANGLES
  • Loading branch information
aeauseth authored Nov 24, 2024
2 parents fabdd07 + dffc4a3 commit 0fa16f8
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 35 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
4 changes: 0 additions & 4 deletions module/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2398,10 +2398,6 @@ export class HeroSystem6eActor extends Actor {

this.system.pointsDetail[item.parentItem?.type || item.type] += _realCost;
this.system.activePointsDetail[item.parentItem?.type || item.type] += _activePoints;

if ((item.parentItem?.type || item.type) === "power") {
console.log(_realCost, item.name);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions module/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3921,6 +3921,14 @@ function addPower(powerDescription6e, powerOverrideFor5e) {
return 0;
}
},
appliesTo: function (item) {
// Maneuver or other poorly defined item, assume it applies
if (!item || !item.baseInfo) return true;
if (item.baseInfo.type.includes("adjustment")) return false;
if (item.baseInfo.type.includes("sense-affecting")) return false;
if (item.system.XMLID === "ENTANGLE") return false;
return true;
},
xml: `<TALENT XMLID="DEADLYBLOW" ID="1709159979031" BASECOST="0.0" LEVELS="2" ALIAS="Deadly Blow: +2d6" POSITION="9" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" OPTION="VERYLIMITED" OPTIONID="VERYLIMITED" OPTION_ALIAS="[very limited circumstances]" INCLUDE_NOTES_IN_PRINTOUT="Yes" NAME="" />`,
},
{},
Expand Down
7 changes: 7 additions & 0 deletions module/handlebars-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function initializeHandlebarsHelpers() {
Handlebars.registerHelper("isdefined", isDefined);
Handlebars.registerHelper("toLowerCase", toLowerCase);
Handlebars.registerHelper("toUpperCase", toUpperCase);
Handlebars.registerHelper("appliesTo", appliesTo);
}

function indexOf(str, searchTerm) {
Expand Down Expand Up @@ -63,3 +64,9 @@ function concat() {
function isDefined(value) {
return value !== undefined;
}

// Typically to determine if DEADLYBLOW applies to a specific attack
function appliesTo(power, attack) {
if (typeof power?.baseInfo?.appliesTo !== "function") return false;
return power.baseInfo.appliesTo(attack);
}
2 changes: 1 addition & 1 deletion module/heroCompendiums.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async function CreateHeroItems() {
)) {
const itemData = HeroSystem6eItem.itemDataFromXml(power.xml, bogusActor);
itemData.system.versionHeroSystem6eManuallyCreated = game.system.version;
console.log(power, itemData, bogusActor);
//console.log(power, itemData, bogusActor);
if (power.type.includes("characteristic")) {
itemData.folder = folderPowerCharacteristic[0].id;
} else if (power.type.includes("perk")) {
Expand Down
15 changes: 6 additions & 9 deletions module/item/item-attack-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,8 @@ export class ItemAttackFormApplication extends FormApplication {
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;
}

data.action = Attack.getActionInfo(
Expand Down Expand Up @@ -402,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
31 changes: 17 additions & 14 deletions templates/attack/item-attack-application.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{!-- {{ log 'HEROSYS ITEM ATTACK APPLICATION CARD item-attack-application' this }} --}}
{{ log 'HEROSYS ITEM ATTACK APPLICATION CARD item-attack-application' this }}
<form data-actor-id="{{actor.id}}" data-item-id="{{item.id}}" data-token-id="{{token.id}}">
<div class="hero chat-card item-card attack-card">
<header class="card-header flexrow">
Expand Down Expand Up @@ -303,19 +303,22 @@

{{!-- Conditional attack selection. DEADLY BLOW --}}
<div class="form-fields csl-attack-list">
<table>
{{#each item.system.conditionalAttacks}}
<tr>
<td>
<input name="system.conditionalAttacks.{{this.id}}.checked" type="checkbox" _id="{{this.id}}" {{checked this.checked}} data-dtype="Boolean" />
</td>
<td class="left">
<b>{{this.name}}{{#if item.system.SFX}} ({{item.system.SFX}}){{/if}}</b>: {{this.system.description}}
</td>
</tr>
{{/each}}
</table>
</div>
<table>
{{#each item.system.conditionalAttacks}}
{{! Don't show DEADLYBLOW/conditional attacks for adjustment or sense-affecting powers --}}
{{#if (appliesTo this @root/item)}}
<tr>
<td>
<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}}
</td>
</tr>
{{/if}}
{{/each}}
</table>
</div>



Expand Down

0 comments on commit 0fa16f8

Please sign in to comment.