Creature computations working again

This commit is contained in:
Stefan Zermatten
2020-03-23 11:59:04 +02:00
parent 74fef2bd39
commit 2981813751
20 changed files with 107 additions and 154 deletions

View File

@@ -1,4 +1,5 @@
import computedValueOfVariableName from '/imports/api/creature/computation/computedValueOfVariableName.js'
import * as math from 'mathjs';
export default function evaluateCalculation(string, memo){
if (!string) return string;
@@ -7,6 +8,7 @@ export default function evaluateCalculation(string, memo){
try {
calc = math.parse(string);
} catch (e) {
console.error(e);
return string;
}
// Replace all symbols with known values
@@ -20,7 +22,6 @@ export default function evaluateCalculation(string, memo){
return node;
}
});
// Evaluate the expression to a number or return with substitutions
try {
return substitutedCalc.eval();