Fixed some fields not storing strings when compiling calculations
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user