diff --git a/test/common/ops/buy/buyMarketGear.js b/test/common/ops/buy/buyMarketGear.js index 444579e78d..f546331215 100644 --- a/test/common/ops/buy/buyMarketGear.js +++ b/test/common/ops/buy/buyMarketGear.js @@ -246,5 +246,14 @@ describe('shared.ops.buyMarketGear', () => { expect(user.items.gear.owned).to.have.property('head_special_2', true); }); + + it('does buyGear equipment if it is an armoire item that an user previously lost', () => { + user.stats.gp = 200; + user.items.gear.owned.shield_armoire_ramHornShield = false; + + buyGear(user, {params: {key: 'shield_armoire_ramHornShield'}}); + + expect(user.items.gear.owned).to.have.property('shield_armoire_ramHornShield', true); + }); }); }); diff --git a/website/common/script/ops/buy/buyMarketGear.js b/website/common/script/ops/buy/buyMarketGear.js index 3636685f0a..5f8728bf53 100644 --- a/website/common/script/ops/buy/buyMarketGear.js +++ b/website/common/script/ops/buy/buyMarketGear.js @@ -27,8 +27,11 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation { canUserPurchase (user, item) { super.canUserPurchase(user, item); + const checkKlass = item.klass && !['special', 'armoire', user.stats.class].includes(item.klass); + const checkSpecialClass = item.klass === 'special' && item.specialClass && item.specialClass !== user.stats.class; + // check for different class gear - if (item.klass !== 'special' && item.klass !== user.stats.class) { + if (checkKlass || checkSpecialClass) { throw new NotAuthorized(this.i18n('cannotBuyItem')); } }