mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
v3 client: fix predicatbale random
This commit is contained in:
@@ -5,7 +5,12 @@ import _ from 'lodash';
|
||||
|
||||
module.exports = function predictableRandom (user, seed) {
|
||||
if (!seed || seed === Math.PI) {
|
||||
seed = _.reduce(user.stats, (accumulator, val) => {
|
||||
let stats = user.stats.toObject ? user.stats.toObject() : user.stats;
|
||||
// These items are not part of the stat object but exists on the server (see controllers/user#getUser)
|
||||
// we remove them in order to use the same user.stats both on server and on client
|
||||
stats = _.omit(stats, 'toNextLevel', 'maxHealth', 'maxMP');
|
||||
|
||||
seed = _.reduce(stats, (accumulator, val) => {
|
||||
if (_.isNumber(val)) {
|
||||
return accumulator + val;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user