Implementing persisting action result mutations

This commit is contained in:
Thaum Rystra
2024-04-02 17:46:31 +02:00
parent 2cbfc5d099
commit 1fb1eb83c7
15 changed files with 285 additions and 144 deletions

View File

@@ -9,13 +9,13 @@ export const insertAction = new ValidatedMethod({
validate: new SimpleSchema({
action: ActionSchema
}).validator({ clean: true }),
run: async function ({ action }: { action: EngineAction }) {
run: function ({ action }: { action: EngineAction }) {
assertEditPermission(getCreature(action.creatureId), this.userId);
// First remove all other actions on this creature
// only do one action at a time, don't wait for this to finish
EngineActions.removeAsync({ creatureId: action.creatureId });
EngineActions.remove({ creatureId: action.creatureId });
// Force a random id even if one was provided, we may use it later as the seed for PRNG
delete action._id;
return EngineActions.insertAsync(action);
return EngineActions.insert(action);
},
});