Implemented Feature editing UI

This commit is contained in:
Thaum
2015-01-21 11:16:00 +00:00
parent 078f873219
commit 84512beb72
32 changed files with 1072 additions and 161 deletions

View File

@@ -1,9 +1,10 @@
//set up the collection for containers
Containers = new Meteor.Collection("containers");
Schemas.Container = new SimpleSchema({
name: { type: String },
owner: { type: String, regEx: SimpleSchema.RegEx.Id},
charId: { type: String, regEx: SimpleSchema.RegEx.Id},
isCarried: { type: Boolean }
});

View File

@@ -4,14 +4,20 @@ Schemas.Item = new SimpleSchema({
name: {type: String, defaultValue: "New Item"},
plural: {type: String, optional: true},
description:{type: String, defaultValue: ""},
container: {type: String}, //id of container it normally is stowed in
character: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of owner
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},
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",
@@ -23,20 +29,20 @@ Schemas.Item = new SimpleSchema({
Items.attachSchema(Schemas.Item);
//update the features of the items as needed
Items.find({}, {fields: {feature: 1, character: 1, equipped: 1}}).observe({
Items.find({}, {fields: {feature: 1, charId: 1, equipped: 1}}).observe({
added: function(newItem){
if(newItem.feature && newItem.character)
addFeatureEffects(newItem.character, newItem.feature);
if(newItem.feature && newItem.charId)
addFeatureEffects(newItem.charId, newItem.feature);
},
changed: function(newItem, oldItem){
if(oldItem.feature && oldItem.character)
removeFeatureEffects(oldItem.character, oldItem.feature);
if(newItem.feature && newItem.character)
addFeatureEffects(newItem.character, newItem.feature);
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.character)
removeFeatureEffects(oldItem.character, oldItem.feature);
if(oldItem.feature && oldItem.charId)
removeFeatureEffects(oldItem.charId, oldItem.feature);
}
});