Fixed action dialog applying actions
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user