Fixed stats being displayed for all subscribed creatures instead of the current creature
This commit is contained in:
@@ -52,10 +52,10 @@
|
||||
<v-content class="flex" v-if="$subReady.singleCharacter">
|
||||
<v-tabs-items v-model="tab">
|
||||
<v-tab-item>
|
||||
<stats-tab/>
|
||||
<stats-tab :creature-id="creatureId"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<features-tab/>
|
||||
<features-tab :creature-id="creatureId"/>
|
||||
</v-tab-item>
|
||||
<v-tab-item>
|
||||
<tree-tab :creature-id="creatureId"/>
|
||||
|
||||
@@ -15,15 +15,14 @@
|
||||
|
||||
<script>
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import Features, { updateFeature } from '/imports/api/properties/Features.js';
|
||||
import { insertFeature } from '/imports/api/properties/Features.js';
|
||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
||||
import FeatureCard from '/imports/ui/properties/components/features/FeatureCard.vue';
|
||||
import { evaluateComputation, evaluateStringWithVariables } from '/imports/ui/utility/evaluate.js';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
charId: String,
|
||||
creatureId: String,
|
||||
},
|
||||
components: {
|
||||
ColumnLayout,
|
||||
@@ -31,33 +30,24 @@
|
||||
},
|
||||
meteor: {
|
||||
features(){
|
||||
let char = Creatures.findOne(this.charId, {fields: {variables: 1}});
|
||||
let char = Creatures.findOne(this.creatureId, {fields: {variables: 1}});
|
||||
if (!char) return [];
|
||||
let vars = char.variables;
|
||||
return Features.find({
|
||||
charId: this.charId,
|
||||
console.log('finding features for', this.creatureId);
|
||||
return CreatureProperties.find({
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'feature',
|
||||
removed: {$ne: true},
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
}).map(f => {
|
||||
console.log(f);
|
||||
f.description = evaluateStringWithVariables(f.description, vars);
|
||||
return f;
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
insertFeature(){
|
||||
const charId = this.charId;
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'feature-creation-dialog',
|
||||
elementId: 'insert-feature-fab',
|
||||
callback(feature){
|
||||
if (!feature) return;
|
||||
feature.charId = charId;
|
||||
let featureId = insertFeature.call(feature);
|
||||
return featureId
|
||||
}
|
||||
});
|
||||
},
|
||||
updateFeature({_id, update}, ack){
|
||||
updateFeature.call({_id, update}, error => {
|
||||
if (ack){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="stats-tab ma-2">
|
||||
|
||||
<div class="px-2 pt-2">
|
||||
<health-bar-card-container :charId="charId"/>
|
||||
<health-bar-card-container :creature-id="creatureId"/>
|
||||
</div>
|
||||
|
||||
<column-layout>
|
||||
@@ -141,8 +141,9 @@
|
||||
let adjustAttribute = insertAttribute = () => console.error("this shit isn't defined");
|
||||
|
||||
const getAttributeOfType = function(charId, type){
|
||||
console.log({charId})
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': charId,
|
||||
'ancestors.id': charId,
|
||||
type: 'attribute',
|
||||
attributeType: type,
|
||||
removed: {$ne: true},
|
||||
@@ -153,7 +154,7 @@
|
||||
|
||||
const getNonZeroAttributeOfType = function(charId, type){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': charId,
|
||||
'ancestors.id': charId,
|
||||
type: 'attribute',
|
||||
attributeType: type,
|
||||
value: {$ne: 0},
|
||||
@@ -165,7 +166,7 @@
|
||||
|
||||
export default {
|
||||
props: {
|
||||
charId: String,
|
||||
creatureId: String,
|
||||
},
|
||||
components: {
|
||||
AbilityListTile,
|
||||
@@ -179,23 +180,23 @@
|
||||
},
|
||||
meteor: {
|
||||
abilities(){
|
||||
return getAttributeOfType(this.charId, 'ability');
|
||||
return getAttributeOfType(this.creatureId, 'ability');
|
||||
},
|
||||
stats(){
|
||||
return getAttributeOfType(this.charId, 'stat');
|
||||
return getAttributeOfType(this.creatureId, 'stat');
|
||||
},
|
||||
modifiers(){
|
||||
return getAttributeOfType(this.charId, 'modifier');
|
||||
return getAttributeOfType(this.creatureId, 'modifier');
|
||||
},
|
||||
resources(){
|
||||
return getNonZeroAttributeOfType(this.charId, 'resource');
|
||||
return getNonZeroAttributeOfType(this.creatureId, 'resource');
|
||||
},
|
||||
spellSlots(){
|
||||
return getNonZeroAttributeOfType(this.charId, 'spellSlot');
|
||||
return getNonZeroAttributeOfType(this.creatureId, 'spellSlot');
|
||||
},
|
||||
hitDice(){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'attribute',
|
||||
attributeType: 'hitDice',
|
||||
value: {$ne: 0},
|
||||
@@ -205,7 +206,7 @@
|
||||
let diceMatch = hd.variableName.match(/d(\d+)/);
|
||||
let dice = diceMatch && +diceMatch[1];
|
||||
let con = CreatureProperties.findOne({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'attribute',
|
||||
variableName: 'constitution'
|
||||
});
|
||||
@@ -222,7 +223,7 @@
|
||||
},
|
||||
checks(){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'skill',
|
||||
skillType: 'check',
|
||||
}, {
|
||||
@@ -231,7 +232,7 @@
|
||||
},
|
||||
savingThrows(){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'skill',
|
||||
skillType: 'save',
|
||||
}, {
|
||||
@@ -240,7 +241,7 @@
|
||||
},
|
||||
skills(){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'skill',
|
||||
skillType: 'skill',
|
||||
}, {
|
||||
@@ -261,19 +262,6 @@
|
||||
damageProperty.call({_id, operation: 'increment' ,value: -value});
|
||||
}
|
||||
},
|
||||
insertAttribute(){
|
||||
const charId = this.charId;
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'attribute-creation-dialog',
|
||||
elementId: 'insert-attribute-fab',
|
||||
callback(attribute){
|
||||
if (!attribute) return;
|
||||
attribute.charId = charId;
|
||||
let attId = insertAttribute.call({attribute});
|
||||
return attId
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
HealthBarCard,
|
||||
},
|
||||
props: {
|
||||
charId: String,
|
||||
creatureId: String,
|
||||
},
|
||||
meteor: {
|
||||
attributes(){
|
||||
return CreatureProperties.find({
|
||||
'ancestor.id': this.charId,
|
||||
'ancestors.id': this.creatureId,
|
||||
type: 'attribute',
|
||||
attributeType: 'healthBar',
|
||||
value: {$ne: 0},
|
||||
|
||||
Reference in New Issue
Block a user