mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
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:
@@ -3,8 +3,8 @@
|
|||||||
"potionNotes": "Recover 15 Health (Instant Use)",
|
"potionNotes": "Recover 15 Health (Instant Use)",
|
||||||
|
|
||||||
"armoireText": "Enchanted Armoire",
|
"armoireText": "Enchanted Armoire",
|
||||||
"armoireNotesFull": "Open the Armoire to randomly receive special Equipment, Experience, or food!",
|
"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!",
|
"armoireNotesEmpty": "The Enchanted Armoire will have new Equipment every month. Until then, keep clicking for Experience and Food!",
|
||||||
|
|
||||||
"dropEggWolfText": "Wolf",
|
"dropEggWolfText": "Wolf",
|
||||||
"dropEggWolfAdjective": "loyal",
|
"dropEggWolfAdjective": "loyal",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
|
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
|
||||||
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",
|
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",
|
||||||
"messageFoundQuest": "You've found the quest \"<%= questText %>\"!",
|
"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?",
|
"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!"
|
"armoireExp": "You wrestle with the Armoire and gain Experience. Take that!"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ api.timeTravelerStore = (owned) ->
|
|||||||
###
|
###
|
||||||
|
|
||||||
api.potion = type: 'potion', text: t('potionText'), notes: t('potionNotes'), value: 25, key: 'potion'
|
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))
|
||||||
|
|
||||||
###
|
###
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
|
|||||||
@@ -362,6 +362,10 @@ api.countTriad = (pets) ->
|
|||||||
if pets[egg + "-" + potion] > 0 then count3++
|
if pets[egg + "-" + potion] > 0 then count3++
|
||||||
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
|
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)
|
drop = user.fns.randomVal(eligibleEquipment)
|
||||||
user.items.gear.owned[drop.key] = true
|
user.items.gear.owned[drop.key] = true
|
||||||
user.flags.armoireOpened = 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
|
else if (!_.isEmpty(eligibleEquipment) and armoireResult < .85) or armoireResult < .6
|
||||||
drop = user.fns.randomVal _.where(content.food, {canDrop:true})
|
drop = user.fns.randomVal _.where(content.food, {canDrop:true})
|
||||||
user.items.food[drop.key] ?= 0
|
user.items.food[drop.key] ?= 0
|
||||||
|
|||||||
@@ -494,6 +494,10 @@ describe 'User', ->
|
|||||||
result
|
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', ->
|
it 'does not open without paying', ->
|
||||||
sinon.stub(user.fns, 'predictableRandom').returns 0
|
sinon.stub(user.fns, 'predictableRandom').returns 0
|
||||||
user.ops.buy({params: {key: 'armoire'}})
|
user.ops.buy({params: {key: 'armoire'}})
|
||||||
@@ -516,6 +520,7 @@ describe 'User', ->
|
|||||||
user.achievements.ultimateGearSets = {'healer':false,'wizard':false,'rogue':true,'warrior':false}
|
user.achievements.ultimateGearSets = {'healer':false,'wizard':false,'rogue':true,'warrior':false}
|
||||||
user.ops.buy({params: {key: 'armoire'}})
|
user.ops.buy({params: {key: 'armoire'}})
|
||||||
expect(user.items.gear.owned).to.eql {'weapon_warrior_0': true, 'shield_armoire_gladiatorShield':true}
|
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.items.food).to.eql {}
|
||||||
expect(user.stats.exp).to.eql 0
|
expect(user.stats.exp).to.eql 0
|
||||||
expect(user.stats.gp).to.eql 400
|
expect(user.stats.gp).to.eql 400
|
||||||
@@ -540,6 +545,7 @@ describe 'User', ->
|
|||||||
sinon.stub(user.fns, 'predictableRandom', cycle [.6,.5])
|
sinon.stub(user.fns, 'predictableRandom', cycle [.6,.5])
|
||||||
user.ops.buy({params: {key: 'armoire'}})
|
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(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.items.food).to.eql {'Honey': 1}
|
||||||
expect(user.stats.exp).to.eql 30
|
expect(user.stats.exp).to.eql 30
|
||||||
expect(user.stats.gp).to.eql 100
|
expect(user.stats.gp).to.eql 100
|
||||||
@@ -549,6 +555,7 @@ describe 'User', ->
|
|||||||
user.items.gear.owned = fullArmoire
|
user.items.gear.owned = fullArmoire
|
||||||
user.ops.buy({params: {key: 'armoire'}})
|
user.ops.buy({params: {key: 'armoire'}})
|
||||||
expect(user.items.gear.owned).to.eql fullArmoire
|
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.items.food).to.eql {'Honey': 1}
|
||||||
expect(user.stats.exp).to.eql 60
|
expect(user.stats.exp).to.eql 60
|
||||||
expect(user.stats.gp).to.eql 0
|
expect(user.stats.gp).to.eql 0
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||||||
$rootScope.Groups = Groups;
|
$rootScope.Groups = Groups;
|
||||||
$rootScope.toJson = angular.toJson;
|
$rootScope.toJson = angular.toJson;
|
||||||
$rootScope.Payments = Payments;
|
$rootScope.Payments = Payments;
|
||||||
|
$rootScope.armoireCount = Shared.countArmoire(User.user.items.gear.owned);
|
||||||
|
|
||||||
// Angular UI Router
|
// Angular UI Router
|
||||||
$rootScope.$state = $state;
|
$rootScope.$state = $state;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
|
|||||||
|
|
||||||
// Static Rewards
|
// Static Rewards
|
||||||
ul.items.rewards(ng-if='main && list.type=="reward"')
|
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
|
// right-hand side control buttons
|
||||||
.task-meta-controls
|
.task-meta-controls
|
||||||
span.task-notes
|
span.task-notes
|
||||||
|
|||||||
Reference in New Issue
Block a user