drops are randomly selected, not based on user values fixes #7929
This commit is contained in:
committed by
Blade Barringer
parent
b54441a637
commit
4d5b6992be
@@ -3,7 +3,6 @@ import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import { daysSince } from '../cron';
|
||||
import { diminishingReturns } from '../statHelpers';
|
||||
import _predictableRandom from './predictableRandom';
|
||||
import randomVal from './randomVal';
|
||||
|
||||
// Clone a drop object maintaining its functions so that we can change it without affecting the original item
|
||||
@@ -21,7 +20,7 @@ module.exports = function randomDrop (user, options, req = {}) {
|
||||
let rarity;
|
||||
let task;
|
||||
|
||||
let predictableRandom = options.predictableRandom || _predictableRandom;
|
||||
let predictableRandom = options.predictableRandom || Math.random;
|
||||
task = options.task;
|
||||
|
||||
chance = _.min([Math.abs(task.value - 21.27), 37.5]) / 150 + 0.02;
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import _ from 'lodash';
|
||||
import predictableRandom from './predictableRandom';
|
||||
|
||||
// Get a random property from an object
|
||||
// returns random property (the value)
|
||||
|
||||
function randomGenerator (user, seed, providedRandom) {
|
||||
return providedRandom ? providedRandom(user, seed) : Math.random();
|
||||
}
|
||||
|
||||
module.exports = function randomVal (user, obj, options = {}) {
|
||||
let array = options.key ? _.keys(obj) : _.values(obj);
|
||||
let rand = predictableRandom(user, options.seed);
|
||||
let rand = randomGenerator(user, options.seed, options.randomFunc);
|
||||
|
||||
array.sort();
|
||||
return array[Math.floor(rand * array.length)];
|
||||
|
||||
let randomIndex = Math.floor(rand * array.length);
|
||||
|
||||
return array[randomIndex];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user