Skip to content

Commit

Permalink
Iterate on action engine and tree data store migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaumRystra committed Oct 28, 2024
1 parent e887daf commit e8158ba
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 128 deletions.
24 changes: 2 additions & 22 deletions app/imports/client/ui/creature/actions/input/CastSpellInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@
</v-list-item-group>
</template>
</split-list-layout>
<v-btn
text
:disabled="!canCast"
class="mx-2 px-4"
color="primary"
@click="cast"
>
Cast
</v-btn>
</div>
</template>

Expand Down Expand Up @@ -186,18 +177,10 @@ export default {
type: String,
required: true,
},
slotId: {
type: String,
default: undefined,
},
value: {
type: Object,
required: true,
},
spellId: {
type: String,
default: undefined,
},
},
data() {
return {
Expand Down Expand Up @@ -258,7 +241,7 @@ export default {
} else {
const newSlot = find(
CreatureProperties.find({
'ancestors.id': this.creatureId,
...getFilter.descendantsOfRoot(this.creatureId),
...slotFilter
}, {
sort: { 'spellSlotLevel.value': 1, order: 1 },
Expand Down Expand Up @@ -339,9 +322,6 @@ export default {
);
}
},
cast() {
this.$emit('continue');
}
},
meteor: {
spells() {
Expand Down Expand Up @@ -379,7 +359,7 @@ export default {
},
spellSlots() {
return CreatureProperties.find({
'ancestors.id': this.creatureId,
...getFilter.descendantsOfRoot(this.creatureId),
...slotFilter
}, {
sort: { 'spellSlotLevel.value': 1, order: 1 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import { getPropertyName } from '/imports/constants/PROPERTIES';
import PropertyForm from '/imports/client/ui/properties/PropertyForm.vue';
import getPropertyTitle from '/imports/client/ui/properties/shared/getPropertyTitle';
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions';
import { get, findLast } from 'lodash';
import { get } from 'lodash';
import equipItem from '/imports/api/creature/creatureProperties/methods/equipItem';
import { snackbar } from '/imports/client/ui/components/snackbars/SnackbarQueue';
import insertProperty from '/imports/api/creature/creatureProperties/methods/insertProperty';
Expand Down
9 changes: 4 additions & 5 deletions app/imports/client/ui/creature/slots/LevelUpDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</div>
</v-layout>
<div class="text-caption text-no-wrap text-truncate">
{{ libraryNames[libraryNode.ancestors[0].id ] }}
{{ libraryNames[libraryNode.root.id ] }}
</div>
</v-layout>
<div
Expand Down Expand Up @@ -187,14 +187,13 @@ import LibraryNodes from '/imports/api/library/LibraryNodes';
import DialogBase from '/imports/client/ui/dialogStack/DialogBase.vue';
import TreeNodeView from '/imports/client/ui/properties/treeNodeViews/TreeNodeView.vue';
import PropertyDescription from '/imports/client/ui/properties/viewers/shared/PropertyDescription.vue'
import resolve, { toString } from '/imports/parser/resolve';
import resolve from '/imports/parser/resolve';
import { prettifyParseError, parse } from '/imports/parser/parser';
// import evaluateString from '/imports/api/creature/computation/afterComputation/evaluateString';
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter'
import Libraries from '/imports/api/library/Libraries';
import LibraryNodeExpansionContent from '/imports/client/ui/library/LibraryNodeExpansionContent.vue';
import PropertyTags from '/imports/client/ui/properties/viewers/shared/PropertyTags.vue';
import { clone, difference, isEqual } from 'lodash';
import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
Expand Down Expand Up @@ -378,7 +377,7 @@ export default {
ancestorId = this.creatureId;
}
CreatureProperties.find({
'ancestors.id': ancestorId,
...getFilter.descendants(ancestorId),
libraryNodeId: { $exists: true },
removed: { $ne: true },
}, {
Expand Down
3 changes: 2 additions & 1 deletion app/imports/client/ui/library/LibraryEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import Libraries, { updateLibraryName, updateLibraryDescription, updateLibrarySh
import LibraryNodes, { restoreLibraryNode } from '/imports/api/library/LibraryNodes';
import TreeNodeView from '/imports/client/ui/properties/treeNodeViews/TreeNodeView.vue';
import { snackbar } from '/imports/client/ui/components/snackbars/SnackbarQueue';
import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
Expand Down Expand Up @@ -186,7 +187,7 @@ export default {
},
removedDocs() {
return LibraryNodes.find({
'ancestors.0.id': this._id,
...getFilter.descendantsOfRoot(this._id),
removed: true,
removedWith: { $exists: false },
}, {
Expand Down
87 changes: 72 additions & 15 deletions app/imports/client/ui/log/TabletopLogContent.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
<template lang="html">
<div class="log-content">
<div
v-for="(content, index) in model"
v-for="(contentGroup, index) in contentByTargetId"
:key="index"
class="content-line"
>
<h4
class="content-name"
style="min-height: 12px;"
<h3
v-if="contentGroup.targetIds.length"
class="content-target-ids"
>
{{ content.name }}
</h4>
<markdown-text
v-if="content.value"
class="content-value"
:markdown="content.value"
/>
<v-icon>mdi-chevron-right</v-icon>
<v-list-item-avatar
v-for="creature in contentGroup.targetCreatures"
:key="creature._id"
:color="model.color || 'grey'"
size="32"
>
<img
v-if="creature.avatarPicture"
:src="creature.avatarPicture"
:alt="creature.name"
>
<span v-else>
{{ creature.name && creature.name[0] || '?' }}
</span>
</v-list-item-avatar>
</h3>
<div
v-else
style="min-height: 12px;"
/>
v-for="(content, contentIndex) in contentGroup.content"
:key="contentIndex"
class="content-line"
>
<h4
class="content-name"
style="min-height: 12px;"
>
{{ content.name }}
</h4>
<markdown-text
v-if="content.value"
class="content-value"
:markdown="content.value"
/>
<div
v-else
style="min-height: 12px;"
/>
</div>
</div>
</div>
</template>

<script lang="js">
import { isEqual } from 'lodash';
import MarkdownText from '/imports/client/ui/components/MarkdownText.vue';
import Creatures from '/imports/api/creature/creatures/Creatures';
export default {
components: {
Expand All @@ -37,6 +65,35 @@ export default {
default: () => [],
},
},
meteor: {
contentByTargetId() {
const content = [];
const creaturesById = {};
const getCreature = creatureId => {
if (creaturesById[creatureId]) return creaturesById[creatureId];
return creaturesById[creatureId] = Creatures.findOne(creatureId, {
fields: { _id: 1, avatarPicture: 1, name: 1 },
});
};
let currentContent = undefined;
for (const contentItem of this.model) {
if (!currentContent || !isEqual(currentContent.targetIds, contentItem.targetIds)) {
if (currentContent) {
content.push(currentContent);
}
currentContent = {
targetIds: contentItem.targetIds,
targetCreatures: contentItem.targetIds.map(getCreature),
content: [contentItem],
};
} else {
currentContent.content.push(contentItem);
}
}
content.push(currentContent);
return content;
}
}
}
</script>

Expand Down
5 changes: 2 additions & 3 deletions app/imports/client/ui/properties/InsertPropertyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ import getThemeColor from '/imports/client/ui/utility/getThemeColor';
import PropertySelector from '/imports/client/ui/properties/shared/PropertySelector.vue';
import {snackbar} from '/imports/client/ui/components/snackbars/SnackbarQueue';
import PropertyForm from '/imports/client/ui/properties/PropertyForm.vue';
import SimpleSchema from 'simpl-schema';
export default {
components: {
Expand Down Expand Up @@ -372,9 +371,9 @@ export default {
_searchResult: true
},{
sort: {
'ancestors.0.id': 1,
name: 1,
order: 1,
type: 1,
left: 1,
},
});
},
Expand Down
7 changes: 4 additions & 3 deletions app/imports/client/ui/properties/viewers/SkillViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ import SkillProficiency from '/imports/client/ui/properties/components/skills/Sk
import getProficiencyIcon from '/imports/client/ui/utility/getProficiencyIcon';
import sortEffects from '/imports/client/ui/utility/sortEffects';
import PropertyTargetTags from '/imports/client/ui/properties/viewers/shared/PropertyTargetTags.vue';
import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
Expand Down Expand Up @@ -201,12 +202,12 @@ export default {
let ability = this.model.ability;
if (!creatureId || !ability) return;
let abilityProp = CreatureProperties.findOne({
...getFilter.descendantsOfRoot(creatureId),
variableName: ability,
type: 'attribute',
removed: { $ne: true },
inactive: { $ne: true },
overridden: { $ne: true },
'ancestors.id': creatureId,
});
if (!abilityProp) return;
return {
Expand All @@ -215,16 +216,16 @@ export default {
operation: 'base',
amount: { value: abilityProp.modifier },
stats: [this.model.variableName],
ancestors: abilityProp.ancestors,
root: abilityProp.root,
}
},
proficiencyBonus() {
return CreatureProperties.findOne({
...getFilter.descendantsOfRoot(this.context.creatureId),
variableName: 'proficiencyBonus',
overridden: { $ne: true },
removed: { $ne: true },
inactive: { $ne: true },
'ancestors.id': this.context.creatureId,
})?.value;
},
},
Expand Down
15 changes: 8 additions & 7 deletions app/imports/client/ui/tabletop/TabletopActionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import TreeNodeList from '/imports/client/ui/components/tree/TreeNodeList.vue';
import { docsToForest } from '/imports/api/parenting/parentingFunctions';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
import { some } from 'lodash';
import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
Expand Down Expand Up @@ -184,28 +185,28 @@ export default {
},
meteor: {
children() {
const indicesOfTerminatingProps = [];
const excludedRanges = [];
const decendants = CreatureProperties.find({
'ancestors.id': this.model._id,
...getFilter.descendants(this.model),
'removed': { $ne: true },
}, {
sort: {left: 1}
}).map(prop => {
// Get all the props we don't want to show the decendants of and
// where they might appear in the ancestor list
if (prop.type === 'buff' || prop.type === 'folder') {
indicesOfTerminatingProps.push({
id: prop._id,
ancestorIndex: prop.ancestors.length,
excludedRanges.push({
left: prop.left,
right: prop.right,
});
}
return prop;
}).filter(prop => {
// Filter out folders entirely
if (prop.type === 'folder') return false;
// Filter out decendants of terminating props
return !some(indicesOfTerminatingProps, buffIndex => {
return prop.ancestors[buffIndex.ancestorIndex]?.id === buffIndex.id;
return !some(excludedRanges, range => {
return prop.left > range.left && prop.right < range.right;
});
});
return docsToForest(decendants);
Expand Down
29 changes: 14 additions & 15 deletions app/imports/client/ui/tabletop/TabletopBuffCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import TreeNodeList from '/imports/client/ui/components/tree/TreeNodeList.vue';
import { docsToForest } from '/imports/api/parenting/parentingFunctions';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
import { some } from 'lodash';
import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
Expand Down Expand Up @@ -137,31 +138,29 @@ export default {
},
meteor: {
children() {
const indicesOfTerminatingProps = [];
const decendants = CreatureProperties.find({
'ancestors.id': this.model._id,
const excludedRanges = [];
const descendants = CreatureProperties.find({
...getFilter.descendants(this.model),
'removed': { $ne: true },
}, {
sort: {left: 1}
}).map(prop => {
// Get all the props we don't want to show the decendants of and
// where they might appear in the ancestor list
if (prop.type === 'buff' || prop.type === 'folder') {
indicesOfTerminatingProps.push({
id: prop._id,
ancestorIndex: prop.ancestors.length,
});
}
// Get all the props we don't want to show the descendants of and what range they cover in
// the tree
excludedRanges.push({
left: prop.left,
right: prop.right,
});
return prop;
}).filter(prop => {
// Filter out folders entirely
if (prop.type === 'folder') return false;
// Filter out decendants of terminating props
return !some(indicesOfTerminatingProps, buffIndex => {
return prop.ancestors[buffIndex.ancestorIndex]?.id === buffIndex.id;
// Filter out descendants of terminating props
return !some(excludedRanges, range => {
return prop.left > range.left && prop.right < range.right;
});
});
return docsToForest(decendants);
return docsToForest(descendants);
},
},
methods: {
Expand Down
Loading

0 comments on commit e8158ba

Please sign in to comment.