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.
This commit is contained in:
@@ -11,13 +11,6 @@ Schemas.Item = new SimpleSchema({
|
||||
value: {type: Number, min: 0, defaultValue: 0, decimal: true},
|
||||
tradeGood: {type: Boolean, defaultValue: false},
|
||||
stackable: {type: Boolean, defaultValue: false},
|
||||
feature: {type: Schemas.Feature},
|
||||
"feature.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.description": {type: String, autoValue: function(){return this.field("description").value}},
|
||||
"feature.source": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.effects.$.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
"feature.effects.$.type": {type: String, autoValue: function(){return "equipment"}},
|
||||
"feature.attacks.$.name": {type: String, autoValue: function(){return this.field("name").value}},
|
||||
equipmentSlot: {
|
||||
type: String,
|
||||
defaultValue: "none",
|
||||
@@ -28,24 +21,6 @@ Schemas.Item = new SimpleSchema({
|
||||
|
||||
Items.attachSchema(Schemas.Item);
|
||||
|
||||
//update the features of the items as needed
|
||||
Items.find({}, {fields: {feature: 1, charId: 1, equipped: 1}}).observe({
|
||||
added: function(newItem){
|
||||
if(newItem.feature && newItem.charId)
|
||||
addFeatureEffects(newItem.charId, newItem.feature);
|
||||
},
|
||||
changed: function(newItem, oldItem){
|
||||
if(oldItem.feature && oldItem.charId)
|
||||
removeFeatureEffects(oldItem.charId, oldItem.feature);
|
||||
if(newItem.feature && newItem.charId)
|
||||
addFeatureEffects(newItem.charId, newItem.feature);
|
||||
},
|
||||
removed: function(oldItem){
|
||||
if(oldItem.feature && oldItem.charId)
|
||||
removeFeatureEffects(oldItem.charId, oldItem.feature);
|
||||
}
|
||||
});
|
||||
|
||||
Items.helpers({
|
||||
totalValue: function(){
|
||||
return this.value * this.quantity;
|
||||
|
||||
Reference in New Issue
Block a user