Fixed bug in stat computation dependency tracking
This commit is contained in:
@@ -82,7 +82,9 @@ export default function computeStat(stat, memo){
|
|||||||
value: statInstance.baseProficiency,
|
value: statInstance.baseProficiency,
|
||||||
stats: [statInstance.variableName],
|
stats: [statInstance.variableName],
|
||||||
type: 'proficiency',
|
type: 'proficiency',
|
||||||
dependencies: [],
|
dependencies: statInstance.overridden ?
|
||||||
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
|
[],
|
||||||
computationDetails: {
|
computationDetails: {
|
||||||
computed: true,
|
computed: true,
|
||||||
}
|
}
|
||||||
@@ -90,7 +92,7 @@ export default function computeStat(stat, memo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute each active stat's baseValue calculation and apply it
|
// Compute each active stat's baseValue calculation and apply it
|
||||||
if (statInstance.baseValueCalculation) {
|
if (!statInstance.inactive) {
|
||||||
let {
|
let {
|
||||||
result,
|
result,
|
||||||
context,
|
context,
|
||||||
@@ -100,45 +102,38 @@ export default function computeStat(stat, memo){
|
|||||||
prop: statInstance,
|
prop: statInstance,
|
||||||
memo
|
memo
|
||||||
});
|
});
|
||||||
baseDependencies = union(baseDependencies, dependencies);
|
|
||||||
statInstance.baseValue = +result.value;
|
statInstance.baseValue = +result.value;
|
||||||
|
statInstance.dependencies = union(statInstance.dependencies, dependencies);
|
||||||
if (context.errors.length){
|
if (context.errors.length){
|
||||||
statInstance.baseValueErrors = context.errors;
|
statInstance.baseValueErrors = context.errors;
|
||||||
}
|
}
|
||||||
// Apply all the base values
|
// Apply all the base values
|
||||||
if (!statInstance.inactive){
|
effects.push({
|
||||||
effects.push({
|
operation: 'base',
|
||||||
operation: 'base',
|
calculation: statInstance.baseValueCalculation,
|
||||||
calculation: statInstance.baseValueCalculation,
|
result: statInstance.baseValue,
|
||||||
result: statInstance.baseValue,
|
stats: [statInstance.variableName],
|
||||||
stats: [statInstance.variableName],
|
dependencies: statInstance.overridden ?
|
||||||
dependencies: [],
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
computationDetails: {
|
[],
|
||||||
computed: true,
|
computationDetails: {
|
||||||
},
|
computed: true,
|
||||||
});
|
},
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply all the base baseDependencies
|
|
||||||
allStats.forEach(statInstance => {
|
|
||||||
statInstance.dependencies = union(
|
|
||||||
statInstance.dependencies,
|
|
||||||
without(baseDependencies, statInstance._id)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Compute and aggregate all the effects
|
// Compute and aggregate all the effects
|
||||||
let aggregator = new EffectAggregator();
|
let aggregator = new EffectAggregator();
|
||||||
let effectDeps = [];
|
let effectDeps = [];
|
||||||
|
if (Meteor.isClient) console.log({effects});
|
||||||
each(effects, (effect) => {
|
each(effects, (effect) => {
|
||||||
// Compute
|
// Compute
|
||||||
computeEffect(effect, memo);
|
computeEffect(effect, memo);
|
||||||
if (effect.deactivatedByToggle) return;
|
if (effect.deactivatedByToggle) return;
|
||||||
|
|
||||||
// dependencies
|
// dependencies
|
||||||
if (effect._id) effectDeps = [effect._id];
|
if (effect._id) effectDeps = union(effectDeps, [effect._id]);
|
||||||
effectDeps = union(effectDeps, effect.dependencies);
|
effectDeps = union(effectDeps, effect.dependencies);
|
||||||
|
|
||||||
// Add computed effect to aggregator
|
// Add computed effect to aggregator
|
||||||
@@ -152,9 +147,9 @@ export default function computeStat(stat, memo){
|
|||||||
// Mark the stats as computed
|
// Mark the stats as computed
|
||||||
statInstance.computationDetails.computed = true;
|
statInstance.computationDetails.computed = true;
|
||||||
statInstance.computationDetails.busyComputing = false;
|
statInstance.computationDetails.busyComputing = false;
|
||||||
statInstance.dependencies = union(
|
// Only the active stat instance depeneds on the effects
|
||||||
statInstance.dependencies,
|
if (!statInstance.overridden){
|
||||||
effectDeps
|
statInstance.dependencies = union(statInstance.dependencies, effectDeps);
|
||||||
);
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user