Files
DiceCloud/rpg-docs/Model/Inventory/Items.js
Thaum 6a2e7f0832 Gave effects their own collection, they no longer live in arrays attached to skills/attributes
Also improved the display of features and generally iterated on their manipulation.

Characters now fetch the relevant effects directly when making a calculation, simplifying almost everything.

Effects now store a reference to their source if they have one.

Effect names are now optional, they can be fetched from the source's name if the source exists.
2015-01-23 11:04:07 +00:00

38 lines
1.2 KiB
JavaScript

Items = new Meteor.Collection('items');
Schemas.Item = new SimpleSchema({
name: {type: String, defaultValue: "New Item"},
plural: {type: String, optional: true},
description:{type: String, defaultValue: ""},
container: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of container it normally is stowed in
charId: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of owner
quantity: {type: Number, min: 0, defaultValue: 1},
weight: {type: Number, min: 0, defaultValue: 0, decimal: true},
value: {type: Number, min: 0, defaultValue: 0, decimal: true},
tradeGood: {type: Boolean, defaultValue: false},
stackable: {type: Boolean, defaultValue: false},
equipmentSlot: {
type: String,
defaultValue: "none",
allowedValues: ["none", "head", "armor", "arms", "hands", "held", "feet"]
},
equipped: {type: Boolean, defaultValue: false}
});
Items.attachSchema(Schemas.Item);
Items.helpers({
totalValue: function(){
return this.value * this.quantity;
},
totalWeight: function(){
return this.weight * this.quantity;
},
pluralName: function(){
if(this.stackable && this.plural && this.quantity > 1){
return this.plural;
} else{
return this.name;
}
}
});