Replaced languages and proficiency strings with proper proficiencies

This commit is contained in:
Thaum
2015-04-20 09:11:45 +00:00
parent b76ac23713
commit 6ec9f09b6a
17 changed files with 142 additions and 54 deletions

View File

@@ -1,31 +1,37 @@
Migrations.add({
version: 1,
name: "converts effect proficiencies to proficiency objects, removes types from assets",
up: function() {
return;
}
});
Migrations.add({
version: 2,
name: "converts effect proficiencies to proficiency objects",
up: function() {
//convert proficiency effects to proficiency objects
Effects.find({operation: "proficiency"}).forEach(function(effect){
var type;
if(_.contains(SKILLS, effect.stat)) type = "skill";
var type = "skill";
if(_.contains(SAVES, effect.stat)) type = "save";
if(!type) throw "stat not a skill or a save";
Proficiencies.insert({
charId: effect.charId,
name: effect.stat,
value: effect.value,
parent: effect.parent,
parent: _.clone(effect.parent),
type: type,
enabled: effect.enabled
}, function(err){
if(!err) Effects.remove(effect._id);
});
Effects.remove(effect._id);
});
//store type as a parent group if it's needed
Effects.find({"parent.collection": "Characters"}).forEach(function(e){
Effects.update(e._id, {$set: {"parent.group": e.type}});
});
Attacks.find({"parent.collection": "Characters"}).forEach(function(a){
Attacks.update(a._id, {$set: {"parent.group": a.type}});
});
//remove type
Effects.update({}, {$unset: {type: ""}}, {validate: false, multi: true});
Attacks.update({}, {$unset: {type: ""}}, {validate: false, multi: true});
//remove languages and proficiencies
Characters.update(
{},
{$unset: {languages: "", proficiencies: ""}},
{validate: false, multi: true}
);
},
down: function(){
return;
}
});