From 484b19be258882f3dafdead13f4bbcb202bd1539 Mon Sep 17 00:00:00 2001 From: Thaum Date: Thu, 5 Feb 2015 10:06:37 +0000 Subject: [PATCH] Began implementing spellbooks --- rpg-docs/Model/Character/SpellLists.js | 22 ++++++++++++++ rpg-docs/Model/Character/Spells.js | 27 +++++++++-------- .../client/views/character/spells/spells.css | 3 ++ .../client/views/character/spells/spells.html | 30 +++++++++++++++++++ .../client/views/character/spells/spells.js | 21 +++++++++++++ 5 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 rpg-docs/Model/Character/SpellLists.js create mode 100644 rpg-docs/client/views/character/spells/spells.css create mode 100644 rpg-docs/client/views/character/spells/spells.html create mode 100644 rpg-docs/client/views/character/spells/spells.js diff --git a/rpg-docs/Model/Character/SpellLists.js b/rpg-docs/Model/Character/SpellLists.js new file mode 100644 index 00000000..0cac6445 --- /dev/null +++ b/rpg-docs/Model/Character/SpellLists.js @@ -0,0 +1,22 @@ +SpellLists = new Meteor.Collection("spellLists"); + +Schemas.SpellLists = new SimpleSchema({ + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, + name: {type: String}, + saveDC: {type: String, optional: true}, + attackBonus: {type: String, optional: true}, + maxPrepared: {type: String, optional: true}, + "settings.showUnprepared": {type: Boolean, defaultValue: true} +}); + +SpellLists.attachSchema(Schemas.SpellLists); + +SpellLists.helpers({ + numPrepared: function(){ + var num = 0; + Spells.find({charId: this.charId, listId: this._id, prepared: 1}, {fields: {prepareCost: 1}}).forEach(function(spell){ + num += spell.prepareCost; + }); + return num; + } +}); diff --git a/rpg-docs/Model/Character/Spells.js b/rpg-docs/Model/Character/Spells.js index 84f7411b..d0bb3266 100644 --- a/rpg-docs/Model/Character/Spells.js +++ b/rpg-docs/Model/Character/Spells.js @@ -1,20 +1,21 @@ Spells = new Meteor.Collection("spells"); Schemas.Spell = new SimpleSchema({ - charId: {type: String, regEx: SimpleSchema.RegEx.Id}, - name: {type: String}, - description:{type: String}, - castingTime:{type: String}, - range: {type: String}, - duration: {type: Number}, - "components.verbal": {type: Boolean}, - "components.somatic": {type: Boolean}, + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, + listId: {type: String, regEx: SimpleSchema.RegEx.Id}, + prepared: {type: Boolean, defaultValue: false}, + prepareCost: {type: Number, defaultValue: 1}, //0 for spells that "dont count against your max number of spells prepared", 1 otherwise + name: {type: String}, + description: {type: String, optional: true}, + castingTime: {type: String, optional: true}, + range: {type: String, optional: true}, + duration: {type: String, optional: true}, + "components.verbal": {type: Boolean, defaultValue: false}, + "components.somatic": {type: Boolean, defaultValue: false}, "components.material": {type: String, optional: true}, - "components.concentration": {type: Boolean}, - ritual: {type: Boolean}, - selfBuffs: {type: [Schemas.Buff], defaultValue: []}, - level: {type: Number}, - class: {type: String} + "components.concentration": {type: Boolean, defaultValue: false}, + ritual: {type: Boolean, defaultValue: false}, + level: {type: Number, defaultValue: 0} }); Spells.attachSchema(Schemas.Spell); diff --git a/rpg-docs/client/views/character/spells/spells.css b/rpg-docs/client/views/character/spells/spells.css new file mode 100644 index 00000000..6f3de0d1 --- /dev/null +++ b/rpg-docs/client/views/character/spells/spells.css @@ -0,0 +1,3 @@ +#spells { + padding: 4px; +} \ No newline at end of file diff --git a/rpg-docs/client/views/character/spells/spells.html b/rpg-docs/client/views/character/spells/spells.html new file mode 100644 index 00000000..450c6797 --- /dev/null +++ b/rpg-docs/client/views/character/spells/spells.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/spells/spells.js b/rpg-docs/client/views/character/spells/spells.js new file mode 100644 index 00000000..fad51497 --- /dev/null +++ b/rpg-docs/client/views/character/spells/spells.js @@ -0,0 +1,21 @@ +var spellLevels = [ + { name: "Cantrips", level: 0 }, + { name: "Level 1", level: 1, attribute: "level1SpellSlots" }, + { name: "Level 2", level: 2, attribute: "level2SpellSlots" }, + { name: "Level 3", level: 3, attribute: "level3SpellSlots" }, + { name: "Level 4", level: 4, attribute: "level4SpellSlots" }, + { name: "Level 5", level: 5, attribute: "level5SpellSlots" }, + { name: "Level 6", level: 6, attribute: "level6SpellSlots" }, + { name: "Level 7", level: 7, attribute: "level7SpellSlots" }, + { name: "Level 8", level: 8, attribute: "level8SpellSlots" }, + { name: "Level 9", level: 9, attribute: "level9SpellSlots" }, +]; + +Template.spells.helpers({ + spellLevels: function(){ + return spellLevels; + }, + spellsAtLevel: function(){ + return Spells.find( {charId: Template.parentData()._id, level: this.level} ) + } +}) \ No newline at end of file