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:
@@ -584,12 +584,20 @@ let backgrounds = {
|
||||
};
|
||||
/* eslint-enable quote-props */
|
||||
|
||||
let flat = {};
|
||||
|
||||
forOwn(backgrounds, function prefillBackgroundSet (backgroundsInSet, set) {
|
||||
forOwn(backgroundsInSet, function prefillBackground (background, bgKey) {
|
||||
background.key = bgKey;
|
||||
background.set = set;
|
||||
background.price = 7;
|
||||
|
||||
flat[bgKey] = background;
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = backgrounds;
|
||||
module.exports = {
|
||||
tree: backgrounds,
|
||||
flat,
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from './quests';
|
||||
|
||||
import appearances from './appearance';
|
||||
import backgrounds from './appearance/backgrounds.js';
|
||||
import backgrounds from './appearance/backgrounds';
|
||||
import spells from './spells';
|
||||
import subscriptionBlocks from './subscriptionBlocks';
|
||||
import faq from './faq';
|
||||
@@ -523,7 +523,8 @@ each(api.food, (food, key) => {
|
||||
|
||||
api.appearances = appearances;
|
||||
|
||||
api.backgrounds = backgrounds;
|
||||
api.backgrounds = backgrounds.tree;
|
||||
api.backgroundsFlat = backgrounds.flat;
|
||||
|
||||
api.userDefaults = {
|
||||
habits: [
|
||||
|
||||
@@ -137,7 +137,7 @@ module.exports = function getItemInfo (user, type, item, language = 'en') {
|
||||
};
|
||||
}) : undefined,
|
||||
lvl: item.lvl,
|
||||
class: locked ? `inventory_quest_scroll_locked inventory_quest_scroll_${item.key}_locked` : `inventory_quest_scroll inventory_quest_scroll_${item.key}`,
|
||||
class: locked ? `inventory_quest_scroll_${item.key}_locked` : `inventory_quest_scroll_${item.key}`,
|
||||
purchaseType: 'quests',
|
||||
path: `quests.${item.key}`,
|
||||
pinType: 'quests',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user