From d03fac858c4868ba437b0fac7d2514d02b3df498 Mon Sep 17 00:00:00 2001 From: marvin9257 <72580196+marvin9257@users.noreply.github.com> Date: Tue, 26 Nov 2024 08:28:16 -0600 Subject: [PATCH] fix: max encumbrance for CT (#1695) 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. --- src/module/entities/TwodsixActor.ts | 16 +++++++++++++++- static/styles/twodsix.css | 8 ++++---- static/styles/twodsix_basic.css | 5 +++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/module/entities/TwodsixActor.ts b/src/module/entities/TwodsixActor.ts index 9846f44bb..b4f1395eb 100644 --- a/src/module/entities/TwodsixActor.ts +++ b/src/module/entities/TwodsixActor.ts @@ -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. @@ -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); } diff --git a/static/styles/twodsix.css b/static/styles/twodsix.css index 29420c4be..02862663b 100644 --- a/static/styles/twodsix.css +++ b/static/styles/twodsix.css @@ -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; diff --git a/static/styles/twodsix_basic.css b/static/styles/twodsix_basic.css index 7aace0bf3..aef076ba8 100644 --- a/static/styles/twodsix_basic.css +++ b/static/styles/twodsix_basic.css @@ -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; }