From 951d5417bc488e330a015866f48aafda5d144fc7 Mon Sep 17 00:00:00 2001 From: Kevin Gisi Date: Sat, 20 Jun 2015 01:58:05 -0400 Subject: [PATCH 1/2] Add failing spec for armoire edge case --- test/common/user.fns.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/common/user.fns.js diff --git a/test/common/user.fns.js b/test/common/user.fns.js new file mode 100644 index 0000000000..6a622058a7 --- /dev/null +++ b/test/common/user.fns.js @@ -0,0 +1,30 @@ +'use strict'; + +var shared = require('../../common/script/index.coffee'); +shared.i18n.translations = require('../../website/src/i18n.js').translations + +require('./test_helper'); + +describe('User.fns', function() { + describe('.ultimateGear', function() { + + it('sets armoirEnabled when partial achievement already achieved', function() { + var user = shared.wrap({ + items: { gear: { owned: { + toObject: function() { return { + armor_warrior_5: true, + shield_warrior_5: true, + head_warrior_5: true, + weapon_warrior_6: true + }} + }}}, + achievements: { + ultimateGearSets: {} + }, + flags: {} + }); + user.fns.ultimateGear(); + expect(user.flags.armoireEnabled).to.equal(true); + }); + }); +}); From f32305458ac7cc9bdcfc675f063f9f5d7b6e86da Mon Sep 17 00:00:00 2001 From: Kevin Gisi Date: Sat, 20 Jun 2015 01:58:54 -0400 Subject: [PATCH 2/2] Fix armoire edge case --- common/script/index.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/script/index.coffee b/common/script/index.coffee index cc055a0b8d..6a00754b52 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -698,7 +698,7 @@ api.wrap = (user, main=true) -> pd.push(item) unless i != -1 cb? null, user.pushDevices - + # ------ # Inbox # ------ @@ -1579,7 +1579,7 @@ api.wrap = (user, main=true) -> _.merge plan.consecutive, {count:0, offset:0, gemCapExtra:0} user.markModified? 'purchased.plan' - # User is resting at the inn. + # User is resting at the inn. # On cron, buffs are cleared and all dailies are reset without performing damage if user.preferences.sleep is true user.stats.buffs = clearBuffs @@ -1715,7 +1715,7 @@ api.wrap = (user, main=true) -> owned = if window? then user.items.gear.owned else user.items.gear.owned.toObject() user.achievements.ultimateGearSets ?= {healer: false, wizard: false, rogue: false, warrior: false} content.classes.forEach (klass) -> - if user.achievements.ultimateGearSets[klass] is not true + if user.achievements.ultimateGearSets[klass] isnt true user.achievements.ultimateGearSets[klass] = _.reduce ['armor', 'shield', 'head', 'weapon'], (soFarGood, type) -> found = _.find content.gear.tree[type][klass], {last:true} soFarGood and (!found or owned[found.key]==true) #!found only true when weapon is two-handed (mages)