Skip to content

Commit

Permalink
Merge pull request dmdorman#1419 from phBalance/phBalance/charge-desc…
Browse files Browse the repository at this point in the history
…ription-improvements

Ph balance/charge description improvements
  • Loading branch information
phBalance authored Nov 9, 2024
2 parents e948442 + 8888dcd commit 84c82d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
29 changes: 23 additions & 6 deletions module/item/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3751,7 +3751,7 @@ export class HeroSystem6eItem extends Item {
}

// Disadvantages sorted low to high
for (let modifier of modifiers) {
for (const modifier of modifiers) {
system.description += this.createPowerDescriptionModifier(modifier);
}

Expand Down Expand Up @@ -3822,8 +3822,9 @@ export class HeroSystem6eItem extends Item {
{
// 1 Recoverable Continuing Charge lasting 1 Minute
result += ", ";

const maxCharges = parseInt(modifier.OPTION_ALIAS);
if (maxCharges != parseInt(this.system.charges.max)) {
if (maxCharges !== parseInt(system.charges.max)) {
console.error("CHARGES mismatch", item);
}
const currentCharges = parseInt(this.system.charges.value);
Expand All @@ -3832,18 +3833,34 @@ export class HeroSystem6eItem extends Item {
}
result += modifier.OPTION_ALIAS;

let recoverable = (modifier.ADDER || []).find((o) => o.XMLID == "RECOVERABLE");
const recoverable = (modifier.ADDER || []).find((o) => o.XMLID === "RECOVERABLE");
if (recoverable) {
result += " " + recoverable.ALIAS;
result += ` ${recoverable.ALIAS}`;
}

const boostable = (modifier.ADDER || []).find((o) => o.XMLID === "BOOSTABLE");
if (boostable) {
result += ` ${boostable.ALIAS}`;
}

let continuing = (modifier.ADDER || []).find((o) => o.XMLID == "CONTINUING");
const continuing = (modifier.ADDER || []).find((o) => o.XMLID === "CONTINUING");
if (continuing) {
result += " " + continuing.ALIAS;
result += ` ${continuing.ALIAS}`;
}

const fuel = (modifier.ADDER || []).find((o) => o.XMLID === "FUEL");
if (fuel) {
result += ` ${fuel.ALIAS}`;
}

result += maxCharges > 1 ? " Charges" : " Charge";

const totalClips = this.system.charges.clipsMax;
if (totalClips > 1) {
const currentClips = this.system.charges.clips;
result += ` (${currentClips}/${totalClips} clips)`;
}

if (continuing) {
result += " lasting " + continuing.OPTION_ALIAS;
}
Expand Down
19 changes: 5 additions & 14 deletions module/ruler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class HeroRuler extends Ruler {
const activeMovement =
movementItems.length === 0
? "none"
: movementItems.find((o) => o._id == relevantToken.actor.flags.activeMovement)?._id ||
: movementItems.find((o) => o._id === relevantToken.actor.flags.activeMovement)?._id ||
movementItems[0]._id;

const radioOptions = movementItems
Expand Down Expand Up @@ -201,7 +201,7 @@ export class HeroRuler extends Ruler {

if (
automation === "all" ||
(automation === "npcOnly" && actor.type == "npc") ||
(automation === "npcOnly" && actor.type === "npc") ||
(automation === "pcEndOnly" && actor.type === "pc")
) {
// Only consume endurance on token's phase, allowing for Knockback movement (which does not consume END)
Expand Down Expand Up @@ -318,10 +318,10 @@ export class HeroRuler extends Ruler {
return;
}

// Kluge to update actor right away so the render has proper data.
// Kludge to update actor right away so the render has proper data.
// There is likely a better way to deal with this, possibly in the refreshToken hook.
if (args?.flags?.activeMovement) {
actor.flags.activeMovement = args?.flags?.activeMovement;
actor.flags.activeMovement = args.flags.activeMovement;
}

that._movementRadioSelectRender();
Expand All @@ -346,15 +346,6 @@ export class HeroRuler extends Ruler {
* @returns {string}
* @protected
*/

/** V11
* Get the text label for a segment of the measured path
* @param {RulerMeasurementSegment} segment
* @param {number} totalDistance
* @returns {string}
* @protected
*/

_getSegmentLabel(_segment, _totalDistance) {
// second argument only provided in v11
// however total distance is avail in v12
Expand All @@ -376,7 +367,7 @@ export class HeroRuler extends Ruler {
const activeMovement =
movementItems.length === 0
? "none"
: movementItems.find((o) => o._id == actor.flags.activeMovement)?._id || movementItems[0]._id;
: movementItems.find((o) => o._id === actor.flags.activeMovement)?._id || movementItems[0]._id;
const activeMovementLabel =
activeMovement === "none" ? "Running" : movementItems.find((e) => e._id === activeMovement)?.name;

Expand Down

0 comments on commit 84c82d1

Please sign in to comment.