cast values to their appropriate types when running scoring functions

This commit is contained in:
Tyler Renelle 2013-08-15 00:00:12 -04:00
parent 8ae6e361b8
commit fc3d863feb
3 changed files with 2514 additions and 2516 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -183,13 +183,13 @@ randomDrop = (user, delta, priority, streak = 0, options={}) ->
user.items.lastDrop.count++
paths['items.lastDrop'] = true
# {task} task you want to score
# {direction} 'up' or 'down'
obj.score = (user, task, direction, options={}) ->
{gp, hp, exp, lvl} = user.stats
{type, value, streak} = task
[gp, hp, exp, lvl] = [+user.stats.gp, +user.stats.hp, +user.stats.exp, ~~user.stats.lvl]
[type, value, streak, priority] = [task.type, +task.value, ~~task.streak, task.priority or '!']
[paths, times, cron] = [options.paths || {}, options.times || 1, options.cron || false]
priority = task.priority or '!'
# Handle corrupt tasks
# This type of cleanup-code shouldn't be necessary, revisit once we're off Derby