Implemented container editing
This commit is contained in:
@@ -5,7 +5,27 @@ Containers = new Meteor.Collection("containers");
|
||||
Schemas.Container = new SimpleSchema({
|
||||
name: { type: String },
|
||||
charId: { type: String, regEx: SimpleSchema.RegEx.Id},
|
||||
isCarried: { type: Boolean }
|
||||
isCarried: { type: Boolean },
|
||||
weight: {type: Number, min: 0, defaultValue: 0, decimal: true},
|
||||
value: {type: Number, min: 0, defaultValue: 0, decimal: true},
|
||||
description:{type: String, optional: true}
|
||||
});
|
||||
|
||||
Containers.attachSchema(Schemas.Container);
|
||||
Containers.attachSchema(Schemas.Container);
|
||||
|
||||
Containers.helpers({
|
||||
totalValue: function(){
|
||||
var value = this.value;
|
||||
Items.find({container: this._id, equipped: false}, {fields: {quantity: 1, value: 1}}).forEach(function(item){
|
||||
value += item.totalValue();
|
||||
});
|
||||
return value;
|
||||
},
|
||||
totalWeight: function(){
|
||||
var weight = this.weight;
|
||||
Items.find({container: this._id, equipped: false}, {fields: {weight: 1, value: 1}}).forEach(function(item){
|
||||
weight += item.totalWeight();
|
||||
});
|
||||
return weight;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ Items = new Meteor.Collection('items');
|
||||
Schemas.Item = new SimpleSchema({
|
||||
name: {type: String, defaultValue: "New Item"},
|
||||
plural: {type: String, optional: true},
|
||||
description:{type: String, defaultValue: ""},
|
||||
description:{type: String, optional: true},
|
||||
container: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of container it is normally stowed in
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of owner
|
||||
quantity: {type: Number, min: 0, defaultValue: 1},
|
||||
|
||||
Reference in New Issue
Block a user