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 evaluateCalculation from '/imports/api/creature/computation/evaluateCalculation.js';
|
||||||
|
import ConstantNode from '/imports/parser/parseTree/ConstantNode.js';
|
||||||
|
|
||||||
export default function computeEndStepProperty(prop, memo){
|
export default function computeEndStepProperty(prop, memo){
|
||||||
switch (prop.type){
|
switch (prop.type){
|
||||||
@@ -85,7 +86,11 @@ function computePropertyField(prop, memo, fieldName, fn){
|
|||||||
context,
|
context,
|
||||||
dependencies,
|
dependencies,
|
||||||
} = evaluateCalculation(prop[fieldName], memo, fn);
|
} = 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);
|
prop.dependencies.push(...dependencies);
|
||||||
if (context.errors.length){
|
if (context.errors.length){
|
||||||
prop[`${fieldName}Errors`] = context.errors;
|
prop[`${fieldName}Errors`] = context.errors;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function computeInlineCalcsForField(prop, memo, field){
|
|||||||
} = evaluateCalculation(calculation, memo, 'compile');
|
} = evaluateCalculation(calculation, memo, 'compile');
|
||||||
let computation = {
|
let computation = {
|
||||||
calculation,
|
calculation,
|
||||||
result: result.value,
|
result: result.toString(),
|
||||||
};
|
};
|
||||||
if (context.errors.length){
|
if (context.errors.length){
|
||||||
computation.errors = context.errors;
|
computation.errors = context.errors;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const DamageSchema = new SimpleSchema({
|
|||||||
|
|
||||||
const ComputedOnlyDamageSchema = new SimpleSchema({
|
const ComputedOnlyDamageSchema = new SimpleSchema({
|
||||||
amountResult: {
|
amountResult: {
|
||||||
type: SimpleSchema.Integer,
|
type: SimpleSchema.oneOf(String, SimpleSchema.Integer),
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
amountErrors: {
|
amountErrors: {
|
||||||
|
|||||||
Reference in New Issue
Block a user