diff --git a/rpg-docs/client/views/character/spells/spells.js b/rpg-docs/client/views/character/spells/spells.js
index f8baf8cc..fe467f79 100644
--- a/rpg-docs/client/views/character/spells/spells.js
+++ b/rpg-docs/client/views/character/spells/spells.js
@@ -46,7 +46,7 @@ Template.spells.helpers({
}
if(this.components.material){
components += components? ", M" : "M";
- components += "("+this.components.material+")";
+ components += " ("+this.components.material+")";
}
if(this.components.concentration){
components += " - Requires concentration"
@@ -83,6 +83,14 @@ Template.spells.helpers({
showSlots: function(char){
return this.level && char.attributeBase("level" + this.level +"SpellSlots");
},
+ hasSlots: function(){
+ for(var i = 1; i <= 9; i += 1){
+ if(this.attributeBase("level"+i+"SpellSlots")){
+ return true;
+ }
+ }
+ return false;
+ },
slotBubbles: function(char){
var baseSlots = char.attributeBase("level" + this.level +"SpellSlots"),
currentSlots = char.attributeValue("level" + this.level +"SpellSlots"),
@@ -165,7 +173,8 @@ Template.spells.events({
Spells.insert({
name: "New Spell",
charId: this._id,
- listId: SpellLists.findOne({charId: this._id})._id
+ listId: SpellLists.findOne({charId: this._id})._id,
+ prepared: "prepared"
}, function(error, id){
if(!error){
GlobalUI.setDetail({
diff --git a/rpg-docs/client/views/character/healthCard/healthCard.css b/rpg-docs/client/views/character/stats/healthCard/healthCard.css
similarity index 100%
rename from rpg-docs/client/views/character/healthCard/healthCard.css
rename to rpg-docs/client/views/character/stats/healthCard/healthCard.css
diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.html b/rpg-docs/client/views/character/stats/healthCard/healthCard.html
new file mode 100644
index 00000000..ed2154d4
--- /dev/null
+++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.html
@@ -0,0 +1,53 @@
+
+
+
+ Hit Points
+
+
+
+ {{#if showDeathSave}}
+ {{#with deathSaveObject}}
+
+
+ Death Saves
+
+
+
+
+ {{#if dead}}
+ DEAD
+ {{else}}
+ {{#if stable}}
+
Stable
+ {{else}}
+
Unstable
+ {{/if}}
+ {{/if}}
+
+
+
+
+ {{/with}}
+ {{/if}}
+
+
+
diff --git a/rpg-docs/client/views/character/stats/healthCard/healthCard.js b/rpg-docs/client/views/character/stats/healthCard/healthCard.js
new file mode 100644
index 00000000..e64b964a
--- /dev/null
+++ b/rpg-docs/client/views/character/stats/healthCard/healthCard.js
@@ -0,0 +1,61 @@
+Template.healthCard.helpers({
+ showDeathSave: function(){
+ return this.attributeValue("hitPoints") <= 0;
+ },
+ deathSaveObject: function(){
+ var char = Characters.findOne(this._id, {fields: {deathSave: 1}});
+ return char && char.deathSave;
+ },
+ failIcon: function(num){
+ console.log("checking ", num, " against fail", this)
+ if(num <= this.fail) return "radio-button-on";
+ else return "radio-button-off";
+ },
+ passIcon: function(num){
+ if(num <= this.pass) return "radio-button-on";
+ else return "radio-button-off";
+ },
+ failDisabled: function(num){
+ return !(num === this.fail || num - 1 === this.fail)
+ },
+ passDisabled: function(num){
+ return !(num === this.pass || num - 1 === this.pass)
+ },
+ dead: function(char){
+ return this.fail >= 3;
+ }
+})
+
+Template.healthCard.events({
+ "change #hitPointSlider": function(event){
+ var value = event.currentTarget.value;
+ var adjustment = value - this.attributeBase("hitPoints");
+ Characters.update(this._id, {$set: {"hitPoints.adjustment": adjustment}});
+ },
+ "tap .failBubble": function(event){
+ if(event.currentTarget.disabled) return;
+ var char = Template.parentData();
+ if(event.currentTarget.icon === "radio-button-off"){
+ Characters.update(char._id, {$set: {"deathSave.fail": this.fail + 1}});
+ } else{
+ Characters.update(char._id, {$set: {"deathSave.fail": this.fail - 1}});
+ }
+ },
+ "tap .passBubble": function(event){
+ if(event.currentTarget.disabled) return;
+ var char = Template.parentData();
+ if(event.currentTarget.icon === "radio-button-off"){
+ Characters.update(char._id, {$set: {"deathSave.pass": this.pass + 1}});
+ } else{
+ Characters.update(char._id, {$set: {"deathSave.pass": this.pass - 1}});
+ }
+ },
+ "tap #stableButton": function(event){
+ var char = Template.parentData();
+ Characters.update(char._id, {$set: {"deathSave.stable": false}});
+ },
+ "tap #unstableButton": function(event){
+ var char = Template.parentData();
+ Characters.update(char._id, {$set: {"deathSave.stable": true}});
+ }
+});
diff --git a/rpg-docs/lib/functions/evaluate.js b/rpg-docs/lib/functions/evaluate.js
index 7d1ae307..e936345d 100644
--- a/rpg-docs/lib/functions/evaluate.js
+++ b/rpg-docs/lib/functions/evaluate.js
@@ -34,15 +34,9 @@ evaluateString = function(charId, string){
if(!string) return string;
var brackets = /\{[^\{\}]*\}/g;
var result = string.replace(brackets, function(exp){
- var exp = exp.replace(/(\{|\})/g, "") //remove brackets
- var span = jQuery('
', {
- title: exp,
- text: evaluate(charId, exp),
- class: "calculatedValue"
- });
- return span.prop('outerHTML');
+ var exp = exp.replace(/(\{|\})/g, "") //remove curly brackets
+ return evaluate(charId, exp);
});
- //this is going to return HTML, ensure it is santized!
return result;
}
diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js
index 56a831b8..85969e89 100644
--- a/rpg-docs/server/publications/singleCharacter.js
+++ b/rpg-docs/server/publications/singleCharacter.js
@@ -1,14 +1,19 @@
Meteor.publish("singleCharacter", function(characterId, userId){
//TODO check if this characer can be viewed by this user
return [
- Characters.find({_id: characterId}),
+ Characters.find({_id: characterId}),
+
+ Actions.find({charId: characterId}),
+ Attacks.find({charId: characterId}),
+ Classes.find({charId: characterId}),
Containers.find({charId: characterId}),
- Items.find({charId: characterId}),
- Features.find({charId: characterId}),
Effects.find({charId: characterId}),
+ Experiences.find({charId: characterId}),
+ Features.find({charId: characterId}),
+ Items.find({charId: characterId}),
+ Levels.find({charId: characterId}),
+ Notes.find({charId: characterId}),
Spells.find({charId: characterId}),
SpellLists.find({charId: characterId}),
- Notes.find({charId: characterId}),
- Experiences.find({charId: characterId})
];
});