From e9a273244ab983f7bc3d1f60b5674333e2115879 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 22 Apr 2021 15:12:49 +0200 Subject: [PATCH] Improved Effect and Proficiency UI in attribute and skill viewers --- .../creatureProperties/Breadcrumbs.vue | 31 +++- .../components/attributes/AttributeEffect.vue | 138 +++++++++++++++++ .../components/skills/SkillProficiency.vue | 107 +++++++++++++ .../ui/properties/viewers/AttributeViewer.vue | 64 ++++++-- .../properties/viewers/ProficiencyViewer.vue | 26 ++-- .../ui/properties/viewers/SkillViewer.vue | 142 ++++++++++++++++-- 6 files changed, 467 insertions(+), 41 deletions(-) create mode 100644 app/imports/ui/properties/components/attributes/AttributeEffect.vue create mode 100644 app/imports/ui/properties/components/skills/SkillProficiency.vue diff --git a/app/imports/ui/creature/creatureProperties/Breadcrumbs.vue b/app/imports/ui/creature/creatureProperties/Breadcrumbs.vue index 8eef5676..c7f85f46 100644 --- a/app/imports/ui/creature/creatureProperties/Breadcrumbs.vue +++ b/app/imports/ui/creature/creatureProperties/Breadcrumbs.vue @@ -1,5 +1,8 @@ diff --git a/app/imports/ui/properties/viewers/SkillViewer.vue b/app/imports/ui/properties/viewers/SkillViewer.vue index fc9fc040..8eda4d46 100644 --- a/app/imports/ui/properties/viewers/SkillViewer.vue +++ b/app/imports/ui/properties/viewers/SkillViewer.vue @@ -40,18 +40,44 @@ :inactive="model.inactive" /> - - + + + @@ -60,11 +86,14 @@ import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'; import numberToSignedString from '/imports/ui/utility/numberToSignedString.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; -import EffectViewer from '/imports/ui/properties/viewers/EffectViewer.vue'; +import AttributeEffect from '/imports/ui/properties/components/attributes/AttributeEffect.vue'; +import SkillProficiency from '/imports/ui/properties/components/skills/SkillProficiency.vue'; +import Creatures from '/imports/api/creature/Creatures.js'; export default { components: { - EffectViewer, + AttributeEffect, + SkillProficiency, }, mixins: [propertyViewerMixin], inject: { @@ -94,8 +123,37 @@ export default { methods: { numberToSignedString, isFinite: Number.isFinite, + clickEffect(id){ + this.$store.commit('pushDialogStack', { + component: 'creature-property-dialog', + elementId: `${id}`, + data: {_id: id}, + }); + }, }, meteor: { + baseEffects(){ + if (this.context.creatureId){ + let creatureId = this.context.creatureId; + return CreatureProperties.find({ + 'ancestors.id': creatureId, + type: 'attribute', + variableName: this.model.variableName, + removed: {$ne: true}, + inactive: {$ne: true}, + }).map( prop => ({ + _id: prop._id, + name: 'Skill base value', + operation: 'base', + calculation: prop.baseValueCalculation, + result: prop.baseValue, + stats: [prop.variableName], + ancestors: prop.ancestors, + }) ).filter(effect => effect.result); + } else { + return []; + } + }, effects(){ if (this.context.creatureId){ let creatureId = this.context.creatureId; @@ -109,6 +167,70 @@ export default { return []; } }, + baseProficiencies(){ + if (this.context.creatureId){ + let creatureId = this.context.creatureId; + return CreatureProperties.find({ + 'ancestors.id': creatureId, + type: 'skill', + variableName: this.model.variableName, + removed: {$ne: true}, + inactive: {$ne: true}, + }).map( prop => ({ + _id: prop._id, + name: 'Skill base proficiency', + value: prop.baseProficiency, + stats: [prop.variableName], + ancestors: prop.ancestors, + }) ).filter(prof => prof.value); + } else { + return []; + } + }, + proficiencies(){ + let creatureId = this.context.creatureId; + if (creatureId){ + return CreatureProperties.find({ + 'ancestors.id': creatureId, + stats: this.model.variableName, + type: 'proficiency', + removed: {$ne: true}, + inactive: {$ne: true}, + }); + } else { + return []; + } + }, + ability(){ + let creatureId = this.context.creatureId; + let ability = this.model.ability; + if (!creatureId || !ability) return; + let abilityProp = CreatureProperties.findOne({ + 'ancestors.id': creatureId, + variableName: ability, + type: 'attribute', + removed: {$ne: true}, + inactive: {$ne: true}, + overridden: {$ne: true}, + }); + if (!abilityProp) return; + return { + _id: abilityProp._id, + name: abilityProp.name, + operation: 'base', + result: abilityProp.modifier, + stats: [this.model.variableName], + ancestors: abilityProp.ancestors, + } + }, + proficiencyBonus(){ + let creatureId = this.context.creatureId; + if (!creatureId) return; + let creature = Creatures.findOne(creatureId) + return creature && + creature.variables.proficiencyBonus && + creature.variables.proficiencyBonus.currentValue; + }, }, }