diff --git a/app/imports/api/engine/action/EngineActions.ts b/app/imports/api/engine/action/EngineActions.ts index 656eb7bc..68749b55 100644 --- a/app/imports/api/engine/action/EngineActions.ts +++ b/app/imports/api/engine/action/EngineActions.ts @@ -8,7 +8,7 @@ export interface EngineAction { _id?: string; _isSimulation?: boolean; _stepThrough?: boolean; - _choices?: any[], + _decisions?: any[], creatureId: string; rootPropId: string; targetIds?: string[]; diff --git a/app/imports/api/engine/action/functions/getEffectiveActionScope.ts b/app/imports/api/engine/action/functions/getEffectiveActionScope.ts index 01a7df7f..1508d6a9 100644 --- a/app/imports/api/engine/action/functions/getEffectiveActionScope.ts +++ b/app/imports/api/engine/action/functions/getEffectiveActionScope.ts @@ -4,8 +4,8 @@ import { getVariables } from '/imports/api/engine/loadCreatures'; // Combine all the action results into the scope at present export async function getEffectiveActionScope(action: EngineAction) { const scope = await getVariables(action.creatureId); - delete scope._id; - delete scope._creatureId; + // delete scope._id; + // delete scope._creatureId; // Combine the applied results for (const result of action.results) { // Pop keys that are not longer used by a busy property diff --git a/app/imports/api/engine/action/functions/userInput/saveInputChoices.ts b/app/imports/api/engine/action/functions/userInput/saveInputChoices.ts index 112b6ee0..c1e25300 100644 --- a/app/imports/api/engine/action/functions/userInput/saveInputChoices.ts +++ b/app/imports/api/engine/action/functions/userInput/saveInputChoices.ts @@ -8,17 +8,17 @@ import InputProvider from '/imports/api/engine/action/functions/userInput/InputP export default function saveInputChoices(action: EngineAction, userInput: InputProvider): InputProvider { const newInputProvider: Partial = {}; - if (!action._choices) { - action._choices = []; + if (!action._decisions) { + action._decisions = []; } // For every function in the given input provider for (const key in userInput) { const oldFn = userInput[key]; - // Make a new function that does the same thing, but saves the result to action._choices + // Make a new function that does the same thing, but saves the result to action._decisions const newFn = (...args) => { const result = oldFn(...args); - action._choices.push(result); + action._decisions.push(result); return result; } newInputProvider[key] = newFn; diff --git a/app/imports/api/engine/action/methods/runAction.ts b/app/imports/api/engine/action/methods/runAction.ts index ad7f91eb..a5da8323 100644 --- a/app/imports/api/engine/action/methods/runAction.ts +++ b/app/imports/api/engine/action/methods/runAction.ts @@ -10,12 +10,12 @@ import getReplayChoicesInputProvider from '/imports/api/engine/action/functions/ export const runAction = new ValidatedMethod({ name: 'actions.runAction', validate: new SimpleSchema({ - action: { - type: Object, - blackbox: true, + actionId: { + type: String, }, decisions: { type: Array, + optional: true, }, 'decisions.$': { type: Object, diff --git a/app/imports/api/engine/action/tasks/applyDamagePropTask.ts b/app/imports/api/engine/action/tasks/applyDamagePropTask.ts index a7533c24..4100d1ad 100644 --- a/app/imports/api/engine/action/tasks/applyDamagePropTask.ts +++ b/app/imports/api/engine/action/tasks/applyDamagePropTask.ts @@ -22,6 +22,10 @@ export default async function applyDamagePropTask( const { title, operation } = task.params; let targetProp = task.params.targetProp; + console.log({ task, action, result, userInput }); + + if (!targetProp) throw new Meteor.Error('not-found', 'Target property is required') + // Set the scope properties result.pushScope = {}; if (operation === 'increment') { diff --git a/app/imports/client/ui/creature/actions/ActionDialog.vue b/app/imports/client/ui/creature/actions/ActionDialog.vue index de812bb8..a1a37e8e 100644 --- a/app/imports/client/ui/creature/actions/ActionDialog.vue +++ b/app/imports/client/ui/creature/actions/ActionDialog.vue @@ -149,7 +149,7 @@ export default { this.resumeActionFn?.(); }, finishAction() { - this.$store.dispatch('popDialogStack'); + this.$store.dispatch('popDialogStack', this.actionResult); }, promiseInput() { return new Promise(resolve => { diff --git a/app/imports/client/ui/creature/actions/doAction.ts b/app/imports/client/ui/creature/actions/doAction.ts index 19e6fc03..6790e409 100644 --- a/app/imports/client/ui/creature/actions/doAction.ts +++ b/app/imports/client/ui/creature/actions/doAction.ts @@ -56,17 +56,17 @@ export default async function doAction( data: { actionId, }, - async callback(action, decisions) { - resolve(await callActionMethod(action, decisions)); + async callback(action: EngineAction) { + resolve(await callActionMethod(action)); }, }); }) } } -const callActionMethod = (action: EngineAction, decisions?: any[]) => { +const callActionMethod = (action: EngineAction) => { if (!action._id) throw new Meteor.Error('type-error', 'Action must have and _id'); - return runAction.call({ actionId: action._id, decisions }); + return runAction.callAsync({ actionId: action._id, decisions: action._decisions }); } const throwInputRequestedError = () => { diff --git a/app/imports/client/ui/properties/components/actions/ActionCard.vue b/app/imports/client/ui/properties/components/actions/ActionCard.vue index c3cbea9b..f2bdf8ea 100644 --- a/app/imports/client/ui/properties/components/actions/ActionCard.vue +++ b/app/imports/client/ui/properties/components/actions/ActionCard.vue @@ -19,7 +19,10 @@ - +