mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
fix seasonal gear filtering
This commit is contained in:
@@ -3,6 +3,10 @@ import {
|
|||||||
generateUser,
|
generateUser,
|
||||||
} from '../../helpers/common.helper';
|
} from '../../helpers/common.helper';
|
||||||
|
|
||||||
|
import {
|
||||||
|
currentSeason,
|
||||||
|
} from '../../../website/common/script/libs/shops-seasonal.config';
|
||||||
|
|
||||||
describe('shops', () => {
|
describe('shops', () => {
|
||||||
const user = generateUser();
|
const user = generateUser();
|
||||||
|
|
||||||
@@ -39,6 +43,7 @@ describe('shops', () => {
|
|||||||
shopCategories.forEach(category => {
|
shopCategories.forEach(category => {
|
||||||
category.items.forEach(item => {
|
category.items.forEach(item => {
|
||||||
expect(item.event).to.not.exist;
|
expect(item.event).to.not.exist;
|
||||||
|
expect(item.season).to.not.exist;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -60,12 +65,12 @@ describe('shops', () => {
|
|||||||
|
|
||||||
const gearCategories = shared.shops.getMarketGearCategories(contributor);
|
const gearCategories = shared.shops.getMarketGearCategories(contributor);
|
||||||
const specialCategory = gearCategories.find(o => o.identifier === 'none');
|
const specialCategory = gearCategories.find(o => o.identifier === 'none');
|
||||||
expect(specialCategory.items.find(item => item.key === 'weapon_special_1'));
|
expect(specialCategory.items.find(item => item.key === 'weapon_special_1'), 'weapon_special_1');
|
||||||
expect(specialCategory.items.find(item => item.key === 'armor_special_1'));
|
expect(specialCategory.items.find(item => item.key === 'armor_special_1'), 'armor_special_1');
|
||||||
expect(specialCategory.items.find(item => item.key === 'head_special_1'));
|
expect(specialCategory.items.find(item => item.key === 'head_special_1'), 'head_special_1');
|
||||||
expect(specialCategory.items.find(item => item.key === 'shield_special_1'));
|
expect(specialCategory.items.find(item => item.key === 'shield_special_1'), 'shield_special_1');
|
||||||
expect(specialCategory.items.find(item => item.key === 'weapon_special_critical'));
|
expect(specialCategory.items.find(item => item.key === 'weapon_special_critical'), 'weapon_special_critical');
|
||||||
expect(specialCategory.items.find(item => item.key === 'weapon_armoire_basicCrossbow'));// eslint-disable-line camelcase
|
expect(specialCategory.items.find(item => item.key === 'weapon_armoire_basicCrossbow'), 'weapon_armoire_basicCrossbow');// eslint-disable-line camelcase
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show gear when it is all owned', () => {
|
it('does not show gear when it is all owned', () => {
|
||||||
@@ -234,7 +239,7 @@ describe('shops', () => {
|
|||||||
it('does not return items with event data', async () => {
|
it('does not return items with event data', async () => {
|
||||||
shopCategories.forEach(category => {
|
shopCategories.forEach(category => {
|
||||||
category.items.forEach(item => {
|
category.items.forEach(item => {
|
||||||
expect(item.event).to.not.exist;
|
expect(item.event, item.key).to.not.exist;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -243,7 +248,7 @@ describe('shops', () => {
|
|||||||
_.each(shopCategories, category => {
|
_.each(shopCategories, category => {
|
||||||
_.each(category.items, item => {
|
_.each(category.items, item => {
|
||||||
_.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'type'], key => {
|
_.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'type'], key => {
|
||||||
expect(_.has(item, key)).to.eql(true);
|
expect(_.has(item, key), item.key).to.eql(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -252,8 +257,16 @@ describe('shops', () => {
|
|||||||
it('items have a valid end date', () => {
|
it('items have a valid end date', () => {
|
||||||
shopCategories.forEach(category => {
|
shopCategories.forEach(category => {
|
||||||
category.items.forEach(item => {
|
category.items.forEach(item => {
|
||||||
expect(item.end).to.be.a('date');
|
expect(item.end, item.key).to.be.a('date');
|
||||||
expect(item.end).to.be.greaterThan(today);
|
expect(item.end, item.key).to.be.greaterThan(today);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('items match current season', () => {
|
||||||
|
shopCategories.forEach(category => {
|
||||||
|
category.items.forEach(item => {
|
||||||
|
expect(item.season).to.eql(currentSeason);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -17,6 +17,7 @@ function isSeasonalEventKey (key) {
|
|||||||
function fillSpecialGear (gearItems, gearType, value, stats) {
|
function fillSpecialGear (gearItems, gearType, value, stats) {
|
||||||
Object.keys(gearItems).forEach(key => {
|
Object.keys(gearItems).forEach(key => {
|
||||||
if (isSeasonalEventKey(key)) {
|
if (isSeasonalEventKey(key)) {
|
||||||
|
const season = key.split(/(?=[A-Z])/)[1];
|
||||||
let klass = key.split(/(?=[A-Z])/)[1].toLowerCase();
|
let klass = key.split(/(?=[A-Z])/)[1].toLowerCase();
|
||||||
if (klass === 'mage') {
|
if (klass === 'mage') {
|
||||||
klass = 'wizard';
|
klass = 'wizard';
|
||||||
@@ -29,6 +30,7 @@ function fillSpecialGear (gearItems, gearType, value, stats) {
|
|||||||
text: t(`${textKey}Text`),
|
text: t(`${textKey}Text`),
|
||||||
notes: t(`${textKey}Notes`, stats),
|
notes: t(`${textKey}Notes`, stats),
|
||||||
value: actualValue,
|
value: actualValue,
|
||||||
|
season,
|
||||||
}, stats);
|
}, stats);
|
||||||
if (klass === 'wizard') {
|
if (klass === 'wizard') {
|
||||||
defaults(gearItems[key], {
|
defaults(gearItems[key], {
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ shops.getMarketGearCategories = function getMarketGear (user, language) {
|
|||||||
|
|
||||||
const result = filter(content.gear.flat, gearItem => {
|
const result = filter(content.gear.flat, gearItem => {
|
||||||
if (gearItem.klass === classType) return true;
|
if (gearItem.klass === classType) return true;
|
||||||
|
if (gearItem.season) return false;
|
||||||
const classShift = {
|
const classShift = {
|
||||||
items: user.items,
|
items: user.items,
|
||||||
stats: {
|
stats: {
|
||||||
|
|||||||
Reference in New Issue
Block a user