Fixed negative base values being ignored
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
export default class EffectAggregator{
|
||||
constructor(){
|
||||
this.base = 0;
|
||||
this.base = undefined;
|
||||
this.add = 0;
|
||||
this.mul = 1;
|
||||
this.min = Number.NEGATIVE_INFINITY;
|
||||
@@ -20,7 +20,11 @@ export default class EffectAggregator{
|
||||
switch(effect.operation){
|
||||
case 'base':
|
||||
// Take the largest base value
|
||||
this.base = result > this.base ? result : this.base;
|
||||
if(Number.isFinite(this.base)){
|
||||
this.base = Math.max(this.base, result);
|
||||
} else {
|
||||
this.base = result;
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
// Add all adds together
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user