Improved dependencies-only recalculations and fixed many calculation bugs

This commit is contained in:
Stefan Zermatten
2021-02-04 16:16:51 +02:00
parent 6d1e3f078c
commit 280f30dab5
16 changed files with 175 additions and 67 deletions

View File

@@ -4,6 +4,7 @@ import SymbolNode from '/imports/parser/parseTree/SymbolNode.js';
import AccessorNode from '/imports/parser/parseTree/AccessorNode.js';
import ConstantNode from '/imports/parser/parseTree/ConstantNode.js';
import findAncestorByType from '/imports/api/creature/computation/engine/findAncestorByType.js';
import { union } from 'lodash';
/* Convert a calculation into a constant output and errors*/
export default function evaluateCalculation({
@@ -55,7 +56,12 @@ export default function evaluateCalculation({
if (stat && stat.computationDetails && !stat.computationDetails.computed){
computeStat(stat, memo);
}
if (stat) dependencies.push(stat._id || node.name, ...stat.dependencies);
if (stat){
dependencies = union(dependencies, [
stat._id || node.name,
...stat.dependencies
]);
}
}
});
// Evaluate