Revert "API v3 [WIP] (#6144)"

This reverts commit 28f2e9c356.
This commit is contained in:
Blade Barringer
2016-05-23 07:53:14 -05:00
parent 28f2e9c356
commit 0a7b6b65e7
993 changed files with 12914 additions and 44919 deletions
+12 -16
View File
@@ -1,24 +1,20 @@
import _ from 'lodash';
/*
Because the same op needs to be performed on the client and the server (critical hits, item drops, etc),
we need things to be "random", but technically predictable so that they don't go out-of-sync
*/
// Because the same op needs to be performed on the client and the server (critical hits, item drops, etc),
// we need things to be "random", but technically predictable so that they don't go out-of-sync
module.exports = function predictableRandom (user, seed) {
module.exports = function(user, seed) {
var x;
if (!seed || seed === Math.PI) {
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;
seed = _.reduce(user.stats, (function(m, v) {
if (_.isNumber(v)) {
return m + v;
} else {
return accumulator;
return m;
}
}, 0);
}), 0);
}
let x = Math.sin(seed++) * 10000;
x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
};