refactor: Move user argument to options in randomVal function

This commit is contained in:
Blade Barringer
2016-09-24 19:50:12 -05:00
parent 4df1601718
commit 966a50431f
7 changed files with 23 additions and 17 deletions

View File

@@ -6,6 +6,9 @@ import {
} from '../libs/errors';
import randomVal from '../fns/randomVal';
// TODO this is only used on the server
// move out of common?
module.exports = function revive (user, req = {}, analytics) {
if (user.stats.hp > 0) {
throw new NotAuthorized(i18n.t('cannotRevive', req.language));
@@ -21,7 +24,7 @@ module.exports = function revive (user, req = {}, analytics) {
user.stats.lvl--;
}
let lostStat = randomVal(user, _.reduce(['str', 'con', 'per', 'int'], function findRandomStat (m, k) {
let lostStat = randomVal(_.reduce(['str', 'con', 'per', 'int'], function findRandomStat (m, k) {
if (user.stats[k]) {
m[k] = k;
}
@@ -68,7 +71,7 @@ module.exports = function revive (user, req = {}, analytics) {
}
});
let lostItem = randomVal(user, losableItems);
let lostItem = randomVal(losableItems);
let message = '';
let item = content.gear.flat[lostItem];