From a387ce1c8ba14bdc83e551858539cad45e02cfc8 Mon Sep 17 00:00:00 2001 From: Thaum Date: Wed, 11 Mar 2015 07:52:30 +0000 Subject: [PATCH] Added UI for weakness/resistance --- rpg-docs/Model/Character/Characters.js | 28 ++++++++--------- .../Model/Character/SubSchemas/Attribute.js | 14 --------- .../effects/effectEdit/effectEdit.js | 2 +- .../stats/healthCard/healthCard.html | 6 ++++ .../character/stats/healthCard/healthCard.js | 26 +++++++++++++++- rpg-docs/lib/constants/damageTypes.js | 31 +++++++++++++++++++ 6 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 rpg-docs/lib/constants/damageTypes.js diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index a3c52296..e36d345c 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -61,19 +61,19 @@ Schemas.Character = new SimpleSchema({ d12HitDice: {type: Schemas.Attribute}, //vulnerabilities - acidMultiplier: {type: Schemas.Vulnerability}, - bludgeoningMultiplier: {type: Schemas.Vulnerability}, - coldMultiplier: {type: Schemas.Vulnerability}, - fireMultiplier: {type: Schemas.Vulnerability}, - forceMultiplier: {type: Schemas.Vulnerability}, - lightningMultiplier: {type: Schemas.Vulnerability}, - necroticMultiplier: {type: Schemas.Vulnerability}, - piercingMultiplier: {type: Schemas.Vulnerability}, - poisonMultiplier: {type: Schemas.Vulnerability}, - psychicMultiplier: {type: Schemas.Vulnerability}, - radiantMultiplier: {type: Schemas.Vulnerability}, - slashingMultiplier: {type: Schemas.Vulnerability}, - thunderMultiplier: {type: Schemas.Vulnerability}, + acidMultiplier: {type: Schemas.Attribute}, + bludgeoningMultiplier: {type: Schemas.Attribute}, + coldMultiplier: {type: Schemas.Attribute}, + fireMultiplier: {type: Schemas.Attribute}, + forceMultiplier: {type: Schemas.Attribute}, + lightningMultiplier: {type: Schemas.Attribute}, + necroticMultiplier: {type: Schemas.Attribute}, + piercingMultiplier: {type: Schemas.Attribute}, + poisonMultiplier: {type: Schemas.Attribute}, + psychicMultiplier: {type: Schemas.Attribute}, + radiantMultiplier: {type: Schemas.Attribute}, + slashingMultiplier: {type: Schemas.Attribute}, + thunderMultiplier: {type: Schemas.Attribute}, //skills @@ -178,7 +178,7 @@ var attributeBase = function(charId, statName){ check(statName, String); var effects = Effects.find({charId: charId, stat: statName, enabled: true}).fetch(); effects = _.groupBy(effects, "operation"); - var value = 0; + var value = _.contains(DAMAGE_MULTIPLIERS, statName)? 1 : 0; //start with the highest base value _.each(effects.base, function(effect){ diff --git a/rpg-docs/Model/Character/SubSchemas/Attribute.js b/rpg-docs/Model/Character/SubSchemas/Attribute.js index 69cf05cf..a6f9499a 100644 --- a/rpg-docs/Model/Character/SubSchemas/Attribute.js +++ b/rpg-docs/Model/Character/SubSchemas/Attribute.js @@ -11,17 +11,3 @@ Schemas.Attribute = new SimpleSchema({ allowedValues: ["longRest", "shortRest"] } }); - -//note that to make an invulnerability add a new max of zero value -Schemas.Vulnerability = new SimpleSchema({ - //same as attribute - adjustment: { - type: Number, - defaultValue: 0 - }, - reset: { - type: String, - defaultValue: "longRest", - allowedValues: ["longRest", "shortRest"] - } -}); diff --git a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js index ceab7f93..ac8a5a47 100644 --- a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js +++ b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js @@ -175,7 +175,7 @@ Template.effectEdit.events({ if(!detail.isSelected) return; var value = +detail.item.getAttribute("name"); if (value == this.value) return; - Effects.update(this._id, {$set: {value: value, calculation: ""}}); + Effects.update(this._id, {$set: {value: value, calculation: "", operation: "mul"}}); }, "core-select #proficiencyDropDown": function(event){ var detail = event.originalEvent.detail; diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.html b/rpg-docs/client/views/character/stats/healthCard/healthCard.html index ed2154d4..ccaf35e4 100644 --- a/rpg-docs/client/views/character/stats/healthCard/healthCard.html +++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.html @@ -10,6 +10,12 @@ editable pin role="slider" > + +
+ {{#if multipliers.immunities.length}}
Immune: {{#each multipliers.immunities}} {{name}} {{/each}}
{{/if}} + {{#if multipliers.resistances.length}}
Resistance: {{#each multipliers.resistances}} {{name}} {{/each}}
{{/if}} + {{#if multipliers.weaknesses.length}}
Weakness: {{#each multipliers.weaknesses}} {{name}} {{/each}}
{{/if}} +
{{#if showDeathSave}} {{#with deathSaveObject}}
diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.js b/rpg-docs/client/views/character/stats/healthCard/healthCard.js index 005611ff..7d16d3b0 100644 --- a/rpg-docs/client/views/character/stats/healthCard/healthCard.js +++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.js @@ -20,8 +20,32 @@ Template.healthCard.helpers({ passDisabled: function(num){ return !(num === this.pass || num - 1 === this.pass) }, - dead: function(char){ + dead: function(){ return this.fail >= 3; + }, + multipliers: function(){ + var char = Characters.findOne(this._id, {fields: {_id: 1} }); + var multipliers = [ + {name: "Acid", value: char.attributeValue("acidMultiplier", 1)}, + {name: "Bludgeoning", value: char.attributeValue("bludgeoningMultiplier", 1)}, + {name: "Cold", value: char.attributeValue("coldMultiplier", 1)}, + {name: "Fire", value: char.attributeValue("fireMultiplier", 1)}, + {name: "Force", value: char.attributeValue("forceMultiplier", 1)}, + {name: "Lightning", value: char.attributeValue("lightningMultiplier", 1)}, + {name: "Necrotic", value: char.attributeValue("necroticMultiplier", 1)}, + {name: "Piercing", value: char.attributeValue("piercingMultiplier", 1)}, + {name: "Poison", value: char.attributeValue("poisonMultiplier", 1)}, + {name: "Psychic", value: char.attributeValue("psychicMultiplier", 1)}, + {name: "Radiant", value: char.attributeValue("radiantMultiplier", 1)}, + {name: "Slashing", value: char.attributeValue("slashingMultiplier", 1)}, + {name: "Thunder", value: char.attributeValue("thunderMultiplier", 1)} + ]; + multipliers = _.groupBy(multipliers, "value"); + return { + "immunities": multipliers["0"] || [], + "resistances": multipliers["0.5"] || [], + "weaknesses": multipliers["2"] || [] + }; } }) diff --git a/rpg-docs/lib/constants/damageTypes.js b/rpg-docs/lib/constants/damageTypes.js new file mode 100644 index 00000000..1277e6fa --- /dev/null +++ b/rpg-docs/lib/constants/damageTypes.js @@ -0,0 +1,31 @@ +DAMAGE_TYPES = { + "acid": {name: "Acid"}, + "bludgeoning": {name: "Bludgeoning"}, + "cold": {name: "Cold"}, + "fire": {name: "Fire"}, + "force": {name: "Force"}, + "lightning": {name: "Lightning"}, + "necrotic": {name: "Necrotic"}, + "piercing": {name: "Piercing"}, + "poison": {name: "Poison"}, + "psychic": {name: "Psychic"}, + "radiant": {name: "Radiant"}, + "slashing": {name: "Slashing"}, + "thunder": {name: "Thunder"} +}; + +DAMAGE_MULTIPLIERS = [ + "acidMultiplier", + "bludgeoningMultiplier", + "coldMultiplier", + "fireMultiplier", + "forceMultiplier", + "lightningMultiplier", + "necroticMultiplier", + "piercingMultiplier", + "poisonMultiplier", + "psychicMultiplier", + "radiantMultiplier", + "slashingMultiplier", + "thunderMultiplier" +];