Made proficiencies their own objects, added migration functionality

This commit is contained in:
Thaum
2015-04-17 13:56:52 +00:00
parent 245867dae6
commit b76ac23713
20 changed files with 331 additions and 17 deletions

View File

@@ -0,0 +1,31 @@
Migrations.add({
version: 1,
up: function() {
return;
}
});
Migrations.add({
version: 2,
name: "converts effect proficiencies to proficiency objects",
up: function() {
Effects.find({operation: "proficiency"}).forEach(function(effect){
var type;
if(_.contains(SKILLS, effect.stat)) 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,
type: type,
enabled: effect.enabled
});
Effects.remove(effect._id);
});
},
down: function(){
return;
}
});

View File

@@ -3,9 +3,9 @@ Meteor.publish("singleCharacter", function(characterId, userId){
Characters.findOne({
_id: characterId,
$or: [
{readers: userId},
{writers: userId},
{owner: userId}
{readers: userId},
{writers: userId},
{owner: userId}
]
})
){
@@ -24,6 +24,7 @@ Meteor.publish("singleCharacter", function(characterId, userId){
Spells.find ({charId: characterId}, {removed: true}),
SpellLists.find ({charId: characterId}, {removed: true}),
TemporaryHitPoints.find({charId: characterId}, {removed: true}),
Proficiencies.find ({charId: characterId}, {removed: true}),
];
}
});