Fixed action dialog applying actions
This commit is contained in:
@@ -8,7 +8,7 @@ export interface EngineAction {
|
||||
_id?: string;
|
||||
_isSimulation?: boolean;
|
||||
_stepThrough?: boolean;
|
||||
_choices?: any[],
|
||||
_decisions?: any[],
|
||||
creatureId: string;
|
||||
rootPropId: string;
|
||||
targetIds?: string[];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<InputProvider> = {};
|
||||
|
||||
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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
this.resumeActionFn?.();
|
||||
},
|
||||
finishAction() {
|
||||
this.$store.dispatch('popDialogStack');
|
||||
this.$store.dispatch('popDialogStack', this.actionResult);
|
||||
},
|
||||
promiseInput() {
|
||||
return new Promise(resolve => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
<template v-if="rollBonus && !rollBonusTooLong">
|
||||
{{ rollBonus }}
|
||||
</template>
|
||||
<property-icon :model="model" />
|
||||
<property-icon
|
||||
v-else
|
||||
:model="model"
|
||||
/>
|
||||
</v-btn>
|
||||
</div>
|
||||
<div
|
||||
@@ -87,6 +90,7 @@
|
||||
start-expanded
|
||||
show-external-details
|
||||
:children="children"
|
||||
:root="model.root"
|
||||
@selected="e => $emit('sub-click', e)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user