cap minimum %chance of drop to 1% so users still rewarded for

championed habits. Will remove once we have streaks / combos. Also
factor in task difficulty
This commit is contained in:
Tyler Renelle 2013-04-04 18:01:06 -04:00
parent dd736923ca
commit 85432cabdc
2 changed files with 7 additions and 4 deletions

View file

@ -1,7 +1,7 @@
XP = 15
HP = 2
priorityValue = (priority='!') ->
priorityValue = module.exports.priorityValue = (priority='!') ->
switch priority
when '!' then 1
when '!!' then 1.5

View file

@ -13,7 +13,7 @@ MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this
###
Drop System
###
randomDrop = (model, delta) ->
randomDrop = (model, delta, priority) ->
user = model.at('_user')
# limit drops to 2 / day
@ -26,7 +26,10 @@ randomDrop = (model, delta) ->
# % chance of getting a pet or meat
# debugging purpose - 50% chance during development, 3% chance on prod
chanceMultiplier = if (model.flags.nodeEnv is 'development') then 50 else 1
chanceMultiplier *= Math.abs(delta) # multiply chance by reddness
# TODO temporary min cap of 1 so people still get rewarded for good habits. Will change once we have streaks
deltaMultiplier = if Math.abs(delta) < 1 then 1 else Math.abs(delta)
chanceMultiplier = chanceMultiplier * deltaMultiplier * algos.priorityValue(priority) # multiply chance by reddness
if user.get('flags.dropsEnabled') and Math.random() < (.01 * chanceMultiplier)
# current breakdown - 3% (adjustable) chance on drop
# If they got a drop: 50% chance of egg, 50% Hatching Potion. If hatchingPotion, broken down further even further
@ -181,7 +184,7 @@ score = (model, taskId, direction, times, batch, cron) ->
batch.commit()
# Drop system
randomDrop(model, delta) if direction is 'up'
randomDrop(model, delta, priority) if direction is 'up'
return delta