Skip to content

Commit

Permalink
Merge pull request dmdorman#1516 from aeauseth/main
Browse files Browse the repository at this point in the history
ignoreDefenseIds are passed to onRollKnockback. Only the GM can click on the button to apply knockback. Improved VULNERABILITY description.
  • Loading branch information
aeauseth authored Nov 24, 2024
2 parents ca17587 + 087e399 commit 2c90914
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
- Improved DEADLYBLOW so it does not apply to adjustment powers, sense-affecting powers, or ENTANGLES. Also the extra DCs are not shown in the Attacks tab (which was confusing). GM still has to confirm DEADLYBLOW with applicable powers. [#1493](https://github.com/dmdorman/hero6e-foundryvtt/issues/1493)
- Improved workflow when attacking ENTANGLED tokens. [#1500](https://github.com/dmdorman/hero6e-foundryvtt/issues/1500)
- The Attack type is now included in the Attack Tags on the chat card.
- Conditional defenses used in main damage are also used in knockback damage. [#1498](https://github.com/dmdorman/hero6e-foundryvtt/issues/1498)
- Only the GM can click on the button to apply knockback. [#1454](https://github.com/dmdorman/hero6e-foundryvtt/issues/1454)
- Improved VULNERABILITY description. [#1484](https://github.com/dmdorman/hero6e-foundryvtt/issues/1484)

## Version 4.0.7

Expand Down
10 changes: 5 additions & 5 deletions module/item/item-attack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export async function onMessageRendered(html) {
}
if (game.user.isGM) {
html.find(`[data-visibility="redacted"]`).remove();
html.find(`[data-visibility="!gm"]`).remove();
}

// visibility based on actor owner
Expand Down Expand Up @@ -1201,6 +1202,7 @@ export async function _onRollKnockback(event) {
const button = event.currentTarget;
button.blur(); // The button remains highlighted for some reason; kluge to fix.
const options = { ...button.dataset };
const ignoreDefenseIds = JSON.parse(options.ignoreDefenseIdsJson) || [];
const item = fromUuidSync(options.itemId);
const token = game.scenes.current.tokens.get(options.targetTokenId);
const knockbackResultTotal = options.knockbackResultTotal;
Expand Down Expand Up @@ -1260,7 +1262,7 @@ export async function _onRollKnockback(event) {
label: "Roll & Apply",
callback: async function (html) {
const dice = html.find("input")[0].value;
await _rollApplyKnockback(token, parseInt(dice));
await _rollApplyKnockback(token, parseInt(dice), ignoreDefenseIds);
},
},
cancel: {
Expand All @@ -1279,7 +1281,7 @@ export async function _onRollKnockback(event) {
* @param {HeroSystem6eToken} token
* @param {number} knockbackDice
*/
async function _rollApplyKnockback(token, knockbackDice) {
async function _rollApplyKnockback(token, knockbackDice, ignoreDefenseIds) {
const actor = token.actor;

const damageRoller = new HeroRoller()
Expand All @@ -1301,9 +1303,6 @@ async function _rollApplyKnockback(token, knockbackDice) {
await pdAttack._postUpload();
pdAttack.name ??= "KNOCKBACK";

// TODO: Conditional defenses?
let ignoreDefenseIds = [];

let defense = "";

// New Defense Stuff
Expand Down Expand Up @@ -2493,6 +2492,7 @@ export async function _onApplyDamageToSpecificToken(event, tokenId) {
// defense
defense: defense,
damageNegationValue: damageNegationValue,
ignoreDefenseIdsJson: JSON.stringify(ignoreDefenseIds),

// knockback
knockbackMessage: damageDetail.knockbackMessage,
Expand Down
9 changes: 9 additions & 0 deletions module/item/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3563,6 +3563,11 @@ export class HeroSystem6eItem extends Item {
case "SCIENCE_SKILL":
break;

case "VULNERABILITY":
// Vulnerability: Mental (Common)
system.description += `${system.INPUT}`;
break;

default:
if (configPowerInfo?.type?.includes("skill")) {
break;
Expand All @@ -3588,6 +3593,10 @@ export class HeroSystem6eItem extends Item {
case "RECOGNIZED":
case "SLEEPING":
case "USEFUL":
if (system.XMLID === "VULNERABILITY") {
system.description += ` (${adder.OPTION_ALIAS})`.replace("((", "("); // Unclear why there is a parand in the OPTION_ALIAS
break;
}
_adderArray.push(`${adder.ALIAS} ${adder.OPTION_ALIAS}`);
break;

Expand Down
10 changes: 8 additions & 2 deletions templates/chat/apply-damage-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@


{{#if (gt knockbackResultTotal 0)}}
<div data-visibility="{{actor.id}}">
<div data-visibility="gm">
<button class="roll-knockback" data-item-Id="{{item.uuid}}" data-target-Token-Id="{{targetToken.id}}"
data-knockback-Result-Total="{{knockbackResultTotal}}">
data-knockback-Result-Total="{{knockbackResultTotal}}" data-ignore-Defense-Ids-Json="{{ignoreDefenseIdsJson}}">
{{ knockbackMessage }}
</button>
</div>
<div data-visibility="!gm">
<button class="roll-knockback" data-item-Id="{{item.uuid}}" data-target-Token-Id="{{targetToken.id}}"
data-knockback-Result-Total="{{knockbackResultTotal}}" data-ignore-Defense-Ids-Json="{{ignoreDefenseIdsJson}}" disabled title="Only a GM can perform KB">
{{ knockbackMessage }}
</button>
</div>
Expand Down

0 comments on commit 2c90914

Please sign in to comment.