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

View File

@@ -3,8 +3,8 @@
"potionNotes": "Recover 15 Health (Instant Use)",
"armoireText": "Enchanted Armoire",
"armoireNotesFull": "Open the Armoire to randomly receive special Equipment, Experience, or food!",
"armoireNotesEmpty": "The Enchanted Armoire will have more Equipment soon. Keep clicking for Experience and Food!",
"armoireNotesFull": "Open the Armoire to randomly receive special equipment, Experience, or food!",
"armoireNotesEmpty": "The Enchanted Armoire will have new Equipment every month. Until then, keep clicking for Experience and Food!",
"dropEggWolfText": "Wolf",
"dropEggWolfAdjective": "loyal",

View File

@@ -21,7 +21,7 @@
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",
"messageFoundQuest": "You've found the quest \"<%= questText %>\"!",
"armoireEquipment": "<%= image %> You found a piece of rare Equipment in the Armoire: <%= dropText %>! Awesome!",
"armoireEquipment": "<%= image %> You found a piece of rare Equipment in the Armoire: <%= dropText %>! Awesome! There are <%= count %> pieces left.",
"armoireFood": "<%= image %> You rummage in the Armoire and find <%= dropArticle %><%= dropText %>. What's that doing in here?",
"armoireExp": "You wrestle with the Armoire and gain Experience. Take that!"
}

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))
###
---------------------------------------------------------------

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

View File

@@ -494,6 +494,10 @@ describe 'User', ->
result
)
it 'counts all available equipment before any are claimed', ->
sinon.stub(user.fns, 'predictableRandom').returns 0
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 1)
it 'does not open without paying', ->
sinon.stub(user.fns, 'predictableRandom').returns 0
user.ops.buy({params: {key: 'armoire'}})
@@ -516,6 +520,7 @@ describe 'User', ->
user.achievements.ultimateGearSets = {'healer':false,'wizard':false,'rogue':true,'warrior':false}
user.ops.buy({params: {key: 'armoire'}})
expect(user.items.gear.owned).to.eql {'weapon_warrior_0': true, 'shield_armoire_gladiatorShield':true}
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 2)
expect(user.items.food).to.eql {}
expect(user.stats.exp).to.eql 0
expect(user.stats.gp).to.eql 400
@@ -540,6 +545,7 @@ describe 'User', ->
sinon.stub(user.fns, 'predictableRandom', cycle [.6,.5])
user.ops.buy({params: {key: 'armoire'}})
expect(user.items.gear.owned).to.eql {'weapon_warrior_0': true, 'shield_armoire_gladiatorShield':true,'head_armoire_rancherHat':true}
expect(shared.countArmoire(user.items.gear.owned)).to.eql (_.size(fullArmoire) - 3)
expect(user.items.food).to.eql {'Honey': 1}
expect(user.stats.exp).to.eql 30
expect(user.stats.gp).to.eql 100
@@ -549,6 +555,7 @@ describe 'User', ->
user.items.gear.owned = fullArmoire
user.ops.buy({params: {key: 'armoire'}})
expect(user.items.gear.owned).to.eql fullArmoire
expect(shared.countArmoire(user.items.gear.owned)).to.eql 0
expect(user.items.food).to.eql {'Honey': 1}
expect(user.stats.exp).to.eql 60
expect(user.stats.gp).to.eql 0

View File

@@ -34,6 +34,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.Groups = Groups;
$rootScope.toJson = angular.toJson;
$rootScope.Payments = Payments;
$rootScope.armoireCount = Shared.countArmoire(User.user.items.gear.owned);
// Angular UI Router
$rootScope.$state = $state;

View File

@@ -126,7 +126,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
// Static Rewards
ul.items.rewards(ng-if='main && list.type=="reward"')
li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.notes()}}')
li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.key == "armoire" && armoireCount > 0 ? env.t("armoireNotesFull") : item.notes()}}')
// right-hand side control buttons
.task-meta-controls
span.task-notes