From 50e2e534a0196b097b971603c4aa263301e131be Mon Sep 17 00:00:00 2001 From: Byroks Date: Sun, 18 Feb 2024 15:31:15 +0100 Subject: [PATCH] Add workaround for double Belastun effekt --- source/module/actors/M5Character.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/module/actors/M5Character.ts b/source/module/actors/M5Character.ts index 4c224ce..a6335e3 100644 --- a/source/module/actors/M5Character.ts +++ b/source/module/actors/M5Character.ts @@ -288,12 +288,12 @@ export class M5Character extends Actor { label += "*"; } if (item.system.valuable) { - ret.stats.wealth += parseFloat((this.calculateValue(item.system.value * item.system.quantity, item.system.currency)).toPrecision(3)); + ret.stats.wealth += parseFloat(this.calculateValue(item.system.value * item.system.quantity, item.system.currency).toPrecision(3)); } if (item.system.hoarded) { - ret.stats.hoard += parseFloat((this.calculateValue(item.system.value * item.system.quantity, item.system.currency)).toPrecision(3)); + ret.stats.hoard += parseFloat(this.calculateValue(item.system.value * item.system.quantity, item.system.currency).toPrecision(3)); } - + if (!!item.system.containerId) { ret.gear.containers[item.system.containerId].weight += parseFloat((item.system.weight * item.system.quantity).toPrecision(3)); if (ret.gear.containers[item.system.containerId].equipped) { @@ -461,20 +461,22 @@ export class M5Character extends Actor { }); if (!skip?.encumbrance) { - const item = context.items.find((x) => x.name === "Belastung"); + const item = context.items.filter((x) => x.name === "Belastung"); if (ret.stats.encumbrance > ret.stats.heavyLoad) { - if (!item) { + if (item.length === 0) { this.createEffect("Belastung", [{ id: "movement", operation: M5ModOperation.DIVISION, type: M5ModType.STAT, value: 2 }]); - } else { - item.update({ + } else if (item.length === 1) { + item[0].update({ data: { equipped: true, }, }); + } else if (item.length === 2) { + item[1]?.delete(); } } else if (ret.stats.encumbrance <= ret.stats.heavyLoad) { if (!!item) { - item.update({ + item[0].update({ data: { equipped: false, },