mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
[WIP] shops + market gear api (#8980)
* lock other classes gear * fix avatar in equip-gear-modal * fix seasonal shop * seasonal : new gear type order * fix pin gear (and get new gear on buying) * API: /shops/market-gear - refactoring pinnedGearUtils - move _isPinned to common/libs * use shops.getMarketGearCategories to list the marketGear * use shops.getMarketCategories instead of API-call * mark gear reward items as locked * purchase time-travelers stuff + update view + use method instead of http-api + add missing mammoth shop image * Time Travelers Shop: open/closed state * time travelers: show gear preview + hide sidebar if closed * update resized images * fix lint
This commit is contained in:
@@ -2,6 +2,7 @@ import values from 'lodash/values';
|
||||
import map from 'lodash/map';
|
||||
import keys from 'lodash/keys';
|
||||
import each from 'lodash/each';
|
||||
import filter from 'lodash/filter';
|
||||
import eachRight from 'lodash/eachRight';
|
||||
import toArray from 'lodash/toArray';
|
||||
import pickBy from 'lodash/pickBy';
|
||||
@@ -9,6 +10,7 @@ import sortBy from 'lodash/sortBy';
|
||||
import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import getItemInfo from './getItemInfo';
|
||||
import updateStore from './updateStore';
|
||||
|
||||
let shops = {};
|
||||
|
||||
@@ -69,6 +71,55 @@ shops.getMarketCategories = function getMarket (user, language) {
|
||||
return categories;
|
||||
};
|
||||
|
||||
function getClassName (classType, language) {
|
||||
if (classType === 'wizard') {
|
||||
return i18n.t('mage', language);
|
||||
} else {
|
||||
return i18n.t(classType, language);
|
||||
}
|
||||
}
|
||||
|
||||
shops.checkMarketGearLocked = function checkMarketGearLocked (user, items) {
|
||||
let result = filter(items, ['pinType', 'marketGear']);
|
||||
|
||||
let availableGear = map(updateStore(user), (item) => getItemInfo(user, 'marketGear', item).path);
|
||||
|
||||
for (let gear of result) {
|
||||
if (gear.klass !== user.stats.class) {
|
||||
gear.locked = true;
|
||||
}
|
||||
|
||||
if (!gear.locked && !availableGear.includes(gear.path)) {
|
||||
gear.locked = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
shops.getMarketGearCategories = function getMarketGear (user, language) {
|
||||
let categories = [];
|
||||
|
||||
for (let classType of content.classes) {
|
||||
let category = {
|
||||
identifier: classType,
|
||||
text: getClassName(classType, language),
|
||||
};
|
||||
|
||||
let result = filter(content.gear.flat, ['klass', classType]);
|
||||
category.items = map(result, (e) => {
|
||||
let newItem = getItemInfo(user, 'marketGear', e);
|
||||
|
||||
return newItem;
|
||||
});
|
||||
|
||||
shops.checkMarketGearLocked(user, category.items);
|
||||
|
||||
categories.push(category);
|
||||
}
|
||||
|
||||
return categories;
|
||||
};
|
||||
|
||||
|
||||
shops.getQuestShopCategories = function getQuestShopCategories (user, language) {
|
||||
let categories = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user