habitica/common/script/ops/allocateNow.js

16 lines
327 B
JavaScript
Raw Normal View History

2016-03-07 22:02:42 +00:00
import _ from 'lodash';
2016-03-20 19:21:15 +00:00
import autoAllocate from '../fns/autoAllocate';
2016-03-07 22:02:42 +00:00
2016-04-09 14:45:43 +00:00
module.exports = function allocateNow (user, req = {}) {
2016-03-20 19:21:15 +00:00
_.times(user.stats.points, () => autoAllocate(user));
2016-03-07 22:02:42 +00:00
user.stats.points = 0;
2016-04-09 14:45:43 +00:00
if (req.v2 === true) {
return _.pick(user, 'stats');
} else {
return [
user.stats,
];
2016-04-09 14:45:43 +00:00
}
2016-03-07 22:02:42 +00:00
};