Added character list. Fixed TempHP
This commit is contained in:
@@ -164,7 +164,7 @@ Schemas.Character = new SimpleSchema({
|
||||
deathSave: { type: Schemas.DeathSave },
|
||||
|
||||
//permissions
|
||||
owner: { type: String, regEx: SimpleSchema.RegEx.Id, optional: true },
|
||||
owner: { type: String, regEx: SimpleSchema.RegEx.Id },
|
||||
readers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
|
||||
writers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
|
||||
color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"},
|
||||
|
||||
35
rpg-docs/Model/Character/TemporaryHitPoints.js
Normal file
35
rpg-docs/Model/Character/TemporaryHitPoints.js
Normal file
@@ -0,0 +1,35 @@
|
||||
TemporaryHitPoints = new Meteor.Collection("temporaryHitPoints");
|
||||
|
||||
Schemas.TemporaryHitPoints = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id},
|
||||
maximum: {type: Number, defaultValue: 0},
|
||||
used: {type: Number, defaultValue: 0},
|
||||
deleteOnZero:{type: Boolean, defaultValue: true},
|
||||
dateAdded: {
|
||||
type: Date,
|
||||
autoValue: function() {
|
||||
if (this.isInsert) {
|
||||
return new Date;
|
||||
} else if (this.isUpsert) {
|
||||
return {$setOnInsert: new Date};
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
TemporaryHitPoints.attachSchema(Schemas.TemporaryHitPoints);
|
||||
|
||||
TemporaryHitPoints.helpers({
|
||||
left: function(){
|
||||
return this.maximum - this.used;
|
||||
}
|
||||
});
|
||||
|
||||
//remove the temporary hit points when they hit zero
|
||||
TemporaryHitPoints.after.update(function (userId, thp, fieldNames, modifier, options) {
|
||||
if(thp.used >= thp.maximum && thp.deleteOnZero){
|
||||
TemporaryHitPoints.remove(thp._id);
|
||||
}
|
||||
}, {fetchPrevious: false});
|
||||
Reference in New Issue
Block a user