mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
refactor: Move user argument to options in randomVal function
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user