Began migration of queries to nested sets
This commit is contained in:
@@ -5,7 +5,6 @@ export default function defaultCharacterProperties(creatureId) {
|
||||
const creatureRef = { collection: 'creatures', id: creatureId };
|
||||
let randomSrc = DDP.randomStream('defaultProperties');
|
||||
const inventoryId = randomSrc.id();
|
||||
const inventoryRef = { collection: 'creatureProperties', id: inventoryId };
|
||||
return [
|
||||
{
|
||||
type: 'propertySlot',
|
||||
@@ -17,31 +16,35 @@ export default function defaultCharacterProperties(creatureId) {
|
||||
hideWhenFull: true,
|
||||
spaceLeft: 1,
|
||||
totalFilled: 0,
|
||||
order: 0,
|
||||
parent: creatureRef,
|
||||
ancestors: [creatureRef],
|
||||
left: 1,
|
||||
right: 2,
|
||||
parentId: creatureId,
|
||||
root: creatureRef,
|
||||
}, {
|
||||
_id: inventoryId,
|
||||
type: 'folder',
|
||||
name: 'Inventory',
|
||||
tags: [BUILT_IN_TAGS.inventory],
|
||||
order: 1,
|
||||
parent: creatureRef,
|
||||
ancestors: [creatureRef],
|
||||
left: 3,
|
||||
right: 8,
|
||||
parentId: creatureId,
|
||||
root: creatureRef,
|
||||
}, {
|
||||
type: 'folder',
|
||||
name: 'Equipment',
|
||||
tags: [BUILT_IN_TAGS.equipment],
|
||||
order: 2,
|
||||
parent: inventoryRef,
|
||||
ancestors: [creatureRef, inventoryRef],
|
||||
left: 4,
|
||||
right: 5,
|
||||
parentId: inventoryId,
|
||||
root: creatureRef,
|
||||
}, {
|
||||
type: 'folder',
|
||||
name: 'Carried',
|
||||
tags: [BUILT_IN_TAGS.carried],
|
||||
order: 3,
|
||||
parent: inventoryRef,
|
||||
ancestors: [creatureRef, inventoryRef],
|
||||
left: 6,
|
||||
right: 7,
|
||||
parent: inventoryId,
|
||||
root: creatureRef,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ import CreatureVariables from '/imports/api/creature/creatures/CreatureVariables
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import CreatureLogs from '/imports/api/creature/log/CreatureLogs';
|
||||
import Experiences from '/imports/api/creature/experience/Experiences';
|
||||
import { getFilter } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
function removeRelatedDocuments(creatureId) {
|
||||
CreatureVariables.remove({ _creatureId: creatureId });
|
||||
CreatureProperties.remove({ 'ancestors.id': creatureId });
|
||||
CreatureProperties.remove(getFilter.descendantsOfRoot(creatureId));
|
||||
CreatureLogs.remove({ creatureId });
|
||||
Experiences.remove({ creatureId });
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { union } from 'lodash';
|
||||
import ActionContext from '/imports/api/engine/actions/ActionContext';
|
||||
import { applyTriggers } from '/imports/api/engine/actions/applyTriggers';
|
||||
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty';
|
||||
import { getFilter } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
const restCreature = new ValidatedMethod({
|
||||
name: 'creature.methods.rest',
|
||||
@@ -74,7 +75,7 @@ function doRestWork(restType, actionContext) {
|
||||
export function resetProperties(creatureId, resetFilter, actionContext) {
|
||||
// Only apply to active properties
|
||||
const filter = {
|
||||
'ancestors.id': creatureId,
|
||||
...getFilter.descendantsOfRoot(creatureId),
|
||||
reset: resetFilter,
|
||||
removed: { $ne: true },
|
||||
inactive: { $ne: true },
|
||||
@@ -128,7 +129,7 @@ export function resetProperties(creatureId, resetFilter, actionContext) {
|
||||
|
||||
function resetHitDice(creatureId, actionContext) {
|
||||
let hitDice = CreatureProperties.find({
|
||||
'ancestors.id': creatureId,
|
||||
...getFilter.descendantsOfRoot(creatureId),
|
||||
type: 'attribute',
|
||||
attributeType: 'hitDice',
|
||||
removed: { $ne: true },
|
||||
|
||||
Reference in New Issue
Block a user