Fixed some fields not storing strings when compiling calculations

This commit is contained in:
Stefan Zermatten
2021-02-02 15:07:31 +02:00
parent 8b8f9bea6f
commit a6df4df534
3 changed files with 8 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import evaluateCalculation from '/imports/api/creature/computation/evaluateCalculation.js';
import ConstantNode from '/imports/parser/parseTree/ConstantNode.js';
export default function computeEndStepProperty(prop, memo){
switch (prop.type){
@@ -85,7 +86,11 @@ function computePropertyField(prop, memo, fieldName, fn){
context,
dependencies,
} = evaluateCalculation(prop[fieldName], memo, fn);
prop[`${fieldName}Result`] = result.value;
if (result instanceof ConstantNode){
prop[`${fieldName}Result`] = result.value;
} else {
prop[`${fieldName}Result`] = result.toString();
}
prop.dependencies.push(...dependencies);
if (context.errors.length){
prop[`${fieldName}Errors`] = context.errors;

View File

@@ -22,7 +22,7 @@ function computeInlineCalcsForField(prop, memo, field){
} = evaluateCalculation(calculation, memo, 'compile');
let computation = {
calculation,
result: result.value,
result: result.toString(),
};
if (context.errors.length){
computation.errors = context.errors;

View File

@@ -29,7 +29,7 @@ const DamageSchema = new SimpleSchema({
const ComputedOnlyDamageSchema = new SimpleSchema({
amountResult: {
type: SimpleSchema.Integer,
type: SimpleSchema.oneOf(String, SimpleSchema.Integer),
optional: true,
},
amountErrors: {