Files
DiceCloud/rpg-docs/Model/Character/SpellLists.js
2015-02-13 08:44:30 +00:00

25 lines
810 B
JavaScript

SpellLists = new Meteor.Collection("spellLists");
Schemas.SpellLists = new SimpleSchema({
charId: {type: String, regEx: SimpleSchema.RegEx.Id},
name: {type: String},
description: {type: String, optional: true},
saveDC: {type: String, optional: true},
attackBonus: {type: String, optional: true},
maxPrepared: {type: String, optional: true},
color: {type: String, allowedValues: _.keys(colorOptions), defaultValue: "green"},
"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;
}
});