Implemented and cleaned up character schemas

This commit is contained in:
Thaum
2014-11-13 08:44:21 +00:00
parent d80fb19dfe
commit 7ab97a17cc
27 changed files with 403 additions and 259 deletions

View File

@@ -0,0 +1,17 @@
/*
* A buff becomes an effect when applied on a creature.
* It is the effect plus the stat to which it should be applied
*/
Schemas.Buff = new SimpleSchema({
stat: {
type: String
},
effect: {
type: Schemas.Effect
}
});
Buff = function(name, stat, value){
this.stat = stat;
this.effect = new Effect(name, value);
};

View File

@@ -0,0 +1,35 @@
/*
* Effects are reason-value pairs attached to skills and abilities
* that modify their final value or presentation in some way
*/
Schemas.Effect = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
autoValue: function(){
if(!isSet) return Random.id();
}
},
name: {
type: String
},
value: {
type: Number,
decimal: true,
optional: true
},
calculation: {
type: String,
optional: true
}
});
Effect = function(name, value){
this._id = Random.id();
this.name = name;
if (typeof value === "string"){
this.calculation = value;
} else if (typeof valye === "number"){
this.value = value;
}
};