Fixed failing tests and action engine props
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import { EngineAction } from '/imports/api/engine/action/EngineActions';
|
||||
import InputProvider from '/imports/api/engine/action/functions/InputProvider';
|
||||
import { applyDefaultAfterPropTasks } from '/imports/api/engine/action/functions/applyTaskGroups';
|
||||
import { rollAndReduceCalculation } from '/imports/api/engine/action/functions/recalculateCalculation';
|
||||
import { PropTask } from '/imports/api/engine/action/tasks/Task';
|
||||
import TaskResult from '/imports/api/engine/action/tasks/TaskResult';
|
||||
import { isFiniteNode } from '/imports/parser/parseTree/constant';
|
||||
import toString from '/imports/parser/toString';
|
||||
|
||||
export default async function roll(
|
||||
task: PropTask, action: EngineAction, result: TaskResult, userInput
|
||||
export default async function applyRollProperty(
|
||||
task: PropTask, action: EngineAction, result: TaskResult, inputProvider: InputProvider
|
||||
): Promise<void> {
|
||||
const prop = task.prop;
|
||||
// If there isn't a calculation, just apply the children instead
|
||||
if (!prop.roll?.calculation) {
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, userInput);
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, inputProvider);
|
||||
}
|
||||
|
||||
const logValue: string[] = [];
|
||||
@@ -19,7 +21,7 @@ export default async function roll(
|
||||
// roll the dice only and store that string
|
||||
const {
|
||||
rolled, reduced, errors
|
||||
} = await rollAndReduceCalculation(prop.roll, action);
|
||||
} = await rollAndReduceCalculation(prop.roll, action, inputProvider);
|
||||
|
||||
if (rolled.parseType !== 'constant') {
|
||||
logValue.push(toString(rolled));
|
||||
@@ -38,8 +40,8 @@ export default async function roll(
|
||||
}
|
||||
|
||||
// If we didn't end up with a constant or a number of finite value, give up
|
||||
if (reduced?.parseType !== 'constant' || (reduced.valueType === 'number' && !isFinite(reduced.value))) {
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, userInput);
|
||||
if (reduced?.parseType !== 'constant' || !isFiniteNode(reduced)) {
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, inputProvider);
|
||||
}
|
||||
const value = reduced.value;
|
||||
|
||||
@@ -54,5 +56,5 @@ export default async function roll(
|
||||
}, task.targetIds);
|
||||
|
||||
// Apply children
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, userInput);
|
||||
return applyDefaultAfterPropTasks(action, prop, task.targetIds, inputProvider);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user