From 692a92128c4fbe982abadc9c5acf6111eccb93e3 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 13 Mar 2026 10:29:43 +0100 Subject: [PATCH] fix: compute burden percent from capacity --- static/script.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/script.js b/static/script.js index 2cc79d07..8fcf5437 100644 --- a/static/script.js +++ b/static/script.js @@ -1376,10 +1376,15 @@ function renderInventoryState(state) { }); const stats = characterStats[state.characterName] || {}; - const burden = Number(stats.burden || 0); const burdenUnits = Number(stats.burden_units || 0); - const burdenPct = burdenUnits > 0 ? Math.max(0, Math.min(100, (burden / burdenUnits) * 100)) : 0; - state.burdenLabel.textContent = burdenUnits > 0 ? `${burden}/${burdenUnits}` : `${burden}`; + const encumbranceCapacity = Number(stats.encumbrance_capacity || 0); + const burdenPct = encumbranceCapacity > 0 + ? Math.max(0, Math.min(100, (burdenUnits / encumbranceCapacity) * 100)) + : 0; + state.burdenLabel.textContent = `${Math.round(burdenPct)}%`; + state.burdenLabel.title = burdenUnits > 0 && encumbranceCapacity > 0 + ? `${burdenUnits}/${encumbranceCapacity}` + : ''; state.burdenFill.style.height = `${burdenPct}%`; // 4. Sort containers for stable sidebar order (by unsigned item_id)