Skip to content

Commit

Permalink
Merge pull request dmdorman#1470 from aeauseth/main
Browse files Browse the repository at this point in the history
Improved display of COMPOUNDPOWER costs.  Improved FullHealth.
  • Loading branch information
aeauseth authored Nov 16, 2024
2 parents 12080a2 + 567f975 commit ff8058e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Initial support for Only in Alternate Identity (OIAID). There is a "Heroic Identity" checkbox in the OTHERS tab. [#1431](https://github.com/dmdorman/hero6e-foundryvtt/issues/1431) [#232](https://github.com/dmdorman/hero6e-foundryvtt/issues/232)
- Improved automatic spending of END during combat for continuous powers to prevent spending of resources when rewinding or re-doing a turn. [#1448](https://github.com/dmdorman/hero6e-foundryvtt/issues/1448)
- MAX characteristic is now color coded when different than CORE. [#1461](https://github.com/dmdorman/hero6e-foundryvtt/issues/1461)
- Improved display of COMPOUNDPOWER costs. [#1434](https://github.com/dmdorman/hero6e-foundryvtt/issues/1461)

## Version 4.0.5

Expand Down
26 changes: 20 additions & 6 deletions module/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,17 +1076,31 @@ export class HeroSystem6eActor extends Actor {
await ae.delete();
}

// Set Characteristics MAX to CORE
const characteristicChangesMax = {};
for (const char of Object.keys(this.system.characteristics)) {
const core = parseInt(this.system.characteristics[char].core);
const max = parseInt(this.system.characteristics[char].max);
if (core !== max) {
characteristicChangesMax[`system.characteristics.${char}.max`] = core;
}
}
if (Object.keys(characteristicChangesMax).length > 0) {
await this.update(characteristicChangesMax);
}

// Set Characteristics VALUE to MAX
const characteristicChanges = {};
const characteristicChangesValue = {};
for (const char of Object.keys(this.system.characteristics)) {
const value = parseInt(this.system.characteristics[char].value);
const max = parseInt(this.system.characteristics[char].max);
if (value != max) {
characteristicChanges[`system.characteristics.${char}.value`] = max;
const value = parseInt(this.system.characteristics[char].value);
if (value !== max) {
characteristicChangesValue[`system.characteristics.${char}.value`] = max;
}
}
if (Object.keys(characteristicChanges).length > 0) {
await this.update(characteristicChanges);

if (Object.keys(characteristicChangesValue).length > 0) {
await this.update(characteristicChangesValue);
}

// Reset all items
Expand Down
9 changes: 9 additions & 0 deletions module/item/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4972,6 +4972,15 @@ export class HeroSystem6eItem extends Item {

return this.system.active;
}

get compoundCost() {
if (this.system.XMLID !== "COMPOUNDPOWER") return 0;
let cost = 0;
for (const child of this.childItems) {
cost += parseInt(child.system.realCost);
}
return cost;
}
}

export function getItem(id) {
Expand Down
11 changes: 10 additions & 1 deletion templates/actor/actor-sheet-partial-powers-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
height="24" /></div>
{{/if}}
</td>
<td>{{this.system.realCost}}</td>
<td>{{#if (eq this.system.XMLID "COMPOUNDPOWER")}}
{{this.compoundCost}}
{{else}}
{{#if (eq this.parentItem.system.XMLID "COMPOUNDPOWER")}}
<span style="opacity: 0.5">{{this.system.realCost}}</span>
{{else}}
{{this.system.realCost}}
{{/if}}
{{/if}}
</td>
<td class="left{{#if this.parentItem.type}} item-framework-child-name{{/if}}{{#if this.parentItem.parentItem}}2{{/if}}">
{{#if (and this.childIdx this.parentItem)}}
{{this.childIdx}})
Expand Down

0 comments on commit ff8058e

Please sign in to comment.