rename randomProp to randomVal

This commit is contained in:
Tyler Renelle
2013-03-21 13:55:31 -06:00
parent 3ce2686662
commit cebe7fce7b
3 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ dayMapping = dayMapping = {0:'su',1:'m',2:'t',3:'w',4:'th',5:'f',6:'s',7:'su'}
# http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
# obj: object
# returns random property (the value)
randomProp = (obj) ->
randomVal = (obj) ->
result = undefined
count = 0
for key, val of obj
@@ -60,4 +60,4 @@ viewHelpers = (view) ->
view.fn "truarr", (num) ->
return num-1
module.exports = { viewHelpers, removeWhitespace, randomProp, daysBetween, dayMapping }
module.exports = { viewHelpers, removeWhitespace, randomVal, daysBetween, dayMapping }
+2 -2
View File
@@ -1,5 +1,5 @@
_ = require 'underscore'
{ randomProp, removeWhitespace } = require './helpers'
{ randomVal, removeWhitespace } = require './helpers'
{ pets, food } = require('./items').items
###
@@ -11,7 +11,7 @@ module.exports.app = (appExports, model) ->
user.on 'set', 'flags.dropsEnabled', (captures, args) ->
return unless captures == true
egg = randomProp pets
egg = randomVal pets
dontPersist = model._dontPersist
+3 -3
View File
@@ -1,7 +1,7 @@
async = require 'async'
moment = require 'moment'
_ = require 'underscore'
{ randomProp } = helpers = require './helpers'
{ randomVal } = helpers = require './helpers'
browser = require './browser'
character = require './character'
items = require './items'
@@ -118,11 +118,11 @@ score = (model, taskId, direction, times, batch, cron) ->
# 1% chance of getting a pet or meat
if obj.flags.dropsEnabled and Math.random() < .5
if Math.random() < .5
drop = randomProp(food)
drop = randomVal(food)
user.push 'items.food', drop.text
drop.type = 'Food'
else
drop = randomProp(pets)
drop = randomVal(pets)
user.push 'items.eggs', drop
drop.type = 'Egg'