Fixed: buffs
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
} from '/imports/api/parenting/parenting.js';
|
||||
import {setDocToLastOrder} from '/imports/api/parenting/order.js';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
|
||||
export default function applyBuff({
|
||||
prop,
|
||||
@@ -57,5 +58,10 @@ function copyNodeListToTarget(propList, target, oldParent){
|
||||
collection: CreatureProperties,
|
||||
doc: propList[0],
|
||||
});
|
||||
CreatureProperties.batchInsert(propList);
|
||||
|
||||
CreatureProperties.batchInsert(propList, () => {
|
||||
// This insert is racing the main recompute, recmpute again after it's
|
||||
// certainly finished
|
||||
recomputeCreatureByDoc(target);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,23 +52,24 @@ function applyProperty(options){
|
||||
return true;
|
||||
}
|
||||
|
||||
function applyPropertyAndWalkChildren({prop, child, targets, ...options}){
|
||||
let shouldKeepWalking = applyProperty({ prop, targets, ...options });
|
||||
function applyPropertyAndWalkChildren({prop, children, targets, ...options}){
|
||||
let shouldKeepWalking = applyProperty({ prop, children, targets, ...options });
|
||||
if (shouldKeepWalking){
|
||||
applyProperties({ forest: child.children, targets, ...options,});
|
||||
applyProperties({ forest: children, targets, ...options,});
|
||||
}
|
||||
}
|
||||
|
||||
export default function applyProperties({ forest, targets, ...options}){
|
||||
forest.forEach(child => {
|
||||
let prop = child.node;
|
||||
forest.forEach(node => {
|
||||
let prop = node.node;
|
||||
let children = node.children;
|
||||
if (shouldSplit(prop) && targets.length){
|
||||
targets.forEach(target => {
|
||||
let targets = [target]
|
||||
applyPropertyAndWalkChildren({ targets, prop, child, ...options});
|
||||
applyPropertyAndWalkChildren({ targets, prop, children, ...options});
|
||||
});
|
||||
} else {
|
||||
applyPropertyAndWalkChildren({prop, child, targets, ...options});
|
||||
applyPropertyAndWalkChildren({prop, children, targets, ...options});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user