feat(Armoire): Item counter

Implements a counter for how many pieces of equipment remain to be found in the Armoire, including tests for same.
This commit is contained in:
Sabe Jones
2015-06-03 15:16:09 -05:00
parent 97ae243c40
commit 09d32390f9
7 changed files with 18 additions and 6 deletions
+1 -1
View File
@@ -494,7 +494,7 @@ api.timeTravelerStore = (owned) ->
###
api.potion = type: 'potion', text: t('potionText'), notes: t('potionNotes'), value: 25, key: 'potion'
api.armoire = type: 'armoire', text: t('armoireText'), notes: t('armoireNotesFull'), value: 100, key: 'armoire', canOwn: ((u)-> _.contains(u.achievements.ultimateGearSets, true))
api.armoire = type: 'armoire', text: t('armoireText'), notes: t('armoireNotesEmpty'), value: 100, key: 'armoire', canOwn: ((u)-> _.contains(u.achievements.ultimateGearSets, true))
###
---------------------------------------------------------------
+5 -1
View File
@@ -362,6 +362,10 @@ api.countTriad = (pets) ->
if pets[egg + "-" + potion] > 0 then count3++
count3
api.countArmoire = (gear) ->
count4 = _.size(_.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !gear[i.key])))
count4
###
------------------------------------------------------
User (prototype wrapper to give it ops, helper funcs, and virtuals
@@ -852,7 +856,7 @@ api.wrap = (user, main=true) ->
drop = user.fns.randomVal(eligibleEquipment)
user.items.gear.owned[drop.key] = true
user.flags.armoireOpened = true
message = i18n.t('armoireEquipment', {image: '<span class="shop_'+drop.key+' pull-left"></span>', dropText: drop.text(req.language)}, req.language)
message = i18n.t('armoireEquipment', {image: '<span class="shop_'+drop.key+' pull-left"></span>', dropText: drop.text(req.language), count: api.countArmoire(user.items.gear.owned)}, req.language)
else if (!_.isEmpty(eligibleEquipment) and armoireResult < .85) or armoireResult < .6
drop = user.fns.randomVal _.where(content.food, {canDrop:true})
user.items.food[drop.key] ?= 0