Fix load/Capacity

This commit is contained in:
2026-06-07 21:32:05 +02:00
parent 2fb6bfe444
commit 7623123bb5
54 changed files with 233 additions and 205 deletions
+9 -1
View File
@@ -25,6 +25,7 @@ export default class MGNECharacter extends foundry.abstract.TypeDataModel {
}),
conditions: conditionSchema(),
carryCapacity: numberField(8, 0),
carryCapacityModifier: numberField(0, 0),
rations: numberField(0, 0),
kiffol: numberField(0, 0),
background: stringField(""),
@@ -40,18 +41,25 @@ export default class MGNECharacter extends foundry.abstract.TypeDataModel {
prepareDerivedData() {
super.prepareDerivedData()
this.carryCapacity = (this.abilities.strength?.value ?? 0) + 8
this.resonance.remaining = Math.max(0, (this.resonance.max ?? 0) - (this.resonance.used ?? 0))
this.syncLimit = Math.max(0, this.abilities.toughness?.value ?? 0)
this.syncRemaining = Math.max(0, this.syncLimit - (this.artifactSync.used ?? 0))
this.armorFormula = this.parent?.getArmorRollFormula?.() ?? "0"
// Compute carry capacity: base STR + 8 + feature capacities + direct modifier
const featureCapacity = (this.parent?.items ?? [])
.filter(i => i.type === "feature")
.reduce((sum, f) => sum + (f.system?.capacity ?? 0), 0)
this.carryCapacity = (this.abilities.strength?.value ?? 0) + 8 + featureCapacity + (this.carryCapacityModifier ?? 0)
// Compute current load per RAW:
// Only items with a weight field count — features and creature-traits are excluded
// trivial = 0, light = 10 per slot, normal = 1, heavy = fills remaining capacity (max 1)
let normalLoad = 0
let lightCount = 0
let heavyCount = 0
for (const item of (this.parent?.items ?? [])) {
if (!("weight" in (item.system ?? {}))) continue // no weight field (features, traits)
if (item.system?.carried === false) continue // not being carried
const w = item.system?.weight ?? "normal"
if (w === "trivial") continue