Merge feature-nested-sets into develop
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import _variable from './computeByType/computeVariable.js';
|
||||
import action from './computeByType/computeAction.js';
|
||||
import attribute from './computeByType/computeAttribute.js';
|
||||
import skill from './computeByType/computeSkill.js';
|
||||
import pointBuy from './computeByType/computePointBuy.js';
|
||||
import propertySlot from './computeByType/computeSlot.js';
|
||||
import container from './computeByType/computeContainer.js';
|
||||
import spellList from './computeByType/computeSpellList.js';
|
||||
import toggle from './computeByType/computeToggle.js';
|
||||
import trigger from './computeByType/computeTrigger.js'
|
||||
import _calculation from './computeByType/computeCalculation.js';
|
||||
import _variable from './computeByType/computeVariable';
|
||||
import action from './computeByType/computeAction';
|
||||
import attribute from './computeByType/computeAttribute';
|
||||
import skill from './computeByType/computeSkill';
|
||||
import pointBuy from './computeByType/computePointBuy';
|
||||
import propertySlot from './computeByType/computeSlot';
|
||||
import container from './computeByType/computeContainer';
|
||||
import spellList from './computeByType/computeSpellList';
|
||||
import toggle from './computeByType/computeToggle';
|
||||
import _calculation from './computeByType/computeCalculation';
|
||||
|
||||
export default Object.freeze({
|
||||
_variable,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import call from '/imports/parser/parseTree/call.js';
|
||||
import constant from '/imports/parser/parseTree/constant.js';
|
||||
import operator from '/imports/parser/parseTree/operator.js';
|
||||
import parenthesis from '/imports/parser/parseTree/parenthesis.js';
|
||||
import resolve, { toPrimitiveOrString } from '/imports/parser/resolve.js';
|
||||
import call from '/imports/parser/parseTree/call';
|
||||
import constant from '/imports/parser/parseTree/constant';
|
||||
import operator from '/imports/parser/parseTree/operator';
|
||||
import parenthesis from '/imports/parser/parseTree/parenthesis';
|
||||
import resolve, { toPrimitiveOrString } from '/imports/parser/resolve';
|
||||
|
||||
export default function computeCalculation(computation, node) {
|
||||
const calcObj = node.data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import aggregate from './computeVariable/aggregate/index.js';
|
||||
import { safeStrip } from '/imports/api/engine/computation/utility/stripFloatingPointOddities.js';
|
||||
import aggregate from './computeVariable/aggregate/index';
|
||||
import { safeStrip } from '/imports/api/engine/computation/utility/stripFloatingPointOddities';
|
||||
|
||||
export default function computeContainer(computation, node) {
|
||||
if (!node.data) node.data = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { has } from 'lodash';
|
||||
import resolveCalculationNode from '/imports/api/engine/computation/computeComputation/computeByType/computeCalculation.js';
|
||||
import { resolveCalculationNode } from '/imports/api/engine/computation/computeComputation/computeByType/computeCalculation';
|
||||
|
||||
export default function computePointBuy(computation, node) {
|
||||
const prop = node.data;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import aggregate from './computeVariable/aggregate/index.js';
|
||||
import computeVariableAsAttribute from './computeVariable/computeVariableAsAttribute.js';
|
||||
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';
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
import { computedInlineCalculationField } from '/imports/api/properties/subSchemas/inlineCalculationField';
|
||||
import aggregate from './computeVariable/aggregate/index';
|
||||
import computeVariableAsAttribute from './computeVariable/computeVariableAsAttribute';
|
||||
import computeVariableAsSkill from './computeVariable/computeVariableAsSkill';
|
||||
import computeVariableAsConstant from './computeVariable/computeVariableAsConstant';
|
||||
import computeVariableAsClass from './computeVariable/computeVariableAsClass';
|
||||
import computeVariableAsToggle from './computeVariable/computeVariableAsToggle';
|
||||
import computeImplicitVariable from './computeVariable/computeImplicitVariable';
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX';
|
||||
|
||||
export default function computeVariable(computation, node) {
|
||||
const scope = computation.scope;
|
||||
|
||||
@@ -12,7 +12,7 @@ export default function aggregateDefinition({ node, linkedNode, link }) {
|
||||
!definingProp ||
|
||||
prop.type !== 'pointBuyRow' && (
|
||||
definingProp.type === 'pointBuyRow' ||
|
||||
prop.order > definingProp.order
|
||||
prop.left > definingProp.left
|
||||
)
|
||||
) {
|
||||
// override the current defining prop
|
||||
|
||||
@@ -10,7 +10,7 @@ export default function aggregateEventDefinition({ node, linkedNode, link }) {
|
||||
// Find the last defining event
|
||||
if (
|
||||
!definingEvent ||
|
||||
prop.order > definingEvent.order
|
||||
prop.left > definingEvent.left
|
||||
) {
|
||||
// override the current defining prop
|
||||
if (definingEvent) definingEvent.overridden = true;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import definition from './aggregateDefinition.js';
|
||||
import damageMultiplier from './aggregateDamageMultiplier.js';
|
||||
import effect from './aggregateEffect.js';
|
||||
import eventDefinition from './aggregateEventDefinition.js';
|
||||
import proficiency from './aggregateProficiency.js';
|
||||
import classLevel from './aggregateClassLevel.js';
|
||||
import inventory from './aggregateInventory.js';
|
||||
import definition from './aggregateDefinition';
|
||||
import damageMultiplier from './aggregateDamageMultiplier';
|
||||
import effect from './aggregateEffect';
|
||||
import eventDefinition from './aggregateEventDefinition';
|
||||
import proficiency from './aggregateProficiency';
|
||||
import classLevel from './aggregateClassLevel';
|
||||
import inventory from './aggregateInventory';
|
||||
|
||||
export default Object.freeze({
|
||||
classLevel,
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
import getAggregatorResult from './getAggregatorResult.js';
|
||||
import getAggregatorResult from './getAggregatorResult';
|
||||
|
||||
/*
|
||||
* Variables with effects, proficiencies, or damage multipliers but no defining
|
||||
* properties are added to the scope as implicit variables
|
||||
*/
|
||||
export default function computeImplicitVariable(node){
|
||||
const prop = {};
|
||||
export default function computeImplicitVariable(node) {
|
||||
const prop = {};
|
||||
|
||||
// Combine damage multipliers
|
||||
if (node.data.immunity){
|
||||
if (node.data.immunity) {
|
||||
prop.immunity = node.data.immunity;
|
||||
prop.immunities = node.data.immunities;
|
||||
}
|
||||
if (node.data.resistance){
|
||||
if (node.data.resistance) {
|
||||
prop.resistance = node.data.resistance;
|
||||
prop.resistances = node.data.resistances;
|
||||
}
|
||||
if (node.data.vulnerability){
|
||||
if (node.data.vulnerability) {
|
||||
prop.vulnerability = node.data.vulnerability;
|
||||
prop.vulnerabilities = node.data.vulnerabilities;
|
||||
}
|
||||
|
||||
const result = getAggregatorResult(node);
|
||||
if (result !== undefined){
|
||||
prop.value = result;
|
||||
}
|
||||
if (node.data.proficiency !== undefined){
|
||||
prop.proficiency = node.data.proficiency;
|
||||
}
|
||||
const result = getAggregatorResult(node);
|
||||
if (result !== undefined) {
|
||||
prop.value = result;
|
||||
}
|
||||
if (node.data.proficiency !== undefined) {
|
||||
prop.proficiency = node.data.proficiency;
|
||||
}
|
||||
|
||||
// denormalise class level aggregator
|
||||
let classLevelAgg = node.data.classLevelAggregator;
|
||||
if (classLevelAgg){
|
||||
prop.level = classLevelAgg.level;
|
||||
}
|
||||
// denormalise class level aggregator
|
||||
let classLevelAgg = node.data.classLevelAggregator;
|
||||
if (classLevelAgg) {
|
||||
prop.level = classLevelAgg.level;
|
||||
}
|
||||
|
||||
// denormalise the effect aggregator fields
|
||||
const aggregator = node.data.effectAggregator;
|
||||
if (aggregator){
|
||||
if (aggregator.advantage && !aggregator.disadvantage){
|
||||
prop.advantage = 1;
|
||||
} else if (aggregator.disadvantage && !aggregator.advantage){
|
||||
prop.advantage = -1;
|
||||
} else {
|
||||
prop.advantage = 0;
|
||||
}
|
||||
// Passive bonus
|
||||
prop.passiveBonus = aggregator.passiveAdd;
|
||||
// conditional benefits
|
||||
prop.conditionalBenefits = aggregator.conditional;
|
||||
// Roll bonuses
|
||||
prop.rollBonus = aggregator.rollBonus;
|
||||
// Forced to fail
|
||||
prop.fail = aggregator.fail;
|
||||
// Rollbonus
|
||||
prop.rollBonuses = aggregator.rollBonus;
|
||||
}
|
||||
// denormalise the effect aggregator fields
|
||||
const aggregator = node.data.effectAggregator;
|
||||
if (aggregator) {
|
||||
if (aggregator.advantage && !aggregator.disadvantage) {
|
||||
prop.advantage = 1;
|
||||
} else if (aggregator.disadvantage && !aggregator.advantage) {
|
||||
prop.advantage = -1;
|
||||
} else {
|
||||
prop.advantage = 0;
|
||||
}
|
||||
// Passive bonus
|
||||
prop.passiveBonus = aggregator.passiveAdd;
|
||||
// conditional benefits
|
||||
prop.conditionalBenefits = aggregator.conditional;
|
||||
// Roll bonuses
|
||||
prop.rollBonus = aggregator.rollBonus;
|
||||
// Forced to fail
|
||||
prop.fail = aggregator.fail;
|
||||
// Rollbonus
|
||||
prop.rollBonuses = aggregator.rollBonus;
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import getAggregatorResult from './getAggregatorResult.js';
|
||||
import getAggregatorResult from './getAggregatorResult';
|
||||
|
||||
export default function computeVariableAsAttribute(computation, node, prop) {
|
||||
let result = getAggregatorResult(node) || 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { parse } from '/imports/parser/parser.js';
|
||||
import { parse } from '/imports/parser/parser';
|
||||
|
||||
export default function computeVariableAsConstant(computation, node, prop){
|
||||
export default function computeVariableAsConstant(computation, node, prop) {
|
||||
let string = prop.calculation;
|
||||
if (!string) return;
|
||||
let parseNode;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import aggregate from './aggregate/index.js';
|
||||
import aggregate from './aggregate/index';
|
||||
|
||||
export default function computeVariableAsSkill(computation, node, prop) {
|
||||
// Skills are based on some ability Modifier
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import getAggregatorResult from './getAggregatorResult.js';
|
||||
import getAggregatorResult from './getAggregatorResult';
|
||||
|
||||
export default function computeVariableAsToggle(computation, node, prop){
|
||||
export default function computeVariableAsToggle(computation, node, prop) {
|
||||
let result = getAggregatorResult(node, prop) || 0;
|
||||
|
||||
prop.value = !!result || !!prop.enabled || !!prop.condition?.value;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import stripFloatingPointOddities from '/imports/api/engine/computation/utility/stripFloatingPointOddities.js';
|
||||
import stripFloatingPointOddities from '/imports/api/engine/computation/utility/stripFloatingPointOddities';
|
||||
|
||||
export default function getAggregatorResult(node) {
|
||||
// Work out the base value as the greater of the deining stat value
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
|
||||
@@ -33,7 +33,6 @@ var testProperties = [
|
||||
clean({
|
||||
_id: 'actionId',
|
||||
type: 'action',
|
||||
ancestors: [{id: 'charId'}],
|
||||
summary: {
|
||||
text: 'test summary {1 + 2} without referencing anything {3 + 4}',
|
||||
},
|
||||
@@ -61,14 +60,17 @@ var testProperties = [
|
||||
calculation: 'nonExistantProperty + 7',
|
||||
},
|
||||
usesUsed: 5,
|
||||
left: 1,
|
||||
right: 2,
|
||||
}),
|
||||
clean({
|
||||
_id: 'rolledDescriptionId',
|
||||
type: 'action',
|
||||
ancestors: [{id: 'charId'}],
|
||||
summary: {
|
||||
text: 'test roll gets compiled {4 + (2 + 2)} properly',
|
||||
},
|
||||
left: 3,
|
||||
right: 4,
|
||||
}),
|
||||
clean({
|
||||
_id: 'numItemsConumedId',
|
||||
@@ -77,6 +79,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '3',
|
||||
},
|
||||
left: 5,
|
||||
right: 6,
|
||||
}),
|
||||
clean({
|
||||
_id: 'numResourceConumedId',
|
||||
@@ -85,6 +89,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '4',
|
||||
},
|
||||
left: 7,
|
||||
right: 8,
|
||||
}),
|
||||
clean({
|
||||
_id: 'resourceVarId',
|
||||
@@ -94,6 +100,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '9',
|
||||
},
|
||||
left: 9,
|
||||
right: 10,
|
||||
}),
|
||||
clean({
|
||||
_id: 'inlineRefResourceId',
|
||||
@@ -102,6 +110,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '1 + 5',
|
||||
},
|
||||
left: 11,
|
||||
right: 12,
|
||||
}),
|
||||
clean({
|
||||
_id: 'arrowId',
|
||||
@@ -110,5 +120,7 @@ var testProperties = [
|
||||
quantity: 27,
|
||||
icon: 'itemIcon',
|
||||
color: 'itemColor',
|
||||
left: 13,
|
||||
right: 14,
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
@@ -27,6 +27,8 @@ var testProperties = [
|
||||
_id: 'emptyId',
|
||||
type: 'attribute',
|
||||
attributeType: 'ability',
|
||||
left: 1,
|
||||
right: 2,
|
||||
}),
|
||||
clean({
|
||||
_id: 'noVariableNameId',
|
||||
@@ -35,6 +37,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '8'
|
||||
},
|
||||
left: 3,
|
||||
right: 4,
|
||||
}),
|
||||
clean({
|
||||
_id: 'strengthId',
|
||||
@@ -44,6 +48,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '12'
|
||||
},
|
||||
left: 5,
|
||||
right: 6,
|
||||
}),
|
||||
clean({
|
||||
_id: 'overriddenDexId',
|
||||
@@ -54,6 +60,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '15'
|
||||
},
|
||||
left: 7,
|
||||
right: 8,
|
||||
}),
|
||||
clean({
|
||||
_id: 'dexterityId',
|
||||
@@ -64,6 +72,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '15'
|
||||
},
|
||||
left: 9,
|
||||
right: 10,
|
||||
}),
|
||||
clean({
|
||||
_id: 'constitutionId',
|
||||
@@ -73,6 +83,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '21'
|
||||
},
|
||||
left: 11,
|
||||
right: 12,
|
||||
}),
|
||||
clean({
|
||||
_id: 'referencesDexId',
|
||||
@@ -81,6 +93,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: 'dexterity.modifier + 2'
|
||||
},
|
||||
left: 13,
|
||||
right: 14,
|
||||
}),
|
||||
clean({
|
||||
_id: 'hitDiceId',
|
||||
@@ -91,6 +105,8 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '4'
|
||||
},
|
||||
left: 15,
|
||||
right: 16,
|
||||
}),
|
||||
clean({
|
||||
_id: 'parseErrorId',
|
||||
@@ -100,5 +116,7 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: '12 +'
|
||||
},
|
||||
left: 17,
|
||||
right: 18,
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
const scope = id => computation.scope[id];
|
||||
@@ -20,41 +21,37 @@ var testProperties = [
|
||||
type: 'class',
|
||||
variableName: 'wizard',
|
||||
classType: 'startingClass',
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'rangerId',
|
||||
type: 'class',
|
||||
variableName: 'ranger',
|
||||
classType: 'multiClass',
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'wiz1Id',
|
||||
type: 'classLevel',
|
||||
variableName: 'wizard',
|
||||
level: 1,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'wiz2Id',
|
||||
type: 'classLevel',
|
||||
variableName: 'wizard',
|
||||
level: 2,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'wiz4Id',
|
||||
type: 'classLevel',
|
||||
variableName: 'wizard',
|
||||
level: 4,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'rang1Id',
|
||||
type: 'classLevel',
|
||||
variableName: 'ranger',
|
||||
level: 1,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
];
|
||||
|
||||
applyNestedSetProperties(testProperties);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
const prop = id => computation.propsById[id];
|
||||
@@ -23,6 +24,7 @@ var testProperties = [
|
||||
baseValue: {
|
||||
calculation: 'arrayConstant[3]',
|
||||
},
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
];
|
||||
|
||||
applyNestedSetProperties(testProperties);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
const scope = id => computation.scope[id];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import { propsFromForest } from '/imports/api/properties/tests/propTestBuilder.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
import { applyNestedSetProperties, compareOrder } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
const prop = id => computation.propsById[id];
|
||||
@@ -13,9 +14,8 @@ export default function(){
|
||||
assert.equal(scope('valueEquipment'), 3);
|
||||
|
||||
assert.equal(scope('itemsAttuned'), 1);
|
||||
|
||||
assert.equal(prop('childContainerId').carriedWeight, 69);
|
||||
assert.equal(prop('childContainerId').contentsWeight, 69);
|
||||
assert.equal(prop('childContainerId').carriedWeight, 69, 'Calculates container carried weight correctly');
|
||||
assert.equal(prop('childContainerId').contentsWeight, 69, 'Calculates container contents weight correctly');
|
||||
|
||||
assert.equal(scope('weightCarried'), 104);
|
||||
assert.equal(scope('valueCarried'), 129);
|
||||
@@ -32,7 +32,6 @@ var testProperties = [
|
||||
attuned: true,
|
||||
weight: 2,
|
||||
value: 3,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'containerId',
|
||||
@@ -40,22 +39,13 @@ var testProperties = [
|
||||
carried: true,
|
||||
weight: 5,
|
||||
value: 7,
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'childContainerId',
|
||||
type: 'container',
|
||||
carried: true,
|
||||
weight: 11,
|
||||
value: 13,
|
||||
ancestors: [{id: 'charId'}, {id: 'containerId'}],
|
||||
}),
|
||||
clean({
|
||||
_id: 'childItemId',
|
||||
type: 'item',
|
||||
weight: 17,
|
||||
value: 19,
|
||||
ancestors: [{id: 'charId'}, {id: 'containerId'}],
|
||||
parentId: 'containerId',
|
||||
}),
|
||||
clean({
|
||||
_id: 'grandchildItemId',
|
||||
@@ -63,6 +53,16 @@ var testProperties = [
|
||||
weight: 23, // 69 total
|
||||
value: 29, // 87 total
|
||||
quantity: 3,
|
||||
ancestors: [{id: 'charId'}, {id: 'containerId'}, {id: 'childContainerId'}],
|
||||
parentId: 'childContainerId',
|
||||
}),
|
||||
clean({
|
||||
_id: 'childContainerId',
|
||||
type: 'container',
|
||||
carried: true,
|
||||
weight: 11,
|
||||
value: 13,
|
||||
parentId: 'containerId',
|
||||
}),
|
||||
];
|
||||
applyNestedSetProperties(testProperties);
|
||||
testProperties.sort(compareOrder);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
import { applyNestedSetProperties, compareOrder } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
const hasLink = computation.dependencyGraph.hasLink;
|
||||
computeCreatureComputation(computation);
|
||||
const prop = id => computation.propsById[id];
|
||||
assert.equal(
|
||||
@@ -38,7 +40,6 @@ var testProperties = [
|
||||
clean({
|
||||
_id: 'actionId',
|
||||
type: 'action',
|
||||
ancestors: [{ id: 'charId' }],
|
||||
attackRoll: {
|
||||
calculation: 'strength.modifier',
|
||||
},
|
||||
@@ -48,7 +49,6 @@ var testProperties = [
|
||||
_id: 'profBonusId',
|
||||
type: 'attribute',
|
||||
variableName: 'proficiencyBonus',
|
||||
ancestors: [{ id: 'charId' }],
|
||||
baseValue: {
|
||||
calculation: '13'
|
||||
},
|
||||
@@ -62,3 +62,5 @@ var testProperties = [
|
||||
targetTags: ['martial weapon']
|
||||
}),
|
||||
];
|
||||
applyNestedSetProperties(testProperties);
|
||||
testProperties.sort(compareOrder);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
|
||||
import { assert } from 'chai';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||
import clean from '../../utility/cleanProp.testFn.js';
|
||||
import computeCreatureComputation from '../../computeCreatureComputation';
|
||||
import clean from '../../utility/cleanProp.testFn';
|
||||
|
||||
export default function(){
|
||||
export default function () {
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
computeCreatureComputation(computation);
|
||||
const prop = id => computation.propsById[id];
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import computeAction from './computeAction.testFn.js';
|
||||
import computeAttribute from './computeAttribute.testFn.js';
|
||||
import computeCalculations from './computeCalculations.testFn.js';
|
||||
import computeClasses from './computeClasses.testFn.js';
|
||||
import computeConstants from './computeConstants.testFn.js';
|
||||
import computeInventory from './computeInventory.testFn.js';
|
||||
import computeDamageMultipliers from './computeDamageMultipliers.testFn.js';
|
||||
import computeEffects from './computeEffects.testFn.js';
|
||||
import computeSkills from './computeSkills.testFn.js';
|
||||
import computePointBuys from './computePointBuys.testFn.js';
|
||||
import computeProficiencies from './computeProficiencies.testFn.js';
|
||||
import computeAction from './computeAction.testFn';
|
||||
import computeAttribute from './computeAttribute.testFn';
|
||||
import computeClasses from './computeClasses.testFn';
|
||||
import computeConstants from './computeConstants.testFn';
|
||||
import computeInventory from './computeInventory.testFn';
|
||||
import computeDamageMultipliers from './computeDamageMultipliers.testFn';
|
||||
import computeEffects from './computeEffects.testFn';
|
||||
import computeSkills from './computeSkills.testFn';
|
||||
import computeProficiencies from './computeProficiencies.testFn';
|
||||
|
||||
export default [{
|
||||
text: 'Computes actions',
|
||||
|
||||
Reference in New Issue
Block a user