Continued migration to nested sets

This commit is contained in:
Thaum Rystra
2023-10-04 14:27:06 +02:00
parent f63d2ad254
commit b4993b86b5
11 changed files with 35 additions and 172 deletions

View File

@@ -1,6 +1,7 @@
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
import { assert } from 'chai';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
let computation = buildComputationFromProps(testProperties);
@@ -53,30 +54,22 @@ var testProperties = [
_id: 'itemUnequippedId',
type: 'item',
parentId: 'charId',
left: 1,
right: 4,
}),
clean({
_id: 'itemUnequippedChildId',
type: 'folder',
parentId: 'itemUnequippedId',
left: 2,
right: 3,
}),
clean({
_id: 'itemEquippedId',
type: 'item',
equipped: true,
parentId: 'charId',
left: 5,
right: 8,
}),
clean({
_id: 'itemEquippedChildId',
type: 'folder',
parentId: 'itemEquippedId',
left: 6,
right: 7,
}),
// Spells
clean({
@@ -84,58 +77,44 @@ var testProperties = [
type: 'spell',
parentId: 'charId',
prepared: true,
left: 9,
right: 12,
}),
clean({
_id: 'spellPreparedChildId',
type: 'folder',
parentId: 'spellPreparedId',
left: 10,
right: 11,
}),
clean({
_id: 'spellAlwaysPreparedId',
type: 'spell',
parentId: 'charId',
alwaysPrepared: true,
left: 13,
right: 16,
}),
clean({
_id: 'spellAlwaysPreparedChildId',
type: 'folder',
parentId: 'spellAlwaysPreparedId',
left: 14,
right: 15,
}),
clean({
_id: 'spellUnpreparedId',
type: 'spell',
parentId: 'charId',
left: 17,
right: 20,
}),
clean({
_id: 'spellUnpreparedChildId',
type: 'folder',
parentId: 'spellUnpreparedId',
left: 18,
right: 19,
}),
// Notes
clean({
_id: 'NoteId',
type: 'note',
parentId: 'charId',
left: 21,
right: 24,
}),
clean({
_id: 'NoteChildId',
type: 'folder',
parentId: 'NoteId',
left: 22,
right: 23,
}),
];
applyNestedSetProperties(testProperties);

View File

@@ -1,6 +1,7 @@
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
import { assert } from 'chai';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
@@ -13,8 +14,6 @@ var testProperties = [
clean({
_id: 'slotId',
type: 'propertySlot',
left: 1,
right: 8,
}),
// Children
clean({
@@ -23,21 +22,17 @@ var testProperties = [
slotQuantityFilled: 3,
slotFillerType: 'item',
parentId: 'slotId',
left: 2,
right: 3,
}),
clean({
_id: 'slotChildId',
type: 'item',
parentId: 'slotId',
left: 4,
right: 7,
}),
clean({
_id: 'slotGrandchildId',
type: 'effect',
parentId: 'slotChildId',
left: 5,
right: 6,
}),
];
applyNestedSetProperties(testProperties);

View File

@@ -1,6 +1,7 @@
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
import { assert } from 'chai';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
@@ -37,38 +38,37 @@ var testProperties = [
_id: 'enabledToggleId',
type: 'toggle',
enabled: true,
ancestors: [{ id: 'charId' }],
}),
clean({
_id: 'disabledToggleId',
type: 'toggle',
disabled: true,
ancestors: [{ id: 'charId' }],
}),
clean({
_id: 'conditionToggleId',
type: 'toggle',
ancestors: [{ id: 'charId' }],
}),
// Children
clean({
_id: 'enabledToggleChildId',
type: 'folder',
ancestors: [{ id: 'charId' }, { id: 'enabledToggleId' }],
parentId: 'enabledToggleId',
}),
clean({
_id: 'disabledToggleChildId',
type: 'folder',
ancestors: [{ id: 'charId' }, { id: 'disabledToggleId' }],
parentId: 'disabledToggleId',
}),
clean({
_id: 'conditionToggleChildId',
type: 'folder',
ancestors: [{ id: 'charId' }, { id: 'conditionToggleId' }],
parentId: 'conditionToggleId',
}),
clean({
_id: 'conditionToggleGrandChildId',
type: 'folder',
ancestors: [{ id: 'charId' }, { id: 'conditionToggleId' }, { id: 'conditionToggleChildId' }],
parentId: 'conditionToggleChildId',
}),
];
applyNestedSetProperties(testProperties);

View File

@@ -1,6 +1,7 @@
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation';
import { assert } from 'chai';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
@@ -32,8 +33,6 @@ var testProperties = [
clean({
_id: 'spellListId',
type: 'spellList',
left: 1,
right: 6,
}),
clean({
_id: 'childId',
@@ -42,8 +41,6 @@ var testProperties = [
text: 'DC {#spellList.dc} save or suck'
},
parentId: 'spellListId',
left: 2,
right: 5,
}),
clean({
_id: 'grandchildId',
@@ -52,8 +49,6 @@ var testProperties = [
calculation: '#spellList.dc + strength + wisdom.modifier'
},
parentId: 'childId',
left: 3,
right: 4,
}),
clean({
_id: 'strengthId',
@@ -62,7 +57,7 @@ var testProperties = [
baseValue: {
calculation: '15 + ',
},
left: 7,
right: 8,
}),
];
applyNestedSetProperties(testProperties);

View File

@@ -22,6 +22,5 @@ var testProperties = [
_id: 'strengthId',
type: 'attribute',
variableName: 'strength',
ancestors: [{ id: 'charId' }],
}),
];

View File

@@ -2,6 +2,7 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build
import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
@@ -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);

View File

@@ -2,6 +2,7 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build
import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation';
import clean from '../../utility/cleanProp.testFn';
import { applyNestedSetProperties } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
@@ -23,6 +24,7 @@ var testProperties = [
baseValue: {
calculation: 'arrayConstant[3]',
},
ancestors: [{ id: 'charId' }],
}),
];
applyNestedSetProperties(testProperties);

View File

@@ -44,7 +44,6 @@ var testProperties = [
clean({
_id: 'actionId',
type: 'action',
ancestors: [{ id: 'charId' }],
attackRoll: {
calculation: 'strength.modifier',
},
@@ -54,7 +53,6 @@ var testProperties = [
_id: 'profBonusId',
type: 'attribute',
variableName: 'proficiencyBonus',
ancestors: [{ id: 'charId' }],
baseValue: {
calculation: '13'
},