mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 11:40:25 +00:00
1% chance on every score to get an item
This commit is contained in:
parent
c83da2ae79
commit
4485d226e8
2 changed files with 26 additions and 2 deletions
|
|
@ -1,10 +1,11 @@
|
|||
async = require 'async'
|
||||
moment = require 'moment'
|
||||
_ = require 'underscore'
|
||||
helpers = require './helpers'
|
||||
{ randomProp } = helpers = require './helpers'
|
||||
browser = require './browser'
|
||||
character = require './character'
|
||||
items = require './items'
|
||||
{ pets, food } = items.items
|
||||
algos = require './algos'
|
||||
|
||||
MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this mechanism will change)
|
||||
|
|
@ -105,6 +106,21 @@ score = (model, taskId, direction, times, batch, cron) ->
|
|||
batch.set "#{taskPath}.value", taskObj.value
|
||||
origStats = _.clone obj.stats
|
||||
updateStats model, {hp: hp, exp: exp, gp: gp}, batch
|
||||
|
||||
# 1% chance of getting a pet or meat
|
||||
if Math.random() < .01
|
||||
if Math.random() < .5
|
||||
drop = randomProp(food)
|
||||
user.push 'items.food', drop.name
|
||||
drop.type = 'food'
|
||||
else
|
||||
drop = randomProp(pets)
|
||||
user.push 'items.eggs', drop
|
||||
drop.type = 'egg'
|
||||
|
||||
model.set '_drop', drop
|
||||
$('#itemDropped-modal').show()
|
||||
|
||||
if commit
|
||||
# newStats / origStats is a glorious hack to trick Derby into seeing the change in model.on(*)
|
||||
newStats = _.clone batch.obj().stats
|
||||
|
|
|
|||
|
|
@ -6,4 +6,12 @@
|
|||
<@footer>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
</@footer>
|
||||
</app:modals:modal>
|
||||
</app:modals:modal>
|
||||
<app:modals:modal modalId='itemDropped-modal' header="Item Dropped!">
|
||||
<p>An item has dropped!</p>
|
||||
<p>Here's your first {_drop.type} – {_drop.text}!</p>
|
||||
<p>{_drop.notes}</p>
|
||||
<@footer>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
</@footer>
|
||||
</app:modals:modal>
|
||||
|
|
|
|||
Loading…
Reference in a new issue