mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-31 15:09:32 +00:00
add streak GP bonus & drop bonus (separately handled)
This commit is contained in:
parent
c9aa04439d
commit
bcb2505a96
5 changed files with 15 additions and 10 deletions
|
|
@ -48,8 +48,9 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit
|
|||
Future use
|
||||
{priority} user-defined priority multiplier
|
||||
###
|
||||
module.exports.gpModifier = (value, modifier, priority='!') ->
|
||||
return value * modifier * priorityValue(priority)
|
||||
module.exports.gpModifier = (value, modifier, priority='!', streak=0) ->
|
||||
streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc
|
||||
return value * modifier * priorityValue(priority) * streakBonus
|
||||
|
||||
###
|
||||
Calculates the next task.value based on direction
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this
|
|||
###
|
||||
Drop System
|
||||
###
|
||||
randomDrop = (model, delta, priority) ->
|
||||
randomDrop = (model, delta, priority, streak=0) ->
|
||||
user = model.at('_user')
|
||||
|
||||
# limit drops to 2 / day
|
||||
|
|
@ -27,7 +27,10 @@ randomDrop = (model, delta, priority) ->
|
|||
chanceMultiplier = if (model.flags.nodeEnv is 'development') then 50 else 1
|
||||
# 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
|
||||
chanceMultiplier *= deltaMultiplier
|
||||
chanceMultiplier *= algos.priorityValue(priority) # multiply chance by reddness
|
||||
chanceMultiplier += (streak+ 1) # streak bonus
|
||||
console.log chanceMultiplier
|
||||
|
||||
if user.get('flags.dropsEnabled') and Math.random() < (.05 * chanceMultiplier)
|
||||
# current breakdown - 3% (adjustable) chance on drop
|
||||
|
|
@ -120,7 +123,7 @@ score = (model, taskId, direction, times, batch, cron) ->
|
|||
level = user.get('stats.lvl')
|
||||
weaponStrength = items.items.weapon[user.get('items.weapon')].strength
|
||||
exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast
|
||||
gp += algos.gpModifier(delta, 1, priority)
|
||||
gp += algos.gpModifier(delta, 1, priority, taskObj.streak)
|
||||
|
||||
subtractPoints = ->
|
||||
level = user.get('stats.lvl')
|
||||
|
|
@ -189,7 +192,7 @@ score = (model, taskId, direction, times, batch, cron) ->
|
|||
batch.commit()
|
||||
|
||||
# Drop system
|
||||
randomDrop(model, delta, priority) if direction is 'up'
|
||||
randomDrop(model, delta, priority, taskObj.streak) if direction is 'up'
|
||||
|
||||
return delta
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ module.exports.app = (appExports, model) ->
|
|||
|
||||
user.on 'set', 'tasks.*.streak', (id, val) ->
|
||||
# 21-day streak, as per the old philosophy of doign a thing 21-days in a row makes a habit
|
||||
if (val % 21) is 0
|
||||
if val > 0 and (val % 21) is 0
|
||||
dontPersist = model._dontPersist; model._dontPersist = false
|
||||
user.incr 'achievements.streak', 1, (-> model._dontPersist = dontPersist)
|
||||
$('#streak-achievement-modal').modal('show')
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@
|
|||
<!--<div class='achievement achievement-karaoke'></div>-->
|
||||
{#if @profile.achievements.streak}
|
||||
<div class='achievement achievement-thermometer'></div> {@profile.achievements.streak} Streak Achievement(s)
|
||||
<hr/>
|
||||
{/}
|
||||
{#if @profile.achievements.originalUser}
|
||||
<div class='achievement achievement-cake'></div>Original User
|
||||
|
|
|
|||
|
|
@ -109,9 +109,9 @@
|
|||
<!-- right-hand side control buttons -->
|
||||
<div class="task-meta-controls">
|
||||
<!-- Streak -->
|
||||
{#if :task.streak}
|
||||
{:task.streak} <span rel='tooltip' title='Streak Counter'><i class='icon-forward'></i></span>
|
||||
{/}
|
||||
<span class='{#unless :task.streak}hide{/}'>
|
||||
{:task.streak}<span rel='tooltip' title='Streak Counter'><i class='icon-forward'></i></span>
|
||||
</span>
|
||||
<!-- edit -->
|
||||
<a x-bind=click:toggleTaskEdit data-hide-id="{{:task.id}}-chart" data-toggle-id="{{:task.id}}-edit" rel=tooltip title="Edit"><i class="icon-pencil"></i></a>
|
||||
<!-- delete -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue