Tore out the old engine, left some wounds
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import walkDown from '/imports/api/engine/computation/utility/walkdown.js';
|
||||
|
||||
export default function computeInactiveStatus(node){
|
||||
const prop = node.node;
|
||||
if (isActive(prop)) return;
|
||||
// Unequipped items disable their children, but are not disabled themselves
|
||||
// All notes do the same
|
||||
if (prop.type !== 'item' && prop.type !== 'note' ){
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user