From 7e6147299bae18cd0991a0814176f509d28264ea Mon Sep 17 00:00:00 2001 From: Byroks Date: Sun, 3 Dec 2023 13:07:41 +0100 Subject: [PATCH] Adjust Mod Calculation (#30) Changes: + Adjust mod calculation + remov max 0 from subtract and addition + check in skills for subtract mod --- source/module/actors/M5ModAggregate.ts | 8 ++++---- source/module/items/M5Item.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/module/actors/M5ModAggregate.ts b/source/module/actors/M5ModAggregate.ts index 0e2fbe8..a943bc5 100644 --- a/source/module/actors/M5ModAggregate.ts +++ b/source/module/actors/M5ModAggregate.ts @@ -124,27 +124,27 @@ export default class M5ModAggregate { if (mods.length !== 0) { ret.mods = ret.mods.concat(mods.map(this.pairAsSource)); const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0); - ret.value = Math.max(0, ret.value + bonus); + ret.value = ret.value + bonus; } mods = arr.filter((pair) => pair.mod.operation === M5ModOperation.SUBTRACT); if (mods.length !== 0) { ret.mods = ret.mods.concat(mods.map(this.pairAsSource)); const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0); - ret.value = Math.max(0, ret.value - bonus); + ret.value = ret.value - bonus; } mods = arr.filter((pair) => pair.mod.operation === M5ModOperation.MULTIPLY); if (mods.length !== 0) { ret.mods = ret.mods.concat(mods.map(this.pairAsSource)); - const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0); + const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a * b, 1); ret.value = Math.max(0, ret.value * bonus); } mods = arr.filter((pair) => pair.mod.operation === M5ModOperation.DIVISION); if (mods.length !== 0) { ret.mods = ret.mods.concat(mods.map(this.pairAsSource)); - const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0); + const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a * b, 1); ret.value = Math.max(0, Math.floor(ret.value / bonus)); } } diff --git a/source/module/items/M5Item.ts b/source/module/items/M5Item.ts index 0c11969..da2344e 100644 --- a/source/module/items/M5Item.ts +++ b/source/module/items/M5Item.ts @@ -52,7 +52,8 @@ export class M5Item extends Item { const res = M5ModAggregate.processPairs(pairs); res.mods.forEach((mod) => { if ([M5ModOperation.SET, M5ModOperation.FIXED].includes(mod.operation)) calc.fw = mod.value; - else calc.bonus += mod.value; + else if ([M5ModOperation.SUBTRACT].includes(mod.operation)) calc.bonus -= mod.value; + else if ([M5ModOperation.ADD].includes(mod.operation)) calc.bonus += mod.value; }); calc.ew = calc.fw + calc.bonus;