Creatures are now cached in memory for computation

Also removed dependency group calculation because the optimisation isn't
as useful to reduce DB calls if the creature is in memory anyway
This commit is contained in:
Stefan Zermatten
2022-05-11 13:30:33 +02:00
parent 23fa6fe634
commit 78cd8ffc8d
8 changed files with 145 additions and 95 deletions

View File

@@ -82,14 +82,6 @@ const DenormalisedOnlyCreaturePropertySchema = new SimpleSchema({
index: 1,
removeBeforeCompute: true,
},
// Dependency tree, the ID of the lowest ordered doc connected to this doc
// via dependencies
depGroupId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
index: 1,
removeBeforeCompute: true,
},
});
CreaturePropertySchema.extend(DenormalisedOnlyCreaturePropertySchema);

View File

@@ -4,7 +4,7 @@ import SimpleSchema from 'simpl-schema';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
import computeCreature, { computeCreatureDependencyGroup } from '/imports/api/engine/computeCreature.js';
import computeCreature from '/imports/api/engine/computeCreature.js';
const damageProperty = new ValidatedMethod({
name: 'creatureProperties.damage',
@@ -38,12 +38,7 @@ const damageProperty = new ValidatedMethod({
);
}
let result = damagePropertyWork({ property, operation, value });
if (property.depGroupId) {
// Dependencies can't be changed through damage, only recompute deps
computeCreatureDependencyGroup([property.depGroupId], rootCreature._id);
} else {
computeCreature(rootCreature._id);
}
computeCreature(rootCreature._id);
return result;
},
});