Characters now recompute on subscribe if they haven't been computed in the current version
This commit is contained in:
@@ -96,6 +96,11 @@ let CreatureSchema = new SimpleSchema({
|
||||
type: Number,
|
||||
defaultValue: 0,
|
||||
},
|
||||
// Version of computation engine that was last used to compute this creature
|
||||
computeVersion: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
defaultValue: 'pc',
|
||||
|
||||
@@ -34,6 +34,7 @@ function computeAction(prop, memo){
|
||||
if (prop.usesUsed >= prop.usesResult){
|
||||
prop.insufficientResources = true;
|
||||
}
|
||||
if (!prop.resources) return;
|
||||
// Attributes consumed
|
||||
prop.resources.attributesConsumed.forEach((attConsumed, i) => {
|
||||
if (attConsumed.variableName){
|
||||
|
||||
@@ -102,12 +102,12 @@ export function recomputeCreatureByDoc(creature){
|
||||
'ancestors.id': creatureId,
|
||||
inactive: {$ne: true},
|
||||
type: {$in: calculationPropertyTypes},
|
||||
// TODO filter out expensive fields, particularly icon field
|
||||
}).fetch();
|
||||
/*getActiveProperties({
|
||||
ancestorId: creatureId,
|
||||
filter: {type: {$in: calculationPropertyTypes}},
|
||||
includeUntoggled: true,
|
||||
// TODO filter out expensive fields, particularly icon field
|
||||
});*/
|
||||
let computationMemo = new ComputationMemo(props, creature);
|
||||
computeMemo(computationMemo);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { pick, forOwn } from 'lodash';
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import VERSION from '/imports/constants/VERSION.js';
|
||||
|
||||
export default function writeCreatureVariables(memo, creatureId) {
|
||||
const fields = [
|
||||
@@ -31,5 +32,8 @@ export default function writeCreatureVariables(memo, creatureId) {
|
||||
let condensedStat = pick(stat, fields);
|
||||
memo.creatureVariables[variableName] = condensedStat;
|
||||
});
|
||||
Creatures.update(creatureId, {$set: {variables: memo.creatureVariables}});
|
||||
Creatures.update(creatureId, {$set: {
|
||||
variables: memo.creatureVariables,
|
||||
computeVersion: VERSION,
|
||||
}});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user