From 9ddac7d5cd09a4eb9a0bb4fa1565ecc46209a5c7 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 29 Jul 2017 21:25:05 +0100 Subject: [PATCH] Temporary HP (the attribute) now appears on Stats page --- .../character/stats/healthCard/healthCard.css | 19 ++++++++++++- .../stats/healthCard/healthCard.html | 27 ++++++++++++++++--- .../character/stats/healthCard/healthCard.js | 11 ++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.css b/rpg-docs/client/views/character/stats/healthCard/healthCard.css index 03733970..761e9666 100644 --- a/rpg-docs/client/views/character/stats/healthCard/healthCard.css +++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.css @@ -3,10 +3,27 @@ margin-right: 8px; } +.healthCard #temporaryHitPointSlider { + --paper-diff-slider-active-color: #009688; /* teal */ + --paper-diff-slider-knob-color: #009688; /* these don't seem to work? */ + --paper-diff-slider-pin-color: #009688; +} + +.healthCard .tempHitPointSlider { + --paper-diff-slider-active-color: #00BCD4; /* cyan */ + --paper-diff-slider-knob-color: #00BCD4; /* these don't seem to work? */ + --paper-diff-slider-pin-color: #00BCD4; +} + +.healthCard .bottom-border { + border-bottom: rgba(0,0,0,0.24) solid 1px; + margin-bottom: 12px; +} + .healthCard #stableButton { color: #b71c1c; transition: color 0.4s ease; - width: 100% + width: 100%; } .healthCard #stableButton:before { diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.html b/rpg-docs/client/views/character/stats/healthCard/healthCard.html index 86051139..0bb6c558 100644 --- a/rpg-docs/client/views/character/stats/healthCard/healthCard.html +++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.html @@ -11,17 +11,35 @@
+
- {{#each tempHitPoints}} -
- {{name}} + {{#if characterCalculate "attributeBase" _id "tempHP"}} + +
+
+ Temporary Hit Points +
+ +
+ {{/if}} + + {{#each tempHitPoints}}
+
+ {{name}} +
{{#unless left}} @@ -31,7 +49,8 @@ max={{maximum}} value={{left}} editable pin - > + > +
{{/each}}
diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.js b/rpg-docs/client/views/character/stats/healthCard/healthCard.js index 86b93574..8ee6501f 100644 --- a/rpg-docs/client/views/character/stats/healthCard/healthCard.js +++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.js @@ -5,7 +5,7 @@ Template.healthCard.binding({ "#hitPointSlider": { max: () => Characters.calculate.attributeBase(currentId() , "hitPoints"), value: () => Characters.calculate.attributeValue(currentId() , "hitPoints"), - } + }, }); // Reset the old value between characters so that we don't get red health lost @@ -16,6 +16,7 @@ Template.healthCard.onRendered(function(){ const id = Template.currentData()._id; if (oldId !== id){ this.find("#hitPointSlider").resetOldValue(); + this.find("#temporaryHitPointSlider").resetOldValue(); oldId = id; } }); @@ -93,7 +94,13 @@ Template.healthCard.events({ }} ); }, - "change .tempHitPointSlider": function(event){ + "change #temporaryHitPointSlider": function(event){ //this is the actual THP stat + var value = event.currentTarget.value; + var base = Characters.calculate.attributeBase(this._id, "tempHP"); + var adjustment = value - base; + Characters.update(this._id, {$set: {"tempHP.adjustment": adjustment}}); + }, + "change .tempHitPointSlider": function(event){ //this is the extra bars var value = event.currentTarget.value; var used = this.maximum - value; TemporaryHitPoints.update(this._id, {$set: {"used": used}});