diff --git a/rpg-docs/Model/Character/Attacks.js b/rpg-docs/Model/Character/Attacks.js index 8d9b223e..70813a36 100644 --- a/rpg-docs/Model/Character/Attacks.js +++ b/rpg-docs/Model/Character/Attacks.js @@ -9,7 +9,8 @@ Schemas.Attack = new SimpleSchema({ regEx: SimpleSchema.RegEx.Id }, name: { - type: String + type: String, + defaultValue: "New Attack" }, range: { type: String, @@ -17,15 +18,24 @@ Schemas.Attack = new SimpleSchema({ }, attackBonus: { type: String, - optional: true + optional: true, + defaultValue: "strengthMod + proficiencyBonus" }, damage: { - type: String + type: String, + optional: true, + defaultValue: "1d8 + {strengthMod}" }, damageType: { type: String, - allowedValues: ["acid", "bludgeoning", "cold", "fire", "force", "lightning", "necrotic", - "piercing", "poison", "psychic", "radiant", "slashing", "thunder"] + allowedValues: ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire", "force", "lightning", "necrotic", + "poison", "psychic", "radiant", "thunder"], + defaultValue: "slashing" + }, + color: { + type: String, + allowedValues: _.pluck(colorOptions, "key"), + defaultValue: "q" } }); diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index f5f0cdf4..cb55cfe0 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -3,16 +3,18 @@ Characters = new Meteor.Collection("characters"); Schemas.Character = new SimpleSchema({ //strings - name: { type: String, defaultValue: "", trim: false}, - alignment: { type: String, defaultValue: "", trim: false}, - gender: { type: String, defaultValue: "", trim: false}, - race: { type: String, defaultValue: "", trim: false}, - description:{ type: String, defaultValue: "", trim: false}, - personality:{ type: String, defaultValue: "", trim: false}, - ideals: { type: String, defaultValue: "", trim: false}, - bonds: { type: String, defaultValue: "", trim: false}, - flaws: { type: String, defaultValue: "", trim: false}, - backstory: { type: String, defaultValue: "", trim: false}, + name: { type: String, defaultValue: "", trim: false}, + alignment: { type: String, defaultValue: "", trim: false}, + gender: { type: String, defaultValue: "", trim: false}, + race: { type: String, defaultValue: "", trim: false}, + description: { type: String, defaultValue: "", trim: false}, + personality: { type: String, defaultValue: "", trim: false}, + ideals: { type: String, defaultValue: "", trim: false}, + bonds: { type: String, defaultValue: "", trim: false}, + flaws: { type: String, defaultValue: "", trim: false}, + backstory: { type: String, defaultValue: "", trim: false}, + proficiencies:{ type: String, defaultValue: "", trim: false}, + languages: { type: String, defaultValue: "", trim: false}, //attributes //ability scores diff --git a/rpg-docs/Model/Character/Effects.js b/rpg-docs/Model/Character/Effects.js index 82194e05..8aa172c4 100644 --- a/rpg-docs/Model/Character/Effects.js +++ b/rpg-docs/Model/Character/Effects.js @@ -5,7 +5,7 @@ Effects = new Meteor.Collection("effects"); * that modify their final value or presentation in some way */ Schemas.Effect = new SimpleSchema({ - charId: { + charId: { type: String, regEx: SimpleSchema.RegEx.Id }, @@ -31,7 +31,7 @@ Schemas.Effect = new SimpleSchema({ type: { type: String, defaultValue: "editable", - allowedValues: ["editable", "feature", "buff", "equipment", "inate"] + allowedValues: ["editable", "feature", "level", "buff", "equipment", "racial", "inate"] }, //the id of the feature, buff or item that created this effect sourceId: { diff --git a/rpg-docs/Model/Character/Levels/Classes.js b/rpg-docs/Model/Character/Levels/Classes.js new file mode 100644 index 00000000..3e31ca01 --- /dev/null +++ b/rpg-docs/Model/Character/Levels/Classes.js @@ -0,0 +1,20 @@ +Classes = new Meteor.Collection("classes"); + +Schemas.Class = new SimpleSchema({ + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, + name: {type: String}, + createdAt: { + type: Date, + autoValue: function() { + if (this.isInsert) { + return new Date; + } else if (this.isUpsert) { + return {$setOnInsert: new Date}; + } else { + this.unset(); + } + } + }, +}); + +Classes.attachSchema(Schemas.Class); diff --git a/rpg-docs/Model/Character/Levels/Levels.js b/rpg-docs/Model/Character/Levels/Levels.js new file mode 100644 index 00000000..22d2f75d --- /dev/null +++ b/rpg-docs/Model/Character/Levels/Levels.js @@ -0,0 +1,9 @@ +Levels = new Meteor.Collection("levels"); + +Schemas.Level = new SimpleSchema({ + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, + classId: {type: String, regEx: SimpleSchema.RegEx.Id}, + value: {type: Number} +}); + +Levels.attachSchema(Schemas.Level); diff --git a/rpg-docs/Model/Character/SubSchemas/DeathSaves.js b/rpg-docs/Model/Character/SubSchemas/DeathSaves.js index 17ac17d5..00d7d8bb 100644 --- a/rpg-docs/Model/Character/SubSchemas/DeathSaves.js +++ b/rpg-docs/Model/Character/SubSchemas/DeathSaves.js @@ -14,5 +14,9 @@ Schemas.DeathSave = new SimpleSchema({ canDeathSave: { type: Boolean, defaultValue: true + }, + stable: { + type: Boolean, + defaultValue: false } }); \ No newline at end of file diff --git a/rpg-docs/Model/Inventory/Containers.js b/rpg-docs/Model/Inventory/Containers.js index 25f3c5cd..7fff43ec 100644 --- a/rpg-docs/Model/Inventory/Containers.js +++ b/rpg-docs/Model/Inventory/Containers.js @@ -1,7 +1,6 @@ //set up the collection for containers Containers = new Meteor.Collection("containers"); - Schemas.Container = new SimpleSchema({ name: { type: String }, charId: { type: String, regEx: SimpleSchema.RegEx.Id}, diff --git a/rpg-docs/client/globalHelpers/detailHero.js b/rpg-docs/client/globalHelpers/detailHero.js index e3221a64..ad24922f 100644 --- a/rpg-docs/client/globalHelpers/detailHero.js +++ b/rpg-docs/client/globalHelpers/detailHero.js @@ -1,5 +1,6 @@ -Template.registerHelper("detailHero", function(){ - if ( Session.equals("global.ui.detailHeroId", this._id) ) { +Template.registerHelper("detailHero", function(suffix){ + var id = suffix? this._id + suffix : this._id; + if ( Session.equals("global.ui.detailHeroId", id) ) { return "hero"; } }); \ No newline at end of file diff --git a/rpg-docs/client/globalHelpers/evaluate.js b/rpg-docs/client/globalHelpers/evaluate.js index 14b04ac8..25653dca 100644 --- a/rpg-docs/client/globalHelpers/evaluate.js +++ b/rpg-docs/client/globalHelpers/evaluate.js @@ -4,5 +4,13 @@ Template.registerHelper("evaluate", function(charId, string){ Template.registerHelper("evaluateSigned", function(charId, string){ var number = evaluate(charId, string); - return number > 0? "+" + number : "" + number; + if(_.isFinite(number)){ + return number > 0? "+" + number : "" + number; + } else{ + return number; + } +}); + +Template.registerHelper("evaluateString", function(charId, string){ + return evaluateString(charId, string); }); diff --git a/rpg-docs/client/globalHelpers/mongol.js b/rpg-docs/client/globalHelpers/mongol.js index 7aa522c7..8e46ef56 100644 --- a/rpg-docs/client/globalHelpers/mongol.js +++ b/rpg-docs/client/globalHelpers/mongol.js @@ -1,14 +1,18 @@ Session.set("Mongol", { 'collections': [ "Characters", + "Actions", + "Attacks", + "Classes", "Containers", - "Items", - "Features", "Effects", - "Spells", - "SpellLists", + "Experiences", + "Features", + "Items", + "Levels", "Notes", - "Experiences" + "Spells", + "SpellLists" ], 'display': true, 'opacity_normal': ".7", diff --git a/rpg-docs/client/views/GeneralCSS/general.css b/rpg-docs/client/views/GeneralCSS/general.css index 8fd32771..fa7cfc20 100644 --- a/rpg-docs/client/views/GeneralCSS/general.css +++ b/rpg-docs/client/views/GeneralCSS/general.css @@ -161,6 +161,10 @@ paper-fab-menu /deep/ .container { padding: 24px !important; } +paper-slider { + margin-left: -8px; +} + .list-subhead { color: rgba(0,0,0,0.54); font-size: 14px; @@ -169,6 +173,18 @@ paper-fab-menu /deep/ .container { font-weight: 500; } +.whiteTop { + border-bottom: rgba(0,0,0,0.12) solid 1px; + background: white; + padding: 16px; + position: relative; + border-radius: 2px 2px 0 0; +} + +.whiteTop paper-icon-button { + margin: -8px; +} + .fullwidth { width: 100%; } @@ -177,6 +193,26 @@ paper-fab-menu /deep/ .container { padding: 16px; } +.listPadded { + padding: 0 0 16px 0; +} + +.rightPadded { + padding-right: 16px; +} + +.bottomPadded { + padding-bottom: 16px; +} + +.s { + padding: 0 0 16px 0; +} + .leftRound{ border-radius: 2px 0 0 2px; } + +.preline { + white-space: pre-line; +} diff --git a/rpg-docs/client/views/GeneralCSS/typography.css b/rpg-docs/client/views/GeneralCSS/typography.css index 49bfa0f7..015b724f 100644 --- a/rpg-docs/client/views/GeneralCSS/typography.css +++ b/rpg-docs/client/views/GeneralCSS/typography.css @@ -101,3 +101,8 @@ p, .body1, body { html /deep/ .white-text{ color: #fff; } + +.black54 { + color: #444; + color: rgba(0,0,0,0.54); +} diff --git a/rpg-docs/client/views/character/features/attackDialog/attackDialog.html b/rpg-docs/client/views/character/features/attackDialog/attackDialog.html new file mode 100644 index 00000000..6eeb910a --- /dev/null +++ b/rpg-docs/client/views/character/features/attackDialog/attackDialog.html @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/features/attackDialog/attackDialog.js b/rpg-docs/client/views/character/features/attackDialog/attackDialog.js new file mode 100644 index 00000000..8ce378e9 --- /dev/null +++ b/rpg-docs/client/views/character/features/attackDialog/attackDialog.js @@ -0,0 +1,78 @@ +var damageTypes = ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire", "force", "lightning", "necrotic", + "poison", "psychic", "radiant", "thunder"]; + +Template.attackDialog.rendered = function(){ + var self = this; + //update all autogrows after they've been filled + var pata = this.$("paper-autogrow-textarea"); + pata.each(function(index, el){ + el.update($(el).children().get(0)); + }) + //update all input fields as well + var input = this.$("paper-input"); + input.each(function(index, el){ + el.valueChanged(); + }) + //after the dialog is built, open it + if (!this.alreadyRendered){ + Session.set("global.ui.detailShow", true); + this.alreadyRendered = true; + } +} + +Template.attackDialog.events({ + "tap #backButton": function(){ + GlobalUI.closeDetail() + }, + "tap #deleteAttack": function(){ + Attacks.remove(this._id); + GlobalUI.closeDetail() + }, + "tap #addEffectButton": function(){ + Effects.insert({ + charId: this.charId, + sourceId: this._id, + operation: "add", + type: "attack" + }); + }, + "change #attackNameInput": function(event){ + var value = event.currentTarget.value; + Attacks.update(this._id, {$set: {name: value}}); + }, + "change #attackBonusInput": function(event){ + var value = event.currentTarget.value; + Attacks.update(this._id, {$set: {attackBonus: value}}); + }, + "change #damageInput": function(event){ + var value = event.currentTarget.value; + Attacks.update(this._id, {$set: {damage: value}}); + }, + "change #rangeInput": function(event){ + var value = event.currentTarget.value; + Attacks.update(this._id, {$set: {range: value}}); + }, + "core-select #damageTypeDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + if(value == this.damageType) return; + Attacks.update(this._id, {$set: {damageType: value}}); + }, + "core-select .colorDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + if(value == this.color) return; + Attacks.update(this._id, {$set: {color: value}}); + }, +}); + +Template.attackDialog.helpers({ + attack: function(){ + return Attacks.findOne(this.attackId); + }, + damageTypes: function(){ + return damageTypes; + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/features/features.css b/rpg-docs/client/views/character/features/features.css index 3db8f419..633bc3be 100644 --- a/rpg-docs/client/views/character/features/features.css +++ b/rpg-docs/client/views/character/features/features.css @@ -20,5 +20,4 @@ .resourceCards paper-shadow.healthCard { width: 100%; - padding: 0 16px 0 0; } diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html index e5d7e65e..8e3abaed 100644 --- a/rpg-docs/client/views/character/features/features.html +++ b/rpg-docs/client/views/character/features/features.html @@ -12,6 +12,48 @@ {{>resource name="sorceryPoints" title="Sorcery Points" color="teal" char=this}} {{>resource name="superiorityDice" title="Superiority Dice" color="teal" char=this}} + + + +
+
+
Attacks
+
+ +
+
+ {{#each attacks}} +
+ +
+
+ {{evaluateSigned ../_id attackBonus}} +
+
+
{{name}}
+
+ {{{evaluateString ../_id damage}}} {{damageType}} {{range}} +
+
+
+
+
+ {{/each}} +
+
+ + + +
+
Proficiencies
+
+
{{characterProficiencies}}
+
+ {{#each features}} diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index bc5d29b9..f79a1736 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -11,6 +11,13 @@ Template.features.helpers({ }, featureOrder: function(){ return _.indexOf(_.keys(colorOptions), this.color); + }, + attacks: function(){ + return Attacks.find({charId: this._id}, {sort: {color: 1, name: 1}}); + }, + characterProficiencies: function(){ + var char = Characters.findOne(this._id); + return char && char.proficiencies; } }); @@ -23,7 +30,21 @@ Template.features.events({ heroId: featureId }) }, - "tap .containerTop": function(event){ + "tap #addAttackButton": function(event){ + var charId = this._id; + Attacks.insert({ + charId: charId + }, function(error, id){ + if(!error){ + GlobalUI.setDetail({ + template: "attackDialog", + data: {attackId: id, charId: charId}, + heroId: id + }); + } + }); + }, + "tap .featureCard .containerTop": function(event){ var featureId = this._id; var charId = Template.parentData()._id; GlobalUI.setDetail({ @@ -32,6 +53,15 @@ Template.features.events({ heroId: featureId }); }, + "tap .attack": function(event){ + var attackId = this._id; + var charId = Template.parentData()._id; + GlobalUI.setDetail({ + template: "attackDialog", + data: {attackId: attackId, charId: charId}, + heroId: attackId + }); + }, "tap .useFeature": function(event){ var featureId = this._id; Features.update(featureId, {$inc: {used: 1}}); @@ -39,6 +69,14 @@ Template.features.events({ "tap .resetFeature": function(event){ var featureId = this._id; Features.update(featureId, {$set: {used: 0}}); + }, + "tap #proficiencies": function(event){ + var charId = this._id; + GlobalUI.setDetail({ + template: "textDialog", + data: {charId: charId, field: "proficiencies", title: "Proficiencies", color: "q"}, + heroId: this._id + "proficiencies" + }); } }); diff --git a/rpg-docs/client/views/character/healthCard/healthCard.html b/rpg-docs/client/views/character/healthCard/healthCard.html deleted file mode 100644 index 49534c6b..00000000 --- a/rpg-docs/client/views/character/healthCard/healthCard.html +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/rpg-docs/client/views/character/healthCard/healthCard.js b/rpg-docs/client/views/character/healthCard/healthCard.js deleted file mode 100644 index fe0d3d23..00000000 --- a/rpg-docs/client/views/character/healthCard/healthCard.js +++ /dev/null @@ -1,7 +0,0 @@ -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}}); - } -}); diff --git a/rpg-docs/client/views/character/inventory/inventory.html b/rpg-docs/client/views/character/inventory/inventory.html index 0d248873..cb7bbaaa 100644 --- a/rpg-docs/client/views/character/inventory/inventory.html +++ b/rpg-docs/client/views/character/inventory/inventory.html @@ -2,11 +2,32 @@
+ + +
+ Net Worth +
+
+ {{valueString netWorth}} +
+
+ + +
+ Weight Carried +
+
+ {{round weightCarried}}lbs +
+
+
-
Equipment
-
(net Worth)
-
(weightCarried)lbs
+
+ Equipment +
+
{{valueString equipmentValue}}
+
{{round equipmentWeight}}lbs
{{#if armor}} diff --git a/rpg-docs/client/views/character/inventory/inventory.js b/rpg-docs/client/views/character/inventory/inventory.js index c34615ab..0b858e87 100644 --- a/rpg-docs/client/views/character/inventory/inventory.js +++ b/rpg-docs/client/views/character/inventory/inventory.js @@ -24,8 +24,36 @@ Template.inventory.helpers({ colorClass: function(){ return getColorClass(this.color) }, - containerOrder: function(){ - return _.indexOf(_.keys(colorOptions), this.color); + netWorth: function(){ + var worth = 0; + Items.find({charId: this._id}, {fields: {value : 1, quantity: 1}}).forEach(function(item){ + worth += item.totalValue(); + }); + return worth; + }, + weightCarried: function(){ + var weight = 0; + Containers.find({charId: this._id, isCarried: true}).forEach(function(container){ + weight += container.totalWeight(); + }); + Items.find({charId: this._id, equipped: false}, {fields: {weight : 1, quantity: 1}}).forEach(function(item){ + weight += item.totalWeight(); + }); + return weight; + }, + equipmentValue: function(){ + var value = 0; + Items.find({charId: this._id, equipped: true}, {fields: {value : 1, quantity: 1}}).forEach(function(item){ + value += item.totalValue(); + }); + return value; + }, + equipmentWeight: function(){ + var weight = 0; + Items.find({charId: this._id, equipped: true}, {fields: {weight : 1, quantity: 1}}).forEach(function(item){ + weight += item.totalWeight(); + }); + return weight; } }); diff --git a/rpg-docs/client/views/character/journal/journal.html b/rpg-docs/client/views/character/journal/journal.html index 39c74f01..51995a3a 100644 --- a/rpg-docs/client/views/character/journal/journal.html +++ b/rpg-docs/client/views/character/journal/journal.html @@ -5,7 +5,7 @@
Experience
-
{{experience}}XP
+
{{experience}} XP
{{#each experiences}} @@ -23,6 +23,35 @@
{{/if}}
+ +
+
+
Levels
+
+
+
+
+ Race +
+
+ + {{race}} + +
+ {{#each classes}} +
+ {{name}} +
+ {{#each levels ../_id}} +
+ + Level {{value}} + +
+ {{/each}} + {{/each}} +
+
{{#each notes}}
@@ -30,9 +59,7 @@
{{name}}
-
- {{description}} -
+
{{description}}
{{/each}}
diff --git a/rpg-docs/client/views/character/journal/journal.js b/rpg-docs/client/views/character/journal/journal.js index f26bb61b..49b1844c 100644 --- a/rpg-docs/client/views/character/journal/journal.js +++ b/rpg-docs/client/views/character/journal/journal.js @@ -19,6 +19,16 @@ Template.journal.helpers({ moreExperiencesOrCollapse: function(){ return (!(Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get())) || Template.instance().experiencesLimit.get() > (this.settings && this.settings.experiencesInc || 10); + }, + classes: function(){ + return Classes.find({charId: this._id}, {sort: {createdAt: 1}}); + }, + levels: function(charId){ + return Levels.find({charId: charId, classId: this._id}, {sort: {value: 1}}); + }, + race: function(){ + var char = Characters.findOne(this._id, {fields: {race: 1}}); + return char && char.race; } }); @@ -37,6 +47,20 @@ Template.journal.events({ heroId: this._id }); }, + "tap .level": function(event){ + GlobalUI.setDetail({ + template: "levelDialog", + data: {levelId: this._id, charId: this.charId}, + heroId: this._id + }); + }, + "tap .race": function(event){ + GlobalUI.setDetail({ + template: "raceDialog", + data: {charId: this._id}, + heroId: this._id + "race" + }); + }, "tap #addNote": function(event){ var charId = this._id; Notes.insert({ diff --git a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html new file mode 100644 index 00000000..b1468007 --- /dev/null +++ b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.html @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js new file mode 100644 index 00000000..8193c26f --- /dev/null +++ b/rpg-docs/client/views/character/journal/levelDialog/levelDialog.js @@ -0,0 +1,49 @@ +Template.levelDialog.rendered = function(){ + var self = this; + //update all autogrows after they've been filled + var pata = this.$("paper-autogrow-textarea"); + pata.each(function(index, el){ + el.update($(el).children().get(0)); + }) + //update all input fields as well + var input = this.$("paper-input"); + input.each(function(index, el){ + el.valueChanged(); + }) + //after the dialog is built, open it + if (!this.alreadyRendered){ + Session.set("global.ui.detailShow", true); + this.alreadyRendered = true; + } +} + +Template.levelDialog.events({ + "tap #backButton": function(){ + GlobalUI.closeDetail() + }, + "tap #deleteLevel": function(){ + Levels.remove(this._id); + GlobalUI.closeDetail() + }, + "tap #addEffectButton": function(){ + Effects.insert({ + charId: this.charId, + sourceId: this._id, + operation: "add", + type: "level" + }); + }, + "change #levelValueInput": function(event){ + var value = event.currentTarget.value; + Levels.update(this._id, {$set: {value: value}}); + } +}); + +Template.levelDialog.helpers({ + level: function(){ + return Levels.findOne(this.levelId); + }, + effects: function(){ + return Effects.find({sourceId: this._id, type: "level"}); + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html new file mode 100644 index 00000000..6d7368d8 --- /dev/null +++ b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.html @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/raceDialog/raceDialog.js b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.js new file mode 100644 index 00000000..e6baa0ad --- /dev/null +++ b/rpg-docs/client/views/character/journal/raceDialog/raceDialog.js @@ -0,0 +1,45 @@ +Template.raceDialog.rendered = function(){ + var self = this; + //update all autogrows after they've been filled + var pata = this.$("paper-autogrow-textarea"); + pata.each(function(index, el){ + el.update($(el).children().get(0)); + }) + //update all input fields as well + var input = this.$("paper-input"); + input.each(function(index, el){ + el.valueChanged(); + }) + //after the dialog is built, open it + if (!this.alreadyRendered){ + Session.set("global.ui.detailShow", true); + this.alreadyRendered = true; + } +} + +Template.raceDialog.events({ + "tap #backButton": function(){ + GlobalUI.closeDetail() + }, + "tap #addEffectButton": function(){ + Effects.insert({ + charId: this.charId, + operation: "add", + type: "racial" + }); + }, + "change #raceInput": function(event){ + var value = event.currentTarget.value; + Characters.update(this.charId, {$set: {race: value}}); + } +}); + +Template.raceDialog.helpers({ + effects: function(){ + return Effects.find({charId: this.charId, type: "racial"}); + }, + race: function(){ + var char = Characters.findOne(this.charId, {fields: {race: 1}}); + return char && char.race; + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.html b/rpg-docs/client/views/character/persona/persona.html index 276fee27..7772d639 100644 --- a/rpg-docs/client/views/character/persona/persona.html +++ b/rpg-docs/client/views/character/persona/persona.html @@ -11,6 +11,7 @@ {{> containerCard characterField "bonds" "Bonds"}} {{> containerCard characterField "flaws" "Flaws"}} {{> containerCard characterField "backstory" "Background"}} + {{> containerCard characterField "languages" "Languages"}}
diff --git a/rpg-docs/client/views/character/persona/persona.js b/rpg-docs/client/views/character/persona/persona.js index 41ac500f..55fe4f49 100644 --- a/rpg-docs/client/views/character/persona/persona.js +++ b/rpg-docs/client/views/character/persona/persona.js @@ -4,7 +4,8 @@ var colorMap = { ideals: "g", bonds: "h", flaws: "i", - backstory: "j" + backstory: "j", + languages: "k" } Template.persona.helpers({ diff --git a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js index 49b831ee..32e38117 100644 --- a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js +++ b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js @@ -1,5 +1,5 @@ var spellLevels = [ - { name: "Cantrips", level: 0 }, + { name: "Cantrip", level: 0 }, { name: "Level 1", level: 1 }, { name: "Level 2", level: 2 }, { name: "Level 3", level: 3 }, diff --git a/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js b/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js index 2189664e..3d5d9110 100644 --- a/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js +++ b/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js @@ -31,15 +31,15 @@ Template.spellListDialog.events({ var value = event.currentTarget.value SpellLists.update(this._id, {$set: {name: value}}); }, - "change #spellListSaveDCInput, input #spellListNameInput": function(event){ + "change #spellListSaveDCInput, input #spellListSaveDCInput": function(event){ var value = event.currentTarget.value SpellLists.update(this._id, {$set: {saveDC: value}}); }, - "change #spellListAttackBonusInput, input #spellListNameInput": function(event){ + "change #spellListAttackBonusInput, input #spellListAttackBonusInput": function(event){ var value = event.currentTarget.value SpellLists.update(this._id, {$set: {attackBonus: value}}); }, - "change #spellListMaxPreparedInput, input #spellListNameInput": function(event){ + "change #spellListMaxPreparedInput, input #spellListMaxPreparedInput": function(event){ var value = event.currentTarget.value SpellLists.update(this._id, {$set: {maxPrepared: value}}); }, diff --git a/rpg-docs/client/views/character/spells/spells.html b/rpg-docs/client/views/character/spells/spells.html index 9fe65656..4dd28148 100644 --- a/rpg-docs/client/views/character/spells/spells.html +++ b/rpg-docs/client/views/character/spells/spells.html @@ -2,27 +2,29 @@
- -
-
Spell Slots
-
-
- {{#each levels}}{{#if showSlots ..}} -
- -
- {{name}} -
-
- {{#each slotBubbles ..}} - - {{/each}} -
-
-
- {{/if}}{{/each}} -
-
+ {{#if hasSlots}} + +
+
Spell Slots
+
+
+ {{#each levels}}{{#if showSlots ..}} +
+ +
+ {{name}} +
+
+ {{#each slotBubbles ..}} + + {{/each}} +
+
+
+ {{/if}}{{/each}} +
+
+ {{/if}} {{#each spellLists}}
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 @@ + 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}) ]; });