fix: compute burden percent from capacity

This commit is contained in:
Erik 2026-03-13 10:29:43 +01:00
parent 26624a302b
commit 692a92128c

View file

@ -1376,10 +1376,15 @@ function renderInventoryState(state) {
}); });
const stats = characterStats[state.characterName] || {}; const stats = characterStats[state.characterName] || {};
const burden = Number(stats.burden || 0);
const burdenUnits = Number(stats.burden_units || 0); const burdenUnits = Number(stats.burden_units || 0);
const burdenPct = burdenUnits > 0 ? Math.max(0, Math.min(100, (burden / burdenUnits) * 100)) : 0; const encumbranceCapacity = Number(stats.encumbrance_capacity || 0);
state.burdenLabel.textContent = burdenUnits > 0 ? `${burden}/${burdenUnits}` : `${burden}`; 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}%`; state.burdenFill.style.height = `${burdenPct}%`;
// 4. Sort containers for stable sidebar order (by unsigned item_id) // 4. Sort containers for stable sidebar order (by unsigned item_id)