Fixed negative base values being ignored

This commit is contained in:
Stefan Zermatten
2021-07-12 14:12:20 +02:00
parent 2ecb0e2671
commit 0d21ab758e
2 changed files with 17 additions and 4 deletions

View File

@@ -14,7 +14,14 @@ export default function combineStat(stat, aggregator, memo){
}
function getAggregatorResult(stat, aggregator){
let base = Math.max(aggregator.base, stat.baseValue || 0);
let base;
if (!Number.isFinite(aggregator.base)){
base = stat.baseValue || 0;
} else if (!Number.isFinite(stat.baseValue)){
base = aggregator.base || 0;
} else {
base = Math.max(aggregator.base, stat.baseValue);
}
let result = (base + aggregator.add) * aggregator.mul;
if (result < aggregator.min) {
result = aggregator.min;
@@ -28,6 +35,7 @@ function getAggregatorResult(stat, aggregator){
if (!stat.decimal && Number.isFinite(result)){
result = Math.floor(result);
}
console.log({result, agg: aggregator.base, statBase: stat.baseValue, base, name: stat.name, stat});
return result;
}
@@ -137,7 +145,8 @@ function combineSkill(stat, aggregator, memo){
}
// Combine everything to get the final result
let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
let base = aggregator.base || 0;
let result = (base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
if (result < aggregator.min) result = aggregator.min;
if (result > aggregator.max) result = aggregator.max;
if (aggregator.set !== undefined) {