mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
@@ -66,18 +66,4 @@ describe('armoire', () => {
|
|||||||
const febuaryItems = makeArmoireIitemList();
|
const febuaryItems = makeArmoireIitemList();
|
||||||
expect(febuaryItems.length).to.equal(381);
|
expect(febuaryItems.length).to.equal(381);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets have at least 2 items', () => {
|
|
||||||
const armoire = makeArmoireIitemList();
|
|
||||||
const setMap = {};
|
|
||||||
forEach(armoire, item => {
|
|
||||||
if (setMap[item.set] === undefined) {
|
|
||||||
setMap[item.set] = 0;
|
|
||||||
}
|
|
||||||
setMap[item.set] += 1;
|
|
||||||
});
|
|
||||||
Object.keys(setMap).forEach(set => {
|
|
||||||
expect(setMap[set], set).to.be.at.least(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
import find from 'lodash/find';
|
|
||||||
import {
|
|
||||||
ARMOIRE_RELEASE_DATES,
|
|
||||||
EGGS_RELEASE_DATES,
|
|
||||||
HATCHING_POTIONS_RELEASE_DATES,
|
|
||||||
} from '../../website/common/script/content/constants/releaseDates';
|
|
||||||
import content from '../../website/common/script/content';
|
|
||||||
|
|
||||||
describe('releaseDates', () => {
|
|
||||||
describe('armoire', () => {
|
|
||||||
it('should only contain valid armoire names', () => {
|
|
||||||
Object.keys(ARMOIRE_RELEASE_DATES).forEach(key => {
|
|
||||||
expect(find(content.gear.flat, { set: key }), `${key} is not a valid armoire set`).to.exist;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should contain a valid year and month', () => {
|
|
||||||
Object.keys(ARMOIRE_RELEASE_DATES).forEach(key => {
|
|
||||||
const date = ARMOIRE_RELEASE_DATES[key];
|
|
||||||
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
|
|
||||||
expect(date.year).to.be.at.least(2023);
|
|
||||||
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
|
|
||||||
expect(date.month).to.be.within(1, 12);
|
|
||||||
expect(date.day).to.not.exist;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('eggs', () => {
|
|
||||||
it('should only contain valid egg names', () => {
|
|
||||||
Object.keys(EGGS_RELEASE_DATES).forEach(key => {
|
|
||||||
expect(content.eggs[key], `${key} is not a valid egg name`).to.exist;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should contain a valid year, month and date', () => {
|
|
||||||
Object.keys(EGGS_RELEASE_DATES).forEach(key => {
|
|
||||||
const date = EGGS_RELEASE_DATES[key];
|
|
||||||
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
|
|
||||||
expect(date.year).to.be.at.least(2024);
|
|
||||||
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
|
|
||||||
expect(date.month).to.be.within(1, 12);
|
|
||||||
expect(date.day, `${key} day is not a valid day`).to.be.a('number');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('hatchingPotions', () => {
|
|
||||||
it('should only contain valid potion names', () => {
|
|
||||||
Object.keys(HATCHING_POTIONS_RELEASE_DATES).forEach(key => {
|
|
||||||
expect(content.hatchingPotions[key], `${key} is not a valid potion name`).to.exist;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should contain a valid year, month and date', () => {
|
|
||||||
Object.keys(HATCHING_POTIONS_RELEASE_DATES).forEach(key => {
|
|
||||||
const date = HATCHING_POTIONS_RELEASE_DATES[key];
|
|
||||||
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
|
|
||||||
expect(date.year).to.be.at.least(2024);
|
|
||||||
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
|
|
||||||
expect(date.month).to.be.within(1, 12);
|
|
||||||
expect(date.day, `${key} day is not a valid day`).to.be.a('number');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -2,12 +2,13 @@ import defaults from 'lodash/defaults';
|
|||||||
import find from 'lodash/find';
|
import find from 'lodash/find';
|
||||||
import forEach from 'lodash/forEach';
|
import forEach from 'lodash/forEach';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import nconf from 'nconf';
|
|
||||||
import upperFirst from 'lodash/upperFirst';
|
import upperFirst from 'lodash/upperFirst';
|
||||||
import { ownsItem } from '../gear-helper';
|
import { ownsItem } from '../gear-helper';
|
||||||
import { ATTRIBUTES } from '../../../constants';
|
import { ATTRIBUTES } from '../../../constants';
|
||||||
import t from '../../translation';
|
import t from '../../translation';
|
||||||
import memoize from '../../../fns/datedMemoize';
|
import memoize from '../../../fns/datedMemoize';
|
||||||
|
import { ARMOIRE_RELEASE_DATES as releaseDates } from '../../constants/release_dates';
|
||||||
|
import { buildReleaseDate } from '../../is_released';
|
||||||
|
|
||||||
const armor = {
|
const armor = {
|
||||||
lunarArmor: {
|
lunarArmor: {
|
||||||
@@ -1833,19 +1834,7 @@ const weapon = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const SWITCHOVER_TIME = nconf.get('CONTENT_SWITCHOVER_TIME_OFFSET') || 0;
|
|
||||||
const releaseDay = 7;
|
const releaseDay = 7;
|
||||||
const releaseDates = {
|
|
||||||
somethingSpooky: { year: 2023, month: 10 },
|
|
||||||
cookingImplementsTwo: { year: 2023, month: 11 },
|
|
||||||
greenTrapper: { year: 2023, month: 12 },
|
|
||||||
schoolUniform: { year: 2024, month: 1 },
|
|
||||||
whiteLoungeWear: { year: 2024, month: 2 },
|
|
||||||
hatterSet: { year: 2024, month: 3 },
|
|
||||||
optimistSet: { year: 2024, month: 4 },
|
|
||||||
pottersSet: { year: 2024, month: 5 },
|
|
||||||
beachsideSet: { year: 2024, month: 6 },
|
|
||||||
};
|
|
||||||
|
|
||||||
forEach({
|
forEach({
|
||||||
armor,
|
armor,
|
||||||
@@ -1890,12 +1879,12 @@ forEach({
|
|||||||
|
|
||||||
function updateReleased (type) {
|
function updateReleased (type) {
|
||||||
const today = moment();
|
const today = moment();
|
||||||
const releaseDateEndPart = `${String(releaseDay).padStart(2, '0')}T${String(SWITCHOVER_TIME).padStart(2, '0')}:00-0500`;
|
|
||||||
const returnType = {};
|
const returnType = {};
|
||||||
forEach(type, (gearItem, gearKey) => {
|
forEach(type, (gearItem, gearKey) => {
|
||||||
let released;
|
let released;
|
||||||
if (releaseDates[gearItem.set]) {
|
if (releaseDates[gearItem.set]) {
|
||||||
const releaseDateString = `${releaseDates[gearItem.set].year}-${String(releaseDates[gearItem.set].month).padStart(2, '0')}-${releaseDateEndPart}`;
|
const components = releaseDates[gearItem.set];
|
||||||
|
const releaseDateString = buildReleaseDate(components.year, components.month, releaseDay);
|
||||||
released = today.isAfter(releaseDateString);
|
released = today.isAfter(releaseDateString);
|
||||||
} else {
|
} else {
|
||||||
released = true;
|
released = true;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import assign from 'lodash/assign';
|
|
||||||
import defaults from 'lodash/defaults';
|
import defaults from 'lodash/defaults';
|
||||||
import each from 'lodash/each';
|
import each from 'lodash/each';
|
||||||
|
import { assign } from 'lodash';
|
||||||
import t from './translation';
|
import t from './translation';
|
||||||
|
import datedMemoize from '../fns/datedMemoize';
|
||||||
|
import { filterReleased } from './is_released';
|
||||||
|
import { HATCHING_POTIONS_RELEASE_DATES } from './constants/release_dates';
|
||||||
|
|
||||||
function hasQuestAchievementFunction (key) {
|
function hasQuestAchievementFunction (key) {
|
||||||
return user => user.achievements.quests && user.achievements.quests[key] > 0;
|
return user => user.achievements.quests && user.achievements.quests[key] > 0;
|
||||||
@@ -193,8 +196,23 @@ each(wacky, (pot, key) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const all = assign({}, drops, premium, wacky);
|
function filterEggs (eggs) {
|
||||||
|
return filterReleased(eggs, 'key', HATCHING_POTIONS_RELEASE_DATES);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
const memoizedFilter = datedMemoize(filterEggs);
|
||||||
drops, premium, wacky, all,
|
|
||||||
|
export default {
|
||||||
|
get drops () {
|
||||||
|
return memoizedFilter({ memoizeConfig: true, identifier: 'drops' }, drops);
|
||||||
|
},
|
||||||
|
get premium () {
|
||||||
|
return memoizedFilter({ memoizeConfig: true, identifier: 'premium' }, premium);
|
||||||
|
},
|
||||||
|
get wacky () {
|
||||||
|
return memoizedFilter({ memoizeConfig: true, identifier: 'wacky' }, wacky);
|
||||||
|
},
|
||||||
|
get all () {
|
||||||
|
return assign({}, this.drops, this.premium, this.wacky);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user