Fix load/Capacity
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import { htmlField } from "./shared.mjs"
|
||||
import { htmlField, numberField } from "./shared.mjs"
|
||||
|
||||
export default class MGNEFeature extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
@@ -10,6 +10,7 @@ export default class MGNEFeature extends foundry.abstract.TypeDataModel {
|
||||
blank: true,
|
||||
initial: "",
|
||||
}),
|
||||
capacity: numberField(0, 0),
|
||||
description: htmlField(""),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user