Files
DiceCloud/rpg-docs/Model/Character/Buffs.js
2015-03-04 10:17:32 +00:00

29 lines
653 B
JavaScript

Buffs = new Meteor.Collection("buffs");
//buffs are temporary once applied and store things which expire and their expiry time
Schemas.Buff = new SimpleSchema({
//buff id
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
autoValue: function(){
if(!this.isSet) return Random.id();
}},
charId: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
//expiry time
expiry: { type: Number, optional: true},
duration: { type: Number }
});
Buffs.attachSchema(Schemas.Buff);
Buffs.before.remove(function (userId, buff) {
Effects.find({sourceId: buff._id, type: "buff"}).forEach(function(effect){
Effects.remove(effect._id);
});
});