Created
March 7, 2013 19:08
-
-
Save lefnire/5110824 to your computer and use it in GitHub Desktop.
update exp to new system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js | |
function oldTnl(level) { | |
return (Math.pow(level,2)*10)+(level*10)+80 | |
} | |
function newTnl(level) { | |
var value = 0; | |
if (level >= 100) { | |
value = 0 | |
} else { | |
value = Math.round(((Math.pow(level,2)*0.25)+(10 * level) + 139.75)/10)*10; // round to nearest 10 | |
} | |
return value | |
} | |
/** | |
* Make sure people aren't overflowing their exp with the new system | |
*/ | |
db.users.find().forEach(function(user){ | |
var percent = user.stats.exp / oldTnl(user.stats.lvl); | |
user.stats.exp = newTnl(user.stats.lvl) * percent; | |
try { | |
db.users.update( | |
{_id:user._id}, | |
{$set: {'stats.exp': user.stats.exp}}, | |
{multi:true} | |
); | |
} catch(e) { | |
print(e); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment