From 966fcc449db98292671088eedc646de97939667e Mon Sep 17 00:00:00 2001 From: Thaum Rystra Date: Tue, 28 Apr 2020 17:12:22 +0200 Subject: [PATCH] Hit dice now explicitly set their size --- app/imports/api/properties/Attributes.js | 6 + .../character/characterSheetTabs/StatsTab.vue | 29 +---- .../components/attributes/HitDiceListTile.vue | 119 +++++++++++------- .../ui/properties/forms/AttributeForm.vue | 21 ++++ .../ui/properties/viewers/AttributeViewer.vue | 67 +++++----- 5 files changed, 142 insertions(+), 100 deletions(-) diff --git a/app/imports/api/properties/Attributes.js b/app/imports/api/properties/Attributes.js index de72d92c..51746446 100644 --- a/app/imports/api/properties/Attributes.js +++ b/app/imports/api/properties/Attributes.js @@ -32,6 +32,12 @@ let AttributeSchema = new SimpleSchema({ ], defaultValue: 'stat', index: 1, + }, + // For type hitDice, the size needs to be stored separately + hitDiceSize: { + type: String, + allowedValues: ['d4', 'd6', 'd8', 'd10', 'd12', 'd20'], + optional: true, }, // The starting value, before effects baseValueCalculation: { diff --git a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue index 422cf17c..605bfa61 100644 --- a/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue +++ b/app/imports/ui/creature/character/characterSheetTabs/StatsTab.vue @@ -73,7 +73,7 @@ /> { - let diceMatch = hd.variableName.match(/d(\d+)/); - let dice = diceMatch && +diceMatch[1]; - let con = CreatureProperties.findOne({ - 'ancestors.id': this.creatureId, - type: 'attribute', - variableName: 'constitution', - removed: {$ne: true}, - }); - let conMod = con && con.mod; - return { - _id: hd._id, - dice, - conMod, - key: hd._id, - maxValue: hd.value, - value: hd.value - (hd.damage || 0), - } - }); + return getNonZeroAttributeOfType(this.creatureId, 'hitDice'); }, checks(){ return CreatureProperties.find({ diff --git a/app/imports/ui/properties/components/attributes/HitDiceListTile.vue b/app/imports/ui/properties/components/attributes/HitDiceListTile.vue index fd0c0347..b98aff68 100644 --- a/app/imports/ui/properties/components/attributes/HitDiceListTile.vue +++ b/app/imports/ui/properties/components/attributes/HitDiceListTile.vue @@ -1,58 +1,89 @@ diff --git a/app/imports/ui/properties/viewers/AttributeViewer.vue b/app/imports/ui/properties/viewers/AttributeViewer.vue index 79e392c3..fdbd1830 100644 --- a/app/imports/ui/properties/viewers/AttributeViewer.vue +++ b/app/imports/ui/properties/viewers/AttributeViewer.vue @@ -1,29 +1,37 @@