mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
allow hatching potions to have a release date
This commit is contained in:
@@ -5,28 +5,50 @@ import {
|
|||||||
expectValidTranslationString,
|
expectValidTranslationString,
|
||||||
} from '../helpers/content.helper';
|
} from '../helpers/content.helper';
|
||||||
|
|
||||||
import * as hatchingPotions from '../../website/common/script/content/hatching-potions';
|
import hatchingPotions from '../../website/common/script/content/hatching-potions';
|
||||||
|
|
||||||
describe('hatchingPotions', () => {
|
describe('hatchingPotions', () => {
|
||||||
describe('all', () => {
|
let clock;
|
||||||
it('is a combination of drop, premium, and wacky potions', () => {
|
|
||||||
const dropNumber = Object.keys(hatchingPotions.drops).length;
|
|
||||||
const premiumNumber = Object.keys(hatchingPotions.premium).length;
|
|
||||||
const wackyNumber = Object.keys(hatchingPotions.wacky).length;
|
|
||||||
const allNumber = Object.keys(hatchingPotions.all).length;
|
|
||||||
|
|
||||||
expect(allNumber).to.be.greaterThan(0);
|
afterEach(() => {
|
||||||
expect(allNumber).to.equal(dropNumber + premiumNumber + wackyNumber);
|
if (clock) {
|
||||||
});
|
clock.restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('contains basic information about each potion', () => {
|
const potionTypes = [
|
||||||
each(hatchingPotions.all, (potion, key) => {
|
'drops',
|
||||||
expectValidTranslationString(potion.text);
|
'quests',
|
||||||
expectValidTranslationString(potion.notes);
|
'premium',
|
||||||
expect(potion.canBuy).to.be.a('function');
|
'wacky',
|
||||||
expect(potion.value).to.be.a('number');
|
];
|
||||||
expect(potion.key).to.equal(key);
|
potionTypes.forEach(potionType => {
|
||||||
|
describe(potionType, () => {
|
||||||
|
it('contains basic information about each potion', () => {
|
||||||
|
each(hatchingPotions.all, (potion, key) => {
|
||||||
|
expectValidTranslationString(potion.text);
|
||||||
|
expectValidTranslationString(potion.notes);
|
||||||
|
expect(potion.canBuy).to.be.a('function');
|
||||||
|
expect(potion.value).to.be.a('number');
|
||||||
|
expect(potion.key).to.equal(key);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not contain unreleased potions', () => {
|
||||||
|
clock = sinon.useFakeTimers(new Date('2024-05-20'));
|
||||||
|
const premiumPotions = hatchingPotions.premium;
|
||||||
|
expect(premiumPotions.Koi).to.not.exist;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Releases potions when appropriate without needing restarting', () => {
|
||||||
|
clock = sinon.useFakeTimers(new Date('2024-05-20'));
|
||||||
|
const mayPotions = hatchingPotions.premium;
|
||||||
|
clock.restore();
|
||||||
|
clock = sinon.useFakeTimers(new Date('2024-06-20'));
|
||||||
|
const junePotions = hatchingPotions.premium;
|
||||||
|
expect(junePotions.Koi).to.exist;
|
||||||
|
expect(Object.keys(mayPotions).length).to.equal(Object.keys(junePotions).length - 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
import QUEST_PETS from '../../website/common/script/content/quests/pets';
|
import QUEST_PETS from '../../website/common/script/content/quests/pets';
|
||||||
import QUEST_HATCHINGPOTIONS from '../../website/common/script/content/quests/potions';
|
import QUEST_HATCHINGPOTIONS from '../../website/common/script/content/quests/potions';
|
||||||
import QUEST_BUNDLES from '../../website/common/script/content/bundles';
|
import QUEST_BUNDLES from '../../website/common/script/content/bundles';
|
||||||
import { premium } from '../../website/common/script/content/hatching-potions';
|
import potions from '../../website/common/script/content/hatching-potions';
|
||||||
import SPELLS from '../../website/common/script/content/spells';
|
import SPELLS from '../../website/common/script/content/spells';
|
||||||
import QUEST_SEASONAL from '../../website/common/script/content/quests/seasonal';
|
import QUEST_SEASONAL from '../../website/common/script/content/quests/seasonal';
|
||||||
|
|
||||||
@@ -167,10 +167,10 @@ describe('Content Schedule', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('premium hatching potions', () => {
|
it('premium hatching potions', () => {
|
||||||
const potionKeys = Object.keys(premium);
|
const potionKeys = Object.keys(potions.premium);
|
||||||
Object.keys(MONTHLY_SCHEDULE).forEach(key => {
|
Object.keys(MONTHLY_SCHEDULE).forEach(key => {
|
||||||
const potions = MONTHLY_SCHEDULE[key][21].find(item => item.type === 'premiumHatchingPotions');
|
const monthlyPotions = MONTHLY_SCHEDULE[key][21].find(item => item.type === 'premiumHatchingPotions');
|
||||||
for (const potion of potions.items) {
|
for (const potion of monthlyPotions.items) {
|
||||||
expect(potion).to.be.a('string');
|
expect(potion).to.be.a('string');
|
||||||
expect(potionKeys).to.include(potion);
|
expect(potionKeys).to.include(potion);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import t from '../../website/common/script/content/translation';
|
|||||||
|
|
||||||
import * as stable from '../../website/common/script/content/stable';
|
import * as stable from '../../website/common/script/content/stable';
|
||||||
import eggs from '../../website/common/script/content/eggs';
|
import eggs from '../../website/common/script/content/eggs';
|
||||||
import * as potions from '../../website/common/script/content/hatching-potions';
|
import potions from '../../website/common/script/content/hatching-potions';
|
||||||
|
|
||||||
describe('stable', () => {
|
describe('stable', () => {
|
||||||
describe('dropPets', () => {
|
describe('dropPets', () => {
|
||||||
|
|||||||
@@ -13,3 +13,7 @@ export const ARMOIRE_RELEASE_DATES = {
|
|||||||
export const EGGS_RELEASE_DATES = {
|
export const EGGS_RELEASE_DATES = {
|
||||||
Giraffe: { year: 2024, month: 6, day: 1 },
|
Giraffe: { year: 2024, month: 6, day: 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const HATCHING_POTIONS_RELEASE_DATES = {
|
||||||
|
Koi: { year: 2024, month: 6, day: 1 },
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import defaults from 'lodash/defaults';
|
import defaults from 'lodash/defaults';
|
||||||
import each from 'lodash/each';
|
import each from 'lodash/each';
|
||||||
|
import assign from 'lodash/assign';
|
||||||
import t from './translation';
|
import t from './translation';
|
||||||
import { filterReleased } from './is_released';
|
import { filterReleased } from './is_released';
|
||||||
import { EGGS_RELEASE_DATES } from './constants/release_dates';
|
import { EGGS_RELEASE_DATES } from './constants/release_dates';
|
||||||
@@ -425,4 +426,7 @@ export default {
|
|||||||
get quests () {
|
get quests () {
|
||||||
return memoizedFilter({ memoizeConfig: true, identifier: 'quests' }, quests);
|
return memoizedFilter({ memoizeConfig: true, identifier: 'quests' }, quests);
|
||||||
},
|
},
|
||||||
|
get all () {
|
||||||
|
return assign({}, this.drops, this.quests);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import defaults from 'lodash/defaults';
|
import defaults from 'lodash/defaults';
|
||||||
import each from 'lodash/each';
|
import each from 'lodash/each';
|
||||||
import assign from 'lodash/assign';
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import t from './translation';
|
import t from './translation';
|
||||||
import { tasksByCategory } from './tasks';
|
import { tasksByCategory } from './tasks';
|
||||||
@@ -20,7 +19,7 @@ import {
|
|||||||
import achievements from './achievements';
|
import achievements from './achievements';
|
||||||
|
|
||||||
import eggs from './eggs';
|
import eggs from './eggs';
|
||||||
import * as hatchingPotions from './hatching-potions';
|
import hatchingPotions from './hatching-potions';
|
||||||
import * as stable from './stable';
|
import * as stable from './stable';
|
||||||
import gear from './gear';
|
import gear from './gear';
|
||||||
import { quests, questsByLevel, userCanOwnQuestCategories } from './quests';
|
import { quests, questsByLevel, userCanOwnQuestCategories } from './quests';
|
||||||
@@ -168,7 +167,7 @@ api.special = api.spells.special;
|
|||||||
|
|
||||||
api.dropEggs = eggs.drops;
|
api.dropEggs = eggs.drops;
|
||||||
api.questEggs = eggs.quests;
|
api.questEggs = eggs.quests;
|
||||||
api.eggs = assign({}, eggs.drops, eggs.quests);
|
api.eggs = eggs.all;
|
||||||
|
|
||||||
api.timeTravelStable = {
|
api.timeTravelStable = {
|
||||||
pets: {
|
pets: {
|
||||||
|
|||||||
@@ -2,17 +2,9 @@ import each from 'lodash/each';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { EVENTS } from './constants/events';
|
import { EVENTS } from './constants/events';
|
||||||
import allEggs from './eggs';
|
import allEggs from './eggs';
|
||||||
import {
|
import allPotions from './hatching-potions';
|
||||||
drops as dropPotions,
|
|
||||||
premium as premiumPotions,
|
|
||||||
wacky as wackyPotions,
|
|
||||||
} from './hatching-potions';
|
|
||||||
import t from './translation';
|
import t from './translation';
|
||||||
|
|
||||||
const STABLE_RELEASE_DATES = {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const petInfo = {};
|
const petInfo = {};
|
||||||
const mountInfo = {};
|
const mountInfo = {};
|
||||||
|
|
||||||
@@ -131,10 +123,10 @@ const canFindSpecial = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const [dropPets, dropMounts] = constructSet('drop', allEggs.drops, dropPotions);
|
const [dropPets, dropMounts] = constructSet('drop', allEggs.drops, allPotions.drops);
|
||||||
const [premiumPets, premiumMounts] = constructSet('premium', allEggs.drops, premiumPotions);
|
const [premiumPets, premiumMounts] = constructSet('premium', allEggs.drops, allPotions.premium);
|
||||||
const [questPets, questMounts] = constructSet('quest', allEggs.quests, dropPotions);
|
const [questPets, questMounts] = constructSet('quest', allEggs.quests, allPotions.drops);
|
||||||
const wackyPets = constructSet('wacky', allEggs.drops, wackyPotions, false);
|
const wackyPets = constructSet('wacky', allEggs.drops, allPotions.wacky, false);
|
||||||
|
|
||||||
const specialPets = {
|
const specialPets = {
|
||||||
'Wolf-Veteran': 'veteranWolf',
|
'Wolf-Veteran': 'veteranWolf',
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import allEggs from '../content/eggs';
|
import allEggs from '../content/eggs';
|
||||||
import { drops as hatchingPotions } from '../content/hatching-potions';
|
import allPotions from '../content/hatching-potions';
|
||||||
import randomVal from '../libs/randomVal';
|
import randomVal from '../libs/randomVal';
|
||||||
|
|
||||||
export default function firstDrops (user) {
|
export default function firstDrops (user) {
|
||||||
const eggDrop = randomVal(allEggs.drops);
|
const eggDrop = randomVal(allEggs.drops);
|
||||||
const potionDrop = randomVal(hatchingPotions);
|
const potionDrop = randomVal(allPotions.drops);
|
||||||
|
|
||||||
user.items.eggs = {
|
user.items.eggs = {
|
||||||
...user.items.eggs,
|
...user.items.eggs,
|
||||||
|
|||||||
Reference in New Issue
Block a user