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