Merge remote-tracking branch 'colegleason/drops' into develop

Conflicts:
	dist/habitrpg-shared.js
This commit is contained in:
Tyler Renelle 2014-01-15 17:40:07 -07:00
commit 18ccbb51df
2 changed files with 7 additions and 17 deletions

View file

@ -12161,21 +12161,14 @@ var process=require("__browserify_process");(function() {
},
/*
Get a random property from an object
http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
returns random property (the value)
*/
randomVal: function(obj, options) {
var count, key, result, val;
result = void 0;
count = 0;
for (key in obj) {
val = obj[key];
if (user.fns.predictableRandom(options != null ? options.seed : void 0) < (1 / ++count)) {
result = ((options != null ? options.key : void 0) ? key : val);
}
}
return result;
var array, rand;
array = (options != null ? options.key : void 0) ? _.keys(obj) : _.values(obj);
rand = user.fns.predictableRandom(typeof option !== "undefined" && option !== null ? option.seed : void 0);
return array[Math.floor(rand * array.length)];
},
/*
This allows you to set object properties by dot-path. Eg, you can run pathSet('stats.hp',50,user) which is the same as

View file

@ -912,15 +912,12 @@ api.wrap = (user, main=true) ->
###
Get a random property from an object
http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
returns random property (the value)
###
randomVal: (obj, options) ->
result = undefined
count = 0
for key, val of obj
result = (if options?.key then key else val) if user.fns.predictableRandom(options?.seed) < (1 / ++count)
result
array = if options?.key then _.keys(obj) else _.values(obj)
rand = user.fns.predictableRandom(option?.seed)
array[Math.floor(rand * array.length)]
###
This allows you to set object properties by dot-path. Eg, you can run pathSet('stats.hp',50,user) which is the same as