Items/Market/Quests/misc fixes (#8987)

* use countBadge instead of class

* generic purchase action from buyModal to handle all kind of purchases - able to purchase backgrounds - return backgrounds as flat array

* List MysteryItem & Hourglass in Inventory/Items

* add Subscribers Gem Item (purchase by gold)

* fix mysterybox

* sort unlocked gear first

* add orb of rebirth to market

* remove old quest scroll + class of the quest items

* more padding on countBadge

* use the generic purchase on quests
This commit is contained in:
negue
2017-08-26 12:18:55 +02:00
committed by GitHub
parent 0233f7b486
commit c35e4f5750
19 changed files with 263 additions and 73 deletions

View File

@@ -9,6 +9,10 @@ import {
BadRequest,
} from '../libs/errors';
import { removeItemByPath } from './pinnedGearUtils';
import getItemInfo from '../libs/getItemInfo';
import content from '../content/index';
// If item is already purchased -> equip it
// Otherwise unlock it
module.exports = function unlock (user, req = {}, analytics) {
@@ -75,10 +79,11 @@ module.exports = function unlock (user, req = {}, analytics) {
setWith(user, `purchased.${pathPart}`, true, Object);
});
} else {
let split = path.split('.');
let value = split.pop();
let key = split.join('.');
if (alreadyOwns) { // eslint-disable-line no-lonely-if
let split = path.split('.');
let value = split.pop();
let key = split.join('.');
if (key === 'background' && value === user.preferences.background) {
value = '';
}
@@ -88,6 +93,10 @@ module.exports = function unlock (user, req = {}, analytics) {
} else {
// Using Object so path[1] won't create an array but an object {path: {1: value}}
setWith(user, `purchased.${path}`, true, Object);
let backgroundContent = content.backgroundsFlat[value];
let itemInfo = getItemInfo(user, 'background', backgroundContent);
removeItemByPath(user, itemInfo.path);
}
}