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:
Thaum
2015-01-23 11:04:07 +00:00
parent 84512beb72
commit 6a2e7f0832
32 changed files with 340 additions and 642 deletions

View File

@@ -1,35 +1,12 @@
Features = new Meteor.Collection("features");
Schemas.Feature = new SimpleSchema({
charId: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true},
charId: {type: String, regEx: SimpleSchema.RegEx.Id},
name: {type: String},
description:{type: String, optional: true},
effects: {type: [Schemas.Effect], defaultValue: []},
actions: {type: [Schemas.Action], defaultValue: []},
attacks: {type: [Schemas.Attack], defaultValue: []},
spells: {type: [Schemas.Spell] , defaultValue: []},
});
Features.attachSchema(Schemas.Feature);
//update the features of the items as needed
Features.find({}, {fields: {name: 0, description: 0}}).observe({
added: function(newFeature){
if(newFeature.charId){
//make sure existing versions of this feature's effects aren't duplicated
removeFeatureEffects(newFeature.charId, newFeature);
//add the new feature's effects
addFeatureEffects(newFeature.charId, newFeature);
}
},
changed: function(newFeature, oldFeature){
if(oldFeature.charId)
removeFeatureEffects(oldFeature.charId, oldFeature);
if(newFeature.charId)
addFeatureEffects(newFeature.charId, newFeature);
},
removed: function(oldFeature){
if(oldFeature.charId)
removeFeatureEffects(oldFeature.charId, oldFeature);
}
});