Skip to content

Commit

Permalink
fix: max encumbrance for CT (#1695)
Browse files Browse the repository at this point in the history
This update fixes the display of maximum encumbrance for the Classic Traveller ruleset.  Previously, max encumbrance would change when the actor became encumbered. Thanks to DavetheGrave for finding.
  • Loading branch information
marvin9257 authored Nov 26, 2024
1 parent 63cf8f5 commit d03fac8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
16 changes: 15 additions & 1 deletion src/module/entities/TwodsixActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { applyToAllActors } from "../utils/migration-utils";
import { TwodsixShipActions } from "../utils/TwodsixShipActions";
import { updateFinances } from "../hooks/updateFinances";
import { applyEncumberedEffect, applyWoundedEffect } from "../utils/showStatusIcons";
import { TwodsixActiveEffect } from "./TwodsixActiveEffect";

/**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
Expand Down Expand Up @@ -459,7 +460,20 @@ export default class TwodsixActor extends Actor {
let maxEncumbrance = 0;
const encumbFormula = game.settings.get('twodsix', 'maxEncumbrance');
if (Roll.validate(encumbFormula)) {
maxEncumbrance = Roll.safeEval(Roll.replaceFormulaData(encumbFormula, this.getRollData(), {missing: "0", warn: false}));
let rollData:object;
if (game.settings.get('twodsix', 'ruleset') === 'CT') {
rollData = foundry.utils.duplicate(this.getRollData()); //Not celar why deepClone doesn't work here
const encumberedEffect:TwodsixActiveEffect = this.effects.find(eff => eff.statuses.has('encumbered'));
if (encumberedEffect) {
for (const change of encumberedEffect.changes) {
const rollKey = change.key.replace('system.', '');
foundry.utils.mergeObject(rollData, {[rollKey]: foundry.utils.getProperty(this, change.key) - parseInt(change.value)});
}
}
} else {
rollData = this.getRollData();
}
maxEncumbrance = Roll.safeEval(Roll.replaceFormulaData(encumbFormula, rollData, {missing: "0", warn: false}));
}
return Math.max(maxEncumbrance, 0);
}
Expand Down
8 changes: 4 additions & 4 deletions static/styles/twodsix.css
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,12 @@ h2 {
}

.status-icons.npc {
position: relative !important;
top: -20.5ch;
/* height: -webkit-fill-available !important; */
position: absolute !important;
top: 2ch;
left: 1ch !important;
align-content: flex-start;
/* flex-wrap: wrap; */
}

.condition-icon {
height: auto;
width: 3ch;
Expand Down
5 changes: 3 additions & 2 deletions static/styles/twodsix_basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,9 @@ img.character-info-mask {
}

.status-icons.npc {
position: relative !important;
top: -22.5ch;
position: absolute !important;
top: 2ch;
left: 1ch !important;
align-content: flex-start;
}

Expand Down

0 comments on commit d03fac8

Please sign in to comment.