Migrating character sheet to new data format

This commit is contained in:
Stefan Zermatten
2020-01-16 08:55:53 +02:00
parent eabc0aa32e
commit 4ee7307e34
8 changed files with 63 additions and 53 deletions

View File

@@ -27,22 +27,10 @@
<v-content class="flex" v-if="$subReady.singleCharacter">
<v-tabs-items v-model="tab">
<v-tab-item>
<!--<stats-tab/>-->
<v-alert
:value="true"
type="info"
>
This tab is not available in this version of the alpha.
</v-alert>
<stats-tab/>
</v-tab-item>
<v-tab-item>
<!--<features-tab/>-->
<v-alert
:value="true"
type="info"
>
This tab is not available in this version of the alpha.
</v-alert>
<features-tab/>
</v-tab-item>
<v-tab-item>
<tree-tab :creature-id="creatureId"/>
@@ -60,9 +48,9 @@
import isDarkColor from '/imports/ui/utility/isDarkColor.js';
import { mapMutations } from "vuex";
import { theme } from '/imports/ui/theme.js';
import TreeTab from '/imports/ui/creature/character/TreeTab.vue';
import StatsTab from '/imports/ui/creature/character/StatsTab.vue';
import FeaturesTab from '/imports/ui/creature/character/FeaturesTab.vue';
import TreeTab from '/imports/ui/creature/character/characterSheetTabs/TreeTab.vue';
import StatsTab from '/imports/ui/creature/character/characterSheetTabs/StatsTab.vue';
import FeaturesTab from '/imports/ui/creature/character/characterSheetTabs/FeaturesTab.vue';
import { recomputeCreature } from '/imports/api/creature/creatureComputation.js'
export default {
@@ -72,6 +60,8 @@
},
components: {
TreeTab,
StatsTab,
FeaturesTab,
},
data(){return {
theme,

View File

@@ -138,8 +138,8 @@
</template>
<script>
import Attributes from '/imports/api/properties/Attributes.js';
import Skills from '/imports/api/properties/Skills.js';
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import AttributeCard from '/imports/ui/properties/attributes/AttributeCard.vue';
import AbilityListTile from '/imports/ui/properties/attributes/AbilityListTile.vue';
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
@@ -149,17 +149,24 @@
import ResourceCard from '/imports/ui/properties/attributes/ResourceCard.vue';
import SpellSlotListTile from '/imports/ui/properties/attributes/SpellSlotListTile.vue';
import { adjustAttribute, insertAttribute } from '/imports/api/properties/Attributes.js';
let adjustAttribute = insertAttribute = () => console.error("this shit isn't defined");
const getAttributeOfType = function(charId, type){
return Attributes.find({charId, type}, {sort: {order: 1}});
return CreatureProperties.find({
'ancestor.id': charId,
type: 'attribute',
attributeType: type,
}, {
sort: {order: 1}
});
};
const getNonZeroAttributeOfType = function(charId, type){
return Attributes.find({
charId,
type,
value: {$ne: 0},
return CreatureProperties.find({
'ancestor.id': charId,
type: 'attribute',
attributeType: type,
value: {$ne: 0}
}, {
sort: {order: 1}
});
@@ -196,17 +203,19 @@
return getNonZeroAttributeOfType(this.charId, 'spellSlot');
},
hitDice(){
return Attributes.find({
charId: this.charId,
type: 'hitDice',
return CreatureProperties.find({
'ancestor.id': this.charId,
type: 'attribute',
attributeType: 'hitDice',
value: {$ne: 0},
}, {
sort: {order: 1},
}).map(hd => {
let diceMatch = hd.variableName.match(/d(\d+)/);
let dice = diceMatch && +diceMatch[1];
let con = Attributes.findOne({
charId: this.charId,
let con = CreatureProperties.findOne({
'ancestor.id': this.charId,
type: 'attribute',
variableName: 'constitution'
});
let conMod = con && con.mod;
@@ -221,25 +230,28 @@
});
},
checks(){
return Skills.find({
charId: this.charId,
type: 'check',
return CreatureProperties.find({
'ancestor.id': this.charId,
type: 'skill',
skillType: 'check',
}, {
sort: {order: 1},
});
},
savingThrows(){
return Skills.find({
charId: this.charId,
type: 'save',
return CreatureProperties.find({
'ancestor.id': this.charId,
type: 'skill',
skillType: 'save',
}, {
sort: {order: 1},
});
},
skills(){
return Skills.find({
charId: this.charId,
return CreatureProperties.find({
'ancestor.id': this.charId,
type: 'skill',
skillType: 'skill',
}, {
sort: {order: 1},
});

View File

@@ -139,7 +139,7 @@
editCreatureProperty(){
let that = this;
this.$store.commit('pushDialogStack', {
component: 'library-node-edit-dialog',
component: 'creature-property-dialog',
elementId: 'selected-node-card',
data: {_id: this.selected},
});

View File

@@ -0,0 +1,11 @@
<template lang="html">
</template>
<script>
export default {
}
</script>
<style lang="css" scoped>
</style>

View File

@@ -2,6 +2,7 @@ import AttributeDialog from '/imports/ui/properties/attributes/AttributeDialog.v
import AttributeDialogContainer from '/imports/ui/properties/attributes/AttributeDialogContainer.vue';
import AttributeCreationDialog from '/imports/ui/properties/attributes/AttributeCreationDialog.vue';
import CreaturePropertyCreationDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyCreationDialog.vue';
import CreaturePropertyDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyDialog.vue'
import CreaturePropertyFromLibraryDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyFromLibraryDialog.vue'
import FeatureCreationDialog from '/imports/ui/properties/features/FeatureCreationDialog.vue';
import FeatureDialogContainer from '/imports/ui/properties/features/FeatureDialogContainer.vue';
@@ -15,6 +16,7 @@ export default {
AttributeDialogContainer,
AttributeCreationDialog,
CreaturePropertyCreationDialog,
CreaturePropertyDialog,
CreaturePropertyFromLibraryDialog,
FeatureCreationDialog,
FeatureDialogContainer,

View File

@@ -8,13 +8,7 @@
<script>
import AttributeDialog from '/imports/ui/properties/attributes/AttributeDialog.vue';
import Attributes from '/imports/api/properties/Attributes.js';
import {
updateAttribute,
adjustAttribute
} from '/imports/api/properties/Attributes.js';
import Effects from '/imports/api/properties/Effects.js';
import { setName } from '/imports/api/parenting/parenting.js';
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
export default {
components: {
@@ -31,8 +25,9 @@
if (!this.attribute) return;
let charId = this.attribute.charId;
let stat = this.attribute.variableName;
return Effects.find({
charId,
return CreatureProperties.find({
'ancestor.id': charId,
type: 'effect',
stat,
enabled: true,
}, {

View File

@@ -7,8 +7,7 @@
</template>
<script>
import Attributes from '/imports/api/properties/Attributes.js';
import { adjustAttribute } from '/imports/api/properties/Attributes.js';
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import HealthBarCard from '/imports/ui/properties/attributes/HealthBarCard.vue';
export default {
@@ -20,9 +19,10 @@
},
meteor: {
attributes(){
return Attributes.find({
charId: this.charId,
type: 'healthBar',
return CreatureProperties.find({
'ancestor.id': this.charId,
type: 'attribute',
attributeType: 'healthBar',
value: {$ne: 0},
}, {
sort: {order: 1},