mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-23 06:07:07 +00:00
cast values to their appropriate types when running scoring functions
This commit is contained in:
parent
8ae6e361b8
commit
fc3d863feb
3 changed files with 2514 additions and 2516 deletions
File diff suppressed because one or more lines are too long
1109
browser/browser.js
1109
browser/browser.js
File diff suppressed because it is too large
Load diff
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue