Progress all over the place with viewer, forms, small engine tweaks
This commit is contained in:
@@ -3,9 +3,14 @@ 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, notes, and actions disable their children,
|
||||
// Unequipped items, notes, spells, and actions disable their children,
|
||||
// but are not disabled themselves
|
||||
if (prop.type !== 'item' && prop.type !== 'note' && prop.type !== 'action' ){
|
||||
if (
|
||||
prop.type !== 'item' &&
|
||||
prop.type !== 'note' &&
|
||||
prop.type !== 'action' &&
|
||||
prop.type !== 'spell'
|
||||
){
|
||||
prop.inactive = true;
|
||||
prop.deactivatedBySelf = true;
|
||||
}
|
||||
@@ -20,7 +25,7 @@ function isActive(prop){
|
||||
if (prop.disabled) return false;
|
||||
switch (prop.type){
|
||||
case 'item': return !!prop.equipped;
|
||||
case 'spell': return !!prop.prepared || !!prop.alwaysPrepared;
|
||||
case 'spell': return false;
|
||||
case 'note': return false;
|
||||
case 'action': return false;
|
||||
default: return true;
|
||||
|
||||
@@ -9,6 +9,7 @@ const linkDependenciesByType = {
|
||||
effect: linkStats,
|
||||
skill: linkSkill,
|
||||
spell: linkResources,
|
||||
toggle: linkVariableName,
|
||||
}
|
||||
|
||||
export default function linkTypeDependencies(dependencyGraph, prop, computation){
|
||||
|
||||
@@ -3,6 +3,7 @@ import computeVariableAsAttribute from './computeVariable/computeVariableAsAttri
|
||||
import computeVariableAsSkill from './computeVariable/computeVariableAsSkill.js';
|
||||
import computeVariableAsConstant from './computeVariable/computeVariableAsConstant.js';
|
||||
import computeVariableAsClass from './computeVariable/computeVariableAsClass.js';
|
||||
import computeVariableAsToggle from './computeVariable/computeVariableAsToggle.js';
|
||||
import computeImplicitVariable from './computeVariable/computeImplicitVariable.js';
|
||||
|
||||
export default function computeVariable(computation, node){
|
||||
@@ -50,13 +51,15 @@ function combineAggregations(computation, node){
|
||||
function computeVariableProp(computation, node, prop){
|
||||
if (!prop) return;
|
||||
if (prop.type === 'attribute'){
|
||||
computeVariableAsAttribute(computation, node, prop)
|
||||
computeVariableAsAttribute(computation, node, prop);
|
||||
} else if (prop.type === 'skill'){
|
||||
computeVariableAsSkill(computation, node, prop)
|
||||
computeVariableAsSkill(computation, node, prop);
|
||||
} else if (prop.type === 'constant'){
|
||||
computeVariableAsConstant(computation, node, prop)
|
||||
computeVariableAsConstant(computation, node, prop);
|
||||
} else if (prop.type === 'class'){
|
||||
computeVariableAsClass(computation, node, prop)
|
||||
computeVariableAsClass(computation, node, prop);
|
||||
} else if (prop.type === 'toggle'){
|
||||
computeVariableAsToggle(computation, node, prop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import getAggregatorResult from './getAggregatorResult.js';
|
||||
|
||||
export default function computeVariableAsToggle(computation, node, prop){
|
||||
let result = getAggregatorResult(node, prop) || 0;
|
||||
|
||||
prop.value = !!result || !!prop.enabled || !!prop.condition?.value;
|
||||
}
|
||||
@@ -36,6 +36,7 @@ function compute(computation, node){
|
||||
// Determine the prop's active status by its toggles
|
||||
computeToggles(computation, node);
|
||||
computeCalculations(computation, node);
|
||||
if (node.data) delete node.data._computationDetails;
|
||||
// Compute the property by type
|
||||
computeByType[node.data?.type || '_variable']?.(computation, node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user