Skip to content

Commit

Permalink
Merge pull request dmdorman#560 from phBalance/phBalance/multi-adjust…
Browse files Browse the repository at this point in the history
…ment-improvements

Multi source/target adjustment improvements
  • Loading branch information
phBalance authored Jan 1, 2024
2 parents 37947b6 + 821b5be commit a58aa59
Show file tree
Hide file tree
Showing 20 changed files with 1,527 additions and 948 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Ignore all yaml files
**/*.yml

# Ignore all SCSS files
**/*.scss
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

- The character sheet's power tab now has the dice icon for attack powers to initiate attacks.
- Fix for movement powers toggles. [#533](https://github.com/dmdorman/hero6e-foundryvtt/issues/533)
- Adjustment powers should now respect uploaded multi sources and targets when triggering.
- Adjustment powers should now respect uploaded multi sources and targets when triggering. They should also respect maximum amounts for absorption, aid, and transfer for 5e and 6e.
- No adjustment powers should be killing attacks that are enhanced by strength.
- Compound powers now show proper indices.
- Correct resistant power defense (yes it's a silly thing but we were accidentally boosting it and consequently mostly likely doubling power defenses).
- Calculated power defense will now be shown on the character sheet.
- Defensive powers qualifying for the adjustment multiplier now match 5e more strict list.

## Version 3.0.53

Expand Down
6 changes: 4 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"fullHealthConfirm": {
"Title": "Confirm Full Health",
"Content": "Are you sure you want to restore all characteristics to max, remove status effects, and remote temporary effects?"
"Content": "Are you sure you want to restore all characteristics to max, remove status effects, and remove temporary effects?"
}
}
},
Expand All @@ -24,7 +24,7 @@
"ToHitModifier": "To Hit Modifier",
"UsesStrength": "Uses Strength",
"UsesTk": "Uses Telekinesis Strength",
"Value": "Damage dice",
"Value": "Damage Dice",
"StunBodyDamage": "Stun and/or Body Damage",
"OcvMod": "OCV Modifier",
"DcvMod": "DCV Modifier",
Expand Down Expand Up @@ -55,11 +55,13 @@
"OCV": "OCV",
"DCV": "DCV",
"Char": "Char",
"CharTitle": "Characteristic Name's Abbreviation.",
"Base": "Base",
"BaseTitle": "Starting amount you get for free.",
"Cost": "Cost",
"CostTitle": "Cost paid that are over the base amount.",
"Notes": "Notes",
"NotesTitle": "Additional crucial information relating to the characteristic.",
"Max": "Max",
"MaxTitle": "Maximum value including all powers and effects.",
"Core": "Core",
Expand Down
2 changes: 1 addition & 1 deletion module/actor/actor-active-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class HeroSystem6eActorActiveEffects extends ActiveEffect {
name: "EFFECT.StatusSilenced",
icon: "icons/svg/silenced.svg",
};
static freightenedEffect = {
static frightenedEffect = {
id: "fear",
name: "EFFECT.StatusFear",
icon: "icons/svg/terror.svg",
Expand Down
19 changes: 12 additions & 7 deletions module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValue /*knockbackResistance*/,
,
defenseTagsP,
] = determineDefense.call(this, this.actor, pdAttack);
] = determineDefense(this.actor, pdAttack);
defense.PD = defenseValue;
defense.rPD = resistantValue;
defense.PDtags = "PHYSICAL DEFENSE\n";
Expand Down Expand Up @@ -601,7 +601,7 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValueE /* knockbackResistanceE */,
,
defenseTagsE,
] = determineDefense.call(this, this.actor, edAttack);
] = determineDefense(this.actor, edAttack);
defense.ED = defenseValueE;
defense.rED = resistantValueE;
defense.EDtags = "ENERGY DEFENSE\n";
Expand Down Expand Up @@ -648,7 +648,7 @@ export class HeroSystemActorSheet extends ActorSheet {
damageNegationValueM /*knockbackResistanceM*/,
,
defenseTagsM,
] = determineDefense.call(this, this.actor, mdAttack);
] = determineDefense(this.actor, mdAttack);
defense.MD = defenseValueM;
defense.rMD = resistantValueM;
defense.MDtags = "MENTAL DEFENSE\n";
Expand Down Expand Up @@ -677,8 +677,8 @@ export class HeroSystemActorSheet extends ActorSheet {

// Defense POWD
const drainContentsAttack = `
<POWER XMLID="FORCEFIELD" ID="1686527339658" BASECOST="0.0" LEVELS="10" ALIAS="Resistant Protection" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" NAME="" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes" PDLEVELS="1" EDLEVELS="2" MDLEVELS="3" POWDLEVELS="4">
<NOTES />
<POWER XMLID="DRAIN" ID="1703727634494" BASECOST="0.0" LEVELS="1" ALIAS="Drain" POSITION="14" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" NAME="" INPUT="BODY" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
<NOTES />
</POWER>
`;
const drainAttack = await new HeroSystem6eItem(
Expand All @@ -695,7 +695,7 @@ export class HeroSystemActorSheet extends ActorSheet {
,
,
defenseTagsPOWD,
] = determineDefense.call(this, this.actor, drainAttack);
] = determineDefense(this.actor, drainAttack);
defense.POWD = defenseValuePOWD;
defense.rPOWD = resistantValuePOWD;
defense.POWDtags = "POWER DEFENSE\n";
Expand Down Expand Up @@ -1120,10 +1120,15 @@ export class HeroSystemActorSheet extends ActorSheet {
async _onUnlockCharacteristic(event) {
event.preventDefault();

// The event will not be generated from the disabled input (since disabled elements
// don't generally allow mouse events) but rather from the enclosing td element.
// Find its child input element
const input = event.target.querySelector("input");

// Find all associated Active Effects
let activeEffects = Array.from(
this.actor.allApplicableEffects(),
).filter((o) => o.changes.find((p) => p.key === event.target.name));
).filter((o) => o.changes.find((p) => p.key === input.name));
for (let ae of activeEffects) {
// Delete status
if (ae.statuses) {
Expand Down
67 changes: 40 additions & 27 deletions module/actor/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class HeroSystem6eActor extends Actor {
// TODO: Allow for a non-statusEffects ActiveEffect (like from a power)
async addActiveEffect(activeEffect) {
const newEffect = foundry.utils.deepClone(activeEffect);
newEffect.label = `${game.i18n.localize(newEffect.label)}`;

// Check for standard StatusEffects
// statuses appears to be necessary to associate with StatusEffects
Expand Down Expand Up @@ -773,41 +772,37 @@ export class HeroSystem6eActor extends Actor {
async FullHealth() {
// Remove all status effects
for (let status of this.statuses) {
let ae = Array.from(this.effects).find((o) =>
o.statuses.has(status),
let ae = Array.from(this.effects).find((effect) =>
effect.statuses.has(status),
);
await ae.delete();
}

// Remove temporary effects
let tempEffects = Array.from(this.effects).filter(
const tempEffects = Array.from(this.effects).filter(
(o) => parseInt(o.duration?.seconds || 0) > 0,
);
for (let ae of tempEffects) {
for (const ae of tempEffects) {
await ae.delete();
}

// Set Characterstics VALUE to MAX
for (let char of Object.keys(this.system.characteristics)) {
let value = parseInt(this.system.characteristics[char].value);
let max = parseInt(this.system.characteristics[char].max);
// Set Characteristics VALUE to MAX
const characteristicChanges = {};
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) {
//this.actor.system.characteristics[char].value = max;
await this.update({
[`system.characteristics.${char}.value`]: max,
});
characteristicChanges[`system.characteristics.${char}.value`] =
max;
}
}
if (Object.keys(characteristicChanges).length > 0) {
await this.update(characteristicChanges);
}

// Set Charges to max
for (let item of this.items.filter(
(o) =>
o.system.charges?.max &&
o.system.charges.value != o.system.charges.max,
)) {
await item.update({
[`system.charges.value`]: item.system.charges.max,
});
// Reset all items
for (const item of this.items) {
await item.resetToOriginal();
}

// We just cleared encumbrance, check if it applies again
Expand Down Expand Up @@ -918,7 +913,7 @@ export class HeroSystem6eActor extends Actor {
0,
);

// FIXME: This is, but should never be, called with this.system[characteristic] being undefined. Need to reorder the loading
// TODO: FIXME: This is, but should never be, called with this.system[characteristic] being undefined. Need to reorder the loading
// mechanism to ensure that we do something more similar to a load, transform, and extract pipeline so that we
// not invoked way too many times and way too early.
const charBase = (characteristicUpperCase) => {
Expand Down Expand Up @@ -1131,7 +1126,7 @@ export class HeroSystem6eActor extends Actor {
content += `<li>${retainDamage.end} END used</li>`;
content += `</ul><p>Do you want to apply this damage after the upload?</p>`;
const confirmed = await Dialog.confirm({
title: "Retain damage after upload?", //game.i18n.localize("HERO6EFOUNDRYVTTV2.confirms.deleteConfirm.Title"),
title: "Retain damage after upload?",
content: content,
});
if (confirmed === null) {
Expand Down Expand Up @@ -1215,20 +1210,17 @@ export class HeroSystem6eActor extends Actor {
!this.system.CHARACTER.TEMPLATE.includes("6E.") &&
!this.system.is5e
) {
//changes[`system.is5e`] = true
this.system.is5e = true;
}
if (
this.system.CHARACTER.TEMPLATE.includes("builtIn.") &&
this.system.CHARACTER.TEMPLATE.includes("6E.") &&
this.system.is5e
) {
//changes[`system.is5e`] = false
this.system.is5e = false;
}
}
if (this.system.COM && !this.system.is5e) {
//changes[`system.is5e`] = true
this.system.is5e = true;
}

Expand All @@ -1249,18 +1241,28 @@ export class HeroSystem6eActor extends Actor {
type: itemTag.toLowerCase().replace(/s$/, ""),
system: system,
};

// Hack in some basic information with names.
// TODO: This should be turned into some kind of short version of the description
// and it should probably be done when building the description
switch (system.XMLID) {
case "FOLLOWER":
itemData.name = "Followers";
break;
case "ABSORPTION":
case "AID":
case "DISPEL":
case "DRAIN":
case "HEALING":
case "TRANSFER":
case "SUPPRESS":
if (!system.NAME) {
itemData.name =
system?.ALIAS + " " + system?.INPUT;
}
break;
}

if (this.id) {
const item = await HeroSystem6eItem.create(itemData, {
parent: this,
Expand Down Expand Up @@ -1324,6 +1326,17 @@ export class HeroSystem6eActor extends Actor {
}`,
{ console: true, permanent: true },
);
} else {
const maxAllowedEffects =
item.numberOfSimultaneousAdjustmentEffects();
if (
result.reducesArray.length > maxAllowedEffects.maxReduces ||
result.enhancesArray.length > maxAllowedEffects.maxEnhances
) {
await ui.notifications.warn(
`${this.name} has too many adjustment targets defined for ${item.name}.`,
);
}
}
}

Expand Down
Loading

0 comments on commit a58aa59

Please sign in to comment.