Finished move to 3 tier action methods

This commit is contained in:
ThaumRystra
2023-12-15 12:25:32 +02:00
parent 99bf5fd832
commit 862c2ceb99
3 changed files with 276 additions and 225 deletions

View File

@@ -189,15 +189,22 @@ export function getPropertyDecendants(creatureId, propertyId) {
}
}
export function getPropertyChildren(creatureId, propertyId) {
const property = getSingleProperty(creatureId, propertyId);
/**
* @param {string} creatureId Creature ID
* @param {string | any} property prop or prop ID to get children of
* @returns {any[]} An array of child properties in tree order
*/
export function getPropertyChildren(creatureId, property) {
if (typeof property === 'string') {
property = getSingleProperty(creatureId, property);
}
if (!property) return [];
// This propertyId will always appear in the parent of the children
if (loadedCreatures.has(creatureId)) {
const creature = loadedCreatures.get(creatureId);
const props = [];
for (const prop of creature.properties.values()) {
if (prop.parent?.id === propertyId) {
if (prop.parent?.id === property._id) {
props.push(prop);
}
}
@@ -205,7 +212,7 @@ export function getPropertyChildren(creatureId, propertyId) {
return cloneProps.sort((a, b) => a.order - b.order);
} else {
return CreatureProperties.find({
'parent.id': propertyId,
'parent.id': property._id,
removed: { $ne: true },
}, {
sort: { order: 1 },