18 add more operations for modifiers (#23)

* Added Operations and Combat Conditions

+ Added Multiply, Division and Subtract operations for modifiers
+ Added Combat Conditions Effects form Ars Armorum

* Added Math.floor()

* Fixed Operations and Combat Conditions
This commit is contained in:
LeFrique
2023-12-01 19:04:58 +01:00
committed by GitHub
parent 725dd8c504
commit 6ff4f16f9d
14 changed files with 25 additions and 18 deletions
+6 -6
View File
@@ -130,22 +130,22 @@ export default class M5ModAggregate {
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);
const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0);
ret.value = Math.max(0, 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);
ret.value = Math.max(0, ret.value + bonus);
const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0);
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) => Math.floor(a / b), 0);
ret.value = Math.max(0, ret.value + bonus);
const bonus = mods.map((p) => p.mod.value).reduce((a, b) => a + b, 0);
ret.value = Math.max(0, Math.floor(ret.value / bonus));
}
}