Weight carried, Net worth, and Attunement implemented and exposed in UI

This commit is contained in:
Stefan Zermatten
2021-02-24 13:41:30 +02:00
parent 8d95da8b7a
commit c248d8f4a0
16 changed files with 224 additions and 54 deletions

View File

@@ -92,8 +92,32 @@ let CreatureSchema = new SimpleSchema({
type: SimpleSchema.Integer, type: SimpleSchema.Integer,
defaultValue: 0, defaultValue: 0,
}, },
// Sum of all weights of items and containers that are carried // Inventory
'denormalizedStats.weightCarried': { 'denormalizedStats.weightTotal': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.weightEquipment': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.weightCarried': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.valueTotal': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.valueEquipment': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.valueCarried': {
type: Number,
defaultValue: 0,
},
'denormalizedStats.itemsAttuned': {
type: Number, type: Number,
defaultValue: 0, defaultValue: 0,
}, },

View File

@@ -9,6 +9,7 @@ import { assertEditPermission } from '/imports/api/creature/creaturePermissions.
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import { nodesToTree } from '/imports/api/parenting/parenting.js'; import { nodesToTree } from '/imports/api/parenting/parenting.js';
import applyProperties from '/imports/api/creature/actions/applyProperties.js'; import applyProperties from '/imports/api/creature/actions/applyProperties.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const doAction = new ValidatedMethod({ const doAction = new ValidatedMethod({
name: 'creatureProperties.doAction', name: 'creatureProperties.doAction',
@@ -43,6 +44,8 @@ const doAction = new ValidatedMethod({
}); });
doActionWork({action, creature, targets, method: this}); doActionWork({action, creature, targets, method: this});
// The acting creature might have used ammo
recomputeInventory(creature._id);
// recompute creatures // recompute creatures
recomputeCreatureByDoc(creature); recomputeCreatureByDoc(creature);
targets.forEach(target => { targets.forEach(target => {

View File

@@ -51,7 +51,7 @@ export default function spendResources({prop, log}){
// Now that we have confirmed that there are no errors, do actual work // Now that we have confirmed that there are no errors, do actual work
//Items //Items
itemQuantityAdjustments.forEach(adjustQuantityWork); itemQuantityAdjustments.forEach(adjustQuantityWork);
// Use uses // Use uses
if (prop.usesResult){ if (prop.usesResult){
CreatureProperties.update(prop._id, { CreatureProperties.update(prop._id, {

View File

@@ -4,7 +4,8 @@ import SimpleSchema from 'simpl-schema';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js'; import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
import { recomputePropertyDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
const adjustQuantity = new ValidatedMethod({ const adjustQuantity = new ValidatedMethod({
name: 'creatureProperties.adjustQuantity', name: 'creatureProperties.adjustQuantity',
@@ -30,8 +31,10 @@ const adjustQuantity = new ValidatedMethod({
// Do work // Do work
adjustQuantityWork({property, operation, value}); adjustQuantityWork({property, operation, value});
// Changing quantity does not change dependencies, recompute deps // Changing quantity does not change dependencies, but recomputing the
recomputePropertyDependencies(property); // inventory changes many deps at once, so recompute fully
recomputeCreatureByDoc(rootCreature);
recomputeInventory(rootCreature._id);
}, },
}); });

View File

@@ -4,6 +4,8 @@ import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js'; import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
import { organizeDoc } from '/imports/api/parenting/organizeMethods.js'; import { organizeDoc } from '/imports/api/parenting/organizeMethods.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js'; import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js';
export function getParentRefByTag(creatureId, tag){ export function getParentRefByTag(creatureId, tag){
@@ -49,7 +51,7 @@ const equipItem = new ValidatedMethod({
}); });
let tag = equipped ? INVENTORY_TAGS.equipment : INVENTORY_TAGS.carried; let tag = equipped ? INVENTORY_TAGS.equipment : INVENTORY_TAGS.carried;
let parentRef = getParentRefByTag(creature._id, tag); let parentRef = getParentRefByTag(creature._id, tag);
// organizeDoc handles recompuation
organizeDoc.call({ organizeDoc.call({
docRef: { docRef: {
id: _id, id: _id,
@@ -57,7 +59,11 @@ const equipItem = new ValidatedMethod({
}, },
parentRef, parentRef,
order: Number.MAX_SAFE_INTEGER, order: Number.MAX_SAFE_INTEGER,
skipRecompute: true,
}); });
recomputeInventory(creature._id);
recomputeCreatureByDoc(creature);
}, },
}); });

View File

@@ -6,6 +6,7 @@ import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js
import { reorderDocs } from '/imports/api/parenting/order.js'; import { reorderDocs } from '/imports/api/parenting/order.js';
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js'; import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const insertProperty = new ValidatedMethod({ const insertProperty = new ValidatedMethod({
name: 'creatureProperties.insert', name: 'creatureProperties.insert',
@@ -35,6 +36,11 @@ export function insertPropertyWork({property, creature}){
}); });
// Inserting the active status of the property needs to be denormalised // Inserting the active status of the property needs to be denormalised
recomputeInactiveProperties(creature._id); recomputeInactiveProperties(creature._id);
// Recompute the inventory if it has changed
if (property.type === 'item' || property.type === 'container'){
recomputeInventory(creature._id);
}
// Inserting a creature property invalidates dependencies: full recompute // Inserting a creature property invalidates dependencies: full recompute
recomputeCreatureByDoc(creature); recomputeCreatureByDoc(creature);
return _id; return _id;

View File

@@ -15,6 +15,7 @@ import {
} from '/imports/api/parenting/parenting.js'; } from '/imports/api/parenting/parenting.js';
import { reorderDocs } from '/imports/api/parenting/order.js'; import { reorderDocs } from '/imports/api/parenting/order.js';
import { setDocToLastOrder } from '/imports/api/parenting/order.js'; import { setDocToLastOrder } from '/imports/api/parenting/order.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const insertPropertyFromLibraryNode = new ValidatedMethod({ const insertPropertyFromLibraryNode = new ValidatedMethod({
name: 'creatureProperties.insertPropertyFromLibraryNode', name: 'creatureProperties.insertPropertyFromLibraryNode',
@@ -97,6 +98,8 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
// The library properties need to denormalise which of them are inactive // The library properties need to denormalise which of them are inactive
recomputeInactiveProperties(rootId); recomputeInactiveProperties(rootId);
// Some of the library properties may be items or containers
recomputeInventory(rootCreature._id);
// Inserting a creature property invalidates dependencies: full recompute // Inserting a creature property invalidates dependencies: full recompute
recomputeCreatureByDoc(rootCreature); recomputeCreatureByDoc(rootCreature);
// Return the docId of the last property, the inserted root property // Return the docId of the last property, the inserted root property

View File

@@ -7,6 +7,7 @@ import { restore } from '/imports/api/parenting/softRemove.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js'; import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const restoreProperty = new ValidatedMethod({ const restoreProperty = new ValidatedMethod({
name: 'creatureProperties.restore', name: 'creatureProperties.restore',
@@ -27,6 +28,8 @@ const restoreProperty = new ValidatedMethod({
// Do work // Do work
restore({_id, collection: CreatureProperties}); restore({_id, collection: CreatureProperties});
// Items and containers might be restored
recomputeInventory(rootCreature._id);
// Parents active status may have changed while it was deleted // Parents active status may have changed while it was deleted
recomputeInactiveProperties(rootCreature._id); recomputeInactiveProperties(rootCreature._id);
// Changes dependency tree by restoring children // Changes dependency tree by restoring children

View File

@@ -6,6 +6,7 @@ import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js
import { softRemove } from '/imports/api/parenting/softRemove.js'; import { softRemove } from '/imports/api/parenting/softRemove.js';
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const softRemoveProperty = new ValidatedMethod({ const softRemoveProperty = new ValidatedMethod({
name: 'creatureProperties.softRemove', name: 'creatureProperties.softRemove',
@@ -26,6 +27,8 @@ const softRemoveProperty = new ValidatedMethod({
// Do work // Do work
softRemove({_id, collection: CreatureProperties}); softRemove({_id, collection: CreatureProperties});
// Potentially changes items and containers
recomputeInventory(rootCreature._id);
// Changes dependency tree by removing children // Changes dependency tree by removing children
recomputeCreatureByDoc(rootCreature); recomputeCreatureByDoc(rootCreature);
} }

View File

@@ -5,6 +5,7 @@ import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js'; import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
const updateCreatureProperty = new ValidatedMethod({ const updateCreatureProperty = new ValidatedMethod({
name: 'creatureProperties.update', name: 'creatureProperties.update',
@@ -52,6 +53,11 @@ const updateCreatureProperty = new ValidatedMethod({
].includes(path[0])){ ].includes(path[0])){
recomputeInactiveProperties(rootCreature._id); recomputeInactiveProperties(rootCreature._id);
} }
if (property.type === 'item' || property.type === 'container'){
// Potentially changes items and containers
recomputeInventory(rootCreature._id);
}
// Updating a property is likely to change dependencies, do a full recompute // Updating a property is likely to change dependencies, do a full recompute
recomputeCreatureByDoc(rootCreature); recomputeCreatureByDoc(rootCreature);
}, },

View File

@@ -1,5 +1,6 @@
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import nodesToTree from '/imports/api/parenting/parenting.js'; import Creatures from '/imports/api/creature/Creatures.js';
import { nodesToTree } from '/imports/api/parenting/parenting.js';
export default function recomputeInventory(creatureId){ export default function recomputeInventory(creatureId){
let inventoryForest = nodesToTree({ let inventoryForest = nodesToTree({
@@ -10,27 +11,27 @@ export default function recomputeInventory(creatureId){
}, },
deactivatedByAncestor: {$ne: true}, deactivatedByAncestor: {$ne: true},
}); });
return getChildrenInventoryData(inventoryForest); let containersToWrite = [];
} let data = getChildrenInventoryData(inventoryForest, containersToWrite);
containersToWrite.forEach(container => {
function getChildrenInventoryData(forest){ CreatureProperties.update(container._id, {$set: {
let data = { contentsWeight: container.contentsWeight,
weightTotal: 0, contentsValue: container.contentsValue,
weightEquipment: 0, }}, {selector: {type: 'container'}});
weightCarried: 0,
valueTotal: 0,
valueEquipment: 0,
valueCarried: 0,
}
forest.forEach(tree => {
let treeData = getInventoryData(tree);
for (let key in data){
data[key] += treeData[key];
}
}); });
Creatures.update(creatureId, {$set: {
'denormalizedStats.weightTotal': data.weightTotal,
'denormalizedStats.weightEquipment': data.weightEquipment,
'denormalizedStats.weightCarried': data.weightCarried,
'denormalizedStats.valueTotal': data.valueTotal,
'denormalizedStats.valueEquipment': data.valueEquipment,
'denormalizedStats.valueCarried': data.valueCarried,
'denormalizedStats.itemsAttuned': data.itemsAttuned,
}});
return data;
} }
function getInventoryData(tree){ function getChildrenInventoryData(forest, containersToWrite){
let data = { let data = {
weightTotal: 0, weightTotal: 0,
weightEquipment: 0, weightEquipment: 0,
@@ -40,24 +41,41 @@ function getInventoryData(tree){
valueCarried: 0, valueCarried: 0,
itemsAttuned: 0, itemsAttuned: 0,
} }
let childData = getChildrenInventoryData(tree.children); forest.forEach(tree => {
let treeData = getInventoryData(tree, containersToWrite);
for (let key in data){
data[key] += treeData[key] || 0;
}
});
return data;
}
function getInventoryData(tree, containersToWrite){
let data = {
weightTotal: 0,
weightEquipment: 0,
weightCarried: 0,
valueTotal: 0,
valueEquipment: 0,
valueCarried: 0,
itemsAttuned: 0,
}
let childData = getChildrenInventoryData(tree.children, containersToWrite);
let node = tree.node; let node = tree.node;
if (node.type === 'container'){ if (node.type === 'container'){
data.weightTotal += node.weight; data.weightTotal += node.weight || 0;
data.valueTotal += node.value; data.valueTotal += node.value || 0;
if (node.carried){ data.weightCarried += node.weight || 0;
data.weightCarried += node.weight; data.valueCarried += node.value || 0;
data.valueCarried += node.valueCarried; storeContentsData(node, childData, containersToWrite);
}
storeContentsData(node, childData);
} else if (node.type === 'item'){ } else if (node.type === 'item'){
data.weightTotal += node.weight * node.quantity; data.weightTotal += (node.weight * node.quantity) || 0;
data.valueTotal += node.value * node.quantity; data.valueTotal += (node.value * node.quantity) || 0;
data.weightCarried += node.weight * node.quantity; data.weightCarried += (node.weight * node.quantity) || 0;
data.valueCarried += node.valueCarried * node.quantity; data.valueCarried += (node.value * node.quantity) || 0;
if (node.equipped){ if (node.equipped){
data.weightEquipment += node.weight * node.quantity; data.weightEquipment += (node.weight * node.quantity) || 0;
data.valueEquipment += node.valueCarried * node.quantity; data.valueEquipment += (node.value * node.quantity) || 0;
} }
if (node.attuned){ if (node.attuned){
data.itemsAttuned += 1; data.itemsAttuned += 1;
@@ -66,10 +84,14 @@ function getInventoryData(tree){
for (let key in data){ for (let key in data){
data[key] += childData[key]; data[key] += childData[key];
} }
if (node.carried === false){
data.weightCarried = 0;
data.valueCarried = 0;
}
return data return data
} }
function storeContentsData(node, childData){ function storeContentsData(node, childData, containersToWrite){
let newContentsWeight; let newContentsWeight;
if (node.contentsWeightless){ if (node.contentsWeightless){
newContentsWeight = 0; newContentsWeight = 0;
@@ -85,4 +107,7 @@ function storeContentsData(node, childData){
node.contentsValue = newContentsValue; node.contentsValue = newContentsValue;
node.contentsValueChanged = true; node.contentsValueChanged = true;
} }
if (node.contentsWeightChanged || node.contentsValueChanged){
containersToWrite.push(node);
}
} }

View File

@@ -20,13 +20,14 @@ const organizeDoc = new ValidatedMethod({
type: Number, type: Number,
// Should end in 0.5 to place it reliably between two existing documents // Should end in 0.5 to place it reliably between two existing documents
}, },
skipRecompute: Boolean,
}).validator(), }).validator(),
mixins: [RateLimiterMixin], mixins: [RateLimiterMixin],
rateLimit: { rateLimit: {
numRequests: 5, numRequests: 5,
timeInterval: 5000, timeInterval: 5000,
}, },
run({docRef, parentRef, order}) { run({docRef, parentRef, order, skipRecompute}) {
let doc = fetchDocByRef(docRef); let doc = fetchDocByRef(docRef);
let collection = getCollectionByName(docRef.collection); let collection = getCollectionByName(docRef.collection);
// The user must be able to edit both the doc and its parent to move it // The user must be able to edit both the doc and its parent to move it
@@ -52,15 +53,17 @@ const organizeDoc = new ValidatedMethod({
// Figure out which creatures need to be recalculated after this move // Figure out which creatures need to be recalculated after this move
let docCreatures = getCreatureAncestors(doc); let docCreatures = getCreatureAncestors(doc);
let parentCreatures = getCreatureAncestors(parent); let parentCreatures = getCreatureAncestors(parent);
let creaturesToRecompute = union(docCreatures, parentCreatures); if (!skipRecompute){
// Recompute the creatures let creaturesToRecompute = union(docCreatures, parentCreatures);
creaturesToRecompute.forEach(id => { // Recompute the creatures
// The active status of some properties might change due to a change in creaturesToRecompute.forEach(id => {
// ancestry // The active status of some properties might change due to a change in
recomputeInactiveProperties(id); // ancestry
// Some Dependencies depend on ancestry, so a full recompute is needed recomputeInactiveProperties(id);
recomputeCreatureById(id); // Some Dependencies depend on ancestry, so a full recompute is needed
}); recomputeCreatureById(id);
});
}
}, },
}); });

View File

@@ -3,6 +3,7 @@ import Creatures from '/imports/api/creature/Creatures.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js'; import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
import { assertViewPermission } from '/imports/api/creature/creaturePermissions.js'; import { assertViewPermission } from '/imports/api/creature/creaturePermissions.js';
import recomputeInvetory from '/imports/api/creature/denormalise/recomputeInventory.js';
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js'; import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
import VERSION from '/imports/constants/VERSION.js'; import VERSION from '/imports/constants/VERSION.js';
@@ -25,7 +26,10 @@ Meteor.publish('singleCharacter', function(creatureId){
try { assertViewPermission(creature, userId) } try { assertViewPermission(creature, userId) }
catch(e){ return [] } catch(e){ return [] }
if (creature.computeVersion !== VERSION){ if (creature.computeVersion !== VERSION){
try { recomputeCreatureById(creatureId) } try {
recomputeInvetory(creatureId);
recomputeCreatureById(creatureId)
}
catch(e){ console.error(e) } catch(e){ console.error(e) }
} }
return [ return [

View File

@@ -1,6 +1,59 @@
<template lang="html"> <template lang="html">
<div class="inventory"> <div class="inventory">
<column-layout wide-columns> <column-layout wide-columns>
<div>
<v-card>
<v-list>
<v-list-tile>
<v-list-tile-avatar>
<v-icon>$vuetify.icons.injustice</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>
Weight Carried
</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-list-tile-title>
{{ creature.denormalizedStats.weightCarried || 0 }} lbs
</v-list-tile-title>
</v-list-tile-action>
</v-list-tile>
<v-list-tile>
<v-list-tile-avatar>
<v-icon>$vuetify.icons.cash</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>
Net worth
</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-list-tile-title>
<coin-value
:value="creature.denormalizedStats.valueTotal || 0"
/>
</v-list-tile-title>
</v-list-tile-action>
</v-list-tile>
<v-list-tile v-if="creature.denormalizedStats.itemsAttuned">
<v-list-tile-avatar>
<v-icon>$vuetify.icons.spell</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>
Items attuned
</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-list-tile-title>
{{ creature.denormalizedStats.itemsAttuned }}
</v-list-tile-title>
</v-list-tile-action>
</v-list-tile>
</v-list>
</v-card>
</div>
<div> <div>
<toolbar-card <toolbar-card
:color="creature.color" :color="creature.color"
@@ -53,6 +106,7 @@ import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue'; import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue';
import { getParentRefByTag } from '/imports/api/creature/creatureProperties/methods/equipItem.js'; import { getParentRefByTag } from '/imports/api/creature/creatureProperties/methods/equipItem.js';
import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js'; import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js';
import CoinValue from '/imports/ui/components/CoinValue.vue';
export default { export default {
components: { components: {
@@ -60,6 +114,7 @@ export default {
ContainerCard, ContainerCard,
ToolbarCard, ToolbarCard,
ItemList, ItemList,
CoinValue,
}, },
props: { props: {
creatureId: { creatureId: {
@@ -82,7 +137,10 @@ export default {
}); });
}, },
creature(){ creature(){
return Creatures.findOne(this.creatureId, {fields: {color: 1}}); return Creatures.findOne(this.creatureId, {fields: {
color: 1,
denormalizedStats: 1,
}});
}, },
containersWithoutAncestorContainers(){ containersWithoutAncestorContainers(){
return CreatureProperties.find({ return CreatureProperties.find({

View File

@@ -15,7 +15,13 @@
{{ title }} {{ title }}
</v-list-tile-title> </v-list-tile-title>
</v-list-tile-content> </v-list-tile-content>
<v-list-tile-action> <v-list-tile-action
v-if="model.attuned"
style="min-width: 40px;"
>
<v-icon>$vuetify.icons.spell</v-icon>
</v-list-tile-action>
<v-list-tile-action style="min-width: 40px;">
<increment-button <increment-button
v-if="context.creatureId && model.showIncrement" v-if="context.creatureId && model.showIncrement"
icon icon

View File

@@ -89,6 +89,7 @@
row row
align-center align-center
justify-end justify-end
:class="{'mb-2': model.attuned}"
> >
<span class="title mr-2"> <span class="title mr-2">
{{ model.weight }} lb {{ model.weight }} lb
@@ -106,6 +107,22 @@
$vuetify.icons.weight $vuetify.icons.weight
</v-icon> </v-icon>
</v-layout> </v-layout>
<v-layout
v-if="model.attuned"
row
align-center
justify-end
>
<span class="title">
Attuned
</span>
<v-icon
class="ml-2"
x-large
>
$vuetify.icons.spell
</v-icon>
</v-layout>
</div> </div>
</div> </div>
<property-description <property-description