Vastly improved new character UX

Characters now can limit which libraries they allow
This commit is contained in:
Stefan Zermatten
2022-07-18 13:45:14 +02:00
parent bf9639ae59
commit f8e9131bdd
21 changed files with 686 additions and 503 deletions

View File

@@ -5,8 +5,13 @@ import { EJSON } from 'meteor/ejson';
export default function writeScope(creatureId, computation) {
if (!creatureId) throw 'creatureId is required';
const scope = computation.scope;
const variables = computation.variables || {};
let variables = computation.variables;
if (!variables) {
CreatureVariables.insert({ _creatureId: creatureId });
variables = {};
}
delete variables._id;
delete variables._creatureId;
let $set, $unset;
@@ -48,9 +53,9 @@ export default function writeScope(creatureId, computation) {
const update = {};
if ($set) update.$set = $set;
if ($unset) update.$unset = $unset;
CreatureVariables.upsert({_creatureId: creatureId}, update);
CreatureVariables.update({_creatureId: creatureId}, update);
}
if (computation.creature?.dirty) {
Creatures.update({_creatureId: creatureId}, {$unset: { dirty: 1 }});
Creatures.update({_id: creatureId}, {$unset: { dirty: 1 }});
}
}