Substantial progress on rebuilding computation engine

This commit is contained in:
Stefan Zermatten
2021-09-09 13:47:41 +02:00
parent 23e99565dc
commit 55bca633fc
16 changed files with 401 additions and 244 deletions

View File

@@ -0,0 +1,24 @@
import walkDown from '/imports/api/creature/computation/newEngine/utility/walkdown.js';
export default function computeInactiveStatus(node){
const prop = node.node;
if (isActive(prop)) return;
prop.inactive = true;
prop.deactivatedBySelf = true;
// Mark children as inactive due to ancestor
walkDown(node.children, child => {
child.node.inactive = true;
child.node.deactivatedByAncestor = true;
});
}
function isActive(prop){
if (prop.disabled) return false;
switch (prop.type){
case 'buff': return !!prop.applied;
case 'item': return !!prop.equipped;
case 'spell': return !!prop.prepared || !!prop.alwaysPrepared;
case 'note': return false;
default: return true;
}
}