mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
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:
@@ -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