habitica/migrations/20131204_classes.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Probably the biggest migration of all! This adds the following features:
* - Customization Redo: https://trello.com/c/YKXmHNjY/306-customization-redo
* - Armory: https://trello.com/c/83M5RqQB/299-armory
* - Classes
*/
db.users.find().forEach(function(user){
user.stats.class = 'warrior';
2013-12-14 04:53:42 +00:00
// set default stats (inc mp?)
user.stats.points = user.stats.lvl;
// grant backer/contrib gear, 300, rather than using js logic
2013-12-07 18:31:11 +00:00
// customizations redo: https://trello.com/c/YKXmHNjY/306-customization-redo
// migrate current owned items
// gender => size
user.preferences.size = (user.preferences.gender == 'f') ? 'slim' : 'broad';
delete user.preferences.gender;
// Delete armorSet
delete user.preferences.armorSet;
user.preferences.sleep = user.flags.rest;
delete user.flags.rest;
_.each(user.tasks, function(task){
2013-12-14 04:53:42 +00:00
// migrate task.priority from !, !!, !!! => 1, 1.5, 2
var p = task.priority;
task.priority = p == '!!!' ? 2 : p == '!!' ? 1.5 : 1;
2013-12-14 04:53:42 +00:00
// Add task attributes
task.attribute = 'str';
})
db.users.update({_id:user._id}, user);
});